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