base-screen 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (518) hide show
  1. package/README.md +3 -12
  2. package/dist/_internal/contracts/document/blueprint-capabilities.d.ts +9 -1
  3. package/dist/_internal/contracts/document/blueprint-capabilities.js +16 -0
  4. package/dist/_internal/contracts/document/blueprint-graph.d.ts +68 -0
  5. package/dist/_internal/contracts/document/blueprint-graph.js +424 -0
  6. package/dist/_internal/contracts/document/blueprint-strict.d.ts +3 -1
  7. package/dist/_internal/contracts/document/blueprint-strict.js +77 -91
  8. package/dist/_internal/contracts/document/component-states.d.ts +54 -0
  9. package/dist/_internal/contracts/document/component-states.js +171 -0
  10. package/dist/_internal/contracts/document/json-schema.js +49 -17
  11. package/dist/_internal/contracts/document/limits.d.ts +40 -8
  12. package/dist/_internal/contracts/document/limits.js +40 -8
  13. package/dist/_internal/contracts/document/parse-parts.d.ts +12 -0
  14. package/dist/_internal/contracts/document/parse-parts.js +56 -0
  15. package/dist/_internal/contracts/document/parse.js +1 -1
  16. package/dist/_internal/contracts/document/references.js +108 -41
  17. package/dist/_internal/contracts/document/schema.d.ts +532 -186
  18. package/dist/_internal/contracts/document/schema.js +235 -96
  19. package/dist/_internal/contracts/document/sub-canvas.d.ts +27 -0
  20. package/dist/_internal/contracts/document/sub-canvas.js +38 -0
  21. package/dist/_internal/contracts/document/theme.d.ts +22 -0
  22. package/dist/_internal/contracts/document/theme.js +65 -0
  23. package/dist/_internal/contracts/document/validate-blueprint.d.ts +7 -0
  24. package/dist/_internal/contracts/document/validate-blueprint.js +223 -25
  25. package/dist/_internal/contracts/document/validate-component.d.ts +2 -0
  26. package/dist/_internal/contracts/document/validate-component.js +111 -54
  27. package/dist/_internal/contracts/document/validate-data-source.js +84 -9
  28. package/dist/_internal/contracts/document/validate-sub-canvas.d.ts +9 -0
  29. package/dist/_internal/contracts/document/validate-sub-canvas.js +92 -0
  30. package/dist/_internal/contracts/document/validate-theme.d.ts +4 -0
  31. package/dist/_internal/contracts/document/validate-theme.js +20 -0
  32. package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
  33. package/dist/_internal/contracts/document/validate.js +19 -2
  34. package/dist/_internal/contracts/index.d.ts +11 -4
  35. package/dist/_internal/contracts/index.js +8 -2
  36. package/dist/_internal/contracts/migration/blueprint-graph-migration.d.ts +21 -0
  37. package/dist/_internal/contracts/migration/blueprint-graph-migration.js +328 -0
  38. package/dist/_internal/contracts/migration/migrate-document.d.ts +2 -1
  39. package/dist/_internal/contracts/migration/migrate-document.js +11 -3
  40. package/dist/_internal/contracts/push/delivery.d.ts +16 -0
  41. package/dist/_internal/contracts/push/delivery.js +70 -0
  42. package/dist/_internal/contracts/push/level-scale.d.ts +7 -0
  43. package/dist/_internal/contracts/push/level-scale.js +91 -0
  44. package/dist/_internal/contracts/screen-document.schema.json +1071 -386
  45. package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
  46. package/dist/_internal/contracts/types/document.d.ts +280 -77
  47. package/dist/_internal/contracts/types/execution.d.ts +12 -2
  48. package/dist/_internal/contracts/types/execution.js +0 -5
  49. package/dist/_internal/contracts/types/host.d.ts +35 -1
  50. package/dist/_internal/contracts/types/host.js +7 -1
  51. package/dist/_internal/contracts/types/push.d.ts +86 -0
  52. package/dist/_internal/contracts/types/push.js +1 -0
  53. package/dist/_internal/contracts/types/variable.d.ts +5 -0
  54. package/dist/_internal/contracts/variable/parse.js +30 -1
  55. package/dist/_internal/core/blueprint/runtime-compile.d.ts +4 -0
  56. package/dist/_internal/core/blueprint/runtime-compile.js +45 -21
  57. package/dist/_internal/core/blueprint/runtime-dispatch.js +270 -156
  58. package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
  59. package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
  60. package/dist/_internal/core/blueprint/runtime-types.d.ts +112 -6
  61. package/dist/_internal/core/blueprint/runtime.d.ts +2 -1
  62. package/dist/_internal/core/blueprint/runtime.js +1 -0
  63. package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
  64. package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
  65. package/dist/_internal/core/commands/apply-component-commands.d.ts +5 -0
  66. package/dist/_internal/core/commands/apply-component-commands.js +74 -2
  67. package/dist/_internal/core/commands/apply.js +76 -3
  68. package/dist/_internal/core/commands/parse-command.js +24 -0
  69. package/dist/_internal/core/commands/types.d.ts +56 -3
  70. package/dist/_internal/core/data/data-candidates.d.ts +38 -0
  71. package/dist/_internal/core/data/data-candidates.js +186 -0
  72. package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
  73. package/dist/_internal/core/data/dataset-profile.js +170 -0
  74. package/dist/_internal/core/data/sample-values.d.ts +25 -0
  75. package/dist/_internal/core/data/sample-values.js +45 -0
  76. package/dist/_internal/core/diff/screen-diff.js +7 -1
  77. package/dist/_internal/core/index.d.ts +7 -1
  78. package/dist/_internal/core/index.js +7 -1
  79. package/dist/_internal/core/state/state-preset.d.ts +32 -0
  80. package/dist/_internal/core/state/state-preset.js +37 -0
  81. package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
  82. package/dist/_internal/core/validation/layout-audit.js +228 -0
  83. package/dist/_internal/core/validation/legibility.d.ts +9 -0
  84. package/dist/_internal/core/validation/legibility.js +33 -0
  85. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge-helpers.d.ts +1 -1
  86. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge.d.ts +11 -1
  87. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-panels-controller.d.ts +18 -4
  88. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-timer-scheduler.d.ts +21 -0
  89. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-workbench-panel.d.ts +8 -1
  90. package/dist/_internal/engine/browser/controllers/dataset/designer-data-source-authoring.d.ts +25 -1
  91. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-controller-context.d.ts +6 -2
  92. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +14 -1
  93. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-surface-controller.d.ts +14 -0
  94. package/dist/_internal/engine/browser/controllers/dataset/designer-update-policy-authoring.d.ts +52 -0
  95. package/dist/_internal/engine/browser/controllers/designer-artboard-controller.d.ts +80 -0
  96. package/dist/_internal/engine/browser/controllers/designer-canvas-runtime-controller.d.ts +21 -3
  97. package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +29 -0
  98. package/dist/_internal/engine/browser/controllers/designer-command-palette-controller.d.ts +2 -0
  99. package/dist/_internal/engine/browser/controllers/designer-notification-controller.d.ts +7 -0
  100. package/dist/_internal/engine/browser/controllers/designer-page-preview-controller.d.ts +34 -0
  101. package/dist/_internal/engine/browser/controllers/designer-popup-preview-controller.d.ts +40 -0
  102. package/dist/_internal/engine/browser/controllers/designer-preview-controller.d.ts +1 -3
  103. package/dist/_internal/engine/browser/controllers/designer-reference-layer-controller.d.ts +45 -0
  104. package/dist/_internal/engine/browser/controllers/designer-viewport-controller.d.ts +10 -0
  105. package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-callbacks.d.ts +5 -1
  106. package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-controller.d.ts +2 -0
  107. package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-environment.d.ts +18 -7
  108. package/dist/_internal/engine/browser/controllers/gesture/designer-group-editing-controller.d.ts +8 -1
  109. package/dist/_internal/engine/browser/controllers/layers/designer-layers-controller.d.ts +11 -0
  110. package/dist/_internal/engine/browser/controllers/panel/designer-component-states-controller.d.ts +26 -0
  111. package/dist/_internal/engine/browser/controllers/panel/designer-inspector-focus.d.ts +30 -0
  112. package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller-callbacks.d.ts +23 -6
  113. package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller.d.ts +2 -2
  114. package/dist/_internal/engine/browser/controllers/panel/designer-panel-material-controller.d.ts +4 -0
  115. package/dist/_internal/engine/browser/controllers/panel/designer-panel-property-controller.d.ts +2 -0
  116. package/dist/_internal/engine/browser/controllers/workbench/designer-snap-controller.d.ts +5 -1
  117. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-controller.d.ts +7 -1
  118. package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-inspector-configuration.d.ts +12 -0
  119. package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-library-dom.d.ts +18 -2
  120. package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +22 -5
  121. package/dist/_internal/engine/browser/dom/color/designer-color-palette-dom.d.ts +1 -0
  122. package/dist/_internal/engine/browser/dom/color/designer-color-palette-theme.d.ts +10 -0
  123. package/dist/_internal/engine/browser/dom/color/designer-color-palette-types.d.ts +13 -0
  124. package/dist/_internal/engine/browser/dom/color/designer-color-theme-slots.d.ts +10 -0
  125. package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
  126. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-types.d.ts +17 -6
  127. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-control-dom.d.ts +17 -1
  128. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-model.d.ts +2 -0
  129. package/dist/_internal/engine/browser/dom/designer-field-primitives.d.ts +43 -1
  130. package/dist/_internal/engine/browser/dom/designer-icons.d.ts +2 -0
  131. package/dist/_internal/engine/browser/dom/designer-select-dom.d.ts +2 -0
  132. package/dist/_internal/engine/browser/dom/designer-ui-primitives.d.ts +5 -0
  133. package/dist/_internal/engine/browser/dom/layers/designer-layers-model.d.ts +28 -0
  134. package/dist/_internal/engine/browser/dom/material-library/designer-material-library-dom.d.ts +18 -2
  135. package/dist/_internal/engine/browser/dom/material-library/designer-material-library-group-view.d.ts +1 -0
  136. package/dist/_internal/engine/browser/dom/menu/designer-menu-model.d.ts +4 -2
  137. package/dist/_internal/engine/browser/dom/panel/designer-canvas-properties-dom.d.ts +10 -2
  138. package/dist/_internal/engine/browser/dom/panel/designer-canvas-transactions.d.ts +5 -1
  139. package/dist/_internal/engine/browser/dom/panel/designer-chrome-primitives.d.ts +12 -0
  140. package/dist/_internal/engine/browser/dom/panel/designer-color-group-dom.d.ts +45 -0
  141. package/dist/_internal/engine/browser/dom/panel/designer-component-properties-dom.d.ts +4 -3
  142. package/dist/_internal/engine/browser/dom/panel/designer-component-states-dom.d.ts +22 -0
  143. package/dist/_internal/engine/browser/dom/panel/designer-panel-primitives.d.ts +18 -2
  144. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +2 -0
  145. package/dist/_internal/engine/browser/dom/workspace/designer-workspace-template.d.ts +13 -0
  146. package/dist/_internal/engine/browser/dom/workspace/designer-workspace.d.ts +2 -1
  147. package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +10 -4
  148. package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +17 -5
  149. package/dist/_internal/engine/browser/viewport/designer-canvas-coordinates.d.ts +7 -0
  150. package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +8 -9
  151. package/dist/_internal/engine/browser/viewport/designer-canvas-snap-alignment-index.d.ts +27 -0
  152. package/dist/_internal/engine/browser/viewport/designer-canvas-snap-geometry.d.ts +13 -2
  153. package/dist/_internal/engine/browser/viewport/designer-canvas-snap-preview.d.ts +1 -1
  154. package/dist/_internal/engine/browser/viewport/designer-canvas-snap-spacing.d.ts +12 -0
  155. package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +4 -0
  156. package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
  157. package/dist/_internal/engine/common/observability/designer-metrics.d.ts +1 -1
  158. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-geometry.d.ts +12 -0
  159. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-graph.d.ts +203 -0
  160. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model-types.d.ts +6 -2
  161. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model.d.ts +58 -7
  162. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-protocol-types.d.ts +131 -51
  163. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-value-sources.d.ts +7 -3
  164. package/dist/_internal/engine/common/operations/catalog/designer-catalog-refresh.d.ts +13 -1
  165. package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
  166. package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
  167. package/dist/_internal/engine/common/operations/designer-operation-registry.d.ts +5 -1
  168. package/dist/_internal/engine/common/operations/designer-variable-operations.d.ts +8 -0
  169. package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
  170. package/dist/_internal/engine/common/operations/element/designer-element-operation-types.d.ts +8 -0
  171. package/dist/_internal/engine/common/operations/host-resource/host-resource-authoring.d.ts +1 -1
  172. package/dist/_internal/engine/common/operations/material-component/material-component-fragment-extract.d.ts +34 -0
  173. package/dist/_internal/engine/common/operations/material-component/material-component-fragment.d.ts +24 -41
  174. package/dist/_internal/engine/common/operations/material-component/material-component.d.ts +1 -1
  175. package/dist/_internal/engine/common/operations/material-library/material-library-fragments.d.ts +46 -0
  176. package/dist/_internal/engine/common/operations/material-library/material-library-grouping.d.ts +11 -0
  177. package/dist/_internal/engine/common/operations/selection/designer-group.d.ts +16 -4
  178. package/dist/_internal/engine/common/operations/selection/designer-multi-selection-operations.d.ts +4 -3
  179. package/dist/_internal/engine/common/operations/selection/designer-selection-actions.d.ts +6 -0
  180. package/dist/_internal/engine/common/operations/selection/designer-selection.d.ts +8 -0
  181. package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +67 -0
  182. package/dist/_internal/engine/common/operations/style/designer-material-appearance.d.ts +30 -0
  183. package/dist/_internal/engine/common/session/designer-artboard.d.ts +40 -0
  184. package/dist/_internal/engine/common/session/designer-session.d.ts +21 -0
  185. package/dist/_internal/engine/common/ui-text/designer-blueprint-ui-text.d.ts +169 -0
  186. package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +464 -90
  187. package/dist/_internal/engine/designer-blueprint-workbench-panel-BWSglfAb.js +2792 -0
  188. package/dist/_internal/engine/{designer-dataset-controller-CPytVNBK.js → designer-dataset-controller-DdbY4ILC.js} +1919 -1604
  189. package/dist/_internal/engine/designer-element/api/designer-element-catalog.d.ts +4 -3
  190. package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
  191. package/dist/_internal/engine/designer-element/api/designer-element-configuration-types.d.ts +11 -8
  192. package/dist/_internal/engine/designer-element/api/designer-element-fragment-save.d.ts +16 -0
  193. package/dist/_internal/engine/designer-element/api/designer-element-host-properties.d.ts +0 -5
  194. package/dist/_internal/engine/designer-element/api/designer-element-insert-component-fragment.d.ts +9 -2
  195. package/dist/_internal/engine/designer-element/api/designer-element-material-library-fragments.d.ts +17 -0
  196. package/dist/_internal/engine/designer-element/api/designer-element-project.d.ts +0 -1
  197. package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +36 -24
  198. package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +7 -6
  199. package/dist/_internal/engine/designer-element/runtime/designer-element-guards.d.ts +0 -2
  200. package/dist/_internal/engine/designer-element/runtime/designer-element-host.d.ts +6 -7
  201. package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +12 -2
  202. package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +19 -15
  203. package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
  204. package/dist/_internal/engine/designer-element/runtime/designer-element-state.d.ts +29 -10
  205. package/dist/_internal/engine/{designer-ui-primitives-CH4RNiMa.js → designer-field-primitives-Crn464Qg.js} +919 -348
  206. package/dist/_internal/engine/designer-left-panel-groups-dom-DFdLWxxY.js +1282 -0
  207. package/dist/_internal/engine/host-resource-selection-CWrPLVOc.js +2482 -0
  208. package/dist/_internal/engine/host-tokens.css +12 -12
  209. package/dist/_internal/engine/index.js +9202 -6279
  210. package/dist/_internal/host-kit/index.d.ts +3 -0
  211. package/dist/_internal/host-kit/index.js +3 -0
  212. package/dist/_internal/host-kit/intent/index.d.ts +16 -0
  213. package/dist/_internal/host-kit/intent/index.js +13 -0
  214. package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
  215. package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
  216. package/dist/_internal/host-kit/intent/intent-block.d.ts +59 -0
  217. package/dist/_internal/host-kit/intent/intent-block.js +359 -0
  218. package/dist/_internal/host-kit/intent/intent-catalog.d.ts +105 -0
  219. package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
  220. package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
  221. package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
  222. package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
  223. package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
  224. package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
  225. package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
  226. package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
  227. package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
  228. package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
  229. package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
  230. package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
  231. package/dist/_internal/host-kit/intent/intent-format.js +94 -0
  232. package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
  233. package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
  234. package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
  235. package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
  236. package/dist/_internal/host-kit/intent/intent-parse.d.ts +39 -0
  237. package/dist/_internal/host-kit/intent/intent-parse.js +930 -0
  238. package/dist/_internal/host-kit/intent/intent-prepare.d.ts +52 -0
  239. package/dist/_internal/host-kit/intent/intent-prepare.js +104 -0
  240. package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
  241. package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
  242. package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
  243. package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
  244. package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
  245. package/dist/_internal/host-kit/intent/intent-style.js +77 -0
  246. package/dist/_internal/host-kit/intent/intent-types.d.ts +234 -0
  247. package/dist/_internal/host-kit/intent/intent-types.js +10 -0
  248. package/dist/_internal/host-kit/push-result.d.ts +5 -0
  249. package/dist/_internal/host-kit/push-result.js +8 -0
  250. package/dist/_internal/host-kit/sse-subscribe.d.ts +59 -0
  251. package/dist/_internal/host-kit/sse-subscribe.js +253 -0
  252. package/dist/_internal/host-kit/subscription-hub.d.ts +41 -0
  253. package/dist/_internal/host-kit/subscription-hub.js +179 -0
  254. package/dist/_internal/material/base-material.d.ts +1 -0
  255. package/dist/_internal/material/chart.d.ts +4 -0
  256. package/dist/_internal/material/chart.js +123 -58
  257. package/dist/_internal/material/container.js +19 -33
  258. package/dist/_internal/material/{base-material-BArgjOeL.js → editor-descriptor-DJZYygOa.js} +49 -20
  259. package/dist/_internal/material/editor-descriptor.d.ts +18 -0
  260. package/dist/_internal/material/image.js +30 -34
  261. package/dist/_internal/material/rule.js +29 -42
  262. package/dist/_internal/material/shapes.js +57 -74
  263. package/dist/_internal/material/table.d.ts +4 -0
  264. package/dist/_internal/material/table.js +149 -71
  265. package/dist/_internal/material/text.js +40 -68
  266. package/dist/_internal/plugin-core/contracts.d.ts +38 -49
  267. package/dist/_internal/plugin-core/contribution-kind.js +47 -2
  268. package/dist/_internal/plugin-core/editor/editor-ai-description.d.ts +3 -0
  269. package/dist/_internal/plugin-core/editor/editor-ai-description.js +124 -0
  270. package/dist/_internal/plugin-core/editor/editor-descriptor-conditions.js +5 -0
  271. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.d.ts +32 -0
  272. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.js +83 -0
  273. package/dist/_internal/plugin-core/editor/editor-descriptor-items.d.ts +6 -0
  274. package/dist/_internal/plugin-core/editor/editor-descriptor-items.js +41 -12
  275. package/dist/_internal/plugin-core/editor/editor-descriptor-model.d.ts +24 -1
  276. package/dist/_internal/plugin-core/editor/editor-descriptor-model.js +6 -1
  277. package/dist/_internal/plugin-core/editor/editor-descriptor-schema.js +21 -0
  278. package/dist/_internal/plugin-core/editor/editor-descriptor-sections.js +5 -7
  279. package/dist/_internal/plugin-core/editor/editor-descriptor.d.ts +1 -0
  280. package/dist/_internal/plugin-core/editor/editor-descriptor.js +55 -2
  281. package/dist/_internal/plugin-core/fragment/fragment.d.ts +96 -0
  282. package/dist/_internal/plugin-core/fragment/fragment.js +535 -0
  283. package/dist/_internal/plugin-core/index.d.ts +7 -4
  284. package/dist/_internal/plugin-core/index.js +5 -2
  285. package/dist/_internal/plugin-core/material/material-manifest.js +14 -2
  286. package/dist/_internal/plugin-core/material/material-schema.d.ts +9 -0
  287. package/dist/_internal/plugin-core/material/material-schema.js +31 -1
  288. package/dist/_internal/plugin-core/material/material-theme.d.ts +25 -0
  289. package/dist/_internal/plugin-core/material/material-theme.js +77 -0
  290. package/dist/_internal/plugin-core/material/material-validation-constants.js +2 -0
  291. package/dist/_internal/plugin-core/material/material.d.ts +1 -1
  292. package/dist/_internal/plugin-core/material/material.js +1 -1
  293. package/dist/_internal/plugin-manager/contribution-kind-plan.d.ts +2 -1
  294. package/dist/_internal/plugin-manager/contribution-kind-plan.js +6 -0
  295. package/dist/_internal/plugin-manager/contributions.js +10 -0
  296. package/dist/_internal/plugin-sdk/authoring-finding.d.ts +19 -0
  297. package/dist/_internal/plugin-sdk/authoring-finding.js +12 -0
  298. package/dist/_internal/plugin-sdk/fragment-audit.d.ts +14 -0
  299. package/dist/_internal/plugin-sdk/fragment-audit.js +170 -0
  300. package/dist/_internal/plugin-sdk/fragment-definition.d.ts +11 -0
  301. package/dist/_internal/plugin-sdk/fragment-definition.js +16 -0
  302. package/dist/_internal/plugin-sdk/index.d.ts +15 -0
  303. package/dist/_internal/plugin-sdk/index.js +15 -0
  304. package/dist/_internal/plugin-sdk/material-config-groups.d.ts +44 -0
  305. package/dist/_internal/plugin-sdk/material-config-groups.js +80 -0
  306. package/dist/_internal/plugin-sdk/material-editor-audit.d.ts +24 -0
  307. package/dist/_internal/plugin-sdk/material-editor-audit.js +160 -0
  308. package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
  309. package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
  310. package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
  311. package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
  312. package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
  313. package/dist/_internal/plugin-sdk/material-isolated.js +1024 -0
  314. package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +77 -0
  315. package/dist/_internal/plugin-sdk/material-rendered-element.js +229 -0
  316. package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +24 -0
  317. package/dist/_internal/plugin-sdk/material-spec-audit.js +204 -0
  318. package/dist/_internal/plugin-sdk/material-spec.d.ts +134 -0
  319. package/dist/_internal/plugin-sdk/material-spec.js +710 -0
  320. package/dist/_internal/plugin-sdk/material-style-keys.d.ts +17 -0
  321. package/dist/_internal/plugin-sdk/material-style-keys.js +82 -0
  322. package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
  323. package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
  324. package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
  325. package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
  326. package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
  327. package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
  328. package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
  329. package/dist/_internal/plugin-sdk/material-template.js +879 -0
  330. package/dist/_internal/renderer/index.d.ts +2 -0
  331. package/dist/_internal/renderer/index.js +1745 -616
  332. package/dist/_internal/renderer/renderer/renderer-component-states.d.ts +34 -0
  333. package/dist/_internal/renderer/renderer/renderer-effective-style.d.ts +12 -6
  334. package/dist/_internal/renderer/renderer/renderer-material-dom.d.ts +19 -3
  335. package/dist/_internal/renderer/renderer/renderer-mounted-material.d.ts +11 -10
  336. package/dist/_internal/renderer/renderer/renderer-state.d.ts +17 -1
  337. package/dist/_internal/renderer/renderer/renderer-theme.d.ts +11 -0
  338. package/dist/_internal/renderer/renderer/renderer-types.d.ts +15 -5
  339. package/dist/_internal/renderer/renderer/renderer.d.ts +30 -9
  340. package/dist/_internal/renderer/resource/data-source-runtime.d.ts +25 -2
  341. package/dist/_internal/renderer/resource/push-window.d.ts +43 -0
  342. package/dist/_internal/renderer/resource/source-query-port.d.ts +8 -1
  343. package/dist/_internal/renderer/sub-canvas-layer.d.ts +83 -0
  344. package/dist/_internal/renderer/viewer/viewer-blueprint-timer-scheduler.d.ts +23 -0
  345. package/dist/_internal/renderer/viewer/viewer-configuration-guards.d.ts +0 -1
  346. package/dist/_internal/renderer/viewer/viewer-configuration.d.ts +6 -3
  347. package/dist/_internal/renderer/viewer/viewer-stale-style.d.ts +3 -0
  348. package/dist/_internal/renderer/viewer/viewer-variable-controller.d.ts +2 -0
  349. package/dist/_internal/renderer/viewer/viewer.d.ts +18 -7
  350. package/dist/_internal/sdk/auto-register.js +7 -7
  351. package/dist/_internal/sdk/designer-auto-register.js +3 -3
  352. package/dist/_internal/sdk/designer.d.ts +1 -1
  353. package/dist/_internal/sdk/designer.js +8 -8
  354. package/dist/_internal/sdk/host-tokens.css +12 -12
  355. package/dist/_internal/sdk/index.d.ts +1 -1
  356. package/dist/_internal/sdk/index.js +6 -6
  357. package/dist/auto-register.js +11 -11
  358. package/dist/auto-register.js.map +1 -1
  359. package/dist/contracts.js +73 -43
  360. package/dist/contracts.js.map +1 -1
  361. package/dist/contrast-DRPezUIl.js +131 -0
  362. package/dist/contrast-DRPezUIl.js.map +1 -0
  363. package/dist/core.js +169 -21
  364. package/dist/core.js.map +1 -1
  365. package/dist/{data-contracts-BFld0hw_.js → data-contracts-CnnB5KC9.js} +2 -2
  366. package/dist/{data-contracts-BFld0hw_.js.map → data-contracts-CnnB5KC9.js.map} +1 -1
  367. package/dist/dataset-port-D993nOlT.js +182 -0
  368. package/dist/dataset-port-D993nOlT.js.map +1 -0
  369. package/dist/dataset-profile-Dk6xdtsM.js +261 -0
  370. package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
  371. package/dist/{designer-Byw45cUM.js → designer-CFOvOmLn.js} +3 -3
  372. package/dist/designer-CFOvOmLn.js.map +1 -0
  373. package/dist/designer-auto-register.js +6 -6
  374. package/dist/designer-auto-register.js.map +1 -1
  375. package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js +2773 -0
  376. package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map +1 -0
  377. package/dist/{designer-dataset-controller-CPytVNBK-DWL3SRTP.js → designer-dataset-controller-DdbY4ILC-CMdGdGbr.js} +1471 -1158
  378. package/dist/designer-dataset-controller-DdbY4ILC-CMdGdGbr.js.map +1 -0
  379. package/dist/{designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js → designer-field-primitives-Crn464Qg-Bi7q8s5J.js} +914 -345
  380. package/dist/designer-field-primitives-Crn464Qg-Bi7q8s5J.js.map +1 -0
  381. package/dist/designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js +1265 -0
  382. package/dist/designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js.map +1 -0
  383. package/dist/designer.js +5 -5
  384. package/dist/dist-B2bW2Tru.js +3305 -0
  385. package/dist/dist-B2bW2Tru.js.map +1 -0
  386. package/dist/{dist-BHTClwId.js → dist-CHK9BTXX.js} +9148 -6234
  387. package/dist/dist-CHK9BTXX.js.map +1 -0
  388. package/dist/engine.js +5 -4
  389. package/dist/fragment-B-oP0Fru.js +393 -0
  390. package/dist/fragment-B-oP0Fru.js.map +1 -0
  391. package/dist/host-kit.js +4172 -102
  392. package/dist/host-kit.js.map +1 -1
  393. package/dist/{host-resource-selection-5Cf_gclK-Sv4Z8UXS.js → host-resource-selection-CWrPLVOc-DPDq3jau.js} +1233 -937
  394. package/dist/host-resource-selection-CWrPLVOc-DPDq3jau.js.map +1 -0
  395. package/dist/host-tokens.css +12 -12
  396. package/dist/index.js +10 -10
  397. package/dist/legibility-CS28ivEz.js +12 -0
  398. package/dist/legibility-CS28ivEz.js.map +1 -0
  399. package/dist/level-scale-CwHqFEVd.js +139 -0
  400. package/dist/level-scale-CwHqFEVd.js.map +1 -0
  401. package/dist/{manager-B2CZ2b5I.js → manager-CeB4Jnr9.js} +20 -10
  402. package/dist/manager-CeB4Jnr9.js.map +1 -0
  403. package/dist/material-DeVkzSoT.js +12 -0
  404. package/dist/{material-BPlvEmDi.js.map → material-DeVkzSoT.js.map} +1 -1
  405. package/dist/material-auto-register.js +6 -6
  406. package/dist/material-auto-register.js.map +1 -1
  407. package/dist/{material-definition-B9xCZcD-.js → material-definition-BeW34dJr.js} +2 -2
  408. package/dist/{material-definition-B9xCZcD-.js.map → material-definition-BeW34dJr.js.map} +1 -1
  409. package/dist/{material-manifest-bsGl6vZZ.js → material-manifest-B1XatGPx.js} +222 -137
  410. package/dist/material-manifest-B1XatGPx.js.map +1 -0
  411. package/dist/material-schema-CLoDx-Tl.js +203 -0
  412. package/dist/material-schema-CLoDx-Tl.js.map +1 -0
  413. package/dist/{editor-descriptor-schema-Be30Wv8w.js → material-theme-C91eus78.js} +90 -28
  414. package/dist/material-theme-C91eus78.js.map +1 -0
  415. package/dist/material-validation-utils-ku_6Xxk2.js +125 -0
  416. package/dist/material-validation-utils-ku_6Xxk2.js.map +1 -0
  417. package/dist/material.js +3 -3
  418. package/dist/migrate-document-BM888PtC.js +768 -0
  419. package/dist/migrate-document-BM888PtC.js.map +1 -0
  420. package/dist/parse-Ji7kE9ZT.js +2313 -0
  421. package/dist/parse-Ji7kE9ZT.js.map +1 -0
  422. package/dist/{parse-B0hwp_yj.js → parse-aZat9tAS.js} +69 -61
  423. package/dist/{parse-B0hwp_yj.js.map → parse-aZat9tAS.js.map} +1 -1
  424. package/dist/parse-parts-qzl4suzk.js +42 -0
  425. package/dist/parse-parts-qzl4suzk.js.map +1 -0
  426. package/dist/{plugin-B9Xxtw7G.js → plugin-CstHQ5ws.js} +140 -94
  427. package/dist/plugin-CstHQ5ws.js.map +1 -0
  428. package/dist/plugin-core.js +93 -8
  429. package/dist/plugin-core.js.map +1 -0
  430. package/dist/plugin-manager.js +1 -1
  431. package/dist/plugin-package-DWifuHi1.js +4206 -0
  432. package/dist/plugin-package-DWifuHi1.js.map +1 -0
  433. package/dist/{plugin-registration-BjS_CXJU.js → plugin-registration-DTwBvnHX.js} +4 -4
  434. package/dist/{plugin-registration-BjS_CXJU.js.map → plugin-registration-DTwBvnHX.js.map} +1 -1
  435. package/dist/plugin-sdk.js +6 -6
  436. package/dist/{plugins-B9bwk-t6.js → plugins-QDL0yIql.js} +2 -2
  437. package/dist/{plugins-B9bwk-t6.js.map → plugins-QDL0yIql.js.map} +1 -1
  438. package/dist/plugins.js +8 -8
  439. package/dist/renderer.js +1 -1
  440. package/dist/runtime-dispatch-C0gyIrTv.js +479 -0
  441. package/dist/runtime-dispatch-C0gyIrTv.js.map +1 -0
  442. package/dist/runtime-simulate-aSYO9yDX.js +147 -0
  443. package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
  444. package/dist/{src-Bm7u11mN-BMeb9fvV.js → src-Bm7u11mN-Bi1hDVkh.js} +30 -30
  445. package/dist/{src-Bm7u11mN-BMeb9fvV.js.map → src-Bm7u11mN-Bi1hDVkh.js.map} +1 -1
  446. package/dist/state-preset-DtpygJOH.js +22 -0
  447. package/dist/state-preset-DtpygJOH.js.map +1 -0
  448. package/dist/{text-BVzTcUas.js → text-BSTz0pFQ.js} +454 -360
  449. package/dist/text-BSTz0pFQ.js.map +1 -0
  450. package/dist/theme-CcBXf4Ay.js +48 -0
  451. package/dist/theme-CcBXf4Ay.js.map +1 -0
  452. package/dist/{value-ref-y4_YKUP5.js → value-ref-XkLuckGV.js} +2 -2
  453. package/dist/{value-ref-y4_YKUP5.js.map → value-ref-XkLuckGV.js.map} +1 -1
  454. package/dist/{viewer-CrJupI8I-DZZfdHXr.js → viewer-CrJupI8I-BJiz1cvW.js} +5 -5
  455. package/dist/{viewer-CrJupI8I-DZZfdHXr.js.map → viewer-CrJupI8I-BJiz1cvW.js.map} +1 -1
  456. package/dist/viewer-auto-register.js +2 -2
  457. package/dist/viewer.js +2 -2
  458. package/dist/viewport-BNIRWjiT.js +1207 -0
  459. package/dist/viewport-BNIRWjiT.js.map +1 -0
  460. package/package.json +12 -12
  461. package/dist/_internal/contracts/document/blueprint-relations.d.ts +0 -16
  462. package/dist/_internal/contracts/document/blueprint-relations.js +0 -196
  463. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-panel-mutations.d.ts +0 -5
  464. package/dist/_internal/engine/browser/controllers/designer-guard-controller.d.ts +0 -27
  465. package/dist/_internal/engine/browser/controllers/designer-scene-controller.d.ts +0 -47
  466. package/dist/_internal/engine/browser/controllers/panel/designer-style-rules-controller.d.ts +0 -12
  467. package/dist/_internal/engine/browser/dom/guard/designer-contrast-measure.d.ts +0 -24
  468. package/dist/_internal/engine/browser/dom/guard/designer-guard-dom.d.ts +0 -15
  469. package/dist/_internal/engine/browser/dom/workspace/designer-canvas-hint-dom.d.ts +0 -6
  470. package/dist/_internal/engine/browser/viewport/designer-canvas-snap-index.d.ts +0 -9
  471. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-connection.d.ts +0 -14
  472. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-mutation-helpers.d.ts +0 -20
  473. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-mutations.d.ts +0 -15
  474. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-node-ids.d.ts +0 -12
  475. package/dist/_internal/engine/common/operations/designer-name-validation.d.ts +0 -2
  476. package/dist/_internal/engine/common/operations/scene/designer-scene.d.ts +0 -55
  477. package/dist/_internal/engine/common/operations/style/designer-host-conditional-style.d.ts +0 -21
  478. package/dist/_internal/engine/common/operations/style/designer-style-rules.d.ts +0 -25
  479. package/dist/_internal/engine/common/validation/designer-guard.d.ts +0 -49
  480. package/dist/_internal/engine/designer-blueprint-workbench-panel-C2MoZwKA.js +0 -3548
  481. package/dist/_internal/engine/designer-element/api/designer-element-guard.d.ts +0 -13
  482. package/dist/_internal/engine/designer-element/api/designer-element-scene.d.ts +0 -14
  483. package/dist/_internal/engine/designer-left-panel-groups-dom-WMsH33zw.js +0 -573
  484. package/dist/_internal/engine/host-resource-selection-5Cf_gclK.js +0 -2188
  485. package/dist/_internal/renderer/style-rules.d.ts +0 -9
  486. package/dist/contrast-CZFqj1I5.js +0 -1050
  487. package/dist/contrast-CZFqj1I5.js.map +0 -1
  488. package/dist/dataset-port-CUsMmX2x.js +0 -65
  489. package/dist/dataset-port-CUsMmX2x.js.map +0 -1
  490. package/dist/designer-Byw45cUM.js.map +0 -1
  491. package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js +0 -3517
  492. package/dist/designer-blueprint-workbench-panel-C2MoZwKA-CbXkv78O.js.map +0 -1
  493. package/dist/designer-dataset-controller-CPytVNBK-DWL3SRTP.js.map +0 -1
  494. package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js +0 -557
  495. package/dist/designer-left-panel-groups-dom-WMsH33zw-B9pl8loh.js.map +0 -1
  496. package/dist/designer-ui-primitives-CH4RNiMa-BNXQwJPZ.js.map +0 -1
  497. package/dist/dist-BHTClwId.js.map +0 -1
  498. package/dist/dist-DfAV2jGI.js +0 -2185
  499. package/dist/dist-DfAV2jGI.js.map +0 -1
  500. package/dist/editor-descriptor-schema-Be30Wv8w.js.map +0 -1
  501. package/dist/host-resource-selection-5Cf_gclK-Sv4Z8UXS.js.map +0 -1
  502. package/dist/manager-B2CZ2b5I.js.map +0 -1
  503. package/dist/material-BPlvEmDi.js +0 -12
  504. package/dist/material-manifest-bsGl6vZZ.js.map +0 -1
  505. package/dist/material-schema-CtxTkCP2.js +0 -267
  506. package/dist/material-schema-CtxTkCP2.js.map +0 -1
  507. package/dist/migrate-document-BJUN7NPv.js +0 -436
  508. package/dist/migrate-document-BJUN7NPv.js.map +0 -1
  509. package/dist/parse-BQw3u9_4.js +0 -1126
  510. package/dist/parse-BQw3u9_4.js.map +0 -1
  511. package/dist/plugin-B9Xxtw7G.js.map +0 -1
  512. package/dist/plugin-package-BT-pCoTt.js +0 -174
  513. package/dist/plugin-package-BT-pCoTt.js.map +0 -1
  514. package/dist/runtime-dispatch-Dt9fhcI5.js +0 -360
  515. package/dist/runtime-dispatch-Dt9fhcI5.js.map +0 -1
  516. package/dist/schema-C38FI_z2.js +0 -541
  517. package/dist/schema-C38FI_z2.js.map +0 -1
  518. package/dist/text-BVzTcUas.js.map +0 -1
