decocms 2.291.2 → 2.292.1

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 (208) hide show
  1. package/dist/client/assets/{AlertCircle-BU25E17i.js → AlertCircle-Cx8oex2u.js} +1 -1
  2. package/dist/client/assets/{ArrowNarrowLeft-DsozI7ul.js → ArrowNarrowLeft-DtpIYMrr.js} +1 -1
  3. package/dist/client/assets/{ArrowUpRight-wUPlLzWo.js → ArrowUpRight-BBjaHjTK.js} +1 -1
  4. package/dist/client/assets/{CheckCircle-B6ooPL10.js → CheckCircle-Mywkb82K.js} +1 -1
  5. package/dist/client/assets/{ChevronDown-BjunjZ96.js → ChevronDown-BE0rQ4ho.js} +1 -1
  6. package/dist/client/assets/{ChevronRight-DZ8_B5Zy.js → ChevronRight-BVJ2HUMt.js} +1 -1
  7. package/dist/client/assets/{ChevronUp-BcfJms1N.js → ChevronUp-B2y_5HwX.js} +1 -1
  8. package/dist/client/assets/{Container-BBbTXyMq.js → Container-CtsNRge8.js} +1 -1
  9. package/dist/client/assets/{DotsVertical-ChXlfNDE.js → DotsVertical-BQnGY6Nc.js} +1 -1
  10. package/dist/client/assets/{LinkExternal01-Bq6E6IiB.js → LinkExternal01-SieYyhiZ.js} +1 -1
  11. package/dist/client/assets/{Lock01-CT9fVg-M.js → Lock01-BrFrkt3t.js} +1 -1
  12. package/dist/client/assets/{Palette-CL1PeBDG.js → Palette-2CChK5yr.js} +1 -1
  13. package/dist/client/assets/{Play-O7Kb3HkD.js → Play-BfzIvHVC.js} +1 -1
  14. package/dist/client/assets/{Plus-BX8KY2Vj.js → Plus-kLSd3TZy.js} +1 -1
  15. package/dist/client/assets/{RefreshCcw01-DtyDEAf2.js → RefreshCcw01-B-L6FvMp.js} +1 -1
  16. package/dist/client/assets/{SearchMd-CJm9ITir.js → SearchMd-BfBE-dHK.js} +1 -1
  17. package/dist/client/assets/{Settings02-0UGyPXgy.js → Settings02-EP4I50bB.js} +1 -1
  18. package/dist/client/assets/{Shield01-ajX6eCWD.js → Shield01-D19-LRUf.js} +1 -1
  19. package/dist/client/assets/{Star01-DLcvdqts.js → Star01-MuiWZ8GS.js} +1 -1
  20. package/dist/client/assets/{Sun-DwH3UR5R.js → Sun-CTLobT4y.js} +1 -1
  21. package/dist/client/assets/{Tool01-Dqe-c7_N.js → Tool01-CeBylvMu.js} +1 -1
  22. package/dist/client/assets/{Trash01-CO6PRylN.js → Trash01-BLGcALKg.js} +1 -1
  23. package/dist/client/assets/{User01-JrKdMZpa.js → User01-BLHrCCyy.js} +1 -1
  24. package/dist/client/assets/{Users03-DGkdZmwX.js → Users03-C3QqJn94.js} +1 -1
  25. package/dist/client/assets/{X-BFKhYElJ.js → X-BJbamPEP.js} +1 -1
  26. package/dist/client/assets/{XCircle-BCi1SPUb.js → XCircle-DP5EGLqX.js} +1 -1
  27. package/dist/client/assets/{XClose-BL1_qV1F.js → XClose-BRn4UVuG.js} +1 -1
  28. package/dist/client/assets/{Zap-Bsssnre4.js → Zap-kZUu0No-.js} +1 -1
  29. package/dist/client/assets/{ZapSquare-dR2caQ4h.js → ZapSquare-B3o6QvJe.js} +1 -1
  30. package/dist/client/assets/{accordion-CSdeKGev.js → accordion-BP1gqDGq.js} +1 -1
  31. package/dist/client/assets/{agent-icon-BHvp6mzD.js → agent-icon-Db8xI2bq.js} +1 -1
  32. package/dist/client/assets/{agents-list-DelQtLci.js → agents-list-CKkZAwkG.js} +1 -1
  33. package/dist/client/assets/ai-providers-Cnvjm1DV.js +1 -0
  34. package/dist/client/assets/{alert-dialog-7-SyZGSt.js → alert-dialog-BFg1HHbW.js} +1 -1
  35. package/dist/client/assets/{auth-catchall-iqLWQ8B0.js → auth-catchall-BPCBowrT.js} +1 -1
  36. package/dist/client/assets/{automation-list-row-CGm-OiLc.js → automation-list-row-0e1qSQoQ.js} +1 -1
  37. package/dist/client/assets/{automations-CYw0JH2e.js → automations-Cr0E7mF8.js} +1 -1
  38. package/dist/client/assets/{avatar-Zzj9UMlL.js → avatar-BfSY5CVM.js} +1 -1
  39. package/dist/client/assets/{badge--Lhfsu1W.js → badge-C_B8gNbw.js} +1 -1
  40. package/dist/client/assets/{brand-context-YW1Q-eq7.js → brand-context-DMrJlbv3.js} +1 -1
  41. package/dist/client/assets/{card-9GTnJhWp.js → card-G6flwhwa.js} +1 -1
  42. package/dist/client/assets/{chat-context-DXvG89K2.js → chat-context-BJBiG4eq.js} +1 -1
  43. package/dist/client/assets/{checkbox-duvwt99y.js → checkbox-LBmczTXJ.js} +1 -1
  44. package/dist/client/assets/{collection-detail-F4_8z6Hn.js → collection-detail-D_lV_A0m.js} +1 -1
  45. package/dist/client/assets/{collection-display-button-DinzcNMl.js → collection-display-button-BXL1tYdg.js} +1 -1
  46. package/dist/client/assets/{collection-search-BcpKEq0y.js → collection-search-CsSMb59s.js} +1 -1
  47. package/dist/client/assets/{collection-search-BoQ_EppH.js → collection-search-DoXoIAYq.js} +1 -1
  48. package/dist/client/assets/{collection-table-wrapper-Q2gV7sPs.js → collection-table-wrapper-B2fVBjE4.js} +1 -1
  49. package/dist/client/assets/{collection-tabs-Dl6rp80p.js → collection-tabs-CA1SpsaZ.js} +1 -1
  50. package/dist/client/assets/{collections-CtHgOGSI.js → collections-BAHpsq0P.js} +1 -1
  51. package/dist/client/assets/{command-BY-OMlmS.js → command-CJYPyBOh.js} +1 -1
  52. package/dist/client/assets/{connection-card-CxvFxmw2.js → connection-card-DZ1fYoPr.js} +1 -1
  53. package/dist/client/assets/{connection-detail-B2-UvKp7.js → connection-detail-DGI32gtH.js} +1 -1
  54. package/dist/client/assets/{connection-form-helpers-skhe2PwK.js → connection-form-helpers-Dim-adMo.js} +1 -1
  55. package/dist/client/assets/{connections-B9rvBIJs.js → connections-Dl4MUHeU.js} +1 -1
  56. package/dist/client/assets/{constants-Bp8ek76r.js → constants-B-gCw63I.js} +1 -1
  57. package/dist/client/assets/{constants-BAzsARw1.js → constants-Dw_UtizE.js} +1 -1
  58. package/dist/client/assets/{dialog-C2cBQ0ty.js → dialog-DjZXbytL.js} +1 -1
  59. package/dist/client/assets/{domain-settings-DX4izaPT.js → domain-settings-NIhMIJvG.js} +1 -1
  60. package/dist/client/assets/{drawer-B_-bDnjD.js → drawer-BFBl_9mB.js} +1 -1
  61. package/dist/client/assets/{dropdown-menu-DWNG84J5.js → dropdown-menu--l1OQ6xu.js} +1 -1
  62. package/dist/client/assets/{dynamic-plugin-layout-C-4aN23S.js → dynamic-plugin-layout-D8kk92gE.js} +1 -1
  63. package/dist/client/assets/{empty-state-BKimHCce.js → empty-state-CWYR2iH4.js} +1 -1
  64. package/dist/client/assets/{empty-state-CLCMWued.js → empty-state-DskpQs8Q.js} +1 -1
  65. package/dist/client/assets/{extract-connection-data-DAdB5U1f.js → extract-connection-data-DiYA0QYt.js} +1 -1
  66. package/dist/client/assets/{features-CFZqwKf_.js → features-j7f3i077.js} +1 -1
  67. package/dist/client/assets/{form-92QvOiJ_.js → form-BVdbuwTF.js} +1 -1
  68. package/dist/client/assets/{general-CIx8MPEj.js → general-BLunjYWc.js} +1 -1
  69. package/dist/client/assets/{github-repo-picker-CUaU2lz-.js → github-repo-picker-ku0KWxb8.js} +1 -1
  70. package/dist/client/assets/index-BZi9riJ2.css +1 -0
  71. package/dist/client/assets/{index-CxVUAwST.js → index-Bm_-4bAj.js} +1 -1
  72. package/dist/client/assets/{index-CzXBz_F7.js → index-BnoHDdAn.js} +1 -1
  73. package/dist/client/assets/{index-Dq226A4w.js → index-Bu0xhzLF.js} +2 -2
  74. package/dist/client/assets/{index-DNXvVXJy.js → index-CHcfXh0a.js} +1 -1
  75. package/dist/client/assets/{index-BRQ0tifs.js → index-CllFnV9J.js} +1 -1
  76. package/dist/client/assets/{index-CEfeDibH.js → index-ClmOj0lo.js} +20 -20
  77. package/dist/client/assets/{index-CTsYITXV.js → index-DA_fcz0a.js} +1 -1
  78. package/dist/client/assets/{index-BIYmbFmV.js → index-I_6bIMcX.js} +1 -1
  79. package/dist/client/assets/{index-BPhQ3efs.js → index-QvZR-ABK.js} +1 -1
  80. package/dist/client/assets/{index-BbevWgzi.js → index-x18ABRVV.js} +1 -1
  81. package/dist/client/assets/{infiniteQueryObserver-DAJ1MAYd.js → infiniteQueryObserver-DEk-T30Y.js} +1 -1
  82. package/dist/client/assets/{input-sAl4qpu7.js → input-B5aMagwc.js} +1 -1
  83. package/dist/client/assets/{integration-icon-AZugc3yw.js → integration-icon-B5mNngh-.js} +1 -1
  84. package/dist/client/assets/{label-CgTKL0Kd.js → label-Bv4VMaQH.js} +1 -1
  85. package/dist/client/assets/{layout-irXWDg_F.js → layout-ChoVtsz2.js} +1 -1
  86. package/dist/client/assets/{login-D6bW_SwU.js → login-DFTX50_T.js} +1 -1
  87. package/dist/client/assets/{members-Bl2wPM_1.js → members-BbGgTXF7.js} +1 -1
  88. package/dist/client/assets/{monaco-editor-C_NWZeTl.js → monaco-editor-CV15HqlU.js} +1 -1
  89. package/dist/client/assets/{monitoring-stats-row-CvAc2TdA.js → monitoring-stats-row-FCrYNYUL.js} +1 -1
  90. package/dist/client/assets/{oauth-callback-CVJgN1AT.js → oauth-callback-W1x4HvAt.js} +1 -1
  91. package/dist/client/assets/{oauth-callback-ai-provider-oXA-Awv1.js → oauth-callback-ai-provider-8jGGtkD-.js} +1 -1
  92. package/dist/client/assets/{onboarding-BLnL078F.js → onboarding-DiKHM7MB.js} +1 -1
  93. package/dist/client/assets/{org-layout-OuwJcURT.js → org-layout-B-bINoer.js} +1 -1
  94. package/dist/client/assets/{org-plugin-layout-BldguEGv.js → org-plugin-layout-enuMys5H.js} +1 -1
  95. package/dist/client/assets/{plugin-empty-state-CRh8LLke.js → plugin-empty-state-DCR5r8Zj.js} +1 -1
  96. package/dist/client/assets/{plugin-header-DQQsADvB.js → plugin-header-DX2ycNO6.js} +1 -1
  97. package/dist/client/assets/{plugin-layout-xMoCwh-U.js → plugin-layout-2a2a-fWN.js} +1 -1
  98. package/dist/client/assets/{popover-Cl9Q4B_r.js → popover-CGtNHDEz.js} +1 -1
  99. package/dist/client/assets/{profile-Dwkg2__q.js → profile-C0rN-ocq.js} +1 -1
  100. package/dist/client/assets/{project-app-view-Ds5KIeD6.js → project-app-view-CQsZ6NHk.js} +1 -1
  101. package/dist/client/assets/registry-BO2q_Gke.js +2 -0
  102. package/dist/client/assets/{registry-layout-BcsYgVKZ.js → registry-layout-YWa06n-y.js} +1 -1
  103. package/dist/client/assets/{required-auth-layout-3FXLvGi_.js → required-auth-layout-emsOE3qR.js} +1 -1
  104. package/dist/client/assets/{reset-password-CchTJTF9.js → reset-password-CfhsLJCK.js} +1 -1
  105. package/dist/client/assets/{roles-5IF_wtdu.js → roles-BDsBxvE0.js} +1 -1
  106. package/dist/client/assets/{scroll-area-094tZsTA.js → scroll-area-CoWBmpAM.js} +1 -1
  107. package/dist/client/assets/{search-input-CIR03_9I.js → search-input-DRzVzeWW.js} +1 -1
  108. package/dist/client/assets/{select-C3X6ssTw.js → select-DerdayxE.js} +1 -1
  109. package/dist/client/assets/{select-model-BcH4syAI.js → select-model-BdV3Nm5y.js} +1 -1
  110. package/dist/client/assets/{settings-layout-DiCQMM4S.js → settings-layout-B3TmxZwq.js} +1 -1
  111. package/dist/client/assets/{settings-section-Q55Fgh-8.js → settings-section-nyO0fOgx.js} +1 -1
  112. package/dist/client/assets/{shell-layout-4T5ISWfh.js → shell-layout-cKwbYqFy.js} +1 -1
  113. package/dist/client/assets/{skeleton-DGdg1BKw.js → skeleton-ClT50YXx.js} +1 -1
  114. package/dist/client/assets/{sso-Coky_69P.js → sso-DXETt_Ed.js} +1 -1
  115. package/dist/client/assets/{store-hdsNmYTT.js → store-BBgqe7Dc.js} +1 -1
  116. package/dist/client/assets/store-registry-DKa8Ghfu.js +2 -0
  117. package/dist/client/assets/{switch-D2IuZl3W.js → switch-Bp1Tvx2h.js} +1 -1
  118. package/dist/client/assets/{table-DMAlnYBn.js → table-BL7WuMkY.js} +1 -1
  119. package/dist/client/assets/{tabs-BqcAeZdj.js → tabs-CNz9F6wL.js} +1 -1
  120. package/dist/client/assets/{task-status-95rqQaw6.js → task-status-D3v6N-jY.js} +1 -1
  121. package/dist/client/assets/{textarea-B3aDHfMl.js → textarea-BxmFQbso.js} +1 -1
  122. package/dist/client/assets/{toggle-group-CRKBIdwr.js → toggle-group-B4KaadHq.js} +1 -1
  123. package/dist/client/assets/{tools-list-D1jmrWjZ.js → tools-list-BNtwzSa4.js} +1 -1
  124. package/dist/client/assets/{types-CmztvBo8.js → types-BtVZ_7jK.js} +1 -1
  125. package/dist/client/assets/{use-ai-providers-DV1XR9hI.js → use-ai-providers-DqhLue8O.js} +1 -1
  126. package/dist/client/assets/{use-collections-5a3WcFJc.js → use-collections-CLt7BhQ3.js} +1 -1
  127. package/dist/client/assets/{use-connection-dg_H_Pr1.js → use-connection-BCV5VAjQ.js} +1 -1
  128. package/dist/client/assets/{use-copy-RJi4IuzY.js → use-copy-CYT1tdMJ.js} +1 -1
  129. package/dist/client/assets/{use-create-virtual-mcp-CCwbfx6_.js → use-create-virtual-mcp-DPW_d2QJ.js} +1 -1
  130. package/dist/client/assets/{use-decopilot-events-Dzf3hgZq.js → use-decopilot-events-BNaQbe7E.js} +1 -1
  131. package/dist/client/assets/{use-delete-connection-D5D7M4ay.js → use-delete-connection-YzycomMd.js} +1 -1
  132. package/dist/client/assets/{use-infinite-scroll-C3Qa6hGW.js → use-infinite-scroll-CoMWGssU.js} +1 -1
  133. package/dist/client/assets/{use-list-state-hDUYjUlU.js → use-list-state-jiGNrC7M.js} +1 -1
  134. package/dist/client/assets/{use-mcp-tools-DigN6mZj.js → use-mcp-tools-yi4edHzR.js} +1 -1
  135. package/dist/client/assets/{use-members-ChwILPhE.js → use-members-BPb2gPfy.js} +1 -1
  136. package/dist/client/assets/{use-mobile-BSlkjiym.js → use-mobile-BACO9YYc.js} +1 -1
  137. package/dist/client/assets/{use-navigate-to-agent-yRpKyeIE.js → use-navigate-to-agent-DbPOuTIs.js} +1 -1
  138. package/dist/client/assets/{use-org-sso-OgWFYsGG.js → use-org-sso-CEfAe1W3.js} +1 -1
  139. package/dist/client/assets/{use-organization-roles-AsLd-PIV.js → use-organization-roles-1TjtICKp.js} +1 -1
  140. package/dist/client/assets/{use-organization-settings-dHr-vwwr.js → use-organization-settings-B98QP_Ve.js} +1 -1
  141. package/dist/client/assets/{use-registry-connections-CYHmfgoy.js → use-registry-connections-D0FgXcrs.js} +1 -1
  142. package/dist/client/assets/{use-status-sounds-B12GPbr_.js → use-status-sounds-B5WhjryL.js} +1 -1
  143. package/dist/client/assets/{use-tasks-CBpkur0D.js → use-tasks-COeMfIn8.js} +1 -1
  144. package/dist/client/assets/{use-view-mode-BAlWkrBx.js → use-view-mode-BLlR5qfu.js} +1 -1
  145. package/dist/client/assets/{use-virtual-mcp-CTcuyRU_.js → use-virtual-mcp-CZoeCuBL.js} +1 -1
  146. package/dist/client/assets/useInfiniteQuery-BiAZtptE.js +1 -0
  147. package/dist/client/assets/useSuspenseInfiniteQuery-CPbx6xDm.js +1 -0
  148. package/dist/client/assets/{user-BnSZoTYs.js → user-CWcWoefF.js} +1 -1
  149. package/dist/client/assets/{view-mode-toggle-XuC9ujfW.js → view-mode-toggle-C_B0ABFw.js} +1 -1
  150. package/dist/client/assets/{workflow-CmKE8auY.js → workflow-Cq9jV44q.js} +1 -1
  151. package/dist/client/assets/workflow-detail-CaiPxMVe.js +1 -0
  152. package/dist/client/index.html +2 -2
  153. package/dist/server/cli.js +2 -2
  154. package/dist/server/server.js +1 -1
  155. package/package.json +1 -1
  156. package/dist/client/assets/ai-providers-B3ZQpsvX.js +0 -1
  157. package/dist/client/assets/index-BHUL0rr0.css +0 -1
  158. package/dist/client/assets/registry-BBs0abCV.js +0 -2
  159. package/dist/client/assets/store-registry-DMKzasMp.js +0 -2
  160. package/dist/client/assets/useInfiniteQuery-DWgeOHBC.js +0 -1
  161. package/dist/client/assets/useSuspenseInfiniteQuery-B1Hn37mg.js +0 -1
  162. package/dist/client/assets/workflow-detail-DUmWuXHM.js +0 -1
  163. package/dist/server/node_modules/ansi-styles/index.d.ts +0 -236
  164. package/dist/server/node_modules/ansi-styles/index.js +0 -223
  165. package/dist/server/node_modules/ansi-styles/license +0 -9
  166. package/dist/server/node_modules/ansi-styles/package.json +0 -54
  167. package/dist/server/node_modules/ansi-styles/readme.md +0 -173
  168. package/dist/server/node_modules/environment/index.d.ts +0 -74
  169. package/dist/server/node_modules/environment/index.js +0 -47
  170. package/dist/server/node_modules/environment/license +0 -9
  171. package/dist/server/node_modules/environment/package.json +0 -74
  172. package/dist/server/node_modules/environment/readme.md +0 -94
  173. package/dist/server/node_modules/escape-string-regexp/index.d.ts +0 -18
  174. package/dist/server/node_modules/escape-string-regexp/index.js +0 -11
  175. package/dist/server/node_modules/escape-string-regexp/license +0 -9
  176. package/dist/server/node_modules/escape-string-regexp/package.json +0 -43
  177. package/dist/server/node_modules/escape-string-regexp/readme.md +0 -29
  178. package/dist/server/node_modules/is-unicode-supported/index.d.ts +0 -12
  179. package/dist/server/node_modules/is-unicode-supported/index.js +0 -21
  180. package/dist/server/node_modules/is-unicode-supported/license +0 -9
  181. package/dist/server/node_modules/is-unicode-supported/package.json +0 -47
  182. package/dist/server/node_modules/is-unicode-supported/readme.md +0 -35
  183. package/dist/server/node_modules/pg-pool/LICENSE +0 -21
  184. package/dist/server/node_modules/pg-pool/README.md +0 -357
  185. package/dist/server/node_modules/pg-pool/esm/index.mjs +0 -5
  186. package/dist/server/node_modules/pg-pool/index.js +0 -517
  187. package/dist/server/node_modules/pg-pool/package.json +0 -51
  188. package/dist/server/node_modules/postgres-array/index.d.ts +0 -4
  189. package/dist/server/node_modules/postgres-array/index.js +0 -97
  190. package/dist/server/node_modules/postgres-array/license +0 -21
  191. package/dist/server/node_modules/postgres-array/package.json +0 -35
  192. package/dist/server/node_modules/postgres-array/readme.md +0 -43
  193. package/dist/server/node_modules/postgres-bytea/index.js +0 -33
  194. package/dist/server/node_modules/postgres-bytea/license +0 -21
  195. package/dist/server/node_modules/postgres-bytea/package.json +0 -34
  196. package/dist/server/node_modules/postgres-bytea/readme.md +0 -34
  197. package/dist/server/node_modules/string-width/index.d.ts +0 -39
  198. package/dist/server/node_modules/string-width/index.js +0 -82
  199. package/dist/server/node_modules/string-width/license +0 -9
  200. package/dist/server/node_modules/string-width/package.json +0 -64
  201. package/dist/server/node_modules/string-width/readme.md +0 -66
  202. package/dist/server/node_modules/xtend/.jshintrc +0 -30
  203. package/dist/server/node_modules/xtend/LICENSE +0 -20
  204. package/dist/server/node_modules/xtend/README.md +0 -32
  205. package/dist/server/node_modules/xtend/immutable.js +0 -19
  206. package/dist/server/node_modules/xtend/mutable.js +0 -17
  207. package/dist/server/node_modules/xtend/package.json +0 -55
  208. package/dist/server/node_modules/xtend/test.js +0 -103
