@lobu/runtime-server 24.3.0 → 24.5.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 (290) hide show
  1. package/dist/catalogs/skills.json +2 -2
  2. package/dist/component.json +1 -1
  3. package/dist/connectors/postgres.ts +77 -48
  4. package/dist/db/migrations/20261101010000_public_source_type_references.sql +157 -0
  5. package/dist/dependencies.bun.lock +115 -144
  6. package/dist/owletto/dist/assets/_-CCWuGXtQ.js +2 -0
  7. package/dist/owletto/dist/assets/_-DOJW1D-I.js +3 -0
  8. package/dist/owletto/dist/assets/_agentId-CJhQbi6k.js +2 -0
  9. package/dist/owletto/dist/assets/_agentId-DD4K1i6V.js +2 -0
  10. package/dist/owletto/dist/assets/_automationId-Cbd7B0mP.js +2 -0
  11. package/dist/owletto/dist/assets/_connectorKey._connectionId-DFpPep9B.js +2 -0
  12. package/dist/owletto/dist/assets/_connectorKey.index-n3iSDT74.js +2 -0
  13. package/dist/owletto/dist/assets/_conversationId-B1yGIGA9.js +2 -0
  14. package/dist/owletto/dist/assets/_eventId-B1H0-vD7.js +2 -0
  15. package/dist/owletto/dist/assets/_name-D30_V03t.js +2 -0
  16. package/dist/owletto/dist/assets/_owner-Be8O41u8.js +3 -0
  17. package/dist/owletto/dist/assets/_shape-C6YbloRh.js +2 -0
  18. package/dist/owletto/dist/assets/_skillKey-BMPvvoOI.js +2 -0
  19. package/dist/owletto/dist/assets/_slug-Bc4YIEA2.js +2 -0
  20. package/dist/owletto/dist/assets/_view-aoFDwEld.js +2 -0
  21. package/dist/owletto/dist/assets/_viewKey-DuNHc3cc.js +2 -0
  22. package/dist/owletto/dist/assets/_viewKey-rJ7A1zNx.js +2 -0
  23. package/dist/owletto/dist/assets/accept-invitation-pUl-c1KQ.js +2 -0
  24. package/dist/owletto/dist/assets/activity-route-view-DN0ZEAzr.js +2 -0
  25. package/dist/owletto/dist/assets/{agent-card-controls-DiU7Un5w.js → agent-card-controls-C5jNWgfq.js} +2 -2
  26. package/dist/owletto/dist/assets/agent-client-setup-list-DbXtJTsO.js +4 -0
  27. package/dist/owletto/dist/assets/agent-connect-pages-DcTuiSt9.js +2 -0
  28. package/dist/owletto/dist/assets/agent-editor-form-CdA5vLr8.js +2 -0
  29. package/dist/owletto/dist/assets/agent-guardrails-route-BJyfalBY.js +2 -0
  30. package/dist/owletto/dist/assets/agent-list-row-rF5LH-3k.js +2 -0
  31. package/dist/owletto/dist/assets/{agent-loading-shells-CamDtzHY.js → agent-loading-shells-ClY_O6lb.js} +2 -2
  32. package/dist/owletto/dist/assets/{agent-permissions-matrix-CgsQ8BK_.js → agent-permissions-matrix-bP1Qihv7.js} +2 -2
  33. package/dist/owletto/dist/assets/{agent-skill-context-lWbXKEm1.js → agent-skill-context-BAaGpvfS.js} +2 -2
  34. package/dist/owletto/dist/assets/agent-skills-route-Bv5luNdw.js +2 -0
  35. package/dist/owletto/dist/assets/agent-tab-intro-ednTs4WF.js +2 -0
  36. package/dist/owletto/dist/assets/agent-thread-WNk2HapT.js +6 -0
  37. package/dist/owletto/dist/assets/agent-thread-storage-U6htL3ad.js +2 -0
  38. package/dist/owletto/dist/assets/agents-DY2S2SGE.js +2 -0
  39. package/dist/owletto/dist/assets/agents-workbench-bPTjdVS1.js +2 -0
  40. package/dist/owletto/dist/assets/app._appId-DrL5H5lB.js +2 -0
  41. package/dist/owletto/dist/assets/assist-composer-ClfFEVx7.js +2 -0
  42. package/dist/owletto/dist/assets/automation-detail-content-dFy1Huas.js +2 -0
  43. package/dist/owletto/dist/assets/automation-row-DCHM--aD.js +2 -0
  44. package/dist/owletto/dist/assets/automations-DY2S2SGE.js +2 -0
  45. package/dist/owletto/dist/assets/{calendar-DDCCSPW6.js → calendar-Ck0yOLYu.js} +2 -2
  46. package/dist/owletto/dist/assets/{callback-DFciMR8u.js → callback-DRABUOha.js} +2 -2
  47. package/dist/owletto/dist/assets/{card-BCsbrdGs.js → card-Bdi7VEwo.js} +2 -2
  48. package/dist/owletto/dist/assets/change-summary-PBoM6Asb.js +2 -0
  49. package/dist/owletto/dist/assets/{claim-BRua2b_7.js → claim-CUIG1Oc-.js} +2 -2
  50. package/dist/owletto/dist/assets/client-activity-scopes-CXOWB5co.js +2 -0
  51. package/dist/owletto/dist/assets/{client-rows-DiJQ5D1z.js → client-rows-36VnmgMK.js} +2 -2
  52. package/dist/owletto/dist/assets/clients-BJRcMk1A.js +2 -0
  53. package/dist/owletto/dist/assets/code-editor-DNuRKde1.js +16 -0
  54. package/dist/owletto/dist/assets/connect-CMcEQWls.js +2 -0
  55. package/dist/owletto/dist/assets/connect-menu-C-B-1xGR.js +2 -0
  56. package/dist/owletto/dist/assets/connect._clientId-tGipxP5a.js +2 -0
  57. package/dist/owletto/dist/assets/connected._clientId-DSGU78eV.js +2 -0
  58. package/dist/owletto/dist/assets/connected._clientId.activity-CPLbry8R.js +2 -0
  59. package/dist/owletto/dist/assets/connected._clientId.index-jSnGvzYs.js +2 -0
  60. package/dist/owletto/dist/assets/connection-feed-detail-BIlkK0Pd.js +2 -0
  61. package/dist/owletto/dist/assets/connection-q1bdnxCN.js +2 -0
  62. package/dist/owletto/dist/assets/{connections-browser-BMV8bf54.js → connections-browser-V-3td9DB.js} +2 -2
  63. package/dist/owletto/dist/assets/{connector-boxes-DqZA-FdG.js → connector-boxes-lFc-WP83.js} +2 -2
  64. package/dist/owletto/dist/assets/connector-page-shell-Cs1SjrYB.js +2 -0
  65. package/dist/owletto/dist/assets/{connector-provenance-BIg8P8WY.js → connector-provenance-aJFeeRIC.js} +2 -2
  66. package/dist/owletto/dist/assets/{connector-scope-lists-CJYz53YF.js → connector-scope-lists--vNdbOn0.js} +2 -2
  67. package/dist/owletto/dist/assets/connectors-BsvDMdsQ.js +2 -0
  68. package/dist/owletto/dist/assets/consent-DJV78pnz.js +2 -0
  69. package/dist/owletto/dist/assets/copy-button-DjMWgrBf.js +2 -0
  70. package/dist/owletto/dist/assets/{core.esm-A1UnFbGs.js → core.esm-CQzL3ObT.js} +3 -3
  71. package/dist/owletto/dist/assets/create-BmKx5vq3.js +2 -0
  72. package/dist/owletto/dist/assets/create-Rt0RbiD4.js +2 -0
  73. package/dist/owletto/dist/assets/create-automation-form-PEmSLMD6.js +3 -0
  74. package/dist/owletto/dist/assets/create-jBEuveV1.js +2 -0
  75. package/dist/owletto/dist/assets/create._connectorKey-DcxhYIYC.js +2 -0
  76. package/dist/owletto/dist/assets/device-Ba3RsIgb.js +2 -0
  77. package/dist/owletto/dist/assets/device-pin-tombstone-C79KIAIK.js +2 -0
  78. package/dist/owletto/dist/assets/device._deviceId-CIaoq9co.js +2 -0
  79. package/dist/owletto/dist/assets/{entity-avatar-CEV4ttUQ.js → entity-avatar-TVKjZxWQ.js} +2 -2
  80. package/dist/owletto/dist/assets/entity-options-daOOQo7O.js +2 -0
  81. package/dist/owletto/dist/assets/entity-page-BfJXvbxn.js +2 -0
  82. package/dist/owletto/dist/assets/entity-type-page-BLwH6qa7.js +2 -0
  83. package/dist/owletto/dist/assets/event-card-DVUB8my6.js +2 -0
  84. package/dist/owletto/dist/assets/event-detail-DkY95e5b.js +2 -0
  85. package/dist/owletto/dist/assets/{events-feed-VfU4csn2.js → events-feed-B9CZHI_P.js} +2 -2
  86. package/dist/owletto/dist/assets/filter-bar-wPaR12SS.js +2 -0
  87. package/dist/owletto/dist/assets/{full-page-spinner-C1Q_jEzD.js → full-page-spinner-BqmckkOf.js} +2 -2
  88. package/dist/owletto/dist/assets/guardrails-Csusrok2.js +2 -0
  89. package/dist/owletto/dist/assets/identity-Dmg3STO8.js +2 -0
  90. package/dist/owletto/dist/assets/index--ZWegctR.js +2 -0
  91. package/dist/owletto/dist/assets/{index-DFyBbp7b.js → index-B0kw2lFL.js} +2 -2
  92. package/dist/owletto/dist/assets/index-BKrdVwW9.js +2 -0
  93. package/dist/owletto/dist/assets/index-BUBcNNUY.js +2 -0
  94. package/dist/owletto/dist/assets/index-BUDr4-Yv.js +2 -0
  95. package/dist/owletto/dist/assets/index-BYPQWVwD.js +2 -0
  96. package/dist/owletto/dist/assets/index-BfpaPJPj.js +2 -0
  97. package/dist/owletto/dist/assets/index-BicNFLBW.js +2 -0
  98. package/dist/owletto/dist/assets/index-Bsdv5aks.js +2 -0
  99. package/dist/owletto/dist/assets/index-C186T2Rw.js +53 -0
  100. package/dist/owletto/dist/assets/index-CX0pJ9j9.js +2 -0
  101. package/dist/owletto/dist/assets/{index-DQxzeM37.js → index-CsrT07TJ.js} +2 -2
  102. package/dist/owletto/dist/assets/index-DdBTTN3y.js +7899 -0
  103. package/dist/owletto/dist/assets/index-DdYWarql.css +1 -0
  104. package/dist/owletto/dist/assets/index-JYEIN8nM.js +2 -0
  105. package/dist/owletto/dist/assets/index-Vcq4gwWv.js +2 -0
  106. package/dist/owletto/dist/assets/{index-DNtYqkiA.js → index-ijqrJaRB.js} +2 -2
  107. package/dist/owletto/dist/assets/{index-yIub2xUM.js → index-ikp_mTsf.js} +2 -2
  108. package/dist/owletto/dist/assets/json-diff-BaLL4Fsu.js +14 -0
  109. package/dist/owletto/dist/assets/{list-skeleton-Kzxi2OXB.js → list-skeleton-CXDLkYTg.js} +2 -2
  110. package/dist/owletto/dist/assets/login-u6LCgDYG.js +2 -0
  111. package/dist/owletto/dist/assets/{logout-Dt_VDilG.js → logout-JhmuWJEH.js} +2 -2
  112. package/dist/owletto/dist/assets/manage-gear-D8LMhehh.js +2 -0
  113. package/dist/owletto/dist/assets/{member-scope-gate-De75CR7W.js → member-scope-gate-4FQ0aanZ.js} +2 -2
  114. package/dist/owletto/dist/assets/memory-browse-page-CNZJbCJC.js +74 -0
  115. package/dist/owletto/dist/assets/model-jL871x2J.js +2 -0
  116. package/dist/owletto/dist/assets/model-selector-CgU8SJMF.js +2 -0
  117. package/dist/owletto/dist/assets/models-jdemgIZk.js +2 -0
  118. package/dist/owletto/dist/assets/nav-pill-DrFkuyUQ.js +2 -0
  119. package/dist/owletto/dist/assets/new-CcJOd5aH.js +2 -0
  120. package/dist/owletto/dist/assets/{new-BbdwuJPm.js → new-DgE1pVV0.js} +2 -2
  121. package/dist/owletto/dist/assets/new-OWwrYckd.js +2 -0
  122. package/dist/owletto/dist/assets/organization-CKM_oFX3.js +2 -0
  123. package/dist/owletto/dist/assets/peek-pane-content-D68BjguQ.js +2 -0
  124. package/dist/owletto/dist/assets/pending-seed-sml8Uf6e.js +2 -0
  125. package/dist/owletto/dist/assets/permissions-BvA9SATv.js +2 -0
  126. package/dist/owletto/dist/assets/proposal-review-shell-D6KABxah.js +2 -0
  127. package/dist/owletto/dist/assets/public-shell-ready-BIVCHQHe.js +2 -0
  128. package/dist/owletto/dist/assets/record-activity-C9gVBbF0.js +2 -0
  129. package/dist/owletto/dist/assets/{record-session-D07szzqN.js → record-session-R-uHNuby.js} +2 -2
  130. package/dist/owletto/dist/assets/{renderer-AJxSmE3-.js → renderer-DXfJaCCa.js} +23 -23
  131. package/dist/owletto/dist/assets/reset-password-Mx3baeNc.js +2 -0
  132. package/dist/owletto/dist/assets/run-activity-link-CaIBSRQj.js +2 -0
  133. package/dist/owletto/dist/assets/run-initiator-BvzQJYW9.js +2 -0
  134. package/dist/owletto/dist/assets/runs-fFJ1lPnw.js +2 -0
  135. package/dist/owletto/dist/assets/runs-panel-DEnZHTa5.js +2 -0
  136. package/dist/owletto/dist/assets/runs-table-XGnxJl7S.js +2 -0
  137. package/dist/owletto/dist/assets/{schema-type-editor-panel-C_Es0qDf.js → schema-type-editor-panel-C0_9VcSs.js} +2 -2
  138. package/dist/owletto/dist/assets/settings-CP4PjMQA.js +2 -0
  139. package/dist/owletto/dist/assets/settings-CgaUJMHH.js +2 -0
  140. package/dist/owletto/dist/assets/skills-D-e_h3a9.js +2 -0
  141. package/dist/owletto/dist/assets/{source-record-panels-CjFPgKKJ.js → source-record-panels-Bh0n4gGw.js} +2 -2
  142. package/dist/owletto/dist/assets/{status-dot-CSBtKT4g.js → status-dot-Cpq63I7p.js} +2 -2
  143. package/dist/owletto/dist/assets/{table-DHM-vCxP.js → table-BUqshjxa.js} +2 -2
  144. package/dist/owletto/dist/assets/{use-automations-C4TSie1i.js → use-automations-BLNjxq2K.js} +2 -2
  145. package/dist/owletto/dist/assets/use-login-redirect-CmyQW7GT.js +2 -0
  146. package/dist/owletto/dist/assets/{use-mention-search-PfZrNbu_.js → use-mention-search-dn3ws1WB.js} +3 -3
  147. package/dist/owletto/dist/assets/use-scroll-sentinel-DRyBMueA.js +2 -0
  148. package/dist/owletto/dist/assets/view-param-filters-CER47Tlz.js +2 -0
  149. package/dist/owletto/dist/assets/{views-access-required-2ubIf_3N.js → views-access-required-C_b9itZ2.js} +2 -2
  150. package/dist/owletto/dist/index.html +2 -2
  151. package/dist/server-main.bundle.mjs +54218 -51082
  152. package/dist/server.bundle.mjs +5 -5
  153. package/dist/verify.mjs +1 -1
  154. package/npm-shrinkwrap.json +351 -371
  155. package/package.json +3 -4
  156. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +8 -2
  157. package/vendor/connector-sdk/dist/reaction-sdk.d.ts +5 -1
  158. package/vendor/connector-sdk/package.json +1 -1
  159. package/vendor/core/dist/contracts/agent-settings.d.ts +61 -6
  160. package/vendor/core/dist/contracts/agent-settings.js +10 -7
  161. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +473 -98
  162. package/vendor/core/dist/contracts/tools/manage-agents.js +111 -2
  163. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +21 -18
  164. package/vendor/core/dist/contracts/tools/manage-automations.js +15 -15
  165. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +2 -2
  166. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +45 -20
  167. package/vendor/core/dist/contracts/tools/manage-entity.js +17 -5
  168. package/vendor/core/dist/contracts/tools/manage-inference-providers.d.ts +445 -0
  169. package/vendor/core/dist/contracts/tools/manage-inference-providers.js +133 -0
  170. package/vendor/core/dist/contracts/tools/manage-views.d.ts +4 -4
  171. package/vendor/core/dist/contracts/tools/manage-views.js +5 -3
  172. package/vendor/core/dist/contracts/worker/device-automation.js +4 -2
  173. package/vendor/core/dist/error-report.d.ts +73 -0
  174. package/vendor/core/dist/error-report.js +346 -0
  175. package/vendor/core/dist/index.d.ts +4 -1
  176. package/vendor/core/dist/index.js +7 -1
  177. package/vendor/core/dist/logger.js +15 -6
  178. package/vendor/core/dist/otel-fetch.d.ts +19 -0
  179. package/vendor/core/dist/otel-fetch.js +96 -0
  180. package/vendor/core/dist/otel.d.ts +22 -2
  181. package/vendor/core/dist/otel.js +95 -48
  182. package/vendor/core/dist/reserved.d.ts +1 -1
  183. package/vendor/core/dist/reserved.js +6 -4
  184. package/vendor/core/dist/tool-result.d.ts +8 -0
  185. package/vendor/core/dist/tool-result.js +61 -0
  186. package/vendor/core/dist/trace-context.d.ts +12 -0
  187. package/vendor/core/dist/trace-context.js +50 -0
  188. package/vendor/core/dist/utils/diagnostic-scrubber.js +1 -1
  189. package/vendor/core/dist/worker/auth.js +4 -0
  190. package/vendor/core/package.json +6 -1
  191. package/vendor/views/package.json +1 -1
  192. package/dist/owletto/dist/assets/_-XKF0m81R.js +0 -3
  193. package/dist/owletto/dist/assets/_-e8MbEBtw.js +0 -2
  194. package/dist/owletto/dist/assets/_agentId-Cv9goIFf.js +0 -2
  195. package/dist/owletto/dist/assets/_agentId-emObu67X.js +0 -2
  196. package/dist/owletto/dist/assets/_automationId-CfFFAYK1.js +0 -2
  197. package/dist/owletto/dist/assets/_connectorKey._connectionId-D6NKXSOE.js +0 -2
  198. package/dist/owletto/dist/assets/_connectorKey.index-DFrkLLTU.js +0 -2
  199. package/dist/owletto/dist/assets/_conversationId-D3vuAQPe.js +0 -2
  200. package/dist/owletto/dist/assets/_eventId-BV5SQaUA.js +0 -2
  201. package/dist/owletto/dist/assets/_name-DjtJMop4.js +0 -2
  202. package/dist/owletto/dist/assets/_owner-oBX68rb9.js +0 -3
  203. package/dist/owletto/dist/assets/_shape-C4lLPAwI.js +0 -2
  204. package/dist/owletto/dist/assets/_skillKey-Cw-7q6hI.js +0 -2
  205. package/dist/owletto/dist/assets/_slug-B2g5qzn3.js +0 -2
  206. package/dist/owletto/dist/assets/_viewKey-CIKGCtdK.js +0 -2
  207. package/dist/owletto/dist/assets/_viewKey-Dx4kJo7o.js +0 -2
  208. package/dist/owletto/dist/assets/accept-invitation-38lHBvjO.js +0 -2
  209. package/dist/owletto/dist/assets/activity-route-view-voRYSM3a.js +0 -2
  210. package/dist/owletto/dist/assets/agent-client-setup-list-Bkyw22GW.js +0 -5
  211. package/dist/owletto/dist/assets/agent-connect-pages-CpBxQCpx.js +0 -2
  212. package/dist/owletto/dist/assets/agent-editor-form-QrIDroFL.js +0 -2
  213. package/dist/owletto/dist/assets/agent-guardrails-route-CyoGSxcZ.js +0 -2
  214. package/dist/owletto/dist/assets/agent-skills-route-D-w3tY_2.js +0 -2
  215. package/dist/owletto/dist/assets/agent-subpage-shell-CLqpn5Tb.js +0 -2
  216. package/dist/owletto/dist/assets/agent-thread-CsRexwTv.js +0 -6
  217. package/dist/owletto/dist/assets/agents-DzH_FFKU.js +0 -2
  218. package/dist/owletto/dist/assets/agents-workbench-CmGrMvPC.js +0 -2
  219. package/dist/owletto/dist/assets/app._appId-BO7G38fL.js +0 -2
  220. package/dist/owletto/dist/assets/automation-detail-content-DMYxs6F6.js +0 -2
  221. package/dist/owletto/dist/assets/automations-DzH_FFKU.js +0 -2
  222. package/dist/owletto/dist/assets/client-activity-scopes-BLIy1Zc3.js +0 -2
  223. package/dist/owletto/dist/assets/clients-8-EpRjsm.js +0 -2
  224. package/dist/owletto/dist/assets/code-editor-BFZa4EIt.js +0 -16
  225. package/dist/owletto/dist/assets/connect-C0cHE9Xl.js +0 -2
  226. package/dist/owletto/dist/assets/connect-menu-D2K4tmvW.js +0 -2
  227. package/dist/owletto/dist/assets/connect._clientId-D4EG5a0v.js +0 -2
  228. package/dist/owletto/dist/assets/connected._clientId-DhoCT6sT.js +0 -2
  229. package/dist/owletto/dist/assets/connected._clientId.activity-Dn4qw2Us.js +0 -2
  230. package/dist/owletto/dist/assets/connected._clientId.index-BTI5JXA3.js +0 -2
  231. package/dist/owletto/dist/assets/connection-X9VU9Ijm.js +0 -2
  232. package/dist/owletto/dist/assets/connection-feed-detail-B6ydKasK.js +0 -2
  233. package/dist/owletto/dist/assets/connectors-BroKpwhB.js +0 -2
  234. package/dist/owletto/dist/assets/consent-fzLN-Qy7.js +0 -2
  235. package/dist/owletto/dist/assets/copy-button-Df7QXE0w.js +0 -2
  236. package/dist/owletto/dist/assets/create-BjwsYarn.js +0 -2
  237. package/dist/owletto/dist/assets/create-Dzr4mlr0.js +0 -2
  238. package/dist/owletto/dist/assets/create-automation-form-DHW6OUoS.js +0 -3
  239. package/dist/owletto/dist/assets/create-c94SPL21.js +0 -2
  240. package/dist/owletto/dist/assets/create._connectorKey-DLLn2nej.js +0 -2
  241. package/dist/owletto/dist/assets/cronstrue-xxpD1P2-.js +0 -2
  242. package/dist/owletto/dist/assets/device-C3AEoL5c.js +0 -2
  243. package/dist/owletto/dist/assets/device-pin-tombstone-B_te59GE.js +0 -2
  244. package/dist/owletto/dist/assets/device._deviceId-ZU09qrot.js +0 -2
  245. package/dist/owletto/dist/assets/entity-options-DJv2EhVV.js +0 -2
  246. package/dist/owletto/dist/assets/entity-page-BUghWZ1s.js +0 -2
  247. package/dist/owletto/dist/assets/entity-type-page-Lf6ONdpf.js +0 -2
  248. package/dist/owletto/dist/assets/event-card-CBlsG32u.js +0 -2
  249. package/dist/owletto/dist/assets/event-detail-BKSGEOdW.js +0 -2
  250. package/dist/owletto/dist/assets/filter-bar-COU0sBFQ.js +0 -2
  251. package/dist/owletto/dist/assets/guardrails-6ZJv1uzM.js +0 -2
  252. package/dist/owletto/dist/assets/identity-BaFLmbSo.js +0 -2
  253. package/dist/owletto/dist/assets/index-008wj-Pz.js +0 -7950
  254. package/dist/owletto/dist/assets/index-BaetvYLa.js +0 -2
  255. package/dist/owletto/dist/assets/index-BiEf5xOE.css +0 -1
  256. package/dist/owletto/dist/assets/index-BrDP4PCs.js +0 -2
  257. package/dist/owletto/dist/assets/index-BuXIeK7D.js +0 -2
  258. package/dist/owletto/dist/assets/index-CAVcR9za.js +0 -2
  259. package/dist/owletto/dist/assets/index-CMLfWGPU.js +0 -2
  260. package/dist/owletto/dist/assets/index-D0YEYP7N.js +0 -2
  261. package/dist/owletto/dist/assets/index-DkO0nPex.js +0 -2
  262. package/dist/owletto/dist/assets/index-KlRId0g6.js +0 -2
  263. package/dist/owletto/dist/assets/index-Ywnqi4A6.js +0 -2
  264. package/dist/owletto/dist/assets/index-wHFQv1aT.js +0 -12
  265. package/dist/owletto/dist/assets/index-xnxhf3Op.js +0 -2
  266. package/dist/owletto/dist/assets/json-diff-LE_vNZrM.js +0 -4
  267. package/dist/owletto/dist/assets/login-DWOT6jtS.js +0 -2
  268. package/dist/owletto/dist/assets/memory-browse-page-p2vIbfkC.js +0 -74
  269. package/dist/owletto/dist/assets/model-selector-3l9lY50C.js +0 -2
  270. package/dist/owletto/dist/assets/model-udnQ_S43.js +0 -2
  271. package/dist/owletto/dist/assets/models-CQj7GIOp.js +0 -2
  272. package/dist/owletto/dist/assets/new-BOwIHkre.js +0 -2
  273. package/dist/owletto/dist/assets/new-DTuFCQhV.js +0 -2
  274. package/dist/owletto/dist/assets/oauth-workspace-access-QPo4YwRX.js +0 -2
  275. package/dist/owletto/dist/assets/organization-BDzjnqPf.js +0 -2
  276. package/dist/owletto/dist/assets/peek-pane-content-D7yt0PrA.js +0 -2
  277. package/dist/owletto/dist/assets/permissions-CfoY4WFY.js +0 -2
  278. package/dist/owletto/dist/assets/proposal-review-shell-CVkLnnKo.js +0 -2
  279. package/dist/owletto/dist/assets/public-shell-ready-DXUTTGGp.js +0 -2
  280. package/dist/owletto/dist/assets/record-activity-BXhvJbd9.js +0 -2
  281. package/dist/owletto/dist/assets/reset-password-kRYyQuTY.js +0 -2
  282. package/dist/owletto/dist/assets/runs-lG2ChtOt.js +0 -2
  283. package/dist/owletto/dist/assets/runs-panel-LnGpHCAQ.js +0 -2
  284. package/dist/owletto/dist/assets/settings-CEAOg7fr.js +0 -2
  285. package/dist/owletto/dist/assets/settings-gGYXbFfd.js +0 -2
  286. package/dist/owletto/dist/assets/skills-BOL5c_Tk.js +0 -2
  287. package/dist/owletto/dist/assets/use-scroll-sentinel-D-fJx_Md.js +0 -2
  288. package/dist/owletto/dist/assets/view-param-filters-DkX4YdDT.js +0 -2
  289. /package/vendor/@better-auth-kysely-adapter/{.bun-tag-abf95749a412716 → .bun-tag-654b3a002b271269} +0 -0
  290. /package/vendor/postgres/{.bun-tag-22d644c2873790db → .bun-tag-c81dacd34e959a7a} +0 -0
