dirigent-server 0.9.2__tar.gz → 0.9.4__tar.gz

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 (147) hide show
  1. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/PKG-INFO +1 -1
  2. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/pyproject.toml +1 -1
  3. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/pyproject.toml.orig +1 -1
  4. dirigent_server-0.9.2/src/dirigent_server/static/assets/Alerting-CIsCj-6c.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Alerting-BIhNmOxf.js +1 -1
  5. dirigent_server-0.9.2/src/dirigent_server/static/assets/Blocks-Cvo8YMNh.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Blocks-DAo8_PG9.js +1 -1
  6. dirigent_server-0.9.2/src/dirigent_server/static/assets/Connections-DXdsME87.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Connections-DsnMTiIk.js +1 -1
  7. dirigent_server-0.9.2/src/dirigent_server/static/assets/Dashboard-_HpXroFp.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Dashboard-BqRQb7Y9.js +1 -1
  8. dirigent_server-0.9.2/src/dirigent_server/static/assets/JsonBlock-CN39X8Cq.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/JsonBlock-CE3Z9rOk.js +1 -1
  9. dirigent_server-0.9.2/src/dirigent_server/static/assets/Overview-09NEISad.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Overview-D25nQ1mY.js +1 -1
  10. dirigent_server-0.9.2/src/dirigent_server/static/assets/Picker-BsoYhAn2.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Picker-BWWGdN86.js +1 -1
  11. dirigent_server-0.9.2/src/dirigent_server/static/assets/PipelineEditor-BUkcsTJx.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/PipelineEditor-CGYiQ_RS.js +2 -2
  12. dirigent_server-0.9.2/src/dirigent_server/static/assets/PipelineGraph-C7FEixJr.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/PipelineGraph-VDlVb6oE.js +1 -1
  13. dirigent_server-0.9.2/src/dirigent_server/static/assets/PipelinePreview-BVRbD1s8.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/PipelinePreview-XjwlgU-a.js +1 -1
  14. dirigent_server-0.9.2/src/dirigent_server/static/assets/PipelineTab-BUknHED2.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/PipelineTab-DkpDNs3l.js +1 -1
  15. dirigent_server-0.9.2/src/dirigent_server/static/assets/Refusal-D4_PzLAl.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Refusal-JlhK6Mh_.js +1 -1
  16. dirigent_server-0.9.2/src/dirigent_server/static/assets/RunDetail-BYk8kgjA.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/RunDetail-DG3dbzT_.js +3 -3
  17. dirigent_server-0.9.2/src/dirigent_server/static/assets/RunGraph-Bu83-LYC.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/RunGraph-iHPOD_w8.js +1 -1
  18. dirigent_server-0.9.2/src/dirigent_server/static/assets/SchemaForm-Cg8Z7V7H.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/SchemaForm-DDpXEjh5.js +1 -1
  19. dirigent_server-0.9.2/src/dirigent_server/static/assets/Schemas-RyigFd22.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Schemas-B4DAs5a7.js +1 -1
  20. dirigent_server-0.9.2/src/dirigent_server/static/assets/SettingsDialog-C22vGEt_.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/SettingsDialog-BhV4tAsN.js +1 -1
  21. dirigent_server-0.9.2/src/dirigent_server/static/assets/TileCard-BhdD6xgH.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/TileCard-D1sr4_Pk.js +1 -1
  22. dirigent_server-0.9.2/src/dirigent_server/static/assets/Triggers-BcMSaJEd.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Triggers-_p64iSNi.js +1 -1
  23. dirigent_server-0.9.2/src/dirigent_server/static/assets/Users-BWHk-WWd.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Users-D0Ha-Dwb.js +1 -1
  24. dirigent_server-0.9.2/src/dirigent_server/static/assets/Workers-sHe1DQol.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/Workers-B_pwpd3E.js +1 -1
  25. dirigent_server-0.9.2/src/dirigent_server/static/assets/WorkersTable-6exKSnOc.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/WorkersTable-C_fx8dTx.js +1 -1
  26. dirigent_server-0.9.4/src/dirigent_server/static/assets/index-a02YzA4l.css +2 -0
  27. dirigent_server-0.9.4/src/dirigent_server/static/assets/index-jhYU37cm.js +53 -0
  28. dirigent_server-0.9.2/src/dirigent_server/static/assets/select-BzYLXMEI.js → dirigent_server-0.9.4/src/dirigent_server/static/assets/select-CKTm9cc4.js +1 -1
  29. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/index.html +2 -2
  30. dirigent_server-0.9.2/src/dirigent_server/static/assets/index-BnHUKeQz.css +0 -2
  31. dirigent_server-0.9.2/src/dirigent_server/static/assets/index-fYbFix6w.js +0 -53
  32. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/LICENSE +0 -0
  33. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/README.md +0 -0
  34. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/THIRD_PARTY_NOTICES.md +0 -0
  35. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/__init__.py +0 -0
  36. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/app.py +0 -0
  37. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/dependencies.py +0 -0
  38. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/errors.py +0 -0
  39. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/health.py +0 -0
  40. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/logging.py +0 -0
  41. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/pagination.py +0 -0
  42. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/py.typed +0 -0
  43. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/__init__.py +0 -0
  44. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/alerts.py +0 -0
  45. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/auth.py +0 -0
  46. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/blocks.py +0 -0
  47. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/connections.py +0 -0
  48. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/hooks.py +0 -0
  49. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/pipelines.py +0 -0
  50. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/runs.py +0 -0
  51. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/schema.py +0 -0
  52. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/schemas.py +0 -0
  53. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/system.py +0 -0
  54. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/trigger_documents.py +0 -0
  55. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/triggers.py +0 -0
  56. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/users.py +0 -0
  57. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/routes/workers.py +0 -0
  58. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/security.py +0 -0
  59. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/.gitkeep +0 -0
  60. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/AdminOnly-DaihxNZC.js +0 -0
  61. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Breadcrumb-C8mERKVl.js +0 -0
  62. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/CodeEditor-B55U_qvj.css +0 -0
  63. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/CodeEditor-CeCQ17xS.js +0 -0
  64. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Description-BP4Ga-RV.js +0 -0
  65. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Instant-C9TZFyg5.js +0 -0
  66. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/KindChip-CuBFi3X9.js +0 -0
  67. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Markdown-CttJCcht.js +0 -0
  68. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/PageState-CvfT4nGl.js +0 -0
  69. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Panel-Cb5LtMYX.js +0 -0
  70. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/Segmented-CR-Iqv1r.js +0 -0
  71. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/StepPorts-CtcvnIvJ.js +0 -0
  72. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/auth-tGoFbaSP.js +0 -0
  73. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/badge-DJ6MGkEI.js +0 -0
  74. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/blocks-DkD_WaQ6.js +0 -0
  75. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/chevron-down-CrkpqUMs.js +0 -0
  76. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/chunk-BV7QT456-Bfa1dvOx.js +0 -0
  77. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/connections-DORVdX7a.js +0 -0
  78. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/copy-r6NpGwbU.js +0 -0
  79. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/dist-BWSEJlfk.js +0 -0
  80. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/dropdown-menu-DTSgujsZ.js +0 -0
  81. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/editor.worker-BaAK1IVA.js +0 -0
  82. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/format-CR2ze2LO.js +0 -0
  83. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  84. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  85. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  86. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  87. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  88. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  89. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  90. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  91. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  92. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  93. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  94. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  95. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  96. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  97. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  98. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  99. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  100. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  101. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  102. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  103. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  104. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  105. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  106. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  107. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  108. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  109. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  110. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  111. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  112. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  113. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
  114. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
  115. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
  116. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
  117. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
  118. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
  119. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/identity-BNZxCf_y.js +0 -0
  120. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/input-o9l61NKa.js +0 -0
  121. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/json.worker-C-kBQgxp.js +0 -0
  122. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/jsonMode-CrarWqyF.js +0 -0
  123. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/maximize-2-B2tdtoC6.js +0 -0
  124. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/paging-MGEIXfCZ.js +0 -0
  125. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/pipelines-C9zjqLmS.js +0 -0
  126. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/preferences-Cl9nlEI4.js +0 -0
  127. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/preload-helper-Czpn1I53.js +0 -0
  128. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/react-BatatxyT.js +0 -0
  129. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/resolveAriaLabelledBy-BSPxlOXj.js +0 -0
  130. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/rolldown-runtime-Dd_uD5pT.js +0 -0
  131. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/schema-form-FkbdR3oI.js +0 -0
  132. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/shell-CC2rA5mh.js +0 -0
  133. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/status-Ctx8x8Mf.js +0 -0
  134. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/store-CVrCnru0.js +0 -0
  135. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/textarea-XMYmRm72.js +0 -0
  136. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/triggers-Bk6judIf.js +0 -0
  137. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/use-heartbeat-ByRKom_T.js +0 -0
  138. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/use-store-CgWwefFs.js +0 -0
  139. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/users-xhJLEYNg.js +0 -0
  140. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/utils-CRMSf51M.js +0 -0
  141. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/workers-D2C0PSb8.js +0 -0
  142. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/yaml-B8bSwfJE.js +0 -0
  143. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/assets/yaml.worker-D2mqiKN-.js +0 -0
  144. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/favicon-32.png +0 -0
  145. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/static/logo.png +0 -0
  146. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/transactions.py +0 -0
  147. {dirigent_server-0.9.2 → dirigent_server-0.9.4}/src/dirigent_server/ui.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dirigent-server
3
- Version: 0.9.2
3
+ Version: 0.9.4
4
4
  Summary: Dirigent FastAPI server: the REST API, its authentication, and the health probes.
5
5
  License-Expression: LicenseRef-Proprietary
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-server"
3
- version = "0.9.2"
3
+ version = "0.9.4"
4
4
  description = "Dirigent FastAPI server: the REST API, its authentication, and the health probes."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dirigent-server"