@@ -1 +1 @@
1
- import{r as k,s as Re,K as ce,aM as it,j as s,c as H,l as _e,B as ne,e as q,n as Ge,o as De,x as rt,w as ot,a as we,z as pe,t as Ae,b as re,v as ye,aK as he,y as se,aI as Le,a_ as ve,E as lt,f as at,d as ct}from"./index-Dq226A4w.js";import{u as dt}from"./use-organization-roles-AsLd-PIV.js";import{B as fe}from"./badge--Lhfsu1W.js";import{f as Ue,a as ke,b as Ve,c as Be,d as ze,A as Ye,e as $e,g as He}from"./alert-dialog-7-SyZGSt.js";import{c as mt,d as ut,e as gt,D as Et}from"./dropdown-menu-DWNG84J5.js";import{i as Tt}from"./DotsVertical-ChXlfNDE.js";import{i as Ke}from"./Lock01-CT9fVg-M.js";import{s as Ce}from"./Plus-BX8KY2Vj.js";import{s as pt}from"./Trash01-CO6PRylN.js";import{C as ft}from"./collection-table-wrapper-Q2gV7sPs.js";import{P as te}from"./index-DNXvVXJy.js";import{E as je}from"./empty-state-CLCMWued.js";import{S as Se}from"./search-input-CIR03_9I.js";import{P as Fe,D as Qe}from"./ai-providers-logos-D6a8kmGH.js";import{I as be}from"./integration-icon-AZugc3yw.js";import{u as _t}from"./use-infinite-scroll-C3Qa6hGW.js";import{C as Oe}from"./checkbox-duvwt99y.js";import{i as It}from"./RefreshCcw01-DtyDEAf2.js";import{u as ht}from"./useSuspenseInfiniteQuery-B1Hn37mg.js";import{u as Rt,S as xt}from"./constants-BAzsARw1.js";import{C as Nt}from"./collection-search-BoQ_EppH.js";import{u as Ze}from"./use-members-ChwILPhE.js";import{u as Ct}from"./use-connection-dg_H_Pr1.js";import{u as At,c as St}from"./use-ai-providers-DV1XR9hI.js";import{A as qe}from"./avatar-Zzj9UMlL.js";import{S as oe}from"./switch-D2IuZl3W.js";import{T as ue,c as ge,a as Ee,b as Te}from"./use-mobile-BSlkjiym.js";import{t as bt}from"./ChevronDown-BjunjZ96.js";import{i as Ot}from"./ChevronRight-DZ8_B5Zy.js";import{a as yt}from"./SearchMd-CJm9ITir.js";import{i as Pe}from"./X-BFKhYElJ.js";import"./table-DMAlnYBn.js";import"./XClose-BL1_qV1F.js";import"./Container-BBbTXyMq.js";import"./agent-icon-BHvp6mzD.js";import"./AlertCircle-BU25E17i.js";import"./Tool01-Dqe-c7_N.js";import"./ArrowNarrowLeft-DsozI7ul.js";import"./XCircle-BCi1SPUb.js";import"./ArrowUpRight-wUPlLzWo.js";import"./ZapSquare-dR2caQ4h.js";import"./Users03-DGkdZmwX.js";import"./CheckCircle-B6ooPL10.js";import"./ChevronUp-BcfJms1N.js";import"./Star01-DLcvdqts.js";import"./Palette-CL1PeBDG.js";import"./LinkExternal01-Bq6E6IiB.js";import"./Sun-DwH3UR5R.js";import"./Play-O7Kb3HkD.js";import"./Settings02-0UGyPXgy.js";import"./Shield01-ajX6eCWD.js";import"./User01-JrKdMZpa.js";import"./Zap-Bsssnre4.js";import"./infiniteQueryObserver-DAJ1MAYd.js";import"./use-collections-5a3WcFJc.js";const Xe=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"BRAND_CONTEXT_LIST",description:"List brand contexts",category:"Organizations"},{name:"BRAND_CONTEXT_GET",description:"View brand context",category:"Organizations"},{name:"BRAND_CONTEXT_CREATE",description:"Create brand context",category:"Organizations"},{name:"BRAND_CONTEXT_UPDATE",description:"Update brand context",category:"Organizations"},{name:"BRAND_CONTEXT_DELETE",description:"Delete brand context",category:"Organizations",dangerous:!0},{name:"BRAND_CONTEXT_EXTRACT",description:"Extract brand context from website",category:"Organizations"},{name:"BRAND_GET",description:"Get brand (binding)",category:"Organizations"},{name:"BRAND_LIST",description:"List brands (binding)",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_GET",description:"Get organization domain claim",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_SET",description:"Set organization domain claim",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_UPDATE",description:"Update organization domain settings",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_CLEAR",description:"Clear organization domain claim",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"MONITORING_LOG_GET",description:"View monitoring log details",category:"Monitoring"},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"},{name:"AUTOMATION_CREATE",description:"Create automation",category:"Automations"},{name:"AUTOMATION_GET",description:"View automation details",category:"Automations"},{name:"AUTOMATION_LIST",description:"List automations",category:"Automations"},{name:"AUTOMATION_UPDATE",description:"Update automation",category:"Automations"},{name:"AUTOMATION_DELETE",description:"Delete automation",category:"Automations",dangerous:!0},{name:"AUTOMATION_TRIGGER_ADD",description:"Add trigger to automation",category:"Automations"},{name:"AUTOMATION_TRIGGER_REMOVE",description:"Remove trigger from automation",category:"Automations"},{name:"AUTOMATION_RUN",description:"Manually trigger an automation run",category:"Automations"},{name:"VIRTUAL_MCP_PLUGIN_CONFIG_GET",description:"View virtual MCP plugin configuration",category:"Virtual MCPs"},{name:"VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE",description:"Update virtual MCP plugin configuration",category:"Virtual MCPs"},{name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",description:"Update virtual MCP pinned sidebar views",category:"Virtual MCPs"},{name:"AI_PROVIDERS_LIST",description:"List available AI providers",category:"AI Providers"},{name:"AI_PROVIDERS_LIST_MODELS",description:"List AI provider models",category:"AI Providers"},{name:"AI_PROVIDERS_ACTIVE",description:"List active AI providers",category:"AI Providers"},{name:"AI_PROVIDER_KEY_CREATE",description:"Store AI provider API key",category:"AI Providers"},{name:"AI_PROVIDER_KEY_LIST",description:"List AI provider API keys",category:"AI Providers"},{name:"AI_PROVIDER_KEY_DELETE",description:"Delete AI provider API key",category:"AI Providers",dangerous:!0},{name:"AI_PROVIDER_OAUTH_URL",description:"Get OAuth URL for provider",category:"AI Providers"},{name:"AI_PROVIDER_OAUTH_EXCHANGE",description:"Exchange OAuth code for API key",category:"AI Providers"},{name:"AI_PROVIDER_PROVISION_KEY",description:"Auto-provision API key for a provider",category:"AI Providers"},{name:"AI_PROVIDER_TOPUP_URL",description:"Get checkout URL to top up provider credits",category:"AI Providers"},{name:"AI_PROVIDER_CREDITS",description:"Get current credit balance for a provider",category:"AI Providers"},{name:"AI_PROVIDER_CLI_ACTIVATE",description:"Activate Claude Code via local CLI",category:"AI Providers"},{name:"LIST_OBJECTS",description:"List objects in storage",category:"Object Storage"},{name:"GET_OBJECT_METADATA",description:"Get object metadata",category:"Object Storage"},{name:"GET_PRESIGNED_URL",description:"Generate download URL",category:"Object Storage"},{name:"PUT_PRESIGNED_URL",description:"Generate upload URL",category:"Object Storage"},{name:"DELETE_OBJECT",description:"Delete object",category:"Object Storage",dangerous:!0},{name:"DELETE_OBJECTS",description:"Delete multiple objects",category:"Object Storage",dangerous:!0},{name:"COLLECTION_REGISTRY_APP_LIST",description:"List registry apps",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_GET",description:"Get registry app details",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_VERSIONS",description:"List registry app versions",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_FILTERS",description:"Get registry app filters",category:"Registry"},{name:"REGISTRY_ITEM_LIST",description:"List private registry items",category:"Registry"},{name:"REGISTRY_ITEM_SEARCH",description:"Search registry items",category:"Registry"},{name:"REGISTRY_ITEM_GET",description:"Get registry item details",category:"Registry"},{name:"REGISTRY_ITEM_VERSIONS",description:"List registry item versions",category:"Registry"},{name:"REGISTRY_ITEM_CREATE",description:"Create registry item",category:"Registry"},{name:"REGISTRY_ITEM_BULK_CREATE",description:"Bulk create registry items",category:"Registry"},{name:"REGISTRY_ITEM_UPDATE",description:"Update registry item",category:"Registry"},{name:"REGISTRY_ITEM_DELETE",description:"Delete registry item",category:"Registry",dangerous:!0},{name:"REGISTRY_ITEM_FILTERS",description:"Get registry item filters",category:"Registry"},{name:"REGISTRY_DISCOVER_TOOLS",description:"Discover tools from MCP server",category:"Registry"},{name:"REGISTRY_AI_GENERATE",description:"AI-generate registry content",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_LIST",description:"List publish requests",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_REVIEW",description:"Review publish request",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_COUNT",description:"Count pending publish requests",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_DELETE",description:"Delete publish request",category:"Registry",dangerous:!0},{name:"REGISTRY_PUBLISH_API_KEY_GENERATE",description:"Generate publish API key",category:"Registry"},{name:"REGISTRY_PUBLISH_API_KEY_LIST",description:"List publish API keys",category:"Registry"},{name:"REGISTRY_PUBLISH_API_KEY_REVOKE",description:"Revoke publish API key",category:"Registry",dangerous:!0},{name:"REGISTRY_MONITOR_RUN_START",description:"Start monitor run",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_LIST",description:"List monitor runs",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_GET",description:"Get monitor run details",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_CANCEL",description:"Cancel monitor run",category:"Registry"},{name:"REGISTRY_MONITOR_RESULT_LIST",description:"List monitor results",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_LIST",description:"List monitor connections",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_SYNC",description:"Sync monitor connections",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_UPDATE_AUTH",description:"Update monitor connection auth",category:"Registry"},{name:"REGISTRY_MONITOR_SCHEDULE_SET",description:"Set monitor schedule",category:"Registry"},{name:"REGISTRY_MONITOR_SCHEDULE_CANCEL",description:"Cancel monitor schedule",category:"Registry"},{name:"VM_START",description:"Start a Freestyle VM with dev server preview",category:"VM"},{name:"VM_DELETE",description:"Stop and delete a Freestyle VM",category:"VM"},{name:"GITHUB_LIST_USER_ORGS",description:"List GitHub user's personal account and organizations",category:"GitHub"}],Lt={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",BRAND_CONTEXT_LIST:"List brand contexts",BRAND_CONTEXT_GET:"View brand context",BRAND_CONTEXT_CREATE:"Create brand context",BRAND_CONTEXT_UPDATE:"Update brand context",BRAND_CONTEXT_DELETE:"Delete brand context",BRAND_CONTEXT_EXTRACT:"Extract brand from website",BRAND_GET:"Get brand",BRAND_LIST:"List brands",ORGANIZATION_DOMAIN_GET:"Get domain claim",ORGANIZATION_DOMAIN_SET:"Set domain claim",ORGANIZATION_DOMAIN_UPDATE:"Update domain settings",ORGANIZATION_DOMAIN_CLEAR:"Clear domain claim",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",MONITORING_LOG_GET:"View monitoring log details",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags",VIRTUAL_MCP_PLUGIN_CONFIG_GET:"View plugin config",VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE:"Update plugin config",VIRTUAL_MCP_PINNED_VIEWS_UPDATE:"Update pinned views",AUTOMATION_CREATE:"Create automation",AUTOMATION_GET:"View automation details",AUTOMATION_LIST:"List automations",AUTOMATION_UPDATE:"Update automation",AUTOMATION_DELETE:"Delete automation",AUTOMATION_TRIGGER_ADD:"Add trigger",AUTOMATION_TRIGGER_REMOVE:"Remove trigger",AUTOMATION_RUN:"Run automation",AI_PROVIDERS_LIST:"List AI providers",AI_PROVIDERS_LIST_MODELS:"List AI models",AI_PROVIDERS_ACTIVE:"List active providers",AI_PROVIDER_KEY_CREATE:"Create provider key",AI_PROVIDER_KEY_LIST:"List provider keys",AI_PROVIDER_KEY_DELETE:"Delete provider key",AI_PROVIDER_OAUTH_URL:"Get OAuth URL",AI_PROVIDER_OAUTH_EXCHANGE:"Connect via OAuth",AI_PROVIDER_PROVISION_KEY:"Auto-provision key",AI_PROVIDER_TOPUP_URL:"Get top-up checkout URL",AI_PROVIDER_CREDITS:"Get credit balance",AI_PROVIDER_CLI_ACTIVATE:"Activate Claude Code CLI",LIST_OBJECTS:"List objects",GET_OBJECT_METADATA:"Get object metadata",GET_PRESIGNED_URL:"Generate download URL",PUT_PRESIGNED_URL:"Generate upload URL",DELETE_OBJECT:"Delete object",DELETE_OBJECTS:"Delete multiple objects",COLLECTION_REGISTRY_APP_LIST:"List registry apps",COLLECTION_REGISTRY_APP_GET:"Get registry app",COLLECTION_REGISTRY_APP_VERSIONS:"List registry app versions",COLLECTION_REGISTRY_APP_FILTERS:"Get registry filters",REGISTRY_ITEM_LIST:"List registry items",REGISTRY_ITEM_SEARCH:"Search registry",REGISTRY_ITEM_GET:"Get registry item",REGISTRY_ITEM_VERSIONS:"List item versions",REGISTRY_ITEM_CREATE:"Create registry item",REGISTRY_ITEM_BULK_CREATE:"Bulk create items",REGISTRY_ITEM_UPDATE:"Update registry item",REGISTRY_ITEM_DELETE:"Delete registry item",REGISTRY_ITEM_FILTERS:"Get item filters",REGISTRY_DISCOVER_TOOLS:"Discover tools",REGISTRY_AI_GENERATE:"AI generate content",REGISTRY_PUBLISH_REQUEST_LIST:"List publish requests",REGISTRY_PUBLISH_REQUEST_REVIEW:"Review publish request",REGISTRY_PUBLISH_REQUEST_COUNT:"Count publish requests",REGISTRY_PUBLISH_REQUEST_DELETE:"Delete publish request",REGISTRY_PUBLISH_API_KEY_GENERATE:"Generate API key",REGISTRY_PUBLISH_API_KEY_LIST:"List API keys",REGISTRY_PUBLISH_API_KEY_REVOKE:"Revoke API key",REGISTRY_MONITOR_RUN_START:"Start monitor run",REGISTRY_MONITOR_RUN_LIST:"List monitor runs",REGISTRY_MONITOR_RUN_GET:"Get monitor run",REGISTRY_MONITOR_RUN_CANCEL:"Cancel monitor run",REGISTRY_MONITOR_RESULT_LIST:"List monitor results",REGISTRY_MONITOR_CONNECTION_LIST:"List monitor connections",REGISTRY_MONITOR_CONNECTION_SYNC:"Sync monitor connections",REGISTRY_MONITOR_CONNECTION_UPDATE_AUTH:"Update connection auth",REGISTRY_MONITOR_SCHEDULE_SET:"Set monitor schedule",REGISTRY_MONITOR_SCHEDULE_CANCEL:"Cancel monitor schedule",VM_START:"Start VM preview",VM_DELETE:"Delete VM preview",GITHUB_LIST_USER_ORGS:"List GitHub user orgs"};function vt(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],Tags:[],"AI Providers":[],Automations:[],"Object Storage":[],Registry:[],GitHub:[],VM:[]};for(const e of Xe)t[e.category]?.push(e);return t}function jt(){return Xe.map(t=>({value:t.name,label:Lt[t.name],dangerous:t.dangerous}))}const Pt=k.memo(function(e){const n=q.c(21),{connection:i,isSelected:o,hasToolsEnabled:c,activeToolsCount:u,totalToolsCount:f,onSelect:d,onToggle:T}=e,g=o?"bg-accent/50":"hover:bg-muted/50";let r;n[0]!==g?(r=H("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",g),n[0]=g,n[1]=r):r=n[1];let E;n[2]!==i.icon||n[3]!==i.title?(E=s.jsx(be,{icon:i.icon,name:i.title,size:"xs"}),n[2]=i.icon,n[3]=i.title,n[4]=E):E=n[4];let a;n[5]!==i.title?(a=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:i.title})}),n[5]=i.title,n[6]=a):a=n[6];let m;n[7]!==d||n[8]!==E||n[9]!==a?(m=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:d,children:[E,a]}),n[7]=d,n[8]=E,n[9]=a,n[10]=m):m=n[10];let _;n[11]!==u||n[12]!==i.tools||n[13]!==c||n[14]!==T||n[15]!==f?(_=i.tools&&i.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[u,"/",f]}),s.jsx(Oe,{checked:c,onCheckedChange:T,onClick:Dt})]}),n[11]=u,n[12]=i.tools,n[13]=c,n[14]=T,n[15]=f,n[16]=_):_=n[16];let x;return n[17]!==r||n[18]!==m||n[19]!==_?(x=s.jsxs("div",{className:r,children:[m,_]}),n[17]=r,n[18]=m,n[19]=_,n[20]=x):x=n[20],x}),Mt=k.memo(function(e){const n=q.c(18),{connectionId:i,tool:o,isSelected:c,onToggle:u}=e,f=`tool-${i}-${o.name}`,d=c?"text-foreground":"text-muted-foreground";let T;n[0]!==d?(T=H("text-sm font-medium",d),n[0]=d,n[1]=T):T=n[1];let g;n[2]!==T||n[3]!==o.name?(g=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:T,children:o.name})}),n[2]=T,n[3]=o.name,n[4]=g):g=n[4];let r;n[5]!==o.description?(r=o.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:o.description}),n[5]=o.description,n[6]=r):r=n[6];let E;n[7]!==g||n[8]!==r?(E=s.jsxs("div",{className:"flex-1 min-w-0",children:[g,r]}),n[7]=g,n[8]=r,n[9]=E):E=n[9];const a=`tool-${i}-${o.name}`;let m;n[10]!==c||n[11]!==u||n[12]!==a?(m=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(Oe,{id:a,checked:c,onCheckedChange:u,onClick:wt})}),n[10]=c,n[11]=u,n[12]=a,n[13]=m):m=n[13];let _;return n[14]!==f||n[15]!==E||n[16]!==m?(_=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:f,children:[E,m]}),n[14]=f,n[15]=E,n[16]=m,n[17]=_):_=n[17],_});function Gt({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n,searchQuery:i}){const[o,c]=k.useState(""),u=i!==void 0?i:o,f=k.useDeferredValue(u),[d,T]=k.useState("all"),[g,r]=k.useState(!1),E=k.useRef(new Set(Object.keys(t))),{org:a}=Re(),m=Rt({connectionId:xt,orgId:a.id}),_=100,x=f.trim(),C=x?{operator:"or",conditions:[{field:["title"],operator:"contains",value:x},{field:["description"],operator:"contains",value:x}]}:void 0,v=!!n,A={...C&&{where:C},orderBy:[{field:["updated_at"],direction:"asc"}],limit:_,offset:0,...v&&{include_virtual:!0}},y=JSON.stringify(A),{data:S,fetchNextPage:N,hasNextPage:p,isFetchingNextPage:b}=ht({queryKey:ce.collectionListInfinite(m,a.id,"","CONNECTIONS",y),queryFn:async({pageParam:I=0})=>(await m.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...C&&{where:C},orderBy:[{field:["updated_at"],direction:"asc"}],limit:_,offset:I,...v&&{include_virtual:!0}}})).structuredContent,initialPageParam:0,getNextPageParam:(I,U)=>{if(I?.hasMore)return U.reduce((K,ee)=>K+(ee?.items?.length??0),0)},staleTime:3e4}),l=S?.pages.flatMap(I=>I?.items??[])??[],h=_t(N,p??!1,b),P=n?l.filter(I=>I.connection_type!=="VIRTUAL"?!0:it(I.connection_url)!==n):l,j=E.current,R=[...j.values()].map(I=>P.find(U=>U.id===I)).filter(I=>I!==void 0),O=P.filter(I=>!j.has(I.id)),M=[...R,...O],Y=I=>{const U=t[I];return U!==void 0&&U.length>0},z=M.filter(I=>{if(d==="all")return!0;const U=Y(I.id);return d==="selected"?U:d==="unselected"?!U:!0}),[D,w]=k.useState(M[0]?.id??null),L=D?M.find(I=>I.id===D)??null:null,V=L?.tools??[],$=(I,U)=>t[I]?.includes(U)??!1,Q=(I,U)=>{const K=t[I]??[],ee=K.includes(U),Z={...t};if(ee){const J=K.filter(F=>F!==U);J.length===0?delete Z[I]:Z[I]=J}else Z[I]=[...K,U];e(Z)},X=I=>{const U=M.find(F=>F.id===I);if(!U?.tools)return;const K=t[I]??[],ee=U.tools.map(F=>F.name),Z=K.length>0&&ee.every(F=>K.includes(F)),J={...t};Z?delete J[I]:(J[I]=ee,w(I)),e(J)},W=I=>{w(I),r(!0)},ie=()=>{r(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:H("w-full md:w-80 border-r border-border flex flex-col",g&&"hidden md:flex"),children:[i===void 0&&s.jsx(Nt,{value:o,onChange:c,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>T("all"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>T("selected"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>T("unselected"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:z.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:u?"No connections found":d==="selected"?"No servers selected":d==="unselected"?"No unselected servers":"No connections available"}):s.jsxs("div",{className:"p-2 space-y-1",children:[z.map(I=>{const U=I.tools?.length??0,K=t[I.id]?.length??0;return s.jsx(Pt,{connection:I,isSelected:D===I.id,hasToolsEnabled:Y(I.id),activeToolsCount:K,totalToolsCount:U,onSelect:()=>W(I.id),onToggle:()=>X(I.id)},I.id)}),s.jsx("div",{ref:h,className:"h-4"}),b&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(_e,{size:18,className:"animate-spin text-muted-foreground"})})]})})]}),s.jsx("div",{className:H("flex-1 flex-col",g?"flex":"hidden md:flex"),children:L?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:ie,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(It,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(be,{icon:L.icon,name:L.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:L.title}),L.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:L.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:V.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:V.map(I=>s.jsx(Mt,{connectionId:L.id,tool:I,isSelected:$(L.id,I.name),onToggle:()=>Q(L.id,I.name)},I.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function Dt(t){return t.stopPropagation()}function wt(t){return t.stopPropagation()}const xe=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],Ut={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function Je(t){if(!t)return"bg-neutral-400";let e=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);e=(e<<5)-e+o,e=e&e}const n=Math.abs(e)%xe.length;return xe[n]??xe[0]}function Me(t,e){return e?Ut[t]??"bg-neutral-400":Je(t)}const kt=ye({role:ye({id:se().optional(),slug:se().optional(),label:se()}),allowAllStaticPermissions:ve(),staticPermissions:he(se()),toolSet:Le(se(),he(se())),allowAllModels:ve(),modelSet:Le(se(),he(se())),memberIds:he(se())});function We(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Vt(t){const e=q.c(34),{allowAllStaticPermissions:n,staticPermissions:i,onAllowAllChange:o,onPermissionsChange:c,readOnly:u,searchQuery:f}=t,d=u===void 0?!1:u,T=k.useDeferredValue(f);let g,r,E,a;if(e[0]!==n||e[1]!==T||e[2]!==o||e[3]!==c||e[4]!==d||e[5]!==i){const x=vt(),C=jt(),v=C.filter(l=>l.label.toLowerCase().includes(T.toLowerCase())),A=l=>{if(i.includes(l))c(i.filter(h=>h!==l));else{const h=[...i,l];h.length===C.length?(o(!0),c([])):c(h)}};E="flex flex-col h-full";const y=!d&&"hover:bg-muted/50 cursor-pointer";let S;e[10]!==y?(S=H("flex items-center justify-between px-4 py-3",y),e[10]=y,e[11]=S):S=e[11];let N;e[12]!==n||e[13]!==o||e[14]!==c||e[15]!==d?(N=()=>{d||(o(!n),c([]))},e[12]=n,e[13]=o,e[14]=c,e[15]=d,e[16]=N):N=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[17]=p):p=e[17];let b;e[18]!==n||e[19]!==o||e[20]!==c||e[21]!==d?(b=s.jsx("div",{onClick:Kt,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n,disabled:!0,onCheckedChange:Ht})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n,onCheckedChange:l=>{o(l),c([])}})}),e[18]=n,e[19]=o,e[20]=c,e[21]=d,e[22]=b):b=e[22],e[23]!==b||e[24]!==S||e[25]!==N?(a=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:S,onClick:N,children:[p,b]})}),e[23]=b,e[24]=S,e[25]=N,e[26]=a):a=e[26],g="flex-1 overflow-auto",r=Object.entries(x).map(l=>{const[h,P]=l,j=v.filter(R=>P.some(O=>O.name===R.value));return j.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:h}),s.jsx("div",{className:"space-y-1",children:j.map(R=>s.jsxs("div",{className:H("flex items-center justify-between gap-3 px-4 py-3",!d&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{d||(n?(o(!1),c(C.map($t).filter(O=>O!==R.value))):A(R.value))},children:[s.jsx("span",{className:"text-sm flex-1 min-w-0",children:R.label}),s.jsx("div",{onClick:Yt,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n||i.includes(R.value),disabled:!0,onCheckedChange:zt})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n||i.includes(R.value),onCheckedChange:()=>{n?(o(!1),c(C.map(Bt).filter(O=>O!==R.value))):A(R.value)}})})]},R.value))})]},h)}),e[0]=n,e[1]=T,e[2]=o,e[3]=c,e[4]=d,e[5]=i,e[6]=g,e[7]=r,e[8]=E,e[9]=a}else g=e[6],r=e[7],E=e[8],a=e[9];let m;e[27]!==g||e[28]!==r?(m=s.jsx("div",{className:g,children:r}),e[27]=g,e[28]=r,e[29]=m):m=e[29];let _;return e[30]!==E||e[31]!==a||e[32]!==m?(_=s.jsxs("div",{className:E,children:[a,m]}),e[30]=E,e[31]=a,e[32]=m,e[33]=_):_=e[33],_}function Bt(t){return t.value}function zt(){}function Yt(t){return t.stopPropagation()}function $t(t){return t.value}function Ht(){}function Kt(t){return t.stopPropagation()}const et={anthropic:"Anthropic",openrouter:"OpenRouter"},Ft={openai:"OpenAI",anthropic:"Anthropic",google:"Google","meta-llama":"Meta",mistralai:"Mistral","x-ai":"xAI",deepseek:"DeepSeek",qwen:"Qwen",moonshotai:"MoonshotAI",nvidia:"NVIDIA",perplexity:"Perplexity",cohere:"Cohere",amazon:"Amazon",microsoft:"Microsoft","z-ai":"Z.ai","ibm-granite":"IBM Granite",alibaba:"Alibaba",baidu:"Baidu",bytedance:"ByteDance",tencent:"Tencent",minimax:"MiniMax",nousresearch:"Nous Research",allenai:"Allen AI",inception:"Inception"};function Qt(t,e){const n=t.indexOf("/"),i=n>0?t.slice(0,n):e;return i.startsWith("~")?i.slice(1):i}function Zt(t){return Ft[t]??et[t]??t}function qt(t){const e=t.indexOf(": ");return e>0&&e<32?t.slice(e+2):t}const tt=30;function Xt(t){const e=q.c(44),{connectionId:n,subProviderId:i,subProviderName:o,groupLogo:c,models:u,allConnectionModelIds:f,selectedModels:d,allowAllModels:T,allConnectionModelsSelected:g,onToggleModel:r,onExitAllowAll:E,readOnly:a,defaultExpanded:m}=t,[_,x]=k.useState(m),C=m||_,v=x,[A,y]=k.useState(tt);let S;e[0]!==g||e[1]!==T||e[2]!==d?(S=h=>T||g||d.includes("*")||d.includes(h),e[0]=g,e[1]=T,e[2]=d,e[3]=S):S=e[3];const N=S;let p;if(e[4]!==N||e[5]!==u){let h;e[7]!==N?(h=P=>N(P.id),e[7]=N,e[8]=h):h=e[8],p=u.filter(h),e[4]=N,e[5]=u,e[6]=p}else p=e[6];const b=p.length;let l;if(e[9]!==f||e[10]!==T||e[11]!==n||e[12]!==b||e[13]!==C||e[14]!==c||e[15]!==N||e[16]!==u||e[17]!==E||e[18]!==r||e[19]!==a||e[20]!==i||e[21]!==o||e[22]!==A){const h=u.slice(0,A),P=u.length>A;let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=()=>v(ts),e[24]=j):j=e[24];const R=c??Fe[i]??Qe;let O;e[25]!==o||e[26]!==R?(O=s.jsx(be,{icon:R,name:o,size:"sm"}),e[25]=o,e[26]=R,e[27]=O):O=e[27];let M;e[28]!==o?(M=s.jsx("span",{className:"text-sm font-medium truncate",children:o}),e[28]=o,e[29]=M):M=e[29];let Y;e[30]!==O||e[31]!==M?(Y=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[O,M]}),e[30]=O,e[31]=M,e[32]=Y):Y=e[32];let z;e[33]!==b||e[34]!==u.length?(z=s.jsxs(fe,{variant:"secondary",className:"text-xs text-muted-foreground",children:[b,"/",u.length," enabled"]}),e[33]=b,e[34]=u.length,e[35]=z):z=e[35];let D;e[36]!==C?(D=C?s.jsx(bt,{size:16,className:"text-muted-foreground shrink-0"}):s.jsx(Ot,{size:16,className:"text-muted-foreground shrink-0"}),e[36]=C,e[37]=D):D=e[37];let w;e[38]!==D||e[39]!==z?(w=s.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[z,D]}),e[38]=D,e[39]=z,e[40]=w):w=e[40];let L;e[41]!==w||e[42]!==Y?(L=s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 hover:bg-muted/50 cursor-pointer",onClick:j,children:[Y,w]}),e[41]=w,e[42]=Y,e[43]=L):L=e[43],l=s.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card",children:[L,C&&s.jsxs("div",{className:"border-t border-border bg-muted/20",children:[h.map(V=>{const $=N(V.id),Q=()=>{if(!a){if(T){E(n,f,V.id);return}r(n,V.id)}};return s.jsxs("div",{className:H("flex items-center justify-between gap-3 px-4 py-3 border-b border-border last:border-b-0",!a&&"hover:bg-muted/50 cursor-pointer"),onClick:Q,children:[s.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:s.jsx("span",{className:"text-sm truncate",children:V.title})}),s.jsx("div",{onClick:es,children:a?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:$,disabled:!0,onCheckedChange:Wt})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:$,onCheckedChange:Q})})]},V.id)}),P&&s.jsxs("button",{type:"button",className:"w-full px-4 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",onClick:()=>y(Jt),children:["Show more (",u.length-A," remaining)"]})]})]}),e[9]=f,e[10]=T,e[11]=n,e[12]=b,e[13]=C,e[14]=c,e[15]=N,e[16]=u,e[17]=E,e[18]=r,e[19]=a,e[20]=i,e[21]=o,e[22]=A,e[23]=l}else l=e[23];return l}function Jt(t){return t+tt}function Wt(){}function es(t){return t.stopPropagation()}function ts(t){return!t}function ss(t){const e=q.c(33),{connection:n,selectedModels:i,allowAllModels:o,onToggleModel:c,onExitAllowAll:u,allConnectionModelsSelected:f,searchQuery:d,readOnly:T}=t,g=St(n.id);let r,E,a,m,_;if(e[0]!==f||e[1]!==o||e[2]!==n.id||e[3]!==n.label||e[4]!==n.providerId||e[5]!==u||e[6]!==c||e[7]!==g||e[8]!==T||e[9]!==d||e[10]!==i){_=Symbol.for("react.early_return_sentinel");e:{let v;e[16]!==n.label?(v=R=>({...R,id:R.modelId,provider:n.label}),e[16]=n.label,e[17]=v):v=e[17];const A=g.filter(os).map(v),y=d.trim().toLowerCase(),S=y?A.filter(R=>R.title.toLowerCase().includes(y)||R.id.toLowerCase().includes(y)||R.provider?.toLowerCase().includes(y)):A;if(S.length===0){_=null;break e}const N=new Map;for(const R of S){const O=Qt(R.id,n.providerId),M=N.get(O)??{models:[],logo:null};M.models.push({id:R.id,title:qt(R.title),logo:R.logo}),!M.logo&&R.logo&&(M.logo=R.logo),N.set(O,M)}const p=Array.from(N.entries()).map(rs).sort(is),b=p.length===1||y.length>0;a="flex flex-col gap-3";const l=Fe[n.providerId]??Qe;let h;e[18]!==n.providerId||e[19]!==l?(h=s.jsx("img",{src:l,alt:n.providerId,className:"w-4 h-4 rounded-sm dark:bg-white dark:rounded-sm dark:p-px"}),e[18]=n.providerId,e[19]=l,e[20]=h):h=e[20];const P=et[n.providerId]??n.providerId;let j;e[21]!==P?(j=s.jsx("h4",{className:"text-sm font-medium",children:P}),e[21]=P,e[22]=j):j=e[22],e[23]!==j||e[24]!==h?(m=s.jsxs("div",{className:"flex items-center gap-2",children:[h,j]}),e[23]=j,e[24]=h,e[25]=m):m=e[25],r="flex flex-col gap-3",E=p.map(R=>s.jsx(Xt,{connectionId:n.id,subProviderId:R.id,subProviderName:R.name,groupLogo:R.logo,models:R.models,allConnectionModelIds:A.map(ns),selectedModels:i,allowAllModels:o,allConnectionModelsSelected:f,onToggleModel:c,onExitAllowAll:u,readOnly:T,defaultExpanded:b},R.id))}e[0]=f,e[1]=o,e[2]=n.id,e[3]=n.label,e[4]=n.providerId,e[5]=u,e[6]=c,e[7]=g,e[8]=T,e[9]=d,e[10]=i,e[11]=r,e[12]=E,e[13]=a,e[14]=m,e[15]=_}else r=e[11],E=e[12],a=e[13],m=e[14],_=e[15];if(_!==Symbol.for("react.early_return_sentinel"))return _;let x;e[26]!==r||e[27]!==E?(x=s.jsx("div",{className:r,children:E}),e[26]=r,e[27]=E,e[28]=x):x=e[28];let C;return e[29]!==a||e[30]!==m||e[31]!==x?(C=s.jsxs("div",{className:a,children:[m,x]}),e[29]=a,e[30]=m,e[31]=x,e[32]=C):C=e[32],C}function ns(t){return t.id}function is(t,e){return t.name.localeCompare(e.name)}function rs(t){const[e,n]=t;return{id:e,name:Zt(e),logo:n.logo,models:n.models}}function os(t,e,n){return n.findIndex(i=>i.modelId===t.modelId)===e}function ls(t){const e=q.c(35),{allowAllModels:n,modelSet:i,onAllowAllChange:o,onModelSetChange:c,readOnly:u,searchQuery:f}=t,d=u===void 0?!1:u,T=k.useDeferredValue(f),g=At();let r;e[0]!==i||e[1]!==c?(r=(p,b)=>{const l=i[p]??[],h={...i};if(l.includes(b)){const P=l.filter(j=>j!==b);P.length===0?delete h[p]:h[p]=P}else h[p]=[...l,b];c(h)},e[0]=i,e[1]=c,e[2]=r):r=e[2];const E=r;let a;e[3]!==i||e[4]!==o||e[5]!==c?(a=(p,b,l)=>{o(!1),c({...i,[p]:b.filter(h=>h!==l)})},e[3]=i,e[4]=o,e[5]=c,e[6]=a):a=e[6];const m=a,_=!d&&"hover:bg-muted/50 cursor-pointer";let x;e[7]!==_?(x=H("flex items-center justify-between px-4 py-3 rounded-lg border border-border bg-card",_),e[7]=_,e[8]=x):x=e[8];let C;e[9]!==n||e[10]!==o||e[11]!==c||e[12]!==d?(C=()=>{if(d)return;const p=!n;o(p),p&&c({})},e[9]=n,e[10]=o,e[11]=c,e[12]=d,e[13]=C):C=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("span",{className:"text-sm font-medium",children:"All models"}),e[14]=v):v=e[14];let A;e[15]!==n||e[16]!==o||e[17]!==c||e[18]!==d?(A=s.jsx("div",{onClick:cs,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n,disabled:!0,onCheckedChange:as})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n,onCheckedChange:p=>{o(p),p&&c({})}})}),e[15]=n,e[16]=o,e[17]=c,e[18]=d,e[19]=A):A=e[19];let y;e[20]!==x||e[21]!==C||e[22]!==A?(y=s.jsxs("div",{className:x,onClick:C,children:[v,A]}),e[20]=x,e[21]=C,e[22]=A,e[23]=y):y=e[23];let S;e[24]!==g||e[25]!==n||e[26]!==T||e[27]!==m||e[28]!==i||e[29]!==d||e[30]!==E?(S=g.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No LLM connections configured"}):g.map(p=>s.jsx(k.Suspense,{fallback:s.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(_e,{className:"size-4 animate-spin"}),"Loading models..."]}),children:s.jsx(ss,{connection:p,selectedModels:i[p.id]??[],allowAllModels:n,onToggleModel:E,onExitAllowAll:m,allConnectionModelsSelected:(i[p.id]??[]).includes("*"),searchQuery:T,readOnly:d})},p.id)),e[24]=g,e[25]=n,e[26]=T,e[27]=m,e[28]=i,e[29]=d,e[30]=E,e[31]=S):S=e[31];let N;return e[32]!==S||e[33]!==y?(N=s.jsxs("div",{className:"flex flex-col h-full overflow-auto gap-6 pb-6",children:[y,S]}),e[32]=S,e[33]=y,e[34]=N):N=e[34],N}function as(){}function cs(t){return t.stopPropagation()}function ds(t){const e=q.c(52),{open:n,onOpenChange:i,selectedMemberIds:o,onAddMembers:c}=t,[u,f]=k.useState(""),d=k.useDeferredValue(u);let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[0]=T):T=e[0];const[g,r]=k.useState(T),{data:E}=Ze();let a,m,_,x,C,v,A,y,S,N,p;if(e[1]!==E?.data?.members||e[2]!==d||e[3]!==c||e[4]!==i||e[5]!==n||e[6]!==g||e[7]!==u||e[8]!==o){const Y=E?.data?.members??[];let z;e[20]!==d?(z=L=>{const V=d.toLowerCase();return L.user?.name?.toLowerCase().includes(V)||L.user?.email?.toLowerCase().includes(V)},e[20]=d,e[21]=z):z=e[21];const D=Y.filter(z);let w;e[22]!==c||e[23]!==i||e[24]!==g?(w=()=>{c(g),r([]),i(!1)},e[22]=c,e[23]=i,e[24]=g,e[25]=w):w=e[25],_=w,m=Ue,N=n,p=i,a=ke,y="sm:max-w-md p-0 overflow-hidden",e[26]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(Ve,{className:"px-6 pt-6",children:[s.jsx(Be,{children:"Add Members to Role"}),s.jsx(ze,{children:"Select members to add to this role."})]}),e[26]=S):S=e[26],v="flex flex-col h-80",e[27]!==u?(A=s.jsx("div",{className:"border-b border-border px-4 py-3",children:s.jsx(Se,{value:u,onChange:f,placeholder:"Search members...",className:"w-full"})}),e[27]=u,e[28]=A):A=e[28],x="flex-1 overflow-auto",C=D.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:u?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:D.map(L=>{const V=L.role!=="owner",$=o.includes(L.id),Q=g.includes(L.id);return s.jsxs("label",{className:H("flex items-center gap-3 p-2 rounded-lg",!V||$?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(Oe,{checked:Q||$,onCheckedChange:()=>{!V||$||r(X=>X.includes(L.id)?X.filter(W=>W!==L.id):[...X,L.id])},disabled:!V||$}),s.jsx(qe,{url:L.user?.image??void 0,fallback:We(L.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:L.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:L.user?.email})]}),!V&&s.jsx(fe,{variant:"secondary",className:"shrink-0",children:"Owner"}),$&&V&&s.jsx(fe,{variant:"outline",className:"shrink-0",children:"Added"})]},L.id)})}),e[1]=E?.data?.members,e[2]=d,e[3]=c,e[4]=i,e[5]=n,e[6]=g,e[7]=u,e[8]=o,e[9]=a,e[10]=m,e[11]=_,e[12]=x,e[13]=C,e[14]=v,e[15]=A,e[16]=y,e[17]=S,e[18]=N,e[19]=p}else a=e[9],m=e[10],_=e[11],x=e[12],C=e[13],v=e[14],A=e[15],y=e[16],S=e[17],N=e[18],p=e[19];let b;e[29]!==x||e[30]!==C?(b=s.jsx("div",{className:x,children:C}),e[29]=x,e[30]=C,e[31]=b):b=e[31];let l;e[32]!==b||e[33]!==v||e[34]!==A?(l=s.jsxs("div",{className:v,children:[A,b]}),e[32]=b,e[33]=v,e[34]=A,e[35]=l):l=e[35];let h;e[36]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(Ye,{children:"Cancel"}),e[36]=h):h=e[36];const P=g.length===0,j=g.length>0&&`(${g.length})`;let R;e[37]!==_||e[38]!==P||e[39]!==j?(R=s.jsxs($e,{className:"px-6 pb-6",children:[h,s.jsxs(He,{onClick:_,disabled:P,children:["Add ",j]})]}),e[37]=_,e[38]=P,e[39]=j,e[40]=R):R=e[40];let O;e[41]!==a||e[42]!==l||e[43]!==R||e[44]!==y||e[45]!==S?(O=s.jsxs(a,{className:y,children:[S,l,R]}),e[41]=a,e[42]=l,e[43]=R,e[44]=y,e[45]=S,e[46]=O):O=e[46];let M;return e[47]!==m||e[48]!==O||e[49]!==N||e[50]!==p?(M=s.jsx(m,{open:N,onOpenChange:p,children:O}),e[47]=m,e[48]=O,e[49]=N,e[50]=p,e[51]=M):M=e[51],M}function ms(t){const e=q.c(28),{memberIds:n,onMemberIdsChange:i,readOnly:o,searchQuery:c,addMemberDialogOpen:u,onAddMemberDialogOpenChange:f}=t,d=o===void 0?!1:o,T=k.useDeferredValue(c),{data:g}=Ze();let r,E,a;if(e[0]!==g?.data?.members||e[1]!==T||e[2]!==n||e[3]!==i||e[4]!==d||e[5]!==c){const v=g?.data?.members??[];let A;e[9]!==n?(A=p=>n.includes(p.id),e[9]=n,e[10]=A):A=e[10];const y=v.filter(A);let S;e[11]!==T?(S=p=>{const b=T.toLowerCase();return p.user?.name?.toLowerCase().includes(b)||p.user?.email?.toLowerCase().includes(b)},e[11]=T,e[12]=S):S=e[12];const N=y.filter(S);a="flex flex-col h-full",r="flex-1 overflow-auto",E=y.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-base font-medium mb-1",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to grant them the configured permissions."})]})}):N.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',c,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:N.map(p=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(qe,{url:p.user?.image??void 0,fallback:We(p.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:p.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:p.user?.email})]}),d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(ne,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(Pe,{size:16})})})}),s.jsx(Te,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>i(n.filter(b=>b!==p.id)),children:s.jsx(Pe,{size:16})})]},p.id))}),e[0]=g?.data?.members,e[1]=T,e[2]=n,e[3]=i,e[4]=d,e[5]=c,e[6]=r,e[7]=E,e[8]=a}else r=e[6],E=e[7],a=e[8];let m;e[13]!==r||e[14]!==E?(m=s.jsx("div",{className:r,children:E}),e[13]=r,e[14]=E,e[15]=m):m=e[15];let _;e[16]!==n||e[17]!==i?(_=v=>i([...n,...v]),e[16]=n,e[17]=i,e[18]=_):_=e[18];let x;e[19]!==u||e[20]!==n||e[21]!==f||e[22]!==_?(x=s.jsx(ds,{open:u,onOpenChange:f,selectedMemberIds:n,onAddMembers:_}),e[19]=u,e[20]=n,e[21]=f,e[22]=_,e[23]=x):x=e[23];let C;return e[24]!==a||e[25]!==m||e[26]!==x?(C=s.jsxs("div",{className:a,children:[m,x]}),e[24]=a,e[25]=m,e[26]=x,e[27]=C):C=e[27],C}function us(t){const e=q.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let i;return e[1]!==t?(i=s.jsx(k.Suspense,{fallback:n,children:s.jsx(ms,{...t})}),e[1]=t,e[2]=i):i=e[2],i}const gs={owner:[],admin:[],user:[]};function Es(t,e){const n=t==="owner"||t==="admin";return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:gs[t],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:e.filter(i=>i.role===t).map(i=>i.id)}}function Ts(t,e,n){const i=t.permission||{},o=i.self||[],c=o.includes("*"),u=c?[]:o.filter(r=>r!=="*"),f={};for(const[r,E]of Object.entries(i))if(!(r==="self"||r==="models"))if(r==="*")for(const a of n)f[a.id]=E.includes("*")?a.tools?.map(m=>m.name)??[]:E;else{const a=n.find(m=>m.id===r);a&&(f[r]=E.includes("*")?a.tools?.map(m=>m.name)??[]:E)}const d=i.models||[],T=d.length===0||d.includes("*:*"),g={};if(!T)for(const r of d){const E=r.indexOf(":");if(E===-1)continue;const a=r.slice(0,E),m=r.slice(E+1);g[a]||(g[a]=[]),g[a].push(m)}return{role:{id:t.id,slug:t.role,label:t.label},allowAllStaticPermissions:c,staticPermissions:u,toolSet:f,allowAllModels:T,modelSet:g,memberIds:e.filter(r=>r.role===t.role).map(r=>r.id)}}function ps(t,e){const n={};t.allowAllStaticPermissions?n.self=["*"]:t.staticPermissions.length>0&&(n.self=t.staticPermissions);for(const[i,o]of Object.entries(t.toolSet))if(o.length>0){const u=e.find(f=>f.id===i)?.tools?.map(f=>f.name)??[];n[i]=u.length>0&&u.every(f=>o.includes(f))?["*"]:o}if(t.allowAllModels)n.models=["*:*"];else{const i=[];for(const[o,c]of Object.entries(t.modelSet))for(const u of c)i.push(`${o}:${u}`);i.length>0&&(n.models=i)}return n}function fs(t,e,n){return t.kind==="builtin"?Es(t.role,e):t.kind==="custom"?Ts(t.role,e,n):{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:[]}}function _s(t){const e=q.c(5),{readOnly:n,onOpen:i}=t;if(n){let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ne,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(Ce,{size:16}),"Add Member"]})})}),e[0]=u):u=e[0];let f;return e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(ue,{children:s.jsxs(ge,{children:[u,s.jsx(Te,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}),e[1]=f):f=e[1],f}let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ce,{size:16}),e[2]=o):o=e[2];let c;return e[3]!==i?(c=s.jsxs(ne,{variant:"outline",size:"sm",onClick:i,children:[o,"Add Member"]}),e[3]=i,e[4]=c):c=e[4],c}function Is(t){const e=q.c(11),{locator:n}=Re(),i=Ct();let o;e[0]!==n?(o=ce.members(n),e[0]=n,e[1]=o):o=e[1];let c;e[2]!==o?(c={queryKey:o,queryFn:hs},e[2]=o,e[3]=c):c=e[3];const{data:u,isPending:f}=Ge(c);if(f||!i){let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:32,className:"animate-spin text-muted-foreground"})})}),e[4]=r):r=e[4],r}let d;e[5]!==u?.data?.members?(d=u?.data?.members??[],e[5]=u?.data?.members,e[6]=d):d=e[6];const T=d;let g;return e[7]!==i||e[8]!==T||e[9]!==t?(g=s.jsx(Rs,{...t,members:T,connections:i}),e[7]=i,e[8]=T,e[9]=t,e[10]=g):g=e[10],g}function hs(){return re.organization.listMembers()}function Rs({target:t,onBack:e,onSaved:n,members:i,connections:o}){const{locator:c}=Re(),u=De(),f=t.kind==="builtin",d=t.kind==="new",[T,g]=k.useState(f?"org":"mcp"),r=rt({resolver:ot(kt),defaultValues:fs(t,i,o)}),E=r.formState.isValid,a=r.formState.isDirty,m=we({mutationFn:async l=>{const h=ps(l,o),P=l.role.slug||l.role.label.toLowerCase().replace(/\s+/g,"-"),j=l.role.slug&&!l.role.id,R=async O=>{const M=i.filter(D=>D.role===O).map(D=>D.id),Y=l.memberIds.filter(D=>!M.includes(D)),z=M.filter(D=>!l.memberIds.includes(D));for(const D of Y){const w=await re.organization.updateMemberRole({memberId:D,role:[O]});if(w?.error)throw new Error(w.error.message??"Something went wrong")}for(const D of z){const w=await re.organization.updateMemberRole({memberId:D,role:["user"]});if(w?.error)throw new Error(w.error.message??"Something went wrong")}};if(j)return await R(l.role.slug),l;if(l.role.id){const O=await re.organization.updateRole({roleId:l.role.id,data:{permission:h}});if(O?.error)throw new Error(O.error.message??"Something went wrong");return await R(l.role.slug),l}else{const O=await re.organization.createRole({role:P,permission:h});if(O?.error)throw new Error(O.error.message??"Something went wrong");for(const M of l.memberIds){const Y=await re.organization.updateMemberRole({memberId:M,role:[P]});if(Y?.error)throw new Error(Y.error.message)}return{...l,role:{...l.role,id:O.data?.roleData?.id,slug:P}}}},onSuccess:(l,h)=>{u.invalidateQueries({queryKey:ce.members(c)}),u.invalidateQueries({queryKey:ce.organizationRoles(c)});const P=!h.role.id&&!h.role.slug,j=h.role.slug&&!h.role.id;Ae(j?"role_members_updated":P?"role_created":"role_updated",{role_slug:h.role.slug??null}),pe.success(j?"Members updated successfully!":P?"Role created successfully!":"Role updated successfully!"),r.reset(l),n(l.role.id)},onError:l=>{pe.error(l instanceof Error?l.message:"Failed to save role")}}),_=r.handleSubmit(l=>{if(!l.role.label.trim()){pe.error("Role name is required"),r.setFocus("role.label");return}m.mutate(l)}),x=!f||t.kind==="builtin"&&t.role!=="owner",C=t.kind==="builtin"?t.role.charAt(0).toUpperCase()+t.role.slice(1):t.kind==="custom"?t.role.label:"",v=[...f?[]:[{id:"mcp",label:"MCP Permissions"}],{id:"org",label:"Organization Permissions"},{id:"models",label:"Models"},{id:"members",label:"Members"}],[A,y]=k.useState(""),[S,N]=k.useState(!1),p=l=>{g(l),y("")},b={mcp:"Search MCP servers...",org:"Search permissions...",models:"Search models...",members:"Search members..."};return s.jsx(te,{children:s.jsxs(te.Content,{className:"flex flex-col overflow-hidden",children:[s.jsx("div",{className:"shrink-0 mx-auto w-full max-w-[1200px] px-4 md:px-10 pt-8 md:pt-12 pb-4",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsx(te.Title,{actions:x&&s.jsxs(s.Fragment,{children:[s.jsx(ne,{variant:"outline",size:"sm",onClick:e,disabled:m.isPending,children:"Cancel"}),s.jsx(ne,{size:"sm",onClick:_,disabled:m.isPending||!E||!a,children:m.isPending?"Saving...":d?"Create Role":"Save Changes"})]}),children:s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[s.jsx("div",{className:H("size-2.5 rounded-full shrink-0",t.kind==="builtin"?Me(t.role,!0):t.kind==="custom"?Me(t.role.role,!1):Je(r.watch("role.label")))}),f?s.jsx(Ke,{size:16,className:"text-muted-foreground shrink-0"}):s.jsx(yt,{size:16,className:"text-muted-foreground shrink-0"}),d?s.jsx("input",{...r.register("role.label"),placeholder:"Role name",className:"leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-64 placeholder:text-muted-foreground/50",autoFocus:!0}):s.jsx("span",{className:"truncate",children:C})]})}),s.jsx("div",{className:"flex items-center gap-2",children:v.map(l=>s.jsx("button",{type:"button",onClick:()=>p(l.id),className:H("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex items-center",T===l.id?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:l.label},l.id))}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(Se,{value:A,onChange:y,placeholder:b[T]??"Search...",className:"w-full md:w-[375px]"}),T==="members"&&s.jsx(_s,{readOnly:t.kind==="builtin"&&t.role==="owner",onOpen:()=>N(!0)})]})]})}),s.jsx("div",{className:"flex-1 min-h-0 mx-auto w-full max-w-[1200px] px-4 md:px-10 pb-6",children:s.jsxs("div",{className:H("h-full overflow-hidden",T!=="models"&&"border border-border rounded-xl bg-card"),children:[T==="mcp"&&!f&&s.jsx(Gt,{toolSet:r.watch("toolSet"),onToolSetChange:l=>r.setValue("toolSet",l,{shouldDirty:!0}),searchQuery:A}),T==="org"&&s.jsx(Vt,{allowAllStaticPermissions:r.watch("allowAllStaticPermissions"),staticPermissions:r.watch("staticPermissions"),onAllowAllChange:l=>r.setValue("allowAllStaticPermissions",l,{shouldDirty:!0}),onPermissionsChange:l=>r.setValue("staticPermissions",l,{shouldDirty:!0}),readOnly:f,searchQuery:A}),T==="models"&&s.jsx(ls,{allowAllModels:r.watch("allowAllModels"),modelSet:r.watch("modelSet"),onAllowAllChange:l=>r.setValue("allowAllModels",l,{shouldDirty:!0}),onModelSetChange:l=>r.setValue("modelSet",l,{shouldDirty:!0}),readOnly:f,searchQuery:A}),T==="members"&&s.jsx(us,{memberIds:r.watch("memberIds"),onMemberIdsChange:l=>r.setValue("memberIds",l,{shouldDirty:!0}),readOnly:t.kind==="builtin"&&t.role==="owner",searchQuery:A,addMemberDialogOpen:S,onAddMemberDialogOpenChange:N})]})})]})})}function xs(t){return t.kind==="builtin"?`builtin-${t.role}`:t.kind==="custom"?`custom-${t.role.id}`:"new"}const Ns=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],Ne=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function Cs(t){if(!t)return"bg-neutral-400";let e=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);e=(e<<5)-e+o,e=e&e}const n=Math.abs(e)%Ne.length;return Ne[n]??Ne[0]}const As={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function Ss(t,e){return e?As[t]??"bg-neutral-400":Cs(t)}function bs(){const t=q.c(72),[e,n]=k.useState(""),[i,o]=k.useState(null),c=at();let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[0]=u):u=t[0];const{role:f}=ct(u),{locator:d}=Re(),T=De(),{customRoles:g,refetch:r}=dt();let E;t[1]!==c?(E=G=>c({to:".",search:B=>({...B,role:G})}),t[1]=c,t[2]=E):E=t[2];const a=E;let m;e:{if(!f){m=null;break e}if(f==="new"){m={kind:"new"};break e}if(f.startsWith("builtin-")){m={kind:"builtin",role:f.slice(8)};break e}let G;t[3]!==f?(G=le=>le.id===f,t[3]=f,t[4]=G):G=t[4];const B=g.find(G);m=B?{kind:"custom",role:B}:null}const _=m;let x;t[5]!==d?(x=ce.members(d),t[5]=d,t[6]=x):x=t[6];let C;t[7]!==x?(C={queryKey:x,queryFn:Ds},t[7]=x,t[8]=C):C=t[8];const{data:v}=Ge(C);let A;t[9]!==v?.data?.members?(A=v?.data?.members??[],t[9]=v?.data?.members,t[10]=A):A=t[10];const y=A;let S;t[11]!==y?(S=G=>y.filter(B=>B.role===G).length,t[11]=y,t[12]=S):S=t[12];const N=S;let p;if(t[13]!==g||t[14]!==N||t[15]!==e){let G;t[17]!==N?(G=ae=>({kind:"builtin",role:{...ae,memberCount:N(ae.role)}}),t[17]=N,t[18]=G):G=t[18];const B=Ns.map(G);let le;t[19]!==N?(le=ae=>({kind:"custom",role:{...ae,memberCount:N(ae.role)}}),t[19]=N,t[20]=le):le=t[20];const st=g.map(le);if(p=[...B,...st],e){const ae=e.toLowerCase();p=p.filter(nt=>nt.role.label.toLowerCase().includes(ae))}t[13]=g,t[14]=N,t[15]=e,t[16]=p}else p=t[16];const b=we({mutationFn:Gs,onSuccess:(G,B)=>{Ae("role_deleted",{role_id:B}),T.invalidateQueries({queryKey:ce.members(d)}),T.invalidateQueries({queryKey:ce.organizationRoles(d)}),pe.success("Role deleted successfully!"),r(),_?.kind==="custom"&&_.role.id===B&&a(void 0)},onError:Ms});let l,h,P,j;t[21]===Symbol.for("react.memo_cache_sentinel")?(h={id:"role",header:"Role",render:Ps,cellClassName:"flex-1 min-w-0",sortable:!0},P={id:"type",header:"Type",render:js,cellClassName:"w-28 shrink-0"},j={id:"permissions",header:"Permissions",render:vs,cellClassName:"flex-1 min-w-0"},l={id:"members",header:"Members",render:Ls,cellClassName:"w-24 shrink-0"},t[21]=l,t[22]=h,t[23]=P,t[24]=j):(l=t[21],h=t[22],P=t[23],j=t[24]);let R;t[25]===Symbol.for("react.memo_cache_sentinel")?(R=[h,P,j,l,{id:"actions",header:"",render:G=>G.kind==="builtin"?null:s.jsxs(mt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:ys,children:s.jsx(Tt,{size:16})})}),s.jsx(gt,{align:"end",onClick:Os,children:s.jsxs(Et,{variant:"destructive",onClick:()=>{const B=G.role;B.id&&o({id:B.id,label:B.label})},children:[s.jsx(pt,{size:16}),"Delete"]})})]}),cellClassName:"w-12 shrink-0"}],t[25]=R):R=t[25];const O=R;let M;t[26]!==a?(M=G=>{if(G.kind==="builtin")a(`builtin-${G.role.role}`);else{const B=G.role;a(B.id)}},t[26]=a,t[27]=M):M=t[27];const Y=M;if(_){let G;t[28]!==a?(G=()=>a(void 0),t[28]=a,t[29]=G):G=t[29];let B;return t[30]!==r||t[31]!==a?(B=()=>{r(),a(void 0)},t[30]=r,t[31]=a,t[32]=B):B=t[32],s.jsx(Is,{target:_,onBack:G,onSaved:B},xs(_))}let z;t[33]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(te.Title,{children:"Roles"}),t[33]=z):z=t[33];let D;t[34]===Symbol.for("react.memo_cache_sentinel")?(D=G=>{G.key==="Escape"&&(n(""),G.target.blur())},t[34]=D):D=t[34];let w;t[35]!==e?(w=s.jsx(Se,{value:e,onChange:n,placeholder:"Search roles...",className:"w-full md:w-[375px]",onKeyDown:D}),t[35]=e,t[36]=w):w=t[36];let L;t[37]!==a?(L=()=>a("new"),t[37]=a,t[38]=L):L=t[38];let V;t[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Ce,{size:16}),t[39]=V):V=t[39];let $;t[40]!==L?($=s.jsxs(ne,{onClick:L,children:[V,"Create Role"]}),t[40]=L,t[41]=$):$=t[41];let Q;t[42]!==w||t[43]!==$?(Q=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[w,$]}),t[42]=w,t[43]=$,t[44]=Q):Q=t[44];let X;t[45]!==e?(X=e?s.jsx(je,{title:"No roles found",description:`No roles match "${e}"`}):s.jsx(je,{title:"No roles",description:"Create a role to get started."}),t[45]=e,t[46]=X):X=t[46];let W;t[47]!==p||t[48]!==O||t[49]!==Y||t[50]!==X?(W=s.jsx(ft,{columns:O,data:p,isLoading:!1,onRowClick:Y,emptyState:X}),t[47]=p,t[48]=O,t[49]=Y,t[50]=X,t[51]=W):W=t[51];let ie;t[52]!==Q||t[53]!==W?(ie=s.jsx(te.Content,{children:s.jsx(te.Body,{children:s.jsxs("div",{className:"flex flex-col gap-6",children:[z,Q,W]})})}),t[52]=Q,t[53]=W,t[54]=ie):ie=t[54];const I=i!==null;let U;t[55]===Symbol.for("react.memo_cache_sentinel")?(U=G=>!G&&o(null),t[55]=U):U=t[55];let K;t[56]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Be,{children:"Delete Role"}),t[56]=K):K=t[56];const ee=i?.label;let Z;t[57]!==ee?(Z=s.jsxs(Ve,{children:[K,s.jsxs(ze,{children:['Are you sure you want to delete the "',ee,'" role? This action cannot be undone.']})]}),t[57]=ee,t[58]=Z):Z=t[58];let J;t[59]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(Ye,{children:"Cancel"}),t[59]=J):J=t[59];let F;t[60]!==b||t[61]!==i?(F=s.jsxs($e,{children:[J,s.jsx(He,{onClick:()=>{i?.id&&b.mutate(i.id),o(null)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]}),t[60]=b,t[61]=i,t[62]=F):F=t[62];let de;t[63]!==Z||t[64]!==F?(de=s.jsxs(ke,{children:[Z,F]}),t[63]=Z,t[64]=F,t[65]=de):de=t[65];let me;t[66]!==I||t[67]!==de?(me=s.jsx(Ue,{open:I,onOpenChange:U,children:de}),t[66]=I,t[67]=de,t[68]=me):me=t[68];let Ie;return t[69]!==ie||t[70]!==me?(Ie=s.jsxs(te,{children:[ie,me]}),t[69]=ie,t[70]=me,t[71]=Ie):Ie=t[71],Ie}function Os(t){return t.stopPropagation()}function ys(t){return t.stopPropagation()}function Ls(t){return s.jsx("span",{className:"text-sm text-foreground",children:t.role.memberCount})}function vs(t){if(t.kind==="builtin")return t.role.role==="owner"||t.role.role==="admin"?s.jsx("span",{className:"text-sm text-muted-foreground",children:"Full access"}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Basic access"});const e=t.role,n=[];return e.allowsAllStaticPermissions?n.push("Full org access"):e.staticPermissionCount&&e.staticPermissionCount>0&&n.push(`${e.staticPermissionCount} org perm${e.staticPermissionCount!==1?"s":""}`),e.allowsAllConnections?n.push("All connections"):e.connectionCount&&e.connectionCount>0&&n.push(`${e.connectionCount} connection${e.connectionCount!==1?"s":""}`),s.jsx("span",{className:"text-sm text-muted-foreground truncate",children:n.length>0?n.join(", "):"No permissions"})}function js(t){return t.kind==="builtin"?s.jsx(fe,{variant:"secondary",className:"text-xs",children:"Built-in"}):s.jsx(fe,{variant:"outline",className:"text-xs",children:"Custom"})}function Ps(t){return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:H("size-2.5 rounded-full shrink-0",Ss(t.role.role,t.kind==="builtin"))}),s.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t.role.label}),t.kind==="builtin"&&s.jsx(Ke,{size:12,className:"text-muted-foreground shrink-0"})]})}function Ms(t,e){Ae("role_delete_failed",{role_id:e,error:t instanceof Error?t.message:String(t)}),pe.error(t instanceof Error?t.message:"Failed to delete role")}async function Gs(t){const e=await re.organization.deleteRole({roleId:t});if(e?.error)throw new Error(e.error.message);return e?.data}function Ds(){return re.organization.listMembers()}function kn(){const t=q.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load roles"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(lt,{fallback:e,children:s.jsx(k.Suspense,{fallback:s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(bs,{})})}),t[1]=n):n=t[1],n}export{kn as default};
1
+ import{r as k,s as Re,K as ce,aM as it,j as s,c as H,l as _e,B as ne,e as q,n as Ge,o as De,x as rt,w as ot,a as we,z as pe,t as Ae,b as re,v as ye,aK as he,y as se,aI as Le,a_ as ve,E as lt,f as at,d as ct}from"./index-Bu0xhzLF.js";import{u as dt}from"./use-organization-roles-1TjtICKp.js";import{B as fe}from"./badge-C_B8gNbw.js";import{f as Ue,a as ke,b as Ve,c as Be,d as ze,A as Ye,e as $e,g as He}from"./alert-dialog-BFg1HHbW.js";import{c as mt,d as ut,e as gt,D as Et}from"./dropdown-menu--l1OQ6xu.js";import{i as Tt}from"./DotsVertical-BQnGY6Nc.js";import{i as Ke}from"./Lock01-BrFrkt3t.js";import{s as Ce}from"./Plus-kLSd3TZy.js";import{s as pt}from"./Trash01-BLGcALKg.js";import{C as ft}from"./collection-table-wrapper-B2fVBjE4.js";import{P as te}from"./index-CHcfXh0a.js";import{E as je}from"./empty-state-DskpQs8Q.js";import{S as Se}from"./search-input-DRzVzeWW.js";import{P as Fe,D as Qe}from"./ai-providers-logos-D6a8kmGH.js";import{I as be}from"./integration-icon-B5mNngh-.js";import{u as _t}from"./use-infinite-scroll-CoMWGssU.js";import{C as Oe}from"./checkbox-LBmczTXJ.js";import{i as It}from"./RefreshCcw01-B-L6FvMp.js";import{u as ht}from"./useSuspenseInfiniteQuery-CPbx6xDm.js";import{u as Rt,S as xt}from"./constants-Dw_UtizE.js";import{C as Nt}from"./collection-search-DoXoIAYq.js";import{u as Ze}from"./use-members-BPb2gPfy.js";import{u as Ct}from"./use-connection-BCV5VAjQ.js";import{u as At,c as St}from"./use-ai-providers-DqhLue8O.js";import{A as qe}from"./avatar-BfSY5CVM.js";import{S as oe}from"./switch-Bp1Tvx2h.js";import{T as ue,c as ge,a as Ee,b as Te}from"./use-mobile-BACO9YYc.js";import{t as bt}from"./ChevronDown-BE0rQ4ho.js";import{i as Ot}from"./ChevronRight-BVJ2HUMt.js";import{a as yt}from"./SearchMd-BfBE-dHK.js";import{i as Pe}from"./X-BJbamPEP.js";import"./table-BL7WuMkY.js";import"./XClose-BRn4UVuG.js";import"./Container-CtsNRge8.js";import"./agent-icon-Db8xI2bq.js";import"./AlertCircle-Cx8oex2u.js";import"./Tool01-CeBylvMu.js";import"./ArrowNarrowLeft-DtpIYMrr.js";import"./XCircle-DP5EGLqX.js";import"./ArrowUpRight-BBjaHjTK.js";import"./ZapSquare-B3o6QvJe.js";import"./Users03-C3QqJn94.js";import"./CheckCircle-Mywkb82K.js";import"./ChevronUp-B2y_5HwX.js";import"./Star01-MuiWZ8GS.js";import"./Palette-2CChK5yr.js";import"./LinkExternal01-SieYyhiZ.js";import"./Sun-CTLobT4y.js";import"./Play-BfzIvHVC.js";import"./Settings02-EP4I50bB.js";import"./Shield01-D19-LRUf.js";import"./User01-BLHrCCyy.js";import"./Zap-kZUu0No-.js";import"./infiniteQueryObserver-DEk-T30Y.js";import"./use-collections-CLt7BhQ3.js";const Xe=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"BRAND_CONTEXT_LIST",description:"List brand contexts",category:"Organizations"},{name:"BRAND_CONTEXT_GET",description:"View brand context",category:"Organizations"},{name:"BRAND_CONTEXT_CREATE",description:"Create brand context",category:"Organizations"},{name:"BRAND_CONTEXT_UPDATE",description:"Update brand context",category:"Organizations"},{name:"BRAND_CONTEXT_DELETE",description:"Delete brand context",category:"Organizations",dangerous:!0},{name:"BRAND_CONTEXT_EXTRACT",description:"Extract brand context from website",category:"Organizations"},{name:"BRAND_GET",description:"Get brand (binding)",category:"Organizations"},{name:"BRAND_LIST",description:"List brands (binding)",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_GET",description:"Get organization domain claim",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_SET",description:"Set organization domain claim",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_UPDATE",description:"Update organization domain settings",category:"Organizations"},{name:"ORGANIZATION_DOMAIN_CLEAR",description:"Clear organization domain claim",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"MONITORING_LOG_GET",description:"View monitoring log details",category:"Monitoring"},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"},{name:"AUTOMATION_CREATE",description:"Create automation",category:"Automations"},{name:"AUTOMATION_GET",description:"View automation details",category:"Automations"},{name:"AUTOMATION_LIST",description:"List automations",category:"Automations"},{name:"AUTOMATION_UPDATE",description:"Update automation",category:"Automations"},{name:"AUTOMATION_DELETE",description:"Delete automation",category:"Automations",dangerous:!0},{name:"AUTOMATION_TRIGGER_ADD",description:"Add trigger to automation",category:"Automations"},{name:"AUTOMATION_TRIGGER_REMOVE",description:"Remove trigger from automation",category:"Automations"},{name:"AUTOMATION_RUN",description:"Manually trigger an automation run",category:"Automations"},{name:"VIRTUAL_MCP_PLUGIN_CONFIG_GET",description:"View virtual MCP plugin configuration",category:"Virtual MCPs"},{name:"VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE",description:"Update virtual MCP plugin configuration",category:"Virtual MCPs"},{name:"VIRTUAL_MCP_PINNED_VIEWS_UPDATE",description:"Update virtual MCP pinned sidebar views",category:"Virtual MCPs"},{name:"AI_PROVIDERS_LIST",description:"List available AI providers",category:"AI Providers"},{name:"AI_PROVIDERS_LIST_MODELS",description:"List AI provider models",category:"AI Providers"},{name:"AI_PROVIDERS_ACTIVE",description:"List active AI providers",category:"AI Providers"},{name:"AI_PROVIDER_KEY_CREATE",description:"Store AI provider API key",category:"AI Providers"},{name:"AI_PROVIDER_KEY_LIST",description:"List AI provider API keys",category:"AI Providers"},{name:"AI_PROVIDER_KEY_DELETE",description:"Delete AI provider API key",category:"AI Providers",dangerous:!0},{name:"AI_PROVIDER_OAUTH_URL",description:"Get OAuth URL for provider",category:"AI Providers"},{name:"AI_PROVIDER_OAUTH_EXCHANGE",description:"Exchange OAuth code for API key",category:"AI Providers"},{name:"AI_PROVIDER_PROVISION_KEY",description:"Auto-provision API key for a provider",category:"AI Providers"},{name:"AI_PROVIDER_TOPUP_URL",description:"Get checkout URL to top up provider credits",category:"AI Providers"},{name:"AI_PROVIDER_CREDITS",description:"Get current credit balance for a provider",category:"AI Providers"},{name:"AI_PROVIDER_CLI_ACTIVATE",description:"Activate Claude Code via local CLI",category:"AI Providers"},{name:"LIST_OBJECTS",description:"List objects in storage",category:"Object Storage"},{name:"GET_OBJECT_METADATA",description:"Get object metadata",category:"Object Storage"},{name:"GET_PRESIGNED_URL",description:"Generate download URL",category:"Object Storage"},{name:"PUT_PRESIGNED_URL",description:"Generate upload URL",category:"Object Storage"},{name:"DELETE_OBJECT",description:"Delete object",category:"Object Storage",dangerous:!0},{name:"DELETE_OBJECTS",description:"Delete multiple objects",category:"Object Storage",dangerous:!0},{name:"COLLECTION_REGISTRY_APP_LIST",description:"List registry apps",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_GET",description:"Get registry app details",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_VERSIONS",description:"List registry app versions",category:"Registry"},{name:"COLLECTION_REGISTRY_APP_FILTERS",description:"Get registry app filters",category:"Registry"},{name:"REGISTRY_ITEM_LIST",description:"List private registry items",category:"Registry"},{name:"REGISTRY_ITEM_SEARCH",description:"Search registry items",category:"Registry"},{name:"REGISTRY_ITEM_GET",description:"Get registry item details",category:"Registry"},{name:"REGISTRY_ITEM_VERSIONS",description:"List registry item versions",category:"Registry"},{name:"REGISTRY_ITEM_CREATE",description:"Create registry item",category:"Registry"},{name:"REGISTRY_ITEM_BULK_CREATE",description:"Bulk create registry items",category:"Registry"},{name:"REGISTRY_ITEM_UPDATE",description:"Update registry item",category:"Registry"},{name:"REGISTRY_ITEM_DELETE",description:"Delete registry item",category:"Registry",dangerous:!0},{name:"REGISTRY_ITEM_FILTERS",description:"Get registry item filters",category:"Registry"},{name:"REGISTRY_DISCOVER_TOOLS",description:"Discover tools from MCP server",category:"Registry"},{name:"REGISTRY_AI_GENERATE",description:"AI-generate registry content",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_LIST",description:"List publish requests",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_REVIEW",description:"Review publish request",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_COUNT",description:"Count pending publish requests",category:"Registry"},{name:"REGISTRY_PUBLISH_REQUEST_DELETE",description:"Delete publish request",category:"Registry",dangerous:!0},{name:"REGISTRY_PUBLISH_API_KEY_GENERATE",description:"Generate publish API key",category:"Registry"},{name:"REGISTRY_PUBLISH_API_KEY_LIST",description:"List publish API keys",category:"Registry"},{name:"REGISTRY_PUBLISH_API_KEY_REVOKE",description:"Revoke publish API key",category:"Registry",dangerous:!0},{name:"REGISTRY_MONITOR_RUN_START",description:"Start monitor run",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_LIST",description:"List monitor runs",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_GET",description:"Get monitor run details",category:"Registry"},{name:"REGISTRY_MONITOR_RUN_CANCEL",description:"Cancel monitor run",category:"Registry"},{name:"REGISTRY_MONITOR_RESULT_LIST",description:"List monitor results",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_LIST",description:"List monitor connections",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_SYNC",description:"Sync monitor connections",category:"Registry"},{name:"REGISTRY_MONITOR_CONNECTION_UPDATE_AUTH",description:"Update monitor connection auth",category:"Registry"},{name:"REGISTRY_MONITOR_SCHEDULE_SET",description:"Set monitor schedule",category:"Registry"},{name:"REGISTRY_MONITOR_SCHEDULE_CANCEL",description:"Cancel monitor schedule",category:"Registry"},{name:"VM_START",description:"Start a Freestyle VM with dev server preview",category:"VM"},{name:"VM_DELETE",description:"Stop and delete a Freestyle VM",category:"VM"},{name:"GITHUB_LIST_USER_ORGS",description:"List GitHub user's personal account and organizations",category:"GitHub"}],Lt={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",BRAND_CONTEXT_LIST:"List brand contexts",BRAND_CONTEXT_GET:"View brand context",BRAND_CONTEXT_CREATE:"Create brand context",BRAND_CONTEXT_UPDATE:"Update brand context",BRAND_CONTEXT_DELETE:"Delete brand context",BRAND_CONTEXT_EXTRACT:"Extract brand from website",BRAND_GET:"Get brand",BRAND_LIST:"List brands",ORGANIZATION_DOMAIN_GET:"Get domain claim",ORGANIZATION_DOMAIN_SET:"Set domain claim",ORGANIZATION_DOMAIN_UPDATE:"Update domain settings",ORGANIZATION_DOMAIN_CLEAR:"Clear domain claim",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",MONITORING_LOG_GET:"View monitoring log details",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags",VIRTUAL_MCP_PLUGIN_CONFIG_GET:"View plugin config",VIRTUAL_MCP_PLUGIN_CONFIG_UPDATE:"Update plugin config",VIRTUAL_MCP_PINNED_VIEWS_UPDATE:"Update pinned views",AUTOMATION_CREATE:"Create automation",AUTOMATION_GET:"View automation details",AUTOMATION_LIST:"List automations",AUTOMATION_UPDATE:"Update automation",AUTOMATION_DELETE:"Delete automation",AUTOMATION_TRIGGER_ADD:"Add trigger",AUTOMATION_TRIGGER_REMOVE:"Remove trigger",AUTOMATION_RUN:"Run automation",AI_PROVIDERS_LIST:"List AI providers",AI_PROVIDERS_LIST_MODELS:"List AI models",AI_PROVIDERS_ACTIVE:"List active providers",AI_PROVIDER_KEY_CREATE:"Create provider key",AI_PROVIDER_KEY_LIST:"List provider keys",AI_PROVIDER_KEY_DELETE:"Delete provider key",AI_PROVIDER_OAUTH_URL:"Get OAuth URL",AI_PROVIDER_OAUTH_EXCHANGE:"Connect via OAuth",AI_PROVIDER_PROVISION_KEY:"Auto-provision key",AI_PROVIDER_TOPUP_URL:"Get top-up checkout URL",AI_PROVIDER_CREDITS:"Get credit balance",AI_PROVIDER_CLI_ACTIVATE:"Activate Claude Code CLI",LIST_OBJECTS:"List objects",GET_OBJECT_METADATA:"Get object metadata",GET_PRESIGNED_URL:"Generate download URL",PUT_PRESIGNED_URL:"Generate upload URL",DELETE_OBJECT:"Delete object",DELETE_OBJECTS:"Delete multiple objects",COLLECTION_REGISTRY_APP_LIST:"List registry apps",COLLECTION_REGISTRY_APP_GET:"Get registry app",COLLECTION_REGISTRY_APP_VERSIONS:"List registry app versions",COLLECTION_REGISTRY_APP_FILTERS:"Get registry filters",REGISTRY_ITEM_LIST:"List registry items",REGISTRY_ITEM_SEARCH:"Search registry",REGISTRY_ITEM_GET:"Get registry item",REGISTRY_ITEM_VERSIONS:"List item versions",REGISTRY_ITEM_CREATE:"Create registry item",REGISTRY_ITEM_BULK_CREATE:"Bulk create items",REGISTRY_ITEM_UPDATE:"Update registry item",REGISTRY_ITEM_DELETE:"Delete registry item",REGISTRY_ITEM_FILTERS:"Get item filters",REGISTRY_DISCOVER_TOOLS:"Discover tools",REGISTRY_AI_GENERATE:"AI generate content",REGISTRY_PUBLISH_REQUEST_LIST:"List publish requests",REGISTRY_PUBLISH_REQUEST_REVIEW:"Review publish request",REGISTRY_PUBLISH_REQUEST_COUNT:"Count publish requests",REGISTRY_PUBLISH_REQUEST_DELETE:"Delete publish request",REGISTRY_PUBLISH_API_KEY_GENERATE:"Generate API key",REGISTRY_PUBLISH_API_KEY_LIST:"List API keys",REGISTRY_PUBLISH_API_KEY_REVOKE:"Revoke API key",REGISTRY_MONITOR_RUN_START:"Start monitor run",REGISTRY_MONITOR_RUN_LIST:"List monitor runs",REGISTRY_MONITOR_RUN_GET:"Get monitor run",REGISTRY_MONITOR_RUN_CANCEL:"Cancel monitor run",REGISTRY_MONITOR_RESULT_LIST:"List monitor results",REGISTRY_MONITOR_CONNECTION_LIST:"List monitor connections",REGISTRY_MONITOR_CONNECTION_SYNC:"Sync monitor connections",REGISTRY_MONITOR_CONNECTION_UPDATE_AUTH:"Update connection auth",REGISTRY_MONITOR_SCHEDULE_SET:"Set monitor schedule",REGISTRY_MONITOR_SCHEDULE_CANCEL:"Cancel monitor schedule",VM_START:"Start VM preview",VM_DELETE:"Delete VM preview",GITHUB_LIST_USER_ORGS:"List GitHub user orgs"};function vt(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],Tags:[],"AI Providers":[],Automations:[],"Object Storage":[],Registry:[],GitHub:[],VM:[]};for(const e of Xe)t[e.category]?.push(e);return t}function jt(){return Xe.map(t=>({value:t.name,label:Lt[t.name],dangerous:t.dangerous}))}const Pt=k.memo(function(e){const n=q.c(21),{connection:i,isSelected:o,hasToolsEnabled:c,activeToolsCount:u,totalToolsCount:f,onSelect:d,onToggle:T}=e,g=o?"bg-accent/50":"hover:bg-muted/50";let r;n[0]!==g?(r=H("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",g),n[0]=g,n[1]=r):r=n[1];let E;n[2]!==i.icon||n[3]!==i.title?(E=s.jsx(be,{icon:i.icon,name:i.title,size:"xs"}),n[2]=i.icon,n[3]=i.title,n[4]=E):E=n[4];let a;n[5]!==i.title?(a=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:i.title})}),n[5]=i.title,n[6]=a):a=n[6];let m;n[7]!==d||n[8]!==E||n[9]!==a?(m=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:d,children:[E,a]}),n[7]=d,n[8]=E,n[9]=a,n[10]=m):m=n[10];let _;n[11]!==u||n[12]!==i.tools||n[13]!==c||n[14]!==T||n[15]!==f?(_=i.tools&&i.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[u,"/",f]}),s.jsx(Oe,{checked:c,onCheckedChange:T,onClick:Dt})]}),n[11]=u,n[12]=i.tools,n[13]=c,n[14]=T,n[15]=f,n[16]=_):_=n[16];let x;return n[17]!==r||n[18]!==m||n[19]!==_?(x=s.jsxs("div",{className:r,children:[m,_]}),n[17]=r,n[18]=m,n[19]=_,n[20]=x):x=n[20],x}),Mt=k.memo(function(e){const n=q.c(18),{connectionId:i,tool:o,isSelected:c,onToggle:u}=e,f=`tool-${i}-${o.name}`,d=c?"text-foreground":"text-muted-foreground";let T;n[0]!==d?(T=H("text-sm font-medium",d),n[0]=d,n[1]=T):T=n[1];let g;n[2]!==T||n[3]!==o.name?(g=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:T,children:o.name})}),n[2]=T,n[3]=o.name,n[4]=g):g=n[4];let r;n[5]!==o.description?(r=o.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:o.description}),n[5]=o.description,n[6]=r):r=n[6];let E;n[7]!==g||n[8]!==r?(E=s.jsxs("div",{className:"flex-1 min-w-0",children:[g,r]}),n[7]=g,n[8]=r,n[9]=E):E=n[9];const a=`tool-${i}-${o.name}`;let m;n[10]!==c||n[11]!==u||n[12]!==a?(m=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(Oe,{id:a,checked:c,onCheckedChange:u,onClick:wt})}),n[10]=c,n[11]=u,n[12]=a,n[13]=m):m=n[13];let _;return n[14]!==f||n[15]!==E||n[16]!==m?(_=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:f,children:[E,m]}),n[14]=f,n[15]=E,n[16]=m,n[17]=_):_=n[17],_});function Gt({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n,searchQuery:i}){const[o,c]=k.useState(""),u=i!==void 0?i:o,f=k.useDeferredValue(u),[d,T]=k.useState("all"),[g,r]=k.useState(!1),E=k.useRef(new Set(Object.keys(t))),{org:a}=Re(),m=Rt({connectionId:xt,orgId:a.id}),_=100,x=f.trim(),C=x?{operator:"or",conditions:[{field:["title"],operator:"contains",value:x},{field:["description"],operator:"contains",value:x}]}:void 0,v=!!n,A={...C&&{where:C},orderBy:[{field:["updated_at"],direction:"asc"}],limit:_,offset:0,...v&&{include_virtual:!0}},y=JSON.stringify(A),{data:S,fetchNextPage:N,hasNextPage:p,isFetchingNextPage:b}=ht({queryKey:ce.collectionListInfinite(m,a.id,"","CONNECTIONS",y),queryFn:async({pageParam:I=0})=>(await m.callTool({name:"COLLECTION_CONNECTIONS_LIST",arguments:{...C&&{where:C},orderBy:[{field:["updated_at"],direction:"asc"}],limit:_,offset:I,...v&&{include_virtual:!0}}})).structuredContent,initialPageParam:0,getNextPageParam:(I,U)=>{if(I?.hasMore)return U.reduce((K,ee)=>K+(ee?.items?.length??0),0)},staleTime:3e4}),l=S?.pages.flatMap(I=>I?.items??[])??[],h=_t(N,p??!1,b),P=n?l.filter(I=>I.connection_type!=="VIRTUAL"?!0:it(I.connection_url)!==n):l,j=E.current,R=[...j.values()].map(I=>P.find(U=>U.id===I)).filter(I=>I!==void 0),O=P.filter(I=>!j.has(I.id)),M=[...R,...O],Y=I=>{const U=t[I];return U!==void 0&&U.length>0},z=M.filter(I=>{if(d==="all")return!0;const U=Y(I.id);return d==="selected"?U:d==="unselected"?!U:!0}),[D,w]=k.useState(M[0]?.id??null),L=D?M.find(I=>I.id===D)??null:null,V=L?.tools??[],$=(I,U)=>t[I]?.includes(U)??!1,Q=(I,U)=>{const K=t[I]??[],ee=K.includes(U),Z={...t};if(ee){const J=K.filter(F=>F!==U);J.length===0?delete Z[I]:Z[I]=J}else Z[I]=[...K,U];e(Z)},X=I=>{const U=M.find(F=>F.id===I);if(!U?.tools)return;const K=t[I]??[],ee=U.tools.map(F=>F.name),Z=K.length>0&&ee.every(F=>K.includes(F)),J={...t};Z?delete J[I]:(J[I]=ee,w(I)),e(J)},W=I=>{w(I),r(!0)},ie=()=>{r(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:H("w-full md:w-80 border-r border-border flex flex-col",g&&"hidden md:flex"),children:[i===void 0&&s.jsx(Nt,{value:o,onChange:c,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>T("all"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>T("selected"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>T("unselected"),className:H("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",d==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:z.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:u?"No connections found":d==="selected"?"No servers selected":d==="unselected"?"No unselected servers":"No connections available"}):s.jsxs("div",{className:"p-2 space-y-1",children:[z.map(I=>{const U=I.tools?.length??0,K=t[I.id]?.length??0;return s.jsx(Pt,{connection:I,isSelected:D===I.id,hasToolsEnabled:Y(I.id),activeToolsCount:K,totalToolsCount:U,onSelect:()=>W(I.id),onToggle:()=>X(I.id)},I.id)}),s.jsx("div",{ref:h,className:"h-4"}),b&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(_e,{size:18,className:"animate-spin text-muted-foreground"})})]})})]}),s.jsx("div",{className:H("flex-1 flex-col",g?"flex":"hidden md:flex"),children:L?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ne,{variant:"ghost",size:"sm",onClick:ie,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(It,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(be,{icon:L.icon,name:L.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:L.title}),L.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:L.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:V.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:V.map(I=>s.jsx(Mt,{connectionId:L.id,tool:I,isSelected:$(L.id,I.name),onToggle:()=>Q(L.id,I.name)},I.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function Dt(t){return t.stopPropagation()}function wt(t){return t.stopPropagation()}const xe=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"],Ut={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function Je(t){if(!t)return"bg-neutral-400";let e=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);e=(e<<5)-e+o,e=e&e}const n=Math.abs(e)%xe.length;return xe[n]??xe[0]}function Me(t,e){return e?Ut[t]??"bg-neutral-400":Je(t)}const kt=ye({role:ye({id:se().optional(),slug:se().optional(),label:se()}),allowAllStaticPermissions:ve(),staticPermissions:he(se()),toolSet:Le(se(),he(se())),allowAllModels:ve(),modelSet:Le(se(),he(se())),memberIds:he(se())});function We(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Vt(t){const e=q.c(34),{allowAllStaticPermissions:n,staticPermissions:i,onAllowAllChange:o,onPermissionsChange:c,readOnly:u,searchQuery:f}=t,d=u===void 0?!1:u,T=k.useDeferredValue(f);let g,r,E,a;if(e[0]!==n||e[1]!==T||e[2]!==o||e[3]!==c||e[4]!==d||e[5]!==i){const x=vt(),C=jt(),v=C.filter(l=>l.label.toLowerCase().includes(T.toLowerCase())),A=l=>{if(i.includes(l))c(i.filter(h=>h!==l));else{const h=[...i,l];h.length===C.length?(o(!0),c([])):c(h)}};E="flex flex-col h-full";const y=!d&&"hover:bg-muted/50 cursor-pointer";let S;e[10]!==y?(S=H("flex items-center justify-between px-4 py-3",y),e[10]=y,e[11]=S):S=e[11];let N;e[12]!==n||e[13]!==o||e[14]!==c||e[15]!==d?(N=()=>{d||(o(!n),c([]))},e[12]=n,e[13]=o,e[14]=c,e[15]=d,e[16]=N):N=e[16];let p;e[17]===Symbol.for("react.memo_cache_sentinel")?(p=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[17]=p):p=e[17];let b;e[18]!==n||e[19]!==o||e[20]!==c||e[21]!==d?(b=s.jsx("div",{onClick:Kt,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n,disabled:!0,onCheckedChange:Ht})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n,onCheckedChange:l=>{o(l),c([])}})}),e[18]=n,e[19]=o,e[20]=c,e[21]=d,e[22]=b):b=e[22],e[23]!==b||e[24]!==S||e[25]!==N?(a=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:S,onClick:N,children:[p,b]})}),e[23]=b,e[24]=S,e[25]=N,e[26]=a):a=e[26],g="flex-1 overflow-auto",r=Object.entries(x).map(l=>{const[h,P]=l,j=v.filter(R=>P.some(O=>O.name===R.value));return j.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:h}),s.jsx("div",{className:"space-y-1",children:j.map(R=>s.jsxs("div",{className:H("flex items-center justify-between gap-3 px-4 py-3",!d&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{d||(n?(o(!1),c(C.map($t).filter(O=>O!==R.value))):A(R.value))},children:[s.jsx("span",{className:"text-sm flex-1 min-w-0",children:R.label}),s.jsx("div",{onClick:Yt,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n||i.includes(R.value),disabled:!0,onCheckedChange:zt})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n||i.includes(R.value),onCheckedChange:()=>{n?(o(!1),c(C.map(Bt).filter(O=>O!==R.value))):A(R.value)}})})]},R.value))})]},h)}),e[0]=n,e[1]=T,e[2]=o,e[3]=c,e[4]=d,e[5]=i,e[6]=g,e[7]=r,e[8]=E,e[9]=a}else g=e[6],r=e[7],E=e[8],a=e[9];let m;e[27]!==g||e[28]!==r?(m=s.jsx("div",{className:g,children:r}),e[27]=g,e[28]=r,e[29]=m):m=e[29];let _;return e[30]!==E||e[31]!==a||e[32]!==m?(_=s.jsxs("div",{className:E,children:[a,m]}),e[30]=E,e[31]=a,e[32]=m,e[33]=_):_=e[33],_}function Bt(t){return t.value}function zt(){}function Yt(t){return t.stopPropagation()}function $t(t){return t.value}function Ht(){}function Kt(t){return t.stopPropagation()}const et={anthropic:"Anthropic",openrouter:"OpenRouter"},Ft={openai:"OpenAI",anthropic:"Anthropic",google:"Google","meta-llama":"Meta",mistralai:"Mistral","x-ai":"xAI",deepseek:"DeepSeek",qwen:"Qwen",moonshotai:"MoonshotAI",nvidia:"NVIDIA",perplexity:"Perplexity",cohere:"Cohere",amazon:"Amazon",microsoft:"Microsoft","z-ai":"Z.ai","ibm-granite":"IBM Granite",alibaba:"Alibaba",baidu:"Baidu",bytedance:"ByteDance",tencent:"Tencent",minimax:"MiniMax",nousresearch:"Nous Research",allenai:"Allen AI",inception:"Inception"};function Qt(t,e){const n=t.indexOf("/"),i=n>0?t.slice(0,n):e;return i.startsWith("~")?i.slice(1):i}function Zt(t){return Ft[t]??et[t]??t}function qt(t){const e=t.indexOf(": ");return e>0&&e<32?t.slice(e+2):t}const tt=30;function Xt(t){const e=q.c(44),{connectionId:n,subProviderId:i,subProviderName:o,groupLogo:c,models:u,allConnectionModelIds:f,selectedModels:d,allowAllModels:T,allConnectionModelsSelected:g,onToggleModel:r,onExitAllowAll:E,readOnly:a,defaultExpanded:m}=t,[_,x]=k.useState(m),C=m||_,v=x,[A,y]=k.useState(tt);let S;e[0]!==g||e[1]!==T||e[2]!==d?(S=h=>T||g||d.includes("*")||d.includes(h),e[0]=g,e[1]=T,e[2]=d,e[3]=S):S=e[3];const N=S;let p;if(e[4]!==N||e[5]!==u){let h;e[7]!==N?(h=P=>N(P.id),e[7]=N,e[8]=h):h=e[8],p=u.filter(h),e[4]=N,e[5]=u,e[6]=p}else p=e[6];const b=p.length;let l;if(e[9]!==f||e[10]!==T||e[11]!==n||e[12]!==b||e[13]!==C||e[14]!==c||e[15]!==N||e[16]!==u||e[17]!==E||e[18]!==r||e[19]!==a||e[20]!==i||e[21]!==o||e[22]!==A){const h=u.slice(0,A),P=u.length>A;let j;e[24]===Symbol.for("react.memo_cache_sentinel")?(j=()=>v(ts),e[24]=j):j=e[24];const R=c??Fe[i]??Qe;let O;e[25]!==o||e[26]!==R?(O=s.jsx(be,{icon:R,name:o,size:"sm"}),e[25]=o,e[26]=R,e[27]=O):O=e[27];let M;e[28]!==o?(M=s.jsx("span",{className:"text-sm font-medium truncate",children:o}),e[28]=o,e[29]=M):M=e[29];let Y;e[30]!==O||e[31]!==M?(Y=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[O,M]}),e[30]=O,e[31]=M,e[32]=Y):Y=e[32];let z;e[33]!==b||e[34]!==u.length?(z=s.jsxs(fe,{variant:"secondary",className:"text-xs text-muted-foreground",children:[b,"/",u.length," enabled"]}),e[33]=b,e[34]=u.length,e[35]=z):z=e[35];let D;e[36]!==C?(D=C?s.jsx(bt,{size:16,className:"text-muted-foreground shrink-0"}):s.jsx(Ot,{size:16,className:"text-muted-foreground shrink-0"}),e[36]=C,e[37]=D):D=e[37];let w;e[38]!==D||e[39]!==z?(w=s.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[z,D]}),e[38]=D,e[39]=z,e[40]=w):w=e[40];let L;e[41]!==w||e[42]!==Y?(L=s.jsxs("div",{className:"flex items-center justify-between gap-3 px-4 py-3 hover:bg-muted/50 cursor-pointer",onClick:j,children:[Y,w]}),e[41]=w,e[42]=Y,e[43]=L):L=e[43],l=s.jsxs("div",{className:"border border-border rounded-lg overflow-hidden bg-card",children:[L,C&&s.jsxs("div",{className:"border-t border-border bg-muted/20",children:[h.map(V=>{const $=N(V.id),Q=()=>{if(!a){if(T){E(n,f,V.id);return}r(n,V.id)}};return s.jsxs("div",{className:H("flex items-center justify-between gap-3 px-4 py-3 border-b border-border last:border-b-0",!a&&"hover:bg-muted/50 cursor-pointer"),onClick:Q,children:[s.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:s.jsx("span",{className:"text-sm truncate",children:V.title})}),s.jsx("div",{onClick:es,children:a?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:$,disabled:!0,onCheckedChange:Wt})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:$,onCheckedChange:Q})})]},V.id)}),P&&s.jsxs("button",{type:"button",className:"w-full px-4 py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 transition-colors",onClick:()=>y(Jt),children:["Show more (",u.length-A," remaining)"]})]})]}),e[9]=f,e[10]=T,e[11]=n,e[12]=b,e[13]=C,e[14]=c,e[15]=N,e[16]=u,e[17]=E,e[18]=r,e[19]=a,e[20]=i,e[21]=o,e[22]=A,e[23]=l}else l=e[23];return l}function Jt(t){return t+tt}function Wt(){}function es(t){return t.stopPropagation()}function ts(t){return!t}function ss(t){const e=q.c(33),{connection:n,selectedModels:i,allowAllModels:o,onToggleModel:c,onExitAllowAll:u,allConnectionModelsSelected:f,searchQuery:d,readOnly:T}=t,g=St(n.id);let r,E,a,m,_;if(e[0]!==f||e[1]!==o||e[2]!==n.id||e[3]!==n.label||e[4]!==n.providerId||e[5]!==u||e[6]!==c||e[7]!==g||e[8]!==T||e[9]!==d||e[10]!==i){_=Symbol.for("react.early_return_sentinel");e:{let v;e[16]!==n.label?(v=R=>({...R,id:R.modelId,provider:n.label}),e[16]=n.label,e[17]=v):v=e[17];const A=g.filter(os).map(v),y=d.trim().toLowerCase(),S=y?A.filter(R=>R.title.toLowerCase().includes(y)||R.id.toLowerCase().includes(y)||R.provider?.toLowerCase().includes(y)):A;if(S.length===0){_=null;break e}const N=new Map;for(const R of S){const O=Qt(R.id,n.providerId),M=N.get(O)??{models:[],logo:null};M.models.push({id:R.id,title:qt(R.title),logo:R.logo}),!M.logo&&R.logo&&(M.logo=R.logo),N.set(O,M)}const p=Array.from(N.entries()).map(rs).sort(is),b=p.length===1||y.length>0;a="flex flex-col gap-3";const l=Fe[n.providerId]??Qe;let h;e[18]!==n.providerId||e[19]!==l?(h=s.jsx("img",{src:l,alt:n.providerId,className:"w-4 h-4 rounded-sm dark:bg-white dark:rounded-sm dark:p-px"}),e[18]=n.providerId,e[19]=l,e[20]=h):h=e[20];const P=et[n.providerId]??n.providerId;let j;e[21]!==P?(j=s.jsx("h4",{className:"text-sm font-medium",children:P}),e[21]=P,e[22]=j):j=e[22],e[23]!==j||e[24]!==h?(m=s.jsxs("div",{className:"flex items-center gap-2",children:[h,j]}),e[23]=j,e[24]=h,e[25]=m):m=e[25],r="flex flex-col gap-3",E=p.map(R=>s.jsx(Xt,{connectionId:n.id,subProviderId:R.id,subProviderName:R.name,groupLogo:R.logo,models:R.models,allConnectionModelIds:A.map(ns),selectedModels:i,allowAllModels:o,allConnectionModelsSelected:f,onToggleModel:c,onExitAllowAll:u,readOnly:T,defaultExpanded:b},R.id))}e[0]=f,e[1]=o,e[2]=n.id,e[3]=n.label,e[4]=n.providerId,e[5]=u,e[6]=c,e[7]=g,e[8]=T,e[9]=d,e[10]=i,e[11]=r,e[12]=E,e[13]=a,e[14]=m,e[15]=_}else r=e[11],E=e[12],a=e[13],m=e[14],_=e[15];if(_!==Symbol.for("react.early_return_sentinel"))return _;let x;e[26]!==r||e[27]!==E?(x=s.jsx("div",{className:r,children:E}),e[26]=r,e[27]=E,e[28]=x):x=e[28];let C;return e[29]!==a||e[30]!==m||e[31]!==x?(C=s.jsxs("div",{className:a,children:[m,x]}),e[29]=a,e[30]=m,e[31]=x,e[32]=C):C=e[32],C}function ns(t){return t.id}function is(t,e){return t.name.localeCompare(e.name)}function rs(t){const[e,n]=t;return{id:e,name:Zt(e),logo:n.logo,models:n.models}}function os(t,e,n){return n.findIndex(i=>i.modelId===t.modelId)===e}function ls(t){const e=q.c(35),{allowAllModels:n,modelSet:i,onAllowAllChange:o,onModelSetChange:c,readOnly:u,searchQuery:f}=t,d=u===void 0?!1:u,T=k.useDeferredValue(f),g=At();let r;e[0]!==i||e[1]!==c?(r=(p,b)=>{const l=i[p]??[],h={...i};if(l.includes(b)){const P=l.filter(j=>j!==b);P.length===0?delete h[p]:h[p]=P}else h[p]=[...l,b];c(h)},e[0]=i,e[1]=c,e[2]=r):r=e[2];const E=r;let a;e[3]!==i||e[4]!==o||e[5]!==c?(a=(p,b,l)=>{o(!1),c({...i,[p]:b.filter(h=>h!==l)})},e[3]=i,e[4]=o,e[5]=c,e[6]=a):a=e[6];const m=a,_=!d&&"hover:bg-muted/50 cursor-pointer";let x;e[7]!==_?(x=H("flex items-center justify-between px-4 py-3 rounded-lg border border-border bg-card",_),e[7]=_,e[8]=x):x=e[8];let C;e[9]!==n||e[10]!==o||e[11]!==c||e[12]!==d?(C=()=>{if(d)return;const p=!n;o(p),p&&c({})},e[9]=n,e[10]=o,e[11]=c,e[12]=d,e[13]=C):C=e[13];let v;e[14]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("span",{className:"text-sm font-medium",children:"All models"}),e[14]=v):v=e[14];let A;e[15]!==n||e[16]!==o||e[17]!==c||e[18]!==d?(A=s.jsx("div",{onClick:cs,children:d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(oe,{checked:n,disabled:!0,onCheckedChange:as})})}),s.jsx(Te,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(oe,{checked:n,onCheckedChange:p=>{o(p),p&&c({})}})}),e[15]=n,e[16]=o,e[17]=c,e[18]=d,e[19]=A):A=e[19];let y;e[20]!==x||e[21]!==C||e[22]!==A?(y=s.jsxs("div",{className:x,onClick:C,children:[v,A]}),e[20]=x,e[21]=C,e[22]=A,e[23]=y):y=e[23];let S;e[24]!==g||e[25]!==n||e[26]!==T||e[27]!==m||e[28]!==i||e[29]!==d||e[30]!==E?(S=g.length===0?s.jsx("div",{className:"flex items-center justify-center py-8 text-sm text-muted-foreground",children:"No LLM connections configured"}):g.map(p=>s.jsx(k.Suspense,{fallback:s.jsxs("div",{className:"px-4 py-3 flex items-center gap-2 text-sm text-muted-foreground",children:[s.jsx(_e,{className:"size-4 animate-spin"}),"Loading models..."]}),children:s.jsx(ss,{connection:p,selectedModels:i[p.id]??[],allowAllModels:n,onToggleModel:E,onExitAllowAll:m,allConnectionModelsSelected:(i[p.id]??[]).includes("*"),searchQuery:T,readOnly:d})},p.id)),e[24]=g,e[25]=n,e[26]=T,e[27]=m,e[28]=i,e[29]=d,e[30]=E,e[31]=S):S=e[31];let N;return e[32]!==S||e[33]!==y?(N=s.jsxs("div",{className:"flex flex-col h-full overflow-auto gap-6 pb-6",children:[y,S]}),e[32]=S,e[33]=y,e[34]=N):N=e[34],N}function as(){}function cs(t){return t.stopPropagation()}function ds(t){const e=q.c(52),{open:n,onOpenChange:i,selectedMemberIds:o,onAddMembers:c}=t,[u,f]=k.useState(""),d=k.useDeferredValue(u);let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=[],e[0]=T):T=e[0];const[g,r]=k.useState(T),{data:E}=Ze();let a,m,_,x,C,v,A,y,S,N,p;if(e[1]!==E?.data?.members||e[2]!==d||e[3]!==c||e[4]!==i||e[5]!==n||e[6]!==g||e[7]!==u||e[8]!==o){const Y=E?.data?.members??[];let z;e[20]!==d?(z=L=>{const V=d.toLowerCase();return L.user?.name?.toLowerCase().includes(V)||L.user?.email?.toLowerCase().includes(V)},e[20]=d,e[21]=z):z=e[21];const D=Y.filter(z);let w;e[22]!==c||e[23]!==i||e[24]!==g?(w=()=>{c(g),r([]),i(!1)},e[22]=c,e[23]=i,e[24]=g,e[25]=w):w=e[25],_=w,m=Ue,N=n,p=i,a=ke,y="sm:max-w-md p-0 overflow-hidden",e[26]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsxs(Ve,{className:"px-6 pt-6",children:[s.jsx(Be,{children:"Add Members to Role"}),s.jsx(ze,{children:"Select members to add to this role."})]}),e[26]=S):S=e[26],v="flex flex-col h-80",e[27]!==u?(A=s.jsx("div",{className:"border-b border-border px-4 py-3",children:s.jsx(Se,{value:u,onChange:f,placeholder:"Search members...",className:"w-full"})}),e[27]=u,e[28]=A):A=e[28],x="flex-1 overflow-auto",C=D.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:u?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:D.map(L=>{const V=L.role!=="owner",$=o.includes(L.id),Q=g.includes(L.id);return s.jsxs("label",{className:H("flex items-center gap-3 p-2 rounded-lg",!V||$?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(Oe,{checked:Q||$,onCheckedChange:()=>{!V||$||r(X=>X.includes(L.id)?X.filter(W=>W!==L.id):[...X,L.id])},disabled:!V||$}),s.jsx(qe,{url:L.user?.image??void 0,fallback:We(L.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:L.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:L.user?.email})]}),!V&&s.jsx(fe,{variant:"secondary",className:"shrink-0",children:"Owner"}),$&&V&&s.jsx(fe,{variant:"outline",className:"shrink-0",children:"Added"})]},L.id)})}),e[1]=E?.data?.members,e[2]=d,e[3]=c,e[4]=i,e[5]=n,e[6]=g,e[7]=u,e[8]=o,e[9]=a,e[10]=m,e[11]=_,e[12]=x,e[13]=C,e[14]=v,e[15]=A,e[16]=y,e[17]=S,e[18]=N,e[19]=p}else a=e[9],m=e[10],_=e[11],x=e[12],C=e[13],v=e[14],A=e[15],y=e[16],S=e[17],N=e[18],p=e[19];let b;e[29]!==x||e[30]!==C?(b=s.jsx("div",{className:x,children:C}),e[29]=x,e[30]=C,e[31]=b):b=e[31];let l;e[32]!==b||e[33]!==v||e[34]!==A?(l=s.jsxs("div",{className:v,children:[A,b]}),e[32]=b,e[33]=v,e[34]=A,e[35]=l):l=e[35];let h;e[36]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(Ye,{children:"Cancel"}),e[36]=h):h=e[36];const P=g.length===0,j=g.length>0&&`(${g.length})`;let R;e[37]!==_||e[38]!==P||e[39]!==j?(R=s.jsxs($e,{className:"px-6 pb-6",children:[h,s.jsxs(He,{onClick:_,disabled:P,children:["Add ",j]})]}),e[37]=_,e[38]=P,e[39]=j,e[40]=R):R=e[40];let O;e[41]!==a||e[42]!==l||e[43]!==R||e[44]!==y||e[45]!==S?(O=s.jsxs(a,{className:y,children:[S,l,R]}),e[41]=a,e[42]=l,e[43]=R,e[44]=y,e[45]=S,e[46]=O):O=e[46];let M;return e[47]!==m||e[48]!==O||e[49]!==N||e[50]!==p?(M=s.jsx(m,{open:N,onOpenChange:p,children:O}),e[47]=m,e[48]=O,e[49]=N,e[50]=p,e[51]=M):M=e[51],M}function ms(t){const e=q.c(28),{memberIds:n,onMemberIdsChange:i,readOnly:o,searchQuery:c,addMemberDialogOpen:u,onAddMemberDialogOpenChange:f}=t,d=o===void 0?!1:o,T=k.useDeferredValue(c),{data:g}=Ze();let r,E,a;if(e[0]!==g?.data?.members||e[1]!==T||e[2]!==n||e[3]!==i||e[4]!==d||e[5]!==c){const v=g?.data?.members??[];let A;e[9]!==n?(A=p=>n.includes(p.id),e[9]=n,e[10]=A):A=e[10];const y=v.filter(A);let S;e[11]!==T?(S=p=>{const b=T.toLowerCase();return p.user?.name?.toLowerCase().includes(b)||p.user?.email?.toLowerCase().includes(b)},e[11]=T,e[12]=S):S=e[12];const N=y.filter(S);a="flex flex-col h-full",r="flex-1 overflow-auto",E=y.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-base font-medium mb-1",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to grant them the configured permissions."})]})}):N.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',c,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:N.map(p=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(qe,{url:p.user?.image??void 0,fallback:We(p.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:p.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:p.user?.email})]}),d?s.jsx(ue,{children:s.jsxs(ge,{children:[s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsx(ne,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(Pe,{size:16})})})}),s.jsx(Te,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ne,{variant:"ghost",size:"sm",onClick:()=>i(n.filter(b=>b!==p.id)),children:s.jsx(Pe,{size:16})})]},p.id))}),e[0]=g?.data?.members,e[1]=T,e[2]=n,e[3]=i,e[4]=d,e[5]=c,e[6]=r,e[7]=E,e[8]=a}else r=e[6],E=e[7],a=e[8];let m;e[13]!==r||e[14]!==E?(m=s.jsx("div",{className:r,children:E}),e[13]=r,e[14]=E,e[15]=m):m=e[15];let _;e[16]!==n||e[17]!==i?(_=v=>i([...n,...v]),e[16]=n,e[17]=i,e[18]=_):_=e[18];let x;e[19]!==u||e[20]!==n||e[21]!==f||e[22]!==_?(x=s.jsx(ds,{open:u,onOpenChange:f,selectedMemberIds:n,onAddMembers:_}),e[19]=u,e[20]=n,e[21]=f,e[22]=_,e[23]=x):x=e[23];let C;return e[24]!==a||e[25]!==m||e[26]!==x?(C=s.jsxs("div",{className:a,children:[m,x]}),e[24]=a,e[25]=m,e[26]=x,e[27]=C):C=e[27],C}function us(t){const e=q.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let i;return e[1]!==t?(i=s.jsx(k.Suspense,{fallback:n,children:s.jsx(ms,{...t})}),e[1]=t,e[2]=i):i=e[2],i}const gs={owner:[],admin:[],user:[]};function Es(t,e){const n=t==="owner"||t==="admin";return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:gs[t],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:e.filter(i=>i.role===t).map(i=>i.id)}}function Ts(t,e,n){const i=t.permission||{},o=i.self||[],c=o.includes("*"),u=c?[]:o.filter(r=>r!=="*"),f={};for(const[r,E]of Object.entries(i))if(!(r==="self"||r==="models"))if(r==="*")for(const a of n)f[a.id]=E.includes("*")?a.tools?.map(m=>m.name)??[]:E;else{const a=n.find(m=>m.id===r);a&&(f[r]=E.includes("*")?a.tools?.map(m=>m.name)??[]:E)}const d=i.models||[],T=d.length===0||d.includes("*:*"),g={};if(!T)for(const r of d){const E=r.indexOf(":");if(E===-1)continue;const a=r.slice(0,E),m=r.slice(E+1);g[a]||(g[a]=[]),g[a].push(m)}return{role:{id:t.id,slug:t.role,label:t.label},allowAllStaticPermissions:c,staticPermissions:u,toolSet:f,allowAllModels:T,modelSet:g,memberIds:e.filter(r=>r.role===t.role).map(r=>r.id)}}function ps(t,e){const n={};t.allowAllStaticPermissions?n.self=["*"]:t.staticPermissions.length>0&&(n.self=t.staticPermissions);for(const[i,o]of Object.entries(t.toolSet))if(o.length>0){const u=e.find(f=>f.id===i)?.tools?.map(f=>f.name)??[];n[i]=u.length>0&&u.every(f=>o.includes(f))?["*"]:o}if(t.allowAllModels)n.models=["*:*"];else{const i=[];for(const[o,c]of Object.entries(t.modelSet))for(const u of c)i.push(`${o}:${u}`);i.length>0&&(n.models=i)}return n}function fs(t,e,n){return t.kind==="builtin"?Es(t.role,e):t.kind==="custom"?Ts(t.role,e,n):{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},allowAllModels:!0,modelSet:{},memberIds:[]}}function _s(t){const e=q.c(5),{readOnly:n,onOpen:i}=t;if(n){let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Ee,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ne,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(Ce,{size:16}),"Add Member"]})})}),e[0]=u):u=e[0];let f;return e[1]===Symbol.for("react.memo_cache_sentinel")?(f=s.jsx(ue,{children:s.jsxs(ge,{children:[u,s.jsx(Te,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}),e[1]=f):f=e[1],f}let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=s.jsx(Ce,{size:16}),e[2]=o):o=e[2];let c;return e[3]!==i?(c=s.jsxs(ne,{variant:"outline",size:"sm",onClick:i,children:[o,"Add Member"]}),e[3]=i,e[4]=c):c=e[4],c}function Is(t){const e=q.c(11),{locator:n}=Re(),i=Ct();let o;e[0]!==n?(o=ce.members(n),e[0]=n,e[1]=o):o=e[1];let c;e[2]!==o?(c={queryKey:o,queryFn:hs},e[2]=o,e[3]=c):c=e[3];const{data:u,isPending:f}=Ge(c);if(f||!i){let r;return e[4]===Symbol.for("react.memo_cache_sentinel")?(r=s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:32,className:"animate-spin text-muted-foreground"})})}),e[4]=r):r=e[4],r}let d;e[5]!==u?.data?.members?(d=u?.data?.members??[],e[5]=u?.data?.members,e[6]=d):d=e[6];const T=d;let g;return e[7]!==i||e[8]!==T||e[9]!==t?(g=s.jsx(Rs,{...t,members:T,connections:i}),e[7]=i,e[8]=T,e[9]=t,e[10]=g):g=e[10],g}function hs(){return re.organization.listMembers()}function Rs({target:t,onBack:e,onSaved:n,members:i,connections:o}){const{locator:c}=Re(),u=De(),f=t.kind==="builtin",d=t.kind==="new",[T,g]=k.useState(f?"org":"mcp"),r=rt({resolver:ot(kt),defaultValues:fs(t,i,o)}),E=r.formState.isValid,a=r.formState.isDirty,m=we({mutationFn:async l=>{const h=ps(l,o),P=l.role.slug||l.role.label.toLowerCase().replace(/\s+/g,"-"),j=l.role.slug&&!l.role.id,R=async O=>{const M=i.filter(D=>D.role===O).map(D=>D.id),Y=l.memberIds.filter(D=>!M.includes(D)),z=M.filter(D=>!l.memberIds.includes(D));for(const D of Y){const w=await re.organization.updateMemberRole({memberId:D,role:[O]});if(w?.error)throw new Error(w.error.message??"Something went wrong")}for(const D of z){const w=await re.organization.updateMemberRole({memberId:D,role:["user"]});if(w?.error)throw new Error(w.error.message??"Something went wrong")}};if(j)return await R(l.role.slug),l;if(l.role.id){const O=await re.organization.updateRole({roleId:l.role.id,data:{permission:h}});if(O?.error)throw new Error(O.error.message??"Something went wrong");return await R(l.role.slug),l}else{const O=await re.organization.createRole({role:P,permission:h});if(O?.error)throw new Error(O.error.message??"Something went wrong");for(const M of l.memberIds){const Y=await re.organization.updateMemberRole({memberId:M,role:[P]});if(Y?.error)throw new Error(Y.error.message)}return{...l,role:{...l.role,id:O.data?.roleData?.id,slug:P}}}},onSuccess:(l,h)=>{u.invalidateQueries({queryKey:ce.members(c)}),u.invalidateQueries({queryKey:ce.organizationRoles(c)});const P=!h.role.id&&!h.role.slug,j=h.role.slug&&!h.role.id;Ae(j?"role_members_updated":P?"role_created":"role_updated",{role_slug:h.role.slug??null}),pe.success(j?"Members updated successfully!":P?"Role created successfully!":"Role updated successfully!"),r.reset(l),n(l.role.id)},onError:l=>{pe.error(l instanceof Error?l.message:"Failed to save role")}}),_=r.handleSubmit(l=>{if(!l.role.label.trim()){pe.error("Role name is required"),r.setFocus("role.label");return}m.mutate(l)}),x=!f||t.kind==="builtin"&&t.role!=="owner",C=t.kind==="builtin"?t.role.charAt(0).toUpperCase()+t.role.slice(1):t.kind==="custom"?t.role.label:"",v=[...f?[]:[{id:"mcp",label:"MCP Permissions"}],{id:"org",label:"Organization Permissions"},{id:"models",label:"Models"},{id:"members",label:"Members"}],[A,y]=k.useState(""),[S,N]=k.useState(!1),p=l=>{g(l),y("")},b={mcp:"Search MCP servers...",org:"Search permissions...",models:"Search models...",members:"Search members..."};return s.jsx(te,{children:s.jsxs(te.Content,{className:"flex flex-col overflow-hidden",children:[s.jsx("div",{className:"shrink-0 mx-auto w-full max-w-[1200px] px-4 md:px-10 pt-8 md:pt-12 pb-4",children:s.jsxs("div",{className:"flex flex-col gap-5",children:[s.jsx(te.Title,{actions:x&&s.jsxs(s.Fragment,{children:[s.jsx(ne,{variant:"outline",size:"sm",onClick:e,disabled:m.isPending,children:"Cancel"}),s.jsx(ne,{size:"sm",onClick:_,disabled:m.isPending||!E||!a,children:m.isPending?"Saving...":d?"Create Role":"Save Changes"})]}),children:s.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[s.jsx("div",{className:H("size-2.5 rounded-full shrink-0",t.kind==="builtin"?Me(t.role,!0):t.kind==="custom"?Me(t.role.role,!1):Je(r.watch("role.label")))}),f?s.jsx(Ke,{size:16,className:"text-muted-foreground shrink-0"}):s.jsx(yt,{size:16,className:"text-muted-foreground shrink-0"}),d?s.jsx("input",{...r.register("role.label"),placeholder:"Role name",className:"leading-tight text-foreground bg-transparent border-none outline-none px-1 -mx-1 rounded hover:bg-input/25 focus:bg-input/25 transition-colors w-64 placeholder:text-muted-foreground/50",autoFocus:!0}):s.jsx("span",{className:"truncate",children:C})]})}),s.jsx("div",{className:"flex items-center gap-2",children:v.map(l=>s.jsx("button",{type:"button",onClick:()=>p(l.id),className:H("h-7 px-2 text-sm rounded-lg border border-input transition-colors inline-flex items-center",T===l.id?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:l.label},l.id))}),s.jsxs("div",{className:"flex items-center justify-between gap-3",children:[s.jsx(Se,{value:A,onChange:y,placeholder:b[T]??"Search...",className:"w-full md:w-[375px]"}),T==="members"&&s.jsx(_s,{readOnly:t.kind==="builtin"&&t.role==="owner",onOpen:()=>N(!0)})]})]})}),s.jsx("div",{className:"flex-1 min-h-0 mx-auto w-full max-w-[1200px] px-4 md:px-10 pb-6",children:s.jsxs("div",{className:H("h-full overflow-hidden",T!=="models"&&"border border-border rounded-xl bg-card"),children:[T==="mcp"&&!f&&s.jsx(Gt,{toolSet:r.watch("toolSet"),onToolSetChange:l=>r.setValue("toolSet",l,{shouldDirty:!0}),searchQuery:A}),T==="org"&&s.jsx(Vt,{allowAllStaticPermissions:r.watch("allowAllStaticPermissions"),staticPermissions:r.watch("staticPermissions"),onAllowAllChange:l=>r.setValue("allowAllStaticPermissions",l,{shouldDirty:!0}),onPermissionsChange:l=>r.setValue("staticPermissions",l,{shouldDirty:!0}),readOnly:f,searchQuery:A}),T==="models"&&s.jsx(ls,{allowAllModels:r.watch("allowAllModels"),modelSet:r.watch("modelSet"),onAllowAllChange:l=>r.setValue("allowAllModels",l,{shouldDirty:!0}),onModelSetChange:l=>r.setValue("modelSet",l,{shouldDirty:!0}),readOnly:f,searchQuery:A}),T==="members"&&s.jsx(us,{memberIds:r.watch("memberIds"),onMemberIdsChange:l=>r.setValue("memberIds",l,{shouldDirty:!0}),readOnly:t.kind==="builtin"&&t.role==="owner",searchQuery:A,addMemberDialogOpen:S,onAddMemberDialogOpenChange:N})]})})]})})}function xs(t){return t.kind==="builtin"?`builtin-${t.role}`:t.kind==="custom"?`custom-${t.role.id}`:"new"}const Ns=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],Ne=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function Cs(t){if(!t)return"bg-neutral-400";let e=0;for(let i=0;i<t.length;i++){const o=t.charCodeAt(i);e=(e<<5)-e+o,e=e&e}const n=Math.abs(e)%Ne.length;return Ne[n]??Ne[0]}const As={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function Ss(t,e){return e?As[t]??"bg-neutral-400":Cs(t)}function bs(){const t=q.c(72),[e,n]=k.useState(""),[i,o]=k.useState(null),c=at();let u;t[0]===Symbol.for("react.memo_cache_sentinel")?(u={strict:!1},t[0]=u):u=t[0];const{role:f}=ct(u),{locator:d}=Re(),T=De(),{customRoles:g,refetch:r}=dt();let E;t[1]!==c?(E=G=>c({to:".",search:B=>({...B,role:G})}),t[1]=c,t[2]=E):E=t[2];const a=E;let m;e:{if(!f){m=null;break e}if(f==="new"){m={kind:"new"};break e}if(f.startsWith("builtin-")){m={kind:"builtin",role:f.slice(8)};break e}let G;t[3]!==f?(G=le=>le.id===f,t[3]=f,t[4]=G):G=t[4];const B=g.find(G);m=B?{kind:"custom",role:B}:null}const _=m;let x;t[5]!==d?(x=ce.members(d),t[5]=d,t[6]=x):x=t[6];let C;t[7]!==x?(C={queryKey:x,queryFn:Ds},t[7]=x,t[8]=C):C=t[8];const{data:v}=Ge(C);let A;t[9]!==v?.data?.members?(A=v?.data?.members??[],t[9]=v?.data?.members,t[10]=A):A=t[10];const y=A;let S;t[11]!==y?(S=G=>y.filter(B=>B.role===G).length,t[11]=y,t[12]=S):S=t[12];const N=S;let p;if(t[13]!==g||t[14]!==N||t[15]!==e){let G;t[17]!==N?(G=ae=>({kind:"builtin",role:{...ae,memberCount:N(ae.role)}}),t[17]=N,t[18]=G):G=t[18];const B=Ns.map(G);let le;t[19]!==N?(le=ae=>({kind:"custom",role:{...ae,memberCount:N(ae.role)}}),t[19]=N,t[20]=le):le=t[20];const st=g.map(le);if(p=[...B,...st],e){const ae=e.toLowerCase();p=p.filter(nt=>nt.role.label.toLowerCase().includes(ae))}t[13]=g,t[14]=N,t[15]=e,t[16]=p}else p=t[16];const b=we({mutationFn:Gs,onSuccess:(G,B)=>{Ae("role_deleted",{role_id:B}),T.invalidateQueries({queryKey:ce.members(d)}),T.invalidateQueries({queryKey:ce.organizationRoles(d)}),pe.success("Role deleted successfully!"),r(),_?.kind==="custom"&&_.role.id===B&&a(void 0)},onError:Ms});let l,h,P,j;t[21]===Symbol.for("react.memo_cache_sentinel")?(h={id:"role",header:"Role",render:Ps,cellClassName:"flex-1 min-w-0",sortable:!0},P={id:"type",header:"Type",render:js,cellClassName:"w-28 shrink-0"},j={id:"permissions",header:"Permissions",render:vs,cellClassName:"flex-1 min-w-0"},l={id:"members",header:"Members",render:Ls,cellClassName:"w-24 shrink-0"},t[21]=l,t[22]=h,t[23]=P,t[24]=j):(l=t[21],h=t[22],P=t[23],j=t[24]);let R;t[25]===Symbol.for("react.memo_cache_sentinel")?(R=[h,P,j,l,{id:"actions",header:"",render:G=>G.kind==="builtin"?null:s.jsxs(mt,{children:[s.jsx(ut,{asChild:!0,children:s.jsx(ne,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:ys,children:s.jsx(Tt,{size:16})})}),s.jsx(gt,{align:"end",onClick:Os,children:s.jsxs(Et,{variant:"destructive",onClick:()=>{const B=G.role;B.id&&o({id:B.id,label:B.label})},children:[s.jsx(pt,{size:16}),"Delete"]})})]}),cellClassName:"w-12 shrink-0"}],t[25]=R):R=t[25];const O=R;let M;t[26]!==a?(M=G=>{if(G.kind==="builtin")a(`builtin-${G.role.role}`);else{const B=G.role;a(B.id)}},t[26]=a,t[27]=M):M=t[27];const Y=M;if(_){let G;t[28]!==a?(G=()=>a(void 0),t[28]=a,t[29]=G):G=t[29];let B;return t[30]!==r||t[31]!==a?(B=()=>{r(),a(void 0)},t[30]=r,t[31]=a,t[32]=B):B=t[32],s.jsx(Is,{target:_,onBack:G,onSaved:B},xs(_))}let z;t[33]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx(te.Title,{children:"Roles"}),t[33]=z):z=t[33];let D;t[34]===Symbol.for("react.memo_cache_sentinel")?(D=G=>{G.key==="Escape"&&(n(""),G.target.blur())},t[34]=D):D=t[34];let w;t[35]!==e?(w=s.jsx(Se,{value:e,onChange:n,placeholder:"Search roles...",className:"w-full md:w-[375px]",onKeyDown:D}),t[35]=e,t[36]=w):w=t[36];let L;t[37]!==a?(L=()=>a("new"),t[37]=a,t[38]=L):L=t[38];let V;t[39]===Symbol.for("react.memo_cache_sentinel")?(V=s.jsx(Ce,{size:16}),t[39]=V):V=t[39];let $;t[40]!==L?($=s.jsxs(ne,{onClick:L,children:[V,"Create Role"]}),t[40]=L,t[41]=$):$=t[41];let Q;t[42]!==w||t[43]!==$?(Q=s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[w,$]}),t[42]=w,t[43]=$,t[44]=Q):Q=t[44];let X;t[45]!==e?(X=e?s.jsx(je,{title:"No roles found",description:`No roles match "${e}"`}):s.jsx(je,{title:"No roles",description:"Create a role to get started."}),t[45]=e,t[46]=X):X=t[46];let W;t[47]!==p||t[48]!==O||t[49]!==Y||t[50]!==X?(W=s.jsx(ft,{columns:O,data:p,isLoading:!1,onRowClick:Y,emptyState:X}),t[47]=p,t[48]=O,t[49]=Y,t[50]=X,t[51]=W):W=t[51];let ie;t[52]!==Q||t[53]!==W?(ie=s.jsx(te.Content,{children:s.jsx(te.Body,{children:s.jsxs("div",{className:"flex flex-col gap-6",children:[z,Q,W]})})}),t[52]=Q,t[53]=W,t[54]=ie):ie=t[54];const I=i!==null;let U;t[55]===Symbol.for("react.memo_cache_sentinel")?(U=G=>!G&&o(null),t[55]=U):U=t[55];let K;t[56]===Symbol.for("react.memo_cache_sentinel")?(K=s.jsx(Be,{children:"Delete Role"}),t[56]=K):K=t[56];const ee=i?.label;let Z;t[57]!==ee?(Z=s.jsxs(Ve,{children:[K,s.jsxs(ze,{children:['Are you sure you want to delete the "',ee,'" role? This action cannot be undone.']})]}),t[57]=ee,t[58]=Z):Z=t[58];let J;t[59]===Symbol.for("react.memo_cache_sentinel")?(J=s.jsx(Ye,{children:"Cancel"}),t[59]=J):J=t[59];let F;t[60]!==b||t[61]!==i?(F=s.jsxs($e,{children:[J,s.jsx(He,{onClick:()=>{i?.id&&b.mutate(i.id),o(null)},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]}),t[60]=b,t[61]=i,t[62]=F):F=t[62];let de;t[63]!==Z||t[64]!==F?(de=s.jsxs(ke,{children:[Z,F]}),t[63]=Z,t[64]=F,t[65]=de):de=t[65];let me;t[66]!==I||t[67]!==de?(me=s.jsx(Ue,{open:I,onOpenChange:U,children:de}),t[66]=I,t[67]=de,t[68]=me):me=t[68];let Ie;return t[69]!==ie||t[70]!==me?(Ie=s.jsxs(te,{children:[ie,me]}),t[69]=ie,t[70]=me,t[71]=Ie):Ie=t[71],Ie}function Os(t){return t.stopPropagation()}function ys(t){return t.stopPropagation()}function Ls(t){return s.jsx("span",{className:"text-sm text-foreground",children:t.role.memberCount})}function vs(t){if(t.kind==="builtin")return t.role.role==="owner"||t.role.role==="admin"?s.jsx("span",{className:"text-sm text-muted-foreground",children:"Full access"}):s.jsx("span",{className:"text-sm text-muted-foreground",children:"Basic access"});const e=t.role,n=[];return e.allowsAllStaticPermissions?n.push("Full org access"):e.staticPermissionCount&&e.staticPermissionCount>0&&n.push(`${e.staticPermissionCount} org perm${e.staticPermissionCount!==1?"s":""}`),e.allowsAllConnections?n.push("All connections"):e.connectionCount&&e.connectionCount>0&&n.push(`${e.connectionCount} connection${e.connectionCount!==1?"s":""}`),s.jsx("span",{className:"text-sm text-muted-foreground truncate",children:n.length>0?n.join(", "):"No permissions"})}function js(t){return t.kind==="builtin"?s.jsx(fe,{variant:"secondary",className:"text-xs",children:"Built-in"}):s.jsx(fe,{variant:"outline",className:"text-xs",children:"Custom"})}function Ps(t){return s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:H("size-2.5 rounded-full shrink-0",Ss(t.role.role,t.kind==="builtin"))}),s.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:t.role.label}),t.kind==="builtin"&&s.jsx(Ke,{size:12,className:"text-muted-foreground shrink-0"})]})}function Ms(t,e){Ae("role_delete_failed",{role_id:e,error:t instanceof Error?t.message:String(t)}),pe.error(t instanceof Error?t.message:"Failed to delete role")}async function Gs(t){const e=await re.organization.deleteRole({roleId:t});if(e?.error)throw new Error(e.error.message);return e?.data}function Ds(){return re.organization.listMembers()}function kn(){const t=q.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load roles"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(lt,{fallback:e,children:s.jsx(k.Suspense,{fallback:s.jsx(te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(_e,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(bs,{})})}),t[1]=n):n=t[1],n}export{kn as default};
@@ -1,4 +1,4 @@
1
- import{e as di,c as fi,aX as ju,j as M,r as w,cE as _l,bg as Hu,J as Wu,bc as St,cF as Uu,ah as it,ai as Qe,aW as On,aT as qu,aU as Ku,b6 as Mt,cG as Vl,ao as jl,aS as Ju,ae as ut}from"./index-Dq226A4w.js";import{e as Gu}from"./select-C3X6ssTw.js";const Yu=ju("animate-spin",{variants:{variant:{default:"fill-primary text-gray-200",destructive:"fill-destructive text-gray-200",secondary:"fill-secondary text-gray-200",special:"fill-special text-backround"},size:{default:"h-7 w-7",sm:"h-6 w-6",lg:"h-8 w-8",icon:"h-6 w-6",xs:"h-4 w-4"}},defaultVariants:{variant:"default",size:"default"}});function db(n){const e=di.c(10),{variant:t,size:r}=n;let s;e[0]!==r||e[1]!==t?(s=fi(Yu({variant:t,size:r})),e[0]=r,e[1]=t,e[2]=s):s=e[2];let i,o;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=M.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),o=M.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"}),e[3]=i,e[4]=o):(i=e[3],o=e[4]);let l;e[5]!==s?(l=M.jsxs("svg",{"aria-hidden":"true",className:s,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i,o]}),e[5]=s,e[6]=l):l=e[6];let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=M.jsx("span",{className:"sr-only",children:"Loading..."}),e[7]=a):a=e[7];let c;return e[8]!==l?(c=M.jsxs("div",{role:"status",children:[l,a]}),e[8]=l,e[9]=c):c=e[9],c}function Q(n){this.content=n}Q.prototype={constructor:Q,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Q(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(n,e){return new Q([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Q(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Q(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Q.from(n),n.size?new Q(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Q.from(n),n.size?new Q(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Q.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Q.from=function(n){if(n instanceof Q)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Q(e)};function Hl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Hl(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Wl(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Wl(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new k(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new k(r,s)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new k(s,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Hl(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Wl(this,e,t,r)}findIndex(e){if(e==0)return Ln(0,e);if(e==this.size)return Ln(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?Ln(t+1,i):Ln(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const ls={index:0,offset:0};function Ln(n,e){return ls.index=n,ls.offset=e,ls}function Qn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Qn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Qn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let z=class Ps{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Qn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Ps.none;if(e instanceof Ps)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};z.none=[];class Zn extends Error{}class v{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ql(this.content,e+this.openStart,t);return r&&new v(r,this.openStart,this.openEnd)}removeBetween(e,t){return new v(Ul(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return v.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new v(k.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new v(e,r,s)}}v.empty=new v(k.empty,0,0);function Ul(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Ul(i.content,e-s-1,t-s-1)))}function ql(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=ql(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function Xu(n,e,t){if(t.openStart>n.depth)throw new Zn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Zn("Inconsistent open depths");return Kl(n,e,t,0)}function Kl(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Kl(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return yt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Qu(t,n);return yt(i,Gl(n,o,l,e,r))}else return yt(i,er(n,e,r))}function Jl(n,e){if(!e.type.compatibleContent(n.type))throw new Zn("Cannot join "+e.type.name+" onto "+n.type.name)}function Ls(n,e,t){let r=n.node(t);return Jl(r,e.node(t)),r}function gt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function an(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(gt(n.nodeAfter,r),i++));for(let l=i;l<o;l++)gt(s.child(l),r);e&&e.depth==t&&e.textOffset&&gt(e.nodeBefore,r)}function yt(n,e){return n.type.checkContent(e),n.copy(e)}function Gl(n,e,t,r,s){let i=n.depth>s&&Ls(n,e,s+1),o=r.depth>s&&Ls(t,r,s+1),l=[];return an(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Jl(i,o),gt(yt(i,Gl(n,e,t,r,s+1)),l)):(i&&gt(yt(i,er(n,e,s+1)),l),an(e,t,s,l),o&&gt(yt(o,er(t,r,s+1)),l)),an(r,null,s,l),new k(l)}function er(n,e,t){let r=[];if(an(null,n,t,r),n.depth>t){let s=Ls(n,e,t+1);gt(yt(s,er(n,e,t+1)),r)}return an(e,null,t,r),new k(r)}function Qu(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(k.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class kn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new tr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new kn(t,r,i)}static resolveCached(e,t){let r=oo.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else oo.set(e,r=new Zu);let s=r.elts[r.i]=kn.resolve(e,t);return r.i=(r.i+1)%ed,s}}class Zu{constructor(){this.elts=[],this.i=0}}const ed=12,oo=new WeakMap;class tr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const td=Object.create(null);class Ee{constructor(e,t,r,s=z.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Qn(this.attrs,t||e.defaultAttrs||td)&&z.sameSet(this.marks,r||z.none)}copy(e=null){return e==this.content?this:new Ee(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ee(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return v.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new v(c,s.depth-o,i.depth-o)}replace(e,t,r){return Xu(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return kn.resolveCached(this,e)}resolveNoCache(e){return kn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=k.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=z.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Ee.prototype.text=void 0;class nr extends Ee{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Yl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new nr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Yl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new nd(e,t);if(r.next==null)return wt.empty;let s=Xl(r);r.next&&r.err("Unexpected trailing text");let i=cd(ad(s));return ud(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
1
+ import{e as di,c as fi,aX as ju,j as M,r as w,cE as _l,bg as Hu,J as Wu,bc as St,cF as Uu,ah as it,ai as Qe,aW as On,aT as qu,aU as Ku,b6 as Mt,cG as Vl,ao as jl,aS as Ju,ae as ut}from"./index-Bu0xhzLF.js";import{e as Gu}from"./select-DerdayxE.js";const Yu=ju("animate-spin",{variants:{variant:{default:"fill-primary text-gray-200",destructive:"fill-destructive text-gray-200",secondary:"fill-secondary text-gray-200",special:"fill-special text-backround"},size:{default:"h-7 w-7",sm:"h-6 w-6",lg:"h-8 w-8",icon:"h-6 w-6",xs:"h-4 w-4"}},defaultVariants:{variant:"default",size:"default"}});function db(n){const e=di.c(10),{variant:t,size:r}=n;let s;e[0]!==r||e[1]!==t?(s=fi(Yu({variant:t,size:r})),e[0]=r,e[1]=t,e[2]=s):s=e[2];let i,o;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=M.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),o=M.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"}),e[3]=i,e[4]=o):(i=e[3],o=e[4]);let l;e[5]!==s?(l=M.jsxs("svg",{"aria-hidden":"true",className:s,viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[i,o]}),e[5]=s,e[6]=l):l=e[6];let a;e[7]===Symbol.for("react.memo_cache_sentinel")?(a=M.jsx("span",{className:"sr-only",children:"Loading..."}),e[7]=a):a=e[7];let c;return e[8]!==l?(c=M.jsxs("div",{role:"status",children:[l,a]}),e[8]=l,e[9]=c):c=e[9],c}function Q(n){this.content=n}Q.prototype={constructor:Q,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,s=r.find(n),i=r.content.slice();return s==-1?i.push(t||n,e):(i[s+1]=e,t&&(i[s]=t)),new Q(i)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Q(t)},addToStart:function(n,e){return new Q([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Q(t)},addBefore:function(n,e,t){var r=this.remove(e),s=r.content.slice(),i=r.find(n);return s.splice(i==-1?s.length:i,0,e,t),new Q(s)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Q.from(n),n.size?new Q(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Q.from(n),n.size?new Q(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Q.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};Q.from=function(n){if(n instanceof Q)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Q(e)};function Hl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let s=n.child(r),i=e.child(r);if(s==i){t+=s.nodeSize;continue}if(!s.sameMarkup(i))return t;if(s.isText&&s.text!=i.text){for(let o=0;s.text[o]==i.text[o];o++)t++;return t}if(s.content.size||i.content.size){let o=Hl(s.content,i.content,t+1);if(o!=null)return o}t+=s.nodeSize}}function Wl(n,e,t,r){for(let s=n.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:t,b:r};let o=n.child(--s),l=e.child(--i),a=o.nodeSize;if(o==l){t-=a,r-=a;continue}if(!o.sameMarkup(l))return{a:t,b:r};if(o.isText&&o.text!=l.text){let c=0,u=Math.min(o.text.length,l.text.length);for(;c<u&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(o.content.size||l.content.size){let c=Wl(o.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,s=0,i){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&r(a,s+l,i||null,o)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,s){let i="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(o?o=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(s[s.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new k(s,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],s=0;if(t>e)for(let i=0,o=0;o<t;i++){let l=this.content[i],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),r.push(l),s+=l.nodeSize),o=a}return new k(r,s)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let s=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return s[e]=t,new k(s,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let s=this.content[t];e(s,r,t),r+=s.nodeSize}}findDiffStart(e,t=0){return Hl(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Wl(this,e,t,r)}findIndex(e){if(e==0)return Ln(0,e);if(e==this.size)return Ln(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let s=this.child(t),i=r+s.nodeSize;if(i>=e)return i==e?Ln(t+1,i):Ln(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(t||(t=e.slice(0,s)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,r)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const ls={index:0,offset:0};function Ln(n,e){return ls.index=n,ls.offset=e,ls}function Qn(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!Qn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Qn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let z=class Ps{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,s)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Qn(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let s=r.create(t.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Ps.none;if(e instanceof Ps)return[e];let t=e.slice();return t.sort((r,s)=>r.type.rank-s.type.rank),t}};z.none=[];class Zn extends Error{}class v{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ql(this.content,e+this.openStart,t);return r&&new v(r,this.openStart,this.openEnd)}removeBetween(e,t){return new v(Ul(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return v.empty;let r=t.openStart||0,s=t.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new v(k.fromJSON(e,t.content),r,s)}static maxOpen(e,t=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)s++;return new v(e,r,s)}}v.empty=new v(k.empty,0,0);function Ul(n,e,t){let{index:r,offset:s}=n.findIndex(e),i=n.maybeChild(r),{index:o,offset:l}=n.findIndex(t);if(s==e||i.isText){if(l!=t&&!n.child(o).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=o)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Ul(i.content,e-s-1,t-s-1)))}function ql(n,e,t,r){let{index:s,offset:i}=n.findIndex(e),o=n.maybeChild(s);if(i==e||o.isText)return r&&!r.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=ql(o.content,e-i-1,t,o);return l&&n.replaceChild(s,o.copy(l))}function Xu(n,e,t){if(t.openStart>n.depth)throw new Zn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Zn("Inconsistent open depths");return Kl(n,e,t,0)}function Kl(n,e,t,r){let s=n.index(r),i=n.node(r);if(s==e.index(r)&&r<n.depth-t.openStart){let o=Kl(n,e,t,r+1);return i.copy(i.content.replaceChild(s,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let o=n.parent,l=o.content;return yt(o,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=Qu(t,n);return yt(i,Gl(n,o,l,e,r))}else return yt(i,er(n,e,r))}function Jl(n,e){if(!e.type.compatibleContent(n.type))throw new Zn("Cannot join "+e.type.name+" onto "+n.type.name)}function Ls(n,e,t){let r=n.node(t);return Jl(r,e.node(t)),r}function gt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function an(n,e,t,r){let s=(e||n).node(t),i=0,o=e?e.index(t):s.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(gt(n.nodeAfter,r),i++));for(let l=i;l<o;l++)gt(s.child(l),r);e&&e.depth==t&&e.textOffset&&gt(e.nodeBefore,r)}function yt(n,e){return n.type.checkContent(e),n.copy(e)}function Gl(n,e,t,r,s){let i=n.depth>s&&Ls(n,e,s+1),o=r.depth>s&&Ls(t,r,s+1),l=[];return an(null,n,s,l),i&&o&&e.index(s)==t.index(s)?(Jl(i,o),gt(yt(i,Gl(n,e,t,r,s+1)),l)):(i&&gt(yt(i,er(n,e,s+1)),l),an(e,t,s,l),o&&gt(yt(o,er(t,r,s+1)),l)),an(r,null,s,l),new k(l)}function er(n,e,t){let r=[];if(an(null,n,t,r),n.depth>t){let s=Ls(n,e,t+1);gt(yt(s,er(n,e,t+1)),r)}return an(e,null,t,r),new k(r)}function Qu(n,e){let t=e.depth-n.openStart,s=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)s=e.node(i).copy(k.from(s));return{start:s.resolveNoCache(n.openStart+t),end:s.resolveNoCache(s.content.size-n.openEnd-t)}}class kn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(t);return r?e.child(t).cut(r):s}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],s=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return z.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),s=e.maybeChild(t);if(!r){let l=r;r=s,s=l}let i=r.marks;for(var o=0;o<i.length;o++)i[o].type.spec.inclusive===!1&&(!s||!i[o].isInSet(s.marks))&&(i=i[o--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,s=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new tr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],s=0,i=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(i),c=i-a;if(r.push(o,l,s+a),!c||(o=o.child(l),o.isText))break;i=c-1,s+=a+1}return new kn(t,r,i)}static resolveCached(e,t){let r=oo.get(e);if(r)for(let i=0;i<r.elts.length;i++){let o=r.elts[i];if(o.pos==t)return o}else oo.set(e,r=new Zu);let s=r.elts[r.i]=kn.resolve(e,t);return r.i=(r.i+1)%ed,s}}class Zu{constructor(){this.elts=[],this.i=0}}const ed=12,oo=new WeakMap;class tr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const td=Object.create(null);class Ee{constructor(e,t,r,s=z.none){this.type=e,this.attrs=t,this.marks=s,this.content=r||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,s=0){this.content.nodesBetween(e,t,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,s){return this.content.textBetween(e,t,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&Qn(this.attrs,t||e.defaultAttrs||td)&&z.sameSet(this.marks,r||z.none)}copy(e=null){return e==this.content?this:new Ee(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ee(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return v.empty;let s=this.resolve(e),i=this.resolve(t),o=r?0:s.sharedDepth(t),l=s.start(o),c=s.node(o).content.cut(s.pos-l,i.pos-l);return new v(c,s.depth-o,i.depth-o)}replace(e,t,r){return Xu(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:s}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(s==e||t.isText)return t;e-=s+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let s=this.content.child(t-1);return{node:s,index:t-1,offset:r-s.nodeSize}}resolve(e){return kn.resolveCached(this,e)}resolveNoCache(e){return kn.resolve(this,e)}rangeHasMark(e,t,r){let s=!1;return t>e&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Yl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=k.empty,s=0,i=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,s,i),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=s;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),o=i&&i.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=z.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!z.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let s=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Ee.prototype.text=void 0;class nr extends Ee{constructor(e,t,r,s){if(super(e,t,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Yl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new nr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new nr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Yl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class wt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new nd(e,t);if(r.next==null)return wt.empty;let s=Xl(r);r.next&&r.err("Unexpected trailing text");let i=cd(ad(s));return ud(i,r),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let s=this;for(let i=t;s&&i<r;i++)s=s.matchType(e.child(i).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let s=[this];function i(o,l){let a=o.matchFragment(e,r);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:u,next:d}=o.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),i=s.match;if(i.matchType(e)){let o=[];for(let l=s;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<i.next.length;o++){let{type:l,next:a}=i.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&t(r.next[s].next)}return t(this),e.map((r,s)=>{let i=s+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)i+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return i}).join(`
2
2
  `)}}wt.empty=new wt(!0);class nd{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Xl(n){let e=[];do e.push(rd(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function rd(n){let e=[];do e.push(sd(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function sd(n){let e=ld(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=id(n,e);else break;return e}function lo(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function id(n,e){let t=lo(n),r=t;return n.eat(",")&&(n.next!="}"?r=lo(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function od(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let s=[];for(let i in t){let o=t[i];o.isInGroup(e)&&s.push(o)}return s.length==0&&n.err("No node type or group '"+e+"' found"),s}function ld(n){if(n.eat("(")){let e=Xl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=od(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function ad(n){let e=[[]];return s(i(n,0),t()),e;function t(){return e.push([])-1}function r(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function s(o,l){o.forEach(a=>a.to=l)}function i(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=i(o.exprs[a],l);if(a==o.exprs.length-1)return c;s(c,l=t())}else if(o.type=="star"){let a=t();return r(l,a),s(i(o.expr,a),a),[r(a)]}else if(o.type=="plus"){let a=t();return s(i(o.expr,l),a),s(i(o.expr,a),a),[r(a)]}else{if(o.type=="opt")return[r(l)].concat(i(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let u=t();s(i(o.expr,a),u),a=u}if(o.max==-1)s(i(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let u=t();r(a,u),s(i(o.expr,a),u),a=u}return[r(a)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Ql(n,e){return e-n}function ao(n,e){let t=[];return r(e),t.sort(Ql);function r(s){let i=n[s];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(s);for(let o=0;o<i.length;o++){let{term:l,to:a}=i[o];!l&&t.indexOf(a)==-1&&r(a)}}}function cd(n){let e=Object.create(null);return t(ao(n,0));function t(r){let s=[];r.forEach(o=>{n[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);ao(n,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new wt(r.indexOf(n.length-1)>-1);for(let o=0;o<s.length;o++){let l=s[o][1].sort(Ql);i.next.push({type:s[o][0],next:e[l.join(",")]||t(l)})}return i}}function ud(n,e){for(let t=0,r=[n];t<r.length;t++){let s=r[t],i=!s.validEnd,o=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];o.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Zl(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function ea(n,e){let t=Object.create(null);for(let r in n){let s=e&&e[r];if(s===void 0){let i=n[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=s}return t}function ta(n,e,t,r){for(let s in e)if(!(s in n))throw new RangeError(`Unsupported attribute ${s} for ${t} of type ${s}`);for(let s in n){let i=n[s];i.validate&&i.validate(e[s])}}function na(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new fd(n,r,e[r]);return t}let co=class ra{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=na(e,r.attrs),this.defaultAttrs=Zl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==wt.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ea(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ee(this,this.computeAttrs(e),k.from(t),z.setFrom(r))}createChecked(e=null,t,r){return t=k.from(t),this.checkContent(t),new Ee(this,this.computeAttrs(e),t,z.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=k.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let s=this.contentMatch.matchFragment(t),i=s&&s.fillBefore(k.empty,!0);return i?new Ee(this,e,t.append(i),z.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ta(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:z.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,o)=>r[i]=new ra(i,t,o));let s=t.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function dd(n,e,t){let r=t.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}class fd{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?dd(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class jr{constructor(e,t,r,s){this.name=e,this.rank=t,this.schema=r,this.spec=s,this.attrs=na(e,s.attrs),this.excluded=null;let i=Zl(this.attrs);this.instance=i?new z(this,i):null}create(e=null){return!e&&this.instance?this.instance:new z(this,ea(this.attrs,e))}static compile(e,t){let r=Object.create(null),s=0;return e.forEach((i,o)=>r[i]=new jr(i,s++,t,o)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){ta(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class sa{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let s in e)t[s]=e[s];t.nodes=Q.from(e.nodes),t.marks=Q.from(e.marks||{}),this.nodes=co.compile(this.spec.nodes,this),this.marks=jr.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let i=this.nodes[s],o=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[o]||(r[o]=wt.parse(o,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?uo(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],o=i.spec.excludes;i.excluded=o==null?[i]:o==""?[]:uo(this,o.split(" "))}this.nodeFromJSON=s=>Ee.fromJSON(this,s),this.markFromJSON=s=>z.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof co){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,s)}text(e,t){let r=this.nodes.text;return new nr(r,r.defaultAttrs,e,z.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function uo(n,e){let t=[];for(let r=0;r<e.length;r++){let s=e[r],i=n.marks[s],o=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function hd(n){return n.tag!=null}function pd(n){return n.style!=null}class Ze{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(s=>{if(hd(s))this.tags.push(s);else if(pd(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new ho(this,t,!1);return r.addAll(e,z.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new ho(this,t,!0);return r.addAll(e,z.none,t.from,t.to),v.maxOpen(r.finish())}matchTag(e,t,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(yd(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let o=i.getAttrs(e);if(o===!1)continue;i.attrs=o||void 0}return i}}}matchStyle(e,t,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let o=this.styles[i],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function r(s){let i=s.priority==null?50:s.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<i)break}t.splice(o,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(o=>{r(o=po(o)),o.mark||o.ignore||o.clearMark||(o.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(o=>{r(o=po(o)),o.node||o.ignore||o.mark||(o.node=s)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ze(e,Ze.schemaRules(e)))}}const ia={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},md={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},oa={ol:!0,ul:!0},xn=1,Bs=2,cn=4;function fo(n,e,t){return e!=null?(e?xn:0)|(e==="full"?Bs:0):n&&n.whitespace=="pre"?xn|Bs:t&~cn}class Bn{constructor(e,t,r,s,i,o){this.type=e,this.attrs=t,this.marks=r,this.solid=s,this.options=o,this.content=[],this.activeMarks=z.none,this.match=i||(o&cn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xn)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ia.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ho{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=t.topNode,i,o=fo(null,t.preserveWhitespace,0)|(r?cn:0);s?i=new Bn(s.type,s.attrs,z.none,!0,t.topMatch||s.type.contentMatch,o):r?i=new Bn(null,null,z.none,!0,null,o):i=new Bn(e.schema.topNodeType,null,z.none,!0,null,o),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,s=this.top,i=s.options&Bs?"full":this.localPreserveWS||(s.options&xn)>0,{schema:o}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=s.content[s.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;oa.hasOwnProperty(o)&&this.parser.normalizeLists&&gd(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:md.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(ia.hasOwnProperty(o))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let i=this.parser.matchedStyles[s],o=r.getPropertyValue(i);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(i,o,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,s){let i,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(o,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,s){let i=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o,t);this.findAtPoint(e,i)}findPlace(e,t,r){let s,i;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(i);for(let o=0;o<s.length;o++)t=this.enterInner(s[o],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let s=this.findPlace(e,t,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let o=z.none;for(let l of s.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):mo(l.type,e.type))&&(o=l.addToSet(o));return i.content.push(e.mark(o)),!0}return!1}enter(e,t,r,s){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,s)),i}enterInner(e,t,r,s=!1,i){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=fo(e,i,o.options);o.options&cn&&o.content.length==0&&(l|=cn);let a=z.none;return r=r.filter(c=>(o.type?o.type.allowsMarkType(c.type):mo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Bn(e,t,a,s,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=xn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&t.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(s?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(o(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function gd(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&oa.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function yd(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function po(n){let e={};for(let t in n)e[t]=n[t];return e}function mo(n,e){let t=e.schema.nodes;for(let r in t){let s=t[r];if(!s.allowsMarkType(n))continue;let i=[],o=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&o(u))return!0}};if(o(s.contentMatch))return!0}}class At{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=as(t).createDocumentFragment());let s=r,i=[];return e.forEach(o=>{if(i.length||o.marks.length){let l=0,a=0;for(;l<i.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)s=i.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],u=this.serializeMark(c,o.isInline,t);u&&(i.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(o,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:s}=Kn(as(t),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,s)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let s=e.marks.length-1;s>=0;s--){let i=this.serializeMark(e.marks[s],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let s=this.marks[e.type.name];return s&&Kn(as(r),s(e,t),null,e.attrs)}static renderSpec(e,t,r=null,s){return Kn(e,t,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new At(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=go(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return go(e.marks)}}function go(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function as(n){return n.document||window.document}const yo=new WeakMap;function bd(n){let e=yo.get(n);return e===void 0&&yo.set(n,e=kd(n)),e}function kd(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)t(r[s]);else for(let s in r)t(r[s])}return t(n),e}function Kn(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=bd(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=s.indexOf(" ");o>0&&(t=s.slice(0,o),s=s.slice(o+1));let l,a=t?n.createElementNS(t,s):n.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=Kn(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const la=65535,aa=Math.pow(2,16);function xd(n,e){return n+e*aa}function bo(n){return n&la}function Sd(n){return(n-(n&la))/aa}const ca=1,ua=2,Jn=4,da=8;class zs{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&da)>0}get deletedBefore(){return(this.delInfo&(ca|Jn))>0}get deletedAfter(){return(this.delInfo&(ua|Jn))>0}get deletedAcross(){return(this.delInfo&Jn)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,r=bo(e);if(!this.inverted)for(let s=0;s<r;s++)t+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+t+Sd(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let s=0,i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+o],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+s+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:xd(l/3,e-a),m=e==a?ua:e==d?ca:Jn;return(t<0?e!=a:e!=d)&&(m|=da),new zs(h,m,p)}s+=u-c}return r?e+s:new zs(e+s,0,null)}touches(e,t){let r=0,s=bo(t),i=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let o=this.ranges[s],l=o-(this.inverted?i:0),a=o+(this.inverted?0:i),c=this.ranges[s+t],u=this.ranges[s+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class Sn{constructor(e,t,r=0,s=e?e.length:0){this.mirror=t,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Sn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let s=e.getMirror(t);this.appendMap(e._maps[t],s!=null&&s<t?r+s:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let s=e.getMirror(t);this.appendMap(e._maps[t].invert(),s!=null&&s>t?r-s-1:void 0)}}invert(){let e=new Sn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let s=0;for(let i=this.from;i<this.to;i++){let o=this._maps[i],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this._maps[a].recover(l.recover);continue}}s|=l.delInfo,e=l.pos}return r?e:new zs(e,s,null)}}const cs=Object.create(null);class se{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=cs[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in cs)throw new RangeError("Duplicate use of step JSON ID "+e);return cs[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,r,s){try{return q.ok(e.replace(t,r,s))}catch(i){if(i instanceof Zn)return q.fail(i.message);throw i}}}function hi(n,e,t){let r=[];for(let s=0;s<n.childCount;s++){let i=n.child(s);i.content.size&&(i=i.copy(hi(i.content,e,i))),i.isInline&&(i=e(i,t,s)),r.push(i)}return k.fromArray(r)}class Ge extends se{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),i=new v(hi(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),s),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,i)}invert(){return new ve(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Ge(t.pos,r.pos,this.mark)}merge(e){return e instanceof Ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ge(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ge(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("addMark",Ge);class ve extends se{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new v(hi(t.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,r)}invert(){return new Ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new ve(t.pos,r.pos,this.mark)}merge(e){return e instanceof ve&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ve(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ve(t.from,t.to,e.markFromJSON(t.mark))}}se.jsonID("removeMark",ve);class Ye extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new v(k.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let s=0;s<t.marks.length;s++)if(!t.marks[s].isInSet(r))return new Ye(this.pos,t.marks[s]);return new Ye(this.pos,this.mark)}}return new Ct(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ye(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ye(t.pos,e.markFromJSON(t.mark))}}se.jsonID("addNodeMark",Ye);class Ct extends se{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new v(k.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ct(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ct(t.pos,e.markFromJSON(t.mark))}}se.jsonID("removeNodeMark",Ct);class U extends se{constructor(e,t,r,s=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=s}apply(e){return this.structure&&$s(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new U(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&U.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new U(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof U)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?v.empty:new v(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new U(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?v.empty:new v(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new U(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new U(t.from,t.to,v.fromJSON(e,t.slice),!!t.structure)}}U.MAP_BIAS=1;se.jsonID("replace",U);class Y extends se{constructor(e,t,r,s,i,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=o,this.structure=l}apply(e){if(this.structure&&($s(e,this.from,this.gapFrom)||$s(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?q.fromReplace(e,this.from,this.to,r):q.fail("Content does not fit in gap")}getMap(){return new fe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Y(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||s<t.pos||i>r.pos?null:new Y(t.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Y(t.from,t.to,t.gapFrom,t.gapTo,v.fromJSON(e,t.slice),t.insert,!!t.structure)}}se.jsonID("replaceAround",Y);function $s(n,e,t){let r=n.resolve(e),s=t-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let o=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,s--}}return!1}function wd(n,e,t,r){let s=[],i=[],o,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(o&&o.to==f&&o.mark.eq(d[m])?o.to=h:s.push(o=new ve(f,h,d[m])));l&&l.to==f?l.to=h:i.push(l=new Ge(f,h,r))}}),s.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function Cd(n,e,t,r){let s=[],i=0;n.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;i++;let a=null;if(r instanceof jr){let c=o.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(o.marks)&&(a=[r]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<s.length;h++){let p=s[h];p.step==i-1&&d.eq(s[h].style)&&(f=p)}f?(f.to=c,f.step=i):s.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),s.forEach(o=>n.step(new ve(o.from,o.to,o.style)))}function pi(n,e,t,r=t.contentMatch,s=!0){let i=n.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)o.push(new U(l,u,v.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new ve(l,u,c.marks[f]));if(s&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new v(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new U(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(k.empty,!0);n.replace(l,l,new v(a,0,0))}for(let a=o.length-1;a>=0;a--)n.step(o[a])}function vd(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Yt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,s=0,i=0;;--r){let o=n.$from.node(r),l=n.$from.index(r)+s,a=n.$to.indexAfter(r)-i;if(r<n.depth&&o.canReplace(l,a,t))return r;if(r==0||o.type.spec.isolating||!vd(o,l,a))break;l&&(s=1),a<o.childCount&&(i=1)}return null}function Ed(n,e,t){let{$from:r,$to:s,depth:i}=e,o=r.before(i+1),l=s.after(i+1),a=o,c=l,u=k.empty,d=0;for(let p=i,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=k.from(r.node(p).copy(u)),d++):a--;let f=k.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.after(p+1)<s.end(p)?(m=!0,f=k.from(s.node(p).copy(f)),h++):c++;n.step(new Y(a,c,o,l,new v(u.append(f),d,h),u.size-d,!0))}function mi(n,e,t=null,r=n){let s=Td(n,e),i=s&&Md(r,e);return i?s.map(ko).concat({type:e,attrs:t}).concat(i.map(ko)):null}function ko(n){return{type:n,attrs:null}}function Td(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let o=i.length?i[0]:e;return t.canReplaceWith(r,s,o)?i:null}function Md(n,e){let{parent:t,startIndex:r,endIndex:s}=n,i=t.child(r),o=e.contentMatch.findWrapping(i.type);if(!o)return null;let a=(o.length?o[o.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:o}function Ad(n,e,t){let r=k.empty;for(let o=t.length-1;o>=0;o--){if(r.size){let l=t[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=k.from(t[o].type.create(t[o].attrs,r))}let s=e.start,i=e.end;n.step(new Y(s,i,s,i,new v(r,0,0),t.length,!0))}function Nd(n,e,t,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(o,l)=>{let a=typeof s=="function"?s(o):s;if(o.isTextblock&&!o.hasMarkup(r,a)&&Od(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&ha(n,o,l,i),pi(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),f=u.map(l+o.nodeSize,1);return n.step(new Y(d,f,d+1,f-1,new v(k.from(r.create(a,null,o.marks)),0,0),1,!0)),c===!0&&fa(n,o,l,i),!1}})}function fa(n,e,t,r){e.forEach((s,i)=>{if(s.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(s.text);){let a=n.mapping.slice(r).map(t+1+i+o.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ha(n,e,t,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let o=n.mapping.slice(r).map(t+1+i);n.replaceWith(o,o+1,e.type.schema.text(`
@@ -1 +1 @@
1
- import{e as b,c as w,j as a,l as j}from"./index-Dq226A4w.js";import{i as N}from"./SearchMd-CJm9ITir.js";function S(f){const e=b.c(17),{value:l,onChange:c,placeholder:g,onKeyDown:d,className:u,isSearching:p,disabled:i}=f,m=g===void 0?"Search...":g,x=i&&"pointer-events-none opacity-50";let t;e[0]!==u||e[1]!==x?(t=w("flex items-center gap-4 rounded-lg bg-background dark:bg-input/30 px-3 h-8 card-shadow","focus-within:border-ring focus-within:ring-ring/20 focus-within:ring-[2px]","transition-[color,box-shadow]",x,u),e[0]=u,e[1]=x,e[2]=t):t=e[2];let n;e[3]!==p?(n=p?a.jsx(j,{size:16,className:"animate-spin text-muted-foreground/75 shrink-0"}):a.jsx(N,{size:16,className:"text-muted-foreground/75 shrink-0"}),e[3]=p,e[4]=n):n=e[4];let s;e[5]!==c?(s=h=>c(h.target.value),e[5]=c,e[6]=s):s=e[6];let o;e[7]!==i||e[8]!==d||e[9]!==m||e[10]!==s||e[11]!==l?(o=a.jsx("input",{type:"text",value:l,onChange:s,onKeyDown:d,placeholder:m,disabled:i,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[7]=i,e[8]=d,e[9]=m,e[10]=s,e[11]=l,e[12]=o):o=e[12];let r;return e[13]!==t||e[14]!==n||e[15]!==o?(r=a.jsxs("label",{className:t,children:[n,o]}),e[13]=t,e[14]=n,e[15]=o,e[16]=r):r=e[16],r}export{S};
1
+ import{e as b,c as w,j as a,l as j}from"./index-Bu0xhzLF.js";import{i as N}from"./SearchMd-BfBE-dHK.js";function S(f){const e=b.c(17),{value:l,onChange:c,placeholder:g,onKeyDown:d,className:u,isSearching:p,disabled:i}=f,m=g===void 0?"Search...":g,x=i&&"pointer-events-none opacity-50";let t;e[0]!==u||e[1]!==x?(t=w("flex items-center gap-4 rounded-lg bg-background dark:bg-input/30 px-3 h-8 card-shadow","focus-within:border-ring focus-within:ring-ring/20 focus-within:ring-[2px]","transition-[color,box-shadow]",x,u),e[0]=u,e[1]=x,e[2]=t):t=e[2];let n;e[3]!==p?(n=p?a.jsx(j,{size:16,className:"animate-spin text-muted-foreground/75 shrink-0"}):a.jsx(N,{size:16,className:"text-muted-foreground/75 shrink-0"}),e[3]=p,e[4]=n):n=e[4];let s;e[5]!==c?(s=h=>c(h.target.value),e[5]=c,e[6]=s):s=e[6];let o;e[7]!==i||e[8]!==d||e[9]!==m||e[10]!==s||e[11]!==l?(o=a.jsx("input",{type:"text",value:l,onChange:s,onKeyDown:d,placeholder:m,disabled:i,className:"flex-1 min-w-0 bg-transparent text-sm text-foreground placeholder:text-muted-foreground/50 outline-none"}),e[7]=i,e[8]=d,e[9]=m,e[10]=s,e[11]=l,e[12]=o):o=e[12];let r;return e[13]!==t||e[14]!==n||e[15]!==o?(r=a.jsxs("label",{className:t,children:[n,o]}),e[13]=t,e[14]=n,e[15]=o,e[16]=r):r=e[16],r}export{S};