@@ -0,0 +1,3 @@
1
+ import{r,j as e,bl as oe,bm as ie,bn as re,bo as ce,bp as D,I as ae,B as J,X as ds,aH as Es,aB as Fs,l as us,hm as Os,hn as As,S as Lt,H as b,i as R,dh as We,eY as Rt,dS as Ts,dU as Ds,gq as Ms,cI as ms,dY as Ps,fC as Ls,ft as $t,ho as Rs,fa as ct,cU as Ue,Y as rt,fc as bt,bc as hs,d6 as Xe,cP as $s,a3 as Is,Q as qs,aI as Ks,hp as Bs,hq as Ws,hr as zs,hs as Us,ht as Vs,V as Qs,L as Js,v as xs,hk as Gs,bb as Hs,aG as Ys,fK as It,gZ as Xs,hu as Zs,ce as en,eS as tn,bP as _t,ab as sn,hv as nn,fo as an,hw as on,hx as rn,bO as cn}from"./index-DdBTTN3y.js";import{c as ln,a as qt}from"./model-jL871x2J.js";import{C as dn,f as un}from"./entity-options-daOOQo7O.js";import{c as mn,d as hn,e as xn,f as gn,g as pn,u as fn}from"./use-automations-BLNjxq2K.js";import{M as vn}from"./model-selector-CgU8SJMF.js";import{b as yn}from"./skill-editor-D_W3QlRz.js";import{C as Nt}from"./code-editor-DNuRKde1.js";import{J as Kt}from"./json-diff-BaLL4Fsu.js";import{u as jn,b as Bt,c as Wt,s as _n,o as Nn,a as bn,d as kn,e as Sn,f as wn,v as Cn,r as En}from"./use-mention-search-dn3ws1WB.js";const at=[{value:"*/15 * * * *",label:"Every 15 minutes"},{value:"0 * * * *",label:"Every hour"},{value:"0 */6 * * *",label:"Every 6 hours"},{value:"0 9 * * *",label:"Daily at 9:00 AM"},{value:"0 18 * * *",label:"Daily at 6:00 PM"},{value:"0 9 * * 1-5",label:"Weekdays at 9:00 AM"},{value:"0 9 * * 1",label:"Weekly · Monday 9:00 AM"},{value:"0 9 1 * *",label:"Monthly · 1st at 9:00 AM"},{value:"custom",label:"Custom cron…"}];function Fn(n){const s=n.trim();if(!s)return null;try{return ln.toString(s,{throwExceptionOnParseError:!0})}catch{return null}}function On({value:n,onChange:s,placeholder:t="No schedule",className:c}){const d=n??"",u=at.some(p=>p.value===d),[i,o]=r.useState(!u&&d!==""),x=p=>{p==="custom"?o(!0):(o(!1),s(p))},N=d?Fn(d):null,m=d?e.jsx("p",{className:N?"text-xs text-muted-foreground":"text-xs text-destructive",children:N??"Not a valid cron expression."}):null;return!d&&!i?e.jsxs(oe,{onValueChange:x,children:[e.jsx(ie,{className:c??"w-full",children:e.jsx(re,{placeholder:t})}),e.jsx(ce,{children:at.map(p=>e.jsxs(D,{value:p.value,children:[p.label,p.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:p.value})]},p.value))})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[i?e.jsx(ae,{placeholder:"0 */6 * * *",value:d,onChange:p=>s(p.target.value),className:"font-mono text-sm flex-1"}):e.jsxs(oe,{value:d,onValueChange:x,children:[e.jsx(ie,{className:c??"w-full flex-1",children:e.jsx(re,{children:at.find(p=>p.value===d)?.label??d})}),e.jsx(ce,{children:at.map(p=>e.jsxs(D,{value:p.value,children:[p.label,p.value!=="custom"&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground font-mono",children:p.value})]},p.value))})]}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0",onClick:()=>{o(!1),s("")},children:e.jsx(ds,{className:"h-4 w-4"})})]}),m]})}const gt="__all_workspace_event_types__",An=[],Tn={};function zt(n,s,t){const c=new Map;if(!s)for(const[u,i]of Object.entries(t??{}))c.set(u,{key:u,label:$t(u),description:i.description});const d=[...n].filter(u=>!s||u.slug===s).sort((u,i)=>u.slug.localeCompare(i.slug));for(const u of d)for(const[i,o]of Object.entries(u.event_kinds??{})){const x=c.get(i);if(x){!x.description&&o.description&&(x.description=o.description),JSON.stringify(x.metadataSchema??null)!==JSON.stringify(o.metadataSchema??null)&&(x.metadataSchema=void 0);continue}c.set(i,{key:i,label:$t(i),description:o.description,metadataSchema:o.metadataSchema})}return[...c.values()].sort((u,i)=>u.label.localeCompare(i.label))}function Ut(n){const s=n[0];if(!s)return;const t=d=>JSON.stringify(Object.keys(d?.properties??{}).sort()),c=t(s);return n.every(d=>t(d)===c)?s:void 0}function Vt(n,s,t){const c=new Set(Object.keys(s.properties??{}));return{...Object.fromEntries(Object.entries(n).filter(([d])=>!c.has(d))),...t}}function Be(n,s,t){return t==="steer"&&(n==="window"||s!=="reply_to_source")?"coalesce":t}function He(n,s){return n==="window"?"silent":s}function Qt(n){return Object.fromEntries(Object.entries(n).filter(([s])=>s==="resource_ref"||s==="resource_type"))}function Jt(n,s,t){const c=new Set(Object.keys(s?.properties??{})),d=new Set(t.flatMap(u=>Object.keys(u.filterSchema?.properties??{})));return Object.fromEntries(Object.entries(Rs(n)).filter(([u])=>u==="resource_ref"||u==="resource_type"||!d.has(u)||c.has(u)))}function Dn({value:n,options:s,onChange:t}){return e.jsx("div",{className:"inline-flex rounded-md border bg-muted/30 p-0.5 text-sm",children:s.map(c=>e.jsx("button",{type:"button","aria-pressed":n===c.value,onClick:()=>t(c.value),className:R("rounded px-3 py-1 transition-colors",n===c.value?"bg-background text-foreground ":"text-muted-foreground hover:text-foreground"),children:c.label},c.value))})}function Gt({events:n,selectedKeys:s,onToggle:t,ariaLabel:c="Events"}){const d=r.useId(),u=n.filter(o=>s.includes(o.key)).map(o=>o.label),i=u.length===0?"Choose events":u.length===1?u[0]:`${u.length} events selected`;return e.jsx(ct,{contentClassName:"w-[var(--radix-popover-trigger-width)] min-w-[280px]",searchPlaceholder:"Filter events...",emptyText:"No events found.",trigger:o=>e.jsxs(J,{type:"button",variant:"outline",role:"combobox","aria-label":c,"aria-expanded":o,className:"w-full justify-between font-normal",children:[e.jsx("span",{className:R(u.length===0&&"text-muted-foreground"),children:i}),e.jsx(bt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:()=>n.map((o,x)=>{const N=s.includes(o.key),m=`${d}-${x}-state`;return e.jsxs(Ue,{value:`${o.label} ${o.key}`,onSelect:()=>t(o.key),"aria-label":o.label,"aria-describedby":m,className:"cursor-pointer",children:[e.jsx(rt,{className:R("mr-2 h-4 w-4",N?"opacity-100":"opacity-0")}),o.label,e.jsx("span",{id:m,className:"sr-only",children:N?"Selected":"Not selected"})]},o.key)})})}function Mn({organizationId:n,initialTrigger:s,onChange:t,allowedKinds:c,showSectionHeader:d=!0,fieldIdPrefix:u="automation-trigger-"}){const i=Es(n,{status:"active",limit:500}),o=Fs(n),x=us({organizationId:n}),N=Os({organizationId:n}),m=i.data??[],p=o.data??[],$=x.data??An,h=N.data??Tn,k=r.useMemo(()=>$.filter(l=>l.organization_id===n),[$,n]),S=s?.kind==="event"&&s?.source==="workspace",F=S||s===void 0,W=c?.length?[...c]:["event","time","manual"],f=W.join("|"),M=(()=>{const l=s===null?"manual":s?.kind==="schedule"?"time":"event";return W.includes(l)?l:W[0]??"event"})(),[j,le]=r.useState(M),[I,de]=r.useState(S?"workspace":typeof s?.connection_id=="number"?String(s.connection_id):s?.kind==="event"&&s.connector_key?"":"workspace"),w=I==="workspace",X=w?"":I,[v,_]=r.useState(typeof s?.entity_type=="string"?s.entity_type:""),Se=r.useMemo(()=>Array.isArray(s?.event_types)?s.event_types:[],[s]),[E,ge]=r.useState(()=>Se.filter(l=>typeof l=="string")),[z,pe]=r.useState(s?.match&&typeof s.match=="object"&&!Array.isArray(s.match)?s.match:{}),[fe,ve]=r.useState(typeof s?.cron=="string"?s.cron:"0 9 * * 1-5"),Ne=typeof s?.timezone=="string"?s.timezone:void 0,[q,ye]=r.useState(s?.kind==="schedule"||F&&s?.execution!=="turn"||s?.execution==="window"?"window":"turn"),[K,ue]=r.useState(He(q,s?.output==="reply_to_source"?"reply_to_source":"silent")),[G,Z]=r.useState(s?.kind==="schedule"||F&&s?.active_run!=="queue"?"coalesce":Be(q,K,s?.active_run==="coalesce"||s?.active_run==="steer"?s.active_run:"queue")),[je,Te]=r.useState(s?.skip_if_unchanged!==!1),[De,Me]=r.useState(!1);r.useEffect(()=>{const l=f.split("|");if(!l.includes(j)){const y=l[0]??"event";le(y),ye(y==="time"||y==="event"&&w?"window":"turn"),Z(y==="time"||y==="event"&&w?"coalesce":"queue"),ue("silent")}},[f,j,w]);const se=m.find(l=>String(l.id)===X),g=i.isLoading||o.isLoading,me=x.isLoading,U=typeof s?.connector_key=="string"?s.connector_key:void 0,te=j==="event"&&!w&&s?.kind==="event"&&s?.source!=="workspace"&&typeof s.connection_id=="number"&&String(s.connection_id)===X&&!se,P=j==="event"&&!w&&s?.kind==="event"&&s?.source!=="workspace"&&s.connection_id==null&&U!==void 0&&X==="",Pe=p.find(l=>l.key===(se?.connector_key??(P?U:void 0))),H=Pe?.automation_events??[],Ve=H.filter(l=>E.includes(l.key)),we=Ve[0],Le=k.find(l=>l.slug===v),Fe=[...k.filter(l=>Object.keys(l.event_kinds??{}).length>0||l.slug===v),...v&&!Le?[{slug:v,name:v}]:[]],O=r.useMemo(()=>zt(k,v||void 0,h),[k,v,h]),Oe=O.filter(l=>E.includes(l.key)),Re=Oe[0],he=Ut(Ve.map(l=>l.filterSchema)),Ce=Ut(Oe.map(l=>l.metadataSchema)),$e=!!(w&&v&&!Le),Ie=te||P,xe=(j==="event"?w?E.length>0&&!$e:!!(E.length>0&&(X&&se||Ie)):j==="time"?!!fe.trim():!0)&&(j!=="event"||!As(z));r.useEffect(()=>{let l;if(xe&&j==="event"&&!w){const y=Jt(z,he,Pe?.automation_events??[]);se||P?l={kind:"event",source:"connector",connector_key:se?.connector_key??U,...se?{connection_id:Number(X)}:{},event_types:E,...Object.keys(y).length>0?{match:y}:{},execution:q,active_run:Be(q,K,G),output:He(q,K),skip_if_unchanged:je}:te&&(l=s?{...s,source:"connector"}:void 0)}else if(xe&&j==="event"&&w){const y=Jt(z,Ce,O.map(A=>({filterSchema:A.metadataSchema})));l={kind:"event",source:"workspace",...v?{entity_type:v}:{},event_types:E,...Object.keys(y).length>0?{match:y}:{},execution:q,active_run:G==="queue"?"queue":"coalesce"}}else xe&&j==="time"&&(l={kind:"schedule",cron:fe.trim(),...Ne?{timezone:Ne}:{},execution:"window",active_run:"coalesce",skip_if_unchanged:je});t({ready:xe,kind:j,trigger:l})},[G,X,se,fe,Pe,E,q,z,j,U,Ne,s,w,t,K,xe,he,Ce,je,v,O,P,te]);const qe=l=>{const y=m.find(T=>String(T.id)===l),A=p.find(T=>T.key===y?.connector_key),ee=E.filter(T=>A?.automation_events?.some(ke=>ke.key===T)),ne=A?.automation_events?.find(T=>T.key===ee[0]),be=y?.connector_key!==(se?.connector_key??U);if(de(l),ge(ee),!ne)pe(Qt);else if(be){const T=ne.defaults?.execution??"turn",ke=ne.defaults?.activeRun??"queue",V=He(T,ne.defaults?.output??"silent");pe(Qt),ye(T),Z(Be(T,V,ke)),ue(V)}},et=l=>{if(l==="workspace"){de("workspace"),ge(y=>y.filter(A=>O.some(ee=>ee.key===A))),pe({}),ye("window"),Z("coalesce"),ue("silent");return}qe(l)},Je=l=>{const y=E.includes(l)?E.filter(T=>T!==l):H.map(T=>T.key).filter(T=>T===l||E.includes(T));if(ge(y),y[0]===E[0])return;const A=H.find(T=>T.key===y[0]),ee=A?.defaults?.execution??"turn",ne=A?.defaults?.activeRun??"queue",be=He(ee,A?.defaults?.output??"silent");ye(ee),Z(Be(ee,be,ne)),ue(be)},tt=l=>{const y=l===gt?"":l,A=k.find(ne=>ne.slug===y),ee=zt(k,A?.slug,h);_(y),ge(ne=>ne.filter(be=>ee.some(T=>T.key===be))),pe({})},st=l=>{ge(y=>y.includes(l)?y.filter(A=>A!==l):O.map(A=>A.key).filter(A=>A===l||y.includes(A)))},Ae=[{value:"event",label:"Event"},{value:"time",label:"Schedule"},{value:"manual",label:"Manual"}].filter(l=>W.includes(l.value));return e.jsxs("div",{className:"space-y-4",children:[d?e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:"When"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose what starts this Automation. Its goal and context stay reusable."})]}):null,Ae.length>1?e.jsx(Dn,{value:j,options:Ae,onChange:l=>{le(l),ye(l==="time"||l==="event"&&w?"window":"turn"),Z(l==="time"||l==="event"&&w?"coalesce":"queue"),ue("silent")}}):null,j==="event"?g||w&&me?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Lt,{className:"h-9 w-full"}),e.jsx(Lt,{className:"h-9 w-full"})]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Source"}),e.jsx(dn,{connections:m,value:I,onValueChange:et,disabled:Ie,includeWorkspaceEvents:!0,ariaLabel:"Source",placeholder:"Choose a source"}),te?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This shared connection is managed outside this organization. Other Automation fields can still be edited."}):P?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This Automation listens across all"," ",String(s?.connector_key)," connections. Other Automation fields can still be edited."]}):null]}),w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:O.length>1?"Events":"Event"}),O.length>0?e.jsx(Gt,{events:O,selectedKeys:E,onToggle:st}):e.jsx("div",{className:R(We,"px-3 py-2 text-sm text-muted-foreground"),children:v?"This entity type has no declared Automation events.":"This workspace has no declared Automation events."}),Re?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:Re.description}):null,$e?e.jsxs("p",{className:"text-xs text-destructive",children:["This trigger filters on entity type “",v,"”, which no longer exists in this workspace. Clear the Entity type filter under Trigger options to save."]}):null,e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only declared Automation outputs in the current workspace can trigger this Automation. Ordinary saved events remain data."})]}),Ce?e.jsx(Rt,{schema:Ce,values:z,onValuesChange:l=>pe(y=>Vt(y,Ce,l)),fieldIdPrefix:`${u}workspace-`},`${v||"workspace"}:${E.join(",")}`):null]}):se||P?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:H.length>1?"Events":"Event"}),H.length?e.jsx(Gt,{events:H,selectedKeys:E,onToggle:Je}):e.jsx("div",{className:R(We,"px-3 py-2 text-sm text-muted-foreground"),children:"This connector has not published subscribable events."}),we?.description?e.jsx("p",{className:"text-xs text-muted-foreground",children:we.description}):null]}),typeof z.resource_ref=="string"||he?e.jsxs("div",{className:"space-y-3",children:[typeof z.resource_ref=="string"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Resource"}),e.jsx("div",{className:R(We,"px-3 py-2 text-sm"),children:z.resource_ref})]}):null,he?e.jsx(Rt,{schema:he,values:z,onValuesChange:l=>pe(y=>Vt(y,he,l)),fieldIdPrefix:u},E.join(",")):null]}):null]}):I?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose workspace events or a connected app as the source."})]}):j==="time"?e.jsx(On,{value:fe,onChange:ve}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this Automation explicitly from Lobu, the API, CLI, or MCP."}),j!=="manual"&&!Ie?e.jsxs(Ts,{open:De,onOpenChange:Me,children:[e.jsx(Ds,{asChild:!0,children:e.jsxs(J,{type:"button",variant:"ghost",className:"h-auto w-full justify-between px-0 py-1 text-muted-foreground hover:bg-transparent hover:text-foreground",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm",children:[e.jsx(Ms,{className:"h-4 w-4"}),"Trigger options",e.jsxs("span",{className:"font-normal text-muted-foreground",children:["· ",q==="turn"?"Each event":"Window"," ·"," ",j==="time"?"Combine":w?G==="queue"?"Queue":"Combine":G==="queue"?"Queue":G==="coalesce"?"Combine":"Update current run",j==="event"&&!w?` · ${q==="turn"&&K==="reply_to_source"?"Reply":"Save in Lobu"}`:""]})]}),e.jsx(ms,{className:R("h-4 w-4 transition-transform",De&&"rotate-180")})]})}),e.jsxs(Ps,{className:"space-y-4 pt-3",children:[j==="event"&&w?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Entity type filter"}),e.jsxs(oe,{value:v||gt,onValueChange:tt,children:[e.jsx(ie,{"aria-label":"Entity type filter",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:gt,children:"All event types"}),Fe.map(l=>e.jsx(D,{value:l.slug,children:l.name},l.slug))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Optional. Limit selected events to outputs linked to this entity type."})]}):null,j==="event"?e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Run"}),e.jsxs(oe,{value:q,onValueChange:l=>{const y=l,A=He(y,K);ye(y),ue(A),Z(Be(y,A,G))},children:[e.jsx(ie,{children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"turn",children:"Start a run for each event"}),e.jsx(D,{value:"window",children:"Batch events into a window"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"When busy"}),e.jsxs(oe,{value:G,onValueChange:l=>Z(l),children:[e.jsx(ie,{children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"queue",children:"Queue"}),e.jsx(D,{value:"coalesce",children:"Combine waiting events"}),!w&&q==="turn"&&K==="reply_to_source"&&we?.capabilities?.steering?e.jsx(D,{value:"steer",children:"Update the current run"}):null]})]})]})]}):null,q==="window"&&(j==="time"||!w)?e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Skip unchanged windows"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No source changes means no agent run or LLM call."})]}),e.jsx(Ls,{"aria-label":"Skip unchanged windows",checked:je,onCheckedChange:Te})]}):null,j==="event"&&!w&&q==="turn"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Result"}),e.jsxs(oe,{value:K,onValueChange:l=>{const y=l;ue(y),Z(Be(q,y,G))},children:[e.jsx(ie,{children:e.jsx(re,{})}),e.jsxs(ce,{children:[we?.capabilities?.replyToSource?e.jsx(D,{value:"reply_to_source",children:"Reply where it happened"}):null,e.jsx(D,{value:"silent",children:"Save in Lobu"})]})]}),we?.capabilities?.replyToSource?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Messages matching this trigger run the Automation; anything else in the conversation stays with the connected agent."}):null]}):null]})]}):null]})}const Pn=16;function ze(){return crypto.randomUUID()}function Ln(n){return n===void 0?[{key:ze(),initial:void 0}]:n.length===0?[{key:ze(),initial:null}]:n.map(s=>({key:ze(),initial:s}))}function gs(n){return n?n.kind==="time"||n.trigger?.kind==="schedule":!1}function Rn(n,s){return n?n.ready===s.ready&&n.kind===s.kind&&JSON.stringify(n.trigger)===JSON.stringify(s.trigger):!1}function $n(n,s){const t=n.map(o=>s[o.key]??{ready:!1,kind:"event"});if(!(n.length>1)&&t[0]?.kind==="manual")return{ready:t[0].ready,triggers:[]};const d=t.filter(gs).length;return{ready:!t.some(o=>o.kind==="manual")&&d<=1&&t.length>0&&t.every(o=>o.ready&&o.trigger),triggers:t.filter(o=>o.trigger).map(o=>o.trigger)}}function ya({organizationId:n,initialTriggers:s,onChange:t}){const c=r.useId(),[d,u]=r.useState(()=>Ln(s)),[i,o]=r.useState({}),x=r.useRef("");r.useEffect(()=>{const h=$n(d,i),k=JSON.stringify(h);k!==x.current&&(x.current=k,t(h))},[d,i,t]);const N=d.find(h=>gs(i[h.key]))?.key??d.find(h=>h.initial&&typeof h.initial=="object"&&h.initial.kind==="schedule"&&!i[h.key])?.key??null,m=r.useCallback((h,k)=>{o(S=>Rn(S[h],k)?S:{...S,[h]:k})},[]),p=()=>{const h=d[0],k=h?i[h.key]:void 0;if(d.length===1&&(k?.kind==="manual"||h?.initial===null)){const S=ze();o({}),u([{key:S,initial:void 0}]);return}u(S=>[...S,{key:ze(),initial:void 0}])},$=h=>{if(d.length<=1){const k=ze();o({}),u([{key:k,initial:null}]);return}o(k=>{const S={...k};return delete S[h],S}),u(k=>k.filter(S=>S.key!==h))};return e.jsxs("section",{className:"space-y-4","aria-labelledby":`${c}-heading`,children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{id:`${c}-heading`,className:"text-sm font-medium",children:"When"}),d.length>1?e.jsx("p",{className:"text-xs text-muted-foreground",children:"Each trigger can start this Automation independently (OR). At most one schedule. If several match the same event, the first listed wins for run options."}):null]}),e.jsx("div",{className:"space-y-3",children:d.map((h,k)=>{const S=d.length>1,F=S?N&&N!==h.key?["event"]:["event","time"]:["event","time","manual"],W=i[h.key],f=S||(W?W.kind!=="manual":h.initial!==null);return e.jsxs("div",{className:R("space-y-3 rounded-lg border bg-card/40 p-3",S&&"relative"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:S?`Trigger ${k+1}`:"Trigger"}),f?e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive","aria-label":S?`Remove trigger ${k+1}`:"Clear trigger",onClick:()=>$(h.key),children:e.jsx(hs,{className:"h-3.5 w-3.5"})}):null]}),e.jsx(In,{slotKey:h.key,organizationId:n,initial:h.initial,kinds:F,fieldIdPrefix:`${c}-${h.key}-`,onChange:m})]},h.key)})}),e.jsxs(J,{type:"button",variant:"outline",size:"sm",className:"w-full sm:w-auto",onClick:p,disabled:d.length>=Pn,children:[e.jsx(Xe,{className:"mr-1.5 h-3.5 w-3.5"}),"Add another trigger"]})]})}function In({slotKey:n,organizationId:s,initial:t,kinds:c,fieldIdPrefix:d,onChange:u}){const i=r.useCallback(o=>u(n,o),[u,n]);return e.jsx(Mn,{organizationId:s,initialTrigger:t,allowedKinds:c,showSectionHeader:!1,fieldIdPrefix:d,onChange:i})}const qn=["claude-code","codex","opencode","pi","agy"],Kn={"claude-code":"Claude Code",codex:"Codex",opencode:"OpenCode",pi:"Pi",agy:"Antigravity (agy)"},Bn=[{kind:"claude-code",binaryName:"claude",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"claude-config-file",flag:"--mcp-config",extraArgs:["--strict-mcp-config","--allowedTools","mcp__lobu__search_sdk,mcp__lobu__query_sdk,mcp__lobu__run_sdk"]},headlessArgs:[],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:"--permission-mode",budgetFlag:"--max-budget-usd",timeoutFlag:null,trailingArgs:[]},{kind:"agy",binaryName:"agy",promptDelivery:{kind:"flag",flag:"-p"},mcpDelivery:{kind:"none"},headlessArgs:["--dangerously-skip-permissions"],modelFlag:"--model",effortFlag:"--effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:{flag:"--print-timeout",suffix:"s"},trailingArgs:[]},{kind:"opencode",binaryName:"opencode",promptDelivery:{kind:"positional",subcommand:["run"]},mcpDelivery:{kind:"opencode-config-env",variable:"OPENCODE_CONFIG_CONTENT"},headlessArgs:["--auto","--print-logs","--log-level","ERROR"],modelFlag:"-m",effortFlag:"--variant",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"codex",binaryName:"codex",promptDelivery:{kind:"positional",subcommand:["exec"]},mcpDelivery:{kind:"none"},headlessArgs:["--skip-git-repo-check","--sandbox","workspace-write","-c","sandbox_workspace_write.network_access=true"],modelFlag:"-m",effortFlag:"-c",effortConfigKey:"model_reasoning_effort",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]},{kind:"pi",binaryName:"pi",promptDelivery:{kind:"positional",subcommand:[]},mcpDelivery:{kind:"none"},headlessArgs:["-p","--no-session","--tools","read,bash,edit,write"],modelFlag:"--model",effortFlag:"--thinking",permissionModeFlag:null,budgetFlag:null,timeoutFlag:null,trailingArgs:[]}];new Map(Bn.map(n=>[n.kind,n]));const Ht={agents:!0,lobuEmbedded:!1};function Wn(){const{data:n}=$s({queryKey:["features"],queryFn:async()=>{const s=await Is(`${qs}/api/features`);return s.ok?s.json():Ht},staleTime:3e4,refetchInterval:6e4});return n??Ht}const pt="__none__";function Ye(n){return`${n.connection_id}:${n.feed_key}`}function zn(n){const s=n.indexOf(":");if(s<=0)return null;const t=Number(n.slice(0,s)),c=n.slice(s+1);return!Number.isSafeInteger(t)||t<=0||!c?null:{connection_id:t,channel_id:c}}function ft(n){return n?`${n.connection_id}:${n.channel_id}`:""}function ot(n){return`${n.display_name||n.feed_key} (${n.feed_key})`}function Un(n){return n.connection_name?`connection ${n.connection_id} (${n.connection_name})`:`connection ${n.connection_id}`}function Yt(n,s){return n.store==="channel_messages"&&n.target_agent_id===s&&n.connection_status==="active"}function Vn({organizationId:n,agentId:s,value:t,onChange:c,disabled:d=!1,automationName:u,onPendingChange:i}){const{data:o=[],isLoading:x}=Ks(n),N=ft(t),[m,p]=r.useState(null),[$,h]=r.useState(!1),k=r.useRef(s),S=r.useMemo(()=>o.filter(v=>Yt(v,s)),[o,s]);r.useEffect(()=>{if(k.current===s)return;const v=k.current;if(k.current=s,p(null),h(!1),!v||t==null)return;const _=ft(t);if(_==="")return;o.some(E=>Yt(E,s)&&Ye(E)===_)||c(null)},[s,o,t,c]);const F=m??N,W=F===""?pt:F,f=S.find(v=>Ye(v)===F),M=m!==null&&m!==""&&m!==N;r.useEffect(()=>{i?.(M)},[M,i]);const j=f??(m?void 0:S.find(v=>Ye(v)===N)),le=v=>{const _=v===pt?"":v;if(_===""){p(null),h(!1),c(null);return}if(_===N){p(null),h(!1);return}p(_),h(!1)},I=v=>{if(h(v),v&&m){const _=zn(m);_&&(p(null),c(_))}else!v&&m&&p(null)},w=(t&&ft(t)!==""?t:void 0)??(f?{connection_id:f.connection_id,channel_id:f.feed_key}:void 0),X=(u??"").trim()||"This automation";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"automation-delivery-target",children:["Digest destination"," ",e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),s?e.jsxs(oe,{value:W,onValueChange:le,disabled:d||x,children:[e.jsx(ie,{id:"automation-delivery-target",className:"font-mono text-sm",children:e.jsx(re,{placeholder:x?"Loading bound channels…":S.length===0?"No bound chat channels":"No digest — runs stay silent"})}),e.jsxs(ce,{children:[e.jsx(D,{value:pt,children:"No digest — runs stay silent"}),S.map(v=>e.jsxs(D,{value:Ye(v),children:[ot(v)," · ",v.connector_key]},Ye(v)))]})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select a managed agent first — only channels bound to that agent can receive digests."}),s&&!x&&S.length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No active chat channels are bound to this agent yet. Link a private channel first, then select it here."}):null,M&&f?e.jsxs("label",{className:"flex cursor-pointer items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",checked:$,onChange:v=>I(v.target.checked),className:"mt-0.5","aria-label":`Confirm digest delivery to ${ot(f)}`}),e.jsxs("span",{className:"text-muted-foreground",children:["I confirm posting material-change digests to"," ",e.jsx("span",{className:"font-medium text-foreground",children:ot(f)}),". Destination changes are audited."]})]}):null,j||w?e.jsxs("div",{className:R(We,"space-y-1.5 px-3 py-2"),children:[e.jsxs("p",{className:"text-xs font-medium",children:["Digest preview →"," ",e.jsx("span",{className:"font-mono font-normal",children:j?`${j.connector_key} ${ot(j)} · ${Un(j)}`:`${w?.channel_id} · connection ${w?.connection_id}`})]}),e.jsxs("p",{className:"font-mono text-xs",children:[X," applied 2 new + 1 updated"]}),e.jsx("p",{className:"whitespace-pre-line font-mono text-xs text-muted-foreground",children:`+ Example task (#12)
2
+ ~ Follow-up item (#34)`}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Sends only after a successful run with material changes. Runs with zero changes send nothing. Retries reuse the same notification and delivery receipts dedupe channel posts, but provider acceptance with a lost receipt can still duplicate."})]}):null]})}const Xt=4096;function Qn({open:n,onOpenChange:s,initial:t,onSubmit:c}){const[d,u]=r.useState(""),[i,o]=r.useState(""),[x,N]=r.useState(null);r.useEffect(()=>{n&&(u(t?.name??""),o(t?.query??""),N(null))},[n,t]);const m=()=>{const $=d.trim(),h=i.trim();if(!$){N("Give the SQL source a name.");return}if(!h){N("Enter a query.");return}if(h.length>Xt){N(`Query is too long (${h.length} chars, max ${Xt}).`);return}c({name:$,query:h}),s(!1)},p=!!t;return e.jsx(Bs,{open:n,onOpenChange:s,children:e.jsxs(Ws,{className:"max-w-2xl",children:[e.jsxs(zs,{children:[e.jsx(Us,{children:p?"Edit SQL source":"SQL source"}),e.jsx(Vs,{children:"Write a query the automation runs each period. It becomes a reference in the prompt — the query travels with the chip."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"sql-source-name",children:"Name"}),e.jsx(ae,{id:"sql-source-name",value:d,onChange:$=>u($.target.value),placeholder:"recent_cancellations",autoFocus:!p}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"The output-field name this source fills."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"sql-source-query",children:"Query"}),e.jsx(Nt,{value:i,onChange:o,language:"sql",placeholder:"SELECT id, payload_text, occurred_at FROM events ORDER BY occurred_at DESC",minHeight:"160px"})]}),x?e.jsx("p",{className:"text-sm text-destructive",children:x}):null]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(J,{variant:"outline",onClick:()=>s(!1),children:"Cancel"}),e.jsx(J,{onClick:m,children:p?"Save":"Add source"})]})]})})}const Jn=["skill","feed","connection","connector","metric","entity_type"];function Gn({value:n,onChange:s,library:t,pinned:c,required:d,error:u,owner:i,agentId:o,sources:x,onAddSources:N}){const m=jn(Jn,Bt,{skills:t,skillAgentId:o||null}),p=r.useRef(null),[$,h]=r.useState(null),k=r.useMemo(()=>{if(!x)return[];const f=new Set(x.map(M=>M.query.trim()));return Wt(n).filter(M=>!f.has(M.query.trim()))},[n,x]),S=_n(n),F=Nn(c.filter(f=>S.includes(f.name)),t),W=t.length>0;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(b,{htmlFor:"automation-prompt",children:["Instructions"," ",d?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),S.length>0?e.jsxs("span",{className:"text-xs text-muted-foreground",children:[S.length,"/",Bt," skills"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-background focus-within:ring-1 focus-within:ring-ring",children:e.jsx(bn,{value:n,onChange:s,onSubmit:()=>{},submitOnEnter:!1,searchRefs:m,handleRef:p,onSqlRequest:()=>h({}),onSqlEdit:(f,M)=>h({initial:f,pos:M}),placeholder:W?"What should this Automation do? Type @ to pull in a skill or a data source.":"What should this Automation do? Type @ to pull in a data source.",className:"[&_.ProseMirror]:min-h-[7rem] [&_.ProseMirror]:max-h-72 [&_.ProseMirror]:overflow-y-auto"})}),e.jsx(Qn,{open:$!==null,onOpenChange:f=>{f||h(null)},initial:$?.initial,onSubmit:f=>{p.current?.insertSql(f,$?.pos),h(null)}}),k.length>0&&N?e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-dashed p-3",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[k.length===1?`"${k[0]?.name}" is referenced in the instructions but is not a source on this Automation.`:`${k.length} references in the instructions are not sources on this Automation.`," ","Editing an Automation does not add them automatically."]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>N(Wt(n,x)),children:k.length===1?"Add as a source":"Add as sources"})]}):null,S.length>0?e.jsx("div",{className:"flex flex-wrap items-center gap-1.5",children:S.map(f=>{const M=F.includes(f),j=!t.some(le=>le.name===f);return e.jsxs(Qs,{variant:j?"destructive":"secondary",className:"font-normal",children:[f,j?" · unavailable":M?" · newer text":null]},f)})}):null,F.length>0?e.jsxs("p",{className:"rounded-lg border border-dashed p-3 text-xs text-muted-foreground",children:[F.length===1?`"${F[0]}" has been edited since this Automation pinned it.`:`${F.length} skills have been edited since this Automation pinned them.`," ","This Automation keeps running the pinned text until you save it again."]}):null,u?e.jsx("p",{className:"text-xs text-destructive",children:u}):null,!W&&o?e.jsxs("p",{className:"text-xs text-muted-foreground",children:["This agent has no skills yet."," ",e.jsx(Js,{to:"/$owner/agents/$agentId/skills",params:{owner:i,agentId:o},className:"font-medium text-foreground underline underline-offset-2",children:"Add one"})," ","to reuse instructions across Automations."]}):u?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:W?"Type @ to pull in a skill, a feed, connection, connector, metric, entity type, or a SQL query. Skill text is saved with this version, so later edits to the skill do not change this Automation until you update it.":"Type @ to pull in a feed, connection, connector, metric, entity type, or a SQL query this Automation should read."})]})}const Hn=["connection","connector","feed","metric","entity_type"];function Yn({sources:n,onChange:s,disabled:t}){const{currentOwner:c,resolvedOrganizationId:d}=xs(),[u,i]=r.useState(""),{refs:o}=kn({owner:c,organizationId:d,kinds:Hn,query:u,limitPerKind:10});return e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Sources"}),n.length>0?e.jsx("ul",{className:"space-y-2",children:n.map(x=>e.jsxs("li",{className:"flex items-start gap-2 rounded-lg border bg-background p-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate font-mono text-xs font-medium",children:x.name}),e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:x.query})]}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0","aria-label":`Remove source ${x.name}`,disabled:t,onClick:()=>s(n.filter(N=>N.query!==x.query)),children:e.jsx(ds,{className:"h-3.5 w-3.5"})})]},x.query))}):null,e.jsx("div",{className:"flex gap-2",children:e.jsx(ct,{searchPlaceholder:"Search feeds, connections, metrics…",emptyText:"No matching reference.",onQueryChange:i,trigger:()=>e.jsxs(J,{type:"button",variant:"outline",size:"sm",disabled:t,children:[e.jsx(Xe,{className:"mr-2 h-3.5 w-3.5"}),"Add source"]}),children:x=>o.map(N=>e.jsxs(Ue,{value:`${N.label} ${N.kind}`,onSelect:()=>{s(Sn(N,n)),x()},children:[e.jsx("span",{className:"truncate text-sm",children:N.label}),e.jsx("span",{className:"ml-2 shrink-0 text-xs text-muted-foreground",children:N.kind})]},`${N.kind}:${N.id}`))})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Data handed to the agent alongside its instructions, and what change detection is measured against. Editing an Automation does not re-read the instructions for these — this list is what runs. To add a SQL source, write it with @ in the instructions above. Automation-owned; skills never add or remove sources."})]})}function Xn({organizationId:n,value:s,onChange:t,className:c}){const{data:d=[]}=Gs(n),u=un(d),i=u.find(o=>o.id===s);return e.jsx(ct,{contentClassName:"w-[300px]",searchPlaceholder:"Search entities...",emptyText:"No entities found.",trigger:o=>e.jsxs(J,{variant:"outline",role:"combobox","aria-expanded":o,className:R("w-full justify-between",c),children:[i?`${i.name} (${i.entityType})`:"All workspace",e.jsx(bt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:o=>e.jsxs(e.Fragment,{children:[e.jsxs(Ue,{value:"all workspace",onSelect:()=>{t(void 0),o()},className:"cursor-pointer",children:[e.jsx(rt,{className:R("mr-2 h-4 w-4",s===void 0?"opacity-100":"opacity-0")}),e.jsx("span",{children:"All workspace"})]}),u.map(x=>e.jsxs(Ue,{value:`${x.name} ${x.entityType}`,onSelect:()=>{t(x.id),o()},className:"cursor-pointer",children:[e.jsx(rt,{className:R("mr-2 h-4 w-4",s===x.id?"opacity-100":"opacity-0")}),e.jsxs("span",{children:[x.name," ",e.jsxs("span",{className:"text-muted-foreground text-xs",children:["(",x.entityType,")"]})]})]},x.id))]})})}function it(n){if(Array.isArray(n))return n;if(typeof n=="string"&&n.startsWith("{")&&n.endsWith("}")){const s=n.slice(1,-1);return s?s.split(",").map(t=>t.trim()):[]}return[]}function Zt(n){return JSON.stringify(n,(s,t)=>t&&typeof t=="object"&&!Array.isArray(t)?Object.fromEntries(Object.keys(t).sort().map(c=>[c,t[c]])):t)}const Zn=qn.map(n=>({value:n,label:Kn[n]})),es=[{value:"agent",label:"Agent",hint:"An agent reads the window and follows your instructions."},{value:"code",label:"Code",hint:"A deterministic script processes each completed window."},{value:"both",label:"Agent + code",hint:"An agent extracts per your instructions, then the script runs."}];function ts(n){const s=!!(n?.prompt?.trim()||n?.skills?.some(c=>c.content.trim())),t=!!n?.reaction_script?.trim();return s&&t?"both":t?"code":"agent"}const ea=["text","number","date","boolean","json"],ta=[{value:"key",label:"Key"},{value:"plain",label:"Plain"}],vt=[{value:"plan",label:"Plan first"},{value:"auto",label:"Auto"},{value:"acceptEdits",label:"Accept edits"},{value:"dontAsk",label:"Don't ask"},{value:"bypassPermissions",label:"Bypass permissions"}];let ss=0;function sa(){return ss+=1,`field-${ss}`}function ps(n={}){return{id:sa(),name:n.name??"",type:n.type??"text",role:n.role??"plain"}}function Ze(n){return n.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"")}function na(n){return n?Object.keys(n).every(s=>["entity_type","entity_path","key_fields","key_output_field"].includes(s)):!0}function ns(n){return n?na(n.keying_config)?"fields":"json":"fields"}function as(n){const s=n?.keying_config?.entity_type;return typeof s=="string"?s:""}function os(n){const s=n?.keying_config?.entity_path;return typeof s=="string"&&s.trim()?s:"$"}function is(n){const s=new Map,t=Array.isArray(n?.keying_config?.key_fields)?n?.keying_config?.key_fields:[];for(const c of t){if(typeof c!="string")continue;const d=Ze(c);d&&s.set(d,ps({name:d,role:"key"}))}return Array.from(s.values())}function Y(n,s){const t=n?.execution_config?.[s];return typeof t=="number"||typeof t=="string"?String(t):""}function rs(n,s,t){const c=n?.execution_config?.[s];return typeof c=="string"&&t.includes(c)?c:""}function yt(n,s){const t=n.trim();if(!t)return{};const c=Number(t);return Number.isFinite(c)?{value:c}:{error:`${s} must be a number.`}}function cs({entityType:n,entityPath:s,fields:t}){const d=t.map(o=>({...o,name:Ze(o.name)})).filter(o=>o.name).filter(o=>o.role==="key").map(o=>o.name),u=Ze(n),i=s.trim()||"$";return d.length>0&&!u?{error:"Key fields need an output entity type."}:(d.length>0,{keyingConfig:d.length>0?{entity_type:u,entity_path:i,key_fields:d,key_output_field:`${u}_key`}:void 0})}function aa(n,s){return e.jsxs("div",{className:"space-y-1",children:[e.jsx("h2",{className:"text-sm font-medium",children:n}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s})]})}function ls(n){return!!(n?.keying_config||n?.reactions_guidance||n?.model_config||n?.execution_config||n?.sources?.length||it(n?.tags).length)}function oa({organizationId:n,entityId:s,prefill:t,onSubmit:c,isSubmitting:d,error:u,isEditing:i,onCancel:o,triggerFields:x,submitLabel:N="Create Automation",submitDisabled:m=!1,triggers:p,savedTriggers:$=p,agentFirst:h=!1}){const{lobuEmbedded:k}=Wn(),{currentOwner:S}=xs(),{data:F=[]}=Hs(),{data:W=[]}=Ys(),[f,M]=r.useState(t?.managed_agent_id??""),j=!!t?.managed_agent_id&&!i,[le,I]=r.useState(t?.delivery_target??null),[de,w]=r.useState(!1),[X,v]=r.useState(t?.device_worker_id??""),[_,Se]=r.useState(()=>{const a=qt(t);return a==="manual"&&!i?"agent":a}),E=_==="external"||_==="script",ge=E&&i,[z,pe]=r.useState(t?.agent_kind??""),{data:fe=[]}=us({organizationId:n}),[ve,Ne]=r.useState(t?.name??""),[q,ye]=r.useState(t?.slug??""),[K,ue]=r.useState(!!t?.slug),[G,Z]=r.useState(t?.description??""),[je,Te]=r.useState(t?.prompt??""),[De,Me]=r.useState(!1),se=t?.skills??[],[g,me]=r.useState(t?.sources??[]),[U,te]=r.useState(t?.entity_id??s),[P,Pe]=r.useState(t?.reaction_script??""),[H,Ve]=r.useState(()=>ts(t)),[we,Le]=r.useState(t?.keying_config?JSON.stringify(t.keying_config,null,2):""),[Fe,O]=r.useState(null),[Oe,Re]=r.useState(()=>ns(t)),[he,Ce]=r.useState(()=>as(t)),[$e,Ie]=r.useState(()=>os(t)),[Qe,xe]=r.useState(()=>is(t)),[qe,et]=r.useState(t?.reactions_guidance??""),[Je,tt]=r.useState(()=>Y(t,"timeout_seconds")),[st,kt]=r.useState(()=>Y(t,"max_budget_usd")),[Ae,l]=r.useState(()=>Y(t,"model")),[y,A]=r.useState(()=>rs(t,"permission_mode",vt.map(a=>a.value))),[ee,ne]=r.useState(()=>Y(t,"effort")),[be,T]=r.useState(()=>Y(t,"finalize_nudges")),[ke,V]=r.useState(null),[nt,St]=r.useState(it(t?.tags).join(", ")),[lt,wt]=r.useState(""),[dt,Ct]=r.useState(!!(i||ls(t)));r.useEffect(()=>{if(!t)return;Ne(t.name??""),ye(t.slug??""),ue(!!t.slug),Z(t.description??""),Te(t.prompt??""),Me(!1),me(t.sources??[]),te(t.entity_id??s),v(t.device_worker_id??"");const a=qt(t);Se(a==="manual"&&!i?"agent":a),pe(t.agent_kind??""),Pe(t.reaction_script??""),Ve(ts(t)),Le(t.keying_config?JSON.stringify(t.keying_config,null,2):""),O(null),Re(ns(t)),Ce(as(t)),Ie(os(t)),xe(is(t)),et(t.reactions_guidance??""),tt(Y(t,"timeout_seconds")),kt(Y(t,"max_budget_usd")),l(Y(t,"model")),A(rs(t,"permission_mode",vt.map(C=>C.value))),ne(Y(t,"effort")),T(Y(t,"finalize_nudges")),V(null),St(it(t.tags).join(", ")),wt(""),M(t.managed_agent_id??""),I(t.delivery_target??null),Ct(!!(i||ls(t)))},[t,s,i]);const fs=K?q:It(ve),{data:vs}=Xs(f||null),{data:ys}=Zs(f||null,{enabled:!!f}),ut=yn(vs??null,ys?.catalog??[]),js=wn(p),mt=P.trim().length>0,Ge=!i&&H==="code"?"":je,_s=!i&&H==="agent"?void 0:P.trim()||void 0,Et=_==="script"||(i||H==="code")&&mt,Ft=Cn(Ge,ut,p,Et),Ns=De||Ge.trim()!==""?Ft:null,Ot=En(Ge,ut),ht=[["Name",t?.name??"",ve],["Description",t?.description??"",G],["Instructions",t?.prompt??"",Ge],["Sources",t?.sources??[],g],["Triggers",$??[],p??[]],["Reaction script",t?.reaction_script??"",P],["Reactions guidance",t?.reactions_guidance??"",qe],["Agent",t?.managed_agent_id??null,_==="manual"?null:f||null],["Device",t?.device_worker_id??null,_==="device"&&X||null],["Device runtime",t?.agent_kind??null,_==="device"&&z||null],["Delivery target",t?.delivery_target??null,le],["Timeout seconds",Y(t,"timeout_seconds"),Je],["Budget USD",Y(t,"max_budget_usd"),st],["Model",Y(t,"model"),Ae],["Permission mode",Y(t,"permission_mode"),y],["Effort",Y(t,"effort"),ee],["Finalize nudges",Y(t,"finalize_nudges"),be],["Tags",it(t?.tags),nt.split(",").map(a=>a.trim()).filter(Boolean)],["Change notes","",lt]].filter(([,a,C])=>Zt(a)!==Zt(C)),At=!i&&H!=="agent",Ke=h&&!i,Tt=_==="device"||_==="script"||Ke&&_==="agent",bs=Tt&&!f.trim(),xt=F.length===1?F[0]?.agentId:void 0;r.useEffect(()=>{Ke&&_==="agent"&&!f&&xt&&M(xt)},[Ke,_,f,xt]);const Dt=!!ve.trim()&&!bs&&!Ft&&(!At||mt)&&!de,ks=js&&!Et&&Ot.length===0,Ss=()=>{if(E&&!i){V("Choose a native agent or code module before creating a copy of a legacy Automation.");return}if(!Dt)return;let a;if(!i&&Oe==="fields"){const _e=cs({entityType:he,entityPath:$e,fields:Qe});if(_e.error){O(_e.error);return}a=_e.keyingConfig,O(null)}else if(!i){if(we.trim())try{const _e=JSON.parse(we);if(typeof _e!="object"||Array.isArray(_e)){O("Keying config must be a JSON object.");return}a=_e}catch{O("Invalid JSON. Please check the syntax.");return}O(null)}const C=yt(Je,"Timeout");if(C.error){V(C.error);return}if(C.value!==void 0&&(!Number.isInteger(C.value)||C.value<1)){V("Timeout must be a whole number greater than 0.");return}const B=yt(st,"Budget");if(B.error){V(B.error);return}if(B.value!==void 0&&B.value<0){V("Budget cannot be negative.");return}const L=yt(be,"Finalize nudges");if(L.error){V(L.error);return}if(L.value!==void 0&&(!Number.isInteger(L.value)||L.value<0||L.value>5)){V("Finalize nudges must be a whole number from 0 to 5.");return}const Ee={...Object.fromEntries(Object.entries(t?.execution_config??{}).filter(([_e])=>!["timeout_seconds","max_budget_usd","model","permission_mode","effort","finalize_nudges"].includes(_e))),...C.value!==void 0?{timeout_seconds:C.value}:{},...B.value!==void 0?{max_budget_usd:B.value}:{},...Ae.trim()?{model:Ae.trim()}:{},...y?{permission_mode:y}:{},...ee.trim()?{effort:ee.trim()}:{},...L.value!==void 0?{finalize_nudges:L.value}:{}},Q=E?void 0:Object.keys(Ee).length>0||i?Ee:void 0;V(null);const Cs=nt.trim()?nt.split(",").map(_e=>_e.trim()).filter(Boolean):i?[]:void 0;c({slug:fs,name:ve.trim(),description:i?G.trim():G.trim()||void 0,prompt:Ge,skills:Ot,entity_id:U,sources:g,reaction_script:_s,keying_config:a,reactions_guidance:i?qe.trim():qe.trim()||void 0,execution_config:Q,tags:Cs,outputs:t?.outputs,change_notes:lt.trim()||void 0,managed_agent_id:ge?t?.managed_agent_id??null:_==="manual"?null:f.trim()||null,device_worker_id:_==="device"&&X.trim()||null,agent_kind:_==="device"&&z.trim()||null,delivery_target:le})},Mt=e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"scratch-reaction",children:["Reaction Script"," ",At?e.jsx("span",{className:"text-destructive",children:"*"}):e.jsx("span",{className:"text-xs font-normal text-muted-foreground",children:"(optional)"})]}),e.jsx(Nt,{value:P,onChange:Pe,language:"typescript",placeholder:"export default async function reaction(ctx) { ... }",minHeight:"120px"}),i?null:e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Export ",e.jsx("code",{children:"prepare"})," to save sources before analysis and a default handler to run after completion. A module without agent instructions, extraction input or outputs runs without an LLM."]})]}),Pt=!j&&!ge&&_!=="manual"?e.jsxs("div",{className:"space-y-2",children:[e.jsxs(b,{htmlFor:"scratch-agent-id",children:[E?"Owning agent":"Agent",Tt&&e.jsx("span",{className:"text-destructive",children:" *"})]}),k?e.jsxs(oe,{value:f,onValueChange:M,disabled:F.length===0,children:[e.jsx(ie,{id:"scratch-agent-id",className:"font-mono text-sm",children:e.jsx(re,{placeholder:F.length===0?"No agents yet":"Select a Lobu agent"})}),e.jsx(ce,{children:F.map(a=>e.jsxs(D,{value:a.agentId,children:[a.name," (",a.agentId,")"]},a.agentId))})]}):e.jsx(ae,{id:"scratch-agent-id",value:f,onChange:a=>{M(a.target.value)},placeholder:"e.g., agent-123",className:"font-mono text-sm"}),_==="device"?e.jsx("p",{className:"text-xs text-muted-foreground",children:"The device run uses this agent's memory and tools, acting as the agent's owner."}):Ke?e.jsx("p",{className:"text-xs text-muted-foreground",children:"This agent answers the conversation's messages."}):null]}):null,ws=F.find(a=>a.agentId===f)?.name??f;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"space-y-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs(b,{htmlFor:"scratch-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),!i&&e.jsx("button",{type:"button",onClick:()=>ue(!K),className:"text-xs text-muted-foreground hover:text-foreground",children:K?"Use automatic slug":"Customize slug"})]}),e.jsx(ae,{id:"scratch-name",value:ve,onChange:a=>Ne(a.target.value),placeholder:"e.g., Escalation signals"}),!i&&K?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-slug",children:"Slug"}),e.jsx(ae,{id:"scratch-slug",value:q,onChange:a=>ye(a.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")),placeholder:It(ve)||"custom-slug"})]}):null]})}),Ke?j?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Agent"}),e.jsx("p",{className:"text-sm",children:ws})]}):Pt:null,i?null:e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:"How does this run?"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:es.map(a=>e.jsx("button",{type:"button","aria-pressed":H===a.value,onClick:()=>Ve(a.value),className:R("rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors",H===a.value?"bg-secondary text-secondary-foreground":"text-muted-foreground hover:bg-accent/50 hover:text-foreground"),children:a.label},a.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:es.find(a=>a.value===H)?.hint})]}),i||H!=="code"?e.jsx(Gn,{value:je,onChange:a=>{Me(!0),Te(a)},library:ut,pinned:se,required:ks,error:Ns,owner:S??"",agentId:f,sources:i?g:void 0,onAddSources:i?me:void 0}):null,!i&&H!=="agent"?Mt:null,i?e.jsx(Yn,{sources:g,onChange:me,disabled:d}):null,e.jsx("div",{className:"space-y-4",children:x}),e.jsx(Vn,{organizationId:n,agentId:_==="agent"?f.trim():"",value:le,onChange:I,disabled:d,automationName:ve,onPendingChange:w}),de?e.jsx("p",{className:"text-xs text-destructive",children:"Confirm the digest destination above before saving — an unconfirmed destination is not sent."}):null,e.jsxs(J,{type:"button",variant:"ghost",className:"w-full justify-between px-0 text-muted-foreground hover:bg-transparent hover:text-foreground","aria-expanded":dt,"aria-controls":"automation-advanced-settings",onClick:()=>Ct(a=>!a),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(en,{className:"h-4 w-4"}),"Advanced settings"]}),e.jsx(ms,{className:R("h-4 w-4 transition-transform",dt&&"rotate-180")})]}),e.jsxs("div",{id:"automation-advanced-settings",className:R("space-y-4",!dt&&"hidden"),children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-description",children:"Description"}),e.jsx(ae,{id:"scratch-description",value:G,onChange:a=>Z(a.target.value),placeholder:"What this automation does"})]}),!i&&!s&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Entity scope"}),e.jsx(Xn,{organizationId:n,value:U,onChange:te}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Limit this automation to one workspace entity."})]}),i?Mt:null,i?e.jsxs("section",{"aria-label":"Legacy output configuration",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Legacy output keying is read-only here. This editor cannot save changes to it."}),t?.keying_config?e.jsx(Kt,{before:null,after:t.keying_config}):null]}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(b,{children:"Output fields"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Key fields become stable entity keys."})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:()=>{if(Oe==="fields"){const a=cs({entityType:he,entityPath:$e,fields:Qe});if(a.error){O(a.error);return}Le(a.keyingConfig?JSON.stringify(a.keyingConfig,null,2):""),Re("json")}else Re("fields");O(null)},children:Oe==="fields"?"Edit JSON":"Use fields"})]}),Oe==="fields"?e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-output-entity-type",children:"Output entity type"}),e.jsx(ct,{contentClassName:"w-[320px]",searchPlaceholder:"Search or type a new type…",emptyText:"Type a name to create a new entity type.",trigger:a=>e.jsxs(J,{type:"button",variant:"outline",role:"combobox","aria-expanded":a,id:"scratch-output-entity-type",className:"w-full justify-between font-mono text-sm font-normal",children:[e.jsx("span",{className:R("truncate",!he&&"text-muted-foreground"),children:he||"Select entity type"}),e.jsx(bt,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]}),children:(a,C)=>{const B=Ze(C),L=fe.filter(Q=>!Q.backing_sql),Ee=L.some(Q=>Q.slug===B);return e.jsxs(e.Fragment,{children:[L.map(Q=>e.jsxs(Ue,{value:`${Q.name??Q.slug} ${Q.slug}`,onSelect:()=>{Ce(Q.slug),O(null),a()},className:"cursor-pointer",children:[e.jsx(rt,{className:R("mr-2 h-4 w-4",he===Q.slug?"opacity-100":"opacity-0")}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-mono text-sm",children:Q.slug}),Q.name&&Q.name!==Q.slug&&e.jsx("div",{className:"truncate text-xs text-muted-foreground",children:Q.name})]})]},Q.slug)),B&&!Ee&&e.jsxs(Ue,{value:C,onSelect:()=>{Ce(B),O(null),a()},className:"cursor-pointer",children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),e.jsxs("span",{className:"text-sm",children:["Create"," ",e.jsx("span",{className:"font-mono",children:B})]})]})]})}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-output-path",children:"Output path"}),e.jsx(ae,{id:"scratch-output-path",value:$e,onChange:a=>{Ie(a.target.value),O(null)},placeholder:"$.items[*]",className:"font-mono text-sm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx(b,{children:"Fields"}),e.jsxs(J,{type:"button",variant:"outline",size:"sm",onClick:()=>{xe(a=>[...a,ps()]),O(null)},children:[e.jsx(Xe,{className:"mr-2 h-4 w-4"}),"Add field"]})]}),Qe.length===0?e.jsx("div",{className:R(We,"px-3 py-2 text-sm text-muted-foreground"),children:"No output fields configured."}):e.jsx("div",{className:"space-y-2",children:Qe.map(a=>e.jsxs("div",{className:R(We,"grid gap-2 p-3 sm:grid-cols-[minmax(0,1fr)_128px_minmax(0,240px)_auto]"),children:[e.jsx(ae,{value:a.name,onChange:C=>{const B=Ze(C.target.value);xe(L=>L.map(Ee=>Ee.id===a.id?{...Ee,name:B}:Ee)),O(null)},placeholder:"severity","aria-label":"Output field name",className:"font-mono text-sm"}),e.jsxs(oe,{value:a.type,onValueChange:C=>{xe(B=>B.map(L=>L.id===a.id?{...L,type:C}:L))},children:[e.jsx(ie,{"aria-label":"Output field type",children:e.jsx(re,{})}),e.jsx(ce,{children:ea.map(C=>e.jsx(D,{value:C,children:C},C))})]}),e.jsx("div",{className:"grid grid-cols-2 rounded-md border border-input bg-background p-1",children:ta.map(C=>e.jsx("button",{type:"button",onClick:()=>{xe(B=>B.map(L=>L.id===a.id?{...L,role:C.value}:L)),O(null)},className:R("rounded-sm px-2 py-1 text-xs transition-colors",a.role===C.value?"bg-muted/70 text-foreground":"text-muted-foreground hover:text-foreground"),children:C.label},C.value))}),e.jsx(J,{type:"button",variant:"ghost",size:"icon",onClick:()=>{xe(C=>C.filter(B=>B.id!==a.id)),O(null)},"aria-label":"Remove output field",children:e.jsx(hs,{className:"h-4 w-4"})})]},a.id))})]}),Fe&&e.jsx("p",{className:"text-xs text-destructive",children:Fe})]}):e.jsx("div",{className:"space-y-3",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-keying-config",children:"Keying Config (JSON)"}),e.jsx(Nt,{value:we,onChange:a=>{Le(a),O(null)},language:"json",placeholder:'{ "entity_type": "topic", "entity_path": "$.items[*]", "key_fields": ["name"], "key_output_field": "entity_key" }',minHeight:"60px"}),Fe&&e.jsx("p",{className:"text-xs text-destructive",children:Fe})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-reactions-guidance",children:"Reactions Guidance"}),e.jsx(tn,{id:"scratch-reactions-guidance",value:qe,onChange:a=>et(a.target.value),placeholder:"Guidance text for the reaction system (e.g., when to alert, severity thresholds)...",className:"font-mono text-xs min-h-[80px]"})]}),e.jsxs("div",{className:"space-y-4",children:[aa("Run settings","Choose where the automation runs and the budget it can use."),E?e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Runs on"}),e.jsx("p",{className:"text-sm",children:_==="external"?"External executor":"Script"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"This executor is configured outside this editor."}),ge&&e.jsxs(e.Fragment,{children:[e.jsx(b,{children:"Owning agent"}),e.jsx("p",{className:"text-sm",children:f||"None assigned"})]})]}):!j&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-runs-on",children:"Runs on"}),e.jsxs(oe,{value:_,onValueChange:a=>Se(a),children:[e.jsx(ie,{id:"scratch-runs-on",className:"text-sm",children:e.jsx(re,{})}),e.jsxs(ce,{children:[e.jsx(D,{value:"agent",children:"Managed agent"}),e.jsx(D,{value:"device",children:"On a device"}),e.jsx(D,{value:"manual",children:"Manual-only"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:_==="agent"?"Automated runs dispatch to a managed Lobu agent.":_==="device"?"Automated runs are claimed and executed locally by a device worker (Mac app, remote worker).":"No executor — this automation runs only when started manually by a connected client."})]}),!Ke&&Pt,!j&&_==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-device-id",children:"Device"}),e.jsxs(oe,{value:X||"__unselected__",onValueChange:a=>v(a==="__unselected__"?"":a),children:[e.jsx(ie,{id:"scratch-device-id",className:"font-mono text-sm",children:e.jsx(re,{placeholder:"Select a device worker"})}),e.jsx(ce,{children:W.map(a=>e.jsx(D,{value:a.id,children:a.label||a.platform||a.id},a.id))})]})]}),!j&&_==="device"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-device-agent-kind",children:"Runs as"}),e.jsxs(oe,{value:z||"__default__",onValueChange:a=>pe(a==="__default__"?"":a),children:[e.jsx(ie,{id:"scratch-device-agent-kind",className:"text-sm",children:e.jsx(re,{placeholder:"Device default"})}),e.jsxs(ce,{children:[e.jsx(D,{value:"__default__",children:"Device default"}),Zn.map(a=>e.jsx(D,{value:a.value,children:a.label},a.value))]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Device default uses that device's preferred local agent. Availability is checked again when a run is claimed, so a run stays queued if its selected runtime is no longer available."})]}),!E&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{children:"Model"}),e.jsx(vn,{value:Ae,onChange:a=>{l(a),V(null)},placeholder:"Use agent default"})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-timeout",children:"Timeout seconds"}),e.jsx(ae,{id:"scratch-timeout",type:"number",min:1,max:86400,value:Je,onChange:a=>{tt(a.target.value),V(null)},placeholder:"600"})]}),e.jsxs("div",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-permission-mode",children:"Permission mode"}),e.jsxs(oe,{value:y||"__default__",onValueChange:a=>{A(a==="__default__"?"":a),V(null)},children:[e.jsx(ie,{id:"scratch-permission-mode",children:e.jsx(re,{placeholder:"Default"})}),e.jsxs(ce,{children:[e.jsx(D,{value:"__default__",children:"Default"}),vt.map(a=>e.jsx(D,{value:a.value,children:a.label},a.value))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-effort",children:"Effort"}),e.jsx(ae,{id:"scratch-effort",value:ee,onChange:a=>{ne(a.target.value),V(null)},placeholder:"Default","aria-describedby":"scratch-effort-help"}),e.jsx("p",{id:"scratch-effort-help",className:"text-xs text-muted-foreground",children:"For device runs, use a value supported by the selected CLI and model. Leave empty for its default."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-finalize-nudges",children:"Finalize nudges"}),e.jsx(ae,{id:"scratch-finalize-nudges",type:"number",min:0,max:5,value:be,onChange:a=>{T(a.target.value),V(null)},placeholder:"Default"})]})]}),ke&&e.jsx("p",{className:"text-xs text-destructive",children:ke})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-tags",children:"Tags"}),e.jsx(ae,{id:"scratch-tags",value:nt,onChange:a=>St(a.target.value),placeholder:"ops, support, risk"})]}),i&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(b,{htmlFor:"scratch-change-notes",children:"Change notes"}),e.jsx(ae,{id:"scratch-change-notes",value:lt,onChange:a=>wt(a.target.value),placeholder:"What changed in this version?"})]})]})]}),(E&&ke||u&&!Fe&&!ke)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-destructive",children:E&&ke?ke:u}),i&&ht.length>0?e.jsxs("section",{"aria-label":"Review changes",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Review changes"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved values compared with this draft. Only changed fields are shown."}),e.jsx(Kt,{before:Object.fromEntries(ht.map(([a,C])=>[a,C])),after:Object.fromEntries(ht.map(([a,,C])=>[a,C]))})]}):null,e.jsx(_t,{onCancel:o,children:e.jsx(J,{onClick:Ss,disabled:!Dt||d||m,children:d?e.jsxs(e.Fragment,{children:[e.jsx(sn,{size:"lg",className:"mr-2"}),i?"Saving...":"Creating..."]}):i?"Save Automation":N})})]})}function ia(n,s){const t=n??null,c=s??null;return t===null||c===null?t===c:t.connection_id===c.connection_id&&t.channel_id===c.channel_id}function ra(n){const s=n.detail??{};return{name:n.name,slug:s.slug,description:s.description??n.description??void 0,prompt:s.prompt,triggers:s.triggers,sources:s.sources,keying_config:s.keying_config,reactions_guidance:s.reactions_guidance,reaction_script:s.reaction_script,model_config:s.model_config,execution_config:s.execution_config,tags:s.tags,outputs:s.outputs}}function ja({startFromScratch:n=!1,onClose:s,hideCancel:t=!1,hideHeader:c=!1,organizationId:d,entityId:u,entityName:i,prefillAgentId:o,conversationSetup:x,onSuccess:N,editingAutomation:m,catalogPrefill:p,onDraft:$,triggerFields:h,submitLabel:k,submitDisabled:S,createFields:F,onPrefillTriggers:W}){const f=mn(),M=hn(),j=xn(),le=gn(),I=!!m,[de,w]=r.useState(n?"scratch":"template"),[X,v]=r.useState(void 0),[_,Se]=r.useState(void 0),{data:E=[],isLoading:ge}=pn(),[z,pe]=r.useState(""),fe=x?.name,ve=r.useMemo(()=>o||fe?{...fe?{name:fe}:{},...o?{managed_agent_id:o}:{}}:void 0,[o,fe]),Ne=r.useMemo(()=>E.map(g=>({key:g.id,name:g.name,description:g.description??"",badges:g.detail?.tags??[]})),[E]),q=r.useMemo(()=>Ne.filter(g=>g.name.toLowerCase().includes(z.toLowerCase())||g.description.toLowerCase().includes(z.toLowerCase())),[Ne,z]),ye=g=>{const me=E.find(te=>te.id===g.key);if(!me)return;const U=ra(me);Se(o?{...U,managed_agent_id:o}:U),W?.(U.triggers??[]),w("scratch")},K=()=>{f.reset(),M.reset(),w("template"),v(void 0),Se(void 0),s()},ue=I?F?.triggers??m.triggers??[]:F?.triggers??_?.triggers??p?.triggers??[],G=async g=>{try{if($){await $(g);return}if(I){const me=F?.triggers??m.triggers??[],U=m.reaction_script??"",te=g.reaction_script??"";te&&te!==U&&await j.mutateAsync({automation_id:m.automation_id,reaction_script:te}),await M.mutateAsync({automation_id:m.automation_id,name:g.name,description:g.description,prompt:g.prompt,sources:g.sources,set_as_current:!0,triggers:me,keying_config:g.keying_config,reactions_guidance:g.reactions_guidance,change_notes:g.change_notes}),!te&&U&&await j.mutateAsync({automation_id:m.automation_id,reaction_script:""});const P={};g.model_config!==void 0&&(P.model_config=g.model_config),g.execution_config!==void 0&&(P.execution_config=g.execution_config),g.tags!==void 0&&(P.tags=g.tags),g.delivery_target!==void 0&&!ia(g.delivery_target,m.delivery_target)&&(P.delivery_target=g.delivery_target),g.managed_agent_id!==void 0&&(P.managed_agent_id=g.managed_agent_id||null),g.agent_kind!==void 0&&(P.agent_kind=g.agent_kind||null),g.device_worker_id!==void 0&&(P.device_worker_id=g.device_worker_id||null),Object.keys(P).length>0&&await le.mutateAsync({automation_id:m.automation_id,...P}),K(),N?.(m.automation_id)}else{const me=F?.triggers??_?.triggers??p?.triggers??[],U=await f.mutateAsync({...g,managed_agent_id:g.managed_agent_id??void 0,device_worker_id:g.device_worker_id??void 0,agent_kind:g.agent_kind??void 0,delivery_target:g.delivery_target??void 0,triggers:me});K(),U.automation_id&&N?.(U.automation_id)}}catch{}},Z=I?M:f;let je="Add an automation";I?je="Edit automation configuration (saves as a new version)":i&&(je=`Add an automation for ${i}`);const Te=r.useMemo(()=>m?{entity_id:m.entity_id,name:m.name,slug:m.slug,description:m.description,prompt:m.prompt,sources:m.sources,reaction_script:m.reaction_script,device_worker_id:m.device_worker_id??void 0,agent_kind:m.agent_kind??void 0,keying_config:m.keying_config,reactions_guidance:m.reactions_guidance,model_config:m.model_config,execution_config:m.execution_config,tags:m.tags,managed_agent_id:m.managed_agent_id??void 0,delivery_target:m.delivery_target??void 0}:void 0,[m]),De=I?"Edit Automation":"Create Automation",Me=e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("h1",{className:"text-2xl font-semibold leading-tight",children:De}),e.jsx("p",{className:"text-sm text-muted-foreground",children:je})]}),se=e.jsxs("div",{className:"py-6 space-y-6",children:[!I&&e.jsxs("div",{className:"flex flex-wrap justify-start gap-2",children:[e.jsx(jt,{active:de==="template",onClick:()=>w("template"),icon:e.jsx(nn,{className:"h-4 w-4"}),label:"From templates"}),e.jsx(jt,{active:de==="scratch",onClick:()=>{w("scratch"),v(void 0),Se(void 0)},icon:e.jsx(Xe,{className:"h-4 w-4"}),label:"From scratch"}),e.jsx(jt,{active:de==="clone",onClick:()=>w("clone"),icon:e.jsx(an,{className:"h-4 w-4"}),label:"Clone existing"})]}),!I&&de==="template"?e.jsxs(e.Fragment,{children:[ge?e.jsx(on,{}):e.jsx(rn,{items:q,searchQuery:z,onSearchChange:pe,onSelect:ye,searchPlaceholder:"Search templates...",searchAriaLabel:"Search automation templates",emptyMessage:Ne.length===0?"No automation templates available.":void 0}),c&&!t?e.jsx(_t,{onCancel:K}):null]}):!I&&de==="clone"&&!X?e.jsxs(e.Fragment,{children:[e.jsx(ca,{organizationId:d,onSelect:g=>{v(g),W?.(g.triggers??[]),w("scratch")}}),c&&!t?e.jsx(_t,{onCancel:K}):null]}):e.jsx(oa,{organizationId:d,entityId:u,prefill:Te??X??_??p??ve,onSubmit:G,isSubmitting:Z.isPending,error:Z.error?Z.error.message:null,isEditing:I,onCancel:t?void 0:K,triggerFields:h,submitLabel:k,submitDisabled:S,triggers:ue,savedTriggers:m?.triggers,agentFirst:!!x})]});return e.jsxs("div",{className:"flex flex-col",children:[c?null:Me,se]})}function jt({active:n,onClick:s,icon:t,label:c}){return e.jsxs("button",{type:"button",onClick:s,className:R("flex items-center gap-2 rounded-md border px-3 py-2 text-sm transition-colors",n?"border-primary bg-primary/5 text-primary":"border-border text-muted-foreground hover:border-muted-foreground/30 hover:text-foreground"),children:[t,c]})}function ca({organizationId:n,onSelect:s}){const{data:t,isLoading:c}=fn(n),[d,u]=r.useState(""),i=(t||[]).filter(o=>o.name?.toLowerCase().includes(d.toLowerCase()));return c?e.jsx(cn,{label:"automations",variant:"list-picker",rows:4}):!t||t.length===0?e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:"No existing automations to clone."}):e.jsxs("div",{className:"space-y-3",children:[e.jsx("input",{type:"text",value:d,onChange:o=>u(o.target.value),placeholder:"Search automations...",className:"w-full rounded-md border px-3 py-2 text-sm bg-background"}),e.jsxs("div",{className:"space-y-2 max-h-[400px] overflow-y-auto",children:[i.map(o=>e.jsxs("button",{type:"button",onClick:()=>s({name:`${o.name} (copy)`,slug:`${o.slug||o.automation_id}-copy`,prompt:o.prompt,keying_config:o.keying_config,triggers:o.triggers,sources:o.sources,outputs:o.outputs}),className:"w-full text-left rounded-md border p-3 hover:border-primary/50 hover:bg-primary/5 transition-colors",children:[e.jsx("p",{className:"text-sm font-medium",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:[o.entity_name||"Space-level"," · v",o.version??"?"]})]},o.automation_id)),i.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"No automations match your search."})]})]})}export{ya as A,ja as C};
3
+ //# sourceMappingURL=create-automation-form-PEmSLMD6.js.map
@@ -0,0 +1,2 @@
1
+ import{j as n,az as t,O as c,aH as r,al as i,gR as l,b3 as m,gS as x,L as d,gT as u,gU as C,fL as j}from"./index-DdBTTN3y.js";function p({owner:o,initialConnectorKey:e}){return n.jsx(t,{owner:o,children:a=>n.jsx(g,{ownerSlug:a.ownerSlug,organizationId:a.organizationId,initialConnectorKey:e})})}function g({ownerSlug:o,organizationId:e,initialConnectorKey:a}){const{data:s=[]}=r(e??"");return n.jsxs(i,{className:"flex flex-1 flex-col gap-6",children:[n.jsx(l,{breadcrumb:n.jsx(x,{crumbs:[n.jsx(d,{to:"/$owner/connectors",params:{owner:o},search:{},className:u,children:"Connectors"},"connectors")]}),icon:n.jsx(m.connectors.icon,{className:"h-6 w-6"}),title:"Add a connection",caption:"Pick a connector from the catalog or drop in an MCP URL — Lobu handles auth and brings the data into memory."}),e?n.jsx(C,{ownerSlug:o,organizationId:e,connections:s,initialConnectorKey:a},a??"catalog"):n.jsx("div",{className:"max-w-3xl",children:n.jsx(j,{rows:4})})]})}const f=()=>n.jsx(c,{});export{p as ConnectionsCreateRouteContent,f as component};
2
+ //# sourceMappingURL=create-jBEuveV1.js.map
@@ -0,0 +1,2 @@
1
+ import{iP as e,j as t,hN as r}from"./index-DdBTTN3y.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-DcxhYIYC.js.map
@@ -0,0 +1,2 @@
1
+ import{M as Ce,q as je,r as h,P as Ne,j as e,I as Se,B as ce,Q as ie}from"./index-DdBTTN3y.js";import{u as Ae,r as te,o as M,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-CmyQW7GT.js";import{F as Ie}from"./full-page-spinner-BqmckkOf.js";import{w as A}from"./workspace-label-o_QfBuCM.js";import"./card-Bdi7VEwo.js";const Le=[];function F(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 Ve(){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,q]=h.useState(null),k=h.useRef(0),j=Ne(t.return_to),V=j?"app":"terminal",de=!!t.user_code,_=F(u),m=$?.code===_?$:null,v=m!==null,D=m?.scopes??Le,E=D.includes("device_worker:run"),ue=D.includes("connections:token"),I=m?.multiWorkspaceGrantsEnabled===!0,{accessLevel:G,setAccessLevel:L,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:I,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,Q=l&&(Y||R===null||we),K=N&&Y&&(I||!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(M(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}),L(_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)}},[L]);De(!!i,n),h.useEffect(()=>{if(!(n||!i||!t.user_code))return W(F(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 ${V}.`);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(M(S,"Failed to process device authorization"));const oe=o?"approved":"denied";if(S?.status!==oe)throw new Error(M(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"?F(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(Ie,{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(),q(null),g(null),s(null)},placeholder:"ABCD-1234",className:"font-mono text-center text-lg tracking-widest",maxLength:9,autoFocus:!t.user_code})]}),H=Q?e.jsx(We,{deviceName:m?.clientName??null,orgList:C,deviceHomeOrgId:R,onChange:q,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:L,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&&!Q&&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&&!K?H:null]}):ee,ke=K?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:I,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 ${V}.`,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{Ve as component};
2
+ //# sourceMappingURL=device-Ba3RsIgb.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,fL as j,r as f,iJ as v,iK as C,gu as k,B as L,L as A,d6 as w,iL as I,iM as N,iN as E,u as O,iO as F,gw as P}from"./index-DdBTTN3y.js";import{b as S}from"./runs-table-XGnxJl7S.js";import{R as b}from"./run-activity-link-CaIBSRQj.js";import{c as y,C as R,b as $}from"./connector-scope-lists--vNdbOn0.js";function V({formRows:s=5}){return e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1fr)_360px]",children:[e.jsx(S,{}),e.jsx(j,{rows:s})]})}function H({connection:s,connectorDef:t,ownerSlug:a,openSettings:n=!1,authResult:o,showActivity:r=!0,embedded:i=!1,showShare:c=!0}){const[l,d]=f.useState(n);f.useEffect(()=>{n&&d(!0)},[n]);const m=s.id,u=s.connector_key,p=s.facets?.chat??!1,h=p?"Channels":"Feeds",x=s.has_operations===!0,_=s.feed_count>0||y(t),g=e.jsx(E,{connection:s,connectorDef:t,ownerSlug:a,showShare:c});return e.jsxs("div",{className:"space-y-6",children:[o&&e.jsx(v,{result:o}),s.auth_profile_kind==="oauth_account"&&e.jsx(C,{connection:s,connectorDef:t,onReview:()=>{d(!0),requestAnimationFrame(()=>document.getElementById("connection-auth")?.scrollIntoView({block:"nearest"}))}}),(_||x)&&e.jsxs("div",{className:i?"space-y-6":"grid grid-cols-1 items-start gap-3 sm:grid-cols-2",children:[_&&(i?e.jsx(k,{title:h,count:s.feed_count===1?"1 source":`${s.feed_count} sources`,action:y(t)?e.jsx(L,{asChild:!0,size:"sm",variant:"outline",children:e.jsxs(A,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:a,connectorKey:u,connectionId:String(m)},search:{addFeed:!0},children:[e.jsx(w,{className:"h-3.5 w-3.5"}),p?"Add channel":"Add source"]})}):null,children:e.jsx(R,{connection:s,ownerSlug:a,connectorKey:u,connectorDef:t})}):e.jsx($,{connection:s,ownerSlug:a,title:h})),x&&(i?e.jsx(I,{connection:s,ownerSlug:a}):e.jsx(B,{connection:s,ownerSlug:a}))]}),i?e.jsx(N,{title:"Connection settings",summary:"name, visibility, credentials, remove",open:l,onOpenChange:d,children:g}):g,r&&e.jsx(b,{owner:a,filters:{connectionIds:[m]},name:s.display_name||u})]})}function B({connection:s,ownerSlug:t}){const a=O(),{data:n=[],isLoading:o,isError:r}=F(s.id),i=n.filter(l=>l.readiness==="scope_upgrade_required").length,c=o?"Loading actions…":r?"Could not load actions — open to retry":`${n.length} actions${i?` · ${i} need additional provider access`:" · permissions and approval policy"}`;return e.jsx(P,{title:"Actions",summary:c,onOpen:()=>a?.open({href:"",title:"Actions",connectorPanel:{section:"actions",connectionId:s.id,connectorKey:s.connector_key,organizationId:s.organization_id,ownerSlug:t}})})}const K=new Set(["Device was removed","Device was moved to another workspace"]);function J(s){const t=s.error_message??null;return!t||!K.has(t)?t:!!s.device_worker_id&&(s.device_last_seen_at!=null||s.device_worker_handle!=null||s.device_label!=null)?null:t}export{H as C,V as R,J as c};
2
+ //# sourceMappingURL=device-pin-tombstone-C79KIAIK.js.map
@@ -0,0 +1,2 @@
1
+ import{aQ as G,iw as ne,ix as U,r as v,j as e,iy as z,B as b,ab as L,gr as C,aH as Y,aB as te,gu as R,S as I,b7 as M,dS as ae,dU as ie,C as ce,dY as oe,iz as re,a1 as le,c as de,aG as me,iA as ue,iB as xe,iC as he,aJ as pe,aC as fe,al as P,b6 as q,L as E,iD as ge,iE as je,aW as ve,iF as ye,iG as be,W as Ne,gR as ke,iH as H,I as _e,bc as we,e_ as Ce,gS as Se,gT as K,e5 as $e,iI as O,az as De}from"./index-DdBTTN3y.js";import{C as Pe}from"./connector-page-shell-Cs1SjrYB.js";import{c as V,C as ze,R as Le}from"./device-pin-tombstone-C79KIAIK.js";import{R as Re}from"./runs-panel-DEnZHTa5.js";import{S as Ie,g as Ae}from"./runs-table-XGnxJl7S.js";import{c as Ee}from"./connection-label-BobuYiAG.js";import{w as B}from"./workspace-label-o_QfBuCM.js";import"./run-activity-link-CaIBSRQj.js";import"./connector-scope-lists--vNdbOn0.js";import"./status-dot-Cpq63I7p.js";import"./use-scroll-sentinel-DRyBMueA.js";import"./runs-fFJ1lPnw.js";import"./filter-bar-wPaR12SS.js";import"./calendar-Ck0yOLYu.js";import"./manage-gear-D8LMhehh.js";import"./run-initiator-BvzQJYW9.js";import"./use-automations-BLNjxq2K.js";import"./clients-BJRcMk1A.js";import"./table-BUqshjxa.js";function Be(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(J(s,o).map(t=>t.connector_key));return n.filter(t=>G(t)&&!!t.required_capability&&h.has(t.required_capability)&&!m.has(t.key)&&!r.has(t.key))}function J(s,n){return s.organization_slug===n?s.update_required:[]}function Me(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),[g,a]=v.useState(null),[f,N]=v.useState(null),[j,d]=v.useState([]),x=s.organization_id===n,y=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(j.map(i=>i.connectorKey)),l=J(s,o),c=h.filter(i=>!k.has(i.key));return e.jsxs("div",{className:"mt-4 space-y-3",children:[j.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&&z[i.required_capability]&&z[i.required_capability]!==i.name?e.jsx("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:z[i.required_capability]}):null]}),e.jsxs(b,{size:"sm",variant:"outline","aria-label":`Connect ${i.name}`,disabled:g!==null,onClick:()=>x?void y(i):p(i.key),children:[g===i.key?e.jsx(L,{className:"mr-1.5"}):null,"Connect"]})]}),u===i.key?e.jsx(Q,{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 y(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 Q({device:s,ownerSlug:n,title:o,intro:h,aftermath:m,confirmLabel:r,pending:t=!1,onConfirm:u,onCancel:p}){const g=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:[g>0?`Moving pauses and unpins all ${g} connection${g===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(b,{size:"sm",disabled:t,onClick:u,children:[t?e.jsx(L,{className:"mr-1.5"}):null,r]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:t,onClick:p,children:"Cancel"})]})]})}function qe({outcome:s,device:n,organizationId:o}){const{data:h=[],isLoading:m}=Y(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=V(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 W({device:s,organizationId:n,ownerSlug:o,selectedConnection:h,openSettings:m}){const{data:r=[],isLoading:t,isError:u,refetch:p}=te(n),g=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=g.get(d.connector_key);if(!x||!G(x)){f.push(d);continue}const y=x.required_capability??`connector:${x.key}`,k=a.get(y)??{key:y,name:x.name,connections:[]};k.name=z[y]??x.name,k.connections.push(d),a.set(y,k)}const N=Be(s,r,o),j=Me(s,r,o);return e.jsxs(e.Fragment,{children:[e.jsxs(R,{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(I,{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(b,{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(F,{group:d,deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d.key))}),n&&!t&&!u?e.jsx(Te,{device:s,organizationId:n,ownerSlug:o,connectable:N,unavailable:j}):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(R,{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(F,{group:{key:d,name:g.get(d)?.name??d,connections:f.filter(x=>x.connector_key===d)},deviceId:s.id,organizationId:n,ownerSlug:o,definitionsByKey:g,selectedConnection:h,openSettings:m},d))})]}):null]})}function F({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,g]=v.useState(u);return v.useEffect(()=>{u&&r!==void 0&&g(!0)},[u,r]),e.jsxs(ae,{open:p,onOpenChange:g,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(He,{summary:a,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m.get(a.connector_key),openSettings:a.connection_id===r&&t},a.connection_id))})})]})}function He({summary:s,deviceId:n,organizationId:o,ownerSlug:h,connectorDef:m,openSettings:r}){const{data:t=[],isLoading:u,isError:p,refetch:g}=Y(o,{connectionIds:[s.connection_id]}),a=t.find(j=>j.id===s.connection_id&&j.device_worker_id===n),f=m?.name??s.connector_key,N=a?V(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:Ee(a)}),e.jsx("span",{children:a.status})]}):null,u||!o?e.jsx(I,{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(b,{variant:"outline",size:"sm",onClick:()=>void g(),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(re,{connection:a})}),e.jsx(ze,{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 Ke({device:s,ownerSlug:n}){const o=v.useId(),{data:h=[]}=le(),m=U(),[r,t]=v.useState(!1),[u,p]=v.useState(null),[g,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),j=N?B(N):s.organization_name??"No workspace",d=f.filter(l=>l.id!==s.organization_id),x=d.find(l=>l.id===u)??null,y=()=>{t(!1),p(null)},k=async l=>{a(null);try{await m.mutateAsync({deviceWorkerId:s.id,organizationId:l}),y()}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: "}),j]}),!r&&d.length>0?e.jsx(b,{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:B(l)},l.id))]}),x?null:e.jsx(b,{size:"sm",variant:"ghost",onClick:y,children:"Cancel"})]}):null,x?e.jsx(Q,{device:s,ownerSlug:n,title:`Move device to ${x.name}`,intro:`Move ${C(s)} from ${j} to ${B(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:y}):null,g?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}):null]})}function Oe({ownerSlug:s,deviceId:n,organizationId:o,selectedConnection:h,openSettings:m}){const r=de(),{data:t=[],isLoading:u,isError:p,refetch:g}=me(),a=ue(),f=xe(),[N,j]=v.useState(!1),[d,x]=v.useState(!1),[y,k]=v.useState(""),l=he(t,n),c=l&&pe(l,s)?l:void 0,i=c?.id??n,{data:w=[]}=fe(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.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{className:"h-6 w-6 rounded"}),e.jsx(I,{className:"h-5 w-40"})]}),e.jsx(Le,{})]});if(p)return e.jsx(P,{children:e.jsxs("div",{role:"alert",className:"space-y-2",children:[e.jsx("p",{children:"Could not load this device."}),e.jsx(b,{variant:"outline",size:"sm",onClick:()=>void g(),children:"Retry"})]})});if(!c&&l&&o)return e.jsxs(P,{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(q,{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(W,{device:l,organizationId:o,ownerSlug:s})]});if(!c)return e.jsxs(P,{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(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:"text-sm text-primary hover:underline",children:"Back to connectors"})]});const D=ge(c),A=D?je(s,D,ve()):void 0,X=M(c),Z=ye(c.app_version),ee=be(c,Z),T=()=>{const _=y.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(Pe,{header:e.jsx(ke,{breadcrumb:e.jsx(Se,{crumbs:[e.jsx(E,{to:"/$owner/connectors",params:{owner:s},search:{},className:K,children:"Connectors"},"connectors"),...A?[e.jsx(E,{to:"/$owner/connectors/app/$appId",params:{owner:s,appId:A.id},className:K,children:A.name},"app")]:[]]}),icon:e.jsx(q,{platform:X,className:"h-5 w-5"}),title:d?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(_e,{"aria-label":"Device name",value:y,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||T()):_.key==="Escape"&&(j(!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(b,{variant:"destructive",size:"sm",disabled:a.isPending,onClick:()=>a.mutate(c.id,{onSuccess:()=>{j(!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(b,{size:"sm",variant:"ghost",disabled:a.isPending,onClick:()=>j(!1),children:"Cancel"})]}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(b,{size:"sm",onClick:T,disabled:f.isPending,children:[f.isPending?e.jsx(L,{className:"mr-1.5"}):null,f.isPending?"Saving...":"Save"]}),e.jsx(b,{size:"sm",variant:"ghost",disabled:f.isPending,onClick:()=>{k(c.label?.trim()??""),x(!1)},children:"Cancel"}),e.jsxs(b,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",disabled:f.isPending||a.isPending,onClick:()=>j(!0),children:[e.jsx(we,{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(b,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 text-muted-foreground","aria-label":"Edit device",onClick:()=>{j(!1),k(c.label?.trim()??""),x(!0)},children:e.jsx(Ce,{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 ${H(new Date(c.last_seen_at),{addSuffix:!0})}${c.last_sync_at?` · Last sync ${H(new Date(c.last_sync_at),{addSuffix:!0})}`:""}`}),children:[e.jsx(Ke,{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(Ne,{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(W,{device:c,organizationId:o,ownerSlug:s,selectedConnection:h,openSettings:m}),S.length>0?e.jsx(R,{title:"Browser auth profiles",children:e.jsx(We,{profiles:S})}):null,e.jsx(R,{title:"Runs",children:e.jsx(Re,{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 ",$e(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(Ie,{status:n.is_expired?"error":Ae(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 ds(){const{owner:s,deviceId:n}=O.useParams(),{connection:o,settings:h}=O.useSearch();return e.jsx(De,{owner:s,children:({ownerSlug:m,organizationId:r})=>e.jsx(Oe,{ownerSlug:m,deviceId:n,organizationId:r,selectedConnection:o,openSettings:h})})}export{ds as component};
2
+ //# sourceMappingURL=device._deviceId-CIaoq9co.js.map
@@ -1,2 +1,2 @@
1
- import{r as a,j as l,g8 as A,h as f,d8 as O}from"./index-008wj-Pz.js";var S="Separator",m="horizontal",k=["horizontal","vertical"],b=a.forwardRef((e,t)=>{const{decorative:r,orientation:o=m,...i}=e,n=I(o)?o:m,c=r?{role:"none"}:{"aria-orientation":n==="vertical"?n:void 0,role:"separator"};return l.jsx(A.div,{"data-orientation":n,...c,...i,ref:t})});b.displayName=S;function I(e){return k.includes(e)}var y=b;const P=a.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},i)=>l.jsx(y,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));P.displayName=y.displayName;function g(e,t){const r=e?.properties;if(r)return Object.entries(r).find(([,o])=>o[t])?.[0]}function R(e){const t=e.trim(),r=t.split(/[\s._@/-]+/).filter(Boolean),o=r.length>=2?`${r[0][0]}${r[1][0]}`:(r[0]??t).slice(0,2);let i=0;for(let n=0;n<t.length;n++)i=i*31+t.charCodeAt(n)>>>0;return{initials:o.toUpperCase()||"?",hue:i%360}}function T(e){const[t,r]=a.useState();return a.useEffect(()=>{if(!e){r(void 0);return}let o=!1;const i=e.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)).then(n=>{o||r(Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join(""))}),()=>{o=!0}},[e]),t?`https://www.gravatar.com/avatar/${t}?d=identicon&s=80`:void 0}function $({metadata:e,metadataSchema:t,name:r,typeIcon:o,className:i="h-6 w-6",iconClassName:n="h-5 w-5",initialsFallback:s=!1}){const c=g(t,"x-image"),u=g(t,"x-email"),p=c&&e?.[c]||void 0,v=u&&e?.[u]||void 0,x=T(p?void 0:v),d=p||x,[w,h]=a.useState(!1);if(a.useEffect(()=>{h(!1)},[d]),d&&!w)return l.jsx("img",{src:d,alt:r,referrerPolicy:"no-referrer",onError:()=>h(!0),className:f("rounded-full object-cover border border-border",i)});if(s){const E=r.trim()||v||z(e,t)||r,{initials:j,hue:N}=R(E);return l.jsx("span",{role:"img","aria-label":r,className:f("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",i),style:{background:`oklch(0.55 0.13 ${N})`,fontSize:"0.85em"},children:j})}return l.jsx(O,{icon:o,className:n})}function z(e,t){if(!e)return;const r=t?.properties,o=["email","handle","username","login","github","x_handle","slug"],i=Object.keys(r||e);for(const n of i)if(o.includes(n.toLowerCase())){const s=e[n];if(typeof s=="string"&&s.trim())return s}}export{$ as E,P as S};
2
- //# sourceMappingURL=entity-avatar-CEV4ttUQ.js.map
1
+ import{r as a,j as l,bu as A,i as f,d5 as O}from"./index-DdBTTN3y.js";var S="Separator",m="horizontal",k=["horizontal","vertical"],g=a.forwardRef((e,t)=>{const{decorative:r,orientation:o=m,...i}=e,n=I(o)?o:m,c=r?{role:"none"}:{"aria-orientation":n==="vertical"?n:void 0,role:"separator"};return l.jsx(A.div,{"data-orientation":n,...c,...i,ref:t})});g.displayName=S;function I(e){return k.includes(e)}var y=g;const P=a.forwardRef(({className:e,orientation:t="horizontal",decorative:r=!0,...o},i)=>l.jsx(y,{ref:i,decorative:r,orientation:t,className:f("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...o}));P.displayName=y.displayName;function b(e,t){const r=e?.properties;if(r)return Object.entries(r).find(([,o])=>o[t])?.[0]}function R(e){const t=e.trim(),r=t.split(/[\s._@/-]+/).filter(Boolean),o=r.length>=2?`${r[0][0]}${r[1][0]}`:(r[0]??t).slice(0,2);let i=0;for(let n=0;n<t.length;n++)i=i*31+t.charCodeAt(n)>>>0;return{initials:o.toUpperCase()||"?",hue:i%360}}function T(e){const[t,r]=a.useState();return a.useEffect(()=>{if(!e){r(void 0);return}let o=!1;const i=e.trim().toLowerCase();return crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)).then(n=>{o||r(Array.from(new Uint8Array(n)).map(s=>s.toString(16).padStart(2,"0")).join(""))}),()=>{o=!0}},[e]),t?`https://www.gravatar.com/avatar/${t}?d=identicon&s=80`:void 0}function $({metadata:e,metadataSchema:t,name:r,typeIcon:o,className:i="h-6 w-6",iconClassName:n="h-5 w-5",initialsFallback:s=!1}){const c=b(t,"x-image"),u=b(t,"x-email"),p=c&&e?.[c]||void 0,v=u&&e?.[u]||void 0,x=T(p?void 0:v),d=p||x,[w,h]=a.useState(!1);if(a.useEffect(()=>{h(!1)},[d]),d&&!w)return l.jsx("img",{src:d,alt:r,referrerPolicy:"no-referrer",onError:()=>h(!0),className:f("rounded-full object-cover border border-border",i)});if(s){const E=r.trim()||v||z(e,t)||r,{initials:j,hue:N}=R(E);return l.jsx("span",{role:"img","aria-label":r,className:f("inline-grid place-items-center rounded-full border border-border font-semibold text-white select-none",i),style:{background:`oklch(0.55 0.13 ${N})`,fontSize:"0.85em"},children:j})}return l.jsx(O,{icon:o,className:n})}function z(e,t){if(!e)return;const r=t?.properties,o=["email","handle","username","login","github","x_handle","slug"],i=Object.keys(r||e);for(const n of i)if(o.includes(n.toLowerCase())){const s=e[n];if(typeof s=="string"&&s.trim())return s}}export{$ as E,P as S};
2
+ //# sourceMappingURL=entity-avatar-TVKjZxWQ.js.map
@@ -0,0 +1,2 @@
1
+ import{c as x,at as m,j as e,bl as C,bm as _,bn as S,bo as b,bp as i,fB as u}from"./index-DdBTTN3y.js";import{c as w}from"./connection-label-BobuYiAG.js";const h="__connection_picker_create_new__";function y({connections:s,value:r,onValueChange:n,connectorKey:a,disabled:p,placeholder:d="Choose a connection",includeWorkspaceEvents:c=!1,ariaLabel:f="Connection"}){const g=x(),l=m().org?.slug,o=a?s.filter(t=>t.connector_key===a):s,j=t=>{if(t===h){if(!l)return;g({to:"/$owner/connectors/create",params:{owner:l},search:a?{connector:a}:{}});return}n(t)};return e.jsxs(C,{value:r,onValueChange:j,disabled:p,children:[e.jsx(_,{"aria-label":f,children:e.jsx(S,{placeholder:d})}),e.jsxs(b,{children:[c?e.jsxs(e.Fragment,{children:[e.jsx(i,{value:"workspace",children:"Current workspace"}),o.length>0?e.jsx(u,{}):null]}):null,o.map(t=>e.jsx(i,{value:String(t.id),children:w(t)},t.id)),l?e.jsxs(e.Fragment,{children:[o.length>0||c?e.jsx(u,{}):null,e.jsx(i,{value:h,children:"Connect an app…"})]}):null]})]})}function v(s){const r=[];for(const n of s)typeof n.id=="number"&&r.push({id:n.id,name:n.name,entityType:n.entity_type}),n.children&&n.children.length>0&&r.push(...v(n.children));return r}export{y as C,v as f};
2
+ //# sourceMappingURL=entity-options-daOOQo7O.js.map
@@ -0,0 +1,2 @@
1
+ import{dj as we,r as R,c2 as Se,jH as S,g3 as Re,ev as ae,j as e,B as N,u as Y,jB as Fe,S as ne,gb as pe,jI as Ee,E as De,c as xe,b as Ce,c3 as B,at as Le,k as Be,ex as X,eP as Pe,jC as Ve,jJ as Ie,e_ as Te,ch as ie,fe as $e,fZ as Me,fL as Oe,hp as Ae,hq as ze,hr as He,hs as Ue,ht as Ke,jK as We,c7 as qe,H as K,I as re,eS as Ge,W as Xe,g1 as oe,dR as W,gS as Qe,L as q,gT as G}from"./index-DdBTTN3y.js";import{R as Ye}from"./record-activity-C9gVBbF0.js";import{m as Je,o as Q,j as Ze,q as le,h as J,R as fe,r as et,t as tt,D as st,S as at}from"./renderer-DXfJaCCa.js";import{r as nt,V as it}from"./views-access-required-C_b9itZ2.js";import{S as rt,E as ot}from"./entity-avatar-TVKjZxWQ.js";import{a as ge,V as ce,M as lt,b as ct}from"./view-param-filters-CER47Tlz.js";import{a as dt}from"./source-record-panels-Bh0n4gGw.js";import{r as ut,R as de,b as mt}from"./event-card-DVUB8my6.js";import{a as ht}from"./record-session-R-uHNuby.js";import"./filter-bar-wPaR12SS.js";import"./calendar-Ck0yOLYu.js";import"./connection-label-BobuYiAG.js";import"./manage-gear-D8LMhehh.js";import"./runs-fFJ1lPnw.js";import"./clients-BJRcMk1A.js";import"./client-activity-scopes-CXOWB5co.js";import"./client-rows-36VnmgMK.js";import"./events-feed-B9CZHI_P.js";import"./use-scroll-sentinel-DRyBMueA.js";import"./agent-loading-shells-ClY_O6lb.js";import"./member-scope-gate-4FQ0aanZ.js";import"./table-BUqshjxa.js";import"./card-Bdi7VEwo.js";import"./app-bridge-C4nPtae3.js";import"./run-initiator-BvzQJYW9.js";import"./use-automations-BLNjxq2K.js";import"./change-summary-PBoM6Asb.js";import"./json-diff-BaLL4Fsu.js";import"./index-Vcq4gwWv.js";import"./copy-button-DjMWgrBf.js";import"./agent-list-row-rF5LH-3k.js";import"./automation-row-DCHM--aD.js";import"./model-jL871x2J.js";function pt(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 xt(t,s){const{shouldBlockFn:i,enableBeforeUnload:n=!0,disabled:a=!1,withResolver:c=!1}=pt(t),r=we(),{history:o}=r,[u,f]=R.useState({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0});return R.useEffect(()=>{const p=async x=>{function l(j){const b=r.parseLocation(j),v=r.getMatchedRoutes(b.pathname);return v.foundRoute===void 0?{routeId:"__notFound__",fullPath:b.pathname,pathname:b.pathname,params:v.routeParams,search:r.options.parseSearch(j.search)}:{routeId:v.foundRoute.id,fullPath:v.foundRoute.fullPath,pathname:b.pathname,params:v.routeParams,search:r.options.parseSearch(j.search)}}const m=l(x.currentLocation),d=l(x.nextLocation);if(m.routeId==="__notFound__"&&d.routeId!=="__notFound__")return!1;const h=await i({action:x.action,current:m,next:d});if(!c)return h;if(!h)return!1;const k=await new Promise(j=>{f({status:"blocked",current:m,next:d,action:x.action,proceed:()=>j(!1),reset:()=>j(!0)})});return f({status:"idle",current:void 0,next:void 0,action:void 0,proceed:void 0,reset:void 0}),k};return a?void 0:o.block({blockerFn:p,enableBeforeUnload:n})},[i,n,a,c,o,r]),u}function H(t,s){return ae(Q(t))===ae(Q(s))}function ft(t,s){const i={};for(const n of new Set([...Object.keys(t),...Object.keys(s)]))H(t[n],s[n])||(i[n]=Q(t[n])??null);return Object.keys(i).length>0?i:void 0}function gt(t,s){return[...new Set([...Object.keys(t),...Object.keys(s)])].filter(i=>{try{return!H(t[i],s[i])}catch{return!0}})}function ue(t,s){return{name:t.name,slug:t.slug,metadata:Je(t.metadata??{},s)}}function vt(t,s,i){const n=new Set(i),a={},c={},r=new Set([...Object.keys(t.values.metadata),...Object.keys(t.baseline.metadata),...Object.keys(s.metadata)]);for(const o of r){const u=n.has(o),f=u?t.values.metadata[o]:t.baseline.metadata[o],p=H(f,s.metadata[o])?f:s.metadata[o];p!==void 0&&(a[o]=p);let x=!1;if(!u)try{x=!H(t.values.metadata[o],t.baseline.metadata[o])}catch{x=!0}const l=x?t.values.metadata[o]:p;l!==void 0&&(c[o]=l)}return{baseline:{name:s.name,slug:s.slug,metadata:a},values:{name:s.name,slug:s.slug,metadata:c}}}function jt({entity:t,schema:s,orgContext:i}){const n=R.useMemo(()=>ue(t,s),[t,s]),a=Se(S(t),n,s),c=Re(i),{values:r,baseline:o,commit:u}=a,f=R.useMemo(()=>gt(r.metadata,o.metadata),[r.metadata,o.metadata]),p=r.name!==o.name||r.slug!==o.slug,x=R.useCallback((m,d)=>a.setValues(h=>({...h,metadata:{...h.metadata,[m]:d}})),[a.setValues]),l=async({note:m}={})=>{if(typeof t.id!="number")throw new Error("Source records are read-only");if(!a.canSubmit)return null;const d=ft(r.metadata,o.metadata),h=r.name.trim()!==o.name.trim();if(!d&&!p)return null;const k=await c.mutateAsync({entityId:t.id,name:h?r.name.trim():void 0,slug:r.slug,metadata:d,field_note:d&&m?.trim()||void 0}),j=ue(k.entity,s);return u(b=>vt(b,j,Object.keys(d??{})),j),{held:k.blocked_fields??[],approvalUrl:k.approval_url}};return{values:r,baseline:o,revision:a.revision,setValues:a.setValues,setMetadataField:x,reset:a.reset,save:l,saving:c.isPending,dirtyKeys:f,identityDirty:p,isDirty:p||f.length>0,canSubmit:a.canSubmit,hasConflict:a.hasConflict,hasInvalidInput:a.hasInvalidInput}}const yt=3,bt=50;function ve(t){const s=R.useRef(null);return R.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 _t({entityId:t,entityName:s,ownerSlug:i,orgContext:n,focus:a,collapsed:c=!1}){const r=Y(),o=ve(a),{data:u,isLoading:f,isError:p,refetch:x}=Fe(t,n,{limit:bt});if(t===void 0)return null;if(f)return e.jsxs("section",{className:"space-y-2","aria-busy":"true",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx(ne,{className:"h-4 w-24"}),e.jsx(ne,{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 x(),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 l=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?[ut(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(de,{count:u.failures?.length??0,onRetry:()=>void x()}),e.jsx("p",{"data-testid":"linked-summary",className:"truncate text-sm text-muted-foreground",children:l.join(" · ")})]})}return e.jsxs("section",{className:"space-y-3","aria-label":"Linked records",children:[e.jsx(V,{headingRef:o,children:"Linked"}),e.jsx(de,{count:u.failures?.length??0,onRetry:()=>void x()}),u.hasMore&&r?e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>r.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(l=>{const m=u.rows.filter(h=>h.relationship_type_slug===l.relationship_type_slug).slice(0,yt),d=l.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:[l.relationship_type_name,d?e.jsxs("span",{className:"tabular-nums text-muted-foreground/70",children:[" ","· ",l.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(mt,{row:h,label:l.relationship_type_name,entityId:t,ownerSlug:i,orgContext:n},h.id)),d&&r?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary",onClick:()=>r.open({href:"",key:`record-links:${t}:${l.relationship_type_slug}`,title:`${l.relationship_type_name} · ${l.count}`,recordLinks:{entityId:t,entityName:s,ownerSlug:i,orgContext:n,relationshipType:l.relationship_type_slug,label:l.relationship_type_name}}),children:["Show all ",l.count]}):null]})]},l.relationship_type_slug)})]})}function kt({record:t,ownerSlug:s,orgContext:i,focus:n}){const[a,c]=R.useState(n),r=ve(n);return e.jsxs("section",{className:"space-y-2",children:[e.jsx(V,{headingRef:r,children:"Linked"}),a?e.jsx(dt,{record:t,ownerSlug:s,orgContext:i}):e.jsx(N,{type:"button",variant:"outline",size:"sm",className:"h-7",onClick:()=>c(!0),children:"Find linked records"})]})}const Nt="$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===Nt?"Name":Ze(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]})}const wt=320,St={},Rt=()=>{};function Ft({view:t,orgSlug:s,recordUrl:i,scope:n}){const a=Y(),c=`${i}${pe(t.key)}`,r=a?()=>a.open({href:c,title:t.name}):void 0;return e.jsxs("section",{className:"min-w-0 rounded-lg border","data-testid":"view-card","data-view":t.key,children:[e.jsxs("header",{className:"flex items-start justify-between gap-3 px-4 pt-3 pb-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"truncate text-sm font-medium",children:t.name}),t.description?e.jsx("p",{className:"truncate text-xs text-muted-foreground",children:t.description}):null]}),r?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-7 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":`Open ${t.name}`,children:[e.jsx(Ee,{className:"h-3.5 w-3.5"}),"Open"]}):null]}),e.jsx("div",{className:"px-4 pb-3",children:e.jsx(ge,{orgSlug:s,viewKey:t.key,scope:n,params:St,onParamsChange:Rt,contentHash:t.content_hash,title:t.name,minHeight:64,displayMode:"inline",maxHeight:wt,onRequestDisplayMode:r?o=>{o==="fullscreen"&&r()}:void 0})})]})}function Et({recordUrl:t,dirty:s,onDiscard:i}){const n=xt({disabled:!s,enableBeforeUnload:s,withResolver:!0,shouldBlockFn:({next:c})=>c.pathname!==t&&!c.pathname.startsWith(`${t}${pe("")}`)}),a=n.status==="blocked";return e.jsx(Ae,{open:a,onOpenChange:c=>{!c&&a&&n.reset()},children:e.jsxs(ze,{className:"max-w-sm",children:[e.jsxs(He,{children:[e.jsx(Ue,{children:"Discard unsaved changes?"}),e.jsx(Ke,{children:"This record has edits that are not saved. Leaving discards them."})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",onClick:()=>a&&n.reset(),children:"Keep editing"}),e.jsx(N,{type:"button",variant:"destructive",onClick:()=>{a&&(i(),n.proceed())},children:"Discard"})]})]})})}const me=6;function Dt({entity:t,ownerSlug:s,orgContext:i,recordUrl:n,schema:a,entityTypeName:c,isTypeLoading:r,record:o,canEdit:u,editing:f,onEditingChange:p,outcome:x,onSaved:l,formId:m,fieldLimit:d,onDeleted:h}){const k=f&&u,j=Y(),b={entity:{id:S(t),name:t.name,entity_type:t.entity_type},ownerSlug:s,orgContext:i,schema:a,record:o,editing:k};ht(b);const v=j?.item?.recordField,D={ownerSlug:s,orgContext:i,controls:t.field_controls,dirtyKeys:o.dirtyKeys,openField:j?L=>j.open(nt(b,L.key)):void 0,openFieldKey:v?.entityId===S(t)?v.field:void 0},C=e.jsx(Et,{recordUrl:n,dirty:k&&o.isDirty,onDiscard:()=>{o.reset(),p(!1)}});if(r)return e.jsx(Oe,{rows:6});if(k)return e.jsxs(e.Fragment,{children:[C,e.jsx(Ct,{formId:m,entity:t,entityTypeName:c,schema:a,record:o,orgContext:i,renderControl:(L,P,E)=>et(P)?e.jsx(tt,{field:{key:L,prop:P},value:E,context:D}):void 0,onSaved:l,onDeleted:h,onDone:()=>p(!1)})]});const F=J(o.revision);return e.jsxs("div",{className:"space-y-3",children:[e.jsx(je,{outcome:x,schema:a}),e.jsx(fe,{fields:F,fieldLimit:d,values:o.values.metadata,context:D})]})}function Ct({formId:t,entity:s,entityTypeName:i,schema:n,record:a,orgContext:c,renderControl:r,onSaved:o,onDeleted:u,onDone:f}){const p=We(),x=s.field_controls,{name:l,slug:m,metadata:d}=a.values,h=g=>a.setValues(y=>({...y,name:g})),k=g=>a.setValues(y=>({...y,slug:g})),j=g=>a.setValues(y=>({...y,metadata:g})),[b,v]=B(S(s),""),[D,C]=B(S(s),null),[F,L]=B(S(s),null),[P,E]=B(S(s),!1),[w,I]=B(S(s),null),T=a.dirtyKeys.length>0,O=async g=>{if(g.preventDefault(),!!a.canSubmit){if(C(null),!l.trim()){C("Name is required");return}try{const y=await a.save({note:b});L(y),o(y),v(""),y?.held.length||f()}catch(y){C(y instanceof Error?y.message:"Failed to update entity")}}},U=async()=>{I(null);try{if(typeof s.id!="number")throw new Error("Source records are read-only");await p.mutateAsync({entityId:s.id}),E(!1),u?.()}catch(g){I(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:O,className:"space-y-4",children:[e.jsx(qe,{visible:a.hasConflict,onReload:a.reset}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(K,{htmlFor:"sidebar-name",children:["Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(re,{id:"sidebar-name",value:l,onChange:g=>h(g.target.value)})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(K,{htmlFor:"sidebar-slug",children:"URL Slug"}),e.jsx(re,{id:"sidebar-slug",value:m,onChange:g=>k(g.target.value.toLowerCase().replace(/[^a-z0-9-]/g,""))})]}),a.revision&&Object.keys(a.revision).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(rt,{}),e.jsx(st,{schema:a.revision,values:d,onValuesChange:j,fieldControls:x,orgContext:c,renderControl:r})]}),T&&e.jsxs("div",{className:"grid gap-2",children:[e.jsx(K,{htmlFor:"sidebar-correction-note",children:"Correction note (optional)"}),e.jsx(Ge,{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:F,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(Xe,{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(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{E(!1),I(null)},children:"Cancel"}),e.jsx(N,{type:"button",variant:"destructive",size:"sm",onClick:U,disabled:p.isPending,children:p.isPending?"Deleting...":`Delete ${i||"entity"}`})]})]}):e.jsx("div",{className:"pt-2",children:e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>E(!0),children:"Delete"})})]})}function ye(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"&&!$e(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 Lt({entity:t,schema:s,ownerSlug:i,fieldLimit:n}){const a=ye(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(fe,{fields:a,fieldLimit:n,values:t.metadata??{},context:{ownerSlug:i}})]})}const Bt=720,he="owletto:record-details-expanded";function Pt(){const[t,s]=R.useState(()=>{try{return window.localStorage.getItem(he)==="1"}catch{return!1}});return[t,n=>{s(n);try{window.localStorage.setItem(he,n?"1":"0")}catch{}}]}function Vt({schema:t,metadata:s}){const i=J(t).filter(({key:n,prop:a})=>a["x-table-column"]===!0&&!a["x-image"]&&s[n]!==void 0&&s[n]!==null&&s[n]!=="");return i.length===0?null:e.jsx("p",{"data-testid":"record-summary",className:"-mt-2 truncate text-sm text-muted-foreground tabular-nums",children:i.map(({key:n,prop:a},c)=>e.jsxs("span",{children:[c>0?" · ":null,e.jsx(at,{value:s[n],prop:a})]},n))})}function It({namespace:t,entity:s,recordUrl:i,viewKey:n,title:a,onDeleted:c}){const r=De({strict:!1}),o=xe(),u=R.useRef(null),f=Ce(u,Bt),[p,x]=Pt(),[l,m]=B(S(s),!1),d={slug:t.slug,organizationId:t.id},{isMember:h,isPublic:k,isLoading:j}=Le(t.slug),b=h||k,v=Be({...d,organizationId:h?t.id:null}),{data:D,isLoading:C}=X(s.entity_type,d),F=D?.metadata_schema,{isAdmin:L,isLoading:P}=Pe(h?d.organizationId:void 0),E=h&&L&&!P&&!s.is_derived,w=jt({entity:s,schema:F,orgContext:d}),[I,T]=B(S(s),null),O=`record-form-${s.id}`,U=l&&E,A=b?v.data??[]:[],g=Ve(A,{type:s.entity_type,id:S(s)}),y=Ie(g,n),z=!n&&r.tab==="relationships",be=_=>void o({to:".",search:_,replace:!0}),Z={type:s.entity_type,entity:s.is_derived?s.slug:s.id??s.slug},$=f&&!p&&!l&&!z,ee=s.is_derived?le(ye(s,F),s.metadata??{}).length:le(J(w.revision),w.values.metadata).length,te=$?me:void 0,se=e.jsxs("div",{className:"space-y-6",children:[s.is_derived?e.jsxs(e.Fragment,{children:[e.jsx(Lt,{entity:s,schema:F,ownerSlug:t.slug,fieldLimit:te}),e.jsx(kt,{record:{type:s.entity_type,key:s.slug},ownerSlug:t.slug,orgContext:d,focus:z})]}):e.jsxs(e.Fragment,{children:[e.jsx(Dt,{entity:s,ownerSlug:t.slug,orgContext:d,recordUrl:i,schema:F,entityTypeName:D?.name,isTypeLoading:C,record:w,canEdit:E,editing:l,onEditingChange:m,outcome:I,onSaved:T,formId:O,fieldLimit:te,onDeleted:c}),e.jsx(_t,{entityId:typeof s.id=="number"?s.id:void 0,entityName:s.name,ownerSlug:t.slug,orgContext:d,focus:z,collapsed:$})]}),f&&!l&&!z?e.jsx(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-primary hover:text-primary","aria-expanded":!$,onClick:()=>x($),children:$?ee>me?`Show all ${ee} fields`:"Show all details":"Show fewer"}):null]}),_e=_=>e.jsx("div",{ref:u,className:"min-w-0 space-y-4",children:f?e.jsxs(e.Fragment,{children:[e.jsx(Vt,{schema:F,metadata:s.metadata??{}}),e.jsx("section",{"aria-label":"Details","data-testid":"record-details",children:se}),_]}):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:se}),_]})}),ke=U?e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:()=>{w.reset(),T(null),m(!1)},children:"Cancel"}),e.jsx(N,{type:"submit",form:O,size:"sm",disabled:!w.canSubmit||!w.isDirty||w.saving||!w.values.name.trim(),children:w.saving?"Saving...":"Save"})]}):E&&!C?e.jsxs(N,{type:"button",variant:"ghost",size:"sm",className:"h-8 shrink-0 gap-1.5 px-2 text-muted-foreground hover:text-foreground",onClick:()=>{T(null),m(!0)},children:[e.jsx(Te,{className:"h-3.5 w-3.5"}),"Edit"]}):null,M=_=>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:a}),ke]}),_]});if(n&&!b)return M(j?null:e.jsx(it,{}));if(n&&v.data===void 0)return M(v.isError?e.jsx(ce,{onRetry:()=>void v.refetch()}):null);if(y.kind==="missing")return M(e.jsx(lt,{viewKey:y.key,backTo:i,backLabel:`Back to ${s.name}`}));if(y.kind==="view"){const{view:_}=y;return M(e.jsxs("div",{className:"min-w-0 space-y-3",children:[e.jsx(ct,{decls:_.params,params:ie(r),onParamsChange:Ne=>void o({to:".",search:Ne})}),e.jsx(ge,{orgSlug:t.slug,viewKey:_.key,scope:Z,params:ie(r),onParamsChange:be,contentHash:_.content_hash,title:_.name,minHeight:320})]}))}return M(_e(e.jsxs("div",{className:"min-w-0 space-y-4",children:[b&&v.isError&&e.jsx(ce,{onRetry:()=>void v.refetch()}),g.map(_=>e.jsx(Ft,{view:_,orgSlug:t.slug,recordUrl:i,scope:Z},_.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(Ye,{entity:s,organizationId:t.id,ownerSlug:t.slug})]})]})))}function Tt(t){return t?.trim()?t:void 0}function gs({namespace:t,path:s,entity:i,viewKey:n}){const a=xe(),{data:c}=X(i.entity_type,{slug:t.slug}),r=s[0]?.entity_type??i.entity_type,{data:o}=X(r,{slug:t.slug}),u=Tt(c?.icon),f=s.map(l=>({entity_type:l.entity_type,slug:l.slug})),p=`/${t.slug}/${oe(i.entity_type)}`,x=W(t.slug,f);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(Qe,{crumbs:[...r==="$member"?[]:[e.jsx(q,{to:"/$owner/data",params:{owner:t.slug},className:G,children:"Memory"},"memory")],e.jsx(q,{to:`/${t.slug}/${oe(r)}`,className:G,children:r==="$member"?"Team":o?.name??r},"type"),...s.slice(0,-1).map((l,m)=>e.jsx(q,{to:W(t.slug,f.slice(0,m+1)),className:G,children:l.name},l.id))],current:i.name}),e.jsx(It,{namespace:t,entity:i,recordUrl:x,viewKey:n,title:e.jsxs(e.Fragment,{children:[e.jsx(ot,{metadata:i.metadata,metadataSchema:c?.metadata_schema,name:i.name,typeIcon:u,className:"h-6 w-6 shrink-0"}),e.jsx("h2",{className:"truncate text-lg font-semibold leading-tight",children:i.name})]}),onDeleted:()=>{const l=s.slice(0,-1);l.length>0?a({to:W(t.slug,l)}):a({to:p})}})]})}export{gs as EntityPage};
2
+ //# sourceMappingURL=entity-page-BfJXvbxn.js.map
@@ -0,0 +1,2 @@
1
+ import{j as e,v as $,fx as me,gf as xe,fA as Y,bO as ae,r as x,fy as he,fz as pe,dE as ge,dG as fe,B as f,d6 as V,dF as je,H as C,bl as q,bm as P,bn as M,bo as I,bp as R,I as O,ab as ve,gg as Ne,gh as ye,V as G,eu as be,X as W,cI as ne,C as re,$ as we,bc as le,gi as ie,gj as Se,W as oe,gk as Ce,g6 as ke,c2 as Ee,c3 as K,c7 as _e,eS as Re,bP as Oe,gl as Te,gm as De,i as Q,L as Ae}from"./index-DdBTTN3y.js";import{C as Fe}from"./change-summary-PBoM6Asb.js";import{J as U}from"./json-diff-BaLL4Fsu.js";import{C as ce}from"./code-editor-DNuRKde1.js";function ze({entry:s}){return e.jsxs("div",{className:"relative pl-6 pb-6 last:pb-0",children:[e.jsx("div",{className:"absolute left-0 top-1.5 h-3 w-3 rounded-full border-2 border-border bg-background"}),e.jsx("div",{className:"absolute left-[5px] top-5 bottom-0 w-px bg-border last:hidden"}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(Fe,{operation:s.action,actor:s.actor,createdAt:s.created_at}),s.action==="update"&&e.jsx(U,{before:s.before_payload,after:s.after_payload}),s.action==="create"&&s.after_payload&&e.jsx(U,{before:null,after:s.after_payload}),s.action==="delete"&&s.before_payload&&e.jsx(U,{before:s.before_payload,after:null})]})]})}function qe({entityType:s}){const{orgContext:a}=$(),{data:c,isLoading:n}=me(a),{data:r}=xe(a),t=(c||[]).filter(m=>m.status==="active"),i=t.filter(m=>!m.organization_slug||m.organization_slug===a?.slug),o=i.filter(m=>m.purpose!==Y),d=i.filter(m=>m.purpose===Y),h=t.filter(m=>m.organization_slug&&m.organization_slug!==a?.slug);return e.jsx("div",{className:"space-y-4 py-4",children:n?e.jsx(ae,{label:"relationships",variant:"rows",rows:4}):e.jsxs(e.Fragment,{children:[e.jsx(B,{entityTypeSlug:s.slug,relationshipTypes:o,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(B,{entityTypeSlug:s.slug,relationshipTypes:d,allEntityTypes:r||[],readOnly:!0})]}),h.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(B,{entityTypeSlug:s.slug,relationshipTypes:h,allEntityTypes:r||[],readOnly:!0})]}),e.jsx(Ie,{entityTypeSlug:s.slug,relationshipTypes:o,allEntityTypes:r||[]})]})})}function B({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c,readOnly:n=!1}){return e.jsx("div",{className:"space-y-2",children:a.map(r=>e.jsx(Pe,{relationshipType:r,entityTypeSlug:s,allEntityTypes:c,readOnly:n},r.id))})}function Pe({relationshipType:s,entityTypeSlug:a,allEntityTypes:c,readOnly:n=!1}){const{orgContext:r}=$(),{data:t}=Ne(s.slug,r),i=ye(),o=(t||[]).filter(h=>h.source_entity_type_slug===a||h.target_entity_type_slug===a);if(o.length===0)return null;const d=new Map(c.map(h=>[h.slug,h.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(G,{variant:"secondary",className:"text-[10px] px-1.5 py-0",children:"symmetric"}),n&&e.jsx(G,{variant:"outline",className:"text-[10px] px-1.5 py-0",children:"read-only"})]}),o.map(h=>e.jsx(Me,{rule:h,entityTypeSlug:a,entityTypeNameMap:d,onRemove:()=>i.mutate(h.id),isRemoving:i.isPending,readOnly:n},h.id))]})}function Me({rule:s,entityTypeSlug:a,entityTypeNameMap:c,onRemove:n,isRemoving:r,readOnly:t=!1}){const[i,o]=x.useState(!1),d=s.source_entity_type_slug===a,h=d?s.target_entity_type_slug:s.source_entity_type_slug,m=c.get(h)||h;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":m}),e.jsx(be,{className:"h-3 w-3 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:d?m:"this"}),t?null:i?e.jsxs("div",{className:"flex items-center gap-1 ml-auto",children:[e.jsx(f,{variant:"destructive",size:"sm",className:"h-6 px-2 text-xs",onClick:n,disabled:r,children:r?"Removing...":"Remove"}),e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>o(!1),disabled:r,children:"Cancel"})]}):e.jsx("div",{className:"ml-auto",children:e.jsx(f,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-muted-foreground hover:text-destructive",onClick:()=>o(!0),disabled:r,children:e.jsx(W,{className:"h-3 w-3"})})})]})}function Ie({entityTypeSlug:s,relationshipTypes:a,allEntityTypes:c}){const{orgContext:n}=$(),r=c.filter(l=>!l.organization_slug||l.organization_slug===n?.slug),[t,i]=x.useState(!1),[o,d]=x.useState("existing"),[h,m]=x.useState(""),[S,N]=x.useState(""),[y,b]=x.useState("source"),[g,j]=x.useState(""),[k,E]=x.useState(""),[D,w]=x.useState(!1),[A,_]=x.useState(null),u=he(),p=pe(),v=()=>{d("existing"),m(""),N(""),b("source"),j(""),E(""),w(!1),_(null)},T=l=>{i(l),l||v()},F=l=>l.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""),J=async()=>{_(null);try{let l=h;if(o==="new"){if(!g.trim()){_("Name is required");return}const H=k.trim()||F(g);if(!H){_("Slug is required");return}l=(await u.mutateAsync({slug:H,name:g.trim(),is_symmetric:D})).relationship_type.slug}if(!l){_("Select a relationship type");return}if(!S){_("Select a target entity type");return}const L=y==="source"?s:S,ue=y==="source"?S:s;await p.mutateAsync({slug:l,source_entity_type_slug:L,target_entity_type_slug:ue}),T(!1)}catch(l){_(l instanceof Error?l.message:"An error occurred")}},z=u.isPending||p.isPending;return e.jsxs(ge,{open:t,onOpenChange:T,children:[e.jsx(fe,{asChild:!0,children:e.jsxs(f,{variant:"outline",size:"sm",className:"w-full",children:[e.jsx(V,{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(C,{className:"text-xs",children:"Relationship Type"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx(f,{variant:o==="existing"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("existing"),children:"Existing"}),e.jsx(f,{variant:o==="new"?"default":"outline",size:"sm",className:"h-7 text-xs flex-1",onClick:()=>d("new"),children:"Create New"})]})]}),o==="existing"?e.jsxs(q,{value:h,onValueChange:m,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select relationship type..."})}),e.jsxs(I,{children:[a.map(l=>e.jsx(R,{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(O,{placeholder:"Name (e.g. Integrates With)",className:"h-8 text-sm",value:g,onChange:l=>{j(l.target.value),k||E("")}}),e.jsx(O,{placeholder:g?F(g)||"slug":"Slug (auto-generated)",className:"h-8 text-sm",value:k,onChange:l=>E(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=>w(l.target.checked),className:"rounded"}),"Symmetric (A↔B = B↔A)"]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{className:"text-xs",children:"Direction"}),e.jsxs(q,{value:y,onValueChange:l=>b(l),children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"source",children:"This type → other"}),e.jsx(R,{value:"target",children:"Other → this type"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(C,{className:"text-xs",children:[y==="source"?"Target":"Source"," Entity Type"]}),e.jsxs(q,{value:S,onValueChange:N,children:[e.jsx(P,{className:"h-8 text-sm",children:e.jsx(M,{placeholder:"Select entity type..."})}),e.jsx(I,{children:r.map(l=>e.jsxs(R,{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(f,{size:"sm",className:"w-full",onClick:J,disabled:z,children:z?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"mr-1.5"}),"Saving..."]}):"Add Rule"})]})})]})}function Le({options:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const i=c.trim();i&&!s.includes(i)&&(a([...s,i]),n(""))},t=i=>{a(s.filter((o,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,o)=>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(o),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(O,{value:c,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&(i.preventDefault(),r())},placeholder:"Add option...",className:"h-7 text-sm"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}const Ve=[{value:"string",label:"Text"},{value:"number",label:"Number"},{value:"integer",label:"Whole number"},{value:"boolean",label:"Yes/No"},{value:"enum",label:"Choice"}];function Je({examples:s,onChange:a}){const[c,n]=x.useState(""),r=()=>{const t=c.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((o,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(O,{value:c,onChange:t=>n(t.target.value),onKeyDown:t=>{t.key==="Enter"&&(t.preventDefault(),r())},placeholder:"Add example...",className:"h-7 text-xs"}),e.jsx(f,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2",onClick:r,children:e.jsx(V,{className:"h-3 w-3"})})]})]})}function Ue({field:s,onChange:a,onDelete:c}){const[n,r]=x.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(ne,{className:"h-3.5 w-3.5"}):e.jsx(re,{className:"h-3.5 w-3.5"})}),e.jsx(O,{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(I,{children:Ve.map(t=>e.jsx(R,{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(we,{checked:s.required,onCheckedChange:t=>a({...s,required:t===!0})}),e.jsx("span",{children:"Required"})]}),e.jsx(f,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 p-0 text-muted-foreground hover:text-destructive",onClick:c,children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}),s.type==="enum"&&e.jsx("div",{className:"pl-6",children:e.jsx(Le,{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(O,{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(O,{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(I,{children:[e.jsx(R,{value:"none",children:"None"}),e.jsx(R,{value:"workflowState",disabled:s.type!=="enum",children:"Workflow state (board)"}),e.jsx(R,{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(Je,{examples:s.examples||[],onChange:t=>a({...s,examples:t.length>0?t:void 0})})})]})]})]})}function X({value:s,onChange:a,readonly:c,error:n}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx(ce,{value:s,onChange:a,readonly:c,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 c of Object.values(a)){if(!c||typeof c!="object")return!1;const n=c,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 de(){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||{},c=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,o={id:de(),name:n,required:c.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?{...o,type:"enum",enumOptions:r.enum||[]}:{...o,type:r.type||"string"}})}function se(s,a){if(a==="number"||a==="integer"){const c=Number(s);return Number.isNaN(c)?s:c}return a==="boolean"?s==="true"?!0:s==="false"?!1:s:s}function Be(s,a="auto"){const c={},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(o=>se(o,t.type))),t.role&&(i["x-lobu"]={role:t.role,...t.role==="workflowState"&&t.type==="enum"?{states:(t.enumOptions||[]).map(o=>({value:o,label:o.replace(/[_-]+/g," ").replace(/\b\w/g,d=>d.toUpperCase()),terminal:["done","complete","completed","closed","archived"].includes(o.toLowerCase())}))}:{}}),c[t.name]=i,t.required&&n.push(t.name)}const r={type:"object",properties:c};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 $e({value:s,onChange:a,readonly:c=!1}){const[n,r]=x.useState("visual"),[t,i]=x.useState([]),[o,d]=x.useState("auto"),[h,m]=x.useState(""),[S,N]=x.useState(null),[y,b]=x.useState(!1),g=x.useRef(!1);x.useEffect(()=>{if(g.current){g.current=!1;return}if(!s||Object.keys(s).length===0){i([]),d("auto"),m(""),b(!1);return}const u=JSON.stringify(s,null,2);m(u),d(te(s)),Z(s)?(i(ee(s)),b(!1)):(b(!0),r("json"))},[s]);const j=x.useCallback((u,p)=>{g.current=!0;const v=Be(u,p),T=u.some(F=>F.name.trim());m(T?JSON.stringify(v,null,2):""),a(T?v:void 0)},[a]),k=x.useCallback(u=>{i(u),j(u,o)},[j,o]),E=x.useCallback(u=>{d(u),j(t,u)},[j,t]),D=x.useCallback(u=>{if(g.current=!0,m(u),!u.trim()){N(null),i([]),d("auto"),a(void 0);return}try{const p=JSON.parse(u);N(null),d(te(p)),Z(p)?(i(ee(p)),b(!1)):b(!0),a(p)}catch(p){N(p instanceof Error?p.message:"Invalid JSON")}},[a]),w=()=>{k([...t,{id:de(),name:"",type:"string",required:!1}])},A=(u,p)=>{const v=[...t];v[u]=p,k(v)},_=u=>{k(t.filter((p,v)=>v!==u))};return c?e.jsx(X,{value:h,onChange:()=>{},readonly:!0}):e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(f,{type:"button",variant:n==="visual"?"default":"outline",size:"sm",onClick:()=>!y&&r("visual"),disabled:y,className:"h-7 text-xs",children:[e.jsx(ie,{className:"h-3 w-3 mr-1"}),"Visual"]}),e.jsxs(f,{type:"button",variant:n==="json"?"default":"outline",size:"sm",onClick:()=>r("json"),className:"h-7 text-xs",children:[e.jsx(Se,{className:"h-3 w-3 mr-1"}),"JSON"]})]}),y&&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(oe,{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((u,p)=>e.jsx(Ue,{field:u,onChange:v=>A(p,v),onDelete:()=>_(p)},u.id)),e.jsxs(f,{type:"button",variant:"outline",size:"sm",onClick:w,className:"w-full",children:[e.jsx(V,{className:"h-3.5 w-3.5 mr-1"}),"Add Field"]}),t.some(u=>u.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:o,onValueChange:u=>E(u),children:[e.jsx(P,{className:"h-8 w-32 text-xs",children:e.jsx(M,{})}),e.jsxs(I,{children:[e.jsx(R,{value:"auto",children:"Auto"}),e.jsx(R,{value:"table",children:"Table"}),e.jsx(R,{value:"board",children:"Board"})]})]})]})]}):e.jsx(X,{value:h,onChange:D,error:S})]})}function We(s){return s.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function He({entityType:s,onCancel:a,onSaved:c}){const n=!!s,r=Ce(),t=ke(),i=s?.slug??"new",o=Ee(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,h]=o.field("name"),[m,S]=o.field("slug"),[N,y]=o.field("description"),[b,g]=o.field("icon"),[j,k]=o.field("color"),[E,D]=o.field("metadataSchema"),[w,A]=o.field("backingSql"),[_,u]=K(i,n),[p,v]=K(i,null),T=w.trim().length>0,F=l=>{h(l),!n&&!_&&S(We(l))},J=async()=>{if(!o.canSubmit)return;if(v(null),!d.trim()){v("Name is required");return}if(!n&&!m.trim()){v("Slug is required");return}const l=T?{sql:w.trim()}:null;try{n?await t.mutateAsync({slug:s.slug,name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}):await r.mutateAsync({slug:m.trim(),name:d.trim(),description:N.trim()||void 0,icon:b.trim()||void 0,color:j.trim()||void 0,metadata_schema:T?void 0:E,backing:l}),c()}catch(L){v(L instanceof Error?L.message:"An error occurred")}},z=r.isPending||t.isPending;return e.jsxs("div",{className:"space-y-5",children:[e.jsx(_e,{visible:o.hasConflict,onReload:o.reset}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-name",children:"Name"}),e.jsx(O,{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(C,{htmlFor:"et-slug",children:"Slug"}),e.jsx(O,{id:"et-slug",value:m,onChange:l=>{u(!0),S(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(C,{htmlFor:"et-desc",children:"Description"}),e.jsx(Re,{id:"et-desc",value:N,onChange:l=>y(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(C,{htmlFor:"et-icon",children:"Icon (emoji)"}),e.jsx(O,{id:"et-icon",value:b,onChange:l=>g(l.target.value),placeholder:"e.g. 📦"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{htmlFor:"et-color",children:"Color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(O,{id:"et-color",value:j,onChange:l=>k(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(C,{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(ce,{value:w,onChange:A,minHeight:"120px",placeholder:"SELECT (metadata->>'vendor') AS vendor, SUM((metadata->>'amount')::numeric) AS total FROM events GROUP BY 1"})]}),T?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(ie,{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(C,{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(C,{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($e,{value:E,onChange:D})]}),n&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(C,{children:"Relationships"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Define how this entity type relates to others."}),e.jsx(qe,{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(f,{onClick:J,disabled:z,children:z?"Saving...":n?"Update":"Create"})})]})}function Ze({entityType:s,onClose:a,orgContext:c,hideDelete:n=!1,compact:r=!1}){const t=!!s,[i,o]=x.useState(!1),[d,h]=x.useState(!1),[m,S]=x.useState(null),N=Te(),{data:y,isLoading:b}=De(i&&s?s.slug:null,c),g=s?.entity_count??0,j=g>0,k=async()=>{if(s){S(null);try{await N.mutateAsync(s.slug),a()}catch(w){S(w instanceof Error?w.message:"Failed to delete")}}},E=t?`${s?.icon||"📄"} ${s?.name}`:"Create Entity Type",D=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.jsx("h1",{className:Q("font-semibold leading-tight",r?"text-lg":"text-2xl"),children:E}),e.jsx("p",{className:"text-sm text-muted-foreground",children:D})]}),e.jsx("div",{className:"py-4",children:e.jsx(He,{entityType:s,onCancel:a,onSaved:a})}),t&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"border-t border-border pt-4 space-y-3",children:[c.slug&&s?e.jsx(Ae,{to:"/$owner/events",params:{owner:c.slug},search:{semantic_types:"change",event_category:"config",resource_kind:"entity-type",resource_id:s.slug},className:"text-sm text-primary underline underline-offset-4",children:"View configuration history in Events"}):null,e.jsxs("button",{type:"button",onClick:()=>o(!i),className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors w-full",children:[i?e.jsx(ne,{className:"h-4 w-4"}):e.jsx(re,{className:"h-4 w-4"}),"Schema audit records"]}),i&&e.jsx("div",{className:"mt-3",children:b?e.jsx(ae,{label:"history",variant:"rows",rows:4}):y&&y.length>0?e.jsx("div",{className:"relative ml-1.5",children:y.map(w=>e.jsx(ze,{entry:w},w.id))}):e.jsx("p",{className:"text-sm text-muted-foreground py-4 text-center",children:"No audit history found."})})]}),!n&&e.jsx("div",{className:"border-t border-border pt-4 mt-4",children:d?e.jsxs("div",{className:"space-y-3",children:[j?e.jsxs("div",{className:"flex items-start gap-3 p-3 rounded-md bg-amber-500/10 text-amber-600",children:[e.jsx(oe,{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 ",g===1?"is":"are"," ",g," entit",g===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.']}),m&&e.jsx("div",{className:"p-3 rounded-md bg-destructive/10 text-destructive text-sm",children:m}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(f,{variant:"outline",size:"sm",onClick:()=>{h(!1),S(null)},children:"Cancel"}),e.jsx(f,{variant:"destructive",size:"sm",onClick:k,disabled:j||N.isPending,children:N.isPending?"Deleting...":"Delete"})]})]}):e.jsxs(f,{variant:"outline",size:"sm",className:"text-destructive hover:text-destructive",onClick:()=>h(!0),children:[e.jsx(le,{className:"h-3.5 w-3.5 mr-1.5"}),"Delete entity type"]})})]})]})}export{Ze as E};
2
+ //# sourceMappingURL=entity-type-page-BLwH6qa7.js.map