3
- version = "0.9.2"
3
+ version = "0.9.4"
4
4
  description = "Dirigent FastAPI server: the REST API, its authentication, and the health probes."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{i as n}from"./store-CVrCnru0.js";import{n as r}from"./chunk-BV7QT456-Bfa1dvOx.js";import{b as i,y as a}from"./dropdown-menu-DTSgujsZ.js";import{n as o,o as s,t as c}from"./PageState-CvfT4nGl.js";import{r as l}from"./utils-CRMSf51M.js";import{d as u,f as d}from"./paging-MGEIXfCZ.js";import{t as f}from"./input-o9l61NKa.js";import{t as p}from"./identity-BNZxCf_y.js";import{n as m,s as h}from"./pipelines-C9zjqLmS.js";import{Ct as g,Dt as _,Et as v,Ft as y,O as b,Ot as x,T as S,Tt as C,b as w,ct as T,g as E,gt as D,kt as O,lt as k,nt as A,pt as j,tt as M,v as N,w as P,wt as F,x as I,y as L}from"./index-fYbFix6w.js";import{t as R}from"./Description-BP4Ga-RV.js";import{t as z}from"./Instant-C9TZFyg5.js";import{l as B}from"./connections-DORVdX7a.js";import{n as V,t as ee}from"./Refusal-D4_PzLAl.js";import{t as te}from"./Segmented-CR-Iqv1r.js";import{t as H}from"./Picker-BsoYhAn2.js";import{t as U}from"./AdminOnly-DaihxNZC.js";var ne=n(`bell-plus`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M15 8h6`,key:`8ybuxh`}],[`path`,{d:`M18 5v6`,key:`g5ayrv`}],[`path`,{d:`M20.002 14.464a9 9 0 0 0 .738.863A1 1 0 0 1 20 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 8.75-5.332`,key:`1abcvy`}]]),re=n(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),W=e(t(),1),ie=[`run_failed`,`run_completed_with_errors`,`run_succeeded`,`run_stuck`],ae=[`pending`,`sending`,`sent`,`failed`],oe=`0s`;function se(e){return e===oe?`none`:e}function ce(e){return e.replaceAll(`_`,` `)}function le(e){return e.scope===`pipeline`&&e.pipeline!==null?e.pipeline:`every pipeline`}function ue(e){return e.active&&!e.paused}function de(e){return e===`sent`||e===`failed`}function fe(e,t=50){let n=new URLSearchParams({limit:String(t)});return e!==null&&n.set(`after`,e),`/alert-rules?${n.toString()}`}function pe(e){return a(fe(e))}function me(e){return i(`/alert-rules`,`POST`,e)}function he(e,t){return i(`/alert-rules/${encodeURIComponent(e)}`,`PATCH`,{paused:t})}function ge(e){return a(`/alert-rules/${encodeURIComponent(e)}`,{method:`DELETE`})}var _e={status:``,notifier:``};function ve(e,t,n=50){let r=new URLSearchParams({limit:String(n)});return e.status!==``&&r.set(`status`,e.status),e.notifier!==``&&r.set(`notifier`,e.notifier),t!==null&&r.set(`after`,t),`/notifications?${r.toString()}`}function ye(e,t){return a(ve(e,t))}function be(e){return a(`/notifications/${encodeURIComponent(e)}`)}function xe(e){return i(`/notifications/${encodeURIComponent(e)}/$retry`,`POST`,{})}function Se(e){return i(`/alert-rules/$test`,`POST`,e)}async function Ce(){return(await a(`/blocks`)).notifiers.map(e=>e.id)}function we(e,t){let n=[];for(let r of e){if(r===`log`){n.push({id:r,notifier:r,connection:null,reachable:!0,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}let e=t.filter(e=>e.kind===r);if(e.length===0){n.push({id:r,notifier:r,connection:null,reachable:!1,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}for(let t of e)n.push({id:`${r}:${t.code}`,notifier:r,connection:t.code,reachable:!0,last_check_at:t.last_check_at,last_check_healthy:t.last_check_healthy,last_check_detail:t.last_check_detail})}return n}function Te(e){return e.notifier===`log`?{tone:`good`,label:`built in`,detail:null}:e.reachable?e.last_check_at===null?{tone:`quiet`,label:`never checked`,detail:null}:{tone:e.last_check_healthy===!0?`good`:`critical`,label:e.last_check_healthy===!0?`checked`:`failing`,detail:e.last_check_detail}:{tone:`quiet`,label:`no connection`,detail:`Nothing delivers through this channel yet.`}}var G=l();function Ee({rule:e,onChanged:t,onDeleted:n,onTest:r}){let[i,a]=(0,W.useState)(!1),o=L(),c=(0,W.useCallback)(e=>ye(_e,e),[]),{state:l}=N(c,Oe),u=l.rows.filter(t=>t.rule===e.code);return(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,G.jsxs)(je,{thing:e,children:[e.paused&&(0,G.jsx)(Ae,{children:`paused`}),!e.active&&(0,G.jsx)(Ae,{children:`off`})]}),(0,G.jsx)(R,{text:e.description}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[(0,G.jsx)(q,{label:`Event`,children:ce(e.event)}),(0,G.jsx)(q,{label:`Scope`,children:le(e)}),(0,G.jsx)(q,{label:`Delivers through`,children:(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})}),(0,G.jsx)(q,{label:`Throttle`,children:se(e.throttle)}),e.template!==null&&(0,G.jsx)(q,{label:`Subject`,children:(0,G.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.template})}),(0,G.jsx)(q,{label:`Last sent`,children:e.last_sent_at===null?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,G.jsx)(z,{at:e.last_sent_at})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:i||!o.may,title:o.why,onClick:()=>{a(!0),he(e.code,!e.paused).then(t,V).finally(()=>{a(!1)})},children:e.paused?`Resume`:`Pause`})}),(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:!o.may,title:o.why,onClick:r,children:`Send a test`})}),(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,className:`destructive-action ml-auto`,disabled:i||!o.may,title:o.why,onClick:()=>{a(!0),ge(e.code).then(n,V).finally(()=>{a(!1)})},children:`Delete`})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Recent deliveries`}),!l.read&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Reading from the server`}),l.read&&u.length===0&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Nothing sent.`}),(0,G.jsx)(`ul`,{className:`divide-border divide-y`,children:u.map(e=>(0,G.jsxs)(`li`,{className:`row-hover -mx-4 flex items-center gap-2 px-4 py-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:e.subject}),(0,G.jsx)(z,{className:`text-faint shrink-0 text-xs`,at:e.created_at})]},e.id))})]})]})}function De({notification:e,onChanged:t}){let[n,i]=(0,W.useState)(!1),a=L();return(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,G.jsx)(`div`,{className:`space-y-1`,children:(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e.subject})]})}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.rule===null?(0,G.jsx)(q,{label:`Raised by`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`a test, not a rule`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{label:`Event`,children:ce(e.event)}),(0,G.jsx)(q,{label:`Rule`,children:(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.rule})})]}),(0,G.jsx)(q,{label:`Delivers through`,children:(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})}),(0,G.jsx)(q,{label:`Run`,children:(0,G.jsx)(ke,{notification:e})}),(0,G.jsx)(q,{label:`Queued`,children:(0,G.jsx)(z,{at:e.created_at})}),e.status===`sent`?(0,G.jsx)(q,{label:`Sent`,children:(0,G.jsx)(z,{at:e.sent_at})}):(0,G.jsx)(q,{label:`Next try`,children:(0,G.jsx)(z,{at:e.available_at})}),(0,G.jsxs)(q,{label:`Attempts`,children:[e.attempt,` of `,e.max_attempts]})]}),e.error!==null&&(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`What the channel said`}),(0,G.jsx)(`p`,{className:`text-critical text-xs break-words`,children:e.error}),(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Only the latest refusal is kept. Earlier attempts are counted, not stored.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(s,{why:a.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:n||!a.may,title:a.why,onClick:()=>{i(!0),xe(e.id).then(t,V).finally(()=>{i(!1)})},children:`Retry now`})}),e.run_id!==null&&(0,G.jsx)(d,{variant:`outline`,size:`sm`,render:(0,G.jsx)(r,{to:`/runs/${e.run_id}`}),children:`Open the run`})]})]})}var Oe=e=>e.id;function K({notifier:e,connection:t}){return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:e}),t!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}function ke({notification:e}){if(e.run_id===null)return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`no run`});let t=e.run_pipeline??`a run`;return(0,G.jsxs)(r,{className:`text-primary hover:underline`,to:`/runs/${e.run_id}`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:t}),e.run_started_at!==null&&(0,G.jsx)(z,{className:`text-muted-foreground ml-1.5 text-xs`,at:e.run_started_at})]})}function Ae({children:e}){return(0,G.jsx)(`span`,{className:`border-border text-muted-foreground rounded-sm border px-1.5 text-xs`,children:e})}function je({thing:e,children:t}){let n=p(e);return(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:n.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:n.title}),t,n.code!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:n.code})]})}function q({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground w-32 shrink-0 text-xs`,children:e}),(0,G.jsx)(`dd`,{className:`min-w-0 text-sm`,children:t})]})}var Me={good:`var(--good)`,critical:`var(--critical)`,quiet:`var(--faint)`};function Ne({channels:e}){return(0,G.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:e.map(e=>(0,G.jsx)(Pe,{channel:e},e.id))})}function Pe({channel:e}){let t=Te(e);return(0,G.jsxs)(`li`,{className:`border-border bg-card flex items-start justify-between gap-3 rounded-lg border p-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,title:e.connection===null?e.notifier:`${e.notifier} ${e.connection}`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,style:{"--chip":Me[t.tone]}}),(0,G.jsx)(`span`,{className:`shrink-0 text-sm font-medium`,children:e.notifier}),e.connection!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e.connection})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t.label}),e.last_check_at!==null&&(0,G.jsx)(z,{className:`text-faint text-xs`,at:e.last_check_at}),t.detail!==null&&(0,G.jsx)(`span`,{className:`text-faint max-w-48 truncate text-xs`,title:t.detail,children:t.detail})]})]})}function J({id:e,label:t,value:n,onChange:r,placeholder:i,mono:a,hint:o}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:t}),(0,G.jsx)(f,{id:e,className:a===!0?`font-mono`:void 0,spellCheck:!1,autoComplete:`off`,value:n,placeholder:i,onChange:e=>{r(e.target.value)}}),o!==void 0&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:o})]})}function Fe({id:e,notifiers:t,value:n,onChange:r}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:`Notifier`}),(0,G.jsx)(H,{id:e,label:`Notifier`,value:n,options:t.map(e=>({value:e,label:e,aside:``})),placeholder:`Search the installed channels`,onChange:r})]})}function Ie({id:e,kind:t,value:n,onChange:r}){let i=Le(t);return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:`Connection`}),(0,G.jsx)(H,{id:e,label:`Connection`,value:n,options:i,placeholder:i.length===0?`No ${t} connection yet`:`Search by name or code`,onChange:r})]})}function Le(e){let[t,n]=(0,W.useState)([]);return(0,W.useEffect)(()=>{if(e===``||e===`log`)return;let t=!0;return B().then(e=>{t&&n(e.items)},()=>{t&&n([])}),()=>{t=!1}},[e]),t.filter(t=>t.kind===e).map(e=>{let t=p(e);return{value:e.code,label:t.title,aside:t.code??``}})}var Re=/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u,ze=/^(?:\d+(?:ms|s|m|h|d|w))+$/u,Be="${run.*} may read the run's pipeline, status, id, error, trigger, duration_ms and url.",Ve=[{value:`global`,label:`Every pipeline`},{value:`pipeline`,label:`One pipeline`}],Y={run_failed:`Failed`,run_completed_with_errors:`Completed with errors`,run_succeeded:`Succeeded`,run_stuck:`Stuck`};function X(e){return e!==``&&e!==`log`}function He(e){if(e.code.trim()===``)return`A rule is addressed by its code, and this one has none.`;if(!Re.test(e.code.trim()))return`A code is lowercase words joined by - or _.`;if(e.scope===`pipeline`&&e.pipeline===``)return`A rule watching one pipeline names that pipeline, and this one names none.`;if(e.notifier===``)return`A rule delivers through a channel, and this one names none.`;if(X(e.notifier)&&e.connection===``)return`The ${e.notifier} channel delivers through a connection, and this one names none.`;if(!ze.test(e.throttle.trim()))return`A throttle is a duration, such as 15m.`}function Ue(e,t){if(e===``)return`A test goes through a channel, and this one names none.`;if(X(e)&&t===``)return`The ${e} channel delivers through a connection, and this one names none.`}var We=`0s`;function Ge({open:e,onOpenChange:t,notifiers:n,onCreated:r}){let[i,a]=(0,W.useState)(``),[o,c]=(0,W.useState)(``),[l,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(`run_failed`),[h,v]=(0,W.useState)(`global`),[y,S]=(0,W.useState)(``),[T,E]=(0,W.useState)(``),[D,k]=(0,W.useState)(``),[A,j]=(0,W.useState)(``),[M,N]=(0,W.useState)(We),[P,I]=(0,W.useState)(null),[R,z]=(0,W.useState)(!1),B=Ke(e),V=L(),U=w(V.why,He({code:i,scope:h,pipeline:y,notifier:T,connection:D,throttle:M}));return(0,G.jsx)(g,{open:e,onOpenChange:t,children:(0,G.jsxs)(C,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,G.jsx)(x,{children:(0,G.jsx)(O,{children:`New rule`})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(J,{id:`rule-code`,label:`Code`,value:i,onChange:a,placeholder:`ops-slack-failed`,mono:!0}),(0,G.jsx)(J,{id:`rule-name`,label:`Name`,value:o,onChange:c,placeholder:`Tell the ops channel`})]}),(0,G.jsx)(J,{id:`rule-description`,label:`Description`,value:l,onChange:f,placeholder:`What this rule is for`}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{children:`Event`}),(0,G.jsx)(te,{label:`Event`,size:`md`,value:p,options:ie.map(e=>({value:e,label:Y[e]})),onChoose:m})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{children:`Scope`}),(0,G.jsx)(te,{label:`Scope`,size:`md`,value:h,options:Ve,onChoose:v})]}),h===`pipeline`&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:`rule-pipeline`,children:`Pipeline`}),(0,G.jsx)(H,{id:`rule-pipeline`,label:`Pipeline`,value:y,options:B,placeholder:`Search by name or code`,onChange:S})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(Fe,{id:`rule-notifier`,notifiers:n,value:T,onChange:e=>{E(e),k(``)}}),X(T)&&(0,G.jsx)(Ie,{id:`rule-connection`,kind:T,value:D,onChange:k})]}),(0,G.jsx)(J,{id:`rule-subject`,label:`Subject`,value:A,onChange:j,placeholder:"${run.pipeline} run ${run.status}",mono:!0,hint:Be}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,G.jsx)(J,{id:`rule-throttle`,label:`Throttle`,value:M,onChange:N,placeholder:`15m`,mono:!0})}),P!==null&&(0,G.jsx)(ee,{problem:P}),(0,G.jsxs)(_,{children:[(0,G.jsx)(`p`,{className:`text-muted-foreground mr-auto self-center text-xs`,children:`A rule fires when a run settles. Nothing is sent now.`}),(0,G.jsx)(F,{render:(0,G.jsx)(d,{variant:`ghost`}),children:`Close`}),(0,G.jsx)(s,{why:U,children:(0,G.jsx)(d,{disabled:R||U!==void 0,title:U,onClick:()=>{z(!0),I(null),me({code:i.trim(),name:Z(o),description:Z(l),event:p,notifier:T,scope:h,pipeline:h===`pipeline`?y:null,connection:X(T)?D:null,template:Z(A),throttle:M.trim()}).then(()=>{r(),a(``),c(``),f(``),j(``),t(!1)},e=>{I(u(e))}).finally(()=>{z(!1)})},children:R?`Creating`:`Create`})})]})]})})}function Z(e){let t=e.trim();return t===``?null:t}function Ke(e){let[t,n]=(0,W.useState)([]);return(0,W.useEffect)(()=>{if(!e)return;let t=!0;return h().then(e=>{t&&n(e.toSorted(m).map(e=>{let t=p(e);return{value:e.code,label:t.title,aside:t.code??``}}))},()=>{t&&n([])}),()=>{t=!1}},[e]),t}var qe=1e3,Je=6e4,Ye=`dirigent test alert`,Q={notifier:``,connection:``,subject:``};function Xe({open:e,draft:t,onOpenChange:n,notifiers:r,onQueued:i,onOpenQueue:a}){let[o,c]=(0,W.useState)(t.notifier),[l,f]=(0,W.useState)(t.connection),[p,m]=(0,W.useState)(t.subject),[h,y]=(0,W.useState)(null),[b,S]=(0,W.useState)(null),[T,E]=(0,W.useState)(!1),D=Qe(h),k=L(),A=D!==null&&de(D.status)?D.id:null;(0,W.useEffect)(()=>{A!==null&&i()},[A]);let j=w(k.why,Ue(o,l));return(0,G.jsx)(g,{open:e,onOpenChange:n,children:(0,G.jsxs)(C,{className:`sm:max-w-lg`,showCloseButton:!1,children:[(0,G.jsxs)(x,{children:[(0,G.jsx)(O,{children:`Send a test`}),(0,G.jsx)(v,{children:`The message goes through the same queue a real alert does, and a worker delivers it.`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(Fe,{id:`test-notifier`,notifiers:r,value:o,onChange:e=>{c(e),f(``)}}),X(o)&&(0,G.jsx)(Ie,{id:`test-connection`,kind:o,value:l,onChange:f})]}),(0,G.jsx)(J,{id:`test-subject`,label:`Subject`,value:p,onChange:m,placeholder:Ye}),b!==null&&(0,G.jsx)(ee,{problem:b}),D!==null&&(0,G.jsx)(Ze,{row:D}),(0,G.jsxs)(_,{children:[(0,G.jsx)(F,{render:(0,G.jsx)(d,{variant:`ghost`}),children:`Close`}),h!==null&&(0,G.jsx)(d,{variant:`outline`,onClick:()=>{a(h)},children:`Open in the queue`}),(0,G.jsx)(s,{why:j,children:(0,G.jsx)(d,{disabled:T||j!==void 0,title:j,onClick:()=>{E(!0),S(null),y(null),Se({notifier:o,connection:X(o)?l:null,...p.trim()===``?{}:{subject:p.trim()}}).then(e=>{y(e.notification_id),i()},e=>{S(u(e))}).finally(()=>{E(!1)})},children:h===null?`Send`:`Send again`})})]})]})})}function Ze({row:e}){return(0,G.jsxs)(`div`,{className:`border-border bg-secondary/40 space-y-2 rounded-lg border p-3`,"data-testid":`test-delivery`,"aria-live":`polite`,children:[(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`text-sm`,children:e.subject})]}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.status===`sent`?(0,G.jsxs)(G.Fragment,{children:[`Delivered `,(0,G.jsx)(z,{at:e.sent_at}),`.`]}):e.status===`failed`?(0,G.jsxs)(G.Fragment,{children:[`Given up after `,e.attempt,` of `,e.max_attempts,` attempts.`]}):e.attempt===0?`Queued for the next worker pass.`:(0,G.jsxs)(G.Fragment,{children:[`Attempt `,e.attempt,` of `,e.max_attempts,`, next try `,(0,G.jsx)(z,{at:e.available_at}),`.`]})}),e.error!==null&&(0,G.jsx)(`p`,{className:`text-critical text-xs break-words`,children:e.error})]})}function Qe(e){let[t,n]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(e===null)return;let t=!0,r,i=Date.now()+Je,a=()=>{be(e).then(o=>{t&&(n({id:e,row:o}),!(de(o.status)||Date.now()>i)&&(r=setTimeout(a,qe)))},()=>{})};return a(),()=>{t=!1,r!==void 0&&clearTimeout(r)}},[e]),t!==null&&t.id===e?t.row:null}var $e=e=>e.id,et=e=>e.id;function tt(){return(0,G.jsx)(U,{children:(0,G.jsx)(nt,{})})}function nt(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[s,l]=(0,W.useState)(null),[u,d]=(0,W.useState)({status:``,notifier:``}),[f,p]=(0,W.useState)({}),[m,h]=(0,W.useState)({}),g=N((0,W.useCallback)(e=>pe(e),[]),$e),_=N((0,W.useCallback)(e=>ye(u,e),[u]),et),v=it(),{reload:b}=g,{reload:x}=_,C=(0,W.useMemo)(()=>g.state.rows.map(e=>f[e.id]??e),[f,g.state.rows]),w=(0,W.useMemo)(()=>_.state.rows.map(e=>m[e.id]??e),[m,_.state.rows]),O=C.find(e=>e.id===i)??null,F=w.find(e=>e.id===s)??null,R=(0,W.useCallback)(e=>{r(t=>({draft:e,opened:(t?.opened??0)+1}))},[]);(0,W.useEffect)(()=>(A({note:null,tone:`quiet`,identifier:null}),M),[]),(0,W.useEffect)(()=>{if(O!==null){let e=O;return T([{id:`rule`,label:`Rule`,render:()=>(0,G.jsx)(Ee,{rule:e,onChanged:e=>{p(t=>({...t,[e.id]:e}))},onDeleted:()=>{a(null),b()},onTest:()=>{R({notifier:e.notifier,connection:e.connection??``,subject:``})}})}],{screen:`alerting`})}if(F!==null){let e=F;return T([{id:`notification`,label:`Notification`,render:()=>(0,G.jsx)(De,{notification:e,onChanged:e=>{h(t=>({...t,[e.id]:e}))}})}],{screen:`alerting`})}},[F,O,R,b]);let z=L(`admin`),B=z.may;return(0,W.useEffect)(()=>D([...B?[{id:`alerting:rule`,title:`New alert rule`,group:j,screen:!0,icon:ne,keywords:[`alert`,`event`,`create`],run:()=>{t(!0)}},{id:`alerting:test`,title:`Send a test through a channel`,group:j,screen:!0,icon:re,keywords:[`alert`,`notification`,`try`],run:()=>{R(Q)}}]:[],{id:`alerting:reload`,title:`Read the alert rules again`,group:j,screen:!0,icon:y,keywords:[`refresh`,`reload`],run:()=>{b(),x()}}]),[B,R,x,b]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(c,{title:`Alerting`,aside:(0,G.jsx)(S,{tag:`alerts`}),actions:[{id:`test`,label:`Send a test`,icon:re,variant:`outline`,disabled:!z.may,why:z.why,onClick:()=>{R(Q)}},{id:`rule`,label:`New rule`,icon:ne,disabled:!z.may,why:z.why,onClick:()=>{t(!0)}}]}),(0,G.jsxs)(`section`,{className:`mb-6 space-y-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Channels`}),v.read?v.rows.length===0?(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No channel is installed.`}):(0,G.jsx)(Ne,{channels:v.rows}):(0,G.jsx)(`p`,{className:`text-faint text-sm`,children:`Reading from the server`})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Rules`}),(0,G.jsx)(o,{loading:!g.state.read,problem:g.state.problem,empty:C.length===0,emptyMessage:`No rules.`,children:(0,G.jsx)(P,{columns:at,rows:C,rowKey:$e,rowClassName:e=>ue(e)?void 0:`opacity-60`,reading:g.state.reading,next:g.state.next,onMore:g.more,noun:`rules`,onSelect:e=>{l(null),a(e.id),k()},selected:e=>e.id===i})})]}),(0,G.jsxs)(`section`,{className:`mt-8 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(E,{label:`Status`,value:u.status,anything:`Any status`,options:ae.map(e=>({value:e,label:e,mark:(0,G.jsx)(I,{status:e})})),onChange:e=>{d(t=>({...t,status:e}))}}),(0,G.jsx)(E,{label:`Notifier`,value:u.notifier,anything:`Any notifier`,options:rt(v.rows),onChange:e=>{d(t=>({...t,notifier:e}))}})]})]}),(0,G.jsx)(o,{loading:!_.state.read,problem:_.state.problem,empty:w.length===0,emptyMessage:`Nothing queued.`,children:(0,G.jsx)(P,{columns:ot,rows:w,rowKey:et,reading:_.state.reading,next:_.state.next,onMore:_.more,noun:`notifications`,onSelect:e=>{a(null),l(e.id),k()},selected:e=>e.id===s})})]}),(0,G.jsx)(Ge,{open:e,onOpenChange:t,notifiers:$(v.rows),onCreated:b}),(0,G.jsx)(Xe,{open:n!==null,draft:n?.draft??Q,onOpenChange:e=>{e||r(null)},notifiers:$(v.rows),onQueued:x,onOpenQueue:e=>{r(null),a(null),l(e),x(),k()}},n?.opened??0)]})}function $(e){return[...new Set(e.map(e=>e.notifier))]}function rt(e){return $(e).map(e=>({value:e,label:e}))}function it(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let e=!0;return Ce().then(n=>{e&&t(n)},()=>{e&&t([])}),B().then(t=>{e&&r(t.items)},()=>{e&&r([])}),()=>{e=!1}},[]),{rows:(0,W.useMemo)(()=>we(e??[],n??[]),[n,e]),read:e!==null&&n!==null}}var at=[{id:`rule`,header:`Rule`,cell:e=>{let t=p(e);return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:t.named?`text-sm font-medium`:`font-mono text-sm font-medium`,children:t.title}),t.code!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.code})]})}},{id:`event`,header:`Event`,cell:e=>(0,G.jsx)(`span`,{className:`text-sm`,children:Y[e.event]})},{id:`scope`,header:`Scope`,cell:e=>(0,G.jsx)(`span`,{className:e.scope===`pipeline`?`font-mono text-xs`:`text-sm`,children:le(e)})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})},{id:`throttle`,header:`Throttle`,className:`font-mono text-xs`,cell:e=>(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:se(e.throttle)})},{id:`sent`,header:`Last sent`,className:`text-xs`,cell:e=>e.last_sent_at===null?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.last_sent_at})},{id:`live`,header:`State`,cell:e=>e.paused?(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`paused`}):e.active?(0,G.jsx)(`span`,{className:`text-good text-xs`,children:`active`}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`off`})}],ot=[{id:`status`,header:`Status`,cell:e=>(0,G.jsx)(I,{status:e.status})},{id:`subject`,header:`Subject`,cell:e=>(0,G.jsxs)(`span`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:e.subject}),e.error!==null&&(0,G.jsx)(`span`,{className:`text-critical max-w-96 truncate text-xs`,title:e.error,children:e.error})]})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})},{id:`run`,header:`Run`,cell:e=>(0,G.jsx)(ke,{notification:e})},{id:`queued`,header:`Queued`,className:`text-xs`,cell:e=>(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.created_at})},{id:`sent`,header:`Sent`,className:`text-xs`,cell:e=>e.status===`sent`?(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.sent_at}):e.attempt>0?(0,G.jsxs)(`span`,{className:`text-faint`,children:[e.attempt,` of `,e.max_attempts,` attempts`]}):null}];export{tt as AdminAlerting};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{i as n}from"./store-CVrCnru0.js";import{n as r}from"./chunk-BV7QT456-Bfa1dvOx.js";import{b as i,y as a}from"./dropdown-menu-DTSgujsZ.js";import{n as o,o as s,t as c}from"./PageState-CvfT4nGl.js";import{r as l}from"./utils-CRMSf51M.js";import{d as u,f as d}from"./paging-MGEIXfCZ.js";import{t as f}from"./input-o9l61NKa.js";import{t as p}from"./identity-BNZxCf_y.js";import{n as m,s as h}from"./pipelines-C9zjqLmS.js";import{Ct as g,Dt as _,Et as v,Ft as y,O as b,Ot as x,T as S,Tt as C,b as w,ct as T,g as E,gt as D,kt as O,lt as k,nt as A,pt as j,tt as M,v as N,w as P,wt as F,x as I,y as L}from"./index-jhYU37cm.js";import{t as R}from"./Description-BP4Ga-RV.js";import{t as z}from"./Instant-C9TZFyg5.js";import{l as B}from"./connections-DORVdX7a.js";import{n as V,t as ee}from"./Refusal-JlhK6Mh_.js";import{t as te}from"./Segmented-CR-Iqv1r.js";import{t as H}from"./Picker-BWWGdN86.js";import{t as U}from"./AdminOnly-DaihxNZC.js";var ne=n(`bell-plus`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M15 8h6`,key:`8ybuxh`}],[`path`,{d:`M18 5v6`,key:`g5ayrv`}],[`path`,{d:`M20.002 14.464a9 9 0 0 0 .738.863A1 1 0 0 1 20 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 8.75-5.332`,key:`1abcvy`}]]),re=n(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),W=e(t(),1),ie=[`run_failed`,`run_completed_with_errors`,`run_succeeded`,`run_stuck`],ae=[`pending`,`sending`,`sent`,`failed`],oe=`0s`;function se(e){return e===oe?`none`:e}function ce(e){return e.replaceAll(`_`,` `)}function le(e){return e.scope===`pipeline`&&e.pipeline!==null?e.pipeline:`every pipeline`}function ue(e){return e.active&&!e.paused}function de(e){return e===`sent`||e===`failed`}function fe(e,t=50){let n=new URLSearchParams({limit:String(t)});return e!==null&&n.set(`after`,e),`/alert-rules?${n.toString()}`}function pe(e){return a(fe(e))}function me(e){return i(`/alert-rules`,`POST`,e)}function he(e,t){return i(`/alert-rules/${encodeURIComponent(e)}`,`PATCH`,{paused:t})}function ge(e){return a(`/alert-rules/${encodeURIComponent(e)}`,{method:`DELETE`})}var _e={status:``,notifier:``};function ve(e,t,n=50){let r=new URLSearchParams({limit:String(n)});return e.status!==``&&r.set(`status`,e.status),e.notifier!==``&&r.set(`notifier`,e.notifier),t!==null&&r.set(`after`,t),`/notifications?${r.toString()}`}function ye(e,t){return a(ve(e,t))}function be(e){return a(`/notifications/${encodeURIComponent(e)}`)}function xe(e){return i(`/notifications/${encodeURIComponent(e)}/$retry`,`POST`,{})}function Se(e){return i(`/alert-rules/$test`,`POST`,e)}async function Ce(){return(await a(`/blocks`)).notifiers.map(e=>e.id)}function we(e,t){let n=[];for(let r of e){if(r===`log`){n.push({id:r,notifier:r,connection:null,reachable:!0,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}let e=t.filter(e=>e.kind===r);if(e.length===0){n.push({id:r,notifier:r,connection:null,reachable:!1,last_check_at:null,last_check_healthy:null,last_check_detail:null});continue}for(let t of e)n.push({id:`${r}:${t.code}`,notifier:r,connection:t.code,reachable:!0,last_check_at:t.last_check_at,last_check_healthy:t.last_check_healthy,last_check_detail:t.last_check_detail})}return n}function Te(e){return e.notifier===`log`?{tone:`good`,label:`built in`,detail:null}:e.reachable?e.last_check_at===null?{tone:`quiet`,label:`never checked`,detail:null}:{tone:e.last_check_healthy===!0?`good`:`critical`,label:e.last_check_healthy===!0?`checked`:`failing`,detail:e.last_check_detail}:{tone:`quiet`,label:`no connection`,detail:`Nothing delivers through this channel yet.`}}var G=l();function Ee({rule:e,onChanged:t,onDeleted:n,onTest:r}){let[i,a]=(0,W.useState)(!1),o=L(),c=(0,W.useCallback)(e=>ye(_e,e),[]),{state:l}=N(c,Oe),u=l.rows.filter(t=>t.rule===e.code);return(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,G.jsxs)(je,{thing:e,children:[e.paused&&(0,G.jsx)(Ae,{children:`paused`}),!e.active&&(0,G.jsx)(Ae,{children:`off`})]}),(0,G.jsx)(R,{text:e.description}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[(0,G.jsx)(q,{label:`Event`,children:ce(e.event)}),(0,G.jsx)(q,{label:`Scope`,children:le(e)}),(0,G.jsx)(q,{label:`Delivers through`,children:(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})}),(0,G.jsx)(q,{label:`Throttle`,children:se(e.throttle)}),e.template!==null&&(0,G.jsx)(q,{label:`Subject`,children:(0,G.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.template})}),(0,G.jsx)(q,{label:`Last sent`,children:e.last_sent_at===null?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,G.jsx)(z,{at:e.last_sent_at})})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:i||!o.may,title:o.why,onClick:()=>{a(!0),he(e.code,!e.paused).then(t,V).finally(()=>{a(!1)})},children:e.paused?`Resume`:`Pause`})}),(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:!o.may,title:o.why,onClick:r,children:`Send a test`})}),(0,G.jsx)(s,{why:o.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,className:`destructive-action ml-auto`,disabled:i||!o.may,title:o.why,onClick:()=>{a(!0),ge(e.code).then(n,V).finally(()=>{a(!1)})},children:`Delete`})})]}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`Recent deliveries`}),!l.read&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Reading from the server`}),l.read&&u.length===0&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Nothing sent.`}),(0,G.jsx)(`ul`,{className:`divide-border divide-y`,children:u.map(e=>(0,G.jsxs)(`li`,{className:`row-hover -mx-4 flex items-center gap-2 px-4 py-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs`,children:e.subject}),(0,G.jsx)(z,{className:`text-faint shrink-0 text-xs`,at:e.created_at})]},e.id))})]})]})}function De({notification:e,onChanged:t}){let[n,i]=(0,W.useState)(!1),a=L();return(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,G.jsx)(`div`,{className:`space-y-1`,children:(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:e.subject})]})}),(0,G.jsxs)(`dl`,{className:`space-y-1.5`,children:[e.rule===null?(0,G.jsx)(q,{label:`Raised by`,children:(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`a test, not a rule`})}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(q,{label:`Event`,children:ce(e.event)}),(0,G.jsx)(q,{label:`Rule`,children:(0,G.jsx)(`span`,{className:`font-mono text-xs`,children:e.rule})})]}),(0,G.jsx)(q,{label:`Delivers through`,children:(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})}),(0,G.jsx)(q,{label:`Run`,children:(0,G.jsx)(ke,{notification:e})}),(0,G.jsx)(q,{label:`Queued`,children:(0,G.jsx)(z,{at:e.created_at})}),e.status===`sent`?(0,G.jsx)(q,{label:`Sent`,children:(0,G.jsx)(z,{at:e.sent_at})}):(0,G.jsx)(q,{label:`Next try`,children:(0,G.jsx)(z,{at:e.available_at})}),(0,G.jsxs)(q,{label:`Attempts`,children:[e.attempt,` of `,e.max_attempts]})]}),e.error!==null&&(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:`What the channel said`}),(0,G.jsx)(`p`,{className:`text-critical text-xs break-words`,children:e.error}),(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:`Only the latest refusal is kept. Earlier attempts are counted, not stored.`})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(s,{why:a.why,children:(0,G.jsx)(d,{variant:`outline`,size:`sm`,disabled:n||!a.may,title:a.why,onClick:()=>{i(!0),xe(e.id).then(t,V).finally(()=>{i(!1)})},children:`Retry now`})}),e.run_id!==null&&(0,G.jsx)(d,{variant:`outline`,size:`sm`,render:(0,G.jsx)(r,{to:`/runs/${e.run_id}`}),children:`Open the run`})]})]})}var Oe=e=>e.id;function K({notifier:e,connection:t}){return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:e}),t!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t})]})}function ke({notification:e}){if(e.run_id===null)return(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`no run`});let t=e.run_pipeline??`a run`;return(0,G.jsxs)(r,{className:`text-primary hover:underline`,to:`/runs/${e.run_id}`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:t}),e.run_started_at!==null&&(0,G.jsx)(z,{className:`text-muted-foreground ml-1.5 text-xs`,at:e.run_started_at})]})}function Ae({children:e}){return(0,G.jsx)(`span`,{className:`border-border text-muted-foreground rounded-sm border px-1.5 text-xs`,children:e})}function je({thing:e,children:t}){let n=p(e);return(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:n.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:n.title}),t,n.code!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:n.code})]})}function q({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`dt`,{className:`text-muted-foreground w-32 shrink-0 text-xs`,children:e}),(0,G.jsx)(`dd`,{className:`min-w-0 text-sm`,children:t})]})}var Me={good:`var(--good)`,critical:`var(--critical)`,quiet:`var(--faint)`};function Ne({channels:e}){return(0,G.jsx)(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:e.map(e=>(0,G.jsx)(Pe,{channel:e},e.id))})}function Pe({channel:e}){let t=Te(e);return(0,G.jsxs)(`li`,{className:`border-border bg-card flex items-start justify-between gap-3 rounded-lg border p-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,title:e.connection===null?e.notifier:`${e.notifier} ${e.connection}`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,style:{"--chip":Me[t.tone]}}),(0,G.jsx)(`span`,{className:`shrink-0 text-sm font-medium`,children:e.notifier}),e.connection!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground truncate font-mono text-xs`,children:e.connection})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 flex-col items-end`,children:[(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:t.label}),e.last_check_at!==null&&(0,G.jsx)(z,{className:`text-faint text-xs`,at:e.last_check_at}),t.detail!==null&&(0,G.jsx)(`span`,{className:`text-faint max-w-48 truncate text-xs`,title:t.detail,children:t.detail})]})]})}function J({id:e,label:t,value:n,onChange:r,placeholder:i,mono:a,hint:o}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:t}),(0,G.jsx)(f,{id:e,className:a===!0?`font-mono`:void 0,spellCheck:!1,autoComplete:`off`,value:n,placeholder:i,onChange:e=>{r(e.target.value)}}),o!==void 0&&(0,G.jsx)(`p`,{className:`text-faint text-xs`,children:o})]})}function Fe({id:e,notifiers:t,value:n,onChange:r}){return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:`Notifier`}),(0,G.jsx)(H,{id:e,label:`Notifier`,value:n,options:t.map(e=>({value:e,label:e,aside:``})),placeholder:`Search the installed channels`,onChange:r})]})}function Ie({id:e,kind:t,value:n,onChange:r}){let i=Le(t);return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:e,children:`Connection`}),(0,G.jsx)(H,{id:e,label:`Connection`,value:n,options:i,placeholder:i.length===0?`No ${t} connection yet`:`Search by name or code`,onChange:r})]})}function Le(e){let[t,n]=(0,W.useState)([]);return(0,W.useEffect)(()=>{if(e===``||e===`log`)return;let t=!0;return B().then(e=>{t&&n(e.items)},()=>{t&&n([])}),()=>{t=!1}},[e]),t.filter(t=>t.kind===e).map(e=>{let t=p(e);return{value:e.code,label:t.title,aside:t.code??``}})}var Re=/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/u,ze=/^(?:\d+(?:ms|s|m|h|d|w))+$/u,Be="${run.*} may read the run's pipeline, status, id, error, trigger, duration_ms and url.",Ve=[{value:`global`,label:`Every pipeline`},{value:`pipeline`,label:`One pipeline`}],Y={run_failed:`Failed`,run_completed_with_errors:`Completed with errors`,run_succeeded:`Succeeded`,run_stuck:`Stuck`};function X(e){return e!==``&&e!==`log`}function He(e){if(e.code.trim()===``)return`A rule is addressed by its code, and this one has none.`;if(!Re.test(e.code.trim()))return`A code is lowercase words joined by - or _.`;if(e.scope===`pipeline`&&e.pipeline===``)return`A rule watching one pipeline names that pipeline, and this one names none.`;if(e.notifier===``)return`A rule delivers through a channel, and this one names none.`;if(X(e.notifier)&&e.connection===``)return`The ${e.notifier} channel delivers through a connection, and this one names none.`;if(!ze.test(e.throttle.trim()))return`A throttle is a duration, such as 15m.`}function Ue(e,t){if(e===``)return`A test goes through a channel, and this one names none.`;if(X(e)&&t===``)return`The ${e} channel delivers through a connection, and this one names none.`}var We=`0s`;function Ge({open:e,onOpenChange:t,notifiers:n,onCreated:r}){let[i,a]=(0,W.useState)(``),[o,c]=(0,W.useState)(``),[l,f]=(0,W.useState)(``),[p,m]=(0,W.useState)(`run_failed`),[h,v]=(0,W.useState)(`global`),[y,S]=(0,W.useState)(``),[T,E]=(0,W.useState)(``),[D,k]=(0,W.useState)(``),[A,j]=(0,W.useState)(``),[M,N]=(0,W.useState)(We),[P,I]=(0,W.useState)(null),[R,z]=(0,W.useState)(!1),B=Ke(e),V=L(),U=w(V.why,He({code:i,scope:h,pipeline:y,notifier:T,connection:D,throttle:M}));return(0,G.jsx)(g,{open:e,onOpenChange:t,children:(0,G.jsxs)(C,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,G.jsx)(x,{children:(0,G.jsx)(O,{children:`New rule`})}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(J,{id:`rule-code`,label:`Code`,value:i,onChange:a,placeholder:`ops-slack-failed`,mono:!0}),(0,G.jsx)(J,{id:`rule-name`,label:`Name`,value:o,onChange:c,placeholder:`Tell the ops channel`})]}),(0,G.jsx)(J,{id:`rule-description`,label:`Description`,value:l,onChange:f,placeholder:`What this rule is for`}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{children:`Event`}),(0,G.jsx)(te,{label:`Event`,size:`md`,value:p,options:ie.map(e=>({value:e,label:Y[e]})),onChoose:m})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{children:`Scope`}),(0,G.jsx)(te,{label:`Scope`,size:`md`,value:h,options:Ve,onChoose:v})]}),h===`pipeline`&&(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(b,{htmlFor:`rule-pipeline`,children:`Pipeline`}),(0,G.jsx)(H,{id:`rule-pipeline`,label:`Pipeline`,value:y,options:B,placeholder:`Search by name or code`,onChange:S})]})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(Fe,{id:`rule-notifier`,notifiers:n,value:T,onChange:e=>{E(e),k(``)}}),X(T)&&(0,G.jsx)(Ie,{id:`rule-connection`,kind:T,value:D,onChange:k})]}),(0,G.jsx)(J,{id:`rule-subject`,label:`Subject`,value:A,onChange:j,placeholder:"${run.pipeline} run ${run.status}",mono:!0,hint:Be}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:(0,G.jsx)(J,{id:`rule-throttle`,label:`Throttle`,value:M,onChange:N,placeholder:`15m`,mono:!0})}),P!==null&&(0,G.jsx)(ee,{problem:P}),(0,G.jsxs)(_,{children:[(0,G.jsx)(`p`,{className:`text-muted-foreground mr-auto self-center text-xs`,children:`A rule fires when a run settles. Nothing is sent now.`}),(0,G.jsx)(F,{render:(0,G.jsx)(d,{variant:`ghost`}),children:`Close`}),(0,G.jsx)(s,{why:U,children:(0,G.jsx)(d,{disabled:R||U!==void 0,title:U,onClick:()=>{z(!0),I(null),me({code:i.trim(),name:Z(o),description:Z(l),event:p,notifier:T,scope:h,pipeline:h===`pipeline`?y:null,connection:X(T)?D:null,template:Z(A),throttle:M.trim()}).then(()=>{r(),a(``),c(``),f(``),j(``),t(!1)},e=>{I(u(e))}).finally(()=>{z(!1)})},children:R?`Creating`:`Create`})})]})]})})}function Z(e){let t=e.trim();return t===``?null:t}function Ke(e){let[t,n]=(0,W.useState)([]);return(0,W.useEffect)(()=>{if(!e)return;let t=!0;return h().then(e=>{t&&n(e.toSorted(m).map(e=>{let t=p(e);return{value:e.code,label:t.title,aside:t.code??``}}))},()=>{t&&n([])}),()=>{t=!1}},[e]),t}var qe=1e3,Je=6e4,Ye=`dirigent test alert`,Q={notifier:``,connection:``,subject:``};function Xe({open:e,draft:t,onOpenChange:n,notifiers:r,onQueued:i,onOpenQueue:a}){let[o,c]=(0,W.useState)(t.notifier),[l,f]=(0,W.useState)(t.connection),[p,m]=(0,W.useState)(t.subject),[h,y]=(0,W.useState)(null),[b,S]=(0,W.useState)(null),[T,E]=(0,W.useState)(!1),D=Qe(h),k=L(),A=D!==null&&de(D.status)?D.id:null;(0,W.useEffect)(()=>{A!==null&&i()},[A]);let j=w(k.why,Ue(o,l));return(0,G.jsx)(g,{open:e,onOpenChange:n,children:(0,G.jsxs)(C,{className:`sm:max-w-lg`,showCloseButton:!1,children:[(0,G.jsxs)(x,{children:[(0,G.jsx)(O,{children:`Send a test`}),(0,G.jsx)(v,{children:`The message goes through the same queue a real alert does, and a worker delivers it.`})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(Fe,{id:`test-notifier`,notifiers:r,value:o,onChange:e=>{c(e),f(``)}}),X(o)&&(0,G.jsx)(Ie,{id:`test-connection`,kind:o,value:l,onChange:f})]}),(0,G.jsx)(J,{id:`test-subject`,label:`Subject`,value:p,onChange:m,placeholder:Ye}),b!==null&&(0,G.jsx)(ee,{problem:b}),D!==null&&(0,G.jsx)(Ze,{row:D}),(0,G.jsxs)(_,{children:[(0,G.jsx)(F,{render:(0,G.jsx)(d,{variant:`ghost`}),children:`Close`}),h!==null&&(0,G.jsx)(d,{variant:`outline`,onClick:()=>{a(h)},children:`Open in the queue`}),(0,G.jsx)(s,{why:j,children:(0,G.jsx)(d,{disabled:T||j!==void 0,title:j,onClick:()=>{E(!0),S(null),y(null),Se({notifier:o,connection:X(o)?l:null,...p.trim()===``?{}:{subject:p.trim()}}).then(e=>{y(e.notification_id),i()},e=>{S(u(e))}).finally(()=>{E(!1)})},children:h===null?`Send`:`Send again`})})]})]})})}function Ze({row:e}){return(0,G.jsxs)(`div`,{className:`border-border bg-secondary/40 space-y-2 rounded-lg border p-3`,"data-testid":`test-delivery`,"aria-live":`polite`,children:[(0,G.jsxs)(`p`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(I,{status:e.status}),(0,G.jsx)(`span`,{className:`text-sm`,children:e.subject})]}),(0,G.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:e.status===`sent`?(0,G.jsxs)(G.Fragment,{children:[`Delivered `,(0,G.jsx)(z,{at:e.sent_at}),`.`]}):e.status===`failed`?(0,G.jsxs)(G.Fragment,{children:[`Given up after `,e.attempt,` of `,e.max_attempts,` attempts.`]}):e.attempt===0?`Queued for the next worker pass.`:(0,G.jsxs)(G.Fragment,{children:[`Attempt `,e.attempt,` of `,e.max_attempts,`, next try `,(0,G.jsx)(z,{at:e.available_at}),`.`]})}),e.error!==null&&(0,G.jsx)(`p`,{className:`text-critical text-xs break-words`,children:e.error})]})}function Qe(e){let[t,n]=(0,W.useState)(null);return(0,W.useEffect)(()=>{if(e===null)return;let t=!0,r,i=Date.now()+Je,a=()=>{be(e).then(o=>{t&&(n({id:e,row:o}),!(de(o.status)||Date.now()>i)&&(r=setTimeout(a,qe)))},()=>{})};return a(),()=>{t=!1,r!==void 0&&clearTimeout(r)}},[e]),t!==null&&t.id===e?t.row:null}var $e=e=>e.id,et=e=>e.id;function tt(){return(0,G.jsx)(U,{children:(0,G.jsx)(nt,{})})}function nt(){let[e,t]=(0,W.useState)(!1),[n,r]=(0,W.useState)(null),[i,a]=(0,W.useState)(null),[s,l]=(0,W.useState)(null),[u,d]=(0,W.useState)({status:``,notifier:``}),[f,p]=(0,W.useState)({}),[m,h]=(0,W.useState)({}),g=N((0,W.useCallback)(e=>pe(e),[]),$e),_=N((0,W.useCallback)(e=>ye(u,e),[u]),et),v=it(),{reload:b}=g,{reload:x}=_,C=(0,W.useMemo)(()=>g.state.rows.map(e=>f[e.id]??e),[f,g.state.rows]),w=(0,W.useMemo)(()=>_.state.rows.map(e=>m[e.id]??e),[m,_.state.rows]),O=C.find(e=>e.id===i)??null,F=w.find(e=>e.id===s)??null,R=(0,W.useCallback)(e=>{r(t=>({draft:e,opened:(t?.opened??0)+1}))},[]);(0,W.useEffect)(()=>(A({note:null,tone:`quiet`,identifier:null}),M),[]),(0,W.useEffect)(()=>{if(O!==null){let e=O;return T([{id:`rule`,label:`Rule`,render:()=>(0,G.jsx)(Ee,{rule:e,onChanged:e=>{p(t=>({...t,[e.id]:e}))},onDeleted:()=>{a(null),b()},onTest:()=>{R({notifier:e.notifier,connection:e.connection??``,subject:``})}})}],{screen:`alerting`})}if(F!==null){let e=F;return T([{id:`notification`,label:`Notification`,render:()=>(0,G.jsx)(De,{notification:e,onChanged:e=>{h(t=>({...t,[e.id]:e}))}})}],{screen:`alerting`})}},[F,O,R,b]);let z=L(`admin`),B=z.may;return(0,W.useEffect)(()=>D([...B?[{id:`alerting:rule`,title:`New alert rule`,group:j,screen:!0,icon:ne,keywords:[`alert`,`event`,`create`],run:()=>{t(!0)}},{id:`alerting:test`,title:`Send a test through a channel`,group:j,screen:!0,icon:re,keywords:[`alert`,`notification`,`try`],run:()=>{R(Q)}}]:[],{id:`alerting:reload`,title:`Read the alert rules again`,group:j,screen:!0,icon:y,keywords:[`refresh`,`reload`],run:()=>{b(),x()}}]),[B,R,x,b]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(c,{title:`Alerting`,aside:(0,G.jsx)(S,{tag:`alerts`}),actions:[{id:`test`,label:`Send a test`,icon:re,variant:`outline`,disabled:!z.may,why:z.why,onClick:()=>{R(Q)}},{id:`rule`,label:`New rule`,icon:ne,disabled:!z.may,why:z.why,onClick:()=>{t(!0)}}]}),(0,G.jsxs)(`section`,{className:`mb-6 space-y-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Channels`}),v.read?v.rows.length===0?(0,G.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`No channel is installed.`}):(0,G.jsx)(Ne,{channels:v.rows}):(0,G.jsx)(`p`,{className:`text-faint text-sm`,children:`Reading from the server`})]}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Rules`}),(0,G.jsx)(o,{loading:!g.state.read,problem:g.state.problem,empty:C.length===0,emptyMessage:`No rules.`,children:(0,G.jsx)(P,{columns:at,rows:C,rowKey:$e,rowClassName:e=>ue(e)?void 0:`opacity-60`,reading:g.state.reading,next:g.state.next,onMore:g.more,noun:`rules`,onSelect:e=>{l(null),a(e.id),k()},selected:e=>e.id===i})})]}),(0,G.jsxs)(`section`,{className:`mt-8 space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Notifications`}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsx)(E,{label:`Status`,value:u.status,anything:`Any status`,options:ae.map(e=>({value:e,label:e,mark:(0,G.jsx)(I,{status:e})})),onChange:e=>{d(t=>({...t,status:e}))}}),(0,G.jsx)(E,{label:`Notifier`,value:u.notifier,anything:`Any notifier`,options:rt(v.rows),onChange:e=>{d(t=>({...t,notifier:e}))}})]})]}),(0,G.jsx)(o,{loading:!_.state.read,problem:_.state.problem,empty:w.length===0,emptyMessage:`Nothing queued.`,children:(0,G.jsx)(P,{columns:ot,rows:w,rowKey:et,reading:_.state.reading,next:_.state.next,onMore:_.more,noun:`notifications`,onSelect:e=>{a(null),l(e.id),k()},selected:e=>e.id===s})})]}),(0,G.jsx)(Ge,{open:e,onOpenChange:t,notifiers:$(v.rows),onCreated:b}),(0,G.jsx)(Xe,{open:n!==null,draft:n?.draft??Q,onOpenChange:e=>{e||r(null)},notifiers:$(v.rows),onQueued:x,onOpenQueue:e=>{r(null),a(null),l(e),x(),k()}},n?.opened??0)]})}function $(e){return[...new Set(e.map(e=>e.notifier))]}function rt(e){return $(e).map(e=>({value:e,label:e}))}function it(){let[e,t]=(0,W.useState)(null),[n,r]=(0,W.useState)(null);return(0,W.useEffect)(()=>{let e=!0;return Ce().then(n=>{e&&t(n)},()=>{e&&t([])}),B().then(t=>{e&&r(t.items)},()=>{e&&r([])}),()=>{e=!1}},[]),{rows:(0,W.useMemo)(()=>we(e??[],n??[]),[n,e]),read:e!==null&&n!==null}}var at=[{id:`rule`,header:`Rule`,cell:e=>{let t=p(e);return(0,G.jsxs)(`span`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,G.jsx)(`span`,{className:t.named?`text-sm font-medium`:`font-mono text-sm font-medium`,children:t.title}),t.code!==null&&(0,G.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.code})]})}},{id:`event`,header:`Event`,cell:e=>(0,G.jsx)(`span`,{className:`text-sm`,children:Y[e.event]})},{id:`scope`,header:`Scope`,cell:e=>(0,G.jsx)(`span`,{className:e.scope===`pipeline`?`font-mono text-xs`:`text-sm`,children:le(e)})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})},{id:`throttle`,header:`Throttle`,className:`font-mono text-xs`,cell:e=>(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:se(e.throttle)})},{id:`sent`,header:`Last sent`,className:`text-xs`,cell:e=>e.last_sent_at===null?(0,G.jsx)(`span`,{className:`text-muted-foreground`,children:`never`}):(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.last_sent_at})},{id:`live`,header:`State`,cell:e=>e.paused?(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`paused`}):e.active?(0,G.jsx)(`span`,{className:`text-good text-xs`,children:`active`}):(0,G.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`off`})}],ot=[{id:`status`,header:`Status`,cell:e=>(0,G.jsx)(I,{status:e.status})},{id:`subject`,header:`Subject`,cell:e=>(0,G.jsxs)(`span`,{className:`flex flex-col`,children:[(0,G.jsx)(`span`,{className:`text-sm`,children:e.subject}),e.error!==null&&(0,G.jsx)(`span`,{className:`text-critical max-w-96 truncate text-xs`,title:e.error,children:e.error})]})},{id:`delivers`,header:`Delivers through`,cell:e=>(0,G.jsx)(K,{notifier:e.notifier,connection:e.connection})},{id:`run`,header:`Run`,cell:e=>(0,G.jsx)(ke,{notification:e})},{id:`queued`,header:`Queued`,className:`text-xs`,cell:e=>(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.created_at})},{id:`sent`,header:`Sent`,className:`text-xs`,cell:e=>e.status===`sent`?(0,G.jsx)(z,{className:`text-muted-foreground`,at:e.sent_at}):e.attempt>0?(0,G.jsxs)(`span`,{className:`text-faint`,children:[e.attempt,` of `,e.max_attempts,` attempts`]}):null}];export{tt as AdminAlerting};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{n,t as r}from"./PageState-CvfT4nGl.js";import{r as i}from"./utils-CRMSf51M.js";import{t as a}from"./input-o9l61NKa.js";import{T as o,_ as s,ct as c,lt as l,nt as u,tt as d,w as f}from"./index-fYbFix6w.js";import{t as p}from"./Markdown-CttJCcht.js";import{t as m}from"./KindChip-CuBFi3X9.js";import{a as h,c as g,l as _,n as v,o as y,r as b,t as x}from"./blocks-DkD_WaQ6.js";import{n as S,r as C}from"./Panel-Cb5LtMYX.js";import{r as w}from"./schema-form-FkbdR3oI.js";var T=e(t(),1),E=i(),D=e=>e.id,O=[{key:`scheme`,title:`Storage schemes`,noun:`schemes`},{key:`notifier`,title:`Notifiers`,noun:`notifiers`},{key:`connection`,title:`Connection kinds`,noun:`connection kinds`}],k=e=>t=>`${e}:${t.id}`,A=()=>{};function j(){let[e,t]=(0,T.useState)(``),[i,p]=(0,T.useState)(null),{value:m,problem:_,read:v}=s(g),b=(0,T.useMemo)(()=>m?.blocks??[],[m]),S=(0,T.useMemo)(()=>h(b,e),[b,e]),C=(0,T.useMemo)(()=>x(S),[S]),w=(0,T.useMemo)(()=>y(m?.storage_schemes??[],e),[m,e]),j=(0,T.useMemo)(()=>y(m?.notifiers??[],e),[m,e]),I=(0,T.useMemo)(()=>y(m?.connection_kinds??[],e),[m,e]),L=b.find(e=>`block:${e.id}`===i)??null,R={scheme:w,notifier:j,connection:I},z=O.flatMap(e=>R[e.key].map(t=>({registry:e,entry:t}))).find(({registry:e,entry:t})=>k(e.key)(t)===i)??null;(0,T.useEffect)(()=>{if(v)return u({note:null,tone:`quiet`,identifier:null}),d},[b,v,m]),(0,T.useEffect)(()=>{if(L!==null)return c([{id:`block`,label:`Block`,render:()=>(0,E.jsx)(F,{entry:L})}],{screen:`blocks`});if(z!==null){let{registry:e,entry:t}=z;return c([{id:`entry`,label:e.title,render:()=>(0,E.jsx)(P,{entry:t})}],{screen:`blocks`})}},[L,z]);let B=(0,T.useCallback)(e=>{p(`block:${e.id}`),l()},[]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(r,{title:`Blocks`,aside:(0,E.jsx)(o,{tag:`blocks`})}),(0,E.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,E.jsx)(a,{className:`w-56`,value:e,onChange:e=>{t(e.target.value)},placeholder:`Search blocks`,"aria-label":`Search blocks by id or summary`})}),(0,E.jsx)(n,{loading:!v,problem:_,empty:S.length===0&&w.length===0&&j.length===0&&I.length===0,emptyMessage:b.length===0?`No blocks installed — plugins contribute them.`:`Nothing in the catalog matches that.`,children:(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C.map(([e,t])=>(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`text-faint mb-1.5 font-mono text-xs font-semibold tracking-wide uppercase`,children:e}),(0,E.jsx)(f,{chrome:{footer:!1},fixed:!0,columns:M,rows:t,rowKey:D,reading:!1,next:null,onMore:A,noun:`blocks`,onSelect:B,selected:e=>`block:${e.id}`===i})]},e)),O.map(e=>{let t=R[e.key];return t.length===0?null:(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`text-faint mb-1.5 font-mono text-xs font-semibold tracking-wide uppercase`,children:e.title}),(0,E.jsx)(f,{chrome:{footer:!1},fixed:!0,columns:N(e.key),rows:t,rowKey:k(e.key),reading:!1,next:null,onMore:A,noun:e.noun,onSelect:t=>{p(k(e.key)(t)),l()},selected:t=>k(e.key)(t)===i})]},e.key)})]})})]})}var M=[{id:`block`,header:`Block`,className:`w-full max-w-0`,cell:e=>(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,title:e.summary,children:e.summary})]})},{id:`kind`,header:`Kind`,className:`w-32 whitespace-nowrap`,cell:e=>(0,E.jsx)(m,{kind:e.kind})},{id:`plugin`,header:`Plugin`,className:`w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}];function N(e){let t=e===`scheme`?`storage`:e;return[{id:`entry`,header:`Entry`,className:`w-full max-w-0`,cell:e=>{let t=typeof e.config_schema.description==`string`?e.config_schema.description:``;return(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,title:t,children:t})]})}},{id:`kind`,header:`Kind`,className:`w-32 whitespace-nowrap`,cell:()=>(0,E.jsx)(m,{kind:t})},{id:`plugin`,header:`Plugin`,className:`w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function P({entry:e}){let t=(0,T.useMemo)(()=>w(e.config_schema),[e]),n=typeof e.config_schema.description==`string`?e.config_schema.description:null;return(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),n!==null&&(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n}),(0,E.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:(0,E.jsx)(S,{term:`plugin`,detail:e.plugin})})]}),(0,E.jsx)(C,{title:`Config`,children:t.length===0?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This takes no configuration.`}):(0,E.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,E.jsx)(I,{field:e},e.name))})})]})}function F({entry:e}){let t=(0,T.useMemo)(()=>w(e.config_schema),[e]),n=b(e);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{children:(0,E.jsx)(m,{kind:e.kind})}),(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.summary})]}),(0,E.jsx)(C,{title:`Facts`,children:(0,E.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:n.map(e=>(0,E.jsx)(S,{term:e.term,detail:e.detail},e.term))})}),(0,E.jsx)(C,{title:`Config`,children:t.length===0?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This block takes no configuration.`}):(0,E.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,E.jsx)(I,{field:e},e.name))})})]})}function I({field:e}){let t=v(e);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,E.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:_(e)}),e.required&&(0,E.jsx)(`span`,{className:`text-primary text-xs`,children:`required`}),e.hint!==null&&(0,E.jsx)(`span`,{className:`text-faint text-xs`,children:e.hint}),t!==null&&(0,E.jsxs)(`span`,{className:`text-faint text-xs`,children:[`default `,t]})]}),e.options.length>0&&(0,E.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:e.options.map(e=>e.label).join(` · `)}),e.help!==null&&(0,E.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,E.jsx)(p,{text:e.help})})]})}export{j as Blocks};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{n,t as r}from"./PageState-CvfT4nGl.js";import{r as i}from"./utils-CRMSf51M.js";import{t as a}from"./input-o9l61NKa.js";import{T as o,_ as s,ct as c,lt as l,nt as u,tt as d,w as f}from"./index-jhYU37cm.js";import{t as p}from"./Markdown-CttJCcht.js";import{t as m}from"./KindChip-CuBFi3X9.js";import{a as h,c as g,l as _,n as v,o as y,r as b,t as x}from"./blocks-DkD_WaQ6.js";import{n as S,r as C}from"./Panel-Cb5LtMYX.js";import{r as w}from"./schema-form-FkbdR3oI.js";var T=e(t(),1),E=i(),D=e=>e.id,O=[{key:`scheme`,title:`Storage schemes`,noun:`schemes`},{key:`notifier`,title:`Notifiers`,noun:`notifiers`},{key:`connection`,title:`Connection kinds`,noun:`connection kinds`}],k=e=>t=>`${e}:${t.id}`,A=()=>{};function j(){let[e,t]=(0,T.useState)(``),[i,p]=(0,T.useState)(null),{value:m,problem:_,read:v}=s(g),b=(0,T.useMemo)(()=>m?.blocks??[],[m]),S=(0,T.useMemo)(()=>h(b,e),[b,e]),C=(0,T.useMemo)(()=>x(S),[S]),w=(0,T.useMemo)(()=>y(m?.storage_schemes??[],e),[m,e]),j=(0,T.useMemo)(()=>y(m?.notifiers??[],e),[m,e]),I=(0,T.useMemo)(()=>y(m?.connection_kinds??[],e),[m,e]),L=b.find(e=>`block:${e.id}`===i)??null,R={scheme:w,notifier:j,connection:I},z=O.flatMap(e=>R[e.key].map(t=>({registry:e,entry:t}))).find(({registry:e,entry:t})=>k(e.key)(t)===i)??null;(0,T.useEffect)(()=>{if(v)return u({note:null,tone:`quiet`,identifier:null}),d},[b,v,m]),(0,T.useEffect)(()=>{if(L!==null)return c([{id:`block`,label:`Block`,render:()=>(0,E.jsx)(F,{entry:L})}],{screen:`blocks`});if(z!==null){let{registry:e,entry:t}=z;return c([{id:`entry`,label:e.title,render:()=>(0,E.jsx)(P,{entry:t})}],{screen:`blocks`})}},[L,z]);let B=(0,T.useCallback)(e=>{p(`block:${e.id}`),l()},[]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(r,{title:`Blocks`,aside:(0,E.jsx)(o,{tag:`blocks`})}),(0,E.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2`,children:(0,E.jsx)(a,{className:`w-56`,value:e,onChange:e=>{t(e.target.value)},placeholder:`Search blocks`,"aria-label":`Search blocks by id or summary`})}),(0,E.jsx)(n,{loading:!v,problem:_,empty:S.length===0&&w.length===0&&j.length===0&&I.length===0,emptyMessage:b.length===0?`No blocks installed — plugins contribute them.`:`Nothing in the catalog matches that.`,children:(0,E.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[C.map(([e,t])=>(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`text-faint mb-1.5 font-mono text-xs font-semibold tracking-wide uppercase`,children:e}),(0,E.jsx)(f,{chrome:{footer:!1},fixed:!0,columns:M,rows:t,rowKey:D,reading:!1,next:null,onMore:A,noun:`blocks`,onSelect:B,selected:e=>`block:${e.id}`===i})]},e)),O.map(e=>{let t=R[e.key];return t.length===0?null:(0,E.jsxs)(`section`,{children:[(0,E.jsx)(`h2`,{className:`text-faint mb-1.5 font-mono text-xs font-semibold tracking-wide uppercase`,children:e.title}),(0,E.jsx)(f,{chrome:{footer:!1},fixed:!0,columns:N(e.key),rows:t,rowKey:k(e.key),reading:!1,next:null,onMore:A,noun:e.noun,onSelect:t=>{p(k(e.key)(t)),l()},selected:t=>k(e.key)(t)===i})]},e.key)})]})})]})}var M=[{id:`block`,header:`Block`,className:`w-full max-w-0`,cell:e=>(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,title:e.summary,children:e.summary})]})},{id:`kind`,header:`Kind`,className:`w-32 whitespace-nowrap`,cell:e=>(0,E.jsx)(m,{kind:e.kind})},{id:`plugin`,header:`Plugin`,className:`w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}];function N(e){let t=e===`scheme`?`storage`:e;return[{id:`entry`,header:`Entry`,className:`w-full max-w-0`,cell:e=>{let t=typeof e.config_schema.description==`string`?e.config_schema.description:``;return(0,E.jsxs)(`div`,{className:`min-w-0`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{className:`text-muted-foreground truncate text-xs`,title:t,children:t})]})}},{id:`kind`,header:`Kind`,className:`w-32 whitespace-nowrap`,cell:()=>(0,E.jsx)(m,{kind:t})},{id:`plugin`,header:`Plugin`,className:`w-36 font-mono text-xs whitespace-nowrap`,cell:e=>(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:e.plugin})}]}function P({entry:e}){let t=(0,T.useMemo)(()=>w(e.config_schema),[e]),n=typeof e.config_schema.description==`string`?e.config_schema.description:null;return(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),n!==null&&(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:n}),(0,E.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:(0,E.jsx)(S,{term:`plugin`,detail:e.plugin})})]}),(0,E.jsx)(C,{title:`Config`,children:t.length===0?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This takes no configuration.`}):(0,E.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,E.jsx)(I,{field:e},e.name))})})]})}function F({entry:e}){let t=(0,T.useMemo)(()=>w(e.config_schema),[e]),n=b(e);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,E.jsxs)(`div`,{className:`space-y-1`,children:[(0,E.jsx)(`h2`,{className:`font-mono text-sm font-semibold`,children:e.id}),(0,E.jsx)(`p`,{children:(0,E.jsx)(m,{kind:e.kind})}),(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:e.summary})]}),(0,E.jsx)(C,{title:`Facts`,children:(0,E.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:n.map(e=>(0,E.jsx)(S,{term:e.term,detail:e.detail},e.term))})}),(0,E.jsx)(C,{title:`Config`,children:t.length===0?(0,E.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`This block takes no configuration.`}):(0,E.jsx)(`div`,{className:`flex flex-col gap-4`,children:t.map(e=>(0,E.jsx)(I,{field:e},e.name))})})]})}function I({field:e}){let t=v(e);return(0,E.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,E.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.name}),(0,E.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:_(e)}),e.required&&(0,E.jsx)(`span`,{className:`text-primary text-xs`,children:`required`}),e.hint!==null&&(0,E.jsx)(`span`,{className:`text-faint text-xs`,children:e.hint}),t!==null&&(0,E.jsxs)(`span`,{className:`text-faint text-xs`,children:[`default `,t]})]}),e.options.length>0&&(0,E.jsx)(`p`,{className:`text-muted-foreground font-mono text-xs`,children:e.options.map(e=>e.label).join(` · `)}),e.help!==null&&(0,E.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:(0,E.jsx)(p,{text:e.help})})]})}export{j as Blocks};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{i as n}from"./store-CVrCnru0.js";import{a as r,i,n as a,r as o,t as s}from"./select-BzYLXMEI.js";import{n as c,o as l,t as u}from"./PageState-CvfT4nGl.js";import{r as d}from"./utils-CRMSf51M.js";import{d as f,f as p}from"./paging-MGEIXfCZ.js";import{t as m}from"./input-o9l61NKa.js";import{t as h}from"./SchemaForm-Cg8Z7V7H.js";import{t as g}from"./textarea-XMYmRm72.js";import{d as _,l as v,s as y}from"./format-CR2ze2LO.js";import{n as b,t as x}from"./identity-BNZxCf_y.js";import{Ct as S,Dt as C,Et as w,Ft as T,O as E,Ot as D,T as O,Tt as k,b as ee,ct as A,gt as j,ht as M,kt as te,lt as N,nt as P,tt as F,v as I,w as L,wt as ne,y as R}from"./index-fYbFix6w.js";import{t as z}from"./KindChip-CuBFi3X9.js";import{t as B}from"./Description-BP4Ga-RV.js";import{t as V}from"./Instant-C9TZFyg5.js";import{a as H,l as re,u as ie}from"./schema-form-FkbdR3oI.js";import{a as U,c as W,d as G,f as K,i as ae,l as q,o as oe,p as J,r as Y,s as se,t as ce,u as X}from"./connections-DORVdX7a.js";import{n as le,t as ue}from"./Refusal-D4_PzLAl.js";var de=n(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Z=e(t(),1),Q=d();function fe({id:e,name:t,stored:n,value:r,onChange:i}){return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:e,className:`font-mono text-sm font-medium`,children:t}),(0,Q.jsx)(m,{id:e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>{i(e.target.value)},placeholder:n?`stored — typing replaces it, blank keeps it`:`not set — type to set one`})]})}function pe({connection:e,schema:t,onSaved:n}){let[r,i]=(0,Z.useState)(e.name??``),[a,o]=(0,Z.useState)(e.description??``),[s,c]=(0,Z.useState)(()=>he(e)),[u,d]=(0,Z.useState)({}),[v,y]=(0,Z.useState)(()=>new Set),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1),O=x(e),k=(0,Z.useMemo)(()=>me(e,t),[e,t]),A=(0,Z.useMemo)(()=>re(k,s),[k,s]),j=R(`admin`),M=ee(j.why,H(A,v)?void 0:`A setting above is not what this kind accepts.`);return(0,Q.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:O.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:O.title}),(0,Q.jsx)(z,{kind:e.kind}),O.code!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:O.code})]}),(0,Q.jsxs)(`p`,{className:`text-faint text-xs`,children:[`Created `,(0,Q.jsx)(V,{at:e.created_at}),_(e.created_at,e.updated_at)&&(0,Q.jsxs)(Q.Fragment,{children:[` · updated `,(0,Q.jsx)(V,{at:e.updated_at})]})]}),(0,Q.jsx)(B,{text:e.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:`connection-name`,children:`Name`}),(0,Q.jsx)(m,{id:`connection-name`,value:r,onChange:e=>{i(e.target.value),D(!1)},placeholder:`What to call this on screen`}),(0,Q.jsxs)(`p`,{className:`text-faint text-xs`,children:[`Display only. Every reference to this credential is by its code, `,e.code,`.`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:`connection-description`,children:`Description`}),(0,Q.jsx)(g,{id:`connection-description`,className:`h-24`,value:a,onChange:e=>{o(e.target.value),D(!1)},placeholder:`What this credential is for. Markdown is rendered.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-faint text-xs font-semibold tracking-wide uppercase`,children:`Settings`}),(0,Q.jsx)(h,{fields:k,values:s,problems:A,onChange:(e,t)=>{c(n=>({...n,[e]:t})),D(!1)},onUnreadable:(e,t)=>{y(n=>ie(n,e,t))}}),e.secret_fields.map(t=>(0,Q.jsx)(fe,{id:`secret-${t}`,name:t,stored:ge(e.config[t]),value:u[t]??``,onChange:e=>{d(n=>({...n,[t]:e})),D(!1)}},t))]}),b!==null&&(0,Q.jsx)(ue,{problem:b}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(l,{why:M,children:(0,Q.jsx)(p,{size:`sm`,onClick:()=>{let t=se(e,_e(e,s,u),$(r),$(a));if(t===null){D(!0);return}w(!0),S(null),K(e.code,t).then(e=>{d({}),D(!0),n(e)},e=>{S(f(e))}).finally(()=>{w(!1)})},disabled:C||M!==void 0,title:M,children:C?`Saving`:`Save`})}),T&&(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Saved.`})]})]})}function me(e,t){let n=new Set(e.secret_fields);return t===null?Object.keys(e.config).filter(e=>!n.has(e)).map(t=>({name:t,kind:typeof e.config[t]==`string`?`text`:`json`,help:null,required:!1,nullable:!0,fallback:void 0,options:[],mediaType:null,hint:null,placeholder:``,bounds:{},accepts:[]})):X(t,e.secret_fields)}function he(e){let t=new Set(e.secret_fields),n={};for(let[r,i]of Object.entries(e.config))t.has(r)||(n[r]=i);return n}function ge(e){return e!=null}function $(e){let t=e.trim();return t===``?null:t}function _e(e,t,n){let r={};for(let[n,i]of Object.entries(t))Object.is(i,e.config[n])||(r[n]=i);for(let[e,t]of Object.entries(n))t!==``&&(r[e]=t);return r}function ve({open:e,kinds:t,onOpenChange:n,onCreated:c}){let[u,d]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,T]=(0,Z.useState)(``),[O,A]=(0,Z.useState)({}),[j,M]=(0,Z.useState)({}),[N,P]=(0,Z.useState)(()=>new Set),[F,I]=(0,Z.useState)(()=>new Set),[L,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(null),[H,U]=(0,Z.useState)(!1),W=t.find(e=>e.id===y)??null,G=X(W?.config_schema??null,W?.secret_fields??[]),K=re(G,O),q=L?void 0:N,J=R(`admin`),Y=ee(J.why,ye(u,y,K,F));return(0,Q.jsx)(S,{open:e,onOpenChange:n,children:(0,Q.jsxs)(k,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(te,{children:`New connection`}),(0,Q.jsx)(w,{children:`Secret fields are sealed on the way in and never read back out.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-code`,children:`Code`}),(0,Q.jsx)(m,{id:`connection-code`,className:`font-mono`,value:u,onChange:e=>{d(e.target.value)},placeholder:`postman-echo`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-kind`,children:`Kind`}),(0,Q.jsxs)(s,{value:y,onValueChange:e=>{b(String(e)),A({}),M({}),P(new Set),I(new Set),z(!1)},children:[(0,Q.jsx)(i,{id:`connection-kind`,className:`w-full font-mono`,children:(0,Q.jsx)(r,{placeholder:`Choose a kind`})}),(0,Q.jsx)(a,{children:t.map(e=>(0,Q.jsx)(o,{value:e.id,className:`font-mono`,children:e.id},e.id))})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-name-new`,children:`Name`}),(0,Q.jsx)(m,{id:`connection-name-new`,value:_,onChange:e=>{v(e.target.value)},placeholder:`What to call it on screen. Optional; nothing references it.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-description-new`,children:`Description`}),(0,Q.jsx)(g,{id:`connection-description-new`,className:`h-24`,value:x,onChange:e=>{T(e.target.value)},placeholder:`What this credential is for. Markdown is rendered.`})]}),W!==null&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-faint text-xs font-semibold tracking-wide uppercase`,children:`Settings`}),(0,Q.jsxs)(`div`,{className:`max-h-[40vh] space-y-3 overflow-y-auto pr-1`,children:[(0,Q.jsx)(h,{fields:G,values:O,problems:K,stated:q,onChange:(e,t)=>{A(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},onTouch:e=>{P(t=>t.has(e)?t:new Set(t).add(e))},onUnreadable:(e,t)=>{I(n=>ie(n,e,t))}}),W.secret_fields.map(e=>(0,Q.jsx)(fe,{id:`new-secret-${e}`,name:e,stored:!1,value:j[e]??``,onChange:t=>{M(n=>({...n,[e]:t}))}},e))]})]}),B!==null&&(0,Q.jsx)(ue,{problem:B}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(ne,{render:(0,Q.jsx)(p,{variant:`ghost`}),children:`Close`}),(0,Q.jsx)(l,{why:Y,children:(0,Q.jsx)(p,{disabled:H||Y!==void 0,title:Y,onClick:()=>{z(!0),U(!0),V(null),ae({code:u.trim(),name:be(_),kind:y,description:be(x),config:oe(O,j)}).then(e=>{c(e),d(``),v(``),T(``),b(``),A({}),M({}),P(new Set),I(new Set),z(!1),n(!1)},e=>{V(f(e))}).finally(()=>{U(!1)})},children:H?`Creating`:`Create`})})]})]})})}function ye(e,t,n,r){if(e.trim()===``)return`A connection is addressed by its code, and this one has none.`;if(t===``)return`No kind is chosen, and a connection is a credential of one kind.`;if(r.size>0)return`A setting below holds text that is not a value.`;if(!H(n,r))return`A setting below is not what its kind accepts.`}function be(e){let t=e.trim();return t===``?null:t}var xe=e=>e.code,Se={good:`var(--good)`,critical:`var(--critical)`};function Ce(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)({}),[o,s]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),{state:m,more:h,reload:g}=I(q,xe),_=(0,Z.useMemo)(()=>m.rows.map(e=>i[e.code]??e),[i,m.rows]),v=_.find(t=>t.code===e)??null,y=(0,Z.useCallback)(e=>{a(t=>({...t,[e.code]:e}))},[]),b=(0,Z.useCallback)(e=>{s(e.code),ce(e.code).then(t=>{y(J(e,t,new Date().toISOString()))},le).finally(()=>{s(null)})},[y]),x=e!==null||n;(0,Z.useEffect)(()=>{if(!x||d!==null)return;let e=!0;return W().then(t=>{e&&f(t)},()=>{}),()=>{e=!1}},[d,x]),(0,Z.useEffect)(()=>{let e=Y(_);if(e===null){F();return}return P({note:e,tone:`quiet`,identifier:null}),F},[_]),(0,Z.useEffect)(()=>{if(v===null)return;let e=d?.find(e=>e.id===v.kind)?.config_schema??null;return A([{id:`connection`,label:`Connection`,render:()=>(0,Q.jsx)(pe,{connection:v,schema:e,onSaved:y},v.code)}],{screen:`connections`})},[y,d,v]);let S=R(`admin`),C=S.may;(0,Z.useEffect)(()=>j([...C?[{id:`connections:new`,title:`New connection`,group:M,screen:!0,icon:de,keywords:[`credential`,`create`,`add`],run:()=>{r(!0)}}]:[],{id:`connections:reload`,title:`Read the connections listing again`,group:M,screen:!0,icon:T,keywords:[`refresh`,`reload`],run:g}]),[C,g]);let w=(0,Z.useMemo)(()=>we(b,o,S.why),[b,o,S.why]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{title:`Connections`,aside:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{tag:`connections`}),(0,Q.jsx)(l,{why:S.why,children:(0,Q.jsxs)(p,{size:`sm`,"aria-label":`New connection`,disabled:!S.may,title:S.why,onClick:()=>{r(!0)},children:[(0,Q.jsx)(de,{"aria-hidden":!0}),`New`]})})]})}),(0,Q.jsx)(c,{loading:!m.read,problem:m.problem,empty:_.length===0,emptyMessage:`No connections.`,children:(0,Q.jsx)(L,{columns:w,rows:_,rowKey:xe,reading:m.reading,next:m.next,onMore:h,noun:`connections`,onSelect:e=>{t(e.code),N()},selected:t=>t.code===e})}),(0,Q.jsx)(ve,{open:n,kinds:d??[],onOpenChange:r,onCreated:()=>{g()}})]})}function we(e,t,n){return[{id:`connection`,header:`Connection`,cell:e=>(0,Q.jsx)(Te,{row:e})},{id:`description`,header:`Description`,cell:e=>(0,Q.jsx)(Ee,{description:e.description})},{id:`health`,header:`Health`,cell:e=>(0,Q.jsx)(De,{row:e})},{id:`checked`,header:`Checked`,className:`text-xs`,cell:e=>(0,Q.jsx)(Oe,{row:e})},{id:`check`,header:``,className:`text-right`,cell:r=>(0,Q.jsx)(l,{why:n,children:(0,Q.jsx)(p,{variant:`outline`,size:`sm`,disabled:t===r.code||n!==void 0,title:n,onClick:t=>{t.stopPropagation(),e(r)},children:t===r.code?`Checking`:`Check`})})}]}function Te({row:e}){let t=x(e);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:t.named?`font-semibold`:`font-mono font-semibold`,children:t.title}),(0,Q.jsx)(z,{kind:e.kind}),t.code!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.code})]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground max-w-md truncate text-xs`,title:G(e),children:G(e)})]})}function Ee({description:e}){let t=e===null?``:b(e);return t===``?null:(0,Q.jsx)(`p`,{className:`text-muted-foreground max-w-64 truncate text-xs`,title:t,children:t})}function De({row:e}){let t=U(e);return t.tone===null?(0,Q.jsx)(`span`,{className:`text-faint text-xs`,children:`never checked`}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`span`,{className:`status-dot`,style:{"--chip":Se[t.tone]},"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t.label}),t.detail!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground max-w-64 truncate`,title:t.detail,children:t.detail})]})}function Oe({row:e}){return e.last_check_at===null?null:(0,Q.jsx)(`span`,{className:`text-muted-foreground`,title:y(e.last_check_at),children:v(e.last_check_at)})}export{Ce as Connections};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{i as n}from"./store-CVrCnru0.js";import{a as r,i,n as a,r as o,t as s}from"./select-CKTm9cc4.js";import{n as c,o as l,t as u}from"./PageState-CvfT4nGl.js";import{r as d}from"./utils-CRMSf51M.js";import{d as f,f as p}from"./paging-MGEIXfCZ.js";import{t as m}from"./input-o9l61NKa.js";import{t as h}from"./SchemaForm-DDpXEjh5.js";import{t as g}from"./textarea-XMYmRm72.js";import{d as _,l as v,s as y}from"./format-CR2ze2LO.js";import{n as b,t as x}from"./identity-BNZxCf_y.js";import{Ct as S,Dt as C,Et as w,Ft as T,O as E,Ot as D,T as O,Tt as k,b as ee,ct as A,gt as j,ht as M,kt as te,lt as N,nt as P,tt as F,v as I,w as L,wt as ne,y as R}from"./index-jhYU37cm.js";import{t as z}from"./KindChip-CuBFi3X9.js";import{t as B}from"./Description-BP4Ga-RV.js";import{t as V}from"./Instant-C9TZFyg5.js";import{a as H,l as re,u as ie}from"./schema-form-FkbdR3oI.js";import{a as U,c as W,d as G,f as K,i as ae,l as q,o as oe,p as J,r as Y,s as se,t as ce,u as X}from"./connections-DORVdX7a.js";import{n as le,t as ue}from"./Refusal-JlhK6Mh_.js";var de=n(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),Z=e(t(),1),Q=d();function fe({id:e,name:t,stored:n,value:r,onChange:i}){return(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:e,className:`font-mono text-sm font-medium`,children:t}),(0,Q.jsx)(m,{id:e,type:`password`,autoComplete:`new-password`,value:r,onChange:e=>{i(e.target.value)},placeholder:n?`stored — typing replaces it, blank keeps it`:`not set — type to set one`})]})}function pe({connection:e,schema:t,onSaved:n}){let[r,i]=(0,Z.useState)(e.name??``),[a,o]=(0,Z.useState)(e.description??``),[s,c]=(0,Z.useState)(()=>he(e)),[u,d]=(0,Z.useState)({}),[v,y]=(0,Z.useState)(()=>new Set),[b,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1),O=x(e),k=(0,Z.useMemo)(()=>me(e,t),[e,t]),A=(0,Z.useMemo)(()=>re(k,s),[k,s]),j=R(`admin`),M=ee(j.why,H(A,v)?void 0:`A setting above is not what this kind accepts.`);return(0,Q.jsxs)(`div`,{className:`space-y-4 p-4`,children:[(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`p`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:O.named?`text-sm font-semibold`:`font-mono text-sm font-semibold`,children:O.title}),(0,Q.jsx)(z,{kind:e.kind}),O.code!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:O.code})]}),(0,Q.jsxs)(`p`,{className:`text-faint text-xs`,children:[`Created `,(0,Q.jsx)(V,{at:e.created_at}),_(e.created_at,e.updated_at)&&(0,Q.jsxs)(Q.Fragment,{children:[` · updated `,(0,Q.jsx)(V,{at:e.updated_at})]})]}),(0,Q.jsx)(B,{text:e.description})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:`connection-name`,children:`Name`}),(0,Q.jsx)(m,{id:`connection-name`,value:r,onChange:e=>{i(e.target.value),D(!1)},placeholder:`What to call this on screen`}),(0,Q.jsxs)(`p`,{className:`text-faint text-xs`,children:[`Display only. Every reference to this credential is by its code, `,e.code,`.`]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(E,{htmlFor:`connection-description`,children:`Description`}),(0,Q.jsx)(g,{id:`connection-description`,className:`h-24`,value:a,onChange:e=>{o(e.target.value),D(!1)},placeholder:`What this credential is for. Markdown is rendered.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-faint text-xs font-semibold tracking-wide uppercase`,children:`Settings`}),(0,Q.jsx)(h,{fields:k,values:s,problems:A,onChange:(e,t)=>{c(n=>({...n,[e]:t})),D(!1)},onUnreadable:(e,t)=>{y(n=>ie(n,e,t))}}),e.secret_fields.map(t=>(0,Q.jsx)(fe,{id:`secret-${t}`,name:t,stored:ge(e.config[t]),value:u[t]??``,onChange:e=>{d(n=>({...n,[t]:e})),D(!1)}},t))]}),b!==null&&(0,Q.jsx)(ue,{problem:b}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(l,{why:M,children:(0,Q.jsx)(p,{size:`sm`,onClick:()=>{let t=se(e,_e(e,s,u),$(r),$(a));if(t===null){D(!0);return}w(!0),S(null),K(e.code,t).then(e=>{d({}),D(!0),n(e)},e=>{S(f(e))}).finally(()=>{w(!1)})},disabled:C||M!==void 0,title:M,children:C?`Saving`:`Save`})}),T&&(0,Q.jsx)(`span`,{className:`text-muted-foreground text-xs`,children:`Saved.`})]})]})}function me(e,t){let n=new Set(e.secret_fields);return t===null?Object.keys(e.config).filter(e=>!n.has(e)).map(t=>({name:t,kind:typeof e.config[t]==`string`?`text`:`json`,help:null,required:!1,nullable:!0,fallback:void 0,options:[],mediaType:null,hint:null,placeholder:``,bounds:{},accepts:[]})):X(t,e.secret_fields)}function he(e){let t=new Set(e.secret_fields),n={};for(let[r,i]of Object.entries(e.config))t.has(r)||(n[r]=i);return n}function ge(e){return e!=null}function $(e){let t=e.trim();return t===``?null:t}function _e(e,t,n){let r={};for(let[n,i]of Object.entries(t))Object.is(i,e.config[n])||(r[n]=i);for(let[e,t]of Object.entries(n))t!==``&&(r[e]=t);return r}function ve({open:e,kinds:t,onOpenChange:n,onCreated:c}){let[u,d]=(0,Z.useState)(``),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,T]=(0,Z.useState)(``),[O,A]=(0,Z.useState)({}),[j,M]=(0,Z.useState)({}),[N,P]=(0,Z.useState)(()=>new Set),[F,I]=(0,Z.useState)(()=>new Set),[L,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(null),[H,U]=(0,Z.useState)(!1),W=t.find(e=>e.id===y)??null,G=X(W?.config_schema??null,W?.secret_fields??[]),K=re(G,O),q=L?void 0:N,J=R(`admin`),Y=ee(J.why,ye(u,y,K,F));return(0,Q.jsx)(S,{open:e,onOpenChange:n,children:(0,Q.jsxs)(k,{className:`sm:max-w-xl`,showCloseButton:!1,children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(te,{children:`New connection`}),(0,Q.jsx)(w,{children:`Secret fields are sealed on the way in and never read back out.`})]}),(0,Q.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-code`,children:`Code`}),(0,Q.jsx)(m,{id:`connection-code`,className:`font-mono`,value:u,onChange:e=>{d(e.target.value)},placeholder:`postman-echo`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-kind`,children:`Kind`}),(0,Q.jsxs)(s,{value:y,onValueChange:e=>{b(String(e)),A({}),M({}),P(new Set),I(new Set),z(!1)},children:[(0,Q.jsx)(i,{id:`connection-kind`,className:`w-full font-mono`,children:(0,Q.jsx)(r,{placeholder:`Choose a kind`})}),(0,Q.jsx)(a,{children:t.map(e=>(0,Q.jsx)(o,{value:e.id,className:`font-mono`,children:e.id},e.id))})]})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-name-new`,children:`Name`}),(0,Q.jsx)(m,{id:`connection-name-new`,value:_,onChange:e=>{v(e.target.value)},placeholder:`What to call it on screen. Optional; nothing references it.`})]}),(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(E,{htmlFor:`connection-description-new`,children:`Description`}),(0,Q.jsx)(g,{id:`connection-description-new`,className:`h-24`,value:x,onChange:e=>{T(e.target.value)},placeholder:`What this credential is for. Markdown is rendered.`})]}),W!==null&&(0,Q.jsxs)(`div`,{className:`space-y-3`,children:[(0,Q.jsx)(`p`,{className:`text-faint text-xs font-semibold tracking-wide uppercase`,children:`Settings`}),(0,Q.jsxs)(`div`,{className:`max-h-[40vh] space-y-3 overflow-y-auto pr-1`,children:[(0,Q.jsx)(h,{fields:G,values:O,problems:K,stated:q,onChange:(e,t)=>{A(n=>{let r={...n};return t===void 0?delete r[e]:r[e]=t,r})},onTouch:e=>{P(t=>t.has(e)?t:new Set(t).add(e))},onUnreadable:(e,t)=>{I(n=>ie(n,e,t))}}),W.secret_fields.map(e=>(0,Q.jsx)(fe,{id:`new-secret-${e}`,name:e,stored:!1,value:j[e]??``,onChange:t=>{M(n=>({...n,[e]:t}))}},e))]})]}),B!==null&&(0,Q.jsx)(ue,{problem:B}),(0,Q.jsxs)(C,{children:[(0,Q.jsx)(ne,{render:(0,Q.jsx)(p,{variant:`ghost`}),children:`Close`}),(0,Q.jsx)(l,{why:Y,children:(0,Q.jsx)(p,{disabled:H||Y!==void 0,title:Y,onClick:()=>{z(!0),U(!0),V(null),ae({code:u.trim(),name:be(_),kind:y,description:be(x),config:oe(O,j)}).then(e=>{c(e),d(``),v(``),T(``),b(``),A({}),M({}),P(new Set),I(new Set),z(!1),n(!1)},e=>{V(f(e))}).finally(()=>{U(!1)})},children:H?`Creating`:`Create`})})]})]})})}function ye(e,t,n,r){if(e.trim()===``)return`A connection is addressed by its code, and this one has none.`;if(t===``)return`No kind is chosen, and a connection is a credential of one kind.`;if(r.size>0)return`A setting below holds text that is not a value.`;if(!H(n,r))return`A setting below is not what its kind accepts.`}function be(e){let t=e.trim();return t===``?null:t}var xe=e=>e.code,Se={good:`var(--good)`,critical:`var(--critical)`};function Ce(){let[e,t]=(0,Z.useState)(null),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)({}),[o,s]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),{state:m,more:h,reload:g}=I(q,xe),_=(0,Z.useMemo)(()=>m.rows.map(e=>i[e.code]??e),[i,m.rows]),v=_.find(t=>t.code===e)??null,y=(0,Z.useCallback)(e=>{a(t=>({...t,[e.code]:e}))},[]),b=(0,Z.useCallback)(e=>{s(e.code),ce(e.code).then(t=>{y(J(e,t,new Date().toISOString()))},le).finally(()=>{s(null)})},[y]),x=e!==null||n;(0,Z.useEffect)(()=>{if(!x||d!==null)return;let e=!0;return W().then(t=>{e&&f(t)},()=>{}),()=>{e=!1}},[d,x]),(0,Z.useEffect)(()=>{let e=Y(_);if(e===null){F();return}return P({note:e,tone:`quiet`,identifier:null}),F},[_]),(0,Z.useEffect)(()=>{if(v===null)return;let e=d?.find(e=>e.id===v.kind)?.config_schema??null;return A([{id:`connection`,label:`Connection`,render:()=>(0,Q.jsx)(pe,{connection:v,schema:e,onSaved:y},v.code)}],{screen:`connections`})},[y,d,v]);let S=R(`admin`),C=S.may;(0,Z.useEffect)(()=>j([...C?[{id:`connections:new`,title:`New connection`,group:M,screen:!0,icon:de,keywords:[`credential`,`create`,`add`],run:()=>{r(!0)}}]:[],{id:`connections:reload`,title:`Read the connections listing again`,group:M,screen:!0,icon:T,keywords:[`refresh`,`reload`],run:g}]),[C,g]);let w=(0,Z.useMemo)(()=>we(b,o,S.why),[b,o,S.why]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(u,{title:`Connections`,aside:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{tag:`connections`}),(0,Q.jsx)(l,{why:S.why,children:(0,Q.jsxs)(p,{size:`sm`,"aria-label":`New connection`,disabled:!S.may,title:S.why,onClick:()=>{r(!0)},children:[(0,Q.jsx)(de,{"aria-hidden":!0}),`New`]})})]})}),(0,Q.jsx)(c,{loading:!m.read,problem:m.problem,empty:_.length===0,emptyMessage:`No connections.`,children:(0,Q.jsx)(L,{columns:w,rows:_,rowKey:xe,reading:m.reading,next:m.next,onMore:h,noun:`connections`,onSelect:e=>{t(e.code),N()},selected:t=>t.code===e})}),(0,Q.jsx)(ve,{open:n,kinds:d??[],onOpenChange:r,onCreated:()=>{g()}})]})}function we(e,t,n){return[{id:`connection`,header:`Connection`,cell:e=>(0,Q.jsx)(Te,{row:e})},{id:`description`,header:`Description`,cell:e=>(0,Q.jsx)(Ee,{description:e.description})},{id:`health`,header:`Health`,cell:e=>(0,Q.jsx)(De,{row:e})},{id:`checked`,header:`Checked`,className:`text-xs`,cell:e=>(0,Q.jsx)(Oe,{row:e})},{id:`check`,header:``,className:`text-right`,cell:r=>(0,Q.jsx)(l,{why:n,children:(0,Q.jsx)(p,{variant:`outline`,size:`sm`,disabled:t===r.code||n!==void 0,title:n,onClick:t=>{t.stopPropagation(),e(r)},children:t===r.code?`Checking`:`Check`})})}]}function Te({row:e}){let t=x(e);return(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:t.named?`font-semibold`:`font-mono font-semibold`,children:t.title}),(0,Q.jsx)(z,{kind:e.kind}),t.code!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:t.code})]}),(0,Q.jsx)(`p`,{className:`text-muted-foreground max-w-md truncate text-xs`,title:G(e),children:G(e)})]})}function Ee({description:e}){let t=e===null?``:b(e);return t===``?null:(0,Q.jsx)(`p`,{className:`text-muted-foreground max-w-64 truncate text-xs`,title:t,children:t})}function De({row:e}){let t=U(e);return t.tone===null?(0,Q.jsx)(`span`,{className:`text-faint text-xs`,children:`never checked`}):(0,Q.jsxs)(`span`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`span`,{className:`status-dot`,style:{"--chip":Se[t.tone]},"aria-hidden":!0}),(0,Q.jsx)(`span`,{children:t.label}),t.detail!==null&&(0,Q.jsx)(`span`,{className:`text-muted-foreground max-w-64 truncate`,title:t.detail,children:t.detail})]})}function Oe({row:e}){return e.last_check_at===null?null:(0,Q.jsx)(`span`,{className:`text-muted-foreground`,title:y(e.last_check_at),children:v(e.last_check_at)})}export{Ce as Connections};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{c as n,n as r}from"./chunk-BV7QT456-Bfa1dvOx.js";import{i,n as a,r as o,t as ee}from"./PageState-CvfT4nGl.js";import{r as s,t as c}from"./utils-CRMSf51M.js";import{t as l}from"./use-store-CgWwefFs.js";import{t as u}from"./auth-tGoFbaSP.js";import{v as d}from"./format-CR2ze2LO.js";import{t as f}from"./use-heartbeat-ByRKom_T.js";import{t as p}from"./identity-BNZxCf_y.js";import{d as m}from"./pipelines-C9zjqLmS.js";import{Ft as h,T as g,_,gt as v,l as y,m as te,mt as ne,t as b,u as x,w as S,x as C}from"./index-fYbFix6w.js";import{t as w}from"./Instant-C9TZFyg5.js";import{l as T,n as E,r as D}from"./connections-DORVdX7a.js";import{f as O,i as k,p as A,r as j,s as M,t as re,u as ie}from"./TileCard-BhdD6xgH.js";import{a as ae,i as N,r as P}from"./workers-D2C0PSb8.js";import{f as F,s as I}from"./triggers-Bk6judIf.js";var L=e(t(),1),R=s(),z={neutral:`bg-muted-foreground`,good:`bg-good`,info:`bg-info`,warning:`bg-warning`,critical:`bg-critical`};function B({rows:e,note:t,reading:n}){let a=l(u).identity?.role??null;return(0,R.jsx)(o,{className:`gap-0 p-0`,children:(0,R.jsxs)(i,{className:`flex h-full flex-col p-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-1 px-3 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Health`}),(0,R.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n?`Reading from the server`:`The workers claiming work, and every connection.`})]}),(0,R.jsx)(`ul`,{className:`max-h-64 grow overflow-y-auto`,children:e.map(e=>{let t=e.kind===`connection`?`/connections`:a===`admin`?`/admin/workers`:null,n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:c(`size-2 shrink-0 rounded-full`,z[e.tone]),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`max-w-[55%] shrink-0 truncate font-mono text-xs`,title:e.label,children:e.label}),(0,R.jsxs)(`span`,{className:`ml-auto flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,title:e.detail,children:e.detail}),e.at!==null&&(0,R.jsx)(w,{className:`text-faint shrink-0 text-xs`,at:e.at})]})]});return(0,R.jsx)(`li`,{className:`border-border border-t`,children:t===null?(0,R.jsx)(`span`,{className:`flex items-center gap-3 px-3 py-1.5`,children:n}):(0,R.jsx)(r,{to:t,className:`hover:bg-accent/60 flex items-center gap-3 px-3 py-1.5`,children:n})},`${e.kind}:${e.id}`)})}),(0,R.jsx)(`p`,{className:`text-muted-foreground border-border border-t px-3 py-2 text-xs`,children:t})]})})}function V(e,t){return`${String(e)}${t.next===null?``:`+`}`}function H(e,t){return e===0?`neutral`:t}function U(e,t){return e.items.filter(e=>e.status===t).length}function W(e,t,n){let r=(t,n,r)=>{if(e===null)return null;let i=U(e,t);return{id:t,label:n,value:V(i,e),note:``,tone:H(i,r),to:x({...b,status:t,since:`24h`})}},i=(e,t,n,r,i)=>{if(i===null)return null;let a=i.items.length;return{id:e,label:t,value:V(a,i),note:a===0?``:r,tone:H(a,n),to:x({...b,status:e})}};return[{id:`runs`,tile:e===null?null:{id:`runs`,label:`Runs`,value:V(e.items.length,e),note:`Last 24 hours.`,tone:`neutral`,to:x({...b,since:`24h`})}},{id:`succeeded`,tile:r(`succeeded`,`Succeeded`,`good`)},{id:`failed`,tile:r(`failed`,`Failed`,`critical`)},{id:`completed_with_errors`,tile:r(`completed_with_errors`,`With errors`,`warning`)},{id:`running`,tile:i(`running`,`Running`,`info`,`Being worked on now.`,t)},{id:`queued`,tile:i(`queued`,`Queued`,`neutral`,`Waiting for a worker.`,n)}]}var G=36e5,K=864e5;function q(e,t){let n=e+t*6e4;return Math.floor(n/G)*G-t*6e4}function J(e,t){let n=e+t*6e4;return Math.floor((n%K+K)%K/G)}function oe(e,t,n,r=24){let i=q(t.getTime(),n)-(r-1)*G,a=Array.from({length:r},(e,t)=>{let r=i+t*G;return{start:r,hour:J(r,n),succeeded:0,withErrors:0,failed:0,total:0}});for(let t of e){let e=Date.parse(t.created_at);if(Number.isNaN(e))continue;let n=Math.floor((e-i)/G);if(n<0||n>=r)continue;let o=a[n];o.total+=1,t.status===`succeeded`?o.succeeded+=1:t.status===`completed_with_errors`?o.withErrors+=1:t.status===`failed`&&(o.failed+=1)}return a}function Y(e){return e.succeeded+e.withErrors+e.failed}function se(e){return e.reduce((e,t)=>Math.max(e,Y(t)),0)}function ce(e){let t=t=>e.reduce((e,n)=>e+t(n),0),n=t(e=>e.total);if(n===0)return`No run was started in the last 24 hours.`;let r=[`${String(t(e=>e.succeeded))} succeeded`,`${String(t(e=>e.withErrors))} finished with errors`,`${String(t(e=>e.failed))} failed`];return`${String(n)} runs started in the last 24 hours, by the hour: ${r.join(`, `)}.`}function le(e,t){let n=e.map(e=>{let t=P(e);return{id:e.id,kind:`worker`,label:e.name,tone:t===null?`good`:k(t),detail:t===null?`worker · ${String(e.concurrency)} ${e.concurrency===1?`slot`:`slots`}`:N(t),at:t===null?null:e.last_seen_at}}),r=t.map(e=>{let t=e.last_check_healthy;return{id:e.id,kind:`connection`,label:e.code,tone:t===null?`neutral`:t?`good`:`critical`,detail:t===null?`never checked`:e.last_check_detail??(t?`healthy`:`did not answer`),at:e.last_check_at}});return[...n,...r]}function ue(e,t){let n=e.filter(e=>P(e)===null).length,{healthy:r,total:i}=E(t),a=[];if(e.length===0?a.push(`no worker has registered`):n<e.length&&a.push(`${String(n)} of ${String(e.length)} workers healthy`),r<i){let e=D(t,`connections`);e!==null&&a.push(e)}if(a.length>0){let e=a.join(` · `);return`${e.charAt(0).toUpperCase()}${e.slice(1)}.`}return t.length===0?`Every worker is healthy, and this instance holds no connections.`:`Every worker and every connection is healthy.`}function de(e,t,n=6){return[...e,...t].toSorted((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)).slice(0,n)}function fe(e,t=6){return e.flatMap(e=>{let t=I(e.schedule);return t.kind===`due`?[{...e,at:t.at}]:[]}).toSorted((e,t)=>Date.parse(e.at)-Date.parse(t.at)).slice(0,t)}async function X(e){let t=e.filter(e=>e.schedules>0);return(await Promise.all(t.map(async e=>(await F(e.code,null)).items.map(t=>({pipeline:e.code,schedule:t}))))).flat()}async function pe(){let e=await m(null);return{pipelines:e.items,schedules:await X(e.items)}}var me=6,Z=[{id:`failed`,label:`Failed`,fill:`bg-status-failed/80`},{id:`withErrors`,label:`With errors`,fill:`bg-status-completed-with-errors/80`},{id:`succeeded`,label:`Succeeded`,fill:`bg-status-succeeded/75`}];function he(e){let t=`${String(e.hour).padStart(2,`0`)}:00`;if(e.total===0)return`${t} — nothing ran`;let n=Z.filter(t=>e[t.id]>0).map(t=>`${String(e[t.id])} ${t.label.toLowerCase()}`),r=n.length===0?`none finished`:n.join(`, `);return`${t} — ${String(e.total)} started, ${r}`}function ge({buckets:e,reading:t,className:n}){let r=se(e);return(0,R.jsx)(o,{className:c(`gap-0 p-0`,n),children:(0,R.jsxs)(i,{className:`space-y-3 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runs over time`}),(0,R.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t?`Reading from the server`:`Every run started in the last 24 hours, by the hour it started in.`})]}),(0,R.jsx)(`ul`,{className:`flex items-center gap-3`,children:Z.map(e=>(0,R.jsxs)(`li`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[(0,R.jsx)(`span`,{className:c(`size-2 shrink-0 rounded-sm`,e.fill),"aria-hidden":!0}),e.label]},e.id))})]}),(0,R.jsx)(`div`,{className:`flex h-32 items-end gap-px`,role:`img`,"aria-label":ce(e),children:e.map(e=>(0,R.jsxs)(`div`,{className:`hover:bg-accent/40 flex h-full flex-1 flex-col justify-end rounded-sm`,title:he(e),children:[Z.map(t=>e[t.id]===0?null:(0,R.jsx)(`div`,{className:c(`min-h-0.5 w-full`,t.fill),style:{height:`${String(e[t.id]/Math.max(r,1)*100)}%`}},t.id)),Y(e)===0&&(0,R.jsx)(`div`,{className:`bg-border h-px w-full`})]},e.start))}),(0,R.jsx)(`div`,{className:`text-faint flex gap-px font-mono text-xs`,"aria-hidden":!0,children:e.map((e,t)=>(0,R.jsx)(`span`,{className:`flex-1 text-center`,children:t%me===0?`${String(e.hour).padStart(2,`0`)}`:``},e.start))})]})})}function _e(){let e=_((0,L.useCallback)(()=>y({...b,since:`24h`},null,500),[])),t=_((0,L.useCallback)(()=>y({...b,status:`running`},null),[])),r=_((0,L.useCallback)(()=>y({...b,status:`queued`},null),[])),i=_((0,L.useCallback)(()=>y({...b,status:`failed`},null),[])),o=_((0,L.useCallback)(()=>y({...b,status:`completed_with_errors`},null),[])),s=_(pe),u=_((0,L.useCallback)(()=>ae(null),[])),p=_((0,L.useCallback)(()=>T(null),[])),{again:m}=e,{again:x}=t,{again:C}=r,{again:w}=i,{again:E}=o,{again:D}=s,{again:k}=u,{again:N}=p,P=(0,L.useCallback)(()=>{m(),x(),C(),w(),E(),D(),k(),N()},[D,N,m,w,E,C,x,k]);(0,L.useEffect)(()=>v([{id:`dashboard:refresh`,title:`Refresh the dashboard`,group:ne,screen:!0,icon:h,keywords:[`refresh`,`reload`,`home`],run:P}]),[P]);let F=n();f(P,l(te));let I=de(t.value?.items??[],r.value?.items??[]),z=ie(M(i.value?.items??[],o.value?.items??[]),s.value?.pipelines??[]),V=fe(s.value?.schedules??[]),H=W(e.value,t.value,r.value),U=new Date,G=oe(e.value?.items??[],U,d(U)),K=u.problem===null&&p.problem===null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ee,{title:`Dashboard`,aside:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(g,{tag:`runs`}),(0,R.jsx)(A,{onRefresh:P})]})}),(0,R.jsx)(`div`,{className:`mb-3 grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:H.map(e=>e.tile===null?(0,R.jsx)(j,{},e.id):(0,R.jsx)(re,{tile:e.tile},e.id))}),(0,R.jsxs)(`div`,{className:`mb-6 grid gap-3 lg:grid-cols-3`,children:[(0,R.jsx)(`div`,{className:c(K?`lg:col-span-2`:`lg:col-span-3`),children:e.problem===null?(0,R.jsx)(ge,{buckets:G,reading:!e.read}):(0,R.jsx)(a,{loading:!1,problem:e.problem,empty:!1,children:null})}),K&&(0,R.jsx)(B,{rows:le(u.value?.items??[],p.value?.items??[]),note:ue(u.value?.items??[],p.value?.items??[]),reading:!u.read||!p.read})]}),(0,R.jsx)(Q,{title:`Right now`,to:`/runs`,children:(0,R.jsx)(a,{loading:!t.read||!r.read,problem:t.problem??r.problem,empty:I.length===0,emptyMessage:`Nothing is running and nothing is waiting.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:ve,rows:I,rowKey:e=>e.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void F(`/runs/${e.id}`)})})}),(0,R.jsx)(Q,{title:`Needs a look`,to:`/runs`,children:(0,R.jsx)(a,{loading:!i.read||!o.read,problem:i.problem??o.problem,empty:z.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:O,rows:z,rowKey:e=>e.run.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void F(`/runs/${e.run.id}`)})})}),(0,R.jsx)(Q,{title:`Next fires`,to:`/triggers`,children:(0,R.jsx)(a,{loading:!s.read,problem:s.problem,empty:V.length===0,emptyMessage:`No schedule is due to fire.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:ye,rows:V,rowKey:e=>`${e.pipeline}:${e.schedule.code}`,reading:!1,next:null,onMore:$,noun:`firings`,onSelect:e=>void F(`/pipelines/${encodeURIComponent(e.pipeline)}`)})})})]})}function Q({title:e,to:t,children:n}){return(0,R.jsxs)(`section`,{className:`mb-6 space-y-2 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`space-y-1`,children:(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:(0,R.jsx)(r,{to:t,className:`hover:text-primary`,children:e})})}),n]})}var $=()=>{},ve=[{id:`status`,header:`Status`,cell:e=>(0,R.jsx)(C,{status:e.status})},{id:`pipeline`,header:`Pipeline`,cell:e=>(0,R.jsx)(`span`,{className:`font-mono text-sm`,children:p({code:e.pipeline}).title})},{id:`since`,header:`Since`,className:`text-right`,cell:e=>(0,R.jsx)(w,{className:`text-faint text-xs`,at:e.started_at??e.created_at})}],ye=[{id:`pipeline`,header:`Pipeline`,cell:e=>(0,R.jsx)(`span`,{className:`font-mono text-sm`,children:p({code:e.pipeline}).title})},{id:`schedule`,header:`Schedule`,cell:e=>{let t=p(e.schedule);return(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:c(`truncate text-xs`,t.named?`text-foreground`:`font-mono`),children:t.title}),t.code!==null&&(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0 font-mono text-xs`,children:t.code})]})}},{id:`fires`,header:`Fires`,className:`text-right`,cell:e=>(0,R.jsx)(w,{className:`text-faint text-xs`,at:e.at})}];export{_e as Dashboard};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{c as n,n as r}from"./chunk-BV7QT456-Bfa1dvOx.js";import{i,n as a,r as o,t as ee}from"./PageState-CvfT4nGl.js";import{r as s,t as c}from"./utils-CRMSf51M.js";import{t as l}from"./use-store-CgWwefFs.js";import{t as u}from"./auth-tGoFbaSP.js";import{v as d}from"./format-CR2ze2LO.js";import{t as f}from"./use-heartbeat-ByRKom_T.js";import{t as p}from"./identity-BNZxCf_y.js";import{d as m}from"./pipelines-C9zjqLmS.js";import{Ft as h,T as g,_,gt as v,l as y,m as te,mt as ne,t as b,u as x,w as S,x as C}from"./index-jhYU37cm.js";import{t as w}from"./Instant-C9TZFyg5.js";import{l as T,n as E,r as D}from"./connections-DORVdX7a.js";import{f as O,i as k,p as A,r as j,s as M,t as re,u as ie}from"./TileCard-D1sr4_Pk.js";import{a as ae,i as N,r as P}from"./workers-D2C0PSb8.js";import{f as F,s as I}from"./triggers-Bk6judIf.js";var L=e(t(),1),R=s(),z={neutral:`bg-muted-foreground`,good:`bg-good`,info:`bg-info`,warning:`bg-warning`,critical:`bg-critical`};function B({rows:e,note:t,reading:n}){let a=l(u).identity?.role??null;return(0,R.jsx)(o,{className:`gap-0 p-0`,children:(0,R.jsxs)(i,{className:`flex h-full flex-col p-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-1 px-3 py-3`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Health`}),(0,R.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:n?`Reading from the server`:`The workers claiming work, and every connection.`})]}),(0,R.jsx)(`ul`,{className:`max-h-64 grow overflow-y-auto`,children:e.map(e=>{let t=e.kind===`connection`?`/connections`:a===`admin`?`/admin/workers`:null,n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:c(`size-2 shrink-0 rounded-full`,z[e.tone]),"aria-hidden":!0}),(0,R.jsx)(`span`,{className:`max-w-[55%] shrink-0 truncate font-mono text-xs`,title:e.label,children:e.label}),(0,R.jsxs)(`span`,{className:`ml-auto flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`text-muted-foreground truncate text-xs`,title:e.detail,children:e.detail}),e.at!==null&&(0,R.jsx)(w,{className:`text-faint shrink-0 text-xs`,at:e.at})]})]});return(0,R.jsx)(`li`,{className:`border-border border-t`,children:t===null?(0,R.jsx)(`span`,{className:`flex items-center gap-3 px-3 py-1.5`,children:n}):(0,R.jsx)(r,{to:t,className:`hover:bg-accent/60 flex items-center gap-3 px-3 py-1.5`,children:n})},`${e.kind}:${e.id}`)})}),(0,R.jsx)(`p`,{className:`text-muted-foreground border-border border-t px-3 py-2 text-xs`,children:t})]})})}function V(e,t){return`${String(e)}${t.next===null?``:`+`}`}function H(e,t){return e===0?`neutral`:t}function U(e,t){return e.items.filter(e=>e.status===t).length}function W(e,t,n){let r=(t,n,r)=>{if(e===null)return null;let i=U(e,t);return{id:t,label:n,value:V(i,e),note:``,tone:H(i,r),to:x({...b,status:t,since:`24h`})}},i=(e,t,n,r,i)=>{if(i===null)return null;let a=i.items.length;return{id:e,label:t,value:V(a,i),note:a===0?``:r,tone:H(a,n),to:x({...b,status:e})}};return[{id:`runs`,tile:e===null?null:{id:`runs`,label:`Runs`,value:V(e.items.length,e),note:`Last 24 hours.`,tone:`neutral`,to:x({...b,since:`24h`})}},{id:`succeeded`,tile:r(`succeeded`,`Succeeded`,`good`)},{id:`failed`,tile:r(`failed`,`Failed`,`critical`)},{id:`completed_with_errors`,tile:r(`completed_with_errors`,`With errors`,`warning`)},{id:`running`,tile:i(`running`,`Running`,`info`,`Being worked on now.`,t)},{id:`queued`,tile:i(`queued`,`Queued`,`neutral`,`Waiting for a worker.`,n)}]}var G=36e5,K=864e5;function q(e,t){let n=e+t*6e4;return Math.floor(n/G)*G-t*6e4}function J(e,t){let n=e+t*6e4;return Math.floor((n%K+K)%K/G)}function oe(e,t,n,r=24){let i=q(t.getTime(),n)-(r-1)*G,a=Array.from({length:r},(e,t)=>{let r=i+t*G;return{start:r,hour:J(r,n),succeeded:0,withErrors:0,failed:0,total:0}});for(let t of e){let e=Date.parse(t.created_at);if(Number.isNaN(e))continue;let n=Math.floor((e-i)/G);if(n<0||n>=r)continue;let o=a[n];o.total+=1,t.status===`succeeded`?o.succeeded+=1:t.status===`completed_with_errors`?o.withErrors+=1:t.status===`failed`&&(o.failed+=1)}return a}function Y(e){return e.succeeded+e.withErrors+e.failed}function se(e){return e.reduce((e,t)=>Math.max(e,Y(t)),0)}function ce(e){let t=t=>e.reduce((e,n)=>e+t(n),0),n=t(e=>e.total);if(n===0)return`No run was started in the last 24 hours.`;let r=[`${String(t(e=>e.succeeded))} succeeded`,`${String(t(e=>e.withErrors))} finished with errors`,`${String(t(e=>e.failed))} failed`];return`${String(n)} runs started in the last 24 hours, by the hour: ${r.join(`, `)}.`}function le(e,t){let n=e.map(e=>{let t=P(e);return{id:e.id,kind:`worker`,label:e.name,tone:t===null?`good`:k(t),detail:t===null?`worker · ${String(e.concurrency)} ${e.concurrency===1?`slot`:`slots`}`:N(t),at:t===null?null:e.last_seen_at}}),r=t.map(e=>{let t=e.last_check_healthy;return{id:e.id,kind:`connection`,label:e.code,tone:t===null?`neutral`:t?`good`:`critical`,detail:t===null?`never checked`:e.last_check_detail??(t?`healthy`:`did not answer`),at:e.last_check_at}});return[...n,...r]}function ue(e,t){let n=e.filter(e=>P(e)===null).length,{healthy:r,total:i}=E(t),a=[];if(e.length===0?a.push(`no worker has registered`):n<e.length&&a.push(`${String(n)} of ${String(e.length)} workers healthy`),r<i){let e=D(t,`connections`);e!==null&&a.push(e)}if(a.length>0){let e=a.join(` · `);return`${e.charAt(0).toUpperCase()}${e.slice(1)}.`}return t.length===0?`Every worker is healthy, and this instance holds no connections.`:`Every worker and every connection is healthy.`}function de(e,t,n=6){return[...e,...t].toSorted((e,t)=>Date.parse(t.created_at)-Date.parse(e.created_at)).slice(0,n)}function fe(e,t=6){return e.flatMap(e=>{let t=I(e.schedule);return t.kind===`due`?[{...e,at:t.at}]:[]}).toSorted((e,t)=>Date.parse(e.at)-Date.parse(t.at)).slice(0,t)}async function X(e){let t=e.filter(e=>e.schedules>0);return(await Promise.all(t.map(async e=>(await F(e.code,null)).items.map(t=>({pipeline:e.code,schedule:t}))))).flat()}async function pe(){let e=await m(null);return{pipelines:e.items,schedules:await X(e.items)}}var me=6,Z=[{id:`failed`,label:`Failed`,fill:`bg-status-failed/80`},{id:`withErrors`,label:`With errors`,fill:`bg-status-completed-with-errors/80`},{id:`succeeded`,label:`Succeeded`,fill:`bg-status-succeeded/75`}];function he(e){let t=`${String(e.hour).padStart(2,`0`)}:00`;if(e.total===0)return`${t} — nothing ran`;let n=Z.filter(t=>e[t.id]>0).map(t=>`${String(e[t.id])} ${t.label.toLowerCase()}`),r=n.length===0?`none finished`:n.join(`, `);return`${t} — ${String(e.total)} started, ${r}`}function ge({buckets:e,reading:t,className:n}){let r=se(e);return(0,R.jsx)(o,{className:c(`gap-0 p-0`,n),children:(0,R.jsxs)(i,{className:`space-y-3 p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Runs over time`}),(0,R.jsx)(`p`,{className:`text-muted-foreground text-xs`,children:t?`Reading from the server`:`Every run started in the last 24 hours, by the hour it started in.`})]}),(0,R.jsx)(`ul`,{className:`flex items-center gap-3`,children:Z.map(e=>(0,R.jsxs)(`li`,{className:`text-muted-foreground flex items-center gap-1.5 text-xs`,children:[(0,R.jsx)(`span`,{className:c(`size-2 shrink-0 rounded-sm`,e.fill),"aria-hidden":!0}),e.label]},e.id))})]}),(0,R.jsx)(`div`,{className:`flex h-32 items-end gap-px`,role:`img`,"aria-label":ce(e),children:e.map(e=>(0,R.jsxs)(`div`,{className:`hover:bg-accent/40 flex h-full flex-1 flex-col justify-end rounded-sm`,title:he(e),children:[Z.map(t=>e[t.id]===0?null:(0,R.jsx)(`div`,{className:c(`min-h-0.5 w-full`,t.fill),style:{height:`${String(e[t.id]/Math.max(r,1)*100)}%`}},t.id)),Y(e)===0&&(0,R.jsx)(`div`,{className:`bg-border h-px w-full`})]},e.start))}),(0,R.jsx)(`div`,{className:`text-faint flex gap-px font-mono text-xs`,"aria-hidden":!0,children:e.map((e,t)=>(0,R.jsx)(`span`,{className:`flex-1 text-center`,children:t%me===0?`${String(e.hour).padStart(2,`0`)}`:``},e.start))})]})})}function _e(){let e=_((0,L.useCallback)(()=>y({...b,since:`24h`},null,500),[])),t=_((0,L.useCallback)(()=>y({...b,status:`running`},null),[])),r=_((0,L.useCallback)(()=>y({...b,status:`queued`},null),[])),i=_((0,L.useCallback)(()=>y({...b,status:`failed`},null),[])),o=_((0,L.useCallback)(()=>y({...b,status:`completed_with_errors`},null),[])),s=_(pe),u=_((0,L.useCallback)(()=>ae(null),[])),p=_((0,L.useCallback)(()=>T(null),[])),{again:m}=e,{again:x}=t,{again:C}=r,{again:w}=i,{again:E}=o,{again:D}=s,{again:k}=u,{again:N}=p,P=(0,L.useCallback)(()=>{m(),x(),C(),w(),E(),D(),k(),N()},[D,N,m,w,E,C,x,k]);(0,L.useEffect)(()=>v([{id:`dashboard:refresh`,title:`Refresh the dashboard`,group:ne,screen:!0,icon:h,keywords:[`refresh`,`reload`,`home`],run:P}]),[P]);let F=n();f(P,l(te));let I=de(t.value?.items??[],r.value?.items??[]),z=ie(M(i.value?.items??[],o.value?.items??[]),s.value?.pipelines??[]),V=fe(s.value?.schedules??[]),H=W(e.value,t.value,r.value),U=new Date,G=oe(e.value?.items??[],U,d(U)),K=u.problem===null&&p.problem===null;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ee,{title:`Dashboard`,aside:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(g,{tag:`runs`}),(0,R.jsx)(A,{onRefresh:P})]})}),(0,R.jsx)(`div`,{className:`mb-3 grid grid-cols-2 gap-3 sm:grid-cols-3 xl:grid-cols-6`,children:H.map(e=>e.tile===null?(0,R.jsx)(j,{},e.id):(0,R.jsx)(re,{tile:e.tile},e.id))}),(0,R.jsxs)(`div`,{className:`mb-6 grid gap-3 lg:grid-cols-3`,children:[(0,R.jsx)(`div`,{className:c(K?`lg:col-span-2`:`lg:col-span-3`),children:e.problem===null?(0,R.jsx)(ge,{buckets:G,reading:!e.read}):(0,R.jsx)(a,{loading:!1,problem:e.problem,empty:!1,children:null})}),K&&(0,R.jsx)(B,{rows:le(u.value?.items??[],p.value?.items??[]),note:ue(u.value?.items??[],p.value?.items??[]),reading:!u.read||!p.read})]}),(0,R.jsx)(Q,{title:`Right now`,to:`/runs`,children:(0,R.jsx)(a,{loading:!t.read||!r.read,problem:t.problem??r.problem,empty:I.length===0,emptyMessage:`Nothing is running and nothing is waiting.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:ve,rows:I,rowKey:e=>e.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void F(`/runs/${e.id}`)})})}),(0,R.jsx)(Q,{title:`Needs a look`,to:`/runs`,children:(0,R.jsx)(a,{loading:!i.read||!o.read,problem:i.problem??o.problem,empty:z.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:O,rows:z,rowKey:e=>e.run.id,reading:!1,next:null,onMore:$,noun:`runs`,onSelect:e=>void F(`/runs/${e.run.id}`)})})}),(0,R.jsx)(Q,{title:`Next fires`,to:`/triggers`,children:(0,R.jsx)(a,{loading:!s.read,problem:s.problem,empty:V.length===0,emptyMessage:`No schedule is due to fire.`,children:(0,R.jsx)(S,{chrome:{footer:!1},columns:ye,rows:V,rowKey:e=>`${e.pipeline}:${e.schedule.code}`,reading:!1,next:null,onMore:$,noun:`firings`,onSelect:e=>void F(`/pipelines/${encodeURIComponent(e.pipeline)}`)})})})]})}function Q({title:e,to:t,children:n}){return(0,R.jsxs)(`section`,{className:`mb-6 space-y-2 last:mb-0`,children:[(0,R.jsx)(`div`,{className:`space-y-1`,children:(0,R.jsx)(`h2`,{className:`text-sm font-semibold`,children:(0,R.jsx)(r,{to:t,className:`hover:text-primary`,children:e})})}),n]})}var $=()=>{},ve=[{id:`status`,header:`Status`,cell:e=>(0,R.jsx)(C,{status:e.status})},{id:`pipeline`,header:`Pipeline`,cell:e=>(0,R.jsx)(`span`,{className:`font-mono text-sm`,children:p({code:e.pipeline}).title})},{id:`since`,header:`Since`,className:`text-right`,cell:e=>(0,R.jsx)(w,{className:`text-faint text-xs`,at:e.started_at??e.created_at})}],ye=[{id:`pipeline`,header:`Pipeline`,cell:e=>(0,R.jsx)(`span`,{className:`font-mono text-sm`,children:p({code:e.pipeline}).title})},{id:`schedule`,header:`Schedule`,cell:e=>{let t=p(e.schedule);return(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:c(`truncate text-xs`,t.named?`text-foreground`:`font-mono`),children:t.title}),t.code!==null&&(0,R.jsx)(`span`,{className:`text-muted-foreground shrink-0 font-mono text-xs`,children:t.code})]})}},{id:`fires`,header:`Fires`,className:`text-right`,cell:e=>(0,R.jsx)(w,{className:`text-faint text-xs`,at:e.at})}];export{_e as Dashboard};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{t as n}from"./maximize-2-B2tdtoC6.js";import{r,t as i}from"./utils-CRMSf51M.js";import{f as a}from"./paging-MGEIXfCZ.js";import{Ct as o,Tt as s,kt as c,ot as l}from"./index-fYbFix6w.js";var u=e(t(),1),d=r();function f({title:e,text:t,mediaType:r,path:i}){let[f,p]=(0,u.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Open ${e} in a window`,className:`text-faint border-border bg-background/90 absolute top-1.5 right-3.5 size-6 rounded-md border`,onClick:()=>{p(!0)},children:(0,d.jsx)(n,{className:`size-3.5`,"aria-hidden":!0})}),(0,d.jsx)(o,{open:f,onOpenChange:p,children:(0,d.jsxs)(s,{finalFocus:!1,className:`flex h-[85vh] w-[min(64rem,90vw)] max-w-[min(64rem,90vw)] flex-col gap-3 sm:max-w-[min(64rem,90vw)]`,children:[(0,d.jsx)(c,{className:`font-mono text-sm`,children:e}),(0,d.jsx)(l,{value:t,mediaType:r,path:i,label:e,readOnly:!0,className:`min-h-0 flex-1`})]})})]})}var p=/("(?:[^"\\]|\\.)*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(true|false|null)/g;function m(e){let t=[],n=0;for(let r of e.matchAll(p)){r.index>n&&t.push({kind:`punctuation`,text:e.slice(n,r.index)});let[,i,a,o,s]=r;i===void 0?o===void 0?s!==void 0&&t.push({kind:`literal`,text:s}):t.push({kind:`number`,text:o}):(t.push({kind:a===void 0?`string`:`key`,text:i}),a!==void 0&&t.push({kind:`punctuation`,text:a})),n=r.index+r[0].length}return n<e.length&&t.push({kind:`punctuation`,text:e.slice(n)}),t}var h={key:`text-info-ink`,string:`text-good-ink`,number:`text-warning-ink`,literal:`text-warning-ink`,punctuation:`text-muted-foreground`};function g({title:e,text:t,className:n}){let r=(0,u.useMemo)(()=>m(t),[t]);return(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`pre`,{className:i(`bg-background border-border overflow-auto rounded-lg border p-2 font-mono text-xs`,n),children:r.map((e,t)=>(0,d.jsx)(`span`,{className:h[e.kind],children:e.text},t))}),(0,d.jsx)(f,{title:e,text:t,mediaType:`application/json`,path:`window/${e}`})]})}export{g as t};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{t as n}from"./maximize-2-B2tdtoC6.js";import{r,t as i}from"./utils-CRMSf51M.js";import{f as a}from"./paging-MGEIXfCZ.js";import{Ct as o,Tt as s,kt as c,ot as l}from"./index-jhYU37cm.js";var u=e(t(),1),d=r();function f({title:e,text:t,mediaType:r,path:i}){let[f,p]=(0,u.useState)(!1);return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(a,{variant:`ghost`,size:`icon`,"aria-label":`Open ${e} in a window`,className:`text-faint border-border bg-background/90 absolute top-1.5 right-3.5 size-6 rounded-md border`,onClick:()=>{p(!0)},children:(0,d.jsx)(n,{className:`size-3.5`,"aria-hidden":!0})}),(0,d.jsx)(o,{open:f,onOpenChange:p,children:(0,d.jsxs)(s,{finalFocus:!1,className:`flex h-[85vh] w-[min(64rem,90vw)] max-w-[min(64rem,90vw)] flex-col gap-3 sm:max-w-[min(64rem,90vw)]`,children:[(0,d.jsx)(c,{className:`font-mono text-sm`,children:e}),(0,d.jsx)(l,{value:t,mediaType:r,path:i,label:e,readOnly:!0,className:`min-h-0 flex-1`})]})})]})}var p=/("(?:[^"\\]|\\.)*")(\s*:)?|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|(true|false|null)/g;function m(e){let t=[],n=0;for(let r of e.matchAll(p)){r.index>n&&t.push({kind:`punctuation`,text:e.slice(n,r.index)});let[,i,a,o,s]=r;i===void 0?o===void 0?s!==void 0&&t.push({kind:`literal`,text:s}):t.push({kind:`number`,text:o}):(t.push({kind:a===void 0?`string`:`key`,text:i}),a!==void 0&&t.push({kind:`punctuation`,text:a})),n=r.index+r[0].length}return n<e.length&&t.push({kind:`punctuation`,text:e.slice(n)}),t}var h={key:`text-info-ink`,string:`text-good-ink`,number:`text-warning-ink`,literal:`text-warning-ink`,punctuation:`text-muted-foreground`};function g({title:e,text:t,className:n}){let r=(0,u.useMemo)(()=>m(t),[t]);return(0,d.jsxs)(`div`,{className:`relative`,children:[(0,d.jsx)(`pre`,{className:i(`bg-background border-border overflow-auto rounded-lg border p-2 font-mono text-xs`,n),children:r.map((e,t)=>(0,d.jsx)(`span`,{className:h[e.kind],children:e.text},t))}),(0,d.jsx)(f,{title:e,text:t,mediaType:`application/json`,path:`window/${e}`})]})}export{g as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{c as n}from"./chunk-BV7QT456-Bfa1dvOx.js";import{n as r,t as i}from"./PageState-CvfT4nGl.js";import{r as a}from"./utils-CRMSf51M.js";import{t as o}from"./use-store-CgWwefFs.js";import{t as s}from"./use-heartbeat-ByRKom_T.js";import{d as c}from"./pipelines-C9zjqLmS.js";import{Ft as l,T as u,_ as d,gt as f,l as p,m,nt as h,pt as g,t as _,tt as v,v as y,w as b}from"./index-fYbFix6w.js";import{l as x}from"./connections-DORVdX7a.js";import{a as S,c as ee,d as C,f as w,l as T,n as E,o as D,p as O,r as k,s as A,u as j}from"./TileCard-BhdD6xgH.js";import{a as M}from"./workers-D2C0PSb8.js";import{t as N}from"./AdminOnly-DaihxNZC.js";import{t as P}from"./WorkersTable-6exKSnOc.js";var F=e(t(),1),I=a(),L=e=>e.id,R=()=>{};function z(){return(0,I.jsx)(N,{children:(0,I.jsx)(B,{})})}function B(){let e=d((0,F.useCallback)(()=>p({..._,since:`24h`},null,500),[])),t=d((0,F.useCallback)(()=>p({..._,status:`failed`},null),[])),a=d((0,F.useCallback)(()=>p({..._,status:`completed_with_errors`},null),[])),N=d((0,F.useCallback)(()=>x(null),[])),z=d((0,F.useCallback)(()=>c(null,[],500),[])),B=y((0,F.useCallback)(e=>M(e),[]),L),{again:V,value:H,problem:U,read:W}=e,{again:G}=t,{again:K}=a,{again:q}=N,{again:J}=z,{reload:Y}=B,X=(0,F.useCallback)(()=>{V(),G(),K(),q(),J(),Y()},[q,V,G,K,J,Y]),Z=n();s(X,o(m)),(0,F.useEffect)(()=>(h({note:null,tone:`quiet`,identifier:null}),v),[]),(0,F.useEffect)(()=>f([{id:`admin:reload`,title:`Refresh the overview`,group:g,screen:!0,icon:l,keywords:[`refresh`,`reload`,`dashboard`],run:X}]),[X]);let Q=[{id:`day`,tile:H===null?null:D(H)},{id:`now`,tile:H===null?null:ee(H)},{id:`workers`,tile:B.state.read?C({items:B.state.rows,next:B.state.next}):null},{id:`connections`,tile:N.value===null?null:S(N.value)},{id:`schedules`,tile:z.value===null?null:T(z.value)}],$=j(A(t.value?.items??[],a.value?.items??[]),z.value?.items??[]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(i,{title:`Overview`,aside:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u,{tag:`system`}),(0,I.jsx)(O,{onRefresh:X})]})}),(0,I.jsx)(`div`,{className:`mb-6 grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,children:Q.map(e=>e.tile===null?(0,I.jsx)(k,{},e.id):(0,I.jsx)(E,{tile:e.tile},e.id))}),W&&U!==null&&(0,I.jsx)(r,{loading:!1,problem:U,empty:!1,children:null}),(0,I.jsxs)(`section`,{className:`mb-6 space-y-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Needs a look`}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every run that failed or finished with errors, newest first.`})]}),(0,I.jsx)(r,{loading:!t.read||!a.read,problem:t.problem??a.problem,empty:$.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,I.jsx)(b,{chrome:{footer:!1},columns:w,rows:$,rowKey:e=>e.run.id,reading:!1,next:null,onMore:R,noun:`runs`,onSelect:e=>void Z(`/runs/${e.run.id}`)})})]}),(0,I.jsxs)(`section`,{className:`space-y-2`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workers`}),(0,I.jsx)(P,{state:B.state,more:B.more,empty:`No workers. Start one with dg worker; nothing is claimed until one registers.`})]})]})}export{z as AdminOverview};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{c as n}from"./chunk-BV7QT456-Bfa1dvOx.js";import{n as r,t as i}from"./PageState-CvfT4nGl.js";import{r as a}from"./utils-CRMSf51M.js";import{t as o}from"./use-store-CgWwefFs.js";import{t as s}from"./use-heartbeat-ByRKom_T.js";import{d as c}from"./pipelines-C9zjqLmS.js";import{Ft as l,T as u,_ as d,gt as f,l as p,m,nt as h,pt as g,t as _,tt as v,v as y,w as b}from"./index-jhYU37cm.js";import{l as x}from"./connections-DORVdX7a.js";import{a as S,c as ee,d as C,f as w,l as T,n as E,o as D,p as O,r as k,s as A,u as j}from"./TileCard-D1sr4_Pk.js";import{a as M}from"./workers-D2C0PSb8.js";import{t as N}from"./AdminOnly-DaihxNZC.js";import{t as P}from"./WorkersTable-C_fx8dTx.js";var F=e(t(),1),I=a(),L=e=>e.id,R=()=>{};function z(){return(0,I.jsx)(N,{children:(0,I.jsx)(B,{})})}function B(){let e=d((0,F.useCallback)(()=>p({..._,since:`24h`},null,500),[])),t=d((0,F.useCallback)(()=>p({..._,status:`failed`},null),[])),a=d((0,F.useCallback)(()=>p({..._,status:`completed_with_errors`},null),[])),N=d((0,F.useCallback)(()=>x(null),[])),z=d((0,F.useCallback)(()=>c(null,[],500),[])),B=y((0,F.useCallback)(e=>M(e),[]),L),{again:V,value:H,problem:U,read:W}=e,{again:G}=t,{again:K}=a,{again:q}=N,{again:J}=z,{reload:Y}=B,X=(0,F.useCallback)(()=>{V(),G(),K(),q(),J(),Y()},[q,V,G,K,J,Y]),Z=n();s(X,o(m)),(0,F.useEffect)(()=>(h({note:null,tone:`quiet`,identifier:null}),v),[]),(0,F.useEffect)(()=>f([{id:`admin:reload`,title:`Refresh the overview`,group:g,screen:!0,icon:l,keywords:[`refresh`,`reload`,`dashboard`],run:X}]),[X]);let Q=[{id:`day`,tile:H===null?null:D(H)},{id:`now`,tile:H===null?null:ee(H)},{id:`workers`,tile:B.state.read?C({items:B.state.rows,next:B.state.next}):null},{id:`connections`,tile:N.value===null?null:S(N.value)},{id:`schedules`,tile:z.value===null?null:T(z.value)}],$=j(A(t.value?.items??[],a.value?.items??[]),z.value?.items??[]);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(i,{title:`Overview`,aside:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(u,{tag:`system`}),(0,I.jsx)(O,{onRefresh:X})]})}),(0,I.jsx)(`div`,{className:`mb-6 grid gap-3 sm:grid-cols-2 xl:grid-cols-5`,children:Q.map(e=>e.tile===null?(0,I.jsx)(k,{},e.id):(0,I.jsx)(E,{tile:e.tile},e.id))}),W&&U!==null&&(0,I.jsx)(r,{loading:!1,problem:U,empty:!1,children:null}),(0,I.jsxs)(`section`,{className:`mb-6 space-y-2`,children:[(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Needs a look`}),(0,I.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:`Every run that failed or finished with errors, newest first.`})]}),(0,I.jsx)(r,{loading:!t.read||!a.read,problem:t.problem??a.problem,empty:$.length===0,emptyMessage:`Nothing has failed or finished with errors.`,children:(0,I.jsx)(b,{chrome:{footer:!1},columns:w,rows:$,rowKey:e=>e.run.id,reading:!1,next:null,onMore:R,noun:`runs`,onSelect:e=>void Z(`/runs/${e.run.id}`)})})]}),(0,I.jsxs)(`section`,{className:`space-y-2`,children:[(0,I.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Workers`}),(0,I.jsx)(P,{state:B.state,more:B.more,empty:`No workers. Start one with dg worker; nothing is claimed until one registers.`})]})]})}export{z as AdminOverview};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{a as n}from"./store-CVrCnru0.js";import{$ as r,$n as i,$t as a,An as o,At as s,Bn as c,Ct as l,D as u,Dt as d,E as f,G as p,Gn as m,Gt as ee,Ht as h,It as g,J as _,Jn as v,Jt as y,K as te,Kn as b,Ln as x,Mt as ne,On as S,Ot as C,Pn as w,Pt as T,Q as E,Qt as D,Rn as re,Rt as O,T as k,U as A,Un as j,Vn as M,W as ie,Wn as N,Xt as P,Y as ae,Yt as oe,Z as se,Zn as ce,_n as F,an as le,cn as ue,d as de,en as fe,f as pe,fn as me,ft as he,g as ge,gn as _e,h as I,hn as ve,in as ye,jn as be,jt as xe,k as Se,kn as Ce,mn as we,nn as L,nt as Te,on as Ee,pn as De,q as Oe,qn as ke,rn as Ae,tt as je,wt as Me,xn as Ne,yn as Pe,z as Fe,zt as Ie}from"./dropdown-menu-DTSgujsZ.js";import{t as Le}from"./chevron-down-CrkpqUMs.js";import{r as Re,t as ze}from"./utils-CRMSf51M.js";import{c as Be,d as Ve,f as He,g as Ue,h as We,i as Ge,l as Ke,m as qe,n as Je,p as Ye,r as Xe,s as Ze,t as Qe,u as $e}from"./resolveAriaLabelledBy-BSPxlOXj.js";import"./paging-MGEIXfCZ.js";import{a as et,c as tt,i as nt,l as rt,n as it,o as at,r as ot,s as st,u as ct}from"./input-o9l61NKa.js";import{Nt as lt,St as ut,bt as dt,xt as ft,yt as pt}from"./index-fYbFix6w.js";var R=e(t(),1),mt=e(n(),1),z=Re();function ht(e,t,n,r,i,a,o,s,c,l=2){let u=h(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return ee(n.current,u)?void 0:u}var gt=R.createContext(void 0),_t=R.createContext(void 0),vt=R.createContext(void 0),yt=R.createContext(!1),bt=R.createContext(``);function B(){let e=R.useContext(gt);if(!e)throw Error(N(22));return e}function xt(){let e=R.useContext(_t);if(!e)throw Error(N(23));return e}function V(){let e=R.useContext(vt);if(!e)throw Error(N(24));return e}function St(){return R.useContext(bt)}function Ct(){return R.useContext(yt)}var H={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Xe(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Ke(t,e,n)):Ke(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight};function wt(e){return e==null?void 0:`${e}-popup`}function Tt(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function Et(e){return Array.isArray(e)?e.map(e=>Et(e)).join(`,`):e==null?``:String(e)}var Dt=new Map;function Ot(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Et(e.locale)}|${JSON.stringify(t)}`,r=Dt.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Ze(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Ze(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Ze(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Dt.set(n,a),a}var kt=Ot;function At(e,t=!1){let{overflowY:n}=o(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var jt=Symbol(`none`),Mt={value:jt,index:-1};function Nt(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:o,defaultInputValue:c,inputValue:p,open:ee,defaultOpen:h=!1,selectionMode:g,onItemHighlighted:_,name:te,form:x,disabled:ne=!1,readOnly:T=!1,required:E=!1,inputRef:re,grid:O=!1,items:A,filteredItems:j,filter:M,openOnInputClick:ie=!0,autoHighlight:N=!1,keepHighlight:P=!1,highlightItemOnHover:ae=!0,loopFocus:se=!0,itemToStringLabel:F,itemToStringValue:le,isItemEqualToValue:ue=$e,virtualized:de=!1,inline:pe=!1,fillInputOnItemPress:me=!0,modal:ge=!1,limit:I=-1,autoComplete:ye=`list`,formAutoComplete:Se,locale:Ee,submitOnItemClick:je=!1}=e,{clearErrors:Fe}=et(),{setDirty:Le,validityData:Re,setFilled:ze,name:Ve,disabled:Xe,setTouched:Qe,setFocused:nt,validationMode:rt,validation:at}=tt(),st=Oe(),ct=ot({id:t}),lt=kt({locale:Ee}),[ut,dt]=R.useState(!1),[ft,pt]=R.useState(null),mt=R.useRef([]),B=R.useRef([]),xt=R.useRef(null),V=R.useRef(null),St=R.useRef(null),Ct=R.useRef(null),wt=R.useRef(null),Et=R.useRef(!0),Dt=R.useRef(!1),Ot=R.useRef(null),Nt=R.useRef(null),Pt=R.useRef(null),Ft=R.useRef(Mt),It=R.useRef(null),Lt=R.useRef([]),Rt=R.useRef(null),U=Xe||ne,zt=Ve??te,W=g===`multiple`,Bt=g===`single`,Vt=p!==void 0||c!==void 0,G=A!==void 0,Ht=j!==void 0,K;K=N===`always`?`always`:N?`input-change`:!1;let[q,Ut]=k({controlled:i,default:W?r??b:r,name:`Combobox`,state:`selectedValue`}),Wt=R.useMemo(()=>M===null?()=>!0:M===void 0?Tt(lt,F):M,[M,lt,F]),Gt=ce(()=>Vt?c??``:Bt?Ze(q,F):``).current,[J,Kt]=k({controlled:p,default:Gt,name:`Combobox`,state:`inputValue`}),[Y,qt]=k({controlled:ee,default:h,name:`Combobox`,state:`open`}),Jt=Ge(A),X=ft??String(J).trim(),Yt=Bt?Ze(q,F):``,Xt=Bt&&!ut&&X!==``&&Yt.length===X.length&&lt.contains(Yt,X),Zt=Xt?``:X,Qt=G&&Ht&&Xt,$t=R.useMemo(()=>A?Jt?A.flatMap(e=>e.items):A:b,[A,Jt]),en=R.useMemo(()=>{if(j&&!Qt)return j;if(!A)return b;if(Jt){let e=A,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=Zt===``?r.items.slice(0,e):[];if(Zt!==``)for(let t of r.items){if(i.length>=e)break;Wt(t,Zt,F)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(Zt===``)return I>-1?$t.slice(0,I):$t;let e=[];for(let t of $t){if(I>-1&&e.length>=I)break;Wt(t,Zt,F)&&e.push(t)}return e},[j,Qt,A,Jt,Zt,I,Wt,F,$t]),Z=R.useMemo(()=>Jt?en.flatMap(e=>e.items):en,[en,Jt]),Q=ce(()=>{let e=null;return pe&&Y&&G&&g!==`none`&&(e=He(Z,q,ue,W)),new d({id:ct,labelId:void 0,selectedValue:q,open:Y,items:A,selectionMode:g,listRef:mt,labelsRef:B,popupRef:xt,emptyRef:wt,inputRef:V,startDismissRef:St,endDismissRef:Ct,keyboardActiveRef:Et,chipsContainerRef:Ot,clearRef:Nt,valuesRef:Lt,pointerDownItemRef:Rt,selectionEventRef:Pt,name:zt,form:x,disabled:U,readOnly:T,required:E,grid:O,virtualized:de,openOnInputClick:ie,itemToStringLabel:F,isItemEqualToValue:ue,modal:ge,autoHighlight:K,submitOnItemClick:je,hasInputValue:Vt,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:pe,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:ke,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:v,setOpen:v,setInputValue:v,setSelectedValue:v,setIndices:v,handleSelection:v,forceMount:v,requestSubmit:v})}).current,tn=g===`none`?J:q,nn=R.useMemo(()=>g===`none`?tn:Array.isArray(q)?q.map(e=>Be(e,le)):Be(q,le),[tn,le,g,q]),rn=D(_),an=D(n),on=C(Q,H.activeIndex),sn=C(Q,H.selectedIndex),cn=C(Q,H.positionerElement),ln=C(Q,H.listElement),un=C(Q,H.triggerElement),dn=C(Q,H.inputElement),fn=C(Q,H.inputGroupElement),$=C(Q,H.inline),pn=C(Q,H.inputInsidePopup),mn=C(Q,H.inputOwnsFormValue),hn=a(un),{mounted:gn,setMounted:_n,transitionStatus:vn}=Me(Y),{openMethod:yn,triggerProps:bn}=f(Y),xn=D(()=>nn);it(pn?hn:V,ct,tn,xn,!U,te);let Sn=D(()=>{A?B.current=Z.map(e=>Ze(e,F)):Q.set(`forceMounted`,!0)}),Cn=D((e,t,n)=>{if(t===-1){if(Ft.current===Mt)return;Ft.current=Mt}else Ft.current={value:e,index:t};rn(e,Ae(n,void 0,{index:t}))}),wn=D(e=>{Q.update(e);let t=e.activeIndex;if(t===void 0)return;let n=e.type||`none`;t===null?Cn(void 0,-1,n):Cn(Lt.current[t],t,n)}),Tn=D((t,n)=>{if(Dt.current=n.reason===De,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){Y&&ft!==null&&pt(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&dt(!0),It.current={hasQuery:e};let n=Q.state.listElement;if(!Q.state.virtualized&&n){let e=xt.current;for(let t of be(n.firstElementChild??n)){if(!w(t)||(e?!S(e,t):t.getAttribute(`role`)===`dialog`))break;if(At(t)){t.scrollTop=0;break}}}e&&K&&Q.state.activeIndex==null&&(Y||$)&&Q.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&Q.state.inputInsidePopup&&(It.current={hasQuery:!1,selection:!0});Kt(t)}}),En=D((t,n)=>{if(Y!==t&&(n.reason===`escape-key`&&G&&Z.length===0&&!wt.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&pn&&!$&&ft!==null&&(dt(!1),pt(null),J!==``&&n.reason!==`input-change`&&Tn(``,L(De,n.event))),!t&&ut&&(Bt?($||pt(X),X===``&&dt(!1)):W&&($||pt(X),pn&&wn({activeIndex:null}),(!pn||$)&&Tn(``,L(De,n.event)))),qt(t),!t&&pn&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Qe(!0),nt(!1),rt===`onBlur`)))){let e=g===`none`?J:q;at.commit(e)}}),Dn=D((e,t)=>{o?.(e,t),!t.isCanceled&&(Ut(e),(g===`none`&&xt.current&&me||Bt&&!Q.state.inputInsidePopup)&&Tn(Ze(e,F),L(t.reason,t.event)))}),On=D((e,t)=>{let n=Ce(e),r=Pt.current??e;Pt.current=null;let i=L(ve,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&En(!1,i);return}if(W){let e=Array.isArray(q)?q:[],n=qe(e,t,ue)?Ye(e,t,ue):[...e,t];if(Dn(n,i),i.isCanceled||!(V.current&&V.current.value.trim()!==``))return;Q.state.inputInsidePopup?Tn(``,L(De,i.event)):En(!1,i)}else{if(Dn(t,i),i.isCanceled)return;En(!1,i)}}),kn=D(()=>{let e=at.inputRef.current?.form??Q.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),An=D(()=>{if(_n(!1),an?.(!1),dt(!1),pt(null),wn(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),W&&V.current&&V.current.value!==``&&!Dt.current&&Tn(``,L(De)),Bt){if(Q.state.inputInsidePopup)V.current&&V.current.value!==``&&Tn(``,L(De));else{let e=Ze(q,F);V.current&&V.current.value!==e&&Tn(e,L(e===``?De:Pe))}}}),jn=R.useMemo(()=>$&&cn?{current:cn.closest(`[role="dialog"]`)}:xt,[$,cn]);l({enabled:!e.actionsRef,open:Y,ref:jn,onComplete(){Y||An()}}),R.useImperativeHandle(e.actionsRef,()=>({unmount:An}),[An]),m(function(){if(Y||(Rt.current=null,g===`none`))return;let e=G?$t:Lt.current;wn({selectedIndex:He(e,q,ue,W)})},[Y,q,g,W,G,$t,ue,wn]),m(()=>{A&&(Lt.current=Z,mt.current.length=Z.length)},[A,Z]),m(()=>{let e=It.current;if(e){let t=Y||$||Q.state.positionerElement?.hidden===!1;if(e.hasQuery)K&&t&&Q.set(`activeIndex`,0),It.current=null;else if(String(J).trim()===``&&(It.current=null,t)){let t=e.selection;K===`always`&&!t&&Q.state.selectionMode===`none`&&Q.set(`activeIndex`,0),queueMicrotask(()=>{if(!Q.state.open&&!Q.state.inline||V.current&&V.current.value.trim()!==``)return;let e=Q.state.selectedValue,n=Q.state.selectionMode===`multiple`,r=n&&Array.isArray(e)?e[e.length-1]:e,i=Q.state.selectionMode!==`none`&&r!=null;if(i||t){let t=G||Ht?Z:Lt.current;Q.set(`activeIndex`,i?He(t,e,Q.state.isItemEqualToValue,n):null)}else K===`always`&&Q.set(`activeIndex`,0)})}}if(!Y&&!$)return;let t=G||Ht?Z:Lt.current,n=Q.state.activeIndex;if(n==null){if(K===`always`&&t.length>0){Q.set(`activeIndex`,0);return}Cn(void 0,-1,Pe);return}if(n>=t.length){Cn(void 0,-1,Pe),Q.set(`activeIndex`,null);return}let r=t[n],i=Ft.current.value,a=i!==jt&&Ke(r,i,Q.state.isItemEqualToValue);(Ft.current.index!==n||!a)&&Cn(r,n,Pe)},[on,K,Cn,Ht,G,Z,$,Y,Q,J]),m(()=>{if(g===`none`){ze(String(J)!==``);return}ze(W?Array.isArray(q)&&q.length>0:q!=null)},[ze,g,J,q,W]),R.useEffect(()=>{G&&K&&Z.length===0&&wn({activeIndex:null})},[G,K,Z.length,wn]);function Mn(e){let t=Re.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Je(e,t,(e,t)=>Ke(e,t,ue)):e!==t}u(X,()=>{!Y||X===``||X===String(Gt)||dt(!0)});function Nn(){let e=Ze(q,F);J!==e&&Tn(e,L(Pe))}u(q,()=>{g!==`none`&&(Fe(zt),Le(Mn(q)),at.change(q),Bt&&!Vt&&!pn&&Nn())}),u(J,()=>{g===`none`&&(Fe(zt),Le(J!==Re.initialValue),at.change(J))}),u(A,()=>{!Bt||Vt||pn||ut||Nn()});let Pn=Ue({open:$?!0:Y,onOpenChange:En,elements:{reference:pn?un:dn,floating:cn}}),Fn=O?`grid`:`listbox`,In=Y||$,Ln=In?`true`:`false`,Rn=R.useMemo(()=>{let e=dn?.tagName===`INPUT`,t=dn==null||e,n=t||In,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Ln,r[`aria-haspopup`]=Fn,r[`aria-controls`]=In?ln?.id:void 0,r[`aria-autocomplete`]=ye),{reference:r,floating:{role:`presentation`}}},[dn,In,Ln,Fn,ln?.id,ye]),zn=xe(Pn,{enabled:!T&&!U&&ie,event:`mousedown-only`,toggle:!1,touchOpenDelay:pn?0:100,reason:we}),Bn=s(Pn,{enabled:!T&&!U&&!$,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:$?!0:void 0,outsidePress(e){let t=Ce(e);return!S(un,t)&&!S(Nt.current,t)&&!S(Ot.current,t)&&!S(fn,t)}}),Vn=Te(Pn,{enabled:!T&&!U,id:ct,listRef:mt,activeIndex:on,selectedIndex:sn,virtual:!0,loopFocus:se,allowEscape:se&&!K,focusItemOnOpen:ut||g===`none`&&!K?!1:`auto`,focusItemOnHover:ae,resetOnPointerLeave:!P,orientation:O?`horizontal`:void 0,rtl:st===`rtl`,disabledIndices:b,grid:O?ht:void 0,onNavigate(e,t){!t&&!Y||vn===`ending`||wn(t?{activeIndex:e,type:Et.current?_e:Ne}:{activeIndex:e})}}),Hn=R.useMemo(()=>Ie(Vn.reference,{onKeyDown(e){O&&Q.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Bn.reference,zn.reference,Rn.reference),[Vn.reference,Bn.reference,zn.reference,Rn.reference,O,Q]),Un=R.useMemo(()=>Ie(he,Bn.floating),[Bn.floating]),Wn=R.useMemo(()=>Ie(Vn.floating,Rn.floating),[Vn.floating,Rn.floating]),Gn=R.useMemo(()=>{let e=Vn.item;return e?{...e,onFocus:void 0}:ke},[Vn.item]);We(()=>{Q.update({inline:pe,popupProps:Un,listProps:Wn,inputProps:Hn,triggerProps:bn,itemProps:Gn,setOpen:En,setInputValue:Tn,setSelectedValue:Dn,setIndices:wn,handleSelection:On,forceMount:Sn,requestSubmit:kn,onOpenChangeComplete:an})}),m(()=>{Q.update({id:ct,selectedValue:q,open:Y,mounted:gn,transitionStatus:vn,items:A,inline:pe,popupProps:Un,listProps:Wn,inputProps:Hn,triggerProps:bn,openMethod:yn,itemProps:Gn,selectionMode:g,name:zt,form:x,disabled:U,readOnly:T,required:E,grid:O,virtualized:de,openOnInputClick:ie,itemToStringLabel:F,modal:ge,autoHighlight:K,isItemEqualToValue:ue,submitOnItemClick:je,hasInputValue:Vt,inputOwnsFormValue:g===`none`&&(pe||!Q.state.inputInsidePopup)})},[Q,ct,q,Y,gn,vn,A,Un,Wn,Hn,Gn,yn,bn,g,zt,U,T,E,O,de,ie,F,ge,ue,je,Vt,pe,K,x]);let Kn=fe(re,at.inputRef),qn=R.useMemo(()=>({query:X,hasItems:G,filteredItems:en,flatFilteredItems:Z}),[X,G,en,Z]),Jn=R.useMemo(()=>Array.isArray(tn)?``:Be(tn,le),[tn,le]),Yn=W&&Array.isArray(q)&&q.length>0,Xn=W||g===`none`&&mn?void 0:zt,Zn=R.useMemo(()=>!W||!Array.isArray(q)||!zt?null:q.map(e=>{let t=Be(e,le);return(0,z.jsx)(`input`,{type:`hidden`,form:x,name:zt,value:t,disabled:U},t)}),[W,q,x,zt,le,U]),Qn=(0,z.jsxs)(R.Fragment,{children:[e.children,(0,z.jsx)(`input`,{...at.getValidationProps(U,{onFocus(){if(pn){un?.focus();return}(V.current||un)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||U||T)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=L(Pe,e.nativeEvent),i=()=>Lt.current.findIndex(e=>Be(e,le).toLowerCase()===n||Ze(e,F).toLowerCase()===n);function a(){if(W)return;if(g===`none`){Tn(t,r);return}let e=i();e===-1&&(e=Lt.current.findIndex((e,t)=>{let r=B.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Lt.current[e];a!=null&&Dn?.(a,r)}Bt&&(Sn(),A&&i()===-1&&Q.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ct&&Xn==null?`${ct}-hidden-input`:void 0,form:x,name:Xn,autoComplete:Se,disabled:U,required:E&&!Yn,readOnly:T,value:Jn,ref:Kn,style:Xn?oe:y,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Zn]});return(0,z.jsx)(gt.Provider,{value:Q,children:(0,z.jsx)(_t.Provider,{value:Pn,children:(0,z.jsx)(yt.Provider,{value:G,children:(0,z.jsx)(vt.Provider,{value:qn,children:(0,z.jsx)(bt.Provider,{value:J,children:Qn})})})})})}var Pt={...se,...ct,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function Ft(e){let t=C(e,H.mounted),n=C(e,H.popupSide),r=C(e,H.positionerElement);return t&&r?n:null}function It(){return V().filteredItems.length===0}function Lt(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Rt(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function U(e,t,n){let r=e.state.listRef.current[t];r&&(e.state.selectionEventRef.current=n,r.click(),e.state.selectionEventRef.current=null)}var zt=R.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=tt(),{labelId:ee}=nt(),h=B(),g=C(h,H.selectionMode),_=C(h,H.disabled),v=C(h,H.readOnly),y=C(h,H.required),te=C(h,H.positionerElement),b=C(h,H.listElement),ne=C(h,H.popupId),w=C(h,H.triggerProps),T=C(h,H.inputInsidePopup),E=C(h,H.id),re=C(h,H.labelId),k=C(h,H.open),A=C(h,H.selectedValue),M=C(h,H.activeIndex),ie=C(h,H.selectedIndex),N=C(h,H.hasSelectedValue),ae=xt(),oe=St(),se=j(),ce=u||_||a,le=It(),ue=Ft(h);ot({id:T?o:void 0});let fe=T?o??E:o,pe=Qe(ee,re),me;k&&T?me=ne??wt(E):k&&(me=b?.id);let he=R.useRef(``);function ge(e){he.current=e.pointerType}let{reference:_e}=je(ae,{enabled:!k&&!v&&!_&&g===`single`,listRef:h.state.labelsRef,activeIndex:M,selectedIndex:ie,onMatch(e){let t=h.state.valuesRef.current[e];t!==void 0&&h.state.setSelectedValue(t,L(Pe))}}),{reference:I}=xe(ae,{enabled:!v&&!_,event:`mousedown`}),{buttonRef:ve,getButtonProps:be}=Fe({native:i,disabled:ce}),Se={...l,open:k,disabled:ce,popupSide:ue,listEmpty:le,placeholder:g!==`none`&&!N},we=D(e=>{h.set(`triggerElement`,e)});return O(`button`,e,{ref:[t,ve,we],state:Se,props:[w,I,_e,{id:fe,tabIndex:T?0:-1,role:T?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":T?`dialog`:`listbox`,"aria-controls":me,"aria-required":T&&y||void 0,"aria-labelledby":pe,onPointerDown:ge,onPointerEnter:ge,onFocus(){f(!0),!(ce||v)&&se.start(0,h.state.forceMount)},onBlur(e){if(!S(te,e.relatedTarget)&&(d(!0),f(!1),p===`onBlur`)){let e=g===`none`?oe:A;m.commit(e)}},onMouseDown(e){if(ce||v||(T||ae.set(`domReferenceElement`,e.currentTarget),h.state.forceMount(),he.current!==`touch`&&(h.state.inputRef.current?.focus(),T||e.preventDefault()),k))return;let t=P(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=Ce(e),r=h.state.positionerElement,i=h.state.listElement;S(t,n)||S(r,n)||S(i,n)||de(e,t)||h.state.setOpen(!1,L(ye,e))}T&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){v||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(x(e),h.state.setOpen(!0,L(F,e.nativeEvent)),h.state.inputRef.current?.focus())}},m.getValidationProps(ce,c),be],stateAttributesMapping:Pt})}),W=R.createContext(void 0);function Bt(){return R.useContext(W)}var Vt=R.createContext(void 0);function G(e){let t=R.useContext(Vt);if(t===void 0&&!e)throw Error(N(21));return t}var Ht=R.forwardRef(function(e,t){let n=B(),{buttonRef:r,getButtonProps:i}=Fe({native:!1}),a=fe(t,r);function o(e){n.state.setOpen(!1,L(Ee,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,z.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:oe})}),K=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=tt(),{labelId:ee}=nt(),h=Bt(),g=!!G(!0),v=B(),y=St(),te=Oe(),b=C(v,H.required),ne=C(v,H.disabled),S=C(v,H.readOnly),w=C(v,H.name),T=C(v,H.form),E=C(v,H.selectionMode),k=C(v,H.autoHighlight),A=C(v,H.inputProps),j=C(v,H.triggerProps),M=C(v,H.open),ie=C(v,H.mounted),N=C(v,H.selectedValue),P=C(v,H.id),ae=C(v,H.inline),oe=C(v,H.modal),se=!!k,ce=Ft(v),F=u||ne||i,le=It(),de=g||ae,fe=!de||oe,pe=_(a??(de?void 0:P)),he=g?rt:l,[ge,I]=R.useState(null),ve=R.useRef(!1),ye=R.useRef(null),be=R.useRef(!1),xe=E===`none`&&!g,Se=D(e=>{let t=g||v.state.inline;t&&!v.state.hasInputValue&&v.state.setInputValue(``,L(Pe)),v.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:xe})}),Ce=g?s:m.getValidationProps(F,s);function we(){v.state.setIndices({activeIndex:null,selectedIndex:null,type:v.state.keyboardActiveRef.current?_e:Ne})}function Te(){v.state.keyboardActiveRef.current=!1}let Ee={...he,open:M,disabled:F,readOnly:S,popupSide:ce,listEmpty:le};function ke(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,[i,a]=Lt(te);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&N.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=Rt(n,N.length),we()),t)}let Ae=O(`input`,e,{state:Ee,ref:[t,v.state.inputRef,Se],props:[A,j,{value:ge??y,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":ee,disabled:F,readOnly:S,required:E===`none`?b:void 0,form:T,...xe&&w&&{name:w},id:pe,onFocus(){if(f(!0),!ae||!be.current)return;be.current=!1;let e=ye.current;e==null||!Object.hasOwn(v.state.valuesRef.current,e)||v.state.setIndices({activeIndex:e})},onBlur(){d(!0),f(!1);let e=v.state.activeIndex;if(ae&&e!==null&&k!==`always`&&(ye.current=e,be.current=!0,v.state.setIndices({activeIndex:null})),p===`onBlur`){let e=E===`none`?y:N;m.commit(e)}},onCompositionStart(e){c||(ve.current=!0,I(e.currentTarget.value))},onCompositionEnd(e){ve.current=!1;let t=e.currentTarget.value;I(null),v.state.setInputValue(t,L(me,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=ve.current||!r;function a(e){S||F||!e||!i||(v.state.setOpen(!0,L(me,t)),se||we())}if(ve.current){let n=e.currentTarget.value;I(n),n===``&&!v.state.openOnInputClick&&!v.state.inputInsidePopup&&v.state.setOpen(!1,L(De,t));let r=n.trim(),i=se&&r!==``;a(r),M&&v.state.activeIndex!==null&&!i&&we();return}let o=L(me,t);if(v.state.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=L(De,t);s&&!v.state.inputInsidePopup&&(E===`single`&&v.state.setSelectedValue(null,c),v.state.openOnInputClick||v.state.setOpen(!1,c)),a(e.currentTarget.value.trim()),M&&v.state.activeIndex!==null&&!se&&we()},onKeyDown(e){if(F||S||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;v.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=te===`rtl`;if(e.key===`Home`){x(e);let n=re&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){x(e);let i=re&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!ie&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(N)?N.length===0:N===null,n=L(ue,e.nativeEvent),r=E===`multiple`?[]:null;v.state.setInputValue(``,n),v.state.setSelectedValue(r,n),!t&&!v.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(N)&&N.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:N.length-1,r=N.filter((e,t)=>t!==n);we(),v.state.setSelectedValue(r,L(Pe,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=ke(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&v.state.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&M){let t=v.state.activeIndex,n=e.nativeEvent;if(t===null){if(ae)return;v.state.setOpen(!1,L(Pe,n));return}x(e),U(v,t,n)}},onPointerMove:Te,onPointerDown:Te},Ce],stateAttributesMapping:Pt}),je=g?(0,z.jsx)(st.Provider,{value:at,children:Ae}):Ae;return(0,z.jsxs)(R.Fragment,{children:[M&&fe&&(0,z.jsx)(Ht,{ref:v.state.startDismissRef}),je]})}),q={...r,...E},Ut=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:u}=tt(),d=B(),f=C(d,H.selectionMode),p=C(d,H.disabled),m=C(d,H.readOnly),ee=C(d,H.open),h=C(d,H.selectedValue),g=C(d,H.hasSelectionChips),_=St(),v=!1;v=f===`none`?_!==``:f===`single`?h!=null:g;let y=u||p||i,{buttonRef:te,getButtonProps:b}=Fe({native:a,disabled:y}),{mounted:x,transitionStatus:ne,setMounted:S}=Me(v),w={disabled:y,visible:v,open:ee,transitionStatus:ne};l({open:v,ref:d.state.clearRef,onComplete(){v||S(!1)}});let T=O(`button`,e,{state:w,ref:[t,te,d.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(y||m)return;let t=d.state.keyboardActiveRef.current?_e:Ne;d.state.setInputValue(``,L(le,e.nativeEvent)),f===`none`?d.state.setIndices({activeIndex:null,type:t}):(d.state.setSelectedValue(Array.isArray(h)?[]:null,L(le,e.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:t})),d.state.inputRef.current?.focus()}},c,b],stateAttributesMapping:q});return o||x?T:null}),Wt=R.createContext(null);function Gt(){return R.useContext(Wt)}function J(e){let{children:t}=e,{filteredItems:n}=V(),r=Gt(),i=r?r.items:n;return(0,z.jsx)(R.Fragment,{children:i.map(t)})}var Kt=R.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=B(),l=xt(),u=!!G(!0),{filteredItems:d,hasItems:f}=V(),p=C(c,H.selectionMode),m=C(c,H.grid),ee=C(c,H.listProps),h=C(c,H.virtualized),g=C(c,H.forceMounted),_=p===`multiple`,v=d.length===0,y=D(e=>{c.set(`positionerElement`,e)}),te=D(e=>{c.set(`listElement`,e)}),b=R.useMemo(()=>typeof o==`function`?n||=(0,z.jsx)(J,{children:o}):o,[o]),ne={empty:v},S=l.useState(`floatingId`),w=O(`div`,e,{state:ne,ref:[t,te,u?null:y],props:[ee,{children:b,tabIndex:-1,id:S,role:m?`grid`:`listbox`,"aria-multiselectable":_?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;x(e),U(c,t,e.nativeEvent)}},onKeyDownCapture(){c.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.state.keyboardActiveRef.current=!1}},s]});if(h)return w;let T=f&&!g?void 0:c.state.labelsRef;return(0,z.jsx)(ge,{elementsRef:c.state.listRef,labelsRef:T,children:w})}),Y=`⁠`;function qt(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Jt(){let e=j(),t=R.useRef(null);return R.useEffect(()=>{if(M)return;let n=t.current;if(n==null)return;let r=qt(n);if(r==null)return;let i=r.data,a=`${i}${Y}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var X=R.createContext(void 0);function Yt(){let e=R.useContext(X);if(e===void 0)throw Error(N(20));return e}var Xt=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=B(),a=C(i,H.mounted),o=C(i,H.forceMounted);return a||n||o?(0,z.jsx)(X.Provider,{value:n,children:(0,z.jsx)(T,{ref:t,...r})}):null}),Zt=R.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:ee=!1,collisionAvoidance:h=g,style:_,...v}=e,y=B(),b=xt(),x=Yt(),ne=C(y,H.modal),S=C(y,H.open),w=C(y,H.mounted),T=C(y,H.openMethod),E=C(y,H.positionerElement),re=C(y,H.triggerElement),O=C(y,H.inputElement),k=C(y,H.inputGroupElement),j=C(y,H.inputInsidePopup),M=C(y,H.transitionStatus),N=It(),P=te({anchor:i??(j?re:k??O),floatingRootContext:b,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:ee,keepMounted:x,collisionAvoidance:h,lazyFlip:!0});pe(S&&ne,T===`touch`,E,re);let ae={open:S,side:P.side,align:P.align,anchorHidden:P.anchorHidden,empty:N};m(()=>{y.set(`popupSide`,P.side)},[y,P.side]);let oe=D(e=>{y.set(`positionerElement`,e)}),se=ie(e,ae,{styles:P.positionerStyles,transitionStatus:M,props:v,refs:[t,oe],hidden:!w,inert:!S});return(0,z.jsxs)(Vt.Provider,{value:P,children:[w&&ne&&(0,z.jsx)(Se,{inert:A(!S),cutout:k??O??re}),se]})}),Qt={...ae,...r},$t=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=B(),u=G(),d=xt(),f=C(c,H.mounted),ee=C(c,H.open),h=C(c,H.openMethod),g=C(c,H.popupProps),_=C(c,H.transitionStatus),v=C(c,H.inputInsidePopup),y=C(c,H.inputElement),te=C(c,H.modal),b=C(c,H.id),x=It(),w=s.id??(v?wt(b):void 0);m(()=>(c.set(`popupId`,c.state.popupRef.current?.id||w),()=>{c.set(`popupId`,void 0)}),[c,w]),l({open:ee,ref:c.state.popupRef,onComplete(){ee&&c.state.onOpenChangeComplete(!0)}});let T={open:ee,side:u.side,align:u.align,anchorHidden:u.anchorHidden,transitionStatus:_,empty:x},E=O(`div`,e,{state:T,ref:[t,c.state.popupRef],props:[g,{id:w,role:v?`dialog`:`presentation`,onFocus(e){let t=Ce(e.nativeEvent);h!==`touch`&&(S(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},p(_),s],stateAttributesMapping:Qt}),D=a===void 0?v?e=>e===`touch`?c.state.popupRef.current:y:!1:a,re;re=o??(v?void 0:!1);let k=!v||te;return(0,z.jsx)(ne,{context:d,disabled:!f,modal:k,openInteractionType:h,initialFocus:D,returnFocus:re,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,z.jsxs)(R.Fragment,{children:[E,k&&(0,z.jsx)(Ht,{ref:c.state.endDismissRef})]})})}),en=R.createContext(void 0);function Z(){let e=R.useContext(en);if(!e)throw Error(N(19));return e}var Q=R.createContext(!1);function tn(){return R.useContext(Q)}function nn(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=R.useRef(null),ee=I({guess:!0,index:l,textRef:p}),h=B(),g=tn(),_=Ct(),v=C(h,H.selectionMode),y=C(h,H.disabled),te=C(h,H.readOnly),b=C(h,H.isItemEqualToValue),x=y||u,ne=v!==`none`,S=l??i??ee.index,w=S!==-1,T=C(h,H.id),E=C(h,H.isActive,S),D=C(h,H.isSelected,c),re=C(h,H.itemProps),k=R.useRef(null),A=T!=null&&w?`${T}-${S}`:void 0,j=D&&ne;m(()=>{if(!(w&&(r||l!=null)))return;let e=h.state.listRef.current;return e[S]=k.current,()=>{delete e[S]}},[w,r,S,l,h]),m(()=>{if(!w||_)return;let e=h.state.valuesRef.current;return e[S]=c,()=>{delete e[S]}},[w,_,S,c,h]),m(()=>{if(!w||_)return;let e=h.state.selectedValue,t=Array.isArray(e)?e[e.length-1]:e;Ke(c,t,b)&&h.set(`selectedIndex`,S)},[w,_,h,S,c,b]);let{getButtonProps:M,buttonRef:ie}=Fe({disabled:x,focusableWhenDisabled:!0,native:d,composite:!0}),N={disabled:x,selected:j,highlighted:E};function P(e){function t(){h.state.handleSelection(e,c)}h.state.submitOnItemClick?(mt.flushSync(t),h.state.requestSubmit()):t()}let ae={id:A,role:g?`gridcell`:`option`,"aria-selected":ne?j:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.state.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){x||te||P(e.nativeEvent)},onMouseUp(e){let t=h.state.pointerDownItemRef.current===e.currentTarget;h.state.pointerDownItemRef.current=null,!(x||te||e.button!==0||t||!E)&&P(e.nativeEvent)}},oe=O(`div`,t,{ref:[ie,n,ee.ref,k],state:N,props:[re,ae,f,M]}),se=R.useMemo(()=>({selected:j,textRef:p}),[j,p]);return(0,z.jsx)(en.Provider,{value:se,children:oe})}function rn(e){let{componentProps:t,forwardedRef:n}=e,r=B(),i=C(r,H.isItemEqualToValue),{flatFilteredItems:a}=V(),o=Ve(a,t.value??null,i);return(0,z.jsx)(nn,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:o})}var an=R.memo(R.forwardRef(function(e,t){let n=B(),r=C(n,H.virtualized);return r&&e.index==null?(0,z.jsx)(rn,{componentProps:e,forwardedRef:t}):(0,z.jsx)(nn,{componentProps:e,forwardedRef:t,virtualized:r,indexFromFilter:void 0})})),on=R.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=V(),c=B(),l=Jt(),u=s.length===0?a:null;return O(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function sn(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,z.jsx)(Nt,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var cn=R.forwardRef(function(e,t){let{selected:n}=Z();return e.keepMounted||n?(0,z.jsx)(ln,{...e,ref:t}):null}),ln=R.memo(R.forwardRef((e,t)=>{let{render:n,className:i,style:a,keepMounted:o,...s}=e,{selected:c}=Z(),u=R.useRef(null),{transitionStatus:d,setMounted:f}=Me(c),p=O(`span`,e,{ref:[t,u],state:{selected:c,transitionStatus:d},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:r});return l({open:c,ref:u,onComplete(){c||f(!1)}}),p})),un=sn;function dn({className:e,children:t,...n}){return(0,z.jsxs)(zt,{"data-slot":`combobox-trigger`,className:ze(`[&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,z.jsx)(Le,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function fn({className:e,...t}){return(0,z.jsx)(Ut,{"data-slot":`combobox-clear`,render:(0,z.jsx)(ft,{variant:`ghost`,size:`icon-xs`}),className:ze(e),...t,children:(0,z.jsx)(lt,{className:`pointer-events-none`})})}function $({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,z.jsxs)(pt,{className:ze(`w-auto`,e),children:[(0,z.jsx)(K,{render:(0,z.jsx)(ut,{disabled:n}),...a}),(0,z.jsxs)(dt,{align:`inline-end`,children:[r&&(0,z.jsx)(ft,{size:`icon-xs`,variant:`ghost`,render:(0,z.jsx)(dn,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,z.jsx)(fn,{disabled:n})]}),t]})}function pn({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,z.jsx)(Xt,{children:(0,z.jsx)(Zt,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,z.jsx)($t,{"data-slot":`combobox-content`,"data-chips":!!a,className:ze(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o})})})}function mn({className:e,...t}){return(0,z.jsx)(Kt,{"data-slot":`combobox-list`,className:ze(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,e),...t})}function hn({className:e,children:t,...n}){return(0,z.jsxs)(an,{"data-slot":`combobox-item`,className:ze(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,z.jsx)(cn,{render:(0,z.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,z.jsx)(i,{className:`pointer-events-none`})})]})}function gn({className:e,...t}){return(0,z.jsx)(on,{"data-slot":`combobox-empty`,className:ze(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}function _n(e,t){let n=t.toLowerCase().split(/\s+/u).filter(Boolean),r=`${e.label} ${e.aside}`.toLowerCase();return n.every(e=>r.includes(e))}function vn({id:e,value:t,options:n,placeholder:r,label:i,onChange:a}){let o=n.find(e=>e.value===t)??null;return(0,z.jsxs)(un,{items:n,value:o,itemToStringLabel:e=>e.label,filter:(e,t)=>_n(e,t),onValueChange:e=>{a(e===null?``:e.value)},children:[(0,z.jsx)($,{id:e,"aria-label":i,placeholder:r,className:`bg-field dark:bg-field`,showTrigger:!1,children:(0,z.jsxs)(dt,{align:`inline-end`,children:[o!==null&&o.aside!==``&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:o.aside}),(0,z.jsx)(ft,{size:`icon-xs`,variant:`ghost`,render:(0,z.jsx)(dn,{})})]})}),(0,z.jsxs)(pn,{children:[(0,z.jsx)(gn,{children:`No match.`}),(0,z.jsx)(mn,{children:e=>(0,z.jsxs)(hn,{value:e,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.label}),e.aside!==``&&(0,z.jsx)(`span`,{className:`text-muted-foreground ml-auto font-mono text-xs whitespace-nowrap`,children:e.aside})]},e.value)})]})]})}export{vn as t};
1
+ import{i as e}from"./rolldown-runtime-Dd_uD5pT.js";import{t}from"./react-BatatxyT.js";import{a as n}from"./store-CVrCnru0.js";import{$ as r,$n as i,$t as a,An as o,At as s,Bn as c,Ct as l,D as u,Dt as d,E as f,G as p,Gn as m,Gt as ee,Ht as h,It as g,J as _,Jn as v,Jt as y,K as te,Kn as b,Ln as x,Mt as ne,On as S,Ot as C,Pn as w,Pt as T,Q as E,Qt as D,Rn as re,Rt as O,T as k,U as A,Un as j,Vn as M,W as ie,Wn as N,Xt as P,Y as ae,Yt as oe,Z as se,Zn as ce,_n as F,an as le,cn as ue,d as de,en as fe,f as pe,fn as me,ft as he,g as ge,gn as _e,h as I,hn as ve,in as ye,jn as be,jt as xe,k as Se,kn as Ce,mn as we,nn as L,nt as Te,on as Ee,pn as De,q as Oe,qn as ke,rn as Ae,tt as je,wt as Me,xn as Ne,yn as Pe,z as Fe,zt as Ie}from"./dropdown-menu-DTSgujsZ.js";import{t as Le}from"./chevron-down-CrkpqUMs.js";import{r as Re,t as ze}from"./utils-CRMSf51M.js";import{c as Be,d as Ve,f as He,g as Ue,h as We,i as Ge,l as Ke,m as qe,n as Je,p as Ye,r as Xe,s as Ze,t as Qe,u as $e}from"./resolveAriaLabelledBy-BSPxlOXj.js";import"./paging-MGEIXfCZ.js";import{a as et,c as tt,i as nt,l as rt,n as it,o as at,r as ot,s as st,u as ct}from"./input-o9l61NKa.js";import{Nt as lt,St as ut,bt as dt,xt as ft,yt as pt}from"./index-jhYU37cm.js";var R=e(t(),1),mt=e(n(),1),z=Re();function ht(e,t,n,r,i,a,o,s,c,l=2){let u=h(n.current,{event:e,orientation:r,loopFocus:i,rtl:a,cols:l,disabledIndices:o,minIndex:s,maxIndex:c,prevIndex:t>c?s:t,stopEvent:!0});return ee(n.current,u)?void 0:u}var gt=R.createContext(void 0),_t=R.createContext(void 0),vt=R.createContext(void 0),yt=R.createContext(!1),bt=R.createContext(``);function B(){let e=R.useContext(gt);if(!e)throw Error(N(22));return e}function xt(){let e=R.useContext(_t);if(!e)throw Error(N(23));return e}function V(){let e=R.useContext(vt);if(!e)throw Error(N(24));return e}function St(){return R.useContext(bt)}function Ct(){return R.useContext(yt)}var H={id:e=>e.id,labelId:e=>e.labelId,items:e=>e.items,selectedValue:e=>e.selectedValue,hasSelectionChips:e=>{let t=e.selectedValue;return Array.isArray(t)&&t.length>0},hasSelectedValue:e=>{let{selectedValue:t,selectionMode:n}=e;return t==null?!1:n===`multiple`&&Array.isArray(t)?t.length>0:!0},hasNullItemLabel:(e,t)=>t?Xe(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMounted:e=>e.forceMounted,inline:e=>e.inline,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.selectedValue;return Array.isArray(r)?r.some(e=>Ke(t,e,n)):Ke(t,r,n)},transitionStatus:e=>e.transitionStatus,popupProps:e=>e.popupProps,listProps:e=>e.listProps,inputProps:e=>e.inputProps,triggerProps:e=>e.triggerProps,itemProps:e=>e.itemProps,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupId:e=>e.popupId,triggerElement:e=>e.triggerElement,inputElement:e=>e.inputElement,inputGroupElement:e=>e.inputGroupElement,popupSide:e=>e.popupSide,openMethod:e=>e.openMethod,inputInsidePopup:e=>e.inputInsidePopup,inputOwnsFormValue:e=>e.inputOwnsFormValue,selectionMode:e=>e.selectionMode,name:e=>e.name,form:e=>e.form,disabled:e=>e.disabled,readOnly:e=>e.readOnly,required:e=>e.required,grid:e=>e.grid,virtualized:e=>e.virtualized,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,modal:e=>e.modal,autoHighlight:e=>e.autoHighlight};function wt(e){return e==null?void 0:`${e}-popup`}function Tt(e,t){return(n,r)=>n!=null&&e.contains(n,r,t)}function Et(e){return Array.isArray(e)?e.map(e=>Et(e)).join(`,`):e==null?``:String(e)}var Dt=new Map;function Ot(e={}){let t={usage:`search`,sensitivity:`base`,ignorePunctuation:!0,...e},n=`${Et(e.locale)}|${JSON.stringify(t)}`,r=Dt.get(n);if(r)return r;let i=new Intl.Collator(e.locale,t),a={contains(e,t,n){if(!t)return!0;let r=Ze(e,n);for(let e=0;e<=r.length-t.length;e+=1)if(i.compare(r.slice(e,e+t.length),t)===0)return!0;return!1},startsWith(e,t,n){if(!t)return!0;let r=Ze(e,n);return i.compare(r.slice(0,t.length),t)===0},endsWith(e,t,n){if(!t)return!0;let r=Ze(e,n),a=t.length;return r.length>=a&&i.compare(r.slice(r.length-a),t)===0}};return Dt.set(n,a),a}var kt=Ot;function At(e,t=!1){let{overflowY:n}=o(e);return n!==`auto`&&n!==`scroll`?!1:t?e.clientHeight>0:e.scrollHeight>e.clientHeight}var jt=Symbol(`none`),Mt={value:jt,index:-1};function Nt(e){let{id:t,onOpenChangeComplete:n,defaultSelectedValue:r=null,selectedValue:i,onSelectedValueChange:o,defaultInputValue:c,inputValue:p,open:ee,defaultOpen:h=!1,selectionMode:g,onItemHighlighted:_,name:te,form:x,disabled:ne=!1,readOnly:T=!1,required:E=!1,inputRef:re,grid:O=!1,items:A,filteredItems:j,filter:M,openOnInputClick:ie=!0,autoHighlight:N=!1,keepHighlight:P=!1,highlightItemOnHover:ae=!0,loopFocus:se=!0,itemToStringLabel:F,itemToStringValue:le,isItemEqualToValue:ue=$e,virtualized:de=!1,inline:pe=!1,fillInputOnItemPress:me=!0,modal:ge=!1,limit:I=-1,autoComplete:ye=`list`,formAutoComplete:Se,locale:Ee,submitOnItemClick:je=!1}=e,{clearErrors:Fe}=et(),{setDirty:Le,validityData:Re,setFilled:ze,name:Ve,disabled:Xe,setTouched:Qe,setFocused:nt,validationMode:rt,validation:at}=tt(),st=Oe(),ct=ot({id:t}),lt=kt({locale:Ee}),[ut,dt]=R.useState(!1),[ft,pt]=R.useState(null),mt=R.useRef([]),B=R.useRef([]),xt=R.useRef(null),V=R.useRef(null),St=R.useRef(null),Ct=R.useRef(null),wt=R.useRef(null),Et=R.useRef(!0),Dt=R.useRef(!1),Ot=R.useRef(null),Nt=R.useRef(null),Pt=R.useRef(null),Ft=R.useRef(Mt),It=R.useRef(null),Lt=R.useRef([]),Rt=R.useRef(null),U=Xe||ne,zt=Ve??te,W=g===`multiple`,Bt=g===`single`,Vt=p!==void 0||c!==void 0,G=A!==void 0,Ht=j!==void 0,K;K=N===`always`?`always`:N?`input-change`:!1;let[q,Ut]=k({controlled:i,default:W?r??b:r,name:`Combobox`,state:`selectedValue`}),Wt=R.useMemo(()=>M===null?()=>!0:M===void 0?Tt(lt,F):M,[M,lt,F]),Gt=ce(()=>Vt?c??``:Bt?Ze(q,F):``).current,[J,Kt]=k({controlled:p,default:Gt,name:`Combobox`,state:`inputValue`}),[Y,qt]=k({controlled:ee,default:h,name:`Combobox`,state:`open`}),Jt=Ge(A),X=ft??String(J).trim(),Yt=Bt?Ze(q,F):``,Xt=Bt&&!ut&&X!==``&&Yt.length===X.length&&lt.contains(Yt,X),Zt=Xt?``:X,Qt=G&&Ht&&Xt,$t=R.useMemo(()=>A?Jt?A.flatMap(e=>e.items):A:b,[A,Jt]),en=R.useMemo(()=>{if(j&&!Qt)return j;if(!A)return b;if(Jt){let e=A,t=[],n=0;for(let r of e){if(I>-1&&n>=I)break;let e=I>-1?I-n:1/0,i=Zt===``?r.items.slice(0,e):[];if(Zt!==``)for(let t of r.items){if(i.length>=e)break;Wt(t,Zt,F)&&i.push(t)}if(i.length>0){let e={...r,items:i};t.push(e),n+=i.length}}return t}if(Zt===``)return I>-1?$t.slice(0,I):$t;let e=[];for(let t of $t){if(I>-1&&e.length>=I)break;Wt(t,Zt,F)&&e.push(t)}return e},[j,Qt,A,Jt,Zt,I,Wt,F,$t]),Z=R.useMemo(()=>Jt?en.flatMap(e=>e.items):en,[en,Jt]),Q=ce(()=>{let e=null;return pe&&Y&&G&&g!==`none`&&(e=He(Z,q,ue,W)),new d({id:ct,labelId:void 0,selectedValue:q,open:Y,items:A,selectionMode:g,listRef:mt,labelsRef:B,popupRef:xt,emptyRef:wt,inputRef:V,startDismissRef:St,endDismissRef:Ct,keyboardActiveRef:Et,chipsContainerRef:Ot,clearRef:Nt,valuesRef:Lt,pointerDownItemRef:Rt,selectionEventRef:Pt,name:zt,form:x,disabled:U,readOnly:T,required:E,grid:O,virtualized:de,openOnInputClick:ie,itemToStringLabel:F,isItemEqualToValue:ue,modal:ge,autoHighlight:K,submitOnItemClick:je,hasInputValue:Vt,mounted:!1,forceMounted:!1,transitionStatus:`idle`,inline:pe,activeIndex:null,selectedIndex:e,popupProps:{},listProps:{},inputProps:{},triggerProps:{},itemProps:ke,positionerElement:null,listElement:null,popupId:void 0,triggerElement:null,inputElement:null,inputGroupElement:null,popupSide:null,openMethod:null,inputInsidePopup:!0,inputOwnsFormValue:g===`none`,onOpenChangeComplete:v,setOpen:v,setInputValue:v,setSelectedValue:v,setIndices:v,handleSelection:v,forceMount:v,requestSubmit:v})}).current,tn=g===`none`?J:q,nn=R.useMemo(()=>g===`none`?tn:Array.isArray(q)?q.map(e=>Be(e,le)):Be(q,le),[tn,le,g,q]),rn=D(_),an=D(n),on=C(Q,H.activeIndex),sn=C(Q,H.selectedIndex),cn=C(Q,H.positionerElement),ln=C(Q,H.listElement),un=C(Q,H.triggerElement),dn=C(Q,H.inputElement),fn=C(Q,H.inputGroupElement),$=C(Q,H.inline),pn=C(Q,H.inputInsidePopup),mn=C(Q,H.inputOwnsFormValue),hn=a(un),{mounted:gn,setMounted:_n,transitionStatus:vn}=Me(Y),{openMethod:yn,triggerProps:bn}=f(Y),xn=D(()=>nn);it(pn?hn:V,ct,tn,xn,!U,te);let Sn=D(()=>{A?B.current=Z.map(e=>Ze(e,F)):Q.set(`forceMounted`,!0)}),Cn=D((e,t,n)=>{if(t===-1){if(Ft.current===Mt)return;Ft.current=Mt}else Ft.current={value:e,index:t};rn(e,Ae(n,void 0,{index:t}))}),wn=D(e=>{Q.update(e);let t=e.activeIndex;if(t===void 0)return;let n=e.type||`none`;t===null?Cn(void 0,-1,n):Cn(Lt.current[t],t,n)}),Tn=D((t,n)=>{if(Dt.current=n.reason===De,e.onInputValueChange?.(t,n),!n.isCanceled){if(n.reason===`input-change`){Y&&ft!==null&&pt(null);let e=n.event,r=e.inputType;if(e.type===`compositionend`||r!=null&&r!==``&&r!==`insertReplacementText`){let e=t.trim()!==``;e&&dt(!0),It.current={hasQuery:e};let n=Q.state.listElement;if(!Q.state.virtualized&&n){let e=xt.current;for(let t of be(n.firstElementChild??n)){if(!w(t)||(e?!S(e,t):t.getAttribute(`role`)===`dialog`))break;if(At(t)){t.scrollTop=0;break}}}e&&K&&Q.state.activeIndex==null&&(Y||$)&&Q.set(`activeIndex`,0)}}else n.reason===`input-clear`&&t===``&&Q.state.inputInsidePopup&&(It.current={hasQuery:!1,selection:!0});Kt(t)}}),En=D((t,n)=>{if(Y!==t&&(n.reason===`escape-key`&&G&&Z.length===0&&!wt.current&&n.allowPropagation(),e.onOpenChange?.(t,n),!n.isCanceled&&(t&&pn&&!$&&ft!==null&&(dt(!1),pt(null),J!==``&&n.reason!==`input-change`&&Tn(``,L(De,n.event))),!t&&ut&&(Bt?($||pt(X),X===``&&dt(!1)):W&&($||pt(X),pn&&wn({activeIndex:null}),(!pn||$)&&Tn(``,L(De,n.event)))),qt(t),!t&&pn&&(n.reason===`focus-out`||n.reason===`outside-press`)&&(Qe(!0),nt(!1),rt===`onBlur`)))){let e=g===`none`?J:q;at.commit(e)}}),Dn=D((e,t)=>{o?.(e,t),!t.isCanceled&&(Ut(e),(g===`none`&&xt.current&&me||Bt&&!Q.state.inputInsidePopup)&&Tn(Ze(e,F),L(t.reason,t.event)))}),On=D((e,t)=>{let n=Ce(e),r=Pt.current??e;Pt.current=null;let i=L(ve,r),a=n?.closest(`a`)?.getAttribute(`href`);if(a){a.startsWith(`#`)&&En(!1,i);return}if(W){let e=Array.isArray(q)?q:[],n=qe(e,t,ue)?Ye(e,t,ue):[...e,t];if(Dn(n,i),i.isCanceled||!(V.current&&V.current.value.trim()!==``))return;Q.state.inputInsidePopup?Tn(``,L(De,i.event)):En(!1,i)}else{if(Dn(t,i),i.isCanceled)return;En(!1,i)}}),kn=D(()=>{let e=at.inputRef.current?.form??Q.state.inputElement?.form;e&&typeof e.requestSubmit==`function`&&e.requestSubmit()}),An=D(()=>{if(_n(!1),an?.(!1),dt(!1),pt(null),wn(g===`none`?{activeIndex:null,selectedIndex:null}:{activeIndex:null}),W&&V.current&&V.current.value!==``&&!Dt.current&&Tn(``,L(De)),Bt){if(Q.state.inputInsidePopup)V.current&&V.current.value!==``&&Tn(``,L(De));else{let e=Ze(q,F);V.current&&V.current.value!==e&&Tn(e,L(e===``?De:Pe))}}}),jn=R.useMemo(()=>$&&cn?{current:cn.closest(`[role="dialog"]`)}:xt,[$,cn]);l({enabled:!e.actionsRef,open:Y,ref:jn,onComplete(){Y||An()}}),R.useImperativeHandle(e.actionsRef,()=>({unmount:An}),[An]),m(function(){if(Y||(Rt.current=null,g===`none`))return;let e=G?$t:Lt.current;wn({selectedIndex:He(e,q,ue,W)})},[Y,q,g,W,G,$t,ue,wn]),m(()=>{A&&(Lt.current=Z,mt.current.length=Z.length)},[A,Z]),m(()=>{let e=It.current;if(e){let t=Y||$||Q.state.positionerElement?.hidden===!1;if(e.hasQuery)K&&t&&Q.set(`activeIndex`,0),It.current=null;else if(String(J).trim()===``&&(It.current=null,t)){let t=e.selection;K===`always`&&!t&&Q.state.selectionMode===`none`&&Q.set(`activeIndex`,0),queueMicrotask(()=>{if(!Q.state.open&&!Q.state.inline||V.current&&V.current.value.trim()!==``)return;let e=Q.state.selectedValue,n=Q.state.selectionMode===`multiple`,r=n&&Array.isArray(e)?e[e.length-1]:e,i=Q.state.selectionMode!==`none`&&r!=null;if(i||t){let t=G||Ht?Z:Lt.current;Q.set(`activeIndex`,i?He(t,e,Q.state.isItemEqualToValue,n):null)}else K===`always`&&Q.set(`activeIndex`,0)})}}if(!Y&&!$)return;let t=G||Ht?Z:Lt.current,n=Q.state.activeIndex;if(n==null){if(K===`always`&&t.length>0){Q.set(`activeIndex`,0);return}Cn(void 0,-1,Pe);return}if(n>=t.length){Cn(void 0,-1,Pe),Q.set(`activeIndex`,null);return}let r=t[n],i=Ft.current.value,a=i!==jt&&Ke(r,i,Q.state.isItemEqualToValue);(Ft.current.index!==n||!a)&&Cn(r,n,Pe)},[on,K,Cn,Ht,G,Z,$,Y,Q,J]),m(()=>{if(g===`none`){ze(String(J)!==``);return}ze(W?Array.isArray(q)&&q.length>0:q!=null)},[ze,g,J,q,W]),R.useEffect(()=>{G&&K&&Z.length===0&&wn({activeIndex:null})},[G,K,Z.length,wn]);function Mn(e){let t=Re.initialValue;return Array.isArray(e)&&Array.isArray(t)?!Je(e,t,(e,t)=>Ke(e,t,ue)):e!==t}u(X,()=>{!Y||X===``||X===String(Gt)||dt(!0)});function Nn(){let e=Ze(q,F);J!==e&&Tn(e,L(Pe))}u(q,()=>{g!==`none`&&(Fe(zt),Le(Mn(q)),at.change(q),Bt&&!Vt&&!pn&&Nn())}),u(J,()=>{g===`none`&&(Fe(zt),Le(J!==Re.initialValue),at.change(J))}),u(A,()=>{!Bt||Vt||pn||ut||Nn()});let Pn=Ue({open:$?!0:Y,onOpenChange:En,elements:{reference:pn?un:dn,floating:cn}}),Fn=O?`grid`:`listbox`,In=Y||$,Ln=In?`true`:`false`,Rn=R.useMemo(()=>{let e=dn?.tagName===`INPUT`,t=dn==null||e,n=t||In,r=t?{autoComplete:`off`,spellCheck:`false`,autoCorrect:`off`,autoCapitalize:`none`}:{};return n&&(r.role=`combobox`,r[`aria-expanded`]=Ln,r[`aria-haspopup`]=Fn,r[`aria-controls`]=In?ln?.id:void 0,r[`aria-autocomplete`]=ye),{reference:r,floating:{role:`presentation`}}},[dn,In,Ln,Fn,ln?.id,ye]),zn=xe(Pn,{enabled:!T&&!U&&ie,event:`mousedown-only`,toggle:!1,touchOpenDelay:pn?0:100,reason:we}),Bn=s(Pn,{enabled:!T&&!U&&!$,outsidePressEvent:{mouse:`sloppy`,touch:`intentional`},bubbles:$?!0:void 0,outsidePress(e){let t=Ce(e);return!S(un,t)&&!S(Nt.current,t)&&!S(Ot.current,t)&&!S(fn,t)}}),Vn=Te(Pn,{enabled:!T&&!U,id:ct,listRef:mt,activeIndex:on,selectedIndex:sn,virtual:!0,loopFocus:se,allowEscape:se&&!K,focusItemOnOpen:ut||g===`none`&&!K?!1:`auto`,focusItemOnHover:ae,resetOnPointerLeave:!P,orientation:O?`horizontal`:void 0,rtl:st===`rtl`,disabledIndices:b,grid:O?ht:void 0,onNavigate(e,t){!t&&!Y||vn===`ending`||wn(t?{activeIndex:e,type:Et.current?_e:Ne}:{activeIndex:e})}}),Hn=R.useMemo(()=>Ie(Vn.reference,{onKeyDown(e){O&&Q.state.activeIndex==null&&(e.key===`ArrowLeft`||e.key===`ArrowRight`)&&e.preventBaseUIHandler()}},Bn.reference,zn.reference,Rn.reference),[Vn.reference,Bn.reference,zn.reference,Rn.reference,O,Q]),Un=R.useMemo(()=>Ie(he,Bn.floating),[Bn.floating]),Wn=R.useMemo(()=>Ie(Vn.floating,Rn.floating),[Vn.floating,Rn.floating]),Gn=R.useMemo(()=>{let e=Vn.item;return e?{...e,onFocus:void 0}:ke},[Vn.item]);We(()=>{Q.update({inline:pe,popupProps:Un,listProps:Wn,inputProps:Hn,triggerProps:bn,itemProps:Gn,setOpen:En,setInputValue:Tn,setSelectedValue:Dn,setIndices:wn,handleSelection:On,forceMount:Sn,requestSubmit:kn,onOpenChangeComplete:an})}),m(()=>{Q.update({id:ct,selectedValue:q,open:Y,mounted:gn,transitionStatus:vn,items:A,inline:pe,popupProps:Un,listProps:Wn,inputProps:Hn,triggerProps:bn,openMethod:yn,itemProps:Gn,selectionMode:g,name:zt,form:x,disabled:U,readOnly:T,required:E,grid:O,virtualized:de,openOnInputClick:ie,itemToStringLabel:F,modal:ge,autoHighlight:K,isItemEqualToValue:ue,submitOnItemClick:je,hasInputValue:Vt,inputOwnsFormValue:g===`none`&&(pe||!Q.state.inputInsidePopup)})},[Q,ct,q,Y,gn,vn,A,Un,Wn,Hn,Gn,yn,bn,g,zt,U,T,E,O,de,ie,F,ge,ue,je,Vt,pe,K,x]);let Kn=fe(re,at.inputRef),qn=R.useMemo(()=>({query:X,hasItems:G,filteredItems:en,flatFilteredItems:Z}),[X,G,en,Z]),Jn=R.useMemo(()=>Array.isArray(tn)?``:Be(tn,le),[tn,le]),Yn=W&&Array.isArray(q)&&q.length>0,Xn=W||g===`none`&&mn?void 0:zt,Zn=R.useMemo(()=>!W||!Array.isArray(q)||!zt?null:q.map(e=>{let t=Be(e,le);return(0,z.jsx)(`input`,{type:`hidden`,form:x,name:zt,value:t,disabled:U},t)}),[W,q,x,zt,le,U]),Qn=(0,z.jsxs)(R.Fragment,{children:[e.children,(0,z.jsx)(`input`,{...at.getValidationProps(U,{onFocus(){if(pn){un?.focus();return}(V.current||un)?.focus()},onChange(e){if(e.nativeEvent.defaultPrevented||U||T)return;let t=e.currentTarget.value,n=t.toLowerCase(),r=L(Pe,e.nativeEvent),i=()=>Lt.current.findIndex(e=>Be(e,le).toLowerCase()===n||Ze(e,F).toLowerCase()===n);function a(){if(W)return;if(g===`none`){Tn(t,r);return}let e=i();e===-1&&(e=Lt.current.findIndex((e,t)=>{let r=B.current[t];return r!=null&&r.toLowerCase()===n}));let a=e===-1?void 0:Lt.current[e];a!=null&&Dn?.(a,r)}Bt&&(Sn(),A&&i()===-1&&Q.set(`forceMounted`,!0)),queueMicrotask(a)}}),id:ct&&Xn==null?`${ct}-hidden-input`:void 0,form:x,name:Xn,autoComplete:Se,disabled:U,required:E&&!Yn,readOnly:T,value:Jn,ref:Kn,style:Xn?oe:y,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Zn]});return(0,z.jsx)(gt.Provider,{value:Q,children:(0,z.jsx)(_t.Provider,{value:Pn,children:(0,z.jsx)(yt.Provider,{value:G,children:(0,z.jsx)(vt.Provider,{value:qn,children:(0,z.jsx)(bt.Provider,{value:J,children:Qn})})})})})}var Pt={...se,...ct,popupSide:e=>e?{"data-popup-side":e}:null,listEmpty:e=>e?{"data-list-empty":``}:null};function Ft(e){let t=C(e,H.mounted),n=C(e,H.popupSide),r=C(e,H.positionerElement);return t&&r?n:null}function It(){return V().filteredItems.length===0}function Lt(e){return e===`rtl`?[`ArrowRight`,`ArrowLeft`]:[`ArrowLeft`,`ArrowRight`]}function Rt(e,t){let n=e>=t-1?t-2:e;return n>=0?n:void 0}function U(e,t,n){let r=e.state.listRef.current[t];r&&(e.state.selectionEventRef.current=n,r.click(),e.state.selectionEventRef.current=null)}var zt=R.forwardRef(function(e,t){let{render:n,className:r,nativeButton:i=!0,disabled:a=!1,id:o,style:s,...c}=e,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=tt(),{labelId:ee}=nt(),h=B(),g=C(h,H.selectionMode),_=C(h,H.disabled),v=C(h,H.readOnly),y=C(h,H.required),te=C(h,H.positionerElement),b=C(h,H.listElement),ne=C(h,H.popupId),w=C(h,H.triggerProps),T=C(h,H.inputInsidePopup),E=C(h,H.id),re=C(h,H.labelId),k=C(h,H.open),A=C(h,H.selectedValue),M=C(h,H.activeIndex),ie=C(h,H.selectedIndex),N=C(h,H.hasSelectedValue),ae=xt(),oe=St(),se=j(),ce=u||_||a,le=It(),ue=Ft(h);ot({id:T?o:void 0});let fe=T?o??E:o,pe=Qe(ee,re),me;k&&T?me=ne??wt(E):k&&(me=b?.id);let he=R.useRef(``);function ge(e){he.current=e.pointerType}let{reference:_e}=je(ae,{enabled:!k&&!v&&!_&&g===`single`,listRef:h.state.labelsRef,activeIndex:M,selectedIndex:ie,onMatch(e){let t=h.state.valuesRef.current[e];t!==void 0&&h.state.setSelectedValue(t,L(Pe))}}),{reference:I}=xe(ae,{enabled:!v&&!_,event:`mousedown`}),{buttonRef:ve,getButtonProps:be}=Fe({native:i,disabled:ce}),Se={...l,open:k,disabled:ce,popupSide:ue,listEmpty:le,placeholder:g!==`none`&&!N},we=D(e=>{h.set(`triggerElement`,e)});return O(`button`,e,{ref:[t,ve,we],state:Se,props:[w,I,_e,{id:fe,tabIndex:T?0:-1,role:T?`combobox`:void 0,"aria-expanded":k,"aria-haspopup":T?`dialog`:`listbox`,"aria-controls":me,"aria-required":T&&y||void 0,"aria-labelledby":pe,onPointerDown:ge,onPointerEnter:ge,onFocus(){f(!0),!(ce||v)&&se.start(0,h.state.forceMount)},onBlur(e){if(!S(te,e.relatedTarget)&&(d(!0),f(!1),p===`onBlur`)){let e=g===`none`?oe:A;m.commit(e)}},onMouseDown(e){if(ce||v||(T||ae.set(`domReferenceElement`,e.currentTarget),h.state.forceMount(),he.current!==`touch`&&(h.state.inputRef.current?.focus(),T||e.preventDefault()),k))return;let t=P(e.currentTarget);function n(e){let t=h.state.triggerElement;if(!t)return;let n=Ce(e),r=h.state.positionerElement,i=h.state.listElement;S(t,n)||S(r,n)||S(i,n)||de(e,t)||h.state.setOpen(!1,L(ye,e))}T&&t.addEventListener(`mouseup`,n,{once:!0})},onKeyDown(e){v||(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(x(e),h.state.setOpen(!0,L(F,e.nativeEvent)),h.state.inputRef.current?.focus())}},m.getValidationProps(ce,c),be],stateAttributesMapping:Pt})}),W=R.createContext(void 0);function Bt(){return R.useContext(W)}var Vt=R.createContext(void 0);function G(e){let t=R.useContext(Vt);if(t===void 0&&!e)throw Error(N(21));return t}var Ht=R.forwardRef(function(e,t){let n=B(),{buttonRef:r,getButtonProps:i}=Fe({native:!1}),a=fe(t,r);function o(e){n.state.setOpen(!1,L(Ee,e.nativeEvent,e.currentTarget))}let s=i({onClick:o});return(0,z.jsx)(`span`,{ref:a,...s,"aria-label":`Dismiss`,tabIndex:void 0,style:oe})}),K=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,id:a,style:o,...s}=e,{state:l,disabled:u,setTouched:d,setFocused:f,validationMode:p,validation:m}=tt(),{labelId:ee}=nt(),h=Bt(),g=!!G(!0),v=B(),y=St(),te=Oe(),b=C(v,H.required),ne=C(v,H.disabled),S=C(v,H.readOnly),w=C(v,H.name),T=C(v,H.form),E=C(v,H.selectionMode),k=C(v,H.autoHighlight),A=C(v,H.inputProps),j=C(v,H.triggerProps),M=C(v,H.open),ie=C(v,H.mounted),N=C(v,H.selectedValue),P=C(v,H.id),ae=C(v,H.inline),oe=C(v,H.modal),se=!!k,ce=Ft(v),F=u||ne||i,le=It(),de=g||ae,fe=!de||oe,pe=_(a??(de?void 0:P)),he=g?rt:l,[ge,I]=R.useState(null),ve=R.useRef(!1),ye=R.useRef(null),be=R.useRef(!1),xe=E===`none`&&!g,Se=D(e=>{let t=g||v.state.inline;t&&!v.state.hasInputValue&&v.state.setInputValue(``,L(Pe)),v.update({inputElement:e,inputInsidePopup:t,inputOwnsFormValue:xe})}),Ce=g?s:m.getValidationProps(F,s);function we(){v.state.setIndices({activeIndex:null,selectedIndex:null,type:v.state.keyboardActiveRef.current?_e:Ne})}function Te(){v.state.keyboardActiveRef.current=!1}let Ee={...he,open:M,disabled:F,readOnly:S,popupSide:ce,listEmpty:le};function ke(e){if(!h)return;let t,{highlightedChipIndex:n}=h,r=h.chipsRef.current.length,[i,a]=Lt(te);return n===void 0?(e.key===i&&(e.currentTarget.selectionStart??0)===0&&N.length>0&&(e.preventDefault(),t=r>0?r-1:void 0),t):(e.key===i?(e.preventDefault(),t=n>0?n-1:void 0):e.key===a?(e.preventDefault(),t=n<r-1?n+1:void 0):(e.key===`Backspace`||e.key===`Delete`)&&(e.preventDefault(),t=Rt(n,N.length),we()),t)}let Ae=O(`input`,e,{state:Ee,ref:[t,v.state.inputRef,Se],props:[A,j,{value:ge??y,"aria-readonly":S||void 0,"aria-required":b||void 0,"aria-labelledby":ee,disabled:F,readOnly:S,required:E===`none`?b:void 0,form:T,...xe&&w&&{name:w},id:pe,onFocus(){if(f(!0),!ae||!be.current)return;be.current=!1;let e=ye.current;e==null||!Object.hasOwn(v.state.valuesRef.current,e)||v.state.setIndices({activeIndex:e})},onBlur(){d(!0),f(!1);let e=v.state.activeIndex;if(ae&&e!==null&&k!==`always`&&(ye.current=e,be.current=!0,v.state.setIndices({activeIndex:null})),p===`onBlur`){let e=E===`none`?y:N;m.commit(e)}},onCompositionStart(e){c||(ve.current=!0,I(e.currentTarget.value))},onCompositionEnd(e){ve.current=!1;let t=e.currentTarget.value;I(null),v.state.setInputValue(t,L(me,e.nativeEvent))},onChange(e){let t=e.nativeEvent,n=t.inputType,r=!n||n===`insertReplacementText`,i=ve.current||!r;function a(e){S||F||!e||!i||(v.state.setOpen(!0,L(me,t)),se||we())}if(ve.current){let n=e.currentTarget.value;I(n),n===``&&!v.state.openOnInputClick&&!v.state.inputInsidePopup&&v.state.setOpen(!1,L(De,t));let r=n.trim(),i=se&&r!==``;a(r),M&&v.state.activeIndex!==null&&!i&&we();return}let o=L(me,t);if(v.state.setInputValue(e.currentTarget.value,o),o.isCanceled)return;let s=e.currentTarget.value===``,c=L(De,t);s&&!v.state.inputInsidePopup&&(E===`single`&&v.state.setSelectedValue(null,c),v.state.openOnInputClick||v.state.setOpen(!1,c)),a(e.currentTarget.value.trim()),M&&v.state.activeIndex!==null&&!se&&we()},onKeyDown(e){if(F||S||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey)return;v.state.keyboardActiveRef.current=!0;let t=e.currentTarget,n=t.scrollWidth-t.clientWidth,r=te===`rtl`;if(e.key===`Home`){x(e);let n=re&&r?t.value.length:0;t.setSelectionRange(n,n),t.scrollLeft=0;return}if(e.key===`End`){x(e);let i=re&&r?0:t.value.length;t.setSelectionRange(i,i),t.scrollLeft=r?-n:n;return}if(!ie&&e.key===`Escape`){let t=E===`multiple`&&Array.isArray(N)?N.length===0:N===null,n=L(ue,e.nativeEvent),r=E===`multiple`?[]:null;v.state.setInputValue(``,n),v.state.setSelectedValue(r,n),!t&&!v.state.inline&&!n.isPropagationAllowed&&e.stopPropagation();return}if(h&&e.key===`Backspace`&&t.value===``&&h.highlightedChipIndex===void 0&&Array.isArray(N)&&N.length>0){let t=h.chipsRef.current.length,n=t>0?t-1:N.length-1,r=N.filter((e,t)=>t!==n);we(),v.state.setSelectedValue(r,L(Pe,e.nativeEvent));return}let i=h?.highlightedChipIndex!==void 0,a=ke(e);if(h?.setHighlightedChipIndex(a),a===void 0?i&&v.state.inputRef.current?.focus():h?.chipsRef.current[a]?.focus(),e.which!==229&&e.key===`Enter`&&M){let t=v.state.activeIndex,n=e.nativeEvent;if(t===null){if(ae)return;v.state.setOpen(!1,L(Pe,n));return}x(e),U(v,t,n)}},onPointerMove:Te,onPointerDown:Te},Ce],stateAttributesMapping:Pt}),je=g?(0,z.jsx)(st.Provider,{value:at,children:Ae}):Ae;return(0,z.jsxs)(R.Fragment,{children:[M&&fe&&(0,z.jsx)(Ht,{ref:v.state.startDismissRef}),je]})}),q={...r,...E},Ut=R.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,nativeButton:a=!0,keepMounted:o=!1,style:s,...c}=e,{disabled:u}=tt(),d=B(),f=C(d,H.selectionMode),p=C(d,H.disabled),m=C(d,H.readOnly),ee=C(d,H.open),h=C(d,H.selectedValue),g=C(d,H.hasSelectionChips),_=St(),v=!1;v=f===`none`?_!==``:f===`single`?h!=null:g;let y=u||p||i,{buttonRef:te,getButtonProps:b}=Fe({native:a,disabled:y}),{mounted:x,transitionStatus:ne,setMounted:S}=Me(v),w={disabled:y,visible:v,open:ee,transitionStatus:ne};l({open:v,ref:d.state.clearRef,onComplete(){v||S(!1)}});let T=O(`button`,e,{state:w,ref:[t,te,d.state.clearRef],props:[{tabIndex:-1,children:`x`,onMouseDown(e){e.preventDefault()},onClick(e){if(y||m)return;let t=d.state.keyboardActiveRef.current?_e:Ne;d.state.setInputValue(``,L(le,e.nativeEvent)),f===`none`?d.state.setIndices({activeIndex:null,type:t}):(d.state.setSelectedValue(Array.isArray(h)?[]:null,L(le,e.nativeEvent)),d.state.setIndices({activeIndex:null,selectedIndex:null,type:t})),d.state.inputRef.current?.focus()}},c,b],stateAttributesMapping:q});return o||x?T:null}),Wt=R.createContext(null);function Gt(){return R.useContext(Wt)}function J(e){let{children:t}=e,{filteredItems:n}=V(),r=Gt(),i=r?r.items:n;return(0,z.jsx)(R.Fragment,{children:i.map(t)})}var Kt=R.forwardRef(function(e,t){var n;let{render:r,className:i,style:a,children:o,...s}=e,c=B(),l=xt(),u=!!G(!0),{filteredItems:d,hasItems:f}=V(),p=C(c,H.selectionMode),m=C(c,H.grid),ee=C(c,H.listProps),h=C(c,H.virtualized),g=C(c,H.forceMounted),_=p===`multiple`,v=d.length===0,y=D(e=>{c.set(`positionerElement`,e)}),te=D(e=>{c.set(`listElement`,e)}),b=R.useMemo(()=>typeof o==`function`?n||=(0,z.jsx)(J,{children:o}):o,[o]),ne={empty:v},S=l.useState(`floatingId`),w=O(`div`,e,{state:ne,ref:[t,te,u?null:y],props:[ee,{children:b,tabIndex:-1,id:S,role:m?`grid`:`listbox`,"aria-multiselectable":_?`true`:void 0,onKeyDown(e){if(!(c.state.disabled||c.state.readOnly)&&e.key===`Enter`){let t=c.state.activeIndex;if(t==null)return;x(e),U(c,t,e.nativeEvent)}},onKeyDownCapture(){c.state.keyboardActiveRef.current=!0},onPointerMoveCapture(){c.state.keyboardActiveRef.current=!1}},s]});if(h)return w;let T=f&&!g?void 0:c.state.labelsRef;return(0,z.jsx)(ge,{elementsRef:c.state.listRef,labelsRef:T,children:w})}),Y=`⁠`;function qt(e){let t=e.ownerDocument.createTreeWalker(e,NodeFilter.SHOW_TEXT),n=null;for(;t.nextNode();){let e=t.currentNode;e.nodeValue!==``&&(n=e)}return n}function Jt(){let e=j(),t=R.useRef(null);return R.useEffect(()=>{if(M)return;let n=t.current;if(n==null)return;let r=qt(n);if(r==null)return;let i=r.data,a=`${i}${Y}`;return r.nodeValue=a,e.start(200,()=>{r.nodeValue===a&&(r.nodeValue=i)}),()=>{e.clear(),r.nodeValue===a&&(r.nodeValue=i)}},[t,e]),t}var X=R.createContext(void 0);function Yt(){let e=R.useContext(X);if(e===void 0)throw Error(N(20));return e}var Xt=R.forwardRef(function(e,t){let{keepMounted:n=!1,...r}=e,i=B(),a=C(i,H.mounted),o=C(i,H.forceMounted);return a||n||o?(0,z.jsx)(X.Provider,{value:n,children:(0,z.jsx)(T,{ref:t,...r})}):null}),Zt=R.forwardRef(function(e,t){let{render:n,className:r,anchor:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:ee=!1,collisionAvoidance:h=g,style:_,...v}=e,y=B(),b=xt(),x=Yt(),ne=C(y,H.modal),S=C(y,H.open),w=C(y,H.mounted),T=C(y,H.openMethod),E=C(y,H.positionerElement),re=C(y,H.triggerElement),O=C(y,H.inputElement),k=C(y,H.inputGroupElement),j=C(y,H.inputInsidePopup),M=C(y,H.transitionStatus),N=It(),P=te({anchor:i??(j?re:k??O),floatingRootContext:b,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:ee,keepMounted:x,collisionAvoidance:h,lazyFlip:!0});pe(S&&ne,T===`touch`,E,re);let ae={open:S,side:P.side,align:P.align,anchorHidden:P.anchorHidden,empty:N};m(()=>{y.set(`popupSide`,P.side)},[y,P.side]);let oe=D(e=>{y.set(`positionerElement`,e)}),se=ie(e,ae,{styles:P.positionerStyles,transitionStatus:M,props:v,refs:[t,oe],hidden:!w,inert:!S});return(0,z.jsxs)(Vt.Provider,{value:P,children:[w&&ne&&(0,z.jsx)(Se,{inert:A(!S),cutout:k??O??re}),se]})}),Qt={...ae,...r},$t=R.forwardRef(function(e,t){let{render:n,className:r,style:i,initialFocus:a,finalFocus:o,...s}=e,c=B(),u=G(),d=xt(),f=C(c,H.mounted),ee=C(c,H.open),h=C(c,H.openMethod),g=C(c,H.popupProps),_=C(c,H.transitionStatus),v=C(c,H.inputInsidePopup),y=C(c,H.inputElement),te=C(c,H.modal),b=C(c,H.id),x=It(),w=s.id??(v?wt(b):void 0);m(()=>(c.set(`popupId`,c.state.popupRef.current?.id||w),()=>{c.set(`popupId`,void 0)}),[c,w]),l({open:ee,ref:c.state.popupRef,onComplete(){ee&&c.state.onOpenChangeComplete(!0)}});let T={open:ee,side:u.side,align:u.align,anchorHidden:u.anchorHidden,transitionStatus:_,empty:x},E=O(`div`,e,{state:T,ref:[t,c.state.popupRef],props:[g,{id:w,role:v?`dialog`:`presentation`,onFocus(e){let t=Ce(e.nativeEvent);h!==`touch`&&(S(c.state.listElement,t)||t===e.currentTarget)&&c.state.inputRef.current?.focus()}},p(_),s],stateAttributesMapping:Qt}),D=a===void 0?v?e=>e===`touch`?c.state.popupRef.current:y:!1:a,re;re=o??(v?void 0:!1);let k=!v||te;return(0,z.jsx)(ne,{context:d,disabled:!f,modal:k,openInteractionType:h,initialFocus:D,returnFocus:re,getInsideElements:()=>[c.state.startDismissRef.current,c.state.endDismissRef.current],children:(0,z.jsxs)(R.Fragment,{children:[E,k&&(0,z.jsx)(Ht,{ref:c.state.endDismissRef})]})})}),en=R.createContext(void 0);function Z(){let e=R.useContext(en);if(!e)throw Error(N(19));return e}var Q=R.createContext(!1);function tn(){return R.useContext(Q)}function nn(e){let{componentProps:t,forwardedRef:n,virtualized:r,indexFromFilter:i}=e,{render:a,className:o,style:s,value:c=null,index:l,disabled:u=!1,nativeButton:d=!1,...f}=t,p=R.useRef(null),ee=I({guess:!0,index:l,textRef:p}),h=B(),g=tn(),_=Ct(),v=C(h,H.selectionMode),y=C(h,H.disabled),te=C(h,H.readOnly),b=C(h,H.isItemEqualToValue),x=y||u,ne=v!==`none`,S=l??i??ee.index,w=S!==-1,T=C(h,H.id),E=C(h,H.isActive,S),D=C(h,H.isSelected,c),re=C(h,H.itemProps),k=R.useRef(null),A=T!=null&&w?`${T}-${S}`:void 0,j=D&&ne;m(()=>{if(!(w&&(r||l!=null)))return;let e=h.state.listRef.current;return e[S]=k.current,()=>{delete e[S]}},[w,r,S,l,h]),m(()=>{if(!w||_)return;let e=h.state.valuesRef.current;return e[S]=c,()=>{delete e[S]}},[w,_,S,c,h]),m(()=>{if(!w||_)return;let e=h.state.selectedValue,t=Array.isArray(e)?e[e.length-1]:e;Ke(c,t,b)&&h.set(`selectedIndex`,S)},[w,_,h,S,c,b]);let{getButtonProps:M,buttonRef:ie}=Fe({disabled:x,focusableWhenDisabled:!0,native:d,composite:!0}),N={disabled:x,selected:j,highlighted:E};function P(e){function t(){h.state.handleSelection(e,c)}h.state.submitOnItemClick?(mt.flushSync(t),h.state.requestSubmit()):t()}let ae={id:A,role:g?`gridcell`:`option`,"aria-selected":ne?j:void 0,tabIndex:void 0,onPointerDownCapture(e){e.isPrimary&&(h.state.pointerDownItemRef.current=e.currentTarget),e.preventDefault()},onMouseDown(e){e.preventDefault()},onClick(e){x||te||P(e.nativeEvent)},onMouseUp(e){let t=h.state.pointerDownItemRef.current===e.currentTarget;h.state.pointerDownItemRef.current=null,!(x||te||e.button!==0||t||!E)&&P(e.nativeEvent)}},oe=O(`div`,t,{ref:[ie,n,ee.ref,k],state:N,props:[re,ae,f,M]}),se=R.useMemo(()=>({selected:j,textRef:p}),[j,p]);return(0,z.jsx)(en.Provider,{value:se,children:oe})}function rn(e){let{componentProps:t,forwardedRef:n}=e,r=B(),i=C(r,H.isItemEqualToValue),{flatFilteredItems:a}=V(),o=Ve(a,t.value??null,i);return(0,z.jsx)(nn,{componentProps:t,forwardedRef:n,virtualized:!0,indexFromFilter:o})}var an=R.memo(R.forwardRef(function(e,t){let n=B(),r=C(n,H.virtualized);return r&&e.index==null?(0,z.jsx)(rn,{componentProps:e,forwardedRef:t}):(0,z.jsx)(nn,{componentProps:e,forwardedRef:t,virtualized:r,indexFromFilter:void 0})})),on=R.forwardRef(function(e,t){let{render:n,className:r,style:i,children:a,...o}=e,{filteredItems:s}=V(),c=B(),l=Jt(),u=s.length===0?a:null;return O(`div`,e,{ref:[t,c.state.emptyRef,l],props:[{children:u,role:`status`,"aria-live":`polite`,"aria-atomic":!0},o]})});function sn(e){let{multiple:t=!1,defaultValue:n,value:r,onValueChange:i,autoComplete:a,...o}=e;return(0,z.jsx)(Nt,{...o,selectionMode:t?`multiple`:`single`,selectedValue:r,defaultSelectedValue:n,onSelectedValueChange:i,formAutoComplete:a})}var cn=R.forwardRef(function(e,t){let{selected:n}=Z();return e.keepMounted||n?(0,z.jsx)(ln,{...e,ref:t}):null}),ln=R.memo(R.forwardRef((e,t)=>{let{render:n,className:i,style:a,keepMounted:o,...s}=e,{selected:c}=Z(),u=R.useRef(null),{transitionStatus:d,setMounted:f}=Me(c),p=O(`span`,e,{ref:[t,u],state:{selected:c,transitionStatus:d},props:[{"aria-hidden":!0,children:`✔️`},s],stateAttributesMapping:r});return l({open:c,ref:u,onComplete(){c||f(!1)}}),p})),un=sn;function dn({className:e,children:t,...n}){return(0,z.jsxs)(zt,{"data-slot":`combobox-trigger`,className:ze(`[&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,z.jsx)(Le,{className:`pointer-events-none size-4 text-muted-foreground`})]})}function fn({className:e,...t}){return(0,z.jsx)(Ut,{"data-slot":`combobox-clear`,render:(0,z.jsx)(ft,{variant:`ghost`,size:`icon-xs`}),className:ze(e),...t,children:(0,z.jsx)(lt,{className:`pointer-events-none`})})}function $({className:e,children:t,disabled:n=!1,showTrigger:r=!0,showClear:i=!1,...a}){return(0,z.jsxs)(pt,{className:ze(`w-auto`,e),children:[(0,z.jsx)(K,{render:(0,z.jsx)(ut,{disabled:n}),...a}),(0,z.jsxs)(dt,{align:`inline-end`,children:[r&&(0,z.jsx)(ft,{size:`icon-xs`,variant:`ghost`,render:(0,z.jsx)(dn,{}),"data-slot":`input-group-button`,className:`group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent`,disabled:n}),i&&(0,z.jsx)(fn,{disabled:n})]}),t]})}function pn({className:e,side:t=`bottom`,sideOffset:n=6,align:r=`start`,alignOffset:i=0,anchor:a,...o}){return(0,z.jsx)(Xt,{children:(0,z.jsx)(Zt,{side:t,sideOffset:n,align:r,alignOffset:i,anchor:a,className:`isolate z-50`,children:(0,z.jsx)($t,{"data-slot":`combobox-content`,"data-chips":!!a,className:ze(`group/combobox-content relative max-h-(--available-height) w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,e),...o})})})}function mn({className:e,...t}){return(0,z.jsx)(Kt,{"data-slot":`combobox-list`,className:ze(`no-scrollbar max-h-[min(calc(--spacing(72)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto overscroll-contain p-1 data-empty:p-0`,e),...t})}function hn({className:e,children:t,...n}){return(0,z.jsxs)(an,{"data-slot":`combobox-item`,className:ze(`relative flex w-full cursor-default items-center gap-2 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground not-data-[variant=destructive]:data-highlighted:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[t,(0,z.jsx)(cn,{render:(0,z.jsx)(`span`,{className:`pointer-events-none absolute right-2 flex size-4 items-center justify-center`}),children:(0,z.jsx)(i,{className:`pointer-events-none`})})]})}function gn({className:e,...t}){return(0,z.jsx)(on,{"data-slot":`combobox-empty`,className:ze(`hidden w-full justify-center py-2 text-center text-sm text-muted-foreground group-data-empty/combobox-content:flex`,e),...t})}function _n(e,t){let n=t.toLowerCase().split(/\s+/u).filter(Boolean),r=`${e.label} ${e.aside}`.toLowerCase();return n.every(e=>r.includes(e))}function vn({id:e,value:t,options:n,placeholder:r,label:i,onChange:a}){let o=n.find(e=>e.value===t)??null;return(0,z.jsxs)(un,{items:n,value:o,itemToStringLabel:e=>e.label,filter:(e,t)=>_n(e,t),onValueChange:e=>{a(e===null?``:e.value)},children:[(0,z.jsx)($,{id:e,"aria-label":i,placeholder:r,className:`bg-field dark:bg-field`,showTrigger:!1,children:(0,z.jsxs)(dt,{align:`inline-end`,children:[o!==null&&o.aside!==``&&(0,z.jsx)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:o.aside}),(0,z.jsx)(ft,{size:`icon-xs`,variant:`ghost`,render:(0,z.jsx)(dn,{})})]})}),(0,z.jsxs)(pn,{children:[(0,z.jsx)(gn,{children:`No match.`}),(0,z.jsx)(mn,{children:e=>(0,z.jsxs)(hn,{value:e,children:[(0,z.jsx)(`span`,{className:`truncate`,children:e.label}),e.aside!==``&&(0,z.jsx)(`span`,{className:`text-muted-foreground ml-auto font-mono text-xs whitespace-nowrap`,children:e.aside})]},e.value)})]})]})}export{vn as t};