@@ -0,0 +1,2773 @@
1
+ import { i as e } from "./image-url-D6mUcjY1.js";
2
+ import { At as t, B as n, H as r, O as i, V as a, g as o, k as s, n as c, q as l } from "./parse-Ji7kE9ZT.js";
3
+ import { t as u } from "./equality-DjZ9cv4u.js";
4
+ import { C as d, c as f, d as p, i as m, m as h } from "./designer-field-primitives-Crn464Qg-Bi7q8s5J.js";
5
+ import { A as ee, B as g, C as _, D as v, E as y, F as b, G as x, I as S, K as C, L as w, M as T, N as E, O as D, R as te, S as ne, T as re, U as ie, V as ae, W as oe, _ as se, b as ce, c as le, g as O, i as ue, j as de, k, m as fe, n as A, o as j, p as M, q as pe, r as me, v as N, w as he, x as ge, z as _e } from "./designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js";
6
+ import { r as ve } from "./runtime-dispatch-C0gyIrTv.js";
7
+ import { n as ye } from "./runtime-simulate-aSYO9yDX.js";
8
+ //#region ../engine/dist/designer-blueprint-workbench-panel-BWSglfAb.js
9
+ var be = 260, xe = 176, P = 80;
10
+ function F(e, n, r) {
11
+ let i = ue(r, t.materialEvent);
12
+ return e.components.flatMap((e) => {
13
+ let t = n?.get(e.type)?.manifest, a = new Map((t?.editorDescriptor?.events ?? []).map((e) => [e.name, e]));
14
+ return (t?.events ?? []).map((t) => {
15
+ let n = a.get(t), o = n?.requiredCapability, s = n?.triggerContexts === void 0 || n.triggerContexts.includes("blueprint");
16
+ return {
17
+ componentId: e.id,
18
+ componentName: e.name,
19
+ materialType: e.type,
20
+ name: t,
21
+ label: n?.label ?? t,
22
+ available: s && i && (o === void 0 || ue(r, o)),
23
+ ...o === void 0 ? {} : { requiredCapability: o }
24
+ };
25
+ });
26
+ });
27
+ }
28
+ function Se(e, t, n) {
29
+ let r = F(e, t, n);
30
+ return {
31
+ isEventAvailable: (e, t) => r.some((n) => n.componentId === e && n.name === t && n.available),
32
+ isHostActionAvailable: (e) => ce(n, e),
33
+ componentStateIds: (t) => e.components.find((e) => e.id === t)?.states?.items.map((e) => e.id) ?? []
34
+ };
35
+ }
36
+ function Ce(e, t, n) {
37
+ let r = F(e, t, n), i = Me(e);
38
+ return e.components.map((t) => {
39
+ let n = g(e.blueprint, t.id);
40
+ return {
41
+ kind: "component",
42
+ entityId: t.id,
43
+ name: t.name,
44
+ subtitle: t.type,
45
+ depth: i.get(t.id) ?? 0,
46
+ ...n === void 0 ? {} : { nodeId: n.id },
47
+ eventCount: r.filter((e) => e.componentId === t.id && e.available).length
48
+ };
49
+ });
50
+ }
51
+ function we(e, t) {
52
+ return f(e).map((n) => {
53
+ let r = C(e.blueprint, n.id);
54
+ return {
55
+ kind: "variable",
56
+ entityId: n.id,
57
+ name: n.name,
58
+ subtitle: t.variableKind[n.type],
59
+ depth: 0,
60
+ ...r === void 0 ? {} : { nodeId: r.id },
61
+ eventCount: 1
62
+ };
63
+ });
64
+ }
65
+ function Te(e, t, o, c) {
66
+ let l = c.graph, u = e.blueprint, d = F(e, t, o), p = ie(o), m = new Map(e.components.map((e) => [e.id, e])), h = new Map(f(e).map((e) => [e.id, e])), ee = new Map((e.subCanvases ?? []).map((e) => [e.id, e])), g = new Map(u.layout?.nodes.map((e) => [e.id, e])), _ = je(u.nodes, u.edges), v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
67
+ for (let e of u.edges) b.set(e.from.node, (b.get(e.from.node) ?? 0) + 1), y.set(e.to.node, (y.get(e.to.node) ?? 0) + 1), e.kind === "flow" && (v.add(`${e.from.node}\u0000out\u0000${e.from.port}`), v.add(`${e.to.node}\u0000in\u0000${e.to.port}`));
68
+ let x = (e, t, n, r, i = !0) => ({
69
+ id: n,
70
+ direction: t,
71
+ label: r,
72
+ available: i,
73
+ connected: v.has(`${e.id}\u0000${t}\u0000${n}`),
74
+ ...i ? {} : { unavailableReason: l.unavailablePort }
75
+ }), S = (e, t) => {
76
+ let n = [];
77
+ for (let r of u.edges) {
78
+ if (r.kind !== "flow") continue;
79
+ let i = t === "out" ? r.from : r.to;
80
+ i.node === e.id && !n.includes(i.port) && n.push(i.port);
81
+ }
82
+ return n;
83
+ }, C = u.nodes.map((e) => {
84
+ let t = g.get(e.id) ?? _.get(e.id) ?? {
85
+ x: P,
86
+ y: P
87
+ }, a = i[e.kind].map((t) => x(e, "in", t, l.ports[t] ?? t)), o = s[e.kind].map((t) => x(e, "out", t, l.ports[t] ?? t)), f = {
88
+ id: e.id,
89
+ kind: e.kind,
90
+ x: t.x,
91
+ y: t.y,
92
+ enabled: e.enabled !== !1,
93
+ semantic: !1,
94
+ renamable: e.kind === "timer" || e.kind === "condition",
95
+ duplicable: e.kind === "timer" || e.kind === "condition",
96
+ inboundCount: y.get(e.id) ?? 0,
97
+ outboundCount: b.get(e.id) ?? 0
98
+ };
99
+ switch (e.kind) {
100
+ case "component": {
101
+ let t = m.get(e.componentId), n = d.filter((t) => t.componentId === e.componentId).map((t) => x(e, "out", `event:${t.name}`, t.label, t.available)), i = t?.states !== void 0;
102
+ i && n.push(x(e, "out", "state-changed", l.ports["state-changed"] ?? "state"));
103
+ for (let t of S(e, "out")) {
104
+ if (n.some((e) => e.id === t)) continue;
105
+ let i = r(t) ?? t;
106
+ n.push(x(e, "out", t, l.missingEventPort(i), !1));
107
+ }
108
+ return {
109
+ ...f,
110
+ title: t?.name ?? e.componentId,
111
+ subtitle: t === void 0 ? l.missingEntity : t.type,
112
+ outputs: n,
113
+ inputs: i ? a : a.filter((e) => e.id !== "set-state" && e.id !== "reset-state"),
114
+ semantic: !0,
115
+ componentId: e.componentId,
116
+ ...t === void 0 ? {} : {
117
+ materialType: t.type,
118
+ hidden: t.status.hidden
119
+ }
120
+ };
121
+ }
122
+ case "variable": {
123
+ let t = h.get(e.variableId);
124
+ return {
125
+ ...f,
126
+ title: t?.name ?? e.variableId,
127
+ subtitle: t === void 0 ? l.missingEntity : c.variableKind[t.type],
128
+ outputs: o,
129
+ inputs: a,
130
+ variableId: e.variableId,
131
+ ...t === void 0 ? {} : { variableType: t.type }
132
+ };
133
+ }
134
+ case "host": {
135
+ let t = [];
136
+ for (let n of S(e, "in")) {
137
+ let i = r(n);
138
+ i !== void 0 && t.push(x(e, "in", n, l.hostEventPort(i)));
139
+ }
140
+ t.push(x(e, "in", `event:${De(u, e.id)}`, l.newHostEventPort));
141
+ for (let n of p) t.push(x(e, "in", `action:${n.actionId}`, l.hostActionPort(n.name)));
142
+ for (let r of S(e, "in")) {
143
+ let i = n(r);
144
+ i === void 0 || t.some((e) => e.id === r) || t.push(x(e, "in", r, c.hostActionUndeclared(i), !1));
145
+ }
146
+ return {
147
+ ...f,
148
+ title: l.nodeKinds.host,
149
+ subtitle: l.nodeKindHints.host,
150
+ outputs: [],
151
+ inputs: t
152
+ };
153
+ }
154
+ case "lifecycle": return {
155
+ ...f,
156
+ title: l.nodeKinds.lifecycle,
157
+ subtitle: l.nodeKindHints.lifecycle,
158
+ outputs: o,
159
+ inputs: []
160
+ };
161
+ case "timer": return {
162
+ ...f,
163
+ title: e.name ?? l.timerTitle(e.intervalSeconds),
164
+ subtitle: l.nodeKinds.timer,
165
+ outputs: o,
166
+ inputs: [],
167
+ intervalSeconds: e.intervalSeconds,
168
+ ...e.name === void 0 ? {} : { name: e.name }
169
+ };
170
+ case "sub-canvas": {
171
+ let t = ee.get(e.canvasId), n = l.subCanvasPorts[t?.display ?? "popup"];
172
+ return {
173
+ ...f,
174
+ title: t?.name ?? e.canvasId,
175
+ subtitle: t === void 0 ? l.missingEntity : l.subCanvasKinds[t.display],
176
+ outputs: s["sub-canvas"].map((t) => x(e, "out", t, n[t] ?? t)),
177
+ inputs: i["sub-canvas"].map((t) => x(e, "in", t, n[t] ?? t)),
178
+ canvasId: e.canvasId,
179
+ ...t === void 0 ? {} : { canvasDisplay: t.display }
180
+ };
181
+ }
182
+ case "main-canvas": return {
183
+ ...f,
184
+ title: l.nodeKinds["main-canvas"],
185
+ subtitle: l.nodeKindHints["main-canvas"],
186
+ outputs: s["main-canvas"].map((t) => x(e, "out", t, l.mainCanvasPorts[t] ?? t)),
187
+ inputs: i["main-canvas"].map((t) => x(e, "in", t, l.mainCanvasPorts[t] ?? t))
188
+ };
189
+ case "condition": return {
190
+ ...f,
191
+ title: e.name ?? l.conditionTitle,
192
+ subtitle: Oe(e.condition, c),
193
+ outputs: o,
194
+ inputs: a,
195
+ condition: e.condition,
196
+ ...e.name === void 0 ? {} : { name: e.name }
197
+ };
198
+ }
199
+ });
200
+ Ae(C, g);
201
+ let w = new Map(C.map((e) => [e.id, e])), T = me(u);
202
+ return {
203
+ nodes: C,
204
+ edges: u.edges.map((e) => {
205
+ let t = w.get(e.from.node), n = w.get(e.to.node), r = t?.enabled !== !1 && n?.enabled !== !1;
206
+ if (e.kind === "semantic") return {
207
+ id: e.id,
208
+ kind: "semantic",
209
+ category: "semantic",
210
+ source: e.from.node,
211
+ sourcePort: "semantic",
212
+ target: e.to.node,
213
+ targetPort: "semantic",
214
+ label: c.semanticRoles[e.role],
215
+ role: e.role,
216
+ active: r
217
+ };
218
+ let i = ae(u, e.id), o = n?.inputs.find((t) => t.id === e.to.port);
219
+ return {
220
+ id: e.id,
221
+ kind: "flow",
222
+ category: a(e, T),
223
+ source: e.from.node,
224
+ sourcePort: e.from.port,
225
+ target: e.to.node,
226
+ targetPort: e.to.port,
227
+ label: o?.label ?? e.to.port,
228
+ ...i === void 0 ? {} : {
229
+ order: i.order,
230
+ siblingCount: i.count
231
+ },
232
+ ...e.value === void 0 ? {} : { value: e.value },
233
+ ...e.payload === void 0 ? {} : { payload: e.payload },
234
+ ...e.transition === void 0 ? {} : { transition: e.transition },
235
+ ...e.stateId === void 0 ? {} : { stateId: e.stateId },
236
+ active: r
237
+ };
238
+ }),
239
+ ...u.layout?.viewport === void 0 ? {} : { viewport: u.layout.viewport }
240
+ };
241
+ }
242
+ function Ee(e, t) {
243
+ let n = [];
244
+ for (let r of t.blueprint.nodes) {
245
+ if (r.enabled === !1) continue;
246
+ let t = e.nodes.find((e) => e.id === r.id);
247
+ for (let e of t?.outputs ?? []) e.connected && l(r, e.id) !== void 0 && n.push({
248
+ nodeId: r.id,
249
+ port: e.id,
250
+ label: `${t?.title ?? r.id} · ${e.label}`
251
+ });
252
+ }
253
+ return n;
254
+ }
255
+ function De(e, t) {
256
+ let n = new Set(e.edges.flatMap((e) => e.kind === "flow" && e.to.node === t ? [e.to.port] : []));
257
+ for (let e = 1;; e++) if (!n.has(`event:event${e}`)) return `event${e}`;
258
+ }
259
+ function Oe(e, t) {
260
+ let n = (e) => {
261
+ switch (e.kind) {
262
+ case "literal": return JSON.stringify(e.value) ?? "null";
263
+ case "event-payload": return e.path.length === 0 ? "payload" : `payload.${e.path.join(".")}`;
264
+ case "variable": return e.variableId;
265
+ default: return e.kind;
266
+ }
267
+ }, r = t.conditionOperator(e.operator);
268
+ return e.right === void 0 ? `${n(e.left)} ${r}` : `${n(e.left)} ${r} ${n(e.right)}`;
269
+ }
270
+ function ke(e) {
271
+ let t = e.inputs.length + e.outputs.length + +!!e.semantic;
272
+ return Math.max(108, 71 + t * 27);
273
+ }
274
+ function Ae(e, t) {
275
+ let n = /* @__PURE__ */ new Map();
276
+ e.forEach((e, r) => {
277
+ if (t.has(e.id)) return;
278
+ let i = n.get(e.x) ?? [];
279
+ i.push(r), n.set(e.x, i);
280
+ });
281
+ for (let t of n.values()) {
282
+ let n = P;
283
+ for (let r of t) {
284
+ let t = e[r];
285
+ e[r] = {
286
+ ...t,
287
+ y: n
288
+ }, n += ke(t) + 28;
289
+ }
290
+ }
291
+ }
292
+ function je(e, t) {
293
+ let n = /* @__PURE__ */ new Map();
294
+ for (let e of t) {
295
+ if (e.kind !== "flow") continue;
296
+ let t = n.get(e.to.node);
297
+ t === void 0 ? n.set(e.to.node, [e.from.node]) : t.push(e.from.node);
298
+ }
299
+ let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = (e) => {
300
+ let t = r.get(e);
301
+ if (t !== void 0) return t;
302
+ if (i.has(e)) return 0;
303
+ i.add(e);
304
+ let o = 0;
305
+ for (let t of n.get(e) ?? []) o = Math.max(o, a(t) + 1);
306
+ return i.delete(e), r.set(e, Math.min(o, 12)), r.get(e);
307
+ }, o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
308
+ for (let t of e) {
309
+ let e = a(t.id), n = o.get(e) ?? 0;
310
+ o.set(e, n + 1), s.set(t.id, {
311
+ x: P + e * be,
312
+ y: P + n * xe
313
+ });
314
+ }
315
+ return s;
316
+ }
317
+ function Me(e) {
318
+ let t = new Map(e.components.map((e) => [e.id, e])), n = /* @__PURE__ */ new Map();
319
+ for (let r of e.components) {
320
+ let e = 0, i = r.parentId, a = /* @__PURE__ */ new Set([r.id]);
321
+ for (; i !== null && !a.has(i);) a.add(i), e += 1, i = t.get(i)?.parentId ?? null;
322
+ n.set(r.id, e);
323
+ }
324
+ return n;
325
+ }
326
+ var Ne = 0, I = 8, L = .3, Pe = 2, R = d.blueprint.graph, Fe = [
327
+ "lifecycle",
328
+ "timer",
329
+ "condition",
330
+ "host"
331
+ ], Ie = {
332
+ component: "cube",
333
+ variable: "variable",
334
+ host: "database",
335
+ lifecycle: "play",
336
+ timer: "activity",
337
+ condition: "sliders",
338
+ "sub-canvas": "copy",
339
+ "main-canvas": "grid"
340
+ };
341
+ function Le(e) {
342
+ let t = new Re(e);
343
+ return {
344
+ element: t.element,
345
+ destroy: () => t.destroy()
346
+ };
347
+ }
348
+ var Re = class {
349
+ element;
350
+ #e;
351
+ #t;
352
+ #n;
353
+ #r;
354
+ #i;
355
+ #a;
356
+ #o;
357
+ #s;
358
+ #c;
359
+ #l;
360
+ #u;
361
+ #d;
362
+ #f = {
363
+ x: 40,
364
+ y: 40,
365
+ z: 1
366
+ };
367
+ #p = !1;
368
+ #m = /* @__PURE__ */ new Map();
369
+ #h = {
370
+ nodes: [],
371
+ edges: []
372
+ };
373
+ #g;
374
+ #_;
375
+ #v;
376
+ #y = !0;
377
+ #b = !0;
378
+ #x = !1;
379
+ #S;
380
+ #C = !1;
381
+ #w = {
382
+ x: 0,
383
+ y: 0
384
+ };
385
+ #T = -1;
386
+ #E = 0;
387
+ #D = "";
388
+ #O = "";
389
+ #k = "";
390
+ #A = "";
391
+ #j = /* @__PURE__ */ new Set();
392
+ #M = [];
393
+ constructor(e) {
394
+ this.#e = e;
395
+ let t = e.createElement("div");
396
+ t.className = "designer-blueprint-canvas", t.tabIndex = 0, t.setAttribute("role", "application"), t.setAttribute("aria-label", d.blueprint.canvas), t.dataset.designerBlueprintCanvas = "true", t.innerHTML = `<div class="bp-toolbar" role="toolbar" aria-label="${N(d.blueprint.localToolbar)}"></div>
397
+ <div class="bp-stage" data-bp-stage>
398
+ <div class="bp-world" data-bp-world>
399
+ <svg class="bp-edges" data-bp-edges aria-hidden="true"></svg>
400
+ <div class="bp-nodes" data-bp-nodes></div>
401
+ <div class="bp-labels" data-bp-labels></div>
402
+ </div>
403
+ <div class="bp-marquee" data-bp-marquee hidden></div>
404
+ <div class="bp-empty" data-bp-empty hidden></div>
405
+ </div>
406
+ <div class="bp-simulation" data-bp-simulation hidden></div>
407
+ <div class="designer-context-menu bp-context-menu" data-bp-menu role="menu" hidden tabindex="-1"></div>`, this.element = t, this.#c = t.querySelector(".bp-toolbar"), this.#t = t.querySelector("[data-bp-stage]"), this.#n = t.querySelector("[data-bp-world]"), this.#r = t.querySelector("[data-bp-edges]"), this.#i = t.querySelector("[data-bp-nodes]"), this.#a = t.querySelector("[data-bp-labels]"), this.#o = t.querySelector("[data-bp-marquee]"), this.#s = t.querySelector("[data-bp-menu]"), this.#l = t.querySelector("[data-bp-simulation]"), this.#u = t.querySelector("[data-bp-empty]"), this.listen(t, te, (e) => this.receive(e.detail.state)), this.listen(this.#t, "pointerdown", (e) => this.onPointerDown(e)), this.listen(this.#t, "pointermove", (e) => this.onPointerMove(e)), this.listen(this.#t, "pointerup", (e) => this.onPointerUp(e)), this.listen(this.#t, "pointercancel", () => this.cancelDrag()), this.listen(this.#t, "pointerleave", () => this.setHoverEdge(void 0)), this.listen(this.#t, "contextmenu", (e) => e.preventDefault()), this.listen(this.#t, "dblclick", (e) => this.onDoubleClick(e)), this.listen(this.#t, "wheel", (e) => this.onWheel(e), { passive: !1 }), this.listen(this.#t, "dragover", (e) => this.onDragOver(e)), this.listen(this.#t, "drop", (e) => this.onDrop(e)), this.listen(t, "keydown", (e) => this.onKeyDown(e)), this.listen(t, "keyup", (e) => {
408
+ e.code === "Space" && (this.#C = !1, this.#t.classList.remove("is-space"));
409
+ }), this.listen(this.#c, "click", (e) => this.onToolbarClick(e)), this.listen(this.#s, "click", (e) => this.onMenuClick(e)), this.listen(this.#l, "click", (e) => this.onSimulationClick(e)), this.listen(this.#l, "change", (e) => {
410
+ let t = e.target.closest("[data-bp-sim-trigger]");
411
+ t !== null && (this.#S = t.value);
412
+ }), this.listen(e, "pointerdown", (e) => {
413
+ !this.#s.hidden && !e.composedPath().includes(this.#s) && this.closeMenu();
414
+ }), this.renderToolbar(), this.applyView(), queueMicrotask(() => this.send({ type: "ready" }));
415
+ }
416
+ destroy() {
417
+ for (let [e, t, n, r] of this.#M) e.removeEventListener(t, n, r);
418
+ this.#M.length = 0;
419
+ }
420
+ listen(e, t, n, r) {
421
+ e.addEventListener(t, n, r), this.#M.push([
422
+ e,
423
+ t,
424
+ n,
425
+ r
426
+ ]);
427
+ }
428
+ receive(e) {
429
+ let t = this.#d;
430
+ this.#d = e, this.#h = e.selection, (t === void 0 || t.documentRevision !== e.documentRevision) && this.#m.clear(), !this.#p && e.graph.viewport !== void 0 && (this.#f = {
431
+ x: e.graph.viewport.x,
432
+ y: e.graph.viewport.y,
433
+ z: z(e.graph.viewport.zoom, L, Pe)
434
+ }, this.#p = !0), this.element.dataset.active = String(e.active), this.render();
435
+ let n = e.viewRequest;
436
+ n !== void 0 && n.id !== this.#T ? (this.#T = n.id, n.type === "fit" ? this.fit() : n.type === "auto-layout" ? this.autoLayout() : n.targetId !== void 0 && this.focus(n.targetId)) : !this.#p && e.graph.nodes.length > 0 && (this.#p = !0, this.fit());
437
+ }
438
+ send(e) {
439
+ let t = this.#d, n = {
440
+ ...e,
441
+ commandId: `default-canvas-${++this.#E}`,
442
+ generation: t?.generation ?? 0,
443
+ documentRevision: t?.documentRevision ?? 0
444
+ };
445
+ this.element.dispatchEvent(new CustomEvent(le, {
446
+ bubbles: !0,
447
+ composed: !0,
448
+ detail: { command: n }
449
+ }));
450
+ }
451
+ select(e) {
452
+ this.#h = e, this.renderSelection(), this.send({
453
+ type: "select",
454
+ selection: e
455
+ });
456
+ }
457
+ get graph() {
458
+ return this.#d?.graph ?? {
459
+ nodes: [],
460
+ edges: []
461
+ };
462
+ }
463
+ node(e) {
464
+ return this.graph.nodes.find((t) => t.id === e);
465
+ }
466
+ position(e) {
467
+ return this.#m.get(e.id) ?? {
468
+ x: e.x,
469
+ y: e.y
470
+ };
471
+ }
472
+ rows(e) {
473
+ return [
474
+ ...e.outputs,
475
+ ...e.inputs,
476
+ ...e.semantic ? ["semantic"] : []
477
+ ];
478
+ }
479
+ height(e) {
480
+ return Math.max(108, 56 + this.rows(e).length * 27 + 13 + 2);
481
+ }
482
+ portPoint(e, t, n) {
483
+ let r = this.rows(e), i = Math.max(0, r.findIndex((e) => t === "semantic" ? e === "semantic" : e !== "semantic" && e.id === t && e.direction === n)), a = this.position(e);
484
+ return {
485
+ x: n === "out" ? a.x + 164 + Ne : a.x - Ne,
486
+ y: a.y + 1 + 44 + 12 + i * 27 + 27 / 2
487
+ };
488
+ }
489
+ toWorld(e, t) {
490
+ let n = this.#t.getBoundingClientRect();
491
+ return {
492
+ x: (e - n.left - this.#f.x) / this.#f.z,
493
+ y: (t - n.top - this.#f.y) / this.#f.z
494
+ };
495
+ }
496
+ visibleEdge(e) {
497
+ return e.kind !== "semantic" || this.#b && (this.#d?.showSemantic ?? !0);
498
+ }
499
+ render() {
500
+ this.renderNodes(), this.renderEdges(), this.renderToolbar(), this.renderSimulation();
501
+ let e = this.graph.nodes.length === 0;
502
+ this.#u.hidden = !e, e && (this.#u.innerHTML = `<strong>${x(d.blueprint.directNodeHint)}</strong>`);
503
+ }
504
+ renderNodes() {
505
+ let e = this.#y ? this.#d?.trace : null;
506
+ this.#j = new Set(e?.visitedNodeIds ?? []);
507
+ let t = this.connectedPorts(), n = this.portCategories(), r = this.graph.nodes.map((e) => {
508
+ let r = this.position(e), i = this.rows(e).map((r) => {
509
+ if (r === "semantic") {
510
+ let n = t.has(`${e.id}\u0000semantic`);
511
+ return `<div class="bp-anchor bp-anchor-semantic"><span class="bp-port bp-port-semantic${n ? " is-used" : ""}" data-bp-node="${N(e.id)}" data-bp-port="semantic" data-bp-dir="in"></span><span class="bp-anchor-label">${x(R.ports.semantic ?? "")}</span><span class="bp-port bp-port-semantic${n ? " is-used" : ""}" data-bp-node="${N(e.id)}" data-bp-port="semantic" data-bp-dir="out"></span></div>`;
512
+ }
513
+ let i = r.unavailableReason === void 0 ? r.id : `${r.id} · ${r.unavailableReason}`, a = n.get(`${e.id}\u0000${r.direction}\u0000${r.id}`);
514
+ return `<div class="bp-anchor" data-dir="${r.direction}" data-available="${String(r.available)}" title="${N(i)}"><span class="bp-port${r.connected ? " is-used" : ""}" data-bp-node="${N(e.id)}" data-bp-port="${N(r.id)}" data-bp-dir="${r.direction}" data-available="${String(r.available)}"${a === void 0 ? "" : ` data-category="${a}"`}></span><span class="bp-anchor-label">${x(r.label)}</span></div>`;
515
+ }).join(""), a = e.kind === "sub-canvas" && e.canvasDisplay !== void 0 ? R.subCanvasKinds[e.canvasDisplay] : R.nodeKinds[e.kind], o = e.kind === "sub-canvas" && e.canvasDisplay === "page" ? "doc" : Ie[e.kind], s = this.#v === e.id ? `<input class="bp-rename" data-bp-rename-input value="${N(e.name ?? e.title)}" maxlength="64" aria-label="${N(R.nodeName)}">` : x(e.title);
516
+ return `<div class="bp-node" data-bp-node-id="${N(e.id)}" data-kind="${e.kind}" data-enabled="${String(e.enabled)}" style="left:${r.x}px;top:${r.y}px;min-height:${this.height(e)}px" role="group" aria-label="${N(`${a} ${e.title}`)}">
517
+ <div class="bp-node-header" data-bp-drag="${N(e.id)}" title="${N(`${e.title} · ${e.subtitle}`)}"><span class="bp-node-icon" aria-hidden="true">${h(o)}</span><span class="bp-node-heading"><span class="bp-node-title" data-bp-rename="${N(e.id)}">${s}</span>${e.title === a ? "" : `<span class="bp-node-kind">${x(a)}</span>`}</span></div>
518
+ <div class="bp-node-content">${i}</div>
519
+ </div>`;
520
+ }).join("");
521
+ if (r === this.#D) {
522
+ this.applyNodeState();
523
+ return;
524
+ }
525
+ this.#D = r, this.#i.innerHTML = r, this.applyNodeState();
526
+ let i = this.#i.querySelector("[data-bp-rename-input]");
527
+ i !== null && (i.focus(), i.select(), i.addEventListener("pointerdown", (e) => e.stopPropagation()), i.addEventListener("keydown", (e) => {
528
+ e.stopPropagation(), e.key === "Enter" && i.blur(), e.key === "Escape" && (this.#v = void 0, this.renderNodes());
529
+ }), i.addEventListener("blur", () => this.finishRename(i.value)));
530
+ }
531
+ connectedPorts() {
532
+ let e = /* @__PURE__ */ new Set();
533
+ for (let t of this.graph.edges) t.kind === "semantic" && (e.add(`${t.source}\u0000semantic`), e.add(`${t.target}\u0000semantic`));
534
+ return e;
535
+ }
536
+ portCategories() {
537
+ let e = /* @__PURE__ */ new Map();
538
+ for (let t of this.graph.edges) {
539
+ if (t.kind === "semantic") continue;
540
+ let n = `${t.source}\u0000out\u0000${t.sourcePort}`, r = `${t.target}\u0000in\u0000${t.targetPort}`;
541
+ e.has(n) || e.set(n, t.category), e.has(r) || e.set(r, t.category);
542
+ }
543
+ return e;
544
+ }
545
+ renderEdges(e) {
546
+ let t = this.#y ? this.#d?.trace : null, n = new Set(t?.executedEdgeIds ?? []), r = "", i = "";
547
+ for (let e of this.graph.edges) {
548
+ if (!this.visibleEdge(e)) continue;
549
+ let t = this.node(e.source), a = this.node(e.target);
550
+ if (t === void 0 || a === void 0) continue;
551
+ let o = ze(this.portPoint(t, e.sourcePort, "out"), this.portPoint(a, e.targetPort, "in")), s = [
552
+ "bp-edge",
553
+ `is-${e.kind}`,
554
+ e.active ? "" : "is-off",
555
+ n.has(e.id) ? "is-traced" : ""
556
+ ].filter((e) => e !== "").join(" ");
557
+ r += `<g class="${s}" data-bp-edge-group="${N(e.id)}" data-bp-edge-source="${N(e.source)}" data-bp-edge-target="${N(e.target)}" data-category="${e.category}"><path class="bp-edge-line" d="${o.d}"/><path class="bp-edge-flow" d="${o.d}"/><path class="bp-edge-arrow" d="M-4.5,-4 L4,0 L-4.5,4 L-2.5,0 Z" transform="translate(${o.mid.x} ${o.mid.y}) rotate(${o.angle})"/><path class="bp-edge-hit" data-bp-edge="${N(e.id)}" d="${o.d}"/></g>`;
558
+ let c = e.order !== void 0 && (e.siblingCount ?? 1) > 1 ? `#${e.order} ` : "";
559
+ i += `<div class="bp-edge-label" data-bp-edge-label="${N(e.id)}" data-category="${e.category}" style="left:${o.mid.x}px;top:${o.mid.y}px">${x(c + e.label)}</div>`;
560
+ }
561
+ e !== void 0 && (r += `<path class="bp-edge-ghost" d="${ze(e.from, e.to).d}"/><circle class="bp-edge-ghost-end" cx="${e.to.x}" cy="${e.to.y}" r="4"/>`);
562
+ let a = `${r}\u0000${i}`;
563
+ a !== this.#O && (this.#O = a, this.#r.innerHTML = r, this.#a.innerHTML = i), this.applyEdgeState();
564
+ }
565
+ renderSelection() {
566
+ this.applyNodeState(), this.applyEdgeState();
567
+ }
568
+ focusSets() {
569
+ let e = new Set(this.#h.nodes), t = new Set(this.#h.edges), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
570
+ for (let i of this.graph.edges) this.visibleEdge(i) && (t.has(i.id) || e.has(i.source) || e.has(i.target)) && (r.add(i.id), n.add(i.source), n.add(i.target));
571
+ return {
572
+ nodes: n,
573
+ edges: r
574
+ };
575
+ }
576
+ applyFocus() {
577
+ let e = this.#h.nodes.length + this.#h.edges.length;
578
+ this.#t.dataset.focus = String(e > 0);
579
+ }
580
+ applyNodeState() {
581
+ this.applyFocus();
582
+ let e = this.focusSets().nodes;
583
+ for (let t of this.#i.querySelectorAll("[data-bp-node-id]")) {
584
+ let n = t.dataset.bpNodeId ?? "", r = this.#h.nodes.includes(n);
585
+ t.dataset.selected = String(r), t.dataset.related = String(!r && e.has(n)), t.dataset.traced = String(this.#j.has(n) && !r);
586
+ }
587
+ }
588
+ applyEdgeState() {
589
+ this.applyFocus();
590
+ let e = new Set(this.#h.edges), t = this.focusSets().edges;
591
+ for (let n of this.#r.querySelectorAll("[data-bp-edge-group]")) {
592
+ let r = n.dataset.bpEdgeGroup ?? "";
593
+ n.classList.toggle("is-selected", e.has(r)), n.classList.toggle("is-related", t.has(r)), n.classList.toggle("is-hover", r === this.#_);
594
+ }
595
+ for (let t of this.#a.querySelectorAll("[data-bp-edge-label]")) {
596
+ let n = t.dataset.bpEdgeLabel ?? "";
597
+ t.classList.toggle("is-selected", e.has(n)), t.classList.toggle("is-visible", n === this.#_);
598
+ }
599
+ }
600
+ setHoverEdge(e) {
601
+ if (this.#_ !== e) {
602
+ this.#_ = e;
603
+ for (let t of this.#r.querySelectorAll("[data-bp-edge-group]")) t.classList.toggle("is-hover", t.dataset.bpEdgeGroup === e);
604
+ for (let t of this.#a.querySelectorAll("[data-bp-edge-label]")) t.classList.toggle("is-visible", t.dataset.bpEdgeLabel === e);
605
+ }
606
+ }
607
+ renderToolbar() {
608
+ let e = this.#d, t = d.blueprint.graph.toolbar, n = (e, t, n, r = "") => `<button type="button" class="designer-control designer-button bp-tool" data-bp-tool="${e}" aria-label="${N(n)}" data-tip="${N(n)}"${r}>${h(t)}</button>`, r = e?.diagnostics.filter((e) => e.severity === "error").length ?? 0, i = `<div class="bp-tool-group">
609
+ <button type="button" class="designer-control designer-button bp-tool bp-tool-wide" data-bp-tool="add" aria-haspopup="menu" aria-label="${N(t.addNode)}" data-tip="${N(t.addNode)}">${h("plus")}<span>${x(t.addNode)}</span></button>
610
+ ${n("auto-layout", "grid", t.autoLayout)}
611
+ </div>
612
+ <div class="bp-tool-group">
613
+ ${n("undo", "undo", d.blueprint.graph.toolbar.undo, e?.canUndo === !0 ? "" : " disabled")}
614
+ ${n("redo", "redo", d.blueprint.graph.toolbar.redo, e?.canRedo === !0 ? "" : " disabled")}
615
+ </div>
616
+ <div class="bp-tool-group">
617
+ ${n("semantic", "link", t.semantic, ` aria-pressed="${String(this.#b)}"`)}
618
+ ${n("trace", "activity", t.highlightTrace, ` aria-pressed="${String(this.#y)}"`)}
619
+ <span class="bp-tool-status" data-state="${r === 0 ? "ok" : "error"}" aria-live="polite">${h(r === 0 ? "check-circle" : "x-circle")}<span>${x(r === 0 ? d.blueprint.problemsHealthy : `${d.blueprint.problemsTitle} ${r}`)}</span></span>
620
+ </div>
621
+ <div class="bp-tool-group bp-tool-group-end">
622
+ ${n("zoom-out", "zoom-out", t.zoomOut)}
623
+ <span class="bp-zoom-value" data-bp-zoom>${Math.round(this.#f.z * 100)}%</span>
624
+ ${n("zoom-in", "zoom-in", t.zoomIn)}
625
+ ${n("fit", "fit", t.fit)}
626
+ <button type="button" class="designer-control designer-button bp-tool bp-tool-wide" data-bp-tool="simulate" data-variant="${this.#x ? "primary" : "neutral"}" aria-pressed="${String(this.#x)}" aria-label="${N(t.simulate)}" data-tip="${N(t.simulate)}">${h("play")}<span>${x(t.simulate)}</span></button>
627
+ </div>`;
628
+ i !== this.#k && (this.#k = i, this.#c.innerHTML = i, b(this.#c));
629
+ }
630
+ renderSimulation() {
631
+ if (this.#l.hidden = !this.#x, !this.#x) {
632
+ this.#A = "";
633
+ return;
634
+ }
635
+ let e = R.simulation, t = this.#d?.simulationTriggers ?? [], n = (e) => `${e.nodeId}\u0000${e.port}`;
636
+ (this.#S === void 0 || !t.some((e) => n(e) === this.#S)) && (this.#S = t[0] === void 0 ? void 0 : n(t[0]));
637
+ let r = this.#l.querySelector("[data-bp-sim-payload]")?.value ?? "{}", i = t.length === 0 ? `<p class="bp-simulation-empty">${x(e.noTriggers)}</p>` : `<label class="designer-field"><span class="designer-field-label">${x(e.trigger)}</span><select class="designer-control designer-select" data-bp-sim-trigger>${t.map((e) => `<option value="${N(n(e))}"${n(e) === this.#S ? " selected" : ""}>${x(e.label)}</option>`).join("")}</select></label>
638
+ <label class="designer-field bp-simulation-payload"><span class="designer-field-label">${x(e.payload)}</span><textarea class="designer-control designer-input" data-bp-sim-payload rows="2" spellcheck="false">${x(r)}</textarea></label>
639
+ <div class="bp-simulation-actions">
640
+ <button type="button" class="designer-control designer-button" data-variant="primary" data-bp-sim="run">${h("play")}<span>${x(e.run)}</span></button>
641
+ <button type="button" class="designer-control designer-button" data-bp-sim="clear"${this.#d?.trace === null ? " disabled" : ""}>${x(e.clear)}</button>
642
+ </div>
643
+ <p class="bp-simulation-message" data-bp-sim-message aria-live="polite"></p>`;
644
+ i !== this.#A && (this.#A = i, this.#l.innerHTML = i, b(this.#l));
645
+ }
646
+ applyView() {
647
+ this.#n.style.transform = `translate(${this.#f.x}px, ${this.#f.y}px) scale(${this.#f.z})`, this.#t.style.setProperty("--bp-pan-x", `${this.#f.x}px`), this.#t.style.setProperty("--bp-pan-y", `${this.#f.y}px`), this.#t.style.setProperty("--bp-zoom", String(this.#f.z)), this.#t.dataset.zoomFar = String(this.#f.z < .6);
648
+ let e = this.#c.querySelector("[data-bp-zoom]");
649
+ e !== null && (e.textContent = `${Math.round(this.#f.z * 100)}%`);
650
+ }
651
+ zoomAt(e, t, n) {
652
+ let r = z(this.#f.z * e, L, Pe), i = r / this.#f.z;
653
+ this.#f = {
654
+ x: t - (t - this.#f.x) * i,
655
+ y: n - (n - this.#f.y) * i,
656
+ z: r
657
+ }, this.applyView();
658
+ }
659
+ fit() {
660
+ let e = this.graph.nodes, t = this.#t.getBoundingClientRect();
661
+ if (e.length === 0 || t.width === 0 || t.height === 0) return;
662
+ let n = e.map((e) => ({
663
+ ...this.position(e),
664
+ h: this.height(e)
665
+ })), r = Math.min(...n.map((e) => e.x)), i = Math.min(...n.map((e) => e.y)), a = Math.max(...n.map((e) => e.x + 164)), o = Math.max(...n.map((e) => e.y + e.h)), s = z(Math.min((t.width - 64) / (a - r), (t.height - 64) / (o - i)), L, 1.1);
666
+ this.#f = {
667
+ z: s,
668
+ x: 32 + (t.width - 64 - (a - r) * s) / 2 - r * s,
669
+ y: 32 + (t.height - 64 - (o - i) * s) / 2 - i * s
670
+ }, this.applyView();
671
+ }
672
+ focus(e) {
673
+ let t = this.node(e), n = this.graph.edges.find((t) => t.id === e), r = t ?? (n === void 0 ? void 0 : this.node(n.source));
674
+ if (r === void 0) return;
675
+ let i = this.#t.getBoundingClientRect(), a = this.position(r);
676
+ this.#f = {
677
+ ...this.#f,
678
+ x: i.width / 2 - (a.x + 164 / 2) * this.#f.z,
679
+ y: i.height / 2 - (a.y + this.height(r) / 2) * this.#f.z
680
+ }, this.applyView();
681
+ let o = this.#i.querySelector(`[data-bp-node-id="${Ve(r.id)}"]`);
682
+ o?.classList.add("is-flash"), setTimeout(() => o?.classList.remove("is-flash"), 600);
683
+ }
684
+ autoLayout() {
685
+ let e = this.graph.nodes, t = new Map(e.map((e) => [e.id, 0]));
686
+ for (let n = 0; n < e.length; n++) {
687
+ let e = !1;
688
+ for (let n of this.graph.edges) {
689
+ if (n.kind !== "flow") continue;
690
+ let r = Math.min((t.get(n.source) ?? 0) + 1, 24);
691
+ r > (t.get(n.target) ?? 0) && (t.set(n.target, r), e = !0);
692
+ }
693
+ if (!e) break;
694
+ }
695
+ let n = /* @__PURE__ */ new Map();
696
+ for (let r of e) {
697
+ let e = t.get(r.id) ?? 0, i = n.get(e) ?? [];
698
+ i.push(r), n.set(e, i);
699
+ }
700
+ for (let [e, t] of n) {
701
+ let n = 24;
702
+ t.sort((e, t) => this.position(e).y - this.position(t).y);
703
+ for (let r of t) this.#m.set(r.id, {
704
+ x: 40 + e * 248,
705
+ y: n
706
+ }), n += this.height(r) + 28;
707
+ }
708
+ this.render(), this.fit(), this.commitLayout();
709
+ }
710
+ commitLayout() {
711
+ let e = this.graph.nodes.map((e) => {
712
+ let t = this.position(e);
713
+ return {
714
+ id: e.id,
715
+ x: Math.round(t.x),
716
+ y: Math.round(t.y)
717
+ };
718
+ });
719
+ this.send({
720
+ type: "commit-layout",
721
+ nodes: e,
722
+ viewport: {
723
+ x: Math.round(this.#f.x),
724
+ y: Math.round(this.#f.y),
725
+ zoom: Math.round(this.#f.z * 1e3) / 1e3
726
+ }
727
+ });
728
+ }
729
+ onPointerDown(e) {
730
+ let t = e.target instanceof Element ? e.target : null;
731
+ if (t?.closest("[data-bp-rename-input]") !== null && t !== null) return;
732
+ this.element.focus({ preventScroll: !0 }), this.closeMenu();
733
+ let n = t?.closest("[data-bp-port]") ?? null, r = t?.closest("[data-bp-edge]") ?? null, i = t?.closest("[data-bp-node-id]") ?? null, a = e.ctrlKey || e.metaKey || e.shiftKey;
734
+ if (e.button === 2) {
735
+ this.#g = {
736
+ type: "context",
737
+ startX: e.clientX,
738
+ startY: e.clientY,
739
+ viewX: this.#f.x,
740
+ viewY: this.#f.y,
741
+ moved: !1,
742
+ target: t,
743
+ additive: a
744
+ }, this.#t.setPointerCapture(e.pointerId);
745
+ return;
746
+ }
747
+ if (this.#C || e.button === 1) {
748
+ this.#g = {
749
+ type: "pan",
750
+ startX: e.clientX,
751
+ startY: e.clientY,
752
+ viewX: this.#f.x,
753
+ viewY: this.#f.y,
754
+ moved: !1,
755
+ target: t,
756
+ additive: a
757
+ }, this.#t.classList.add("is-panning"), this.#t.setPointerCapture(e.pointerId);
758
+ return;
759
+ }
760
+ if (e.button === 0) {
761
+ if (n !== null) {
762
+ let t = this.node(n.dataset.bpNode ?? ""), r = n.dataset.bpPort, i = n.dataset.bpDir === "in" ? "in" : "out";
763
+ if (t !== void 0 && r !== void 0 && n.dataset.available !== "false") {
764
+ let n = {
765
+ node: t.id,
766
+ port: r
767
+ };
768
+ this.#g = {
769
+ type: "link",
770
+ from: n,
771
+ direction: i,
772
+ anchor: this.portPoint(t, r, i),
773
+ snap: void 0
774
+ }, this.#t.classList.add("is-connecting"), this.markConnectable(n, i), this.#t.setPointerCapture(e.pointerId);
775
+ return;
776
+ }
777
+ }
778
+ if (i !== null) {
779
+ let t = i.dataset.bpNodeId ?? "";
780
+ if (a) {
781
+ let e = this.#h.nodes.includes(t) ? this.#h.nodes.filter((e) => e !== t) : [...this.#h.nodes, t];
782
+ this.select({
783
+ nodes: e,
784
+ edges: this.#h.edges
785
+ });
786
+ return;
787
+ }
788
+ this.#h.nodes.includes(t) || this.select({
789
+ nodes: [t],
790
+ edges: []
791
+ });
792
+ let n = this.#h.nodes;
793
+ this.#g = {
794
+ type: "node",
795
+ ids: n,
796
+ origins: n.map((e) => {
797
+ let t = this.node(e);
798
+ return t === void 0 ? {
799
+ x: 0,
800
+ y: 0
801
+ } : this.position(t);
802
+ }),
803
+ startX: e.clientX,
804
+ startY: e.clientY,
805
+ moved: !1
806
+ }, this.#t.setPointerCapture(e.pointerId);
807
+ return;
808
+ }
809
+ if (r !== null) {
810
+ let e = r.dataset.bpEdge ?? "";
811
+ this.select(a ? {
812
+ nodes: this.#h.nodes,
813
+ edges: this.#h.edges.includes(e) ? this.#h.edges.filter((t) => t !== e) : [...this.#h.edges, e]
814
+ } : {
815
+ nodes: [],
816
+ edges: [e]
817
+ });
818
+ return;
819
+ }
820
+ this.#g = {
821
+ type: "marquee",
822
+ startX: e.clientX,
823
+ startY: e.clientY,
824
+ world: this.toWorld(e.clientX, e.clientY),
825
+ moved: !1,
826
+ additive: a,
827
+ base: this.#h.nodes
828
+ }, this.#t.setPointerCapture(e.pointerId);
829
+ }
830
+ }
831
+ onPointerMove(e) {
832
+ let t = this.#g;
833
+ if (t === void 0) {
834
+ let t = e.target?.closest("[data-bp-edge]");
835
+ this.setHoverEdge(t?.dataset.bpEdge);
836
+ return;
837
+ }
838
+ if (t.type === "pan" || t.type === "context") {
839
+ let n = e.clientX - t.startX, r = e.clientY - t.startY;
840
+ if (!t.moved && n * n + r * r < 16) return;
841
+ t.moved = !0, this.#t.classList.add("is-panning"), this.#f = {
842
+ ...this.#f,
843
+ x: t.viewX + n,
844
+ y: t.viewY + r
845
+ }, this.applyView();
846
+ return;
847
+ }
848
+ if (t.type === "node") {
849
+ let n = (e.clientX - t.startX) / this.#f.z, r = (e.clientY - t.startY) / this.#f.z;
850
+ if (!t.moved && Math.abs(n) + Math.abs(r) <= 2) return;
851
+ t.moved = !0, t.ids.forEach((e, i) => {
852
+ let a = t.origins[i] ?? {
853
+ x: 0,
854
+ y: 0
855
+ }, o = {
856
+ x: Math.round((a.x + n) / I) * I,
857
+ y: Math.round((a.y + r) / I) * I
858
+ };
859
+ this.#m.set(e, o);
860
+ let s = this.#i.querySelector(`[data-bp-node-id="${Ve(e)}"]`);
861
+ s !== null && (s.style.left = `${o.x}px`, s.style.top = `${o.y}px`);
862
+ }), this.#D = "", this.renderEdges();
863
+ return;
864
+ }
865
+ if (t.type === "link") {
866
+ let n = t.direction === "out" ? "in" : "out", r, i = 784;
867
+ for (let t of this.#i.querySelectorAll(`[data-bp-dir="${n}"]:not(.is-blocked)`)) {
868
+ let n = t.getBoundingClientRect(), a = (n.left + n.width / 2 - e.clientX) ** 2 + (n.top + n.height / 2 - e.clientY) ** 2;
869
+ a < i && (i = a, r = t);
870
+ }
871
+ for (let e of this.#i.querySelectorAll(".is-snap")) e.classList.remove("is-snap");
872
+ r?.classList.add("is-snap"), t.snap = r === void 0 ? void 0 : {
873
+ node: r.dataset.bpNode ?? "",
874
+ port: r.dataset.bpPort ?? ""
875
+ };
876
+ let a = t.snap === void 0 ? void 0 : this.node(t.snap.node), o = a === void 0 || t.snap === void 0 ? this.toWorld(e.clientX, e.clientY) : this.portPoint(a, t.snap.port, n);
877
+ this.renderEdges(t.direction === "out" ? {
878
+ from: t.anchor,
879
+ to: o
880
+ } : {
881
+ from: o,
882
+ to: t.anchor
883
+ });
884
+ return;
885
+ }
886
+ if (t.type !== "marquee") return;
887
+ let n = e.clientX - t.startX, r = e.clientY - t.startY;
888
+ if (!t.moved && n * n + r * r < 16) return;
889
+ t.moved = !0;
890
+ let i = this.#t.getBoundingClientRect();
891
+ this.#o.hidden = !1, Object.assign(this.#o.style, {
892
+ left: `${Math.min(e.clientX, t.startX) - i.left}px`,
893
+ top: `${Math.min(e.clientY, t.startY) - i.top}px`,
894
+ width: `${Math.abs(n)}px`,
895
+ height: `${Math.abs(r)}px`
896
+ });
897
+ let a = this.toWorld(e.clientX, e.clientY), o = Math.min(a.x, t.world.x), s = Math.max(a.x, t.world.x), c = Math.min(a.y, t.world.y), l = Math.max(a.y, t.world.y), u = this.graph.nodes.filter((e) => {
898
+ let t = this.position(e);
899
+ return t.x < s && t.x + 164 > o && t.y < l && t.y + this.height(e) > c;
900
+ }).map((e) => e.id);
901
+ this.#h = {
902
+ nodes: t.additive ? [.../* @__PURE__ */ new Set([...t.base, ...u])] : u,
903
+ edges: []
904
+ }, this.renderSelection();
905
+ }
906
+ onPointerUp(e) {
907
+ let t = this.#g;
908
+ if (this.#g = void 0, this.#t.classList.remove("is-panning"), t !== void 0) {
909
+ if (t.type === "context") {
910
+ t.moved || this.openMenu(e.clientX, e.clientY, t.target, t.additive);
911
+ return;
912
+ }
913
+ if (t.type === "link") {
914
+ this.#t.classList.remove("is-connecting");
915
+ for (let e of this.#i.querySelectorAll(".is-blocked, .is-snap")) e.classList.remove("is-blocked", "is-snap");
916
+ let e = t.snap;
917
+ if (e !== void 0) {
918
+ let [n, r] = t.direction === "out" ? [t.from, e] : [e, t.from];
919
+ this.send({
920
+ type: "connect",
921
+ from: n,
922
+ to: r
923
+ });
924
+ }
925
+ this.renderEdges();
926
+ return;
927
+ }
928
+ if (t.type === "node") {
929
+ t.moved && this.commitLayout();
930
+ return;
931
+ }
932
+ t.type === "marquee" && (this.#o.hidden = !0, t.moved ? this.select(this.#h) : t.additive || this.select({
933
+ nodes: [],
934
+ edges: []
935
+ }));
936
+ }
937
+ }
938
+ cancelDrag() {
939
+ this.#g = void 0, this.#o.hidden = !0, this.#t.classList.remove("is-panning", "is-connecting"), this.renderEdges();
940
+ }
941
+ markConnectable(e, t) {
942
+ let n = t === "out" ? "in" : "out", r = e.port === "semantic";
943
+ for (let t of this.#i.querySelectorAll("[data-bp-port]")) {
944
+ let i = t.dataset.bpDir !== n || t.dataset.bpNode === e.node || t.dataset.bpPort === "semantic" !== r || t.dataset.available === "false";
945
+ t.classList.toggle("is-blocked", i);
946
+ }
947
+ }
948
+ onDoubleClick(e) {
949
+ let t = (this.#e.elementFromPoint?.(e.clientX, e.clientY)?.closest("[data-bp-rename]"))?.dataset.bpRename ?? e.target?.closest("[data-bp-rename]")?.dataset.bpRename;
950
+ t !== void 0 && (e.preventDefault(), this.startRename(t));
951
+ }
952
+ onWheel(e) {
953
+ if (e.preventDefault(), e.ctrlKey || e.metaKey) {
954
+ let t = this.#t.getBoundingClientRect();
955
+ this.zoomAt(e.deltaY < 0 ? 1.1 : 1 / 1.1, e.clientX - t.left, e.clientY - t.top);
956
+ return;
957
+ }
958
+ this.#f = {
959
+ ...this.#f,
960
+ x: this.#f.x - (e.shiftKey ? e.deltaY : e.deltaX),
961
+ y: this.#f.y - (e.shiftKey ? 0 : e.deltaY)
962
+ }, this.applyView();
963
+ }
964
+ onDragOver(e) {
965
+ e.dataTransfer?.types.includes("application/x-base-screen-blueprint-node") === !0 && (e.preventDefault(), e.dataTransfer.dropEffect = "copy");
966
+ }
967
+ onDrop(e) {
968
+ let t = e.dataTransfer?.getData(ne);
969
+ if (t === void 0 || t === "") return;
970
+ e.preventDefault();
971
+ let n;
972
+ try {
973
+ n = JSON.parse(t);
974
+ } catch {
975
+ return;
976
+ }
977
+ let r = this.toWorld(e.clientX, e.clientY);
978
+ this.send({
979
+ type: "insert-node",
980
+ ...n,
981
+ position: {
982
+ x: Math.round(r.x - 164 / 2),
983
+ y: Math.round(r.y - 44 / 2)
984
+ }
985
+ });
986
+ }
987
+ onKeyDown(e) {
988
+ if (e.target?.closest("input, textarea, select") !== null) return;
989
+ let t = e.ctrlKey || e.metaKey;
990
+ if (e.code === "Space") {
991
+ this.#C = !0, this.#t.classList.add("is-space"), e.preventDefault();
992
+ return;
993
+ }
994
+ if (e.key === "Escape") {
995
+ this.#s.hidden ? this.select({
996
+ nodes: [],
997
+ edges: []
998
+ }) : this.closeMenu();
999
+ return;
1000
+ }
1001
+ if (e.key === "Delete" || e.key === "Backspace") {
1002
+ if (this.#h.nodes.length + this.#h.edges.length === 0) return;
1003
+ e.preventDefault(), this.send({
1004
+ type: "delete-selection",
1005
+ selection: this.#h
1006
+ });
1007
+ return;
1008
+ }
1009
+ if (e.key === "F2" && this.#h.nodes.length === 1) {
1010
+ e.preventDefault(), this.startRename(this.#h.nodes[0] ?? "");
1011
+ return;
1012
+ }
1013
+ if (!t) return;
1014
+ let n = e.key.toLowerCase();
1015
+ n === "a" ? (e.preventDefault(), this.select({
1016
+ nodes: this.graph.nodes.map((e) => e.id),
1017
+ edges: []
1018
+ })) : n === "d" ? (e.preventDefault(), this.#h.nodes.length > 0 && this.send({
1019
+ type: "duplicate-nodes",
1020
+ nodeIds: this.#h.nodes
1021
+ })) : n === "0" ? (e.preventDefault(), this.fit()) : n === "z" ? (e.preventDefault(), this.send({ type: e.shiftKey ? "history-redo" : "history-undo" })) : n === "y" && (e.preventDefault(), this.send({ type: "history-redo" }));
1022
+ }
1023
+ startRename(e) {
1024
+ let t = this.node(e);
1025
+ t === void 0 || !t.renamable || (this.#v = e, this.renderNodes());
1026
+ }
1027
+ finishRename(e) {
1028
+ let t = this.#v;
1029
+ this.#v = void 0;
1030
+ let n = t === void 0 ? void 0 : this.node(t);
1031
+ if (n !== void 0) {
1032
+ let t = e.trim();
1033
+ t !== (n.name ?? "") && t !== n.title && this.send({
1034
+ type: "update-node",
1035
+ nodeIds: [n.id],
1036
+ update: {
1037
+ type: "name",
1038
+ name: t === "" ? null : t
1039
+ }
1040
+ });
1041
+ }
1042
+ this.renderNodes();
1043
+ }
1044
+ onToolbarClick(e) {
1045
+ let t = e.target.closest("[data-bp-tool]");
1046
+ if (t === null || t.disabled) return;
1047
+ let n = this.#t.getBoundingClientRect();
1048
+ switch (t.dataset.bpTool) {
1049
+ case "add": {
1050
+ let e = t.getBoundingClientRect();
1051
+ this.#w = this.toWorld(n.left + n.width / 2, n.top + n.height / 2), this.openAddMenu(e.left, e.bottom + 4);
1052
+ break;
1053
+ }
1054
+ case "auto-layout":
1055
+ this.autoLayout();
1056
+ break;
1057
+ case "undo":
1058
+ this.send({ type: "history-undo" });
1059
+ break;
1060
+ case "redo":
1061
+ this.send({ type: "history-redo" });
1062
+ break;
1063
+ case "semantic":
1064
+ this.#b = !this.#b, this.render();
1065
+ break;
1066
+ case "trace":
1067
+ this.#y = !this.#y, this.render();
1068
+ break;
1069
+ case "zoom-in":
1070
+ this.zoomAt(1.1, n.width / 2, n.height / 2);
1071
+ break;
1072
+ case "zoom-out":
1073
+ this.zoomAt(1 / 1.1, n.width / 2, n.height / 2);
1074
+ break;
1075
+ case "fit":
1076
+ this.fit();
1077
+ break;
1078
+ case "simulate": this.#x = !this.#x, this.renderToolbar(), this.renderSimulation();
1079
+ }
1080
+ }
1081
+ onSimulationClick(e) {
1082
+ let t = e.target.closest("[data-bp-sim]")?.dataset.bpSim;
1083
+ if (t === "clear") {
1084
+ this.send({ type: "clear-simulation" });
1085
+ return;
1086
+ }
1087
+ if (t !== "run" || this.#S === void 0) return;
1088
+ let [n, r] = this.#S.split("\0"), i = this.#l.querySelector("[data-bp-sim-payload]"), a;
1089
+ try {
1090
+ a = JSON.parse(i?.value.trim() || "null");
1091
+ } catch {
1092
+ let e = this.#l.querySelector("[data-bp-sim-message]");
1093
+ e !== null && (e.textContent = R.simulation.invalidPayload);
1094
+ return;
1095
+ }
1096
+ n !== void 0 && r !== void 0 && this.send({
1097
+ type: "run-simulation",
1098
+ nodeId: n,
1099
+ port: r,
1100
+ payload: a
1101
+ });
1102
+ }
1103
+ menuItem(e, t, n, r = {}) {
1104
+ return `<button type="button" class="designer-control designer-button designer-menu-item" role="menuitem" data-bp-menu-action="${N(e)}"${r.danger === !0 ? " data-menu-tone=\"danger\"" : ""}${r.disabled === !0 ? " disabled" : ""}><span class="menu-item-icon" aria-hidden="true">${h(t)}</span><span class="menu-item-label">${x(n)}</span>${r.kbd === void 0 ? "" : `<kbd>${x(r.kbd)}</kbd>`}</button>`;
1105
+ }
1106
+ addItems() {
1107
+ let e = new Set(this.graph.nodes.map((e) => e.kind));
1108
+ return Fe.map((t) => this.menuItem(`add:${t}`, Ie[t], R.nodeKinds[t], { disabled: (t === "host" || t === "lifecycle") && e.has(t) })).join("");
1109
+ }
1110
+ openMenu(e, t, n, r) {
1111
+ let i = n?.closest("[data-bp-node-id]") ?? null, a = n?.closest("[data-bp-edge]") ?? null;
1112
+ if (i !== null) {
1113
+ let e = i.dataset.bpNodeId ?? "";
1114
+ this.#h.nodes.includes(e) || this.select({
1115
+ nodes: [e],
1116
+ edges: []
1117
+ });
1118
+ } else if (a !== null) {
1119
+ let e = a.dataset.bpEdge ?? "";
1120
+ this.#h.edges.includes(e) || this.select({
1121
+ nodes: [],
1122
+ edges: [e]
1123
+ });
1124
+ } else !r && this.#h.nodes.length + this.#h.edges.length > 0 && this.select({
1125
+ nodes: [],
1126
+ edges: []
1127
+ });
1128
+ this.#w = this.toWorld(e, t);
1129
+ let o = R.menu, s = this.#h.nodes.map((e) => this.node(e)).filter(Be), c = s.length === 1 ? s[0] : void 0, l = "";
1130
+ if (s.length > 1 && (l += `<div class="designer-context-menu-heading"><span class="designer-context-menu-heading-icon" aria-hidden="true">${h("select-all")}</span><span class="designer-context-menu-heading-label">${x(R.multiSelection(s.length, this.#h.edges.length))}</span></div>`), s.length > 0) {
1131
+ let e = s.some((e) => e.enabled);
1132
+ l += this.menuItem("delete", "trash", o.delete, {
1133
+ kbd: "Delete",
1134
+ danger: !0
1135
+ }), c !== void 0 && (l += this.menuItem("rename", "pencil", o.rename, {
1136
+ kbd: "F2",
1137
+ disabled: !c.renamable
1138
+ })), l += this.menuItem("duplicate", "duplicate", o.duplicate, {
1139
+ kbd: "Ctrl D",
1140
+ disabled: !s.some((e) => e.duplicable)
1141
+ }), l += this.menuItem(e ? "disable" : "enable", e ? "eye-off" : "eye", e ? o.disable : o.enable);
1142
+ let t = (this.#d?.simulationTriggers ?? []).filter((e) => c !== void 0 && e.nodeId === c.id);
1143
+ c !== void 0 && t.length > 0 && (l += this.menuItem("simulate", "play", o.simulateFrom)), l += "<div class=\"designer-menu-separator\" role=\"separator\"></div>";
1144
+ } else this.#h.edges.length > 0 && (l += this.menuItem("delete", "trash", o.deleteEdge, {
1145
+ kbd: "Delete",
1146
+ danger: !0
1147
+ }), l += "<div class=\"designer-menu-separator\" role=\"separator\"></div>");
1148
+ l += `<div class="designer-menu-section-label">${x(o.addHere)}</div>`, l += this.addItems(), l += "<div class=\"designer-menu-separator\" role=\"separator\"></div>", l += this.menuItem("select-all", "select-all", o.selectAll, { kbd: "Ctrl A" }), l += this.menuItem("auto-layout", "grid", o.autoLayout), l += this.menuItem("fit", "fit", o.fit, { kbd: "Ctrl 0" }), this.showMenu(l, e, t);
1149
+ }
1150
+ openAddMenu(e, t) {
1151
+ this.showMenu(`<div class="designer-menu-section-label">${x(R.toolbar.addNode)}</div>${this.addItems()}`, e, t);
1152
+ }
1153
+ showMenu(e, t, n) {
1154
+ this.#s.innerHTML = e, b(this.#s), this.#s.hidden = !1;
1155
+ let r = this.element.getBoundingClientRect();
1156
+ this.#s.style.left = "0px", this.#s.style.top = "0px";
1157
+ let i = t - r.left, a = n - r.top, o = this.#s.offsetWidth, s = this.#s.offsetHeight;
1158
+ i + o > r.width - 8 && (i = Math.max(8, i - o)), a + s > r.height - 8 && (a = Math.max(8, r.height - 8 - s)), this.#s.style.left = `${i}px`, this.#s.style.top = `${a}px`, this.#s.focus({ preventScroll: !0 });
1159
+ }
1160
+ closeMenu() {
1161
+ this.#s.hidden = !0, this.#s.innerHTML = "";
1162
+ }
1163
+ onMenuClick(e) {
1164
+ let t = e.target.closest("[data-bp-menu-action]");
1165
+ if (t === null || t.disabled) return;
1166
+ let n = t.dataset.bpMenuAction ?? "";
1167
+ this.closeMenu();
1168
+ let r = this.#h.nodes;
1169
+ if (n.startsWith("add:")) {
1170
+ let e = n.slice(4);
1171
+ (e === "host" || e === "lifecycle" || e === "timer" || e === "condition") && this.send({
1172
+ type: "insert-node",
1173
+ kind: e,
1174
+ position: {
1175
+ x: Math.round(this.#w.x),
1176
+ y: Math.round(this.#w.y)
1177
+ }
1178
+ });
1179
+ return;
1180
+ }
1181
+ switch (n) {
1182
+ case "delete":
1183
+ this.send({
1184
+ type: "delete-selection",
1185
+ selection: this.#h
1186
+ });
1187
+ break;
1188
+ case "rename":
1189
+ r[0] !== void 0 && this.startRename(r[0]);
1190
+ break;
1191
+ case "duplicate":
1192
+ this.send({
1193
+ type: "duplicate-nodes",
1194
+ nodeIds: r
1195
+ });
1196
+ break;
1197
+ case "disable":
1198
+ case "enable":
1199
+ this.send({
1200
+ type: "update-node",
1201
+ nodeIds: r,
1202
+ update: {
1203
+ type: "enabled",
1204
+ enabled: n === "enable"
1205
+ }
1206
+ });
1207
+ break;
1208
+ case "simulate": {
1209
+ let e = (this.#d?.simulationTriggers ?? []).find((e) => e.nodeId === r[0]);
1210
+ e !== void 0 && (this.#S = `${e.nodeId}\u0000${e.port}`, this.#x = !0, this.renderToolbar(), this.renderSimulation());
1211
+ break;
1212
+ }
1213
+ case "select-all":
1214
+ this.select({
1215
+ nodes: this.graph.nodes.map((e) => e.id),
1216
+ edges: []
1217
+ });
1218
+ break;
1219
+ case "auto-layout":
1220
+ this.autoLayout();
1221
+ break;
1222
+ case "fit": this.fit();
1223
+ }
1224
+ }
1225
+ };
1226
+ function ze(e, t) {
1227
+ let n = Math.abs(t.x - e.x), r = t.x < e.x ? .8 : .5, i = {
1228
+ x: e.x + n * r,
1229
+ y: e.y
1230
+ }, a = {
1231
+ x: t.x - n * r,
1232
+ y: t.y
1233
+ }, o = .5, s = .5, c = {
1234
+ x: s ** 3 * e.x + 3 * s * s * o * i.x + 3 * s * o * o * a.x + o ** 3 * t.x,
1235
+ y: s ** 3 * e.y + 3 * s * s * o * i.y + 3 * s * o * o * a.y + o ** 3 * t.y
1236
+ }, l = 3 * s * s * (i.x - e.x) + 6 * s * o * (a.x - i.x) + 3 * o * o * (t.x - a.x), u = 3 * s * s * (i.y - e.y) + 6 * s * o * (a.y - i.y) + 3 * o * o * (t.y - a.y);
1237
+ return {
1238
+ d: `M${e.x},${e.y} C${i.x},${i.y} ${a.x},${a.y} ${t.x},${t.y}`,
1239
+ mid: c,
1240
+ angle: Math.round(Math.atan2(u, l) * 180 / Math.PI)
1241
+ };
1242
+ }
1243
+ function z(e, t, n) {
1244
+ return Math.min(n, Math.max(t, e));
1245
+ }
1246
+ function Be(e) {
1247
+ return e !== void 0;
1248
+ }
1249
+ function Ve(e) {
1250
+ return typeof CSS < "u" && typeof CSS.escape == "function" ? CSS.escape(e) : e.replace(/["\\]/g, "\\$&");
1251
+ }
1252
+ function He(e, t, n, r) {
1253
+ let i = e.querySelector(".designer");
1254
+ i !== null && (i.dataset.authoringMode = t);
1255
+ let a = e.querySelector("[data-blueprint-surface]");
1256
+ a !== null && (a.hidden = t !== "blueprint" || !n, a.dataset.slotReady = String(n));
1257
+ for (let r of e.querySelectorAll("[data-workbench-mode-tab]")) {
1258
+ let e = r.dataset.workbenchModeTab, i = e === t, a = e === "blueprint" && !n;
1259
+ r.disabled = a, r.dataset.active = String(i), r.setAttribute("aria-selected", String(i)), r.tabIndex = i ? 0 : -1;
1260
+ let o = a ? d.interactionWorkspaceUnavailable : e === "blueprint" ? d.interactionWorkspaceHint : d.canvasWorkspace;
1261
+ r.setAttribute("data-tip", o), r.ariaLabel = o;
1262
+ }
1263
+ let o = t === "blueprint" ? d.commandPalette.blueprintTrigger : d.commandPalette.trigger, s = e.querySelector("[data-command-palette-trigger-label]");
1264
+ s !== null && (s.textContent = o);
1265
+ let c = e.querySelector("[data-command-palette-toggle]");
1266
+ if (c !== null && (c.ariaLabel = o, c.setAttribute("data-tip", o)), Ue(e, t, r.nodes), t !== "blueprint") return;
1267
+ let l = e.querySelector("[data-status-selection]");
1268
+ l !== null && (l.textContent = d.blueprint.workbench);
1269
+ let u = e.querySelector("[data-status-canvas]");
1270
+ u !== null && (u.textContent = d.blueprint.status(r.nodes, r.relations, r.semantic, r.structural, r.problems));
1271
+ }
1272
+ function Ue(e, t, n) {
1273
+ let r = t === "blueprint", i = e.querySelector("[data-blueprint-library]"), a = e.querySelector("[data-blueprint-inspector]");
1274
+ i !== null && (i.hidden = !r), a !== null && (a.hidden = !r), We(e, "left", r, d.blueprint.library, n), We(e, "right", r, d.blueprint.inspector);
1275
+ }
1276
+ function We(e, t, n, r, i) {
1277
+ let a = e.querySelector(`[data-${t}-panel-title]`), o = e.querySelector(`[data-${t}-panel-count]`);
1278
+ a !== null && (n ? (a.dataset.canvasTitle ??= a.textContent ?? "", a.textContent = r) : a.dataset.canvasTitle !== void 0 && (a.textContent = a.dataset.canvasTitle, delete a.dataset.canvasTitle)), o !== null && (n ? (o.dataset.canvasCount ??= o.textContent ?? "", o.dataset.canvasAriaLabel ??= o.getAttribute("aria-label") ?? "", o.textContent = String(i ?? 0), o.setAttribute("aria-label", d.blueprint.panelCount(r, i ?? 0))) : o.dataset.canvasCount !== void 0 && (o.textContent = o.dataset.canvasCount, o.setAttribute("aria-label", o.dataset.canvasAriaLabel ?? ""), delete o.dataset.canvasCount, delete o.dataset.canvasAriaLabel));
1279
+ }
1280
+ function Ge(e) {
1281
+ return typeof e == "object" && !!e && !Array.isArray(e);
1282
+ }
1283
+ function B(e, t) {
1284
+ return {
1285
+ severity: "error",
1286
+ code: e,
1287
+ path: [],
1288
+ message: t
1289
+ };
1290
+ }
1291
+ function V(e, t) {
1292
+ return {
1293
+ ok: !1,
1294
+ diagnostics: [B(e, t)]
1295
+ };
1296
+ }
1297
+ function Ke(e, t) {
1298
+ let n = Ge(e) && typeof e.commandId == "string" ? e.commandId.slice(0, 128) : "invalid-command";
1299
+ return E({
1300
+ commandId: n,
1301
+ status: "rejected",
1302
+ diagnostics: t
1303
+ });
1304
+ }
1305
+ function qe(e) {
1306
+ return { hasBlueprintCapability: (t) => {
1307
+ try {
1308
+ return e()?.hasBlueprintCapability(t) === !0;
1309
+ } catch {
1310
+ return !1;
1311
+ }
1312
+ } };
1313
+ }
1314
+ function Je(e) {
1315
+ let t = d.blueprint.graph.connection;
1316
+ return e === "duplicate" ? t.duplicate : e === "cycle" ? t.cycle : e === "unavailable" ? t.unavailable : t.invalid;
1317
+ }
1318
+ var Ye = 256, H = d.blueprint.graph, Xe = class {
1319
+ callbacks;
1320
+ #e;
1321
+ #t;
1322
+ #n = null;
1323
+ #r;
1324
+ #i = 0;
1325
+ #a = /* @__PURE__ */ new Map();
1326
+ #o = (e) => this.receive(e);
1327
+ constructor(e) {
1328
+ this.callbacks = e;
1329
+ }
1330
+ get canvas() {
1331
+ return this.#t;
1332
+ }
1333
+ get trace() {
1334
+ return this.#n;
1335
+ }
1336
+ connect(e) {
1337
+ this.#e !== e && (this.disconnect(), this.#e = e, e.addEventListener("base-screen-blueprint-canvas-command", this.#o));
1338
+ }
1339
+ disconnect() {
1340
+ this.#e?.removeEventListener(le, this.#o), this.#e = void 0;
1341
+ }
1342
+ setCanvas(e) {
1343
+ return e !== this.#t && (this.#t = e, this.#i++, this.#a.clear(), this.#r = void 0, !0);
1344
+ }
1345
+ reset() {
1346
+ this.#n = null, this.#r = void 0, this.#a.clear();
1347
+ }
1348
+ clearTrace() {
1349
+ this.#n = null;
1350
+ }
1351
+ dispatchState(e = this.callbacks.getGraph()) {
1352
+ let t = this.#t;
1353
+ if (t === void 0) return;
1354
+ let n = this.callbacks.getDocument(), r = this.callbacks.getViewRequest(), i = E({
1355
+ generation: this.#i,
1356
+ documentRevision: this.callbacks.getDocumentRevision(),
1357
+ projectRevision: this.callbacks.getProjectRevision(),
1358
+ active: this.callbacks.getMode() === "blueprint",
1359
+ canUndo: this.callbacks.canUndo(),
1360
+ canRedo: this.callbacks.canRedo(),
1361
+ graph: e,
1362
+ selection: this.callbacks.getSelection(),
1363
+ diagnostics: this.stateDiagnostics(),
1364
+ trace: this.#n,
1365
+ simulationTriggers: n === void 0 ? [] : Ee(e, n),
1366
+ showSemantic: this.callbacks.getShowSemantic(),
1367
+ ...r === void 0 ? {} : { viewRequest: r },
1368
+ ...this.#r === void 0 ? {} : { lastCommand: this.#r }
1369
+ });
1370
+ t.dispatchEvent(new CustomEvent(te, { detail: { state: i } }));
1371
+ }
1372
+ commitBlueprint(e) {
1373
+ let t = this.callbacks.getDocument();
1374
+ if (t === void 0) return V("AUTHORING_EXPIRED", d.lifecycle.unloaded);
1375
+ if (e === null) return V("AUTHORING_REQUEST_INVALID", d.blueprint.invalidCommand);
1376
+ if (u(e, t.blueprint)) return {
1377
+ ok: !0,
1378
+ value: t,
1379
+ diagnostics: []
1380
+ };
1381
+ let n = c({
1382
+ ...t,
1383
+ blueprint: e
1384
+ });
1385
+ return n.ok ? this.callbacks.executeCommand({
1386
+ type: "replace-blueprint",
1387
+ blueprint: n.value.blueprint
1388
+ }) : n;
1389
+ }
1390
+ stateDiagnostics() {
1391
+ let e = this.callbacks.getDocument(), t = e === void 0 ? void 0 : ve(e, this.capabilities);
1392
+ return [...t !== void 0 && !t.ok ? t.diagnostics : [], ...this.#r?.diagnostics ?? []];
1393
+ }
1394
+ simulate(e, t, n) {
1395
+ let r = this.runSimulation(e, t, n);
1396
+ return r.ok && this.callbacks.onSimulated?.(), this.callbacks.render(), r.ok || this.callbacks.emitDiagnostics(r.diagnostics), r;
1397
+ }
1398
+ receive(e) {
1399
+ if (this.#t === void 0 || !e.composedPath().includes(this.#t)) return;
1400
+ let t = e.detail, n = Ge(t) && Object.keys(t).length === 1 && "command" in t ? t.command : void 0, r = S(n);
1401
+ if (!r.ok) {
1402
+ this.rejectUnknown(n, r.diagnostics);
1403
+ return;
1404
+ }
1405
+ let i = r.value, a = this.#a.get(i.commandId);
1406
+ if (a !== void 0) {
1407
+ this.#r = a, this.dispatchState();
1408
+ return;
1409
+ }
1410
+ let o = i.type === "select" || i.type === "run-simulation" || i.type === "clear-simulation";
1411
+ if (i.generation !== this.#i || !o && i.documentRevision !== this.callbacks.getDocumentRevision()) {
1412
+ this.finish(i.commandId, "rejected", [B("AUTHORING_EXPIRED", d.blueprint.staleCommand)]);
1413
+ return;
1414
+ }
1415
+ this.execute(i);
1416
+ }
1417
+ execute(e) {
1418
+ if (e.type === "ready") {
1419
+ this.finish(e.commandId, "accepted", []);
1420
+ return;
1421
+ }
1422
+ let t = this.callbacks.getDocument();
1423
+ if (t === void 0) {
1424
+ this.finish(e.commandId, "rejected", [B("AUTHORING_EXPIRED", d.lifecycle.unloaded)]);
1425
+ return;
1426
+ }
1427
+ let n = {
1428
+ ok: !0,
1429
+ value: null,
1430
+ diagnostics: []
1431
+ };
1432
+ switch (e.type) {
1433
+ case "select":
1434
+ n = this.callbacks.select(e.selection, !1);
1435
+ break;
1436
+ case "connect": {
1437
+ let r = _e(t.blueprint, e.from, e.to, Se(t, this.callbacks.getCatalog(), this.callbacks.getRuntimeContributions()));
1438
+ n = r.ok ? this.commitBlueprint(r.blueprint) : V("AUTHORING_REQUEST_INVALID", Je(r.reason)), n.ok && r.ok && (n = this.callbacks.select({
1439
+ nodes: [],
1440
+ edges: [r.edgeId]
1441
+ }, !1));
1442
+ break;
1443
+ }
1444
+ case "delete-selection":
1445
+ n = this.commitBlueprint(w(t.blueprint, e.selection)), n.ok && this.callbacks.select(_, !1);
1446
+ break;
1447
+ case "insert-node": {
1448
+ let { type: r, commandId: i, generation: a, documentRevision: o, position: s, ...c } = e, l = T(t, c, s);
1449
+ n = this.commitBlueprint(l?.blueprint ?? null), n.ok && l !== null && (n = this.callbacks.select({
1450
+ nodes: [l.nodeId],
1451
+ edges: []
1452
+ }, !1));
1453
+ break;
1454
+ }
1455
+ case "update-node": {
1456
+ let r = t.blueprint;
1457
+ for (let t of e.nodeIds) {
1458
+ if (r === null) break;
1459
+ r = A(r, t, e.update);
1460
+ }
1461
+ n = this.commitBlueprint(r);
1462
+ break;
1463
+ }
1464
+ case "reorder-edge":
1465
+ n = this.commitBlueprint(re(t.blueprint, e.edgeId, e.direction));
1466
+ break;
1467
+ case "duplicate-nodes": {
1468
+ let r = pe(t.blueprint, e.nodeIds);
1469
+ n = this.commitBlueprint(r?.blueprint ?? null), n.ok && r !== null && (n = this.callbacks.select({
1470
+ nodes: r.nodeIds,
1471
+ edges: []
1472
+ }, !1));
1473
+ break;
1474
+ }
1475
+ case "commit-layout":
1476
+ n = this.commitBlueprint(y(t.blueprint, e.nodes, e.viewport));
1477
+ break;
1478
+ case "commit-viewport":
1479
+ n = this.commitBlueprint(oe(t.blueprint, e.viewport));
1480
+ break;
1481
+ case "history-undo":
1482
+ n = this.callbacks.undo();
1483
+ break;
1484
+ case "history-redo":
1485
+ n = this.callbacks.redo();
1486
+ break;
1487
+ case "run-simulation":
1488
+ n = this.runSimulation(e.nodeId, e.port, e.payload), n.ok && this.callbacks.onSimulated?.();
1489
+ break;
1490
+ case "clear-simulation": this.#n = null;
1491
+ }
1492
+ this.finish(e.commandId, n.ok ? "accepted" : "rejected", n.diagnostics);
1493
+ }
1494
+ runSimulation(e, t, n) {
1495
+ let r = this.callbacks.getDocument();
1496
+ if (r === void 0) return V("AUTHORING_EXPIRED", d.lifecycle.unloaded);
1497
+ let i = D(r.blueprint, e), a = i === void 0 ? void 0 : Ze(i, t, n);
1498
+ if (a === void 0) return V("AUTHORING_REQUEST_INVALID", d.blueprint.invalidCommand);
1499
+ let o = ye(r, a);
1500
+ if (!o.ok) return o;
1501
+ let { plan: s, dispatches: c } = o.value, l = [], u = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set([e]), p = new Map(this.callbacks.getGraph().nodes.map((e) => [e.id, e.title]));
1502
+ for (let { depth: e, ruleTraces: t } of c) for (let n of t) {
1503
+ if (!n.triggerMatched) continue;
1504
+ let t = s.rules.find((e) => e.id === n.ruleId);
1505
+ if (t === void 0) continue;
1506
+ f.add(t.nodeId), l.push({
1507
+ kind: e === 0 ? "trigger" : "cascade",
1508
+ nodeId: t.nodeId,
1509
+ depth: e,
1510
+ text: p.get(t.nodeId) ?? t.nodeId
1511
+ });
1512
+ let i = [...n.conditions], a = [...n.actions], o = (e, t) => {
1513
+ for (let n of e) {
1514
+ if (n.type === "condition") {
1515
+ let e = i[0];
1516
+ if (e === void 0 || e.nodeId !== n.nodeId) return;
1517
+ i.shift(), u.add(n.edgeId), f.add(n.nodeId), l.push({
1518
+ kind: "condition",
1519
+ nodeId: n.nodeId,
1520
+ edgeId: n.edgeId,
1521
+ passed: e.passed,
1522
+ depth: t,
1523
+ text: `${p.get(n.nodeId) ?? n.nodeId} · ${e.passed ? H.simulation.passed : H.simulation.failed}`
1524
+ }), o(e.passed ? n.yes : n.no, t + 1);
1525
+ continue;
1526
+ }
1527
+ let e = a[0];
1528
+ if (e === void 0 || e.edgeId !== n.edgeId) continue;
1529
+ a.shift(), u.add(n.edgeId);
1530
+ let s = r.blueprint.edges.find((e) => e.id === n.edgeId)?.to.node;
1531
+ s !== void 0 && f.add(s), l.push({
1532
+ kind: n.action.type === "request-variable" || n.action.type === "request-component-data" ? "request" : "action",
1533
+ edgeId: n.edgeId,
1534
+ ...s === void 0 ? {} : { nodeId: s },
1535
+ depth: t,
1536
+ text: Qe(n.action, r)
1537
+ });
1538
+ }
1539
+ };
1540
+ o(t.steps, e + 1);
1541
+ }
1542
+ let m = o.value.failure;
1543
+ m !== void 0 && l.push({
1544
+ kind: "error",
1545
+ depth: m.depth,
1546
+ text: m.kind === "depth-exceeded" ? H.simulation.depthExceeded : m.message
1547
+ });
1548
+ let h = m !== void 0;
1549
+ return this.#n = {
1550
+ trigger: {
1551
+ nodeId: e,
1552
+ port: t
1553
+ },
1554
+ executedEdgeIds: [...u],
1555
+ visitedNodeIds: [...f],
1556
+ steps: l,
1557
+ failed: h
1558
+ }, {
1559
+ ok: !0,
1560
+ value: null,
1561
+ diagnostics: []
1562
+ };
1563
+ }
1564
+ finish(e, t, n) {
1565
+ let r = E({
1566
+ commandId: e,
1567
+ status: t,
1568
+ diagnostics: n
1569
+ });
1570
+ this.#r = r, this.#a.set(e, r), this.#a.size > Ye && this.#a.delete(this.#a.keys().next().value), this.callbacks.render(), t === "rejected" && this.callbacks.emitDiagnostics(n);
1571
+ }
1572
+ rejectUnknown(e, t) {
1573
+ this.#r = Ke(e, t), this.callbacks.render(), this.callbacks.emitDiagnostics(t);
1574
+ }
1575
+ get capabilities() {
1576
+ return qe(this.callbacks.getRuntimeContributions);
1577
+ }
1578
+ };
1579
+ function Ze(e, t, n) {
1580
+ if (e.kind === "component") {
1581
+ if (t === "state-changed") return {
1582
+ type: "component-state-changed",
1583
+ componentId: e.componentId,
1584
+ name: "state-changed",
1585
+ payload: n
1586
+ };
1587
+ let i = r(t);
1588
+ return i === void 0 ? void 0 : {
1589
+ componentId: e.componentId,
1590
+ name: i,
1591
+ payload: n
1592
+ };
1593
+ }
1594
+ if (e.kind === "variable" && t === "data-updated") return {
1595
+ type: "variable-event",
1596
+ variableId: e.variableId,
1597
+ name: "data-updated",
1598
+ payload: n
1599
+ };
1600
+ if (e.kind === "lifecycle" && t === "ready") return {
1601
+ type: "lifecycle",
1602
+ name: "ready",
1603
+ payload: n
1604
+ };
1605
+ if (e.kind === "timer" && t === "tick") return {
1606
+ type: "timer",
1607
+ name: "tick",
1608
+ intervalSeconds: e.intervalSeconds,
1609
+ payload: n
1610
+ };
1611
+ if (e.kind === "sub-canvas" && (t === "opened" || t === "closed")) return {
1612
+ type: "canvas-event",
1613
+ canvasId: e.canvasId,
1614
+ name: t,
1615
+ payload: n
1616
+ };
1617
+ if (e.kind === "main-canvas" && t === "page-changed") return {
1618
+ type: "page-changed",
1619
+ name: "page-changed",
1620
+ payload: n
1621
+ };
1622
+ }
1623
+ function Qe(e, t) {
1624
+ let n = (e) => t.components.find((t) => t.id === e)?.name ?? e;
1625
+ switch (e.type) {
1626
+ case "component-visibility": return `${H.ports[e.operation] ?? e.operation} · ${n(e.componentId)}`;
1627
+ case "request-component-data": return H.simulation.requested(n(e.componentId));
1628
+ case "request-variable": return H.simulation.requested(e.variableId);
1629
+ case "set-variable": return d.blueprint.setVariableAction(e.variableId);
1630
+ case "emit-host-event": return d.blueprint.emitHostEventAction(e.eventName);
1631
+ case "host-action": return d.blueprint.hostAction(e.actionId);
1632
+ case "canvas-visibility": {
1633
+ let n = t.subCanvases?.find((t) => t.id === e.canvasId);
1634
+ return d.blueprint.canvasAction(H.subCanvasPorts[n?.display ?? "popup"][e.operation] ?? e.operation, n?.name ?? e.canvasId);
1635
+ }
1636
+ case "page-navigation": return H.mainCanvasPorts[e.operation] ?? e.operation;
1637
+ case "component-state": {
1638
+ let r = t.components.find((t) => t.id === e.componentId)?.states?.items.find((t) => t.id === e.stateId);
1639
+ return `${H.ports[e.operation === "set" ? "set-state" : "reset-state"] ?? e.operation} · ${n(e.componentId)}${r === void 0 ? "" : ` · ${r.name}`}`;
1640
+ }
1641
+ }
1642
+ }
1643
+ var $e = new RegExp(o);
1644
+ function et(e, t) {
1645
+ return se(e.blueprint, t).some((e) => e.node.kind === "component" || e.node.kind === "sub-canvas" && e.port === "opened" || e.node.kind === "main-canvas" && e.port === "page-changed");
1646
+ }
1647
+ function tt(e) {
1648
+ let t = e.split(".").map((e) => e.trim());
1649
+ return t.length === 0 || t.length > 8 || t.some((e) => e === "" || !$e.test(e)) ? null : t;
1650
+ }
1651
+ function nt(e) {
1652
+ return e.kind === "literal" ? "literal" : e.kind === "event-payload" ? e.path.length === 0 ? "event" : "event-field" : e.kind === "variable" ? "variable" : "advanced";
1653
+ }
1654
+ function rt(e, t, n) {
1655
+ let i = [], a = /* @__PURE__ */ new Set();
1656
+ for (let o of se(e.blueprint, t)) {
1657
+ if (o.node.kind !== "component") continue;
1658
+ if (o.port === "state-changed") {
1659
+ for (let e of [
1660
+ "from",
1661
+ "to",
1662
+ "cause"
1663
+ ]) a.has(e) || (a.add(e), i.push([e]));
1664
+ continue;
1665
+ }
1666
+ let t = o.node.componentId, s = r(o.port), c = e.components.find((e) => e.id === t), l = n?.get(c?.type ?? "")?.manifest.editorDescriptor?.events?.find((e) => e.name === s)?.payloadSchema;
1667
+ if (l !== void 0) for (let e of it(l)) {
1668
+ let t = e.join(".");
1669
+ a.has(t) || (a.add(t), i.push(e));
1670
+ }
1671
+ }
1672
+ return i;
1673
+ }
1674
+ function it(e, t = []) {
1675
+ return Object.entries(e.properties).flatMap(([e, n]) => {
1676
+ let r = [...t, e];
1677
+ return n.kind === "object" ? [r, ...it(n, r)] : [r];
1678
+ });
1679
+ }
1680
+ function at(e, t, n) {
1681
+ for (let n of e.querySelectorAll(".host-left-panel-view[data-host-left-panel-group]")) {
1682
+ let e = n.dataset.hostLeftPanelGroup === t?.id;
1683
+ n.hidden = !e, e && t !== void 0 && n.setAttribute("aria-labelledby", de(t.id));
1684
+ }
1685
+ let r = e.querySelector("[data-left-panel-count]");
1686
+ r !== null && (r.hidden = t !== void 0, t === void 0 ? (r.textContent = String(n), r.setAttribute("aria-label", d.blueprint.panelCount(d.blueprint.library, n))) : (r.textContent = "", r.removeAttribute("aria-label")));
1687
+ let i = e.querySelector("[data-left-panel-title]");
1688
+ i !== null && (i.textContent = t?.label ?? d.blueprint.library);
1689
+ let a = e.querySelector("[data-left-panel-scope]");
1690
+ a !== null && (a.textContent = t === void 0 ? d.panelScope.builtin : d.panelScope.host);
1691
+ }
1692
+ var U = d.blueprint, W = U.graph, ot = [
1693
+ "eq",
1694
+ "neq",
1695
+ "gt",
1696
+ "gte",
1697
+ "lt",
1698
+ "lte",
1699
+ "contains",
1700
+ "exists"
1701
+ ], st = [
1702
+ "appear",
1703
+ "fade",
1704
+ "slide-up"
1705
+ ], ct = [
1706
+ "related",
1707
+ "detail",
1708
+ "group",
1709
+ "drill-down"
1710
+ ];
1711
+ function lt(e, t, n, r) {
1712
+ let i = n.nodes.length + n.edges.length;
1713
+ if (e === void 0 || i === 0) return `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${h("sliders")}</span><p class="designer-empty-title">${U.inspectorEmpty}</p><p class="designer-empty-hint">${U.inspectorEmptyHint}</p></div>`;
1714
+ if (i > 1) return ut(n);
1715
+ let a = n.nodes[0];
1716
+ if (a !== void 0) {
1717
+ let n = t.nodes.find((e) => e.id === a);
1718
+ return n === void 0 ? "" : pt(e, t, n);
1719
+ }
1720
+ let o = t.edges.find((e) => e.id === n.edges[0]);
1721
+ return o === void 0 ? "" : ht(e, t, o, r);
1722
+ }
1723
+ function ut(e) {
1724
+ let t = e.nodes.length === 0 ? "" : `<button type="button" class="designer-control designer-button" data-blueprint-nodes-enabled="true">${W.enableNodes}</button><button type="button" class="designer-control designer-button" data-blueprint-nodes-enabled="false">${W.disableNodes}</button>`;
1725
+ return `<div class="blueprint-config" data-blueprint-multi>
1726
+ ${G("multi", U.selectionOverview, `<p class="blueprint-config-summary">${x(W.multiSelection(e.nodes.length, e.edges.length))}</p>
1727
+ <div class="blueprint-config-actions">${t}</div>`)}
1728
+ ${ft(W.menu.delete)}
1729
+ </div>`;
1730
+ }
1731
+ function G(e, t, n, r = "") {
1732
+ return `<details class="designer-panel-section designer-inspector-section designer-inspector-disclosure blueprint-config-section" data-inspector-search-key="blueprint-${e}" open><summary class="designer-panel-section-title designer-inspector-section-title designer-inspector-section-summary designer-panel-section-summary">${x(t)}${r === "" ? "" : `<span class="designer-inspector-section-meta">${x(r)}</span>`}<span class="designer-panel-section-disclosure designer-inspector-section-disclosure" aria-hidden="true">${h("chevron-down")}</span></summary><div class="blueprint-config-content">${n}</div></details>`;
1733
+ }
1734
+ function K(e, t, n = "row") {
1735
+ return `<div data-blueprint-field-row="${N(e)}" data-blueprint-field-variant="${n}">${t}</div>`;
1736
+ }
1737
+ function q(e, t, n = "") {
1738
+ return K(e, `<span class="blueprint-config-value">${t === "" ? "" : `<span>${x(t)}</span>`}${n === "" ? "" : `<code>${x(n)}</code>`}</span>`);
1739
+ }
1740
+ function dt(e, t, n) {
1741
+ return `<span data-blueprint-field-switch="${N(e)}" data-checked="${String(t)}" ${n}></span>`;
1742
+ }
1743
+ function ft(e) {
1744
+ return `<div class="blueprint-config-footer"><button type="button" class="designer-control designer-button blueprint-delete-button" data-variant="danger" data-blueprint-delete>${x(e)}</button></div>`;
1745
+ }
1746
+ function J(e) {
1747
+ return `<p class="blueprint-config-empty">${x(e)}</p>`;
1748
+ }
1749
+ function pt(e, t, n) {
1750
+ let r = (e, t) => e.map((e) => `<li class="blueprint-anchor" data-direction="${t}" data-connected="${String(e.connected)}" data-available="${String(e.available)}"><span class="designer-badge" data-tone="${t === "in" ? "success" : "accent"}">${t === "in" ? W.inputs : W.outputs}</span><span class="blueprint-anchor-label">${x(e.label)}</span><code>${x(e.id)}</code></li>`).join(""), i = `${r(n.outputs, "out")}${r(n.inputs, "in")}`, a = i === "" ? J(W.noEdges) : `<ul class="blueprint-anchor-list">${i}</ul>`, o = N(n.id), s = [n.renamable ? K(W.nodeName, `<input type="text" class="designer-control designer-input" data-blueprint-node-field="name" data-node-id="${o}" value="${N(n.name ?? "")}" placeholder="${N(W.nodeNamePlaceholder)}" maxlength="64">`) : "", dt(W.enabledState, n.enabled, `data-blueprint-node-field="enabled" data-node-id="${o}"`)].join(""), c = mt(e, n), l = t.edges.filter((e) => e.source === n.id || e.target === n.id), u = new Map(t.nodes.map((e) => [e.id, e.title])), d = l.length === 0 ? J(W.noEdges) : `<ul class="blueprint-config-edges">${l.map((e) => {
1751
+ let t = e.target === n.id, r = t ? e.source : e.target;
1752
+ return `<li><button type="button" class="blueprint-config-link" data-blueprint-select-edge="${N(e.id)}" data-category="${e.category}"><span class="designer-badge" data-tone="${t ? "success" : "accent"}">${t ? W.upstream : W.downstream}</span><span class="blueprint-config-link-copy"><strong>${x(u.get(r) ?? r)}</strong><small>${x(e.label)}</small></span><span class="blueprint-config-link-arrow" aria-hidden="true">${h("chevron-right")}</span></button></li>`;
1753
+ }).join("")}</ul>`;
1754
+ return `<div class="blueprint-config" data-blueprint-node-config="${o}" data-node-kind="${n.kind}">
1755
+ ${G("anchors", W.anchorInfo, a, String(n.inputs.length + n.outputs.length))}
1756
+ ${G("basic", W.basicConfig, s)}
1757
+ ${c === "" ? "" : G("node", W.nodeConfig, c)}
1758
+ ${G("edges", W.edgeList, d, String(l.length))}
1759
+ </div>`;
1760
+ }
1761
+ function mt(e, t) {
1762
+ let n = N(t.id);
1763
+ switch (t.kind) {
1764
+ case "timer": return K(U.timerInterval, `<input type="number" class="designer-control designer-input" min="1" max="86400" step="1" data-blueprint-node-field="interval" data-node-id="${n}" value="${t.intervalSeconds ?? 5}">`);
1765
+ case "condition": {
1766
+ let r = t.condition;
1767
+ return r === void 0 ? "" : [
1768
+ Y(e, "node", t.id, "left", W.conditionLeft, r.left, !0),
1769
+ K(U.conditionOperatorLabel, `<select class="designer-control designer-select" data-blueprint-node-field="operator" data-node-id="${n}">${ot.map((e) => `<option value="${e}"${e === r.operator ? " selected" : ""}>${x(U.conditionOperator(e))}</option>`).join("")}</select>`),
1770
+ r.operator === "exists" || r.right === void 0 ? "" : Y(e, "node", t.id, "right", W.conditionRight, r.right, !0)
1771
+ ].join("");
1772
+ }
1773
+ case "component": return q(W.material, "", t.materialType ?? t.subtitle);
1774
+ case "variable": {
1775
+ let n = f(e).find((e) => e.id === t.variableId);
1776
+ return [q(U.variableId, "", t.variableId ?? ""), q(W.initialValue, "", _t(JSON.stringify(n?.initialValue ?? null) ?? "null"))].join("");
1777
+ }
1778
+ default: return J(t.subtitle);
1779
+ }
1780
+ }
1781
+ function ht(e, t, n, r) {
1782
+ let i = new Map(t.nodes.map((e) => [e.id, e])), a = i.get(n.source), o = i.get(n.target), s = N(n.id), c = a?.outputs.find((e) => e.id === n.sourcePort), l = o?.inputs.find((e) => e.id === n.targetPort), u = [q(W.source, `${a?.title ?? n.source} · ${c?.label ?? n.sourcePort}`, n.sourcePort), q(W.target, n.kind === "semantic" ? o?.title ?? n.target : `${o?.title ?? n.target} · ${l?.label ?? n.targetPort}`, n.kind === "semantic" ? "" : n.targetPort)].join(""), d = [];
1783
+ if (n.kind === "semantic") d.push(K(W.role, `<select class="designer-control designer-select" data-blueprint-edge-field="role" data-edge-id="${s}">${ct.map((e) => `<option value="${e}"${e === n.role ? " selected" : ""}>${x(U.semanticRoles[e])}</option>`).join("")}</select>`), J(U.semanticHint));
1784
+ else {
1785
+ let t = o?.inputs.filter((e) => e.available) ?? [];
1786
+ o?.kind === "host" && n.targetPort.startsWith("event:") ? d.push(K(W.hostEventName, `<input type="text" class="designer-control designer-input" data-blueprint-edge-field="host-event" data-edge-id="${s}" value="${N(n.targetPort.slice(6))}" maxlength="128">`)) : t.length > 1 && d.push(K(W.targetPort, `<select class="designer-control designer-select" data-blueprint-edge-field="target-port" data-edge-id="${s}">${t.map((e) => `<option value="${N(e.id)}"${e.id === n.targetPort ? " selected" : ""}>${x(e.label)}</option>`).join("")}</select>`));
1787
+ let i = et(e, n.id);
1788
+ if (n.value !== void 0 && d.push(Y(e, "edge", n.id, "value", W.writeValue, n.value, i, r)), o?.kind === "sub-canvas" && (n.targetPort === "open" || n.targetPort === "toggle") && d.push(dt(W.popupPayload, n.payload !== void 0, `data-blueprint-edge-field="payload-enabled" data-edge-id="${s}"`)), n.payload !== void 0 && d.push(Y(e, "edge", n.id, "payload", o?.kind === "sub-canvas" ? W.popupPayloadValue : W.payload, n.payload, i, r)), o?.kind === "component" && n.targetPort === "set-state") {
1789
+ let t = e.components.find((e) => e.id === o.componentId)?.states?.items ?? [];
1790
+ d.push(K(W.targetState, `<select class="designer-control designer-select" data-blueprint-edge-field="state" data-edge-id="${s}">${t.map((e) => `<option value="${N(e.id)}"${e.id === n.stateId ? " selected" : ""}>${x(e.name)}</option>`).join("")}</select>`));
1791
+ }
1792
+ if (o?.kind === "component" && [
1793
+ "show",
1794
+ "hide",
1795
+ "toggle"
1796
+ ].includes(n.targetPort)) {
1797
+ let e = n.transition;
1798
+ d.push(K(W.transition, `<select class="designer-control designer-select" data-blueprint-edge-field="transition-effect" data-edge-id="${s}">
1799
+ <option value=""${e === void 0 ? " selected" : ""}>${W.noTransition}</option>
1800
+ ${st.map((t) => `<option value="${t}"${e?.effect === t ? " selected" : ""}>${x(W.transitionEffects[t])}</option>`).join("")}
1801
+ </select>`), e === void 0 ? "" : K(W.durationMs, `<input type="number" class="designer-control designer-input" min="0" max="10000" step="50" data-blueprint-edge-field="transition-duration" data-edge-id="${s}" value="${e.durationMs}">`));
1802
+ }
1803
+ n.order !== void 0 && (n.siblingCount ?? 1) > 1 && d.push(K(W.executionOrder, `<span class="blueprint-config-order"><span>${x(W.edgeOrder(n.order, n.siblingCount ?? 1))}</span><button type="button" class="designer-control designer-icon-button" data-blueprint-edge-order="earlier" data-edge-id="${s}" data-tip="${N(W.earlier)}" aria-label="${N(W.earlier)}"${n.order <= 1 ? " disabled" : ""}>${h("arrow-up")}</button><button type="button" class="designer-control designer-icon-button" data-blueprint-edge-order="later" data-edge-id="${s}" data-tip="${N(W.later)}" aria-label="${N(W.later)}"${n.order >= (n.siblingCount ?? 1) ? " disabled" : ""}>${h("arrow-down")}</button></span>`));
1804
+ }
1805
+ return `<div class="blueprint-config" data-blueprint-edge-config="${s}" data-category="${n.category}">
1806
+ ${G("anchors", W.anchorInfo, u)}
1807
+ ${d.length === 0 ? "" : G("edge", W.edgeConfig, d.join(""))}
1808
+ ${ft(W.menu.deleteEdge)}
1809
+ </div>`;
1810
+ }
1811
+ function Y(e, t, n, r, i, a, o, s) {
1812
+ let c = nt(a), l = `data-blueprint-expression="${r}" data-expression-owner="${t}" data-expression-owner-id="${N(n)}"`, u = [
1813
+ ["literal", U.valueSources.literal],
1814
+ ["event", U.valueSources.event],
1815
+ ["event-field", U.valueSources.eventField],
1816
+ ["variable", U.valueSources.variable],
1817
+ ...c === "advanced" ? [["advanced", U.valueSources.advanced]] : []
1818
+ ].filter(([e]) => e !== "event-field" || o || c === "event-field").map(([e, t]) => `<option value="${e}"${e === c ? " selected" : ""}${e === "advanced" ? " disabled" : ""}>${x(t)}</option>`).join(""), d = "";
1819
+ if (a.kind === "literal") d = `<input type="text" class="designer-control designer-input" data-expression-part="literal" value="${N(JSON.stringify(a.value) ?? "null")}" aria-label="${N(U.literalJson)}">`;
1820
+ else if (a.kind === "event-payload" && a.path.length > 0) {
1821
+ let i = `blueprint-fields-${t}-${n}-${r}`.replace(/[^A-Za-z0-9_-]/g, "-"), o = t === "edge" ? rt(e, n, s) : [];
1822
+ d = `<input type="text" class="designer-control designer-input" data-expression-part="field" list="${i}" value="${N(a.path.join("."))}" aria-label="${N(U.eventField)}"><datalist id="${i}">${o.map((e) => `<option value="${N(e.join("."))}"></option>`).join("")}</datalist>`;
1823
+ } else if (a.kind === "variable") {
1824
+ let t = f(e);
1825
+ d = `<select class="designer-control designer-select" data-expression-part="variable" aria-label="${N(U.sourceVariable)}">${t.map((e) => `<option value="${N(e.id)}"${e.id === a.variableId ? " selected" : ""}>${x(e.name)}</option>`).join("")}</select>`;
1826
+ } else c === "advanced" && (d = `<code class="blueprint-config-advanced">${x(_t(JSON.stringify(a) ?? ""))}</code>`);
1827
+ return `<div class="blueprint-expression" ${l}>${K(i, `<span class="blueprint-expression-stack"><select class="designer-control designer-select" data-expression-part="source" aria-label="${N(U.valueSource)}">${u}</select>${d}</span>`, "expression")}</div>`;
1828
+ }
1829
+ function gt(e) {
1830
+ if (typeof e.querySelectorAll != "function") return;
1831
+ let t = e.ownerDocument ?? e;
1832
+ for (let n of e.querySelectorAll("[data-blueprint-field-row]")) {
1833
+ let e = n.dataset.blueprintFieldRow ?? "", r = n.dataset.blueprintFieldVariant === "expression", i = n.querySelector("input, select, textarea") !== null, a = m(t, {
1834
+ label: e,
1835
+ tagName: i && !r ? "label" : "div",
1836
+ className: r ? "blueprint-config-field blueprint-expression-row" : "blueprint-config-field"
1837
+ });
1838
+ if (r) {
1839
+ let n = t.createElement("span");
1840
+ n.className = "blueprint-expression-label", n.textContent = e, a.labelText.replaceChildren(n);
1841
+ }
1842
+ a.control.append(...n.childNodes), n.replaceWith(a.field);
1843
+ }
1844
+ for (let n of e.querySelectorAll("[data-blueprint-field-switch]")) {
1845
+ let { field: e, input: r } = p(t, {
1846
+ label: n.dataset.blueprintFieldSwitch ?? "",
1847
+ checked: n.dataset.checked === "true",
1848
+ className: "blueprint-config-field"
1849
+ });
1850
+ for (let [e, t] of Object.entries(n.dataset)) e !== "blueprintFieldSwitch" && e !== "checked" && t !== void 0 && (r.dataset[e] = t);
1851
+ n.replaceWith(e);
1852
+ }
1853
+ }
1854
+ function _t(e, t = 96) {
1855
+ return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
1856
+ }
1857
+ var vt = [
1858
+ "configuration",
1859
+ "problems",
1860
+ "trace"
1861
+ ];
1862
+ function yt(e, t, n, r, i, a, o, s) {
1863
+ if (e === void 0) return;
1864
+ let c = {
1865
+ configuration: 0,
1866
+ problems: a.length,
1867
+ trace: o?.steps.length ?? 0
1868
+ }, l = Ct(t, n, r, i);
1869
+ e.innerHTML = `<div class="blueprint-inspector-shell">
1870
+ <header class="blueprint-inspector-topbar">
1871
+ <span><strong>${x(l.title)}</strong><small>${x(l.detail)}</small></span>
1872
+ <div class="blueprint-inspector-modes" role="tablist" aria-label="${d.blueprint.inspector}">
1873
+ ${vt.map((e) => wt(e, i, c[e])).join("")}
1874
+ </div>
1875
+ </header>
1876
+ <div class="blueprint-panel-scroll inspector-pane" data-blueprint-inspector-pane id="designer-blueprint-inspector-${i}-panel" role="tabpanel" aria-labelledby="designer-blueprint-inspector-${i}-tab" tabindex="0" aria-live="polite">
1877
+ ${bt(i, t, n, r, a, o, s)}
1878
+ </div>
1879
+ </div>`, gt(e);
1880
+ }
1881
+ function bt(e, t, n, r, i, a, o) {
1882
+ return e === "problems" ? xt(i) : e === "trace" ? St(a) : lt(t, n, r, o);
1883
+ }
1884
+ function xt(e) {
1885
+ let t = e.slice(0, 8);
1886
+ return t.length === 0 ? `<div class="designer-empty" data-tone="success"><span class="designer-empty-icon" aria-hidden="true">${h("check")}</span><p class="designer-empty-title">${d.blueprint.problemsHealthy}</p><p class="designer-empty-hint">${d.blueprint.problemsHealthyHint}</p></div>` : `<section class="blueprint-inspector-status" data-blueprint-problems><ul>${t.map((e) => `<li data-severity="${e.severity}"><strong>${x(e.code)}</strong><span>${x(e.message)}</span><small>${x(e.path.join(".") || "—")}</small></li>`).join("")}</ul></section>`;
1887
+ }
1888
+ function St(e) {
1889
+ if (e === null) return `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${h("terminal")}</span><p class="designer-empty-title">${d.blueprint.noTrace}</p><p class="designer-empty-hint">${d.blueprint.noTraceHint}</p></div>`;
1890
+ let t = e.steps.filter((e) => e.kind === "condition" && e.passed === !1).length;
1891
+ return `<section class="blueprint-inspector-status" data-blueprint-trace data-failed="${String(e.failed)}">
1892
+ <div class="blueprint-trace-summary">${d.blueprint.traceSummary(e.executedEdgeIds.length, t)}</div>
1893
+ <ol class="blueprint-trace-steps">${e.steps.slice(0, 200).map((e) => `<li data-kind="${e.kind}"${e.passed === void 0 ? "" : ` data-passed="${String(e.passed)}"`} style="--bp-trace-depth: ${Math.min(e.depth, 12)}">${e.nodeId === void 0 ? x(e.text) : `<button type="button" class="blueprint-trace-step" data-blueprint-select-node="${x(e.nodeId)}">${x(e.text)}</button>`}</li>`).join("")}</ol>
1894
+ <button type="button" class="designer-button" data-blueprint-clear-trace>${d.blueprint.graph.simulation.clear}</button>
1895
+ </section>`;
1896
+ }
1897
+ function Ct(e, t, n, r) {
1898
+ let i = d.blueprint;
1899
+ if (r === "problems") return {
1900
+ title: i.problemsTitle,
1901
+ detail: i.inspector
1902
+ };
1903
+ if (r === "trace") return {
1904
+ title: i.traceTitle,
1905
+ detail: i.inspector
1906
+ };
1907
+ let a = n.nodes.length + n.edges.length;
1908
+ if (a === 0) return {
1909
+ title: i.inspector,
1910
+ detail: i.inspectorEmpty
1911
+ };
1912
+ if (a > 1) return {
1913
+ title: i.selectionOverview,
1914
+ detail: i.graph.multiSelection(n.nodes.length, n.edges.length)
1915
+ };
1916
+ let o = t.nodes.find((e) => e.id === n.nodes[0]);
1917
+ if (o !== void 0) return {
1918
+ title: o.title,
1919
+ detail: `${o.id} | ${i.graph.nodeKinds[o.kind]}`
1920
+ };
1921
+ let s = t.edges.find((e) => e.id === n.edges[0]);
1922
+ return {
1923
+ title: s?.label ?? i.selectionType.edge,
1924
+ detail: s === void 0 ? i.selectionType.edge : `${s.id} | ${i.graph.edgeCategories[s.category]}`
1925
+ };
1926
+ }
1927
+ function wt(e, t, n) {
1928
+ let r = d.blueprint.inspectorTabs[e];
1929
+ return `<button type="button" class="blueprint-inspector-mode" id="designer-blueprint-inspector-${e}-tab" role="tab" aria-controls="designer-blueprint-inspector-${e}-panel" aria-selected="${String(e === t)}" tabindex="${e === t ? 0 : -1}" data-blueprint-inspector-tab="${e}" data-tip="${r}" aria-label="${r}"><span aria-hidden="true">${h(e === "configuration" ? "sliders" : e === "problems" ? "check" : "terminal")}</span>${n === 0 ? "" : `<em data-tone="${e === "problems" ? "danger" : "neutral"}">${n}</em>`}</button>`;
1930
+ }
1931
+ var Tt = [
1932
+ "components",
1933
+ "relations",
1934
+ "variables"
1935
+ ], Et = [
1936
+ "lifecycle",
1937
+ "timer",
1938
+ "condition",
1939
+ "host"
1940
+ ], X = d.blueprint;
1941
+ function Dt(e, t) {
1942
+ if (e === void 0) return;
1943
+ let n = (t.groups ?? []).filter((e) => M(e, "blueprint")), r = O(t.activeTab), i = n.some((e) => e.id === r) ? r : void 0, a = Ft(t.activeTab) ? t.activeTab : "components", o = i === void 0 ? a : j(i), s = a === "relations" ? X.relationList.search : X.librarySearch;
1944
+ e.innerHTML = `<div class="blueprint-library-shell">
1945
+ <nav class="rail-tabs blueprint-library-rail" role="tablist" aria-orientation="vertical" aria-label="${X.library}">
1946
+ ${Tt.map((e) => Nt(e, o)).join("")}
1947
+ ${n.map((e) => Pt(e, i)).join("")}
1948
+ </nav>
1949
+ <section class="rail-view blueprint-library-main"${i === void 0 ? "" : " hidden"}>
1950
+ <div class="layer-panel-controls blueprint-library-controls">
1951
+ <label class="designer-field layer-search blueprint-library-search">
1952
+ <span class="layer-search-glyph" aria-hidden="true">${h("search")}</span>
1953
+ <input type="search" class="designer-control designer-input" data-blueprint-library-search value="${N(t.query)}" placeholder="${s}" aria-label="${s}">
1954
+ </label>
1955
+ </div>
1956
+ <div class="blueprint-panel-scroll" id="designer-blueprint-library-${a}-panel" role="tabpanel" aria-labelledby="designer-blueprint-library-${a}-tab" tabindex="0">
1957
+ ${Ot(a, t)}
1958
+ </div>
1959
+ </section>
1960
+ </div>`;
1961
+ }
1962
+ function Ot(e, t) {
1963
+ let n = t.query.trim().toLocaleLowerCase();
1964
+ return e === "components" ? kt(t.components, t.selection, n, X.layers, X.noComponentNodes) : e === "variables" ? kt(t.variables, t.selection, n, X.globalVariables, X.noVariables) : jt(t, n);
1965
+ }
1966
+ function kt(e, t, n, r, i) {
1967
+ let a = e.filter((e) => n.length === 0 || `${e.name} ${e.entityId} ${e.subtitle}`.toLocaleLowerCase().includes(n));
1968
+ return a.length === 0 ? Z(i) : `<section class="blueprint-palette-group" aria-label="${N(r)}">
1969
+ <header><strong>${x(r)}</strong><span>${a.length}</span></header>
1970
+ <div class="blueprint-palette-list">
1971
+ ${a.map((e) => At(e, t)).join("")}
1972
+ </div>
1973
+ <p class="blueprint-library-hint">${X.componentNodeHint}</p>
1974
+ </section>`;
1975
+ }
1976
+ function At(e, t) {
1977
+ let n = e.nodeId !== void 0, r = n && t.nodes.includes(e.nodeId ?? ""), i = e.kind === "component", a = n ? `data-blueprint-select-node="${N(e.nodeId ?? "")}"` : i ? `data-blueprint-add-component="${N(e.entityId)}"` : `data-blueprint-add-variable="${N(e.entityId)}"`, o = n ? i ? X.locateComponent(e.name) : X.locateVariable(e.name) : i ? X.addComponent(e.name) : X.addVariableNode(e.name), s = n ? "" : ` draggable="true" data-blueprint-drag-kind="${e.kind}" data-${i ? "component" : "variable"}-id="${N(e.entityId)}" data-blueprint-drag-label="${N(e.name)}"`, c = i ? "layers" : "variable", l = i ? X.componentEventCount(e.eventCount) : e.subtitle;
1978
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-depth="${e.depth}" style="--bp-indent: ${e.depth * 16}px" data-placed="${String(n)}" data-selected="${String(r)}" data-node-kind="${e.kind}"${s}>
1979
+ <button type="button" class="blueprint-palette-primary" ${a} aria-label="${N(o)}" data-tip="${N(o)}">
1980
+ <span class="blueprint-palette-glyph" aria-hidden="true">${h(c)}</span>
1981
+ <span class="blueprint-palette-copy"><strong>${x(e.name)}</strong><small>${x(l)}</small></span>
1982
+ <span class="blueprint-palette-state" aria-hidden="true">${h(n ? "check" : "plus")}</span>
1983
+ </button>
1984
+ </div>`;
1985
+ }
1986
+ function jt(e, t) {
1987
+ let n = X.graph, r = new Set(e.graph.nodes.filter((e) => e.kind === "host" || e.kind === "lifecycle").map((e) => e.kind)), i = Et.filter((e) => t.length === 0 || `${n.nodeKinds[e]} ${n.nodeKindHints[e]} ${e}`.toLocaleLowerCase().includes(t)), a = i.map((t) => {
1988
+ let i = t === "host" || t === "lifecycle" ? e.graph.nodes.find((e) => e.kind === t) : void 0, a = r.has(t), o = i === void 0 ? `data-blueprint-insert-node="${t}"` : `data-blueprint-select-node="${N(i.id)}"`, s = X.addLogicNode(n.nodeKinds[t]), c = t === "timer" ? "activity" : t === "condition" ? "sliders" : t === "host" ? "terminal" : "play";
1989
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-placed="${String(a)}" data-node-kind="${t}"${a ? "" : ` draggable="true" data-blueprint-drag-kind="${t}" data-blueprint-drag-label="${N(n.nodeKinds[t])}"`}>
1990
+ <button type="button" class="blueprint-palette-primary" ${o} aria-label="${N(s)}" data-tip="${N(s)}">
1991
+ <span class="blueprint-palette-glyph" aria-hidden="true">${h(c)}</span>
1992
+ <span class="blueprint-palette-copy"><strong>${x(n.nodeKinds[t])}</strong><small>${x(n.nodeKindHints[t])}</small></span>
1993
+ <span class="blueprint-palette-state" aria-hidden="true">${h(a ? "check" : "plus")}</span>
1994
+ </button>
1995
+ </div>`;
1996
+ }).join(""), o = new Map(e.graph.nodes.map((e) => [e.id, e.title])), s = e.graph.edges.filter((e) => t.length === 0 || `${o.get(e.source) ?? ""} ${o.get(e.target) ?? ""} ${e.label} ${e.sourcePort} ${e.targetPort}`.toLocaleLowerCase().includes(t)), c = s.map((t) => {
1997
+ let r = e.selection.edges.includes(t.id), i = `${o.get(t.source) ?? t.source} → ${o.get(t.target) ?? t.target}`;
1998
+ return `<div class="designer-list-row blueprint-relation-item" data-density="default" data-selected="${String(r)}" data-category="${t.category}" data-active="${String(t.active)}">
1999
+ <button type="button" class="blueprint-palette-primary" data-blueprint-select-edge="${N(t.id)}" aria-label="${N(i)}">
2000
+ <span class="blueprint-relation-swatch" aria-hidden="true"></span>
2001
+ <span class="blueprint-palette-copy"><strong>${x(i)}</strong><small>${x(`${n.edgeCategories[t.category]} · ${t.label}`)}</small></span>
2002
+ </button>
2003
+ </div>`;
2004
+ }).join("");
2005
+ return `<section class="blueprint-palette-group" aria-label="${X.logic}">
2006
+ <header><strong>${X.logic}</strong><span>${i.length}</span></header>
2007
+ <div class="blueprint-palette-list">${a || Z(X.noLogicNodes)}</div>
2008
+ <p class="blueprint-library-hint">${X.directNodeHint}</p>
2009
+ </section>
2010
+ ${Mt(e, t)}
2011
+ <section class="blueprint-palette-group" aria-label="${X.graph.edgeList}">
2012
+ <header><strong>${X.graph.edgeList}</strong><span>${s.length}</span></header>
2013
+ <div class="blueprint-palette-list">${c || Z(n.noEdges)}</div>
2014
+ </section>`;
2015
+ }
2016
+ function Mt(e, t) {
2017
+ let n = e.document?.subCanvases ?? [], r = [...n.some((e) => e.display === "page") ? [{
2018
+ id: "",
2019
+ name: X.graph.nodeKinds["main-canvas"],
2020
+ detail: X.mainCanvasEntry,
2021
+ icon: "grid",
2022
+ kind: "main-canvas"
2023
+ }] : [], ...n.map((e) => ({
2024
+ id: e.id,
2025
+ name: e.name,
2026
+ detail: e.display === "page" ? X.pageSize : `${X.graph.subCanvasKinds.popup} · ${X.popupSize(e.width, e.height)}`,
2027
+ icon: e.display === "page" ? "doc" : "copy",
2028
+ kind: "sub-canvas"
2029
+ }))].filter((e) => t.length === 0 || `${e.name} ${e.id}`.toLocaleLowerCase().includes(t)), i = r.map((t) => {
2030
+ let n = e.graph.nodes.find((e) => t.kind === "main-canvas" ? e.kind === "main-canvas" : e.kind === "sub-canvas" && e.canvasId === t.id), r = n !== void 0, i = r && e.selection.nodes.includes(n.id), a = r ? `data-blueprint-select-node="${N(n.id)}"` : `data-blueprint-add-canvas="${N(t.id)}"`, o = r ? X.locateCanvas(t.name) : X.addCanvasNode(t.name), s = r ? "" : ` draggable="true" data-blueprint-drag-kind="${t.kind}"${t.kind === "sub-canvas" ? ` data-canvas-id="${N(t.id)}"` : ""} data-blueprint-drag-label="${N(t.name)}"`;
2031
+ return `<div class="designer-list-row blueprint-palette-item" data-density="default" data-placed="${String(r)}" data-selected="${String(i)}" data-node-kind="${t.kind}"${s}>
2032
+ <button type="button" class="blueprint-palette-primary" ${a} aria-label="${N(o)}" data-tip="${N(o)}">
2033
+ <span class="blueprint-palette-glyph" aria-hidden="true">${h(t.icon)}</span>
2034
+ <span class="blueprint-palette-copy"><strong>${x(t.name)}</strong><small>${x(t.detail)}</small></span>
2035
+ <span class="blueprint-palette-state" aria-hidden="true">${h(r ? "check" : "plus")}</span>
2036
+ </button>
2037
+ </div>`;
2038
+ }).join("");
2039
+ return `<section class="blueprint-palette-group" aria-label="${X.canvases}">
2040
+ <header><strong>${X.canvases}</strong><span>${r.length}</span></header>
2041
+ <div class="blueprint-palette-list">${i || Z(X.noSubCanvases)}</div>
2042
+ </section>`;
2043
+ }
2044
+ function Nt(e, t) {
2045
+ let n = X.libraryTabs[e], r = e === "components" ? X.layers : e === "relations" ? X.logic : X.globalVariables;
2046
+ return `<button type="button" class="designer-tab blueprint-library-rail-tab" id="designer-blueprint-library-${e}-tab" role="tab" aria-controls="designer-blueprint-library-${e}-panel" aria-selected="${String(e === t)}" tabindex="${e === t ? 0 : -1}" data-blueprint-library-tab="${e}" data-tip="${r}" aria-label="${r}"><span class="rail-tab-glyph" aria-hidden="true">${h(e === "components" ? "layers" : e === "relations" ? "link" : "variable")}</span><span class="rail-tab-label">${n}</span></button>`;
2047
+ }
2048
+ function Pt(e, t) {
2049
+ let n = e.id === t, r = j(e.id), i = N(e.label);
2050
+ return `<button type="button" class="designer-tab blueprint-library-rail-tab" id="${de(e.id)}" role="tab" aria-controls="${fe(e.id)}" aria-selected="${String(n)}" tabindex="${n ? 0 : -1}" data-blueprint-library-tab="${r}" data-host-left-panel-group="${N(e.id)}" data-host-left-panel-mode="blueprint" data-tip="${i}" aria-label="${i}"><span class="rail-tab-glyph" aria-hidden="true">${h(e.icon ?? "shapes")}</span><span class="rail-tab-label">${x(e.label)}</span></button>`;
2051
+ }
2052
+ function Ft(e) {
2053
+ return e === "components" || e === "relations" || e === "variables";
2054
+ }
2055
+ function Z(e) {
2056
+ return `<div class="designer-empty"><span class="designer-empty-icon" aria-hidden="true">${h("search")}</span><p class="designer-empty-title">${e}</p></div>`;
2057
+ }
2058
+ function It(e, t) {
2059
+ if (e === void 0) return !1;
2060
+ if (Ft(e)) return !0;
2061
+ let n = O(e);
2062
+ return n !== void 0 && t?.some((e) => e.id === n && M(e, "blueprint")) === !0;
2063
+ }
2064
+ function Lt(e) {
2065
+ return e === "configuration" || e === "problems" || e === "trace";
2066
+ }
2067
+ var Rt = /* @__PURE__ */ new Set([
2068
+ "eq",
2069
+ "neq",
2070
+ "gt",
2071
+ "gte",
2072
+ "lt",
2073
+ "lte",
2074
+ "contains",
2075
+ "exists"
2076
+ ]), zt = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/, Bt = class {
2077
+ callbacks;
2078
+ #e;
2079
+ #t;
2080
+ #n = "";
2081
+ #r = "components";
2082
+ #i = "configuration";
2083
+ constructor(e) {
2084
+ this.callbacks = e;
2085
+ }
2086
+ connect(e) {
2087
+ this.#e = e.querySelector("[data-blueprint-library]") ?? void 0, this.#t = e.querySelector("[data-blueprint-inspector]") ?? void 0;
2088
+ }
2089
+ release() {
2090
+ this.#e = void 0, this.#t = void 0;
2091
+ }
2092
+ reset() {
2093
+ this.#n = "", this.#r = "components", this.#i = "configuration";
2094
+ }
2095
+ showTrace() {
2096
+ this.#i = "trace";
2097
+ }
2098
+ get selectedLeftPanelGroupId() {
2099
+ return O(this.#r);
2100
+ }
2101
+ selectLeftPanelGroup(e) {
2102
+ let t = this.blueprintHostGroup(e);
2103
+ return t !== void 0 && (this.#r = j(t.id), this.callbacks.expandLeftPanel(), this.render(), !0);
2104
+ }
2105
+ refreshLeftPanelGroups() {
2106
+ this.reconcileLibraryTab();
2107
+ }
2108
+ render() {
2109
+ let e = this.hasLibraryTabFocus();
2110
+ this.reconcileLibraryTab();
2111
+ let t = this.callbacks.getDocument(), n = this.callbacks.getGraph(), r = this.callbacks.getSelection(), i = t === void 0 ? [] : Ce(t, this.callbacks.getCatalog(), this.callbacks.getRuntimeContributions());
2112
+ Dt(this.#e, {
2113
+ document: t,
2114
+ graph: n,
2115
+ components: i,
2116
+ variables: t === void 0 ? [] : we(t, d.blueprint),
2117
+ selection: r,
2118
+ query: this.#n,
2119
+ activeTab: this.#r,
2120
+ groups: this.callbacks.getLeftPanelGroups()
2121
+ }), yt(this.#t, t, n, r, this.#i, this.callbacks.getDiagnostics(), this.callbacks.getTrace(), this.callbacks.getCatalog()), this.#e !== void 0 && b(this.#e), this.#t !== void 0 && b(this.#t), this.callbacks.getMode() === "blueprint" && this.#e !== void 0 && (at(this.#e.getRootNode(), this.blueprintHostGroup(this.selectedLeftPanelGroupId), n.nodes.length), this.callbacks.onActiveLeftPanelGroupChange()), e && this.#e?.querySelector(`[data-blueprint-library-tab="${this.#r}"]`)?.focus();
2122
+ }
2123
+ onClick(e) {
2124
+ let t = e.closest("[data-blueprint-library-tab]")?.dataset.blueprintLibraryTab;
2125
+ if (It(t, this.callbacks.getLeftPanelGroups())) return this.#r = t, this.callbacks.expandLeftPanel(), this.render(), this.#e?.querySelector(`[data-blueprint-library-tab="${t}"]`)?.focus(), !0;
2126
+ let n = e.closest("[data-blueprint-inspector-tab]")?.dataset.blueprintInspectorTab;
2127
+ if (Lt(n)) return this.#i = n, this.render(), this.#t?.querySelector(`[data-blueprint-inspector-tab="${n}"]`)?.focus(), !0;
2128
+ let r = e.closest("[data-blueprint-select-node], [data-blueprint-select-edge], [data-blueprint-add-component], [data-blueprint-add-variable], [data-blueprint-add-canvas], [data-blueprint-insert-node], [data-blueprint-delete], [data-blueprint-nodes-enabled], [data-blueprint-edge-order], [data-blueprint-clear-trace]");
2129
+ if (r === null) return !1;
2130
+ let i = r.dataset;
2131
+ if (i.blueprintSelectNode !== void 0) return this.callbacks.select({
2132
+ nodes: [i.blueprintSelectNode],
2133
+ edges: []
2134
+ }, !0), !0;
2135
+ if (i.blueprintSelectEdge !== void 0) return this.callbacks.select({
2136
+ nodes: [],
2137
+ edges: [i.blueprintSelectEdge]
2138
+ }, !0), !0;
2139
+ if (i.blueprintAddComponent !== void 0) return this.insert({
2140
+ kind: "component",
2141
+ componentId: i.blueprintAddComponent
2142
+ }), !0;
2143
+ if (i.blueprintAddVariable !== void 0) return this.insert({
2144
+ kind: "variable",
2145
+ variableId: i.blueprintAddVariable
2146
+ }), !0;
2147
+ if (i.blueprintAddCanvas !== void 0) return this.insert(i.blueprintAddCanvas === "" ? { kind: "main-canvas" } : {
2148
+ kind: "sub-canvas",
2149
+ canvasId: i.blueprintAddCanvas
2150
+ }), !0;
2151
+ let a = i.blueprintInsertNode;
2152
+ if (a === "host" || a === "lifecycle" || a === "timer" || a === "condition") return this.insert({ kind: a }), !0;
2153
+ if (i.blueprintClearTrace !== void 0) return this.callbacks.clearTrace(), !0;
2154
+ let o = this.callbacks.getDocument();
2155
+ if (o === void 0) return !0;
2156
+ if (i.blueprintDelete !== void 0) {
2157
+ let e = this.callbacks.commitBlueprint(w(o.blueprint, this.callbacks.getSelection()));
2158
+ return e.ok && this.callbacks.select(_, !1), this.report(e), !0;
2159
+ }
2160
+ if (i.blueprintNodesEnabled !== void 0) return this.report(this.callbacks.commitBlueprint(ee(o.blueprint, new Set(this.callbacks.getSelection().nodes), i.blueprintNodesEnabled === "true"))), !0;
2161
+ let s = i.blueprintEdgeOrder;
2162
+ return (s === "earlier" || s === "later") && i.edgeId !== void 0 && this.report(this.callbacks.commitBlueprint(re(o.blueprint, i.edgeId, s))), !0;
2163
+ }
2164
+ onDragStart(e) {
2165
+ let t = (e.target instanceof Element ? e.target : null)?.closest("[data-blueprint-drag-kind]"), n = e.dataTransfer;
2166
+ if (t == null || n === null) return !1;
2167
+ let r = t.dataset.blueprintDragKind, i;
2168
+ return r === "component" && t.dataset.componentId !== void 0 ? i = {
2169
+ kind: r,
2170
+ componentId: t.dataset.componentId
2171
+ } : r === "variable" && t.dataset.variableId !== void 0 ? i = {
2172
+ kind: r,
2173
+ variableId: t.dataset.variableId
2174
+ } : r === "sub-canvas" && t.dataset.canvasId !== void 0 ? i = {
2175
+ kind: r,
2176
+ canvasId: t.dataset.canvasId
2177
+ } : (r === "main-canvas" || r === "host" || r === "lifecycle" || r === "timer" || r === "condition") && (i = { kind: r }), i !== void 0 && (n.effectAllowed = "copy", n.setData("application/x-base-screen-blueprint-node", JSON.stringify(i)), n.setData("text/plain", t.dataset.blueprintDragLabel ?? i.kind), !0);
2178
+ }
2179
+ onKeyDown(e) {
2180
+ let t = e.target?.closest("[data-blueprint-library-tab], [data-blueprint-inspector-tab]");
2181
+ if (t == null || ![
2182
+ "ArrowLeft",
2183
+ "ArrowRight",
2184
+ "ArrowUp",
2185
+ "ArrowDown",
2186
+ "Home",
2187
+ "End"
2188
+ ].includes(e.key)) return !1;
2189
+ e.preventDefault();
2190
+ let n = t.dataset.blueprintLibraryTab === void 0 ? "[data-blueprint-inspector-tab]" : "[data-blueprint-library-tab]", r = [...(t.dataset.blueprintLibraryTab === void 0 ? this.#t : this.#e)?.querySelectorAll(n) ?? []];
2191
+ if (r.length === 0) return !0;
2192
+ let i = r.indexOf(t);
2193
+ return (e.key === "Home" ? r[0] : e.key === "End" ? r.at(-1) : r[(i + (e.key === "ArrowRight" || e.key === "ArrowDown" ? 1 : -1) + r.length) % r.length])?.click(), !0;
2194
+ }
2195
+ onInput(e) {
2196
+ let t = e.closest("[data-blueprint-library-search]");
2197
+ if (t === null) return !1;
2198
+ this.#n = t.value, this.render();
2199
+ let n = this.#e?.querySelector("[data-blueprint-library-search]");
2200
+ return n?.focus(), n?.setSelectionRange(n.value.length, n.value.length), !0;
2201
+ }
2202
+ onChange(e) {
2203
+ let t = this.callbacks.getDocument(), n = e, r = e.closest("[data-blueprint-expression]");
2204
+ if (r !== null) return t !== void 0 && this.changeExpression(t, r, n), !0;
2205
+ let i = n.dataset.blueprintNodeField, a = n.dataset.nodeId;
2206
+ if (i !== void 0 && a !== void 0) {
2207
+ let e = n instanceof HTMLInputElement && n.type === "checkbox" ? String(n.checked) : n.value;
2208
+ return t !== void 0 && this.changeNode(t, a, i, e), !0;
2209
+ }
2210
+ let o = n.dataset.blueprintEdgeField, s = n.dataset.edgeId;
2211
+ if (o !== void 0 && s !== void 0) {
2212
+ let e = n instanceof HTMLInputElement && n.type === "checkbox" ? String(n.checked) : n.value;
2213
+ return t !== void 0 && this.changeEdge(t, s, o, e), !0;
2214
+ }
2215
+ return !1;
2216
+ }
2217
+ insert(e) {
2218
+ let t = this.callbacks.getDocument();
2219
+ if (t === void 0) return;
2220
+ let n = T(t, e);
2221
+ if (n === null) {
2222
+ this.report({
2223
+ ok: !1,
2224
+ diagnostics: [{
2225
+ severity: "error",
2226
+ code: "AUTHORING_REQUEST_INVALID",
2227
+ path: [],
2228
+ message: d.blueprint.invalidCommand
2229
+ }]
2230
+ });
2231
+ return;
2232
+ }
2233
+ let r = n.created ? this.callbacks.commitBlueprint(n.blueprint) : {
2234
+ ok: !0,
2235
+ value: t,
2236
+ diagnostics: []
2237
+ };
2238
+ r.ok && this.callbacks.select({
2239
+ nodes: [n.nodeId],
2240
+ edges: []
2241
+ }, !0), this.report(r);
2242
+ }
2243
+ changeNode(e, t, n, r) {
2244
+ let i = D(e.blueprint, t);
2245
+ if (i === void 0) return;
2246
+ let a = null;
2247
+ if (n === "name") a = A(e.blueprint, t, {
2248
+ type: "name",
2249
+ name: r
2250
+ });
2251
+ else if (n === "enabled") a = A(e.blueprint, t, {
2252
+ type: "enabled",
2253
+ enabled: r === "true"
2254
+ });
2255
+ else if (n === "interval") a = A(e.blueprint, t, {
2256
+ type: "interval",
2257
+ intervalSeconds: Number(r)
2258
+ });
2259
+ else if (n === "operator" && i.kind === "condition" && Rt.has(r)) {
2260
+ let n = r, o = n === "exists" ? {
2261
+ left: i.condition.left,
2262
+ operator: n
2263
+ } : {
2264
+ left: i.condition.left,
2265
+ operator: n,
2266
+ right: i.condition.right ?? {
2267
+ kind: "literal",
2268
+ value: null
2269
+ }
2270
+ };
2271
+ a = A(e.blueprint, t, {
2272
+ type: "condition",
2273
+ condition: o
2274
+ });
2275
+ }
2276
+ this.commitOrRestore(a);
2277
+ }
2278
+ changeEdge(e, t, n, r) {
2279
+ let i = he(e.blueprint, t);
2280
+ if (i === void 0) return;
2281
+ let a = null;
2282
+ if (n === "role" && (r === "related" || r === "detail" || r === "group" || r === "drill-down")) a = k(e.blueprint, t, {
2283
+ type: "role",
2284
+ role: r
2285
+ });
2286
+ else if (n === "target-port") {
2287
+ let n = e.blueprint.nodes.find((e) => e.id === i.to.node), o = n?.kind === "component" ? e.components.find((e) => e.id === n.componentId)?.states?.items[0]?.id : void 0;
2288
+ a = k(e.blueprint, t, {
2289
+ type: "target-port",
2290
+ port: r,
2291
+ ...o === void 0 ? {} : { stateId: o }
2292
+ });
2293
+ } else if (n === "state" && i.kind === "flow") a = k(e.blueprint, t, {
2294
+ type: "state",
2295
+ stateId: r
2296
+ });
2297
+ else if (n === "host-event" && zt.test(r.trim())) a = k(e.blueprint, t, {
2298
+ type: "target-port",
2299
+ port: `event:${r.trim()}`
2300
+ });
2301
+ else if (n === "payload-enabled" && i.kind === "flow") a = k(e.blueprint, t, {
2302
+ type: "payload",
2303
+ payload: r === "true" ? {
2304
+ kind: "event-payload",
2305
+ path: []
2306
+ } : null
2307
+ });
2308
+ else if (n === "transition-effect" && i.kind === "flow") a = k(e.blueprint, t, {
2309
+ type: "transition",
2310
+ transition: r === "appear" || r === "fade" || r === "slide-up" ? {
2311
+ effect: r,
2312
+ durationMs: i.transition?.durationMs ?? 200,
2313
+ easing: i.transition?.easing ?? "ease-in-out-quad"
2314
+ } : null
2315
+ });
2316
+ else if (n === "transition-duration" && i.kind === "flow" && i.transition !== void 0) {
2317
+ let n = Number(r);
2318
+ Number.isInteger(n) && n >= 0 && n <= 1e4 && (a = k(e.blueprint, t, {
2319
+ type: "transition",
2320
+ transition: {
2321
+ ...i.transition,
2322
+ durationMs: n
2323
+ }
2324
+ }));
2325
+ }
2326
+ this.commitOrRestore(a);
2327
+ }
2328
+ changeExpression(t, n, r) {
2329
+ let i = n.dataset.blueprintExpression, a = n.dataset.expressionOwner, o = n.dataset.expressionOwnerId;
2330
+ if (i === void 0 || o === void 0) return;
2331
+ let s = r.dataset.expressionPart, c;
2332
+ if (s === "source") {
2333
+ let e = r.value;
2334
+ if (e === "literal") c = {
2335
+ kind: "literal",
2336
+ value: null
2337
+ };
2338
+ else if (e === "event") c = {
2339
+ kind: "event-payload",
2340
+ path: []
2341
+ };
2342
+ else if (e === "event-field") c = {
2343
+ kind: "event-payload",
2344
+ path: (a === "edge" ? rt(t, o, this.callbacks.getCatalog()) : [])[0] ?? ["value"]
2345
+ };
2346
+ else if (e === "variable") {
2347
+ let e = f(t)[0];
2348
+ e !== void 0 && (c = {
2349
+ kind: "variable",
2350
+ variableId: e.id
2351
+ });
2352
+ }
2353
+ } else if (s === "literal") try {
2354
+ let t = e(JSON.parse(r.value));
2355
+ t.ok && (c = {
2356
+ kind: "literal",
2357
+ value: t.value
2358
+ });
2359
+ } catch {
2360
+ c = void 0;
2361
+ }
2362
+ else if (s === "field") {
2363
+ let e = tt(r.value);
2364
+ e !== null && (c = {
2365
+ kind: "event-payload",
2366
+ path: e
2367
+ });
2368
+ } else s === "variable" && (c = {
2369
+ kind: "variable",
2370
+ variableId: r.value
2371
+ });
2372
+ if (c === void 0) {
2373
+ this.report({
2374
+ ok: !1,
2375
+ diagnostics: [{
2376
+ severity: "error",
2377
+ code: "AUTHORING_REQUEST_INVALID",
2378
+ path: [],
2379
+ message: s === "field" ? d.blueprint.eventFieldInvalid : d.blueprint.graph.simulation.invalidPayload
2380
+ }]
2381
+ }), this.render();
2382
+ return;
2383
+ }
2384
+ let l = null;
2385
+ if (a === "edge" && (i === "value" || i === "payload")) l = k(t.blueprint, o, i === "value" ? {
2386
+ type: "value",
2387
+ value: c
2388
+ } : {
2389
+ type: "payload",
2390
+ payload: c
2391
+ });
2392
+ else if (a === "node" && (i === "left" || i === "right")) {
2393
+ let e = D(t.blueprint, o);
2394
+ e?.kind === "condition" && (l = A(t.blueprint, o, {
2395
+ type: "condition",
2396
+ condition: {
2397
+ ...e.condition,
2398
+ [i]: c
2399
+ }
2400
+ }));
2401
+ }
2402
+ this.commitOrRestore(l);
2403
+ }
2404
+ commitOrRestore(e) {
2405
+ if (e === null) {
2406
+ this.render();
2407
+ return;
2408
+ }
2409
+ let t = this.callbacks.commitBlueprint(e);
2410
+ t.ok || this.render(), this.report(t);
2411
+ }
2412
+ report(e) {
2413
+ e.ok || this.callbacks.emitDiagnostics(e.diagnostics);
2414
+ }
2415
+ reconcileLibraryTab() {
2416
+ let e = this.selectedLeftPanelGroupId;
2417
+ e !== void 0 && this.blueprintHostGroup(e) === void 0 && (this.#r = "components");
2418
+ }
2419
+ hasLibraryTabFocus() {
2420
+ return (this.#e?.getRootNode())?.activeElement?.closest("[data-blueprint-library-tab]") != null;
2421
+ }
2422
+ blueprintHostGroup(e) {
2423
+ if (e !== void 0) return this.callbacks.getLeftPanelGroups()?.find((t) => t.id === e && M(t, "blueprint"));
2424
+ }
2425
+ }, Vt = Object.freeze({
2426
+ nodes: Object.freeze([]),
2427
+ edges: Object.freeze([])
2428
+ }), Ht = class {
2429
+ callbacks;
2430
+ #e;
2431
+ #t;
2432
+ #n;
2433
+ #r;
2434
+ #i = "canvas";
2435
+ #a = _;
2436
+ #o = !0;
2437
+ #s;
2438
+ #c = 0;
2439
+ #l;
2440
+ #u;
2441
+ #d;
2442
+ #f = () => this.resolveCanvas();
2443
+ constructor(e) {
2444
+ this.callbacks = e, this.#u = new Xe({
2445
+ getDocument: e.getDocument,
2446
+ getGraph: () => this.graph,
2447
+ getMode: () => this.#i,
2448
+ getSelection: () => this.#a,
2449
+ getShowSemantic: () => this.#o,
2450
+ getViewRequest: () => this.#s,
2451
+ getCatalog: e.getCatalog,
2452
+ getRuntimeContributions: e.getRuntimeContributions,
2453
+ getDocumentRevision: e.getDocumentRevision,
2454
+ getProjectRevision: e.getProjectRevision,
2455
+ canUndo: e.canUndo,
2456
+ canRedo: e.canRedo,
2457
+ select: (e, t) => this.select(e, t),
2458
+ executeCommand: e.executeCommand,
2459
+ undo: e.undo,
2460
+ redo: e.redo,
2461
+ render: () => this.render(),
2462
+ emitDiagnostics: e.emitDiagnostics,
2463
+ onSimulated: () => this.#d.showTrace()
2464
+ }), this.#d = new Bt({
2465
+ getDocument: e.getDocument,
2466
+ getGraph: () => this.graph,
2467
+ getCatalog: e.getCatalog,
2468
+ getRuntimeContributions: e.getRuntimeContributions,
2469
+ getSelection: () => this.#a,
2470
+ getShowSemantic: () => this.#o,
2471
+ setShowSemantic: (e) => {
2472
+ this.#o = e, this.render();
2473
+ },
2474
+ requestView: (e) => {
2475
+ this.#s = {
2476
+ id: ++this.#c,
2477
+ type: e
2478
+ }, this.render();
2479
+ },
2480
+ simulate: (e, t, n) => this.#u.simulate(e, t, n),
2481
+ clearTrace: () => {
2482
+ this.#u.clearTrace(), this.render();
2483
+ },
2484
+ getDiagnostics: () => this.#u.stateDiagnostics(),
2485
+ getTrace: () => this.#u.trace,
2486
+ getLeftPanelGroups: e.getLeftPanelGroups,
2487
+ getMode: () => this.#i,
2488
+ select: (t, n) => {
2489
+ let r = this.select(t, n);
2490
+ r.ok || e.emitDiagnostics(r.diagnostics);
2491
+ },
2492
+ commitBlueprint: (e) => this.#u.commitBlueprint(e),
2493
+ expandLeftPanel: e.expandLeftPanel,
2494
+ onActiveLeftPanelGroupChange: e.onActiveLeftPanelGroupChange,
2495
+ emitDiagnostics: e.emitDiagnostics
2496
+ });
2497
+ }
2498
+ get mode() {
2499
+ return this.#i;
2500
+ }
2501
+ get available() {
2502
+ return this.#u.canvas !== void 0;
2503
+ }
2504
+ get selectedLeftPanelGroupId() {
2505
+ return this.#d.selectedLeftPanelGroupId;
2506
+ }
2507
+ setInitialMode(e) {
2508
+ this.#i = e;
2509
+ }
2510
+ connect(e) {
2511
+ if (this.#e === e) {
2512
+ this.bindSlot(e.querySelector("[data-blueprint-canvas-slot]") ?? void 0), this.#n = e.querySelector("[data-blueprint-default-canvas]") ?? void 0, this.mountDefaultCanvas(), this.#d.connect(e), this.resolveCanvas(), this.render();
2513
+ return;
2514
+ }
2515
+ this.disconnect(), this.#e = e, this.bindSlot(e.querySelector("[data-blueprint-canvas-slot]") ?? void 0), this.#n = e.querySelector("[data-blueprint-default-canvas]") ?? void 0, this.mountDefaultCanvas(), this.#d.connect(e), this.#u.connect(this.callbacks.getHost()), this.resolveCanvas(), this.render();
2516
+ }
2517
+ bindSlot(e) {
2518
+ this.#t !== e && (this.#t?.removeEventListener("slotchange", this.#f), this.#t = e, this.#t?.addEventListener("slotchange", this.#f));
2519
+ }
2520
+ disconnect() {
2521
+ this.#t?.removeEventListener("slotchange", this.#f), this.#u.disconnect(), this.#d.release(), this.#r?.destroy(), this.#r?.element.remove(), this.#r = void 0, this.#n = void 0, this.#e = void 0, this.#t = void 0;
2522
+ }
2523
+ addVariableNode(e) {
2524
+ let t = this.callbacks.getDocument();
2525
+ if (t === void 0) return;
2526
+ let n = T(t, {
2527
+ kind: "variable",
2528
+ variableId: e
2529
+ });
2530
+ if (n?.created === !0) {
2531
+ let e = this.callbacks.executeCommand({
2532
+ type: "replace-blueprint",
2533
+ blueprint: n.blueprint
2534
+ });
2535
+ if (!e.ok) {
2536
+ this.callbacks.emitDiagnostics(e.diagnostics);
2537
+ return;
2538
+ }
2539
+ }
2540
+ this.setMode("blueprint", { focus: {
2541
+ kind: "variable",
2542
+ id: e
2543
+ } });
2544
+ }
2545
+ resetSession() {
2546
+ this.#a = _, this.#o = !0, this.#s = void 0, this.#d.reset(), this.#u.reset(), this.render();
2547
+ }
2548
+ selectLeftPanelGroup(e) {
2549
+ return this.#i === "blueprint" && this.#d.selectLeftPanelGroup(e);
2550
+ }
2551
+ refreshLeftPanelGroups() {
2552
+ this.#d.refreshLeftPanelGroups(), this.render();
2553
+ }
2554
+ setMode(e, t = {}, n = "api") {
2555
+ let r = v(e, t);
2556
+ if (!r.ok) return r;
2557
+ if (e === "blueprint" && !this.available) return $("BLUEPRINT_CAPABILITY_UNAVAILABLE", d.blueprint.noHostCanvas);
2558
+ if (t.focus !== void 0) {
2559
+ let e = this.ensureFocusNode(t.focus);
2560
+ if (!e.ok) return e;
2561
+ let n = this.resolveFocus(t.focus);
2562
+ if (n === void 0) return $("AUTHORING_REQUEST_INVALID", d.blueprint.invalidSelection);
2563
+ this.#a = this.graphHasEdge(n) ? {
2564
+ nodes: [],
2565
+ edges: [n]
2566
+ } : {
2567
+ nodes: [n],
2568
+ edges: []
2569
+ }, this.#s = {
2570
+ id: ++this.#c,
2571
+ type: "focus",
2572
+ targetId: n
2573
+ };
2574
+ }
2575
+ let i = this.#i;
2576
+ return this.#i = e, this.render(), i !== e && this.emitModeChange(i, e, n), Q(null);
2577
+ }
2578
+ render() {
2579
+ let e = this.graph;
2580
+ this.reconcileSelection(e), this.renderChrome(), this.callbacks.setWorkbenchAuthoringMode(this.#i), this.#d.render(), this.#u.dispatchState(e), this.callbacks.onActiveLeftPanelGroupChange();
2581
+ }
2582
+ dispatchState() {
2583
+ this.#u.dispatchState();
2584
+ }
2585
+ onClick(e) {
2586
+ let t = e.closest("[data-workbench-mode-tab]");
2587
+ if (t !== null) {
2588
+ let e = t.dataset.workbenchModeTab;
2589
+ if (e === "canvas" || e === "blueprint") {
2590
+ let t = this.setMode(e, {}, "user");
2591
+ t.ok || this.callbacks.emitDiagnostics(t.diagnostics);
2592
+ }
2593
+ return !0;
2594
+ }
2595
+ let n = e.closest("[data-blueprint-search-id]")?.dataset.blueprintSearchId;
2596
+ if (n !== void 0) {
2597
+ let e = Wt(n), t = e === void 0 ? $("AUTHORING_REQUEST_INVALID", d.blueprint.invalidSelection) : this.focusOrInsert(e);
2598
+ return t.ok || this.callbacks.emitDiagnostics(t.diagnostics), !0;
2599
+ }
2600
+ return this.#d.onClick(e);
2601
+ }
2602
+ onInput(e) {
2603
+ return this.#d.onInput(e);
2604
+ }
2605
+ onChange(e) {
2606
+ return this.#d.onChange(e);
2607
+ }
2608
+ onDragStart(e) {
2609
+ return this.#d.onDragStart(e);
2610
+ }
2611
+ onKeyDown(e) {
2612
+ if (this.#d.onKeyDown(e)) return !0;
2613
+ let t = e.target?.closest("[data-workbench-mode-tab]");
2614
+ if (t == null || ![
2615
+ "ArrowLeft",
2616
+ "ArrowRight",
2617
+ "Home",
2618
+ "End"
2619
+ ].includes(e.key)) return !1;
2620
+ e.preventDefault();
2621
+ let n = [...this.#e?.querySelectorAll("[data-workbench-mode-tab]:not(:disabled)") ?? []];
2622
+ if (n.length === 0) return !0;
2623
+ let r = n.indexOf(t), i = e.key === "Home" ? n[0] : e.key === "End" ? n.at(-1) : n[(r + (e.key === "ArrowRight" ? 1 : -1) + n.length) % n.length];
2624
+ return i?.focus(), i?.click(), !0;
2625
+ }
2626
+ get graph() {
2627
+ let e = this.callbacks.getDocument();
2628
+ if (e === void 0) return Vt;
2629
+ let t = this.callbacks.getCatalog(), n = this.callbacks.getRuntimeContributions(), r = this.#l;
2630
+ if (r !== void 0 && r.document === e && r.catalog === t && r.contributions === n) return r.graph;
2631
+ let i = Te(e, t, n, d.blueprint);
2632
+ return this.#l = {
2633
+ document: e,
2634
+ catalog: t,
2635
+ contributions: n,
2636
+ graph: i
2637
+ }, i;
2638
+ }
2639
+ focusOrInsert(e) {
2640
+ return this.setMode("blueprint", { focus: e }, "user");
2641
+ }
2642
+ ensureFocusNode(e) {
2643
+ let t = this.callbacks.getDocument();
2644
+ if (t !== void 0 && (e.kind === "component" || e.kind === "variable")) {
2645
+ let n = T(t, e.kind === "component" ? {
2646
+ kind: "component",
2647
+ componentId: e.id
2648
+ } : {
2649
+ kind: "variable",
2650
+ variableId: e.id
2651
+ });
2652
+ if (n?.created === !0) {
2653
+ let e = this.callbacks.executeCommand({
2654
+ type: "replace-blueprint",
2655
+ blueprint: n.blueprint
2656
+ });
2657
+ if (!e.ok) return {
2658
+ ok: !1,
2659
+ diagnostics: e.diagnostics
2660
+ };
2661
+ }
2662
+ }
2663
+ return Q(null);
2664
+ }
2665
+ mountDefaultCanvas() {
2666
+ if (this.#r !== void 0 || this.#n === void 0) return;
2667
+ let e = Le(this.#n.ownerDocument);
2668
+ this.#n.append(e.element), this.#r = e;
2669
+ }
2670
+ resolveCanvas() {
2671
+ let e = this.#t?.assignedElements({ flatten: !0 })[0], t = this.#r?.element;
2672
+ t !== void 0 && (t.hidden = e !== void 0), this.#n !== void 0 && (this.#n.hidden = e !== void 0);
2673
+ let n = e ?? t, r = this.#u.canvas;
2674
+ if (!this.#u.setCanvas(n)) {
2675
+ n === void 0 && this.#i === "blueprint" ? this.fallbackToCanvas(!1) : (this.renderChrome(), this.#u.dispatchState());
2676
+ return;
2677
+ }
2678
+ if (n === void 0 && this.#i === "blueprint") {
2679
+ this.fallbackToCanvas(r !== void 0);
2680
+ return;
2681
+ }
2682
+ this.render();
2683
+ }
2684
+ fallbackToCanvas(e) {
2685
+ let t = this.#i;
2686
+ this.#i = "canvas", this.render(), this.emitModeChange(t, "canvas", "fallback"), e && this.callbacks.emitDiagnostics([Ut("BLUEPRINT_CAPABILITY_UNAVAILABLE", d.blueprint.noHostCanvas)]);
2687
+ }
2688
+ select(e, t) {
2689
+ let n = this.graph, r = new Set(n.nodes.map((e) => e.id)), i = new Set(n.edges.map((e) => e.id));
2690
+ if (e.nodes.some((e) => !r.has(e)) || e.edges.some((e) => !i.has(e))) return $("AUTHORING_REQUEST_INVALID", d.blueprint.invalidSelection);
2691
+ this.#a = {
2692
+ nodes: [...e.nodes],
2693
+ edges: [...e.edges]
2694
+ };
2695
+ let a = e.nodes[0] ?? e.edges[0];
2696
+ return t && a !== void 0 && (this.#s = {
2697
+ id: ++this.#c,
2698
+ type: "focus",
2699
+ targetId: a
2700
+ }), this.render(), Q(null);
2701
+ }
2702
+ reconcileSelection(e) {
2703
+ let t = new Set(e.nodes.map((e) => e.id)), n = new Set(e.edges.map((e) => e.id)), r = this.#a.nodes.filter((e) => t.has(e)), i = this.#a.edges.filter((e) => n.has(e));
2704
+ (r.length !== this.#a.nodes.length || i.length !== this.#a.edges.length) && (this.#a = {
2705
+ nodes: r,
2706
+ edges: i
2707
+ });
2708
+ }
2709
+ resolveFocus(e) {
2710
+ let t = this.callbacks.getDocument();
2711
+ if (t !== void 0) return e.kind === "component" ? g(t.blueprint, e.id)?.id : e.kind === "variable" ? C(t.blueprint, e.id)?.id : e.kind === "node" ? t.blueprint.nodes.some((t) => t.id === e.id) ? e.id : void 0 : this.graphHasEdge(e.id) ? e.id : void 0;
2712
+ }
2713
+ graphHasEdge(e) {
2714
+ return this.graph.edges.some((t) => t.id === e);
2715
+ }
2716
+ renderChrome() {
2717
+ let e = this.#e;
2718
+ if (e === void 0) return;
2719
+ let t = this.callbacks.getDocument(), n = this.#u.stateDiagnostics().filter((e) => e.severity === "error").length, r = t?.blueprint.edges ?? [];
2720
+ He(e, this.#i, this.available, {
2721
+ nodes: t?.blueprint.nodes.length ?? 0,
2722
+ relations: r.filter((e) => e.kind === "flow").length,
2723
+ semantic: r.filter((e) => e.kind === "semantic").length,
2724
+ structural: 0,
2725
+ problems: n
2726
+ });
2727
+ }
2728
+ emitModeChange(e, t, n) {
2729
+ this.callbacks.getHost().dispatchEvent(new CustomEvent(ge, {
2730
+ bubbles: !0,
2731
+ composed: !0,
2732
+ detail: {
2733
+ previousMode: e,
2734
+ mode: t,
2735
+ reason: n
2736
+ }
2737
+ }));
2738
+ }
2739
+ };
2740
+ function Ut(e, t) {
2741
+ return {
2742
+ severity: "error",
2743
+ code: e,
2744
+ path: [],
2745
+ message: t
2746
+ };
2747
+ }
2748
+ function Q(e) {
2749
+ return {
2750
+ ok: !0,
2751
+ value: e,
2752
+ diagnostics: []
2753
+ };
2754
+ }
2755
+ function $(e, t) {
2756
+ return {
2757
+ ok: !1,
2758
+ diagnostics: [Ut(e, t)]
2759
+ };
2760
+ }
2761
+ function Wt(e) {
2762
+ let t = e.indexOf(":");
2763
+ if (t <= 0) return;
2764
+ let n = e.slice(0, t), r = e.slice(t + 1);
2765
+ if (r !== "") return n === "component" || n === "variable" || n === "node" || n === "edge" ? {
2766
+ kind: n,
2767
+ id: r
2768
+ } : void 0;
2769
+ }
2770
+ //#endregion
2771
+ export { Ht as DesignerBlueprintWorkbenchPanel };
2772
+
2773
+ //# sourceMappingURL=designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map