base-screen 0.3.0 → 0.4.2

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 (424) hide show
  1. package/README.md +5 -2
  2. package/dist/_internal/contracts/diagnostics/material-error.d.ts +1 -1
  3. package/dist/_internal/contracts/diagnostics/material-error.js +1 -1
  4. package/dist/_internal/contracts/document/blueprint-graph.d.ts +3 -3
  5. package/dist/_internal/contracts/document/blueprint-graph.js +4 -4
  6. package/dist/_internal/contracts/document/component-states.d.ts +1 -1
  7. package/dist/_internal/contracts/document/component-states.js +1 -1
  8. package/dist/_internal/contracts/document/image-url.js +1 -1
  9. package/dist/_internal/contracts/document/json-schema.js +1 -1
  10. package/dist/_internal/contracts/document/limits.d.ts +5 -5
  11. package/dist/_internal/contracts/document/limits.js +5 -5
  12. package/dist/_internal/contracts/document/references.js +3 -3
  13. package/dist/_internal/contracts/document/schema.d.ts +9 -2
  14. package/dist/_internal/contracts/document/schema.js +4 -4
  15. package/dist/_internal/contracts/document/sub-canvas.d.ts +2 -2
  16. package/dist/_internal/contracts/document/sub-canvas.js +2 -2
  17. package/dist/_internal/contracts/document/theme.d.ts +2 -2
  18. package/dist/_internal/contracts/document/theme.js +2 -2
  19. package/dist/_internal/contracts/document/validate-blueprint.d.ts +1 -1
  20. package/dist/_internal/contracts/document/validate-blueprint.js +1 -1
  21. package/dist/_internal/contracts/document/validate-component.js +2 -2
  22. package/dist/_internal/contracts/document/validate-data-source.js +2 -2
  23. package/dist/_internal/contracts/document/validate-sub-canvas.d.ts +1 -1
  24. package/dist/_internal/contracts/document/validate-sub-canvas.js +1 -1
  25. package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
  26. package/dist/_internal/contracts/index.d.ts +1 -1
  27. package/dist/_internal/contracts/migration/blueprint-graph-migration.d.ts +1 -1
  28. package/dist/_internal/contracts/migration/migrate-document.js +2 -2
  29. package/dist/_internal/contracts/push/delivery.d.ts +1 -1
  30. package/dist/_internal/contracts/push/delivery.js +1 -1
  31. package/dist/_internal/contracts/push/level-scale.d.ts +1 -1
  32. package/dist/_internal/contracts/push/level-scale.js +1 -1
  33. package/dist/_internal/contracts/screen-document.schema.json +15 -3
  34. package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
  35. package/dist/_internal/contracts/types/document.d.ts +21 -19
  36. package/dist/_internal/contracts/types/execution.d.ts +3 -3
  37. package/dist/_internal/contracts/types/host.d.ts +23 -5
  38. package/dist/_internal/contracts/types/host.js +1 -1
  39. package/dist/_internal/contracts/types/push.d.ts +3 -3
  40. package/dist/_internal/contracts/types/variable.d.ts +3 -3
  41. package/dist/_internal/contracts/variable/parse.js +5 -1
  42. package/dist/_internal/core/blueprint/runtime-compile.d.ts +1 -1
  43. package/dist/_internal/core/blueprint/runtime-compile.js +1 -1
  44. package/dist/_internal/core/blueprint/runtime-dispatch.js +1 -1
  45. package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
  46. package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
  47. package/dist/_internal/core/blueprint/runtime-types.d.ts +4 -4
  48. package/dist/_internal/core/blueprint/runtime.d.ts +1 -0
  49. package/dist/_internal/core/blueprint/runtime.js +1 -0
  50. package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
  51. package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
  52. package/dist/_internal/core/commands/apply-component-commands.d.ts +1 -1
  53. package/dist/_internal/core/commands/apply-component-commands.js +2 -2
  54. package/dist/_internal/core/commands/apply.js +15 -2
  55. package/dist/_internal/core/commands/parse-command.js +12 -0
  56. package/dist/_internal/core/commands/types.d.ts +33 -5
  57. package/dist/_internal/core/data/data-candidates.d.ts +38 -0
  58. package/dist/_internal/core/data/data-candidates.js +186 -0
  59. package/dist/_internal/core/data/data-source-dependents.d.ts +1 -1
  60. package/dist/_internal/core/data/data-source-dependents.js +1 -1
  61. package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
  62. package/dist/_internal/core/data/dataset-profile.js +170 -0
  63. package/dist/_internal/core/data/host-dataset.d.ts +2 -2
  64. package/dist/_internal/core/data/host-dataset.js +2 -2
  65. package/dist/_internal/core/data/sample-values.d.ts +25 -0
  66. package/dist/_internal/core/data/sample-values.js +45 -0
  67. package/dist/_internal/core/data/value-ref.d.ts +2 -2
  68. package/dist/_internal/core/data/value-ref.js +1 -1
  69. package/dist/_internal/core/diff/screen-diff.js +6 -0
  70. package/dist/_internal/core/index.d.ts +7 -1
  71. package/dist/_internal/core/index.js +7 -1
  72. package/dist/_internal/core/state/state-preset.d.ts +32 -0
  73. package/dist/_internal/core/state/state-preset.js +37 -0
  74. package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
  75. package/dist/_internal/core/validation/layout-audit.js +228 -0
  76. package/dist/_internal/core/validation/legibility.d.ts +9 -0
  77. package/dist/_internal/core/validation/legibility.js +33 -0
  78. package/dist/_internal/core/validation/validate-semantics.js +1 -1
  79. package/dist/_internal/engine/browser/controllers/blueprint/designer-blueprint-canvas-bridge.d.ts +1 -1
  80. package/dist/_internal/engine/browser/controllers/dataset/designer-data-source-authoring.d.ts +1 -1
  81. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-catalog-controller.d.ts +21 -0
  82. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-controller-context.d.ts +7 -2
  83. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +7 -2
  84. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-effective-value.d.ts +1 -1
  85. package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-surface-controller.d.ts +1 -1
  86. package/dist/_internal/engine/browser/controllers/dataset/designer-update-policy-authoring.d.ts +1 -1
  87. package/dist/_internal/engine/browser/controllers/designer-artboard-controller.d.ts +1 -1
  88. package/dist/_internal/engine/browser/controllers/designer-canvas-runtime-controller.d.ts +2 -2
  89. package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +27 -0
  90. package/dist/_internal/engine/browser/controllers/designer-command-palette-controller.d.ts +1 -1
  91. package/dist/_internal/engine/browser/controllers/designer-intent-controller.d.ts +5 -0
  92. package/dist/_internal/engine/browser/controllers/designer-page-preview-controller.d.ts +1 -1
  93. package/dist/_internal/engine/browser/controllers/designer-popup-preview-controller.d.ts +1 -1
  94. package/dist/_internal/engine/browser/controllers/designer-reference-layer-controller.d.ts +1 -1
  95. package/dist/_internal/engine/browser/controllers/designer-text-edit-controller.d.ts +2 -2
  96. package/dist/_internal/engine/browser/controllers/designer-viewport-controller.d.ts +7 -1
  97. package/dist/_internal/engine/browser/controllers/gesture/designer-drag-gesture.d.ts +6 -1
  98. package/dist/_internal/engine/browser/controllers/gesture/designer-gesture-callbacks.d.ts +1 -1
  99. package/dist/_internal/engine/browser/controllers/panel/designer-component-states-controller.d.ts +1 -1
  100. package/dist/_internal/engine/browser/controllers/panel/designer-panel-controller-callbacks.d.ts +6 -6
  101. package/dist/_internal/engine/browser/controllers/panel/designer-panel-property-controller.d.ts +7 -0
  102. package/dist/_internal/engine/browser/controllers/variables/designer-variable-catalog-controller.d.ts +9 -1
  103. package/dist/_internal/engine/browser/controllers/variables/designer-variable-editor-controller.d.ts +6 -1
  104. package/dist/_internal/engine/browser/controllers/variables/designer-variables-controller.d.ts +16 -1
  105. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-controller.d.ts +2 -0
  106. package/dist/_internal/engine/browser/controllers/workbench/designer-workbench-tabs-controller.d.ts +2 -0
  107. package/dist/_internal/engine/browser/dom/blueprint/designer-blueprint-inspector-configuration.d.ts +1 -1
  108. package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +21 -5
  109. package/dist/_internal/engine/browser/dom/color/designer-color-palette-model.d.ts +3 -3
  110. package/dist/_internal/engine/browser/dom/color/designer-color-palette-types.d.ts +2 -2
  111. package/dist/_internal/engine/browser/dom/color/designer-color-theme-slots.d.ts +1 -1
  112. package/dist/_internal/engine/browser/dom/dataset/designer-data-group-dom.d.ts +1 -1
  113. package/dist/_internal/engine/browser/dom/dataset/designer-data-panel-notice.d.ts +1 -1
  114. package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
  115. package/dist/_internal/engine/browser/dom/dataset/designer-data-state.d.ts +1 -1
  116. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-authoring-dom.d.ts +1 -1
  117. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-catalog-dom.d.ts +1 -1
  118. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-sections.d.ts +1 -1
  119. package/dist/_internal/engine/browser/dom/dataset/designer-dataset-types.d.ts +11 -4
  120. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-control-dom.d.ts +1 -1
  121. package/dist/_internal/engine/browser/dom/descriptor/designer-descriptor-model.d.ts +1 -1
  122. package/dist/_internal/engine/browser/dom/designer-field-primitives.d.ts +1 -1
  123. package/dist/_internal/engine/browser/dom/designer-icons.d.ts +2 -0
  124. package/dist/_internal/engine/browser/dom/designer-text-edit-dom.d.ts +2 -2
  125. package/dist/_internal/engine/browser/dom/designer-variable-inspector-dom.d.ts +7 -0
  126. package/dist/_internal/engine/browser/dom/designer-variables-dom.d.ts +5 -1
  127. package/dist/_internal/engine/browser/dom/designer-variables-editor-dom.d.ts +30 -1
  128. package/dist/_internal/engine/browser/dom/designer-variables-toolbar-dom.d.ts +4 -2
  129. package/dist/_internal/engine/browser/dom/intent/designer-intent-reference-picker-dom.d.ts +2 -0
  130. package/dist/_internal/engine/browser/dom/material-library/designer-material-library-dom.d.ts +1 -1
  131. package/dist/_internal/engine/browser/dom/menu/designer-menu-model.d.ts +3 -3
  132. package/dist/_internal/engine/browser/dom/menu/designer-plugin-command-menu.d.ts +5 -2
  133. package/dist/_internal/engine/browser/dom/panel/designer-canvas-transactions.d.ts +1 -1
  134. package/dist/_internal/engine/browser/dom/panel/designer-component-states-dom.d.ts +2 -2
  135. package/dist/_internal/engine/browser/dom/panel/designer-multi-selection-dom.d.ts +1 -1
  136. package/dist/_internal/engine/browser/dom/panel/designer-panel-primitives.d.ts +2 -2
  137. package/dist/_internal/engine/browser/dom/panel/designer-property-transactions.d.ts +1 -1
  138. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-picker-dom.d.ts +1 -1
  139. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-picker-mount.d.ts +1 -1
  140. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-summary-dom.d.ts +1 -1
  141. package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +6 -4
  142. package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +3 -3
  143. package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +5 -3
  144. package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +2 -14
  145. package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +2 -0
  146. package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
  147. package/dist/_internal/engine/common/observability/designer-metrics.d.ts +1 -1
  148. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-capabilities.d.ts +1 -1
  149. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-graph.d.ts +5 -5
  150. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-model.d.ts +1 -1
  151. package/dist/_internal/engine/common/operations/blueprint/designer-blueprint-protocol-types.d.ts +2 -2
  152. package/dist/_internal/engine/common/operations/canvas/canvas-background-image.d.ts +1 -1
  153. package/dist/_internal/engine/common/operations/catalog/designer-catalog-refresh.d.ts +1 -1
  154. package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
  155. package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
  156. package/dist/_internal/engine/common/operations/designer-clipboard.d.ts +5 -1
  157. package/dist/_internal/engine/common/operations/designer-text-edit-operations.d.ts +1 -1
  158. package/dist/_internal/engine/common/operations/designer-variable-operations.d.ts +3 -3
  159. package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
  160. package/dist/_internal/engine/common/operations/element/designer-element-operation-types.d.ts +1 -1
  161. package/dist/_internal/engine/common/operations/intent/designer-parameter-intent.d.ts +1 -1
  162. package/dist/_internal/engine/common/operations/material-component/material-component-fragment-extract.d.ts +2 -2
  163. package/dist/_internal/engine/common/operations/material-library/material-library-fragments.d.ts +1 -1
  164. package/dist/_internal/engine/common/operations/material-library/material-library-grouping.d.ts +1 -1
  165. package/dist/_internal/engine/common/operations/plugin/designer-plugin-commands.d.ts +2 -0
  166. package/dist/_internal/engine/common/operations/selection/designer-multi-selection-operations.d.ts +9 -9
  167. package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +12 -7
  168. package/dist/_internal/engine/common/operations/style/designer-material-appearance.d.ts +1 -1
  169. package/dist/_internal/engine/common/session/designer-artboard.d.ts +1 -1
  170. package/dist/_internal/engine/common/session/designer-session.d.ts +1 -1
  171. package/dist/_internal/engine/common/ui-text/designer-blueprint-ui-text.d.ts +3 -3
  172. package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +127 -70
  173. package/dist/_internal/engine/{designer-blueprint-workbench-panel-CJ3iZo5v.js → designer-blueprint-workbench-panel-DVvKcSvJ.js} +269 -349
  174. package/dist/_internal/engine/{designer-dataset-controller-CrfOg2Ys.js → designer-dataset-controller-bSR5OB6n.js} +1512 -1348
  175. package/dist/_internal/engine/designer-element/api/designer-element-catalog.d.ts +2 -2
  176. package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
  177. package/dist/_internal/engine/designer-element/api/designer-element-configuration-types.d.ts +4 -4
  178. package/dist/_internal/engine/designer-element/api/designer-element-fragment-save.d.ts +2 -2
  179. package/dist/_internal/engine/designer-element/api/designer-element-host-resource-selection.d.ts +1 -1
  180. package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +21 -9
  181. package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +2 -1
  182. package/dist/_internal/engine/designer-element/runtime/designer-element-plugin-commands.d.ts +3 -3
  183. package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +3 -3
  184. package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +4 -1
  185. package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
  186. package/dist/_internal/engine/designer-element/runtime/designer-element-state.d.ts +7 -7
  187. package/dist/_internal/engine/{designer-field-primitives-KBZuWN_D.js → designer-field-primitives-C_StzrUa.js} +240 -180
  188. package/dist/_internal/engine/{designer-left-panel-groups-dom-N2OHOWjl.js → designer-left-panel-groups-dom-DBpI3Nc2.js} +19 -19
  189. package/dist/_internal/engine/{host-resource-selection-xo2mLCD4.js → host-resource-selection-BCRU23WQ.js} +446 -446
  190. package/dist/_internal/engine/index.js +5477 -4677
  191. package/dist/_internal/host-kit/index.d.ts +1 -0
  192. package/dist/_internal/host-kit/index.js +1 -0
  193. package/dist/_internal/host-kit/intent/index.d.ts +17 -0
  194. package/dist/_internal/host-kit/intent/index.js +14 -0
  195. package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
  196. package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
  197. package/dist/_internal/host-kit/intent/intent-block.d.ts +66 -0
  198. package/dist/_internal/host-kit/intent/intent-block.js +438 -0
  199. package/dist/_internal/host-kit/intent/intent-catalog.d.ts +108 -0
  200. package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
  201. package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
  202. package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
  203. package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
  204. package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
  205. package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
  206. package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
  207. package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
  208. package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
  209. package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
  210. package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
  211. package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
  212. package/dist/_internal/host-kit/intent/intent-format.js +94 -0
  213. package/dist/_internal/host-kit/intent/intent-freeform.d.ts +48 -0
  214. package/dist/_internal/host-kit/intent/intent-freeform.js +412 -0
  215. package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
  216. package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
  217. package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
  218. package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
  219. package/dist/_internal/host-kit/intent/intent-parse.d.ts +41 -0
  220. package/dist/_internal/host-kit/intent/intent-parse.js +931 -0
  221. package/dist/_internal/host-kit/intent/intent-prepare.d.ts +55 -0
  222. package/dist/_internal/host-kit/intent/intent-prepare.js +156 -0
  223. package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
  224. package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
  225. package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
  226. package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
  227. package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
  228. package/dist/_internal/host-kit/intent/intent-style.js +77 -0
  229. package/dist/_internal/host-kit/intent/intent-types.d.ts +277 -0
  230. package/dist/_internal/host-kit/intent/intent-types.js +10 -0
  231. package/dist/_internal/host-kit/push-result.d.ts +1 -1
  232. package/dist/_internal/host-kit/push-result.js +1 -1
  233. package/dist/_internal/host-kit/sse-subscribe.d.ts +1 -1
  234. package/dist/_internal/host-kit/sse-subscribe.js +1 -1
  235. package/dist/_internal/host-kit/subscription-hub.d.ts +3 -3
  236. package/dist/_internal/host-kit/subscription-hub.js +1 -1
  237. package/dist/_internal/material/base-material.d.ts +3 -3
  238. package/dist/_internal/material/chart.js +34 -12
  239. package/dist/_internal/material/editor-descriptor.d.ts +3 -3
  240. package/dist/_internal/material/table.js +52 -21
  241. package/dist/_internal/plugin-core/contracts.d.ts +18 -16
  242. package/dist/_internal/plugin-core/contracts.js +1 -0
  243. package/dist/_internal/plugin-core/contribution-kind.d.ts +5 -5
  244. package/dist/_internal/plugin-core/contribution-kind.js +14 -6
  245. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.d.ts +1 -1
  246. package/dist/_internal/plugin-core/editor/editor-descriptor-inference.js +2 -2
  247. package/dist/_internal/plugin-core/editor/editor-descriptor-items.d.ts +1 -1
  248. package/dist/_internal/plugin-core/editor/editor-descriptor-items.js +1 -1
  249. package/dist/_internal/plugin-core/editor/editor-descriptor-model.d.ts +2 -2
  250. package/dist/_internal/plugin-core/editor/editor-descriptor.js +1 -1
  251. package/dist/_internal/plugin-core/fragment/fragment.d.ts +4 -4
  252. package/dist/_internal/plugin-core/fragment/fragment.js +1 -1
  253. package/dist/_internal/plugin-core/material/material-manifest-fields.js +1 -1
  254. package/dist/_internal/plugin-core/material/material-manifest.js +1 -1
  255. package/dist/_internal/plugin-core/material/material-theme.d.ts +2 -2
  256. package/dist/_internal/plugin-core/material/material-theme.js +2 -2
  257. package/dist/_internal/plugin-manager/contribution-kind-plan.d.ts +5 -1
  258. package/dist/_internal/plugin-manager/contribution-kind-plan.js +20 -12
  259. package/dist/_internal/plugin-manager/manager.js +47 -30
  260. package/dist/_internal/plugin-manager/resolver.js +7 -13
  261. package/dist/_internal/plugin-manager/types.d.ts +2 -2
  262. package/dist/_internal/plugin-sdk/authoring-finding.d.ts +3 -3
  263. package/dist/_internal/plugin-sdk/fragment-audit.d.ts +6 -6
  264. package/dist/_internal/plugin-sdk/fragment-audit.js +8 -8
  265. package/dist/_internal/plugin-sdk/fragment-definition.d.ts +3 -3
  266. package/dist/_internal/plugin-sdk/fragment-definition.js +3 -3
  267. package/dist/_internal/plugin-sdk/index.d.ts +6 -0
  268. package/dist/_internal/plugin-sdk/index.js +6 -0
  269. package/dist/_internal/plugin-sdk/material-config-groups.d.ts +2 -2
  270. package/dist/_internal/plugin-sdk/material-definition.d.ts +5 -1
  271. package/dist/_internal/plugin-sdk/material-definition.js +3 -3
  272. package/dist/_internal/plugin-sdk/material-editor-audit.d.ts +9 -8
  273. package/dist/_internal/plugin-sdk/material-editor-audit.js +19 -11
  274. package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
  275. package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
  276. package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
  277. package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
  278. package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
  279. package/dist/_internal/plugin-sdk/material-isolated.js +1044 -0
  280. package/dist/_internal/plugin-sdk/material-package.d.ts +3 -3
  281. package/dist/_internal/plugin-sdk/material-package.js +7 -7
  282. package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +22 -7
  283. package/dist/_internal/plugin-sdk/material-rendered-element.js +103 -10
  284. package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +20 -10
  285. package/dist/_internal/plugin-sdk/material-spec-audit.js +108 -22
  286. package/dist/_internal/plugin-sdk/material-spec.d.ts +81 -16
  287. package/dist/_internal/plugin-sdk/material-spec.js +241 -42
  288. package/dist/_internal/plugin-sdk/material-style-keys.d.ts +6 -6
  289. package/dist/_internal/plugin-sdk/material-style-keys.js +7 -7
  290. package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
  291. package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
  292. package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
  293. package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
  294. package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
  295. package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
  296. package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
  297. package/dist/_internal/plugin-sdk/material-template.js +879 -0
  298. package/dist/_internal/plugin-sdk/plugin-package.d.ts +2 -2
  299. package/dist/_internal/plugin-sdk/plugin-package.js +3 -3
  300. package/dist/_internal/plugin-sdk/plugin-registration.d.ts +2 -5
  301. package/dist/_internal/plugin-sdk/plugin-registration.js +3 -3
  302. package/dist/_internal/renderer/renderer/renderer-candidates.d.ts +1 -1
  303. package/dist/_internal/renderer/renderer/renderer-component-states.d.ts +1 -1
  304. package/dist/_internal/renderer/renderer/renderer-effective-style.d.ts +1 -1
  305. package/dist/_internal/renderer/renderer/renderer-material-dom.d.ts +1 -1
  306. package/dist/_internal/renderer/renderer/renderer-state.d.ts +2 -2
  307. package/dist/_internal/renderer/renderer/renderer-theme.d.ts +1 -1
  308. package/dist/_internal/renderer/renderer/renderer-types.d.ts +1 -1
  309. package/dist/_internal/renderer/renderer/renderer.d.ts +5 -5
  310. package/dist/_internal/renderer/resource/data-source-runtime.d.ts +3 -3
  311. package/dist/_internal/renderer/resource/push-window.d.ts +1 -1
  312. package/dist/_internal/renderer/resource/request-coordinator.d.ts +1 -1
  313. package/dist/_internal/renderer/resource/source-query-port.d.ts +3 -3
  314. package/dist/_internal/renderer/sub-canvas-layer.d.ts +2 -2
  315. package/dist/_internal/renderer/viewer/viewer-configuration.d.ts +1 -1
  316. package/dist/_internal/renderer/viewer/viewer.d.ts +3 -3
  317. package/dist/auto-register.js +10 -10
  318. package/dist/contracts.js +5 -5
  319. package/dist/contracts.js.map +1 -1
  320. package/dist/contrast-DRPezUIl.js +131 -0
  321. package/dist/contrast-DRPezUIl.js.map +1 -0
  322. package/dist/core.js +156 -136
  323. package/dist/core.js.map +1 -1
  324. package/dist/dataset-port-D993nOlT.js.map +1 -1
  325. package/dist/dataset-profile-Dk6xdtsM.js +261 -0
  326. package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
  327. package/dist/{designer-3Tb0EIDV.js → designer-DzBm8tXS.js} +2 -2
  328. package/dist/{designer-3Tb0EIDV.js.map → designer-DzBm8tXS.js.map} +1 -1
  329. package/dist/designer-auto-register.js +5 -5
  330. package/dist/{designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js → designer-blueprint-workbench-panel-DVvKcSvJ-CkRMBKZA.js} +452 -531
  331. package/dist/designer-blueprint-workbench-panel-DVvKcSvJ-CkRMBKZA.js.map +1 -0
  332. package/dist/{designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js → designer-dataset-controller-bSR5OB6n-DfUP24S6.js} +1355 -1191
  333. package/dist/designer-dataset-controller-bSR5OB6n-DfUP24S6.js.map +1 -0
  334. package/dist/{designer-field-primitives-KBZuWN_D-B3h4jpYe.js → designer-field-primitives-C_StzrUa-QZpcn0yX.js} +241 -181
  335. package/dist/designer-field-primitives-C_StzrUa-QZpcn0yX.js.map +1 -0
  336. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js → designer-left-panel-groups-dom-DBpI3Nc2-D8kYJLCg.js} +18 -18
  337. package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js.map → designer-left-panel-groups-dom-DBpI3Nc2-D8kYJLCg.js.map} +1 -1
  338. package/dist/designer.js +5 -5
  339. package/dist/{dist-6GRboBs-.js → dist-B2bW2Tru.js} +4 -4
  340. package/dist/{dist-6GRboBs-.js.map → dist-B2bW2Tru.js.map} +1 -1
  341. package/dist/{dist-BjLjFUy1.js → dist-YCmniYuO.js} +5636 -4838
  342. package/dist/dist-YCmniYuO.js.map +1 -0
  343. package/dist/engine.js +5 -5
  344. package/dist/{fragment-Y6YnW6wy.js → fragment-B-oP0Fru.js} +3 -3
  345. package/dist/fragment-B-oP0Fru.js.map +1 -0
  346. package/dist/host-kit.js +4388 -187
  347. package/dist/host-kit.js.map +1 -1
  348. package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js → host-resource-selection-BCRU23WQ-Cedz0d14.js} +208 -208
  349. package/dist/host-resource-selection-BCRU23WQ-Cedz0d14.js.map +1 -0
  350. package/dist/image-url-D6mUcjY1.js.map +1 -1
  351. package/dist/index.js +10 -10
  352. package/dist/legibility-CS28ivEz.js +12 -0
  353. package/dist/legibility-CS28ivEz.js.map +1 -0
  354. package/dist/{level-scale-BzUjE31V.js → level-scale-CwHqFEVd.js} +2 -2
  355. package/dist/level-scale-CwHqFEVd.js.map +1 -0
  356. package/dist/{manager-Ch0RTu_i.js → manager-BcvdcZjM.js} +230 -210
  357. package/dist/manager-BcvdcZjM.js.map +1 -0
  358. package/dist/{material-UbSfiuZq.js → material-ReRzBIbb.js} +2 -2
  359. package/dist/{material-UbSfiuZq.js.map → material-ReRzBIbb.js.map} +1 -1
  360. package/dist/material-auto-register.js +1 -1
  361. package/dist/{material-definition-BeW34dJr.js → material-definition-BcjFM-B-.js} +9 -9
  362. package/dist/material-definition-BcjFM-B-.js.map +1 -0
  363. package/dist/material-manifest-B1XatGPx.js.map +1 -1
  364. package/dist/material-theme-C91eus78.js.map +1 -1
  365. package/dist/material.js +2 -2
  366. package/dist/{migrate-document-D3HhCVlZ.js → migrate-document-BM888PtC.js} +2 -2
  367. package/dist/migrate-document-BM888PtC.js.map +1 -0
  368. package/dist/{parse-B1OD1teS.js → parse-1U_-Qtn4.js} +4 -4
  369. package/dist/parse-1U_-Qtn4.js.map +1 -0
  370. package/dist/{parse-AOTE9WnD.js → parse-Ji7kE9ZT.js} +9 -4
  371. package/dist/parse-Ji7kE9ZT.js.map +1 -0
  372. package/dist/{parse-parts-BNrpdG5o.js → parse-parts-qzl4suzk.js} +2 -2
  373. package/dist/{parse-parts-BNrpdG5o.js.map → parse-parts-qzl4suzk.js.map} +1 -1
  374. package/dist/{plugin-DHgh9uHh.js → plugin-BH-4oNvT.js} +63 -55
  375. package/dist/plugin-BH-4oNvT.js.map +1 -0
  376. package/dist/plugin-core.js +2 -2
  377. package/dist/plugin-manager.js +1 -1
  378. package/dist/plugin-package-Cj-3iLv3.js +4369 -0
  379. package/dist/plugin-package-Cj-3iLv3.js.map +1 -0
  380. package/dist/{plugin-registration-rsmb4GvS.js → plugin-registration-C9_IxTxc.js} +9 -9
  381. package/dist/{plugin-registration-rsmb4GvS.js.map → plugin-registration-C9_IxTxc.js.map} +1 -1
  382. package/dist/plugin-sdk.js +6 -6
  383. package/dist/{plugins-DGRHgREK.js → plugins-CwATlfr0.js} +2 -2
  384. package/dist/{plugins-DGRHgREK.js.map → plugins-CwATlfr0.js.map} +1 -1
  385. package/dist/plugins.js +8 -8
  386. package/dist/renderer.js +1 -1
  387. package/dist/{runtime-dispatch-BfnRDtMe.js → runtime-dispatch-C0gyIrTv.js} +2 -2
  388. package/dist/runtime-dispatch-C0gyIrTv.js.map +1 -0
  389. package/dist/runtime-simulate-aSYO9yDX.js +147 -0
  390. package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
  391. package/dist/{src-Bm7u11mN-_0u6cMEw.js → src-Bm7u11mN-DFLnFQSk.js} +39 -39
  392. package/dist/{src-Bm7u11mN-_0u6cMEw.js.map → src-Bm7u11mN-DFLnFQSk.js.map} +1 -1
  393. package/dist/state-preset-DtpygJOH.js +22 -0
  394. package/dist/state-preset-DtpygJOH.js.map +1 -0
  395. package/dist/{text-BNksUr5J.js → text-DfKom8EG.js} +88 -35
  396. package/dist/text-DfKom8EG.js.map +1 -0
  397. package/dist/theme-CcBXf4Ay.js.map +1 -1
  398. package/dist/{value-ref-BG_MV9C-.js → value-ref-XkLuckGV.js} +2 -2
  399. package/dist/{value-ref-BG_MV9C-.js.map → value-ref-XkLuckGV.js.map} +1 -1
  400. package/dist/{viewer-CrJupI8I-D9dVcNw4.js → viewer-CrJupI8I-CeQS58mA.js} +5 -5
  401. package/dist/{viewer-CrJupI8I-D9dVcNw4.js.map → viewer-CrJupI8I-CeQS58mA.js.map} +1 -1
  402. package/dist/viewer-auto-register.js +2 -2
  403. package/dist/viewer.js +2 -2
  404. package/dist/{viewport-CiCKeAQH.js → viewport-BNIRWjiT.js} +354 -155
  405. package/dist/viewport-BNIRWjiT.js.map +1 -0
  406. package/package.json +12 -12
  407. package/dist/designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js.map +0 -1
  408. package/dist/designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js.map +0 -1
  409. package/dist/designer-field-primitives-KBZuWN_D-B3h4jpYe.js.map +0 -1
  410. package/dist/dist-BjLjFUy1.js.map +0 -1
  411. package/dist/fragment-Y6YnW6wy.js.map +0 -1
  412. package/dist/host-resource-selection-xo2mLCD4-BR5XCcim.js.map +0 -1
  413. package/dist/level-scale-BzUjE31V.js.map +0 -1
  414. package/dist/manager-Ch0RTu_i.js.map +0 -1
  415. package/dist/material-definition-BeW34dJr.js.map +0 -1
  416. package/dist/migrate-document-D3HhCVlZ.js.map +0 -1
  417. package/dist/parse-AOTE9WnD.js.map +0 -1
  418. package/dist/parse-B1OD1teS.js.map +0 -1
  419. package/dist/plugin-DHgh9uHh.js.map +0 -1
  420. package/dist/plugin-package-Dr5ro6h6.js +0 -1221
  421. package/dist/plugin-package-Dr5ro6h6.js.map +0 -1
  422. package/dist/runtime-dispatch-BfnRDtMe.js.map +0 -1
  423. package/dist/text-BNksUr5J.js.map +0 -1
  424. package/dist/viewport-CiCKeAQH.js.map +0 -1
@@ -0,0 +1,4369 @@
1
+ import { i as e, r as t } from "./image-url-D6mUcjY1.js";
2
+ import { Nt as n } from "./parse-Ji7kE9ZT.js";
3
+ import { t as r } from "./equality-DjZ9cv4u.js";
4
+ import { u as i } from "./plugin-BH-4oNvT.js";
5
+ import { t as a } from "./material-schema-CLoDx-Tl.js";
6
+ import { r as o, t as s } from "./fragment-B-oP0Fru.js";
7
+ import { i as c } from "./material-theme-C91eus78.js";
8
+ import { r as l, t as u } from "./material-manifest-B1XatGPx.js";
9
+ import { a as d, o as f, r as p } from "./contrast-DRPezUIl.js";
10
+ import { n as m } from "./legibility-CS28ivEz.js";
11
+ import { a as h, i as g, n as _, r as v } from "./material-definition-BcjFM-B-.js";
12
+ import { n as y, r as b, t as x } from "./material-state-view-Bw7xIkEg.js";
13
+ import { n as S } from "./plugin-registration-C9_IxTxc.js";
14
+ //#region ../plugin-sdk/dist/authoring-finding.js
15
+ function C(e) {
16
+ return [...e.filter((e) => e.severity === "error"), ...e.filter((e) => e.severity === "warning")];
17
+ }
18
+ function ee(e) {
19
+ return e.some((e) => e.severity === "error");
20
+ }
21
+ //#endregion
22
+ //#region ../plugin-sdk/dist/fragment-audit.js
23
+ var te = 8, ne = 2, w = .9, re = /* @__PURE__ */ new Set(["base.rectangle", "base.container"]);
24
+ function ie(e, t) {
25
+ let n = o(e);
26
+ if (!n.ok) return n.diagnostics.map((e) => ({
27
+ rule: "SPEC",
28
+ severity: "error",
29
+ message: e.message,
30
+ path: e.path
31
+ }));
32
+ let r = n.value, i = [];
33
+ return t !== void 0 && ae(r, t, i), oe(r, i), se(r, i), ce(r, i), r.nodes.forEach((e, t) => {
34
+ (e.name === void 0 || e.name.trim() === "") && i.push({
35
+ rule: "F9",
36
+ severity: "warning",
37
+ message: `节点 ${e.key} 没有名称:插入后图层里只显示物料名。`,
38
+ path: [
39
+ "nodes",
40
+ t,
41
+ "name"
42
+ ]
43
+ });
44
+ }), C(i);
45
+ }
46
+ function ae(e, t, n) {
47
+ let r = [...e.shell === void 0 ? [] : [[e.shell, ["shell"]]], ...e.nodes.map((e, t) => [e, ["nodes", t]])];
48
+ for (let [i, a] of r) {
49
+ let r = t.get(i.materialType)?.manifest;
50
+ if (r === void 0) {
51
+ n.push({
52
+ rule: "F8",
53
+ severity: "error",
54
+ message: `引用的物料 ${i.materialType} 不在物料目录里。`,
55
+ path: [...a, "materialType"]
56
+ });
57
+ continue;
58
+ }
59
+ r.libraryVisible === !1 && n.push({
60
+ rule: "F8",
61
+ severity: "warning",
62
+ message: `「${r.name}」已下架:已有组合仍可插入,但新作者在物料库里找不到它。`,
63
+ path: [...a, "materialType"]
64
+ }), i === e.shell && r.designCapabilities.children !== !0 && n.push({
65
+ rule: "F8",
66
+ severity: "error",
67
+ message: `外壳「${r.name}」不接受子节点,改用容器。`,
68
+ path: [...a, "materialType"]
69
+ });
70
+ }
71
+ }
72
+ function oe(e, t) {
73
+ if (e.shell !== void 0 || e.nodes.length < 2) return;
74
+ let [n, ...r] = e.nodes;
75
+ if (n === void 0 || !re.has(n.materialType)) return;
76
+ let i = le(n), a = r.map(le).filter((e) => e !== void 0);
77
+ i !== void 0 && a.length !== 0 && a.filter((e) => ue(e, i) >= w).length === a.length && t.push({
78
+ rule: "F2",
79
+ severity: "warning",
80
+ message: "底板由外壳承担:把这块矩形换成容器,其余节点放进容器后整体存为组合,卡片才能整体移动、缩放。",
81
+ path: ["nodes", 0]
82
+ });
83
+ }
84
+ function se(e, t) {
85
+ let n = e.nodes.flatMap((e) => e.dataSource === void 0 || e.dataSource === null ? [] : [e.dataSource]);
86
+ for (let e = 0; e < n.length; e += 1) {
87
+ let i = n[e];
88
+ if (i.type !== "dataset" && i.type !== "host-resource") continue;
89
+ let a = (e) => e.type === i.type && r(de(e), de(i));
90
+ if (!n.slice(0, e).some(a) && n.slice(e + 1).some(a)) {
91
+ t.push({
92
+ rule: "F4",
93
+ severity: "warning",
94
+ message: "多个节点各自查询同一个数据源:改为共享文档级数据源,一次查询、多处读取。",
95
+ path: ["nodes"]
96
+ });
97
+ return;
98
+ }
99
+ }
100
+ }
101
+ function ce(e, t) {
102
+ e.nodes.length > te && t.push({
103
+ rule: "F6",
104
+ severity: "warning",
105
+ message: `组合有 ${e.nodes.length} 个节点(建议不超过 ${te} 个):更像页面模板,考虑拆成几个组合。`,
106
+ path: ["nodes"]
107
+ });
108
+ let n = new Map(e.nodes.map((e) => [e.key, e.parent])), r = (e, t = 0) => e === void 0 || t > 64 ? t : r(n.get(e), t + 1), i = Math.max(0, ...e.nodes.map((e) => r(e.key)));
109
+ i > ne && t.push({
110
+ rule: "F6",
111
+ severity: "warning",
112
+ message: `组合嵌套 ${i} 层(建议不超过 ${ne} 层)。`,
113
+ path: ["nodes"]
114
+ });
115
+ }
116
+ function le(e) {
117
+ if (e.size !== void 0) return {
118
+ x: e.offset?.x ?? 0,
119
+ y: e.offset?.y ?? 0,
120
+ width: e.size.width,
121
+ height: e.size.height
122
+ };
123
+ }
124
+ function ue(e, t) {
125
+ let n = Math.min(e.x + e.width, t.x + t.width) - Math.max(e.x, t.x), r = Math.min(e.y + e.height, t.y + t.height) - Math.max(e.y, t.y), i = e.width * e.height;
126
+ return n <= 0 || r <= 0 || i <= 0 ? 0 : n * r / i;
127
+ }
128
+ function de(e) {
129
+ let { binding: t, ...n } = e;
130
+ return n;
131
+ }
132
+ //#endregion
133
+ //#region ../plugin-sdk/dist/fragment-definition.js
134
+ function fe(e) {
135
+ let t = o(e);
136
+ if (!t.ok) return t;
137
+ let n = {
138
+ kind: "fragment",
139
+ ...t.value
140
+ };
141
+ return {
142
+ ok: !0,
143
+ value: Object.freeze(n),
144
+ diagnostics: []
145
+ };
146
+ }
147
+ //#endregion
148
+ //#region ../plugin-sdk/dist/material-config-groups.js
149
+ var pe = 16, me = 6;
150
+ function he(e = {}) {
151
+ let t = Math.min(Math.max(Math.trunc(e.maxDecimals ?? 4), 0), me), n = Math.min(Math.max(Math.trunc(e.decimals ?? 0), 0), t), r = {}, i = {}, a = [], o = ["decimals"], s = ge(e.prefix);
152
+ s !== void 0 && (r.prefix = {
153
+ kind: "string",
154
+ maxLength: pe
155
+ }, i.prefix = s, a.push(T("prefix", "前缀")));
156
+ let c = ge(e.unit);
157
+ return c !== void 0 && (r.unit = {
158
+ kind: "string",
159
+ maxLength: pe
160
+ }, i.unit = c, a.push(T("unit", "单位"))), r.decimals = {
161
+ kind: "number",
162
+ minimum: 0,
163
+ maximum: t
164
+ }, i.decimals = n, a.push(T("decimals", "小数位")), e.thousandsSeparator !== void 0 && (r.thousandsSeparator = { kind: "boolean" }, i.thousandsSeparator = e.thousandsSeparator, o.push("thousandsSeparator"), a.push(T("thousandsSeparator", "显示千分位"))), {
165
+ id: "number-format",
166
+ properties: r,
167
+ required: o,
168
+ defaults: i,
169
+ fields: a
170
+ };
171
+ }
172
+ function ge(e) {
173
+ return typeof e == "string" ? [...e].slice(0, pe).join("") : e === !0 ? "" : void 0;
174
+ }
175
+ function _e() {
176
+ return {
177
+ id: "chart-title",
178
+ properties: { titleText: { kind: "string" } },
179
+ required: ["titleText"],
180
+ defaults: { titleText: "" },
181
+ fields: [T("titleText", "标题", { placeholder: "留空不显示" })]
182
+ };
183
+ }
184
+ function ve(e = {}) {
185
+ return {
186
+ id: "chart-legend",
187
+ properties: { showLegend: { kind: "boolean" } },
188
+ required: ["showLegend"],
189
+ defaults: { showLegend: e.showLegend ?? !0 },
190
+ fields: [T("showLegend", "显示图例")]
191
+ };
192
+ }
193
+ function ye(e) {
194
+ let t = {}, n = {}, r = [];
195
+ for (let i of e) {
196
+ for (let [e, n] of Object.entries(i.properties)) {
197
+ if (Object.hasOwn(t, e)) throw Error(`Material config groups overlap on props key "${e}".`);
198
+ t[e] = n;
199
+ }
200
+ Object.assign(n, i.defaults), r.push(...i.required);
201
+ }
202
+ return {
203
+ properties: t,
204
+ required: r,
205
+ defaults: n
206
+ };
207
+ }
208
+ function T(e, t, n = {}) {
209
+ return {
210
+ id: e,
211
+ target: "props",
212
+ path: [e],
213
+ label: t,
214
+ ...n
215
+ };
216
+ }
217
+ //#endregion
218
+ //#region ../plugin-sdk/dist/material-template-expression.js
219
+ var E = {
220
+ sourceLength: 400,
221
+ depth: 16,
222
+ nodes: 64,
223
+ concatLength: 256
224
+ }, be = 2e4, xe = {
225
+ min: {
226
+ min: 2,
227
+ max: 8
228
+ },
229
+ max: {
230
+ min: 2,
231
+ max: 8
232
+ },
233
+ clamp: {
234
+ min: 3,
235
+ max: 3
236
+ },
237
+ abs: {
238
+ min: 1,
239
+ max: 1
240
+ },
241
+ round: {
242
+ min: 1,
243
+ max: 2
244
+ },
245
+ floor: {
246
+ min: 1,
247
+ max: 1
248
+ },
249
+ ceil: {
250
+ min: 1,
251
+ max: 1
252
+ },
253
+ sqrt: {
254
+ min: 1,
255
+ max: 1
256
+ },
257
+ sin: {
258
+ min: 1,
259
+ max: 1
260
+ },
261
+ cos: {
262
+ min: 1,
263
+ max: 1
264
+ },
265
+ scale: {
266
+ min: 5,
267
+ max: 5
268
+ },
269
+ pct: {
270
+ min: 1,
271
+ max: 3
272
+ },
273
+ format: {
274
+ min: 1,
275
+ max: 1
276
+ },
277
+ fixed: {
278
+ min: 2,
279
+ max: 2
280
+ },
281
+ concat: {
282
+ min: 1,
283
+ max: 8
284
+ },
285
+ pick: {
286
+ min: 4,
287
+ max: 24,
288
+ even: !0
289
+ },
290
+ len: {
291
+ min: 1,
292
+ max: 1
293
+ },
294
+ charAt: {
295
+ min: 2,
296
+ max: 2
297
+ },
298
+ maxOf: {
299
+ min: 2,
300
+ max: 2,
301
+ aggregate: !0
302
+ },
303
+ minOf: {
304
+ min: 2,
305
+ max: 2,
306
+ aggregate: !0
307
+ },
308
+ sumOf: {
309
+ min: 2,
310
+ max: 2,
311
+ aggregate: !0
312
+ }
313
+ }, Se = Object.keys(xe), Ce = [
314
+ "==",
315
+ "!=",
316
+ "<=",
317
+ ">=",
318
+ "&&",
319
+ "||",
320
+ "<",
321
+ ">",
322
+ "+",
323
+ "-",
324
+ "*",
325
+ "/",
326
+ "%",
327
+ "!",
328
+ "?",
329
+ ":",
330
+ "(",
331
+ ")",
332
+ ",",
333
+ "."
334
+ ];
335
+ function we(e) {
336
+ let t = [], n = 0;
337
+ for (; n < e.length;) {
338
+ let r = e[n];
339
+ if (r === " " || r === " " || r === "\n" || r === "\r") {
340
+ n += 1;
341
+ continue;
342
+ }
343
+ if (/[0-9]/.test(r) || r === "." && /[0-9]/.test(e[n + 1] ?? "")) {
344
+ let r = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(n));
345
+ if (r === null) return `第 ${n + 1} 个字符不是合法的数字。`;
346
+ t.push({
347
+ t: "num",
348
+ v: Number(r[0])
349
+ }), n += r[0].length;
350
+ continue;
351
+ }
352
+ if (r === "'" || r === "\"") {
353
+ let i = n + 1, a = "";
354
+ for (; i < e.length && e[i] !== r;) {
355
+ if (e[i] === "\\") return "字符串里不支持转义。";
356
+ a += e[i], i += 1;
357
+ }
358
+ if (i >= e.length) return "字符串缺少结束引号。";
359
+ t.push({
360
+ t: "str",
361
+ v: a
362
+ }), n = i + 1;
363
+ continue;
364
+ }
365
+ if (/[A-Za-z_]/.test(r)) {
366
+ let r = /^[A-Za-z_][A-Za-z0-9_]*/.exec(e.slice(n));
367
+ t.push({
368
+ t: "id",
369
+ v: r[0]
370
+ }), n += r[0].length;
371
+ continue;
372
+ }
373
+ let i = Ce.find((t) => e.startsWith(t, n));
374
+ if (i === void 0) return `不认识的符号「${r}」。`;
375
+ t.push({
376
+ t: "op",
377
+ v: i
378
+ }), n += i.length;
379
+ }
380
+ return t.push({ t: "end" }), t;
381
+ }
382
+ var D = class extends Error {}, Te = {
383
+ "||": 1,
384
+ "&&": 2,
385
+ "==": 3,
386
+ "!=": 3,
387
+ "<": 4,
388
+ "<=": 4,
389
+ ">": 4,
390
+ ">=": 4,
391
+ "+": 5,
392
+ "-": 5,
393
+ "*": 6,
394
+ "/": 6,
395
+ "%": 6
396
+ }, Ee = class {
397
+ tokens;
398
+ scope;
399
+ #e = 0;
400
+ #t = 0;
401
+ constructor(e, t) {
402
+ this.tokens = e, this.scope = t;
403
+ }
404
+ parse() {
405
+ let e = this.#s(0);
406
+ if (this.#n().t !== "end") throw new D("表达式结尾有多余内容。");
407
+ return e;
408
+ }
409
+ #n() {
410
+ return this.tokens[this.#e];
411
+ }
412
+ #r() {
413
+ let e = this.tokens[this.#e];
414
+ return this.#e += 1, e;
415
+ }
416
+ #i(e) {
417
+ let t = this.#n();
418
+ return t.t === "op" && t.v === e;
419
+ }
420
+ #a(e) {
421
+ if (!this.#i(e)) throw new D(`缺少「${e}」。`);
422
+ this.#e += 1;
423
+ }
424
+ #o(e, t) {
425
+ if (this.#t += 1, this.#t > E.nodes) throw new D(`表达式过长(最多 ${E.nodes} 个节点)。`);
426
+ if (t > E.depth) throw new D(`表达式嵌套过深(最多 ${E.depth} 层)。`);
427
+ return e;
428
+ }
429
+ #s(e) {
430
+ let t = this.#c(1, e);
431
+ if (!this.#i("?")) return t;
432
+ this.#e += 1;
433
+ let n = this.#s(e + 1);
434
+ this.#a(":");
435
+ let r = this.#s(e + 1);
436
+ return this.#o({
437
+ k: "cond",
438
+ t,
439
+ a: n,
440
+ b: r
441
+ }, e);
442
+ }
443
+ #c(e, t) {
444
+ let n = this.#l(t + 1);
445
+ for (;;) {
446
+ let r = this.#n();
447
+ if (r.t !== "op") return n;
448
+ let i = Te[r.v];
449
+ if (i === void 0 || i < e) return n;
450
+ this.#e += 1;
451
+ let a = this.#c(i + 1, t + 1);
452
+ n = this.#o({
453
+ k: "bin",
454
+ op: r.v,
455
+ a: n,
456
+ b: a
457
+ }, t);
458
+ }
459
+ }
460
+ #l(e) {
461
+ if (this.#i("-") || this.#i("!")) {
462
+ let t = this.#r().v;
463
+ return this.#o({
464
+ k: "un",
465
+ op: t,
466
+ a: this.#l(e + 1)
467
+ }, e);
468
+ }
469
+ return this.#u(e);
470
+ }
471
+ #u(e) {
472
+ let t = this.#r();
473
+ if (t.t === "num" || t.t === "str") return this.#o({
474
+ k: "lit",
475
+ v: t.v
476
+ }, e);
477
+ if (t.t === "op" && t.v === "(") {
478
+ let t = this.#s(e + 1);
479
+ return this.#a(")"), t;
480
+ }
481
+ if (t.t === "id") return t.v === "true" || t.v === "false" ? this.#o({
482
+ k: "lit",
483
+ v: t.v === "true"
484
+ }, e) : t.v === "null" ? this.#o({
485
+ k: "lit",
486
+ v: null
487
+ }, e) : this.#i("(") ? this.#d(t.v, e) : this.#p(t.v, e);
488
+ throw new D("表达式不完整。");
489
+ }
490
+ #d(e, t) {
491
+ let n = xe[e];
492
+ if (n === void 0) throw new D(`不支持函数 ${e}(可用:${Se.join("、")})。`);
493
+ this.#a("(");
494
+ let r = [];
495
+ if (!this.#i(")")) for (; n.aggregate === !0 && r.length === 0 ? r.push(this.#f(e, t + 1)) : r.push(this.#s(t + 1)), this.#i(",");) this.#e += 1;
496
+ if (this.#a(")"), r.length < n.min || r.length > n.max) throw new D(n.min === n.max ? `${e} 需要 ${n.min} 个参数。` : `${e} 需要 ${n.min}–${n.max} 个参数。`);
497
+ if (n.even === !0 && r.length % 2 != 0) throw new D(`${e} 的参数是「取值, 键1, 值1, …, 缺省值」,个数应为偶数。`);
498
+ if (n.aggregate === !0) {
499
+ let t = r[1];
500
+ if (t?.k !== "lit" || typeof t.v != "string" || !this.scope.roles.has(t.v)) throw new D(`${e} 的第二个参数必须是已声明的数据角色名(用引号写)。`);
501
+ }
502
+ return this.#o({
503
+ k: "call",
504
+ fn: e,
505
+ args: r
506
+ }, t);
507
+ }
508
+ #f(e, t) {
509
+ let n = this.#r();
510
+ if (n.t !== "id" || n.v !== "rows") throw new D(`${e} 的第一个参数必须是 rows。`);
511
+ if (this.scope.data !== "rows") throw new D("组件不是多行数据,不能读 rows。");
512
+ return this.#o({
513
+ k: "ref",
514
+ root: "rows"
515
+ }, t);
516
+ }
517
+ #p(e, t) {
518
+ let n;
519
+ if (this.#i(".")) {
520
+ this.#e += 1;
521
+ let t = this.#r();
522
+ if (t.t !== "id") throw new D(`${e}. 后面缺少字段名。`);
523
+ if (n = t.v, this.#i(".")) throw new D("引用只能有一层(如 props.showLabel)。");
524
+ }
525
+ let r = this.scope;
526
+ switch (e) {
527
+ case "value":
528
+ if (n !== void 0) throw new D("value 后面不能再接字段。");
529
+ if (r.data !== "scalar") throw new D("组件不是单值数据,不能读 value。");
530
+ return this.#o({
531
+ k: "ref",
532
+ root: "value"
533
+ }, t);
534
+ case "index":
535
+ case "count":
536
+ if (n !== void 0) throw new D(`${e} 后面不能再接字段。`);
537
+ if (!r.inRepeat) throw new D(`${e} 只能用在 repeat 里。`);
538
+ return this.#o({
539
+ k: "ref",
540
+ root: e
541
+ }, t);
542
+ case "rows": throw new D("rows 只能交给 maxOf / minOf / sumOf。");
543
+ case "row":
544
+ if (!r.inRowRepeat) throw new D("row 只能用在遍历 rows 的 repeat 里。");
545
+ if (n === void 0 || !r.roles.has(n)) throw new D(`row.${n ?? ""} 不是已声明的数据角色。`);
546
+ return this.#o({
547
+ k: "ref",
548
+ root: "row",
549
+ key: n
550
+ }, t);
551
+ case "props":
552
+ case "style": {
553
+ let i = e === "props" ? r.props : r.style;
554
+ if (n === void 0 || !i.has(n)) throw new D(`${e}.${n ?? ""} 不是规格里声明的${e === "props" ? "参数" : "样式"}字段。`);
555
+ return this.#o({
556
+ k: "ref",
557
+ root: e,
558
+ key: n
559
+ }, t);
560
+ }
561
+ case "size":
562
+ if (n !== "width" && n !== "height") throw new D("size 只有 width / height。");
563
+ return this.#o({
564
+ k: "ref",
565
+ root: "size",
566
+ key: n
567
+ }, t);
568
+ default: throw new D(`不认识的名字 ${e}(可用:value、row.<角色>、index、count、props.<键>、style.<键>、size.width / height)。`);
569
+ }
570
+ }
571
+ };
572
+ function De(e, t) {
573
+ if (e.length > E.sourceLength) return {
574
+ ok: !1,
575
+ message: `表达式最多 ${E.sourceLength} 个字符。`
576
+ };
577
+ let n = we(e);
578
+ if (typeof n == "string") return {
579
+ ok: !1,
580
+ message: n
581
+ };
582
+ try {
583
+ return {
584
+ ok: !0,
585
+ value: new Ee(n, t).parse()
586
+ };
587
+ } catch (e) {
588
+ if (e instanceof D) return {
589
+ ok: !1,
590
+ message: e.message
591
+ };
592
+ throw e;
593
+ }
594
+ }
595
+ var Oe = class extends Error {
596
+ constructor() {
597
+ super("模板求值超出步数上限。"), this.name = "BaseScreenMaterialTemplateBudgetError";
598
+ }
599
+ };
600
+ function O(e, t) {
601
+ if (--t.budget.steps, t.budget.steps < 0) throw new Oe();
602
+ switch (e.k) {
603
+ case "lit": return e.v;
604
+ case "ref": return ke(e.root, e.key, t);
605
+ case "un": {
606
+ let n = O(e.a, t);
607
+ return e.op === "-" ? -j(n) : !N(n);
608
+ }
609
+ case "cond": return N(O(e.t, t)) ? O(e.a, t) : O(e.b, t);
610
+ case "bin": return Ae(e, t);
611
+ case "call": return je(e.fn, e.args, t);
612
+ }
613
+ }
614
+ function ke(e, t, n) {
615
+ switch (e) {
616
+ case "value": return n.value;
617
+ case "index": return n.index ?? null;
618
+ case "count": return n.count ?? null;
619
+ case "row": return k(t === void 0 ? void 0 : n.row?.[t]);
620
+ case "props": return k(t === void 0 ? void 0 : n.props[t]);
621
+ case "style": return k(t === void 0 ? void 0 : n.style[t]);
622
+ case "size": return t === "height" ? n.size.height : n.size.width;
623
+ case "rows": return null;
624
+ }
625
+ }
626
+ function Ae(e, t) {
627
+ if (e.op === "&&") {
628
+ let n = O(e.a, t);
629
+ return N(n) ? O(e.b, t) : n;
630
+ }
631
+ if (e.op === "||") {
632
+ let n = O(e.a, t);
633
+ return N(n) ? n : O(e.b, t);
634
+ }
635
+ let n = O(e.a, t), r = O(e.b, t);
636
+ switch (e.op) {
637
+ case "==": return Me(n, r);
638
+ case "!=": return !Me(n, r);
639
+ case "<": return j(n) < j(r);
640
+ case "<=": return j(n) <= j(r);
641
+ case ">": return j(n) > j(r);
642
+ case ">=": return j(n) >= j(r);
643
+ case "+": return j(n) + j(r);
644
+ case "-": return j(n) - j(r);
645
+ case "*": return j(n) * j(r);
646
+ case "/": return j(n) / j(r);
647
+ case "%": return j(n) % j(r);
648
+ }
649
+ }
650
+ function je(e, t, n) {
651
+ if (e === "maxOf" || e === "minOf" || e === "sumOf") {
652
+ let r = t[1].v, i = n.rows.map((e) => j(k(e[r]))).filter(Number.isFinite);
653
+ if (n.budget.steps -= n.rows.length, n.budget.steps < 0) throw new Oe();
654
+ return i.length === 0 ? null : e === "sumOf" ? i.reduce((e, t) => e + t, 0) : e === "maxOf" ? Math.max(...i) : Math.min(...i);
655
+ }
656
+ if (e === "pick") {
657
+ let e = O(t[0], n);
658
+ for (let r = 1; r <= t.length - 3; r += 2) if (Me(e, O(t[r], n))) return O(t[r + 1], n);
659
+ return O(t[t.length - 1], n);
660
+ }
661
+ let r = t.map((e) => O(e, n)), i = (e) => j(r[e] ?? null);
662
+ switch (e) {
663
+ case "min": return Math.min(...r.map((e) => j(e)));
664
+ case "max": return Math.max(...r.map((e) => j(e)));
665
+ case "clamp": return Math.min(Math.max(i(0), i(1)), i(2));
666
+ case "abs": return Math.abs(i(0));
667
+ case "round": {
668
+ let e = 10 ** (r.length > 1 ? Math.max(0, Math.min(6, Math.trunc(i(1)))) : 0);
669
+ return Math.round(i(0) * e) / e;
670
+ }
671
+ case "floor": return Math.floor(i(0));
672
+ case "ceil": return Math.ceil(i(0));
673
+ case "sqrt": return Math.sqrt(i(0));
674
+ case "sin": return Math.sin(i(0) * Math.PI / 180);
675
+ case "cos": return Math.cos(i(0) * Math.PI / 180);
676
+ case "scale": {
677
+ let [e, t, n, r, a] = [
678
+ i(0),
679
+ i(1),
680
+ i(2),
681
+ i(3),
682
+ i(4)
683
+ ];
684
+ return n === t ? r : r + (e - t) / (n - t) * (a - r);
685
+ }
686
+ case "pct": {
687
+ let e = r.length > 1 ? i(1) : 0, t = r.length > 2 ? i(2) : 100;
688
+ return t === e ? 0 : Math.min(1, Math.max(0, (i(0) - e) / (t - e)));
689
+ }
690
+ case "format": return n.formatNumber(r[0]);
691
+ case "fixed": {
692
+ let e = i(0);
693
+ return Number.isFinite(e) ? e.toFixed(Math.max(0, Math.min(6, Math.trunc(i(1))))) : "--";
694
+ }
695
+ case "concat": return r.map((e) => e === null ? "" : String(e)).join("").slice(0, E.concatLength);
696
+ case "len": return r[0] === null ? 0 : [...String(r[0])].length;
697
+ case "charAt": return (r[0] === null ? [] : [...String(r[0])])[Math.trunc(i(1))] ?? "";
698
+ default: return null;
699
+ }
700
+ }
701
+ function k(e) {
702
+ return e == null ? null : typeof e == "number" || typeof e == "string" || typeof e == "boolean" ? e : null;
703
+ }
704
+ function A(e) {
705
+ return j(e);
706
+ }
707
+ function j(e) {
708
+ return typeof e == "number" ? e : typeof e == "boolean" ? +!!e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
709
+ }
710
+ function M(e) {
711
+ return N(e);
712
+ }
713
+ function N(e) {
714
+ return typeof e == "number" ? e !== 0 && !Number.isNaN(e) : e !== null && e !== !1 && e !== "";
715
+ }
716
+ function Me(e, t) {
717
+ return typeof e == typeof t ? e === t : typeof e == "number" && typeof t == "string" || typeof e == "string" && typeof t == "number" ? j(e) === j(t) : !1;
718
+ }
719
+ //#endregion
720
+ //#region ../plugin-sdk/dist/material-template.js
721
+ var P = {
722
+ nodes: 300,
723
+ repeat: 200,
724
+ animations: 8,
725
+ events: 4,
726
+ gradients: 8,
727
+ pathCommands: 64,
728
+ dash: 6,
729
+ minDuration: 100,
730
+ maxDuration: 2e4
731
+ }, Ne = [
732
+ "g",
733
+ "repeat",
734
+ "when",
735
+ "clip",
736
+ "rect",
737
+ "circle",
738
+ "ellipse",
739
+ "line",
740
+ "polyline",
741
+ "path",
742
+ "text",
743
+ "arc",
744
+ "ticks",
745
+ "wave"
746
+ ], F = {
747
+ g: [
748
+ "x",
749
+ "y",
750
+ "scale",
751
+ "rotate"
752
+ ],
753
+ repeat: [],
754
+ when: [],
755
+ clip: [],
756
+ rect: [
757
+ "x",
758
+ "y",
759
+ "width",
760
+ "height",
761
+ "rx"
762
+ ],
763
+ circle: [
764
+ "cx",
765
+ "cy",
766
+ "r"
767
+ ],
768
+ ellipse: [
769
+ "cx",
770
+ "cy",
771
+ "rx",
772
+ "ry"
773
+ ],
774
+ line: [
775
+ "x1",
776
+ "y1",
777
+ "x2",
778
+ "y2"
779
+ ],
780
+ polyline: [],
781
+ path: [],
782
+ text: [
783
+ "x",
784
+ "y",
785
+ "fontSize"
786
+ ],
787
+ arc: [
788
+ "cx",
789
+ "cy",
790
+ "r",
791
+ "thickness",
792
+ "start",
793
+ "end"
794
+ ],
795
+ ticks: [
796
+ "cx",
797
+ "cy",
798
+ "r",
799
+ "length",
800
+ "count",
801
+ "start",
802
+ "end"
803
+ ],
804
+ wave: [
805
+ "x",
806
+ "y",
807
+ "width",
808
+ "height",
809
+ "amplitude",
810
+ "wavelength",
811
+ "phase"
812
+ ]
813
+ }, Pe = {
814
+ rect: [
815
+ "x",
816
+ "y",
817
+ "width",
818
+ "height"
819
+ ],
820
+ circle: [
821
+ "cx",
822
+ "cy",
823
+ "r"
824
+ ],
825
+ ellipse: [
826
+ "cx",
827
+ "cy",
828
+ "rx",
829
+ "ry"
830
+ ],
831
+ line: [
832
+ "x1",
833
+ "y1",
834
+ "x2",
835
+ "y2"
836
+ ],
837
+ text: [
838
+ "x",
839
+ "y",
840
+ "fontSize"
841
+ ],
842
+ arc: [
843
+ "cx",
844
+ "cy",
845
+ "r",
846
+ "thickness",
847
+ "start",
848
+ "end"
849
+ ],
850
+ ticks: [
851
+ "cx",
852
+ "cy",
853
+ "r",
854
+ "length",
855
+ "count",
856
+ "start",
857
+ "end"
858
+ ],
859
+ wave: [
860
+ "x",
861
+ "y",
862
+ "width",
863
+ "height",
864
+ "amplitude",
865
+ "wavelength"
866
+ ]
867
+ }, Fe = /* @__PURE__ */ new Set([
868
+ "rect",
869
+ "circle",
870
+ "ellipse",
871
+ "line",
872
+ "polyline",
873
+ "path",
874
+ "text",
875
+ "arc",
876
+ "ticks",
877
+ "wave"
878
+ ]), Ie = /* @__PURE__ */ new Set([
879
+ "rect",
880
+ "circle",
881
+ "ellipse",
882
+ "path"
883
+ ]), Le = /* @__PURE__ */ new Set([
884
+ "g",
885
+ "repeat",
886
+ "when",
887
+ "clip"
888
+ ]), Re = /* @__PURE__ */ new Set([
889
+ "rect",
890
+ "circle",
891
+ "ellipse",
892
+ "path",
893
+ "wave",
894
+ "polyline"
895
+ ]), ze = {
896
+ g: ["children", "opacity"],
897
+ repeat: ["source", "children"],
898
+ when: ["test", "children"],
899
+ clip: ["shape", "children"],
900
+ rect: [],
901
+ circle: [],
902
+ ellipse: [],
903
+ line: [],
904
+ polyline: ["points", "closed"],
905
+ path: ["d"],
906
+ text: [
907
+ "content",
908
+ "fontWeight",
909
+ "anchor",
910
+ "baseline",
911
+ "backdrop"
912
+ ],
913
+ arc: ["linecap"],
914
+ ticks: [],
915
+ wave: []
916
+ }, Be = [
917
+ "fill",
918
+ "stroke",
919
+ "strokeWidth",
920
+ "strokeDasharray",
921
+ "strokeLinecap",
922
+ "opacity",
923
+ "on"
924
+ ], Ve = /^[a-z][A-Za-z0-9-]{0,39}$/, He = /^[a-z][A-Za-z0-9]{0,31}$/, Ue = /^[a-z][A-Za-z0-9]{0,31}$/, I = /^(?:#[0-9a-fA-F]{3,4}|#[0-9a-fA-F]{6}|#[0-9a-fA-F]{8}|(?:rgb|rgba|hsl|hsla)\([0-9.,%\s/deg]*\)|transparent|none|currentColor)$/, We = {
925
+ M: 2,
926
+ L: 2,
927
+ H: 1,
928
+ V: 1,
929
+ C: 6,
930
+ Q: 4,
931
+ A: 7,
932
+ Z: 0
933
+ }, Ge = /* @__PURE__ */ new Set([
934
+ "translateX",
935
+ "translateY",
936
+ "rotate",
937
+ "scale",
938
+ "opacity"
939
+ ]), Ke = /* @__PURE__ */ new Set([
940
+ "linear",
941
+ "ease",
942
+ "ease-in",
943
+ "ease-out",
944
+ "ease-in-out"
945
+ ]), qe = /* @__PURE__ */ new Set([
946
+ "start",
947
+ "middle",
948
+ "end"
949
+ ]), Je = /* @__PURE__ */ new Set([
950
+ "auto",
951
+ "middle",
952
+ "hanging"
953
+ ]), Ye = /* @__PURE__ */ new Set([
954
+ "butt",
955
+ "round",
956
+ "square"
957
+ ]), Xe = /* @__PURE__ */ new Set([
958
+ 400,
959
+ 500,
960
+ 600,
961
+ 700
962
+ ]), Ze = (e, t) => `${e}:${t}`;
963
+ function L(e, t) {
964
+ let n = new Qe(t), r = n.compile(e);
965
+ return n.diagnostics.length > 0 || r === void 0 ? {
966
+ ok: !1,
967
+ diagnostics: n.diagnostics
968
+ } : {
969
+ ok: !0,
970
+ value: r,
971
+ diagnostics: []
972
+ };
973
+ }
974
+ var Qe = class {
975
+ context;
976
+ diagnostics = [];
977
+ #e = /* @__PURE__ */ new Map();
978
+ #t = /* @__PURE__ */ new Set();
979
+ #n = /* @__PURE__ */ new Set();
980
+ #r;
981
+ #i;
982
+ #a;
983
+ #o;
984
+ #s;
985
+ #c;
986
+ #l = 0;
987
+ constructor(e) {
988
+ this.context = e, this.#r = /* @__PURE__ */ new Set(), this.#i = /* @__PURE__ */ new Set(), this.#o = /* @__PURE__ */ new Set(), this.#s = /* @__PURE__ */ new Set();
989
+ for (let t of e.fields) (e.sectionTarget(t.section) === "props" ? this.#r : this.#i).add(t.key), t.kind === "color" && this.#o.add(t.key), t.kind === "number" && this.#s.add(t.key);
990
+ this.#a = new Set(e.data.kind === "rows" ? e.data.roles.map((e) => e.id) : []), this.#c = new Map((e.events ?? []).map((e) => [e.name, e]));
991
+ }
992
+ #u(e, t, n) {
993
+ this.diagnostics.push({
994
+ severity: "error",
995
+ code: "PLUGIN_CORE_MANIFEST_FIELD_INVALID",
996
+ path: ["template", ...t],
997
+ message: Ze(e, n)
998
+ });
999
+ }
1000
+ compile(e) {
1001
+ if (!R(e)) {
1002
+ this.#u("TPL4", [], "模板必须是对象。");
1003
+ return;
1004
+ }
1005
+ for (let t of Object.keys(e)) [
1006
+ "viewBox",
1007
+ "fit",
1008
+ "defs",
1009
+ "nodes",
1010
+ "animations"
1011
+ ].includes(t) || this.#u("TPL1", [t], `模板没有字段 ${t}。`);
1012
+ let t = e.viewBox, n = Array.isArray(t) && t.length === 4 && t.every((e) => typeof e == "number" && Number.isFinite(e)) && t[2] > 0 && t[3] > 0;
1013
+ n || this.#u("TPL4", ["viewBox"], "viewBox 必须是 [x, y, 宽, 高] 四个数字,宽高大于 0。");
1014
+ let r = e.fit ?? "contain";
1015
+ r !== "contain" && r !== "cover" && r !== "stretch" && this.#u("TPL4", ["fit"], "fit 只能是 contain / cover / stretch。");
1016
+ let i = this.#d(e.defs), a = {
1017
+ props: this.#r,
1018
+ style: this.#i,
1019
+ roles: this.#a,
1020
+ data: this.context.data.kind,
1021
+ inRepeat: !1,
1022
+ inRowRepeat: !1
1023
+ };
1024
+ if (!Array.isArray(e.nodes) || e.nodes.length === 0) {
1025
+ this.#u("TPL4", ["nodes"], "nodes 必须是非空数组。");
1026
+ return;
1027
+ }
1028
+ let o = this.#p(e.nodes, ["nodes"], a);
1029
+ this.#_();
1030
+ let s = this.#x(e.animations, a);
1031
+ if (n) return {
1032
+ viewBox: t,
1033
+ fit: r,
1034
+ gradients: i,
1035
+ nodes: o,
1036
+ animations: s,
1037
+ index: this.#e
1038
+ };
1039
+ }
1040
+ #d(e) {
1041
+ if (e === void 0) return [];
1042
+ if (!Array.isArray(e)) return this.#u("TPL4", ["defs"], "defs 必须是数组。"), [];
1043
+ e.length > P.gradients && this.#u("TPL3", ["defs"], `渐变最多 ${P.gradients} 个。`);
1044
+ let t = [];
1045
+ return e.forEach((e, n) => {
1046
+ let r = ["defs", n];
1047
+ if (!R(e) || e.kind !== "linearGradient" && e.kind !== "radialGradient") {
1048
+ this.#u("TPL1", r, "defs 里只能是 linearGradient / radialGradient。");
1049
+ return;
1050
+ }
1051
+ let i = e.kind === "linearGradient" ? [
1052
+ "x1",
1053
+ "y1",
1054
+ "x2",
1055
+ "y2"
1056
+ ] : [
1057
+ "cx",
1058
+ "cy",
1059
+ "r"
1060
+ ];
1061
+ for (let t of Object.keys(e)) [
1062
+ "kind",
1063
+ "id",
1064
+ "stops",
1065
+ ...i
1066
+ ].includes(t) || this.#u("TPL1", [...r, t], `${e.kind} 没有字段 ${t}。`);
1067
+ let a = e.id;
1068
+ if (typeof a != "string" || !Ve.test(a)) {
1069
+ this.#u("TPL4", [...r, "id"], "id 为小写字母开头的字母、数字、连字符(≤ 40)。");
1070
+ return;
1071
+ }
1072
+ this.#n.has(a) && this.#u("TPL4", [...r, "id"], `渐变 id ${a} 重复。`), this.#n.add(a);
1073
+ let o = e.kind === "linearGradient" ? {
1074
+ x1: 0,
1075
+ y1: 0,
1076
+ x2: 0,
1077
+ y2: 1
1078
+ } : {
1079
+ cx: .5,
1080
+ cy: .5,
1081
+ r: .5
1082
+ }, s = {};
1083
+ for (let t of i) {
1084
+ let n = e[t] ?? o[t];
1085
+ typeof n != "number" || !Number.isFinite(n) || n < -1 || n > 2 ? this.#u("TPL4", [...r, t], `${t} 是 -1 到 2 之间的数字(相对图形包围盒的比例)。`) : s[t] = n;
1086
+ }
1087
+ let c = [];
1088
+ !Array.isArray(e.stops) || e.stops.length < 2 || e.stops.length > 8 ? this.#u("TPL4", [...r, "stops"], "stops 是 2–8 个色标。") : e.stops.forEach((e, t) => {
1089
+ let n = [
1090
+ ...r,
1091
+ "stops",
1092
+ t
1093
+ ];
1094
+ if (!R(e)) {
1095
+ this.#u("TPL4", n, "色标必须是对象。");
1096
+ return;
1097
+ }
1098
+ for (let t of Object.keys(e)) [
1099
+ "offset",
1100
+ "color",
1101
+ "opacity"
1102
+ ].includes(t) || this.#u("TPL1", [...n, t], `色标没有字段 ${t}。`);
1103
+ let i = e.offset;
1104
+ (typeof i != "number" || i < 0 || i > 1) && this.#u("TPL4", [...n, "offset"], "offset 是 0–1 的数字。");
1105
+ let a = e.opacity ?? 1;
1106
+ (typeof a != "number" || a < 0 || a > 1) && this.#u("TPL4", [...n, "opacity"], "opacity 是 0–1 的数字。");
1107
+ let o = this.#w(e.color, [...n, "color"], this.#f(), !1);
1108
+ o !== void 0 && typeof i == "number" && typeof a == "number" && c.push({
1109
+ offset: i,
1110
+ color: o,
1111
+ opacity: a
1112
+ });
1113
+ }), t.push({
1114
+ kind: e.kind,
1115
+ id: a,
1116
+ geometry: s,
1117
+ stops: c
1118
+ });
1119
+ }), t;
1120
+ }
1121
+ #f() {
1122
+ return {
1123
+ props: this.#r,
1124
+ style: this.#i,
1125
+ roles: this.#a,
1126
+ data: this.context.data.kind,
1127
+ inRepeat: !1,
1128
+ inRowRepeat: !1
1129
+ };
1130
+ }
1131
+ #p(e, t, n) {
1132
+ let r = [];
1133
+ return e.forEach((e, i) => {
1134
+ let a = this.#m(e, [...t, i], n);
1135
+ a !== void 0 && r.push(a);
1136
+ }), r;
1137
+ }
1138
+ #m(e, t, n) {
1139
+ if (this.#l += 1, this.#l === P.nodes + 1 && this.#u("TPL3", t, `模板节点最多 ${P.nodes} 个。`), !R(e)) {
1140
+ this.#u("TPL4", t, "节点必须是对象。");
1141
+ return;
1142
+ }
1143
+ let r = e.kind;
1144
+ if (typeof r != "string" || !Ne.includes(r)) {
1145
+ this.#u("TPL1", [...t, "kind"], `不支持的节点 ${String(r)}(可用:${Ne.join("、")};不支持 foreignObject、image、use、script、style、filter)。`);
1146
+ return;
1147
+ }
1148
+ let i = r, a = e.id;
1149
+ if (typeof a != "string" || !Ve.test(a)) {
1150
+ this.#u("TPL4", [...t, "id"], "每个节点都要有 id:小写字母开头的字母、数字、连字符(≤ 40)。");
1151
+ return;
1152
+ }
1153
+ this.#t.has(a) && this.#u("TPL4", [...t, "id"], `节点 id ${a} 重复。`), this.#t.add(a);
1154
+ let o = /* @__PURE__ */ new Set([
1155
+ "kind",
1156
+ "id",
1157
+ ...F[i],
1158
+ ...ze[i],
1159
+ ...Fe.has(i) ? Be : []
1160
+ ]);
1161
+ for (let n of Object.keys(e)) if (!o.has(n)) {
1162
+ let e = /^on[A-Z]|^href$|^xlink|^style$|^class$|^filter$/.test(n) ? "(不支持事件属性、外部引用、样式字符串与滤镜)" : "";
1163
+ this.#u("TPL1", [...t, n], `${i} 没有字段 ${n}${e}。`);
1164
+ }
1165
+ let s = {};
1166
+ for (let r of F[i]) {
1167
+ if (e[r] === void 0) continue;
1168
+ let i = this.#C(e[r], [...t, r], n);
1169
+ i !== void 0 && (s[r] = i);
1170
+ }
1171
+ for (let n of Pe[i] ?? []) e[n] === void 0 && this.#u("TPL4", [...t, n], `${i} 缺少 ${n}。`);
1172
+ let c = {
1173
+ kind: i,
1174
+ id: a,
1175
+ path: t,
1176
+ num: s
1177
+ };
1178
+ if (Fe.has(i) && this.#h(e, i, t, n, c, s), i === "g" && e.opacity !== void 0) {
1179
+ let r = this.#C(e.opacity, [...t, "opacity"], n);
1180
+ r !== void 0 && (s.opacity = r);
1181
+ }
1182
+ switch (i) {
1183
+ case "text":
1184
+ this.#g(e, t, n, c, s);
1185
+ break;
1186
+ case "repeat": {
1187
+ let r = this.#b(e.source, [...t, "source"], n);
1188
+ r !== void 0 && (c.source = r);
1189
+ break;
1190
+ }
1191
+ case "when": {
1192
+ let r = this.#S(e.test, [...t, "test"], n);
1193
+ r !== void 0 && (c.test = r);
1194
+ break;
1195
+ }
1196
+ case "clip": {
1197
+ let r = e.shape;
1198
+ if (!R(r) || typeof r.kind != "string" || !Ie.has(r.kind)) this.#u("TPL4", [...t, "shape"], "clip.shape 必须是一个 rect / circle / ellipse / path 节点。");
1199
+ else {
1200
+ let e = this.#m(r, [...t, "shape"], n);
1201
+ e !== void 0 && (c.clipShape = e);
1202
+ }
1203
+ break;
1204
+ }
1205
+ case "polyline":
1206
+ this.#v(e, t, n, c);
1207
+ break;
1208
+ case "path":
1209
+ this.#y(e.d, [...t, "d"], n, c);
1210
+ break;
1211
+ case "arc": e.linecap !== void 0 && (typeof e.linecap != "string" || !Ye.has(e.linecap) ? this.#u("TPL4", [...t, "linecap"], "linecap 只能是 butt / round / square。") : c.linecap = e.linecap);
1212
+ }
1213
+ if (Le.has(i)) {
1214
+ let r = i === "repeat" ? {
1215
+ ...n,
1216
+ inRepeat: !0,
1217
+ inRowRepeat: n.inRowRepeat || c.source?.k === "rows"
1218
+ } : n;
1219
+ Array.isArray(e.children) ? c.children = this.#p(e.children, [...t, "children"], r) : this.#u("TPL4", [...t, "children"], `${i} 需要 children 数组。`);
1220
+ }
1221
+ let l = c;
1222
+ return this.#e.set(a, l), l;
1223
+ }
1224
+ #h(e, t, n, r, i, a) {
1225
+ if (e.fill !== void 0) {
1226
+ let t = this.#w(e.fill, [...n, "fill"], r, !0);
1227
+ t !== void 0 && (i.fill = t);
1228
+ }
1229
+ if (e.stroke !== void 0) {
1230
+ let t = this.#w(e.stroke, [...n, "stroke"], r, !0);
1231
+ t !== void 0 && (i.stroke = t);
1232
+ }
1233
+ for (let t of ["strokeWidth", "opacity"]) {
1234
+ if (e[t] === void 0) continue;
1235
+ let i = this.#C(e[t], [...n, t], r);
1236
+ i !== void 0 && (a[t] = i);
1237
+ }
1238
+ if (e.strokeDasharray !== void 0) {
1239
+ let t = e.strokeDasharray;
1240
+ !Array.isArray(t) || t.length === 0 || t.length > P.dash ? this.#u("TPL4", [...n, "strokeDasharray"], `strokeDasharray 是 1–${P.dash} 个数字。`) : i.dash = t.map((e, t) => this.#C(e, [
1241
+ ...n,
1242
+ "strokeDasharray",
1243
+ t
1244
+ ], r)).filter((e) => e !== void 0);
1245
+ }
1246
+ if (e.strokeLinecap !== void 0 && (typeof e.strokeLinecap != "string" || !Ye.has(e.strokeLinecap) ? this.#u("TPL4", [...n, "strokeLinecap"], "strokeLinecap 只能是 butt / round / square。") : i.linecap = e.strokeLinecap), e.on !== void 0) {
1247
+ let t = e.on, a = typeof t == "string" ? this.#c.get(t) : void 0;
1248
+ if (a === void 0) this.#u("TPL2", [...n, "on"], `on 必须是规格 events 里声明的事件名(当前:${[...this.#c.keys()].join("、") || "无"})。`);
1249
+ else {
1250
+ let e = [];
1251
+ for (let [t, i] of Object.entries(a.payload ?? {})) {
1252
+ let a = this.#S(i.value, [
1253
+ ...n,
1254
+ "on",
1255
+ t
1256
+ ], r);
1257
+ a !== void 0 && e.push({
1258
+ key: t,
1259
+ type: i.type,
1260
+ value: a
1261
+ });
1262
+ }
1263
+ i.on = {
1264
+ name: a.name,
1265
+ payload: e
1266
+ };
1267
+ }
1268
+ }
1269
+ }
1270
+ #g(e, t, n, r, i) {
1271
+ let a = this.#S(e.content, [...t, "content"], n, "文字内容是表达式:字面文字要加引号,如 \"'℃'\";读数用 format(value)。");
1272
+ a !== void 0 && (r.content = a);
1273
+ let o = i.fontSize;
1274
+ o !== void 0 && !this.#E(o) && this.#u("TPL5", [...t, "fontSize"], "字号只能是数字,或 props / style 数字字段的四则运算(不能随数据变化),体检才能检查最小字号。"), e.fontWeight !== void 0 && (typeof e.fontWeight != "number" || !Xe.has(e.fontWeight) ? this.#u("TPL4", [...t, "fontWeight"], "fontWeight 只能是 400 / 500 / 600 / 700。") : r.fontWeight = e.fontWeight);
1275
+ for (let [n, i] of [["anchor", qe], ["baseline", Je]]) {
1276
+ let a = e[n];
1277
+ a !== void 0 && (typeof a != "string" || !i.has(a) ? this.#u("TPL4", [...t, n], `${n} 只能是 ${[...i].join(" / ")}。`) : r[n] = a);
1278
+ }
1279
+ let s = e.backdrop;
1280
+ typeof s != "string" || s === "" ? this.#u("TPL6", [...t, "backdrop"], "文字必须声明底板 backdrop:某个填充节点的 id,或 container(组件背景)。") : r.backdrop = s;
1281
+ }
1282
+ #_() {
1283
+ for (let e of this.#e.values()) {
1284
+ if (e.kind !== "text" || e.backdrop === void 0 || e.backdrop === "container") continue;
1285
+ let t = this.#e.get(e.backdrop);
1286
+ (t === void 0 || !Re.has(t.kind) || t.fill === void 0) && this.#u("TPL6", [...e.path, "backdrop"], `backdrop「${e.backdrop}」必须是带 fill 的填充节点,或 container。`);
1287
+ }
1288
+ }
1289
+ #v(e, t, n, r) {
1290
+ let i = e.points;
1291
+ if (!R(i)) {
1292
+ this.#u("TPL4", [...t, "points"], "polyline.points 是 { source, x, y }:对每行(或每个序号)求一个点。");
1293
+ return;
1294
+ }
1295
+ for (let e of Object.keys(i)) [
1296
+ "source",
1297
+ "x",
1298
+ "y"
1299
+ ].includes(e) || this.#u("TPL1", [
1300
+ ...t,
1301
+ "points",
1302
+ e
1303
+ ], `points 没有字段 ${e}。`);
1304
+ let a = this.#b(i.source, [
1305
+ ...t,
1306
+ "points",
1307
+ "source"
1308
+ ], n);
1309
+ if (a === void 0) return;
1310
+ let o = {
1311
+ ...n,
1312
+ inRepeat: !0,
1313
+ inRowRepeat: n.inRowRepeat || a.k === "rows"
1314
+ }, s = this.#C(i.x, [
1315
+ ...t,
1316
+ "points",
1317
+ "x"
1318
+ ], o), c = this.#C(i.y, [
1319
+ ...t,
1320
+ "points",
1321
+ "y"
1322
+ ], o);
1323
+ s !== void 0 && c !== void 0 && (r.points = {
1324
+ source: a,
1325
+ x: s,
1326
+ y: c
1327
+ }), e.closed !== void 0 && (typeof e.closed == "boolean" ? r.closed = e.closed : this.#u("TPL4", [...t, "closed"], "closed 必须是布尔值。"));
1328
+ }
1329
+ #y(e, t, n, r) {
1330
+ if (!Array.isArray(e) || e.length === 0 || e.length > P.pathCommands) {
1331
+ this.#u("TPL4", t, `path.d 是 1–${P.pathCommands} 条命令,每条形如 ["L", x, y]。`);
1332
+ return;
1333
+ }
1334
+ let i = [];
1335
+ e.forEach((e, r) => {
1336
+ let a = [...t, r];
1337
+ if (!Array.isArray(e) || typeof e[0] != "string" || We[e[0]] === void 0) {
1338
+ this.#u("TPL4", a, "路径命令只能是 M / L / H / V / C / Q / A / Z(绝对坐标)。");
1339
+ return;
1340
+ }
1341
+ let o = e[0], s = We[o];
1342
+ if (e.length - 1 !== s) {
1343
+ this.#u("TPL4", a, `${o} 需要 ${s} 个参数。`);
1344
+ return;
1345
+ }
1346
+ let c = e.slice(1).map((e, t) => this.#C(e, [...a, t + 1], n)).filter((e) => e !== void 0);
1347
+ c.length === s && i.push([o, c]);
1348
+ }), r.d = i;
1349
+ }
1350
+ #b(e, t, n) {
1351
+ if (e === "rows") {
1352
+ if (this.context.data.kind !== "rows") {
1353
+ this.#u("TPL2", t, "组件不是多行数据,不能遍历 rows。");
1354
+ return;
1355
+ }
1356
+ return { k: "rows" };
1357
+ }
1358
+ if (R(e) && Object.keys(e).length === 1 && e.range !== void 0) {
1359
+ if (typeof e.range == "number" && e.range > P.repeat) {
1360
+ this.#u("TPL3", [...t, "range"], `repeat 最多 ${P.repeat} 次。`);
1361
+ return;
1362
+ }
1363
+ let r = this.#C(e.range, [...t, "range"], n);
1364
+ return r === void 0 ? void 0 : {
1365
+ k: "range",
1366
+ n: r
1367
+ };
1368
+ }
1369
+ this.#u("TPL4", t, "source 只能是 \"rows\" 或 { \"range\": 次数 }。");
1370
+ }
1371
+ #x(e, t) {
1372
+ if (e === void 0) return [];
1373
+ if (!Array.isArray(e)) return this.#u("TPL4", ["animations"], "animations 必须是数组。"), [];
1374
+ e.length > P.animations && this.#u("TPL3", ["animations"], `动画最多 ${P.animations} 个。`);
1375
+ let n = [];
1376
+ return e.forEach((e, r) => {
1377
+ let i = ["animations", r];
1378
+ if (!R(e) || e.kind !== "loop" && e.kind !== "change") {
1379
+ this.#u("TPL1", i, "动画只有 loop(循环)与 change(读数变化过渡)两种。");
1380
+ return;
1381
+ }
1382
+ let a = e.kind === "loop" ? [
1383
+ "kind",
1384
+ "target",
1385
+ "property",
1386
+ "from",
1387
+ "to",
1388
+ "duration",
1389
+ "easing",
1390
+ "alternate",
1391
+ "enabledBy"
1392
+ ] : [
1393
+ "kind",
1394
+ "target",
1395
+ "attributes",
1396
+ "duration",
1397
+ "easing"
1398
+ ];
1399
+ for (let t of Object.keys(e)) a.includes(t) || this.#u("TPL1", [...i, t], `${e.kind} 动画没有字段 ${t}。`);
1400
+ let o = typeof e.target == "string" ? this.#e.get(e.target) : void 0;
1401
+ if (o === void 0) {
1402
+ this.#u("TPL4", [...i, "target"], "target 必须是模板里某个节点的 id。");
1403
+ return;
1404
+ }
1405
+ let s = e.duration;
1406
+ if (typeof s != "number" || s < P.minDuration || s > P.maxDuration) {
1407
+ this.#u("TPL4", [...i, "duration"], `duration 是 ${P.minDuration}–${P.maxDuration} 毫秒。`);
1408
+ return;
1409
+ }
1410
+ let c = e.easing ?? (e.kind === "loop" ? "linear" : "ease-out");
1411
+ if (typeof c != "string" || !Ke.has(c)) {
1412
+ this.#u("TPL4", [...i, "easing"], `easing 只能是 ${[...Ke].join(" / ")}。`);
1413
+ return;
1414
+ }
1415
+ if (e.kind === "loop") {
1416
+ if (typeof e.property != "string" || !Ge.has(e.property)) {
1417
+ this.#u("TPL4", [...i, "property"], `循环动画只能改 ${[...Ge].join(" / ")}(只动组件内部,不动外框)。`);
1418
+ return;
1419
+ }
1420
+ let r = this.#C(e.from, [...i, "from"], t), a = this.#C(e.to, [...i, "to"], t);
1421
+ e.alternate !== void 0 && typeof e.alternate != "boolean" && this.#u("TPL4", [...i, "alternate"], "alternate 必须是布尔值。");
1422
+ let l = e.enabledBy === void 0 ? void 0 : this.#S(e.enabledBy, [...i, "enabledBy"], t);
1423
+ if (r === void 0 || a === void 0) return;
1424
+ n.push({
1425
+ kind: "loop",
1426
+ target: o.id,
1427
+ property: e.property,
1428
+ from: r,
1429
+ to: a,
1430
+ duration: s,
1431
+ easing: c,
1432
+ alternate: e.alternate === !0,
1433
+ ...l === void 0 ? {} : { enabledBy: l }
1434
+ });
1435
+ return;
1436
+ }
1437
+ let l = F[o.kind];
1438
+ if (!Array.isArray(e.attributes) || e.attributes.length === 0 || e.attributes.some((e) => typeof e != "string" || !l.includes(e))) {
1439
+ this.#u("TPL4", [...i, "attributes"], `${o.kind} 能补间的参数:${l.join("、") || "无"}。`);
1440
+ return;
1441
+ }
1442
+ n.push({
1443
+ kind: "change",
1444
+ target: o.id,
1445
+ attributes: e.attributes,
1446
+ duration: s,
1447
+ easing: c
1448
+ });
1449
+ }), n;
1450
+ }
1451
+ #S(e, t, n, r) {
1452
+ if (typeof e == "boolean" || typeof e == "number" && Number.isFinite(e)) return {
1453
+ k: "lit",
1454
+ v: e
1455
+ };
1456
+ if (typeof e != "string") {
1457
+ this.#u("TPL4", t, `需要一个表达式字符串${r === void 0 ? "" : `:${r}`}`);
1458
+ return;
1459
+ }
1460
+ let i = De(e, n);
1461
+ if (!i.ok) {
1462
+ this.#u("TPL2", t, `${i.message}${r === void 0 ? "" : ` ${r}`}`);
1463
+ return;
1464
+ }
1465
+ return i.value;
1466
+ }
1467
+ #C(e, t, n) {
1468
+ if (typeof e == "number") {
1469
+ if (!Number.isFinite(e)) {
1470
+ this.#u("TPL4", t, "数值必须是有限数字。");
1471
+ return;
1472
+ }
1473
+ return {
1474
+ k: "lit",
1475
+ v: e
1476
+ };
1477
+ }
1478
+ if (typeof e == "string") return this.#S(e, t, n);
1479
+ this.#u("TPL4", t, "数值参数写数字或表达式字符串。");
1480
+ }
1481
+ #w(e, t, n, r) {
1482
+ if (R(e) && Object.keys(e).length === 1 && typeof e.gradient == "string") {
1483
+ if (!r || !this.#n.has(e.gradient)) {
1484
+ this.#u("TPL4", t, `渐变「${e.gradient}」没有在 defs 里声明。`);
1485
+ return;
1486
+ }
1487
+ return {
1488
+ k: "gradient",
1489
+ id: e.gradient
1490
+ };
1491
+ }
1492
+ if (typeof e != "string") {
1493
+ this.#u("TPL5", t, "颜色写字面量(#rrggbb、rgba(...)、none)、style.<颜色字段>,或 { \"gradient\": \"渐变 id\" }。");
1494
+ return;
1495
+ }
1496
+ if (I.test(e.trim())) return {
1497
+ k: "color",
1498
+ v: e.trim()
1499
+ };
1500
+ if (/url\s*\(/i.test(e)) {
1501
+ this.#u("TPL1", t, "颜色里不能写 url(...):渐变用 { \"gradient\": \"id\" } 引用。");
1502
+ return;
1503
+ }
1504
+ let i = this.#S(e, t, n);
1505
+ if (i !== void 0) {
1506
+ if (!this.#T(i)) {
1507
+ this.#u("TPL5", t, "颜色表达式只能在字面量颜色与 style.<颜色字段> 之间选择(pick / 三元),不能由数据算出颜色;语义色请声明成样式字段,值可写 theme:danger。");
1508
+ return;
1509
+ }
1510
+ return {
1511
+ k: "expr",
1512
+ e: i
1513
+ };
1514
+ }
1515
+ }
1516
+ #T(e) {
1517
+ switch (e.k) {
1518
+ case "lit": return typeof e.v == "string" && I.test(e.v);
1519
+ case "ref": return e.root === "style" && e.key !== void 0 && this.#o.has(e.key);
1520
+ case "cond": return this.#T(e.a) && this.#T(e.b);
1521
+ case "call": return e.fn === "pick" && e.args.every((t, n) => n === 0 || n % 2 == 1 && n !== e.args.length - 1 || this.#T(t));
1522
+ default: return !1;
1523
+ }
1524
+ }
1525
+ #E(e) {
1526
+ switch (e.k) {
1527
+ case "lit": return typeof e.v == "number";
1528
+ case "ref": return (e.root === "props" || e.root === "style") && e.key !== void 0 && this.#s.has(e.key);
1529
+ case "un": return e.op === "-" && this.#E(e.a);
1530
+ case "bin": return [
1531
+ "+",
1532
+ "-",
1533
+ "*",
1534
+ "/"
1535
+ ].includes(e.op) && this.#E(e.a) && this.#E(e.b);
1536
+ case "call": return [
1537
+ "min",
1538
+ "max",
1539
+ "clamp",
1540
+ "round"
1541
+ ].includes(e.fn) && e.args.every((e) => this.#E(e));
1542
+ default: return !1;
1543
+ }
1544
+ }
1545
+ };
1546
+ function R(e) {
1547
+ return typeof e == "object" && !!e && !Array.isArray(e);
1548
+ }
1549
+ function $e(e, t) {
1550
+ if (e === void 0) return;
1551
+ if (!Array.isArray(e) || e.length > P.events) {
1552
+ t(["events"], `events 是最多 ${P.events} 个事件的数组。`);
1553
+ return;
1554
+ }
1555
+ let n = /* @__PURE__ */ new Set();
1556
+ e.forEach((e, r) => {
1557
+ let i = ["events", r];
1558
+ if (!R(e)) {
1559
+ t(i, "事件必须是对象。");
1560
+ return;
1561
+ }
1562
+ for (let n of Object.keys(e)) [
1563
+ "name",
1564
+ "label",
1565
+ "payload"
1566
+ ].includes(n) || t([...i, n], `未知字段 ${n}。`);
1567
+ if (typeof e.name != "string" || !He.test(e.name) ? t([...i, "name"], "事件名为小驼峰 ASCII(如 valueClick)。") : n.has(e.name) ? t([...i, "name"], `事件 ${e.name} 重复。`) : n.add(e.name), (typeof e.label != "string" || e.label.trim() === "" || [...e.label].length > 16) && t([...i, "label"], "事件标签为 1–16 个字符。"), e.payload !== void 0) {
1568
+ if (!R(e.payload) || Object.keys(e.payload).length > 6) {
1569
+ t([...i, "payload"], "payload 是最多 6 项的对象:{ 键: { type, value } }。");
1570
+ return;
1571
+ }
1572
+ for (let [n, r] of Object.entries(e.payload)) Ue.test(n) || t([
1573
+ ...i,
1574
+ "payload",
1575
+ n
1576
+ ], "负载键为小驼峰 ASCII。"), (!R(r) || r.type !== "number" && r.type !== "string" && r.type !== "boolean" || typeof r.value != "string" || Object.keys(r).some((e) => e !== "type" && e !== "value")) && t([
1577
+ ...i,
1578
+ "payload",
1579
+ n
1580
+ ], "负载项写 { \"type\": \"number\" | \"string\" | \"boolean\", \"value\": \"表达式\" }。");
1581
+ }
1582
+ });
1583
+ }
1584
+ //#endregion
1585
+ //#region ../plugin-sdk/dist/material-spec.js
1586
+ var z = [
1587
+ {
1588
+ id: "format",
1589
+ label: "读数格式",
1590
+ target: "props"
1591
+ },
1592
+ {
1593
+ id: "structure",
1594
+ label: "结构",
1595
+ target: "props"
1596
+ },
1597
+ {
1598
+ id: "text",
1599
+ label: "文字",
1600
+ target: "style"
1601
+ },
1602
+ {
1603
+ id: "surface",
1604
+ label: "填充与描边",
1605
+ target: "style"
1606
+ },
1607
+ {
1608
+ id: "semantic",
1609
+ label: "语义色",
1610
+ target: "style",
1611
+ collapsed: !0
1612
+ },
1613
+ {
1614
+ id: "motion",
1615
+ label: "动效",
1616
+ target: "props",
1617
+ advanced: !0
1618
+ }
1619
+ ], et = new Set(z.map((e) => e.id)), tt = /* @__PURE__ */ new Set([
1620
+ "number",
1621
+ "text",
1622
+ "boolean",
1623
+ "color",
1624
+ "choice"
1625
+ ]), nt = /* @__PURE__ */ new Set([
1626
+ "type",
1627
+ "name",
1628
+ "category",
1629
+ "keywords",
1630
+ "defaultSize",
1631
+ "rotate",
1632
+ "numberFormat",
1633
+ "fields",
1634
+ "data",
1635
+ "template",
1636
+ "isolated",
1637
+ "events",
1638
+ "statePresetKeys",
1639
+ "customSections"
1640
+ ]), rt = /* @__PURE__ */ new Set([
1641
+ "key",
1642
+ "label",
1643
+ "section",
1644
+ "kind",
1645
+ "default",
1646
+ "min",
1647
+ "max",
1648
+ "step",
1649
+ "unit",
1650
+ "options",
1651
+ "allowGradient",
1652
+ "visibleWhen",
1653
+ "help"
1654
+ ]), it = /* @__PURE__ */ new Set([
1655
+ "decimals",
1656
+ "maxDecimals",
1657
+ "thousandsSeparator",
1658
+ "prefix",
1659
+ "unit",
1660
+ "visibleWhen"
1661
+ ]), at = /* @__PURE__ */ new Set([
1662
+ "decimals",
1663
+ "prefix",
1664
+ "unit",
1665
+ "thousandsSeparator"
1666
+ ]), ot = /^[a-z][A-Za-z0-9]{0,39}$/, st = 24, ct = 16, lt = 4, ut = 6, dt = 200, ft = 12, pt = 16, mt = /* @__PURE__ */ new Set([
1667
+ "neq",
1668
+ "in",
1669
+ "not-in",
1670
+ "exists",
1671
+ "not-exists"
1672
+ ]), B = 64, V = 32, ht = 200, gt = 8, _t = 512, vt = 8, yt = 4096;
1673
+ function H(e) {
1674
+ let n = [], r = (e, t) => {
1675
+ n.push({
1676
+ severity: "error",
1677
+ code: "PLUGIN_CORE_MANIFEST_FIELD_INVALID",
1678
+ path: e,
1679
+ message: t
1680
+ });
1681
+ };
1682
+ if (!K(e)) return r([], "组件规格必须是对象。"), {
1683
+ ok: !1,
1684
+ diagnostics: n
1685
+ };
1686
+ for (let t of Object.keys(e)) nt.has(t) || r([t], `未知字段 ${t}。`);
1687
+ t(e.type) || r(["type"], "物料类型不合法(形如 host.online.gauge-1a2b)。"), s(e.name, B) || r(["name"], `名称为 1–${B} 个字符。`), s(e.category, B) || r(["category"], `分类为 1–${B} 个字符。`), (!Array.isArray(e.keywords) || e.keywords.length > ct || e.keywords.some((e) => !s(e, V))) && r(["keywords"], `关键词最多 ${ct} 个,每个 1–${V} 个字符。`);
1688
+ let i = e.defaultSize;
1689
+ (!K(i) || !Bt(i.width) || !Bt(i.height) || Object.keys(i).some((e) => e !== "width" && e !== "height")) && r(["defaultSize"], `默认尺寸的宽高为 ${vt}–${yt} 的数字。`), e.rotate !== void 0 && typeof e.rotate != "boolean" && r(["rotate"], "rotate 必须是布尔值。");
1690
+ let a = xt(e.customSections, r), o = Array.isArray(e.fields) ? e.fields : void 0;
1691
+ if (o === void 0 ? r(["fields"], "fields 必须是数组。") : o.length > st ? r(["fields"], `字段最多 ${st} 个。`) : St(o, a, r), e.numberFormat !== void 0 && bt(e.numberFormat, o ?? [], r), Tt(e.data, r), $e(e.events, r), e.statePresetKeys !== void 0) {
1692
+ let t = (e) => z.find((t) => t.id === e)?.target === "style" || a.get(e) === "style", n = new Set((o ?? []).flatMap((e) => K(e) && typeof e.key == "string" && typeof e.section == "string" && t(e.section) ? [e.key] : []));
1693
+ (!Array.isArray(e.statePresetKeys) || e.statePresetKeys.length > 8 || e.statePresetKeys.some((e) => typeof e != "string" || !n.has(e))) && r(["statePresetKeys"], "statePresetKeys 最多 8 个,每个都要是样式分区里声明的字段。");
1694
+ }
1695
+ if (e.isolated !== void 0) {
1696
+ let t = e.isolated, n = K(t) ? t.libraries : void 0;
1697
+ (!K(t) || Object.keys(t).some((e) => e !== "libraries") || n !== void 0 && (!Array.isArray(n) || n.length > 4 || new Set(n).size !== n.length || n.some((e) => typeof e != "string" || !/^[a-z][a-z0-9-]{0,31}$/.test(e)))) && r(["isolated"], "isolated 只能有 libraries:最多 4 个不重复的预置库名。"), e.template !== void 0 && r(["isolated"], "MATERIAL_ISOLATED_CONFLICT:template 与 isolated 互斥(L2 与 L3 只能二选一)。");
1698
+ }
1699
+ if (e.template !== void 0 && n.length === 0) {
1700
+ let t = e, r = L(e.template, {
1701
+ fields: t.fields,
1702
+ data: t.data,
1703
+ ...t.events === void 0 ? {} : { events: t.events },
1704
+ sectionTarget: (e) => W(t, e)
1705
+ });
1706
+ r.ok || n.push(...r.diagnostics);
1707
+ }
1708
+ return n.length > 0 ? {
1709
+ ok: !1,
1710
+ diagnostics: n
1711
+ } : {
1712
+ ok: !0,
1713
+ value: e,
1714
+ diagnostics: []
1715
+ };
1716
+ }
1717
+ function bt(e, t, n) {
1718
+ if (!K(e)) {
1719
+ n(["numberFormat"], "numberFormat 必须是对象。");
1720
+ return;
1721
+ }
1722
+ if (e.visibleWhen !== void 0) {
1723
+ let r = e.visibleWhen, i = t.find((e) => K(e) && K(r) && e.key === r.key);
1724
+ wt(r, i?.section === "format" ? i : void 0, ["numberFormat", "visibleWhen"], "读数格式分区里声明的字段", n);
1725
+ }
1726
+ for (let t of Object.keys(e)) it.has(t) || n(["numberFormat", t], `未知字段 ${t}。`);
1727
+ for (let t of ["decimals", "maxDecimals"]) {
1728
+ let r = e[t];
1729
+ r !== void 0 && (!Number.isInteger(r) || r < 0 || r > 6) && n(["numberFormat", t], `${t} 是 0–6 的整数。`);
1730
+ }
1731
+ e.thousandsSeparator !== void 0 && typeof e.thousandsSeparator != "boolean" && n(["numberFormat", "thousandsSeparator"], "thousandsSeparator 必须是布尔值。");
1732
+ for (let t of ["prefix", "unit"]) {
1733
+ let r = e[t];
1734
+ r !== void 0 && typeof r != "boolean" && (typeof r != "string" || [...r].length > 16) && n(["numberFormat", t], `${t} 是布尔值,或不超过 16 个字符的默认值。`);
1735
+ }
1736
+ }
1737
+ function xt(e, t) {
1738
+ if (e === void 0) return /* @__PURE__ */ new Map();
1739
+ if (!Array.isArray(e)) return t(["customSections"], "customSections 必须是数组。"), /* @__PURE__ */ new Map();
1740
+ if (e.length > lt) return t(["customSections"], `自定义分组最多 ${lt} 个。`), /* @__PURE__ */ new Map();
1741
+ let n = /* @__PURE__ */ new Map();
1742
+ return e.forEach((e, r) => {
1743
+ let i = ["customSections", r];
1744
+ if (!K(e)) {
1745
+ t(i, "自定义分组必须是对象。");
1746
+ return;
1747
+ }
1748
+ for (let n of Object.keys(e)) n !== "id" && n !== "label" && n !== "target" && n !== "advanced" && t([...i, n], `未知字段 ${n}。`);
1749
+ let a = e.id;
1750
+ typeof a != "string" || !ot.test(a) ? t([...i, "id"], "id 为小驼峰 ASCII(字母开头,最多 40 个字符)。") : et.has(a) ? t([...i, "id"], `${a} 与内置分区 id 冲突。`) : n.has(a) ? t([...i, "id"], `分组 id ${a} 重复。`) : n.set(a, e.target === "style" ? "style" : "props"), s(e.label, V) || t([...i, "label"], "标签为 1–32 个字符。"), e.target !== "props" && e.target !== "style" && t([...i, "target"], "target 只能是 props 或 style。"), e.advanced !== void 0 && e.advanced !== !0 && t([...i, "advanced"], "advanced 只能是 true。");
1751
+ }), n;
1752
+ }
1753
+ function St(e, t, n) {
1754
+ let r = /* @__PURE__ */ new Map(), i = new Set(Object.keys(a));
1755
+ e.forEach((e, a) => {
1756
+ let o = ["fields", a];
1757
+ if (!K(e)) {
1758
+ n(o, "字段必须是对象。");
1759
+ return;
1760
+ }
1761
+ for (let t of Object.keys(e)) rt.has(t) || n([...o, t], `未知字段 ${t}。`);
1762
+ let c = e.key;
1763
+ typeof c != "string" || !ot.test(c) ? n([...o, "key"], "键名为小驼峰 ASCII(字母开头,最多 40 个字符)。") : r.has(c) ? n([...o, "key"], `键名 ${c} 重复。`) : i.has(c) ? n([...o, "key"], `${c} 是引擎保留样式(公共区统一提供),物料不再声明。`) : at.has(c) && n([...o, "key"], `${c} 属于读数格式配置组:开启 numberFormat,不要手写同名字段。`), s(e.label, V) || n([...o, "label"], "标签为 1–32 个字符。"), (typeof e.section != "string" || !(et.has(e.section) || t.has(e.section))) && n([...o, "section"], "分区只能是内置 6 项(format / structure / text / surface / semantic / motion)或规格 customSections 中声明的自定义分组。");
1764
+ let l = e.kind;
1765
+ if (typeof l != "string" || !tt.has(l) ? n([...o, "kind"], "类型只能是 number / text / boolean / color / choice。") : Ct(e, l, o, n), e.help !== void 0 && !s(e.help, ht) && n([...o, "help"], `说明最多 ${ht} 个字符。`), e.visibleWhen !== void 0) {
1766
+ let t = e.visibleWhen;
1767
+ wt(t, K(t) && typeof t.key == "string" ? r.get(t.key) : void 0, [...o, "visibleWhen"], "更早声明的字段", n);
1768
+ }
1769
+ typeof c == "string" && !r.has(c) && r.set(c, e);
1770
+ });
1771
+ }
1772
+ function Ct(e, t, n, r) {
1773
+ let i = e.default, a = (i, a) => {
1774
+ for (let o of i) e[o] !== void 0 && t !== a && r([...n, o], `${o} 只用于 ${a} 字段。`);
1775
+ };
1776
+ switch (a([
1777
+ "min",
1778
+ "max",
1779
+ "step",
1780
+ "unit"
1781
+ ], "number"), a(["options"], "choice"), a(["allowGradient"], "color"), t) {
1782
+ case "number": {
1783
+ for (let t of [
1784
+ "min",
1785
+ "max",
1786
+ "step"
1787
+ ]) e[t] !== void 0 && !G(e[t]) && r([...n, t], `${t} 必须是数字。`);
1788
+ let t = e.min, a = e.max;
1789
+ t !== void 0 && a !== void 0 && t >= a && r([...n, "max"], "max 必须大于 min。"), e.step !== void 0 && e.step <= 0 && r([...n, "step"], "step 必须大于 0。"), e.unit !== void 0 && !s(e.unit, gt) && r([...n, "unit"], `单位最多 ${gt} 个字符。`), (!G(i) || t !== void 0 && i < t || a !== void 0 && i > a) && r([...n, "default"], "默认值必须是范围内的数字。");
1790
+ return;
1791
+ }
1792
+ case "boolean":
1793
+ typeof i != "boolean" && r([...n, "default"], "默认值必须是布尔值。");
1794
+ return;
1795
+ case "text":
1796
+ case "color":
1797
+ (typeof i != "string" || [...i].length > _t) && r([...n, "default"], `默认值必须是不超过 ${_t} 个字符的字符串。`), e.allowGradient !== void 0 && typeof e.allowGradient != "boolean" && r([...n, "allowGradient"], "allowGradient 必须是布尔值。");
1798
+ return;
1799
+ case "choice": {
1800
+ let t = e.options;
1801
+ !Array.isArray(t) || t.length < 2 || t.length > ft || t.some((e) => !s(e, V)) || new Set(t).size !== t.length ? r([...n, "options"], `选项为 2–${ft} 个互不相同的字符串。`) : (typeof i != "string" || !t.includes(i)) && r([...n, "default"], "默认值必须是选项之一。");
1802
+ }
1803
+ }
1804
+ }
1805
+ function wt(e, t, n, r, i) {
1806
+ let a = () => i(n, `visibleWhen 只能引用${r}:equals / neq / in / not-in 取该字段的合法值,exists / not-exists 不带取值。`);
1807
+ if (!K(e) || typeof e.key != "string" || t === void 0) {
1808
+ a();
1809
+ return;
1810
+ }
1811
+ if (Object.keys(e).some((e) => e !== "key" && e !== "equals" && e !== "operator" && e !== "value")) {
1812
+ a();
1813
+ return;
1814
+ }
1815
+ if (Object.hasOwn(e, "equals")) {
1816
+ if (Object.hasOwn(e, "operator") || Object.hasOwn(e, "value")) {
1817
+ a();
1818
+ return;
1819
+ }
1820
+ zt(t, e.equals) || a();
1821
+ return;
1822
+ }
1823
+ let o = e.operator;
1824
+ if (typeof o != "string" || !mt.has(o)) {
1825
+ a();
1826
+ return;
1827
+ }
1828
+ if (o === "exists" || o === "not-exists") {
1829
+ Object.hasOwn(e, "value") && a();
1830
+ return;
1831
+ }
1832
+ if (o === "neq") {
1833
+ zt(t, e.value) || a();
1834
+ return;
1835
+ }
1836
+ let s = e.value;
1837
+ (!Array.isArray(s) || s.length === 0 || s.length > pt || s.some((e) => !zt(t, e))) && a();
1838
+ }
1839
+ function Tt(e, t) {
1840
+ if (!K(e)) {
1841
+ t(["data"], "data 必须是对象。");
1842
+ return;
1843
+ }
1844
+ let n = (n) => {
1845
+ for (let r of Object.keys(e)) n.includes(r) || t(["data", r], `未知字段 ${r}。`);
1846
+ };
1847
+ switch (e.kind) {
1848
+ case "none":
1849
+ n(["kind"]);
1850
+ return;
1851
+ case "scalar":
1852
+ n([
1853
+ "kind",
1854
+ "valueType",
1855
+ "sample"
1856
+ ]), e.valueType !== "number" && e.valueType !== "string" ? t(["data", "valueType"], "单值类型只能是 number 或 string。") : (e.valueType === "number" ? !G(e.sample) : typeof e.sample != "string") && t(["data", "sample"], "示例值的类型须与单值类型一致。");
1857
+ return;
1858
+ case "rows": {
1859
+ n([
1860
+ "kind",
1861
+ "roles",
1862
+ "sample"
1863
+ ]);
1864
+ let r = e.roles, i = /* @__PURE__ */ new Set();
1865
+ !Array.isArray(r) || r.length === 0 || r.length > ut ? t(["data", "roles"], `角色为 1–${ut} 个。`) : (r.forEach((e, n) => {
1866
+ let r = [
1867
+ "data",
1868
+ "roles",
1869
+ n
1870
+ ];
1871
+ if (!K(e) || Object.keys(e).some((e) => ![
1872
+ "id",
1873
+ "label",
1874
+ "valueType",
1875
+ "optional"
1876
+ ].includes(e))) {
1877
+ t(r, "角色只包含 id / label / valueType / optional。");
1878
+ return;
1879
+ }
1880
+ typeof e.id != "string" || !ot.test(e.id) || i.has(e.id) ? t([...r, "id"], "角色 id 为互不相同的小驼峰 ASCII。") : i.add(e.id), s(e.label, V) || t([...r, "label"], "角色名为 1–32 个字符。"), e.valueType !== "number" && e.valueType !== "string" && t([...r, "valueType"], "角色类型只能是 number 或 string。"), e.optional !== void 0 && typeof e.optional != "boolean" && t([...r, "optional"], "optional 必须是布尔值。");
1881
+ }), r.every((e) => K(e) && e.optional === !0) && t(["data", "roles"], "至少有一个必填角色。"));
1882
+ let a = e.sample;
1883
+ !Array.isArray(a) || a.length > dt || a.some((e) => !K(e)) ? t(["data", "sample"], `示例行是最多 ${dt} 个对象的数组。`) : a.forEach((e, n) => {
1884
+ for (let [r, a] of Object.entries(e)) i.has(r) ? a !== null && typeof a != "string" && !G(a) && t([
1885
+ "data",
1886
+ "sample",
1887
+ n,
1888
+ r
1889
+ ], "示例单元格只能是字符串、数字或 null。") : t([
1890
+ "data",
1891
+ "sample",
1892
+ n,
1893
+ r
1894
+ ], `示例行的键 ${r} 不是角色 id。`);
1895
+ });
1896
+ return;
1897
+ }
1898
+ default: t(["data", "kind"], "数据形状只能是 none / scalar / rows。");
1899
+ }
1900
+ }
1901
+ function U(e, t) {
1902
+ let n = H(e);
1903
+ if (!n.ok) return n;
1904
+ let r = n.value, i = r.numberFormat === void 0 ? void 0 : he(Dt(r.numberFormat)), a = { ...i?.properties }, o = {}, s = { ...i?.defaults }, c = {}, l = /* @__PURE__ */ new Map();
1905
+ for (let e of r.fields) {
1906
+ let t = W(r, e.section);
1907
+ l.set(e.key, t), (t === "props" ? a : o)[e.key] = At(e), (t === "props" ? s : c)[e.key] = e.default;
1908
+ }
1909
+ let d = [], f = [...z, ...r.customSections ?? []];
1910
+ for (let e of f) {
1911
+ let t = [...r.fields.filter((t) => t.section === e.id).map((t) => jt(t, e.target, l)), ...e.id === "format" ? Ot(i?.fields ?? [], r.numberFormat) : []];
1912
+ t.length !== 0 && d.push({
1913
+ id: e.id,
1914
+ label: e.label,
1915
+ fields: t,
1916
+ ...e.collapsed === !0 ? { collapsed: !0 } : {},
1917
+ ...e.advanced === !0 ? { advanced: !0 } : {}
1918
+ });
1919
+ }
1920
+ let p = {
1921
+ type: r.type,
1922
+ tagName: t.tagName,
1923
+ name: r.name,
1924
+ category: r.category,
1925
+ keywords: [...r.keywords],
1926
+ defaultSize: {
1927
+ width: r.defaultSize.width,
1928
+ height: r.defaultSize.height
1929
+ },
1930
+ defaultProps: s,
1931
+ defaultStyle: c,
1932
+ propsSchema: {
1933
+ kind: "object",
1934
+ properties: a,
1935
+ required: Object.keys(a)
1936
+ },
1937
+ propertyPanel: [],
1938
+ styleSchema: {
1939
+ kind: "object",
1940
+ properties: o,
1941
+ required: Object.keys(o)
1942
+ },
1943
+ stylePanel: [],
1944
+ ...d.length === 0 && (r.events ?? []).length === 0 ? {} : { editorDescriptor: {
1945
+ ...d.length === 0 ? {} : { appearance: d },
1946
+ ...(r.events ?? []).length === 0 ? {} : { events: (r.events ?? []).map(Et) }
1947
+ } },
1948
+ events: (r.events ?? []).map((e) => e.name),
1949
+ ...r.statePresetKeys === void 0 || r.statePresetKeys.length === 0 ? {} : { statePresetKeys: [...r.statePresetKeys] },
1950
+ designCapabilities: {
1951
+ resize: !0,
1952
+ rotate: r.rotate ?? !0,
1953
+ children: !1
1954
+ },
1955
+ ...Mt(r.data),
1956
+ ...t.libraryVisible === !1 ? { libraryVisible: !1 } : {},
1957
+ ...t.cover === void 0 ? {} : { cover: t.cover }
1958
+ };
1959
+ return u(p);
1960
+ }
1961
+ function Et(e) {
1962
+ return {
1963
+ name: e.name,
1964
+ label: e.label,
1965
+ maxPayloadBytes: 4096,
1966
+ triggerContexts: ["blueprint"],
1967
+ requiredCapability: n,
1968
+ payloadSchema: {
1969
+ kind: "object",
1970
+ properties: Object.fromEntries(Object.entries(e.payload ?? {}).map(([e, t]) => [e, { kind: t.type }])),
1971
+ required: []
1972
+ }
1973
+ };
1974
+ }
1975
+ function Dt(e) {
1976
+ let { visibleWhen: t, ...n } = e;
1977
+ return n;
1978
+ }
1979
+ function Ot(e, t) {
1980
+ let n = t?.visibleWhen;
1981
+ return n === void 0 ? e : e.map((e) => ({
1982
+ ...e,
1983
+ when: [kt(n, void 0)]
1984
+ }));
1985
+ }
1986
+ function kt(e, t) {
1987
+ let n = {
1988
+ ...t === void 0 ? {} : { target: t },
1989
+ path: [e.key]
1990
+ };
1991
+ if ("equals" in e) return {
1992
+ ...n,
1993
+ operator: "eq",
1994
+ value: e.equals
1995
+ };
1996
+ switch (e.operator) {
1997
+ case "exists":
1998
+ case "not-exists": return {
1999
+ ...n,
2000
+ operator: e.operator
2001
+ };
2002
+ case "neq": return {
2003
+ ...n,
2004
+ operator: "neq",
2005
+ value: e.value
2006
+ };
2007
+ case "in":
2008
+ case "not-in": return {
2009
+ ...n,
2010
+ operator: e.operator,
2011
+ value: [...e.value]
2012
+ };
2013
+ }
2014
+ }
2015
+ function W(e, t) {
2016
+ let n = z.find((e) => e.id === t);
2017
+ return n === void 0 ? e.customSections?.find((e) => e.id === t)?.target ?? "props" : n.target;
2018
+ }
2019
+ function At(e) {
2020
+ switch (e.kind) {
2021
+ case "number": return {
2022
+ kind: "number",
2023
+ ...e.min === void 0 ? {} : { minimum: e.min },
2024
+ ...e.max === void 0 ? {} : { maximum: e.max }
2025
+ };
2026
+ case "boolean": return { kind: "boolean" };
2027
+ case "choice": return {
2028
+ kind: "enum",
2029
+ values: [...e.options ?? []]
2030
+ };
2031
+ case "text":
2032
+ case "color": return {
2033
+ kind: "string",
2034
+ maxLength: _t
2035
+ };
2036
+ }
2037
+ }
2038
+ function jt(e, t, n) {
2039
+ let r = e.visibleWhen, i = r === void 0 ? void 0 : n.get(r.key);
2040
+ return {
2041
+ id: e.key,
2042
+ target: t,
2043
+ path: [e.key],
2044
+ label: e.label,
2045
+ ...e.kind === "color" ? { control: "color" } : {},
2046
+ ...e.kind === "color" && e.allowGradient === !0 ? { allowGradient: !0 } : {},
2047
+ ...e.unit === void 0 ? {} : { unit: e.unit },
2048
+ ...e.step === void 0 ? {} : { step: e.step },
2049
+ ...e.help === void 0 ? {} : { help: e.help },
2050
+ ...r === void 0 ? {} : { when: [kt(r, i !== void 0 && i !== t ? i : void 0)] }
2051
+ };
2052
+ }
2053
+ function Mt(e) {
2054
+ switch (e.kind) {
2055
+ case "none": return { dataCapabilities: [] };
2056
+ case "scalar": return {
2057
+ dataCapabilities: [
2058
+ "static",
2059
+ "variable",
2060
+ "dataset"
2061
+ ],
2062
+ staticData: {
2063
+ kind: "scalar",
2064
+ valueType: e.valueType
2065
+ },
2066
+ defaultData: e.sample,
2067
+ dataBinding: { roles: [{
2068
+ id: Nt,
2069
+ minFields: 1,
2070
+ maxFields: 1,
2071
+ valueTypes: e.valueType === "number" ? ["number", "string"] : [
2072
+ "string",
2073
+ "number",
2074
+ "date"
2075
+ ]
2076
+ }] }
2077
+ };
2078
+ case "rows": return {
2079
+ dataCapabilities: ["static", "dataset"],
2080
+ staticData: {
2081
+ kind: "tabular",
2082
+ defaultBinding: { fields: Object.fromEntries(e.roles.map((e) => [e.id, [e.id]])) }
2083
+ },
2084
+ defaultData: Pt(e),
2085
+ dataBinding: { roles: e.roles.map((e) => ({
2086
+ id: e.id,
2087
+ minFields: e.optional === !0 ? 0 : 1,
2088
+ maxFields: 1,
2089
+ valueTypes: e.valueType === "number" ? ["number"] : [
2090
+ "string",
2091
+ "number",
2092
+ "date",
2093
+ "boolean"
2094
+ ]
2095
+ })) }
2096
+ };
2097
+ }
2098
+ }
2099
+ var Nt = "value";
2100
+ function Pt(e) {
2101
+ return {
2102
+ fields: e.roles.map((e) => ({
2103
+ id: e.id,
2104
+ label: e.label,
2105
+ valueType: e.valueType,
2106
+ nullable: e.optional === !0
2107
+ })),
2108
+ rows: e.sample.map((t) => Object.fromEntries(e.roles.map((e) => [e.id, t[e.id] ?? null])))
2109
+ };
2110
+ }
2111
+ function Ft(e) {
2112
+ if (e.kind !== "none") return e.kind === "scalar" ? { adapt({ dataset: t, fields: n }) {
2113
+ let r = n[Nt]?.[0], i = t.rows[0];
2114
+ return r === void 0 ? Rt("单值组件需要绑定一列。") : i === void 0 ? {
2115
+ ok: !0,
2116
+ value: null,
2117
+ diagnostics: []
2118
+ } : {
2119
+ ok: !0,
2120
+ value: Lt(i[r.id], e.valueType),
2121
+ diagnostics: []
2122
+ };
2123
+ } } : { adapt({ dataset: t, fields: n }) {
2124
+ for (let t of e.roles) if (t.optional !== !0 && (n[t.id]?.length ?? 0) === 0) return Rt(`角色「${t.label}」需要绑定一列。`);
2125
+ let r = t.rows.map((t) => Object.fromEntries(e.roles.map((e) => {
2126
+ let r = n[e.id]?.[0];
2127
+ return [e.id, r === void 0 ? null : Lt(t[r.id], e.valueType)];
2128
+ })));
2129
+ return {
2130
+ ok: !0,
2131
+ value: {
2132
+ rows: r,
2133
+ total: r.length
2134
+ },
2135
+ diagnostics: []
2136
+ };
2137
+ } };
2138
+ }
2139
+ function It(e, t) {
2140
+ return e.kind === "none" ? {
2141
+ value: null,
2142
+ rows: []
2143
+ } : e.kind === "scalar" ? {
2144
+ value: Lt(t, e.valueType),
2145
+ rows: []
2146
+ } : {
2147
+ value: null,
2148
+ rows: (K(t) && Array.isArray(t.rows) ? t.rows : Array.isArray(t) ? t : []).filter(K).map((t) => Object.fromEntries(e.roles.map((e) => [e.id, Lt(t[e.id], e.valueType)])))
2149
+ };
2150
+ }
2151
+ function Lt(e, t) {
2152
+ if (e == null) return null;
2153
+ if (t === "number") {
2154
+ let t = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
2155
+ return Number.isFinite(t) ? t : null;
2156
+ }
2157
+ return typeof e == "string" ? e : typeof e == "number" || typeof e == "boolean" ? String(e) : null;
2158
+ }
2159
+ function Rt(e) {
2160
+ return {
2161
+ ok: !1,
2162
+ diagnostics: [{
2163
+ severity: "error",
2164
+ code: "HOST_DATASET_BINDING_INVALID",
2165
+ path: [],
2166
+ message: e
2167
+ }]
2168
+ };
2169
+ }
2170
+ function zt(e, t) {
2171
+ return e.kind === "boolean" ? typeof t == "boolean" : Array.isArray(e.options) && typeof t == "string" && e.options.includes(t);
2172
+ }
2173
+ function Bt(e) {
2174
+ return G(e) && e >= vt && e <= yt;
2175
+ }
2176
+ function G(e) {
2177
+ return typeof e == "number" && Number.isFinite(e);
2178
+ }
2179
+ function K(e) {
2180
+ return typeof e == "object" && !!e && !Array.isArray(e);
2181
+ }
2182
+ //#endregion
2183
+ //#region ../plugin-sdk/dist/material-editor-audit.js
2184
+ var Vt = 12, Ht = new Set(z.map((e) => e.id)), Ut = 12, Wt = /* @__PURE__ */ new Set([
2185
+ "array",
2186
+ "repeatable-array",
2187
+ "reorderable-array"
2188
+ ]);
2189
+ function Gt(e) {
2190
+ let t = [], n = (n, r, i) => {
2191
+ t.push({
2192
+ rule: n,
2193
+ materialType: e.type,
2194
+ ...i === void 0 ? {} : { field: i.id },
2195
+ message: r
2196
+ });
2197
+ };
2198
+ ((e.propertyPanel ?? []).length > 0 || (e.stylePanel ?? []).length > 0) && n("R12", "仍声明扁平 propertyPanel / stylePanel;改为 editorDescriptor。");
2199
+ let r = e.editorDescriptor;
2200
+ for (let e of r?.appearance ?? []) e.id === "motion" && e.advanced !== !0 && n("R15", "「动效」分区应标 advanced:动效属于仅全量可见的效果类设置。"), e.id !== "motion" && e.advanced === !0 && Ht.has(e.id) && n("R15", `内置分区「${e.label}」不能标 advanced:内置分区里只有动效仅全量可见。`);
2201
+ let i = [
2202
+ r?.appearance,
2203
+ r?.data,
2204
+ r?.interaction
2205
+ ];
2206
+ for (let t of i) for (let r of t ?? []) for (let t of r.fields) {
2207
+ Kt(t, Xt(e, t), n);
2208
+ let r = Zt(e, t);
2209
+ for (let i of t.itemFields ?? []) Kt(i, i.target === "interaction" ? i.projection === "style" ? e.styleSchema : e.propsSchema : i.target === "props" || i.target === "style" ? r : void 0, n);
2210
+ }
2211
+ let a = (r?.appearance ?? []).flatMap((e) => Qt(e));
2212
+ return a.length > Vt && n("R9", `基础密度下可见字段 ${a.length} 个,超过 ${Vt} 个。`), Jt(e, n), t;
2213
+ }
2214
+ function Kt(e, t, n) {
2215
+ let r = t === void 0 ? void 0 : c(e.path, t);
2216
+ e.advanced === !0 && n("R15", `字段「${e.label}」不能单独标 advanced;整段隐藏或保持可见。`, e);
2217
+ let i = l(e, r);
2218
+ i !== void 0 && !qt(e.control, i, r) && n("R11", `控件是 ${e.control},按字段语义应为 ${i}(可省略 control)。`, e);
2219
+ let a = e.label;
2220
+ $t(a) > Ut && n("R13", `标签「${a}」超过 6 个汉字。`, e), a.includes("是否") && n("R13", `标签「${a}」不写「是否」。`, e), /[(())]|\b(?:px|ms)\b|%/.test(a) && n("R13", `标签「${a}」不带括号或单位,单位写进 unit。`, e), e.control === "color" && !a.endsWith("色") && n("R13", `颜色字段「${a}」应以「色」结尾。`, e), e.control === "boolean" && /^(?:不|禁用|隐藏)/.test(a) && n("R13", `开关「${a}」用正向表述。`, e);
2221
+ }
2222
+ function qt(e, t, n) {
2223
+ return e === t || e === "custom" || e === "json" || e === "group" || Wt.has(e) && n?.kind === "array" || n?.kind === "string" && (e === "text" || e === "color" || e === "field-selector") ? !0 : n?.kind === "enum" && e === "segmented" && n.values.length <= 3;
2224
+ }
2225
+ function Jt(e, t) {
2226
+ let n = (e.editorDescriptor?.appearance ?? []).flatMap((e) => e.fields);
2227
+ for (let [r, i] of Yt) {
2228
+ let a = e.propsSchema.properties[r];
2229
+ if (a === void 0) continue;
2230
+ if (a.kind !== i.schema.kind) {
2231
+ t("R14", `props.${r} 是配置组「${i.group}」的键,类型应为 ${i.schema.kind}。`);
2232
+ continue;
2233
+ }
2234
+ let o = n.find((e) => e.target === "props" && e.path.length === 1 && e.path[0] === r);
2235
+ o === void 0 ? t("R14", `props.${r} 属于配置组「${i.group}」,检查器里缺少该字段。`) : o.label !== i.label && t("R14", `props.${r} 的标签应为配置组的「${i.label}」。`, o);
2236
+ }
2237
+ }
2238
+ var Yt = new Map([
2239
+ he({
2240
+ prefix: !0,
2241
+ unit: !0,
2242
+ thousandsSeparator: !0
2243
+ }),
2244
+ _e(),
2245
+ ve()
2246
+ ].flatMap((e) => e.fields.map((t) => {
2247
+ let n = String(t.path[0]), r = e.properties[n];
2248
+ return [n, {
2249
+ group: e.id,
2250
+ label: t.label,
2251
+ schema: r
2252
+ }];
2253
+ })));
2254
+ function Xt(e, t) {
2255
+ let n = t.target === "interaction" ? t.projection : t.target;
2256
+ if (n === "props") return e.propsSchema;
2257
+ if (n === "style") return e.styleSchema;
2258
+ }
2259
+ function Zt(e, t) {
2260
+ let n = Xt(e, t), r = n === void 0 ? void 0 : c(t.path, n);
2261
+ return r?.kind === "array" && r.items.kind === "object" ? r.items : void 0;
2262
+ }
2263
+ function Qt(e) {
2264
+ return e.collapsed === !0 || e.advanced === !0 ? [] : e.fields.filter((e) => e.advanced !== !0);
2265
+ }
2266
+ function $t(e) {
2267
+ let t = 0;
2268
+ for (let n of e) t += (n.codePointAt(0) ?? 0) > 11904 ? 2 : 1;
2269
+ return t;
2270
+ }
2271
+ //#endregion
2272
+ //#region ../plugin-sdk/dist/material-isolated-csp.js
2273
+ var en = [
2274
+ "default-src 'none'",
2275
+ "style-src 'unsafe-inline'",
2276
+ "img-src data: blob:",
2277
+ "font-src data:",
2278
+ "base-uri 'none'",
2279
+ "form-action 'none'"
2280
+ ], tn = /^'sha256-[A-Za-z0-9+/]{43}='$/, nn = /^[0-9a-f]{64}$/, rn = 16;
2281
+ function an(e) {
2282
+ return Array.isArray(e) && e.length > 0 && e.length <= 16 && e.every((e) => typeof e == "string" && tn.test(e));
2283
+ }
2284
+ function on(e) {
2285
+ return [
2286
+ en[0],
2287
+ `script-src ${e.join(" ")}`,
2288
+ ...en.slice(1)
2289
+ ].join("; ");
2290
+ }
2291
+ function sn(e, t) {
2292
+ if (an(e) && !(t.trim() === "" || /[;,\r\n]/.test(t))) return [
2293
+ "sandbox allow-scripts",
2294
+ on(e),
2295
+ `frame-ancestors ${t.trim()}`
2296
+ ].join("; ");
2297
+ }
2298
+ var cn = {
2299
+ "Content-Type": "text/html; charset=utf-8",
2300
+ "X-Content-Type-Options": "nosniff",
2301
+ "Referrer-Policy": "no-referrer",
2302
+ "Cache-Control": "public, max-age=31536000, immutable",
2303
+ "Cross-Origin-Resource-Policy": "same-site"
2304
+ };
2305
+ //#endregion
2306
+ //#region ../plugin-sdk/dist/material-isolated-runtime.js
2307
+ function ln(e) {
2308
+ let t = globalThis, n = /* @__PURE__ */ new Map(), r = 1e3 / e.maxFps - 1, i = null, a = typeof window.name == "string" ? window.name : "";
2309
+ try {
2310
+ window.name = "";
2311
+ } catch {}
2312
+ let o = (e, t) => String(e).slice(0, t), s = [], c = (e, t = []) => {
2313
+ if (i === null) {
2314
+ let t = e?.type;
2315
+ (t === "error" || t === "csp") && s.length < 20 && s.push(e);
2316
+ return;
2317
+ }
2318
+ try {
2319
+ i.postMessage(e, t);
2320
+ } catch {}
2321
+ }, l = (e, t) => {
2322
+ let n = o(t?.message ?? t, 200);
2323
+ c(e === void 0 ? {
2324
+ type: "error",
2325
+ message: n
2326
+ } : {
2327
+ type: "error",
2328
+ id: e,
2329
+ message: n
2330
+ });
2331
+ };
2332
+ document.addEventListener("securitypolicyviolation", (e) => {
2333
+ c({
2334
+ type: "csp",
2335
+ directive: o(e.effectiveDirective, 64),
2336
+ uri: o(e.blockedURI, 200)
2337
+ });
2338
+ }), window.addEventListener("error", (e) => l(void 0, e.message)), window.addEventListener("unhandledrejection", (e) => l(void 0, e.reason)), window.addEventListener("message", (e) => {
2339
+ if (i !== null || e.source !== window.parent) return;
2340
+ let t = e.data;
2341
+ if (!(typeof t != "object" || !t || t.type !== "bs-connect") && a !== "" && t.token === a && e.ports.length === 1) {
2342
+ i = e.ports[0], i.onmessage = (e) => {
2343
+ try {
2344
+ p(e.data);
2345
+ } catch (e) {
2346
+ l(void 0, e);
2347
+ }
2348
+ }, c({ type: "ready" });
2349
+ for (let e of s.splice(0)) c(e);
2350
+ }
2351
+ });
2352
+ let u = () => {
2353
+ let n = {};
2354
+ for (let [r, i] of e.libraries) n[r] = t[i];
2355
+ return Object.freeze(n);
2356
+ };
2357
+ function d(e) {
2358
+ return Object.freeze({
2359
+ size: Object.freeze({
2360
+ width: e.w,
2361
+ height: e.h
2362
+ }),
2363
+ dpr: e.dpr,
2364
+ props: e.props,
2365
+ style: e.style,
2366
+ mode: e.mode,
2367
+ value: e.value,
2368
+ rows: e.rows,
2369
+ interactive: e.interactive
2370
+ });
2371
+ }
2372
+ function f(e) {
2373
+ let t = Math.max(1, Math.round(e.state.w * e.state.dpr)), n = Math.max(1, Math.round(e.state.h * e.state.dpr));
2374
+ e.canvas.width !== t && (e.canvas.width = t), e.canvas.height !== n && (e.canvas.height = n), e.container !== null && (e.container.style.width = `${e.state.w}px`, e.container.style.height = `${e.state.h}px`);
2375
+ }
2376
+ function p(e) {
2377
+ if (typeof e != "object" || !e) return;
2378
+ if (e.type === "tick") {
2379
+ h(e.now, Array.isArray(e.ids) ? e.ids : []);
2380
+ return;
2381
+ }
2382
+ if (e.type === "mount") {
2383
+ m(e.id, e.state);
2384
+ return;
2385
+ }
2386
+ let t = n.get(e.id);
2387
+ if (t !== void 0) {
2388
+ if (e.type === "update") {
2389
+ let n = t.state;
2390
+ if (t.state = e.state, (n.w !== e.state.w || n.h !== e.state.h || n.dpr !== e.state.dpr) && f(t), t.updated = !0, t.impl === null) return;
2391
+ try {
2392
+ t.impl.update?.(d(e.state));
2393
+ } catch (t) {
2394
+ l(e.id, t);
2395
+ }
2396
+ return;
2397
+ }
2398
+ if (e.type === "pointer") {
2399
+ try {
2400
+ t.impl?.click?.(e.x, e.y);
2401
+ } catch (t) {
2402
+ l(e.id, t);
2403
+ }
2404
+ return;
2405
+ }
2406
+ if (e.type === "unmount") {
2407
+ try {
2408
+ t.impl?.dispose?.();
2409
+ } catch {}
2410
+ t.container?.remove(), n.delete(e.id);
2411
+ }
2412
+ }
2413
+ }
2414
+ function m(e, r) {
2415
+ let i = {
2416
+ id: e,
2417
+ state: r,
2418
+ canvas: new OffscreenCanvas(1, 1),
2419
+ container: null,
2420
+ impl: null,
2421
+ updated: !0,
2422
+ shipping: !1,
2423
+ lastShip: -Infinity
2424
+ };
2425
+ f(i), n.set(e, i);
2426
+ let a = t.__bsCreate;
2427
+ if (typeof a != "function") {
2428
+ l(e, "组件代码没有导出 create(env)。");
2429
+ return;
2430
+ }
2431
+ let s = d(r), p = Object.freeze({
2432
+ ...s,
2433
+ canvas: i.canvas,
2434
+ libraries: u(),
2435
+ formatNumber: (e) => t.__bsFormat(e, i.state.props),
2436
+ emit: (t, n) => c({
2437
+ type: "event",
2438
+ id: e,
2439
+ name: o(t, 128),
2440
+ payload: n
2441
+ }),
2442
+ createContainer: () => {
2443
+ if (i.container === null) {
2444
+ let e = document.createElement("div");
2445
+ e.style.cssText = "position:absolute;left:0;top:0;overflow:hidden", document.body.appendChild(e), i.container = e, f(i);
2446
+ }
2447
+ return i.container;
2448
+ }
2449
+ });
2450
+ try {
2451
+ let t = a(p);
2452
+ if (typeof t != "object" || !t || typeof t.frame != "function") {
2453
+ l(e, "create(env) 必须返回带 frame(now) 的对象。");
2454
+ return;
2455
+ }
2456
+ i.impl = t;
2457
+ } catch (t) {
2458
+ l(e, t);
2459
+ }
2460
+ }
2461
+ function h(e, t) {
2462
+ let i = [];
2463
+ for (let a of t) {
2464
+ let t = n.get(a);
2465
+ if (t !== void 0 && t.impl !== null) {
2466
+ if (!t.shipping && e - t.lastShip >= r) {
2467
+ let n = !1;
2468
+ try {
2469
+ n = t.impl.frame(e) !== !1;
2470
+ } catch (e) {
2471
+ l(a, e);
2472
+ continue;
2473
+ }
2474
+ (n || t.updated) && g(t, e);
2475
+ }
2476
+ t.updated && i.push(a);
2477
+ }
2478
+ }
2479
+ c({
2480
+ type: "tock",
2481
+ pending: i
2482
+ });
2483
+ }
2484
+ function g(e, t) {
2485
+ let r = e.canvas;
2486
+ try {
2487
+ r = e.impl.surface?.() ?? e.canvas;
2488
+ } catch (t) {
2489
+ l(e.id, t);
2490
+ return;
2491
+ }
2492
+ r != null && r.width !== 0 && r.height !== 0 && (e.shipping = !0, e.updated = !1, e.lastShip = t, createImageBitmap(r).then((t) => {
2493
+ if (e.shipping = !1, !n.has(e.id)) {
2494
+ t.close();
2495
+ return;
2496
+ }
2497
+ c({
2498
+ type: "bitmap",
2499
+ id: e.id,
2500
+ bitmap: t
2501
+ }, [t]);
2502
+ }, (t) => {
2503
+ e.shipping = !1, e.updated = !0, l(e.id, t);
2504
+ }));
2505
+ }
2506
+ }
2507
+ //#endregion
2508
+ //#region ../plugin-sdk/dist/material-template-render.js
2509
+ var q = "http://www.w3.org/2000/svg", un = 0;
2510
+ function dn(e) {
2511
+ un += 1;
2512
+ let t = `tpl${un.toString(36)}`, n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), a = new Map(e.animations.filter((e) => e.kind === "loop").map((e) => [e.target, !0])), o = new Map(e.animations.flatMap((e) => e.kind === "change" ? [[e.target, e]] : []));
2513
+ return (s) => {
2514
+ let c = {
2515
+ value: s.value,
2516
+ rows: s.rows,
2517
+ props: s.props,
2518
+ style: s.style,
2519
+ size: s.size,
2520
+ formatNumber: s.formatNumber,
2521
+ budget: { steps: be }
2522
+ }, l = s.document, [u, d, f, p] = e.viewBox, m = l.createElementNS(q, "svg");
2523
+ m.setAttribute("viewBox", `${u} ${d} ${f} ${p}`), m.setAttribute("preserveAspectRatio", e.fit === "cover" ? "xMidYMid slice" : e.fit === "stretch" ? "none" : "xMidYMid meet"), m.setAttribute("width", "100%"), m.setAttribute("height", "100%"), m.style.display = "block", m.style.overflow = "hidden";
2524
+ let h = Math.max(1, s.size.width), g = Math.max(1, s.size.height), _ = e.fit === "cover" ? Math.min(f / h, p / g) : e.fit === "stretch" ? p / g : Math.max(f / h, p / g), v = s.interactive && !(l.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1), y = l.createElementNS(q, "defs");
2525
+ m.appendChild(y);
2526
+ for (let n of e.gradients) {
2527
+ let e = l.createElementNS(q, n.kind);
2528
+ e.setAttribute("id", `${t}-${n.id}`), e.setAttribute("gradientUnits", "objectBoundingBox");
2529
+ for (let [t, r] of Object.entries(n.geometry)) e.setAttribute(t, Y(r));
2530
+ for (let r of n.stops) {
2531
+ let n = mn(r.color, c, t);
2532
+ if (n === void 0) continue;
2533
+ let i = l.createElementNS(q, "stop");
2534
+ i.setAttribute("offset", Y(r.offset)), i.setAttribute("stop-color", n), r.opacity < 1 && i.setAttribute("stop-opacity", Y(r.opacity)), e.appendChild(i);
2535
+ }
2536
+ y.appendChild(e);
2537
+ }
2538
+ let b = [], x = [], S = (e, n, r, i) => {
2539
+ let a = i === "" ? e.id : `${e.id}#${i}`;
2540
+ switch (e.kind) {
2541
+ case "repeat": {
2542
+ let t = e.children ?? [], a = fn(e, n, s.rows.length);
2543
+ for (let o = 0; o < a; o += 1) {
2544
+ let c = {
2545
+ ...n,
2546
+ index: o,
2547
+ count: a,
2548
+ ...e.source?.k === "rows" ? { row: s.rows[o] } : {}
2549
+ };
2550
+ for (let e of t) S(e, c, r, i === "" ? `${o}` : `${i}.${o}`);
2551
+ }
2552
+ return;
2553
+ }
2554
+ case "when":
2555
+ if (e.test === void 0 || !M(w(e.test, n))) return;
2556
+ for (let t of e.children ?? []) S(t, n, r, i);
2557
+ return;
2558
+ case "clip": {
2559
+ let o = `${t}-${e.id}${i === "" ? "" : `-${i.replace(/\./g, "-")}`}`, s = l.createElementNS(q, "clipPath");
2560
+ if (s.setAttribute("id", o), e.clipShape !== void 0) {
2561
+ let t = te(e.clipShape, n);
2562
+ t !== void 0 && s.appendChild(t.element);
2563
+ }
2564
+ y.appendChild(s);
2565
+ let c = l.createElementNS(q, "g");
2566
+ c.setAttribute("clip-path", `url(#${o})`), C(e, c, r, a, n);
2567
+ for (let t of e.children ?? []) S(t, n, c, i);
2568
+ return;
2569
+ }
2570
+ case "g": {
2571
+ let t = l.createElementNS(q, "g"), o = re(e, n), s = (e) => hn(t, e);
2572
+ s(o), Number.isFinite(o.opacity) && t.setAttribute("opacity", Y(Tn(o.opacity))), ee(e, a, o, s), C(e, t, r, a, n);
2573
+ for (let r of e.children ?? []) S(r, n, t, i);
2574
+ return;
2575
+ }
2576
+ default: {
2577
+ let t = te(e, n);
2578
+ if (t === void 0) return;
2579
+ ee(e, a, t.params, t.apply), C(e, t.element, r, a, n);
2580
+ }
2581
+ }
2582
+ }, C = (e, t, n, r, o) => {
2583
+ if (t.setAttribute("data-template-node", e.id), e.on !== void 0 && s.interactive) {
2584
+ let n = e.on, r = {};
2585
+ for (let e of n.payload) {
2586
+ let t = w(e.value, o);
2587
+ r[e.key] = e.type === "number" ? wn(A(t)) : e.type === "boolean" ? M(t) : t === null ? "" : String(t);
2588
+ }
2589
+ t.style.cursor = "pointer", t.addEventListener("click", () => {
2590
+ t.dispatchEvent(new CustomEvent(i, {
2591
+ bubbles: !0,
2592
+ composed: !0,
2593
+ detail: {
2594
+ name: n.name,
2595
+ payload: r
2596
+ }
2597
+ }));
2598
+ });
2599
+ }
2600
+ if (a.has(e.id)) {
2601
+ let r = l.createElementNS(q, "g");
2602
+ r.appendChild(t), n.appendChild(r), x.push({
2603
+ element: r,
2604
+ target: e.id,
2605
+ env: o
2606
+ });
2607
+ return;
2608
+ }
2609
+ n.appendChild(t);
2610
+ }, ee = (e, t, i, a) => {
2611
+ let s = o.get(e.id);
2612
+ if (s === void 0) return;
2613
+ let c = {};
2614
+ for (let e of s.attributes) {
2615
+ let t = i[e];
2616
+ t !== void 0 && Number.isFinite(t) && (c[e] = t);
2617
+ }
2618
+ let u = n.get(t);
2619
+ if (n.set(t, c), !v || u === void 0) {
2620
+ r.delete(t);
2621
+ return;
2622
+ }
2623
+ let d = l.defaultView?.performance.now() ?? 0, f = r.get(t), p = f !== void 0 && d < f.start + f.duration;
2624
+ if (!Object.keys(c).some((e) => u[e] !== void 0 && u[e] !== c[e])) {
2625
+ if (p && f !== void 0) {
2626
+ let e = {
2627
+ ...i,
2628
+ ...f.from
2629
+ };
2630
+ a(yn(e, i, vn(f, d, s.easing))), b.push({
2631
+ apply: a,
2632
+ from: e,
2633
+ to: i,
2634
+ start: f.start,
2635
+ duration: f.duration,
2636
+ easing: s.easing
2637
+ });
2638
+ } else r.delete(t);
2639
+ return;
2640
+ }
2641
+ let m = p && f !== void 0 ? yn({
2642
+ ...i,
2643
+ ...f.from
2644
+ }, {
2645
+ ...i,
2646
+ ...f.to
2647
+ }, vn(f, d, s.easing)) : {
2648
+ ...i,
2649
+ ...u
2650
+ };
2651
+ a(m);
2652
+ let h = {
2653
+ from: m,
2654
+ to: i,
2655
+ start: d,
2656
+ duration: s.duration
2657
+ };
2658
+ r.set(t, h), b.push({
2659
+ apply: a,
2660
+ ...h,
2661
+ easing: s.easing
2662
+ });
2663
+ }, te = (e, t) => {
2664
+ let n = re(e, t), r, i;
2665
+ switch (e.kind) {
2666
+ case "rect":
2667
+ r = l.createElementNS(q, "rect"), i = (e) => {
2668
+ J(r, "x", e.x), J(r, "y", e.y), J(r, "width", Math.max(0, e.width ?? 0)), J(r, "height", Math.max(0, e.height ?? 0)), e.rx !== void 0 && J(r, "rx", Math.max(0, e.rx));
2669
+ };
2670
+ break;
2671
+ case "circle":
2672
+ r = l.createElementNS(q, "circle"), i = (e) => {
2673
+ J(r, "cx", e.cx), J(r, "cy", e.cy), J(r, "r", Math.max(0, e.r ?? 0));
2674
+ };
2675
+ break;
2676
+ case "ellipse":
2677
+ r = l.createElementNS(q, "ellipse"), i = (e) => {
2678
+ J(r, "cx", e.cx), J(r, "cy", e.cy), J(r, "rx", Math.max(0, e.rx ?? 0)), J(r, "ry", Math.max(0, e.ry ?? 0));
2679
+ };
2680
+ break;
2681
+ case "line":
2682
+ r = l.createElementNS(q, "line"), i = (e) => {
2683
+ J(r, "x1", e.x1), J(r, "y1", e.y1), J(r, "x2", e.x2), J(r, "y2", e.y2);
2684
+ };
2685
+ break;
2686
+ case "polyline": {
2687
+ r = l.createElementNS(q, e.closed === !0 ? "polygon" : "polyline");
2688
+ let n = [];
2689
+ if (e.points !== void 0) {
2690
+ let r = pn(e.points.source, t, s.rows.length);
2691
+ for (let i = 0; i < r; i += 1) {
2692
+ let a = {
2693
+ ...t,
2694
+ index: i,
2695
+ count: r,
2696
+ ...e.points.source.k === "rows" ? { row: s.rows[i] } : {}
2697
+ }, o = A(w(e.points.x, a)), c = A(w(e.points.y, a));
2698
+ Number.isFinite(o) && Number.isFinite(c) && n.push(`${Y(o)},${Y(c)}`);
2699
+ }
2700
+ }
2701
+ r.setAttribute("points", n.join(" ")), e.fill === void 0 && e.closed !== !0 && r.setAttribute("fill", "none"), i = () => {};
2702
+ break;
2703
+ }
2704
+ case "path": {
2705
+ r = l.createElementNS(q, "path");
2706
+ let n = [];
2707
+ for (let [r, i] of e.d ?? []) {
2708
+ let e = i.map((e) => A(w(e, t)));
2709
+ e.some((e) => !Number.isFinite(e)) || n.push(r === "Z" ? "Z" : `${r}${e.map(Y).join(" ")}`);
2710
+ }
2711
+ r.setAttribute("d", n.join(" ")), i = () => {};
2712
+ break;
2713
+ }
2714
+ case "arc":
2715
+ r = l.createElementNS(q, "path"), r.setAttribute("fill", "none"), r.setAttribute("stroke-linecap", e.linecap ?? "round"), i = (e) => {
2716
+ r.setAttribute("d", xn(e.cx ?? 0, e.cy ?? 0, e.r ?? 0, e.start ?? 0, e.end ?? 0)), J(r, "stroke-width", Math.max(0, e.thickness ?? 0));
2717
+ };
2718
+ break;
2719
+ case "ticks":
2720
+ r = l.createElementNS(q, "path"), r.setAttribute("fill", "none"), i = (e) => r.setAttribute("d", Sn(e));
2721
+ break;
2722
+ case "wave":
2723
+ r = l.createElementNS(q, "path"), i = (e) => r.setAttribute("d", Cn(e));
2724
+ break;
2725
+ case "text": {
2726
+ r = l.createElementNS(q, "text");
2727
+ let n = e.content === void 0 ? null : w(e.content, t);
2728
+ r.textContent = n === null ? "" : String(n).slice(0, 256), r.setAttribute("text-anchor", e.anchor ?? "start"), r.setAttribute("dominant-baseline", e.baseline === "middle" ? "central" : e.baseline === "hanging" ? "hanging" : "auto"), r.setAttribute("font-weight", String(e.fontWeight ?? 400)), r.style.fontFamily = "inherit", r.style.fontVariantNumeric = "tabular-nums", i = (e) => {
2729
+ J(r, "x", e.x), J(r, "y", e.y), J(r, "font-size", Math.max(0, (e.fontSize ?? 0) * _));
2730
+ };
2731
+ break;
2732
+ }
2733
+ default: return;
2734
+ }
2735
+ if (i(n), ne(r, "fill", e.fill, t), ne(r, "stroke", e.stroke, t), e.kind === "text" && e.fill === void 0 && r.setAttribute("fill", "currentColor"), e.kind === "ticks" && e.stroke === void 0 && r.setAttribute("stroke", "currentColor"), Number.isFinite(n.strokeWidth) && e.kind !== "arc" && J(r, "stroke-width", Math.max(0, n.strokeWidth)), Number.isFinite(n.opacity) && r.setAttribute("opacity", Y(Tn(n.opacity))), e.dash !== void 0) {
2736
+ let n = e.dash.map((e) => A(w(e, t)));
2737
+ n.every((e) => Number.isFinite(e) && e >= 0) && r.setAttribute("stroke-dasharray", n.map(Y).join(" "));
2738
+ }
2739
+ return e.linecap !== void 0 && e.kind !== "arc" && r.setAttribute("stroke-linecap", e.linecap), {
2740
+ element: r,
2741
+ params: n,
2742
+ apply: i
2743
+ };
2744
+ }, ne = (e, n, r, i) => {
2745
+ if (r === void 0) return;
2746
+ let a = mn(r, i, t);
2747
+ a !== void 0 && e.setAttribute(n, a);
2748
+ }, w = (e, t) => O(e, t), re = (e, t) => {
2749
+ let n = {};
2750
+ for (let [r, i] of Object.entries(e.num)) n[r] = A(w(i, t));
2751
+ return n;
2752
+ };
2753
+ for (let t of e.nodes) S(t, c, m, "");
2754
+ if (s.root.replaceChildren(m), v) {
2755
+ for (let e of b) bn(l, e);
2756
+ for (let t of x) for (let n of e.animations) {
2757
+ if (n.kind !== "loop" || n.target !== t.target || n.enabledBy !== void 0 && !M(w(n.enabledBy, t.env))) continue;
2758
+ let e = A(w(n.from, t.env)), r = A(w(n.to, t.env));
2759
+ !Number.isFinite(e) || !Number.isFinite(r) || ((n.property === "rotate" || n.property === "scale") && (t.element.style.transformBox = "fill-box", t.element.style.transformOrigin = "center"), t.element.animate([gn(n.property, e), gn(n.property, r)], {
2760
+ duration: n.duration,
2761
+ iterations: Infinity,
2762
+ easing: n.easing,
2763
+ direction: n.alternate ? "alternate" : "normal"
2764
+ }));
2765
+ }
2766
+ }
2767
+ };
2768
+ }
2769
+ function fn(e, t, n) {
2770
+ return e.source === void 0 ? 0 : pn(e.source, t, n);
2771
+ }
2772
+ function pn(e, t, n) {
2773
+ let r = e.k === "rows" ? n : A(O(e.n, t));
2774
+ return Number.isFinite(r) ? Math.max(0, Math.min(P.repeat, Math.trunc(r))) : 0;
2775
+ }
2776
+ function mn(e, t, n) {
2777
+ if (e.k === "color") return e.v;
2778
+ if (e.k === "gradient") return `url(#${n}-${e.id})`;
2779
+ let r = O(e.e, t);
2780
+ return typeof r == "string" && I.test(r.trim()) ? r.trim() : void 0;
2781
+ }
2782
+ function hn(e, t) {
2783
+ let n = [];
2784
+ (Number.isFinite(t.x) || Number.isFinite(t.y)) && n.push(`translate(${Y(X(t.x))} ${Y(X(t.y))})`), Number.isFinite(t.rotate) && n.push(`rotate(${Y(t.rotate)})`), Number.isFinite(t.scale) && n.push(`scale(${Y(t.scale)})`), n.length > 0 && e.setAttribute("transform", n.join(" "));
2785
+ }
2786
+ function gn(e, t) {
2787
+ switch (e) {
2788
+ case "translateX": return { transform: `translateX(${Y(t)}px)` };
2789
+ case "translateY": return { transform: `translateY(${Y(t)}px)` };
2790
+ case "rotate": return { transform: `rotate(${Y(t)}deg)` };
2791
+ case "scale": return { transform: `scale(${Y(t)})` };
2792
+ default: return { opacity: Tn(t) };
2793
+ }
2794
+ }
2795
+ var _n = {
2796
+ linear: (e) => e,
2797
+ ease: (e) => e * e * (3 - 2 * e),
2798
+ "ease-in": (e) => e * e,
2799
+ "ease-out": (e) => 1 - (1 - e) * (1 - e),
2800
+ "ease-in-out": (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2
2801
+ };
2802
+ function vn(e, t, n) {
2803
+ let r = Math.min(1, Math.max(0, (t - e.start) / e.duration));
2804
+ return (_n[n] ?? ((e) => e))(r);
2805
+ }
2806
+ function yn(e, t, n) {
2807
+ let r = { ...t };
2808
+ for (let [i, a] of Object.entries(t)) {
2809
+ let t = e[i];
2810
+ t !== void 0 && Number.isFinite(t) && Number.isFinite(a) && (r[i] = t + (a - t) * n);
2811
+ }
2812
+ return r;
2813
+ }
2814
+ function bn(e, t) {
2815
+ let n = e.defaultView;
2816
+ if (n === null) {
2817
+ t.apply(t.to);
2818
+ return;
2819
+ }
2820
+ let r = (e) => {
2821
+ t.apply(yn(t.from, t.to, vn(t, e, t.easing))), e < t.start + t.duration && n.requestAnimationFrame(r);
2822
+ };
2823
+ n.requestAnimationFrame(r);
2824
+ }
2825
+ function xn(e, t, n, r, i) {
2826
+ if (!Number.isFinite(e + t + n + r + i) || n <= 0) return "";
2827
+ let a = i - r;
2828
+ if (Math.abs(a) < .001) return "";
2829
+ let o = (r) => {
2830
+ let i = r * Math.PI / 180;
2831
+ return `${Y(e + n * Math.sin(i))} ${Y(t - n * Math.cos(i))}`;
2832
+ };
2833
+ if (Math.abs(a) >= 359.999) return `M${o(r)} A${Y(n)} ${Y(n)} 0 1 1 ${o(r + 180)} A${Y(n)} ${Y(n)} 0 1 1 ${o(r + 359.99)}`;
2834
+ let s = +(Math.abs(a) > 180), c = +(a > 0);
2835
+ return `M${o(r)} A${Y(n)} ${Y(n)} 0 ${s} ${c} ${o(i)}`;
2836
+ }
2837
+ function Sn(e) {
2838
+ let t = Math.max(0, Math.min(P.repeat, Math.trunc(X(e.count)))), n = X(e.cx), r = X(e.cy), i = X(e.r), a = X(e.length), o = X(e.start), s = X(e.end);
2839
+ if (t === 0) return "";
2840
+ let c = [];
2841
+ for (let e = 0; e < t; e += 1) {
2842
+ let l = (t === 1 ? o : o + (s - o) * e / (t - 1)) * Math.PI / 180, u = [n + i * Math.sin(l), r - i * Math.cos(l)], d = [n + (i - a) * Math.sin(l), r - (i - a) * Math.cos(l)];
2843
+ c.push(`M${Y(u[0])} ${Y(u[1])} L${Y(d[0])} ${Y(d[1])}`);
2844
+ }
2845
+ return c.join(" ");
2846
+ }
2847
+ function Cn(e) {
2848
+ let t = X(e.x), n = X(e.y), r = X(e.width), i = X(e.height), a = X(e.amplitude), o = Math.max(1, X(e.wavelength)), s = X(e.phase);
2849
+ if (r <= 0) return "";
2850
+ let c = o / 2, l = t - (s % o + o) % o, u = [`M${Y(l)} ${Y(n)}`], d = l, f = !0, p = 0;
2851
+ for (; d < t + r && p < 400;) {
2852
+ let e = d + c;
2853
+ u.push(`Q${Y(d + c / 2)} ${Y(n + (f ? -a : a))} ${Y(e)} ${Y(n)}`), d = e, f = !f, p += 1;
2854
+ }
2855
+ return u.push(`L${Y(d)} ${Y(n + i)} L${Y(l)} ${Y(n + i)} Z`), u.join(" ");
2856
+ }
2857
+ function J(e, t, n) {
2858
+ if (n === void 0 || !Number.isFinite(n)) {
2859
+ e.removeAttribute(t);
2860
+ return;
2861
+ }
2862
+ e.setAttribute(t, Y(n));
2863
+ }
2864
+ function Y(e) {
2865
+ return String(Math.round(e * 1e3) / 1e3);
2866
+ }
2867
+ function X(e) {
2868
+ return e !== void 0 && Number.isFinite(e) ? e : 0;
2869
+ }
2870
+ function wn(e) {
2871
+ return Number.isFinite(e) ? e : null;
2872
+ }
2873
+ function Tn(e) {
2874
+ return Math.min(1, Math.max(0, e));
2875
+ }
2876
+ //#endregion
2877
+ //#region ../plugin-sdk/dist/material-rendered-element.js
2878
+ var En = ":host{contain:content}.frame{position:relative;box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0;overflow:hidden}.frame>*{box-sizing:border-box;width:100%;height:100%;min-width:0;min-height:0}", Dn = 160;
2879
+ function On(e, t) {
2880
+ let n = e.ownerDocument, r = n.createElement("style");
2881
+ r.textContent = En;
2882
+ let a = n.createElement("div");
2883
+ a.className = "frame", a.setAttribute("part", "frame"), e.replaceChildren(r, a);
2884
+ let o = !1, s = (e, t) => {
2885
+ a.replaceChildren(...e === void 0 ? [] : [e]), o = t;
2886
+ }, c = (e, r) => {
2887
+ let a = It(t.data, r);
2888
+ if (t.data.kind === "rows" && a.rows.length === 0) {
2889
+ s(x(n), !1);
2890
+ return;
2891
+ }
2892
+ let o = n.createElement("div");
2893
+ o.setAttribute("data-base-screen-material-root", "");
2894
+ let c = [], l = !1, u = (e, t) => {
2895
+ o.dispatchEvent(new CustomEvent(i, {
2896
+ bubbles: !0,
2897
+ composed: !0,
2898
+ detail: {
2899
+ name: e,
2900
+ payload: t
2901
+ }
2902
+ }));
2903
+ };
2904
+ try {
2905
+ t.render({
2906
+ document: n,
2907
+ root: o,
2908
+ props: e.props,
2909
+ style: e.style,
2910
+ size: e.size,
2911
+ mode: e.mode,
2912
+ value: a.value,
2913
+ rows: a.rows,
2914
+ formatNumber: (t) => kn(t, e.props),
2915
+ emit: (e, t) => {
2916
+ let n = t ?? null;
2917
+ if (l) {
2918
+ u(e, n);
2919
+ return;
2920
+ }
2921
+ c.push({
2922
+ name: e,
2923
+ payload: n
2924
+ });
2925
+ }
2926
+ });
2927
+ } catch (e) {
2928
+ let t = e instanceof Error ? e.message : String(e);
2929
+ s(y(n, "HOST_DATASET_INVALID", `组件渲染失败:${t}`.slice(0, Dn)), !1);
2930
+ return;
2931
+ }
2932
+ s(o, !0), l = !0;
2933
+ for (let e of c.splice(0)) u(e.name, e.payload);
2934
+ };
2935
+ return { update(e) {
2936
+ let r = e.dataState;
2937
+ if (t.data.kind === "none") {
2938
+ c(e, void 0);
2939
+ return;
2940
+ }
2941
+ if (r.status === "ready") {
2942
+ c(e, r.value);
2943
+ return;
2944
+ }
2945
+ if (o && r.status !== "error") return;
2946
+ let i = b(n, r);
2947
+ s(i, !1);
2948
+ } };
2949
+ }
2950
+ function kn(e, t) {
2951
+ let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
2952
+ if (!Number.isFinite(n)) return "--";
2953
+ let r = typeof t.decimals == "number" ? t.decimals : 0, i = Math.min(6, Math.max(0, Math.trunc(r))), a = t.thousandsSeparator === !0 ? n.toLocaleString("en-US", {
2954
+ minimumFractionDigits: i,
2955
+ maximumFractionDigits: i
2956
+ }) : n.toFixed(i);
2957
+ return `${typeof t.prefix == "string" ? t.prefix : ""}${a}${typeof t.unit == "string" ? t.unit : ""}`;
2958
+ }
2959
+ function An(e) {
2960
+ let t = globalThis.HTMLElement ?? class {}, n = () => ({
2961
+ data: e.data,
2962
+ render: e.renderPerInstance === !0 ? e.render() : e.render
2963
+ });
2964
+ class r extends t {
2965
+ #e;
2966
+ #t;
2967
+ get model() {
2968
+ if (this.#e === void 0) throw Error("Material model has not been set.");
2969
+ return this.#e;
2970
+ }
2971
+ set model(e) {
2972
+ this.#e = e, this.setAttribute("data-base-screen-data-state", e.dataState.status), this.#n();
2973
+ }
2974
+ connectedCallback() {
2975
+ this.#n();
2976
+ }
2977
+ #n() {
2978
+ let e = this.#e;
2979
+ e === void 0 || !this.isConnected || (this.#t ??= On(this.shadowRoot ?? this.attachShadow({ mode: "open" }), n()), this.#t.update(e));
2980
+ }
2981
+ }
2982
+ Object.defineProperty(r, "manifest", {
2983
+ value: e.manifest,
2984
+ configurable: !0
2985
+ });
2986
+ let i = Ft(e.data);
2987
+ return i !== void 0 && Object.defineProperty(r, "tabularDataAdapter", { value: i }), r;
2988
+ }
2989
+ function jn(e) {
2990
+ let t = Mn(e);
2991
+ if (!t.ok) return t;
2992
+ let n = t.value;
2993
+ return {
2994
+ ok: !0,
2995
+ value: () => {
2996
+ let e = dn(n);
2997
+ return (t) => e({
2998
+ document: t.document,
2999
+ root: t.root,
3000
+ props: t.props,
3001
+ style: t.style,
3002
+ size: t.size,
3003
+ interactive: t.mode !== "design",
3004
+ value: t.value,
3005
+ rows: t.rows,
3006
+ formatNumber: t.formatNumber
3007
+ });
3008
+ },
3009
+ diagnostics: []
3010
+ };
3011
+ }
3012
+ function Mn(e) {
3013
+ return e.template === void 0 ? v("PLUGIN_CORE_LIFECYCLE_INVALID", ["template"], "规格没有 template。") : L(e.template, {
3014
+ fields: e.fields,
3015
+ data: e.data,
3016
+ ...e.events === void 0 ? {} : { events: e.events },
3017
+ sectionTarget: (t) => W(e, t)
3018
+ });
3019
+ }
3020
+ function Nn(e) {
3021
+ let t = H(e.spec);
3022
+ if (!t.ok) return t;
3023
+ if (t.value.isolated !== void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["spec", "isolated"], "MATERIAL_ISOLATED_CONFLICT:规格带 isolated 时用 createBaseScreenIsolatedMaterialDefinition 注册。");
3024
+ let n = t.value.template !== void 0;
3025
+ if (n && e.render !== void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["render"], "MATERIAL_TEMPLATE_RENDER_CONFLICT:规格带 template 时不能再给渲染函数。");
3026
+ if (!n && typeof e.render != "function") return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["render"], "渲染函数必须是函数。");
3027
+ let r = U(t.value, {
3028
+ tagName: e.tagName,
3029
+ ...e.libraryVisible === void 0 ? {} : { libraryVisible: e.libraryVisible },
3030
+ ...e.cover === void 0 ? {} : { cover: e.cover }
3031
+ });
3032
+ if (!r.ok) return r;
3033
+ if (n) {
3034
+ let e = jn(t.value);
3035
+ if (!e.ok) return e;
3036
+ let n = An({
3037
+ manifest: r.value,
3038
+ data: t.value.data,
3039
+ render: e.value,
3040
+ renderPerInstance: !0
3041
+ });
3042
+ return _({
3043
+ manifest: r.value,
3044
+ element: n
3045
+ });
3046
+ }
3047
+ let i = An({
3048
+ manifest: r.value,
3049
+ data: t.value.data,
3050
+ render: e.render
3051
+ });
3052
+ return _({
3053
+ manifest: r.value,
3054
+ element: i
3055
+ });
3056
+ }
3057
+ //#endregion
3058
+ //#region ../plugin-sdk/dist/material-isolated.js
3059
+ var Pn = 204800, Fn = 65536, In = 60, Ln = 5e3, Rn = 2e3, zn = 20, Bn = 3, Vn = 20, Hn = 1e4, Un = 500, Wn = /^[a-z][a-z0-9-]{0,31}$/, Gn = /^[A-Za-z_$][A-Za-z0-9_$]{0,63}$/, Kn = ":host{contain:content}.frame{position:relative;box-sizing:border-box;width:100%;height:100%;overflow:hidden}.frame>*{box-sizing:border-box;width:100%;height:100%}canvas{display:block}";
3060
+ function qn(e) {
3061
+ let t = H(e.spec);
3062
+ if (!t.ok) return t;
3063
+ let n = t.value.isolated;
3064
+ if (n === void 0) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["spec", "isolated"], "MATERIAL_ISOLATED_REQUIRED:隔离代码物料的规格必须带 isolated。");
3065
+ if (typeof e.source != "string" || e.source.trim() === "" || new TextEncoder().encode(e.source).byteLength > 204800) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["source"], `组件代码必须是非空文本,最多 ${Pn / 1024} KB。`);
3066
+ let r = new Map((e.libraries ?? []).map((e) => [e.name, e])), i = [];
3067
+ for (let [e, t] of (n.libraries ?? []).entries()) {
3068
+ let n = r.get(t);
3069
+ if (n === void 0 || !Wn.test(n.name) || !Gn.test(n.global) || typeof n.source != "string") return v("PLUGIN_CORE_LIFECYCLE_INVALID", [
3070
+ "spec",
3071
+ "isolated",
3072
+ "libraries",
3073
+ e
3074
+ ], `宿主没有提供预置库 ${t}。`);
3075
+ i.push(n);
3076
+ }
3077
+ let a = e.maxFps ?? In;
3078
+ if (!Number.isFinite(a) || a < 1 || a > 120) return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["maxFps"], "maxFps 必须在 1–120 之间。");
3079
+ if (e.sandbox !== void 0 && typeof e.sandbox.resolve != "function") return v("PLUGIN_CORE_LIFECYCLE_INVALID", ["sandbox"], "sandbox.resolve 必须是函数。");
3080
+ let o = U(t.value, {
3081
+ tagName: e.tagName,
3082
+ ...e.libraryVisible === void 0 ? {} : { libraryVisible: e.libraryVisible },
3083
+ ...e.cover === void 0 ? {} : { cover: e.cover }
3084
+ });
3085
+ if (!o.ok) return o;
3086
+ let s = xr({
3087
+ manifest: o.value,
3088
+ data: t.value.data,
3089
+ bundle: new lr(e.source, i, a),
3090
+ tagName: e.tagName,
3091
+ ...e.onAudit === void 0 ? {} : { onAudit: e.onAudit },
3092
+ ...e.onFrame === void 0 ? {} : { onFrame: e.onFrame },
3093
+ ...e.sandbox === void 0 ? {} : { sandbox: e.sandbox }
3094
+ });
3095
+ return _({
3096
+ manifest: o.value,
3097
+ element: s
3098
+ });
3099
+ }
3100
+ function Jn(e) {
3101
+ return new lr(e.source, e.libraries ?? [], e.maxFps ?? In).document();
3102
+ }
3103
+ function Z(e) {
3104
+ return e.replace(/<\/(script)/gi, "<\\/$1").replace(/<!--/g, "<\\!--");
3105
+ }
3106
+ var Yn = /* @__PURE__ */ new Map();
3107
+ function Xn(e) {
3108
+ let t = new TextEncoder().encode(e), n = globalThis.crypto?.subtle;
3109
+ return n === void 0 ? Promise.resolve($n(t)) : n.digest("SHA-256", t).then((e) => new Uint8Array(e));
3110
+ }
3111
+ function Zn(e) {
3112
+ let t = Yn.get(e);
3113
+ return t === void 0 && (t = Xn(e).then((e) => {
3114
+ let t = "";
3115
+ for (let n of e) t += String.fromCharCode(n);
3116
+ return `'sha256-${btoa(t)}'`;
3117
+ }), Yn.size > 64 && Yn.clear(), Yn.set(e, t)), t;
3118
+ }
3119
+ var Qn = new Uint32Array([
3120
+ 1116352408,
3121
+ 1899447441,
3122
+ 3049323471,
3123
+ 3921009573,
3124
+ 961987163,
3125
+ 1508970993,
3126
+ 2453635748,
3127
+ 2870763221,
3128
+ 3624381080,
3129
+ 310598401,
3130
+ 607225278,
3131
+ 1426881987,
3132
+ 1925078388,
3133
+ 2162078206,
3134
+ 2614888103,
3135
+ 3248222580,
3136
+ 3835390401,
3137
+ 4022224774,
3138
+ 264347078,
3139
+ 604807628,
3140
+ 770255983,
3141
+ 1249150122,
3142
+ 1555081692,
3143
+ 1996064986,
3144
+ 2554220882,
3145
+ 2821834349,
3146
+ 2952996808,
3147
+ 3210313671,
3148
+ 3336571891,
3149
+ 3584528711,
3150
+ 113926993,
3151
+ 338241895,
3152
+ 666307205,
3153
+ 773529912,
3154
+ 1294757372,
3155
+ 1396182291,
3156
+ 1695183700,
3157
+ 1986661051,
3158
+ 2177026350,
3159
+ 2456956037,
3160
+ 2730485921,
3161
+ 2820302411,
3162
+ 3259730800,
3163
+ 3345764771,
3164
+ 3516065817,
3165
+ 3600352804,
3166
+ 4094571909,
3167
+ 275423344,
3168
+ 430227734,
3169
+ 506948616,
3170
+ 659060556,
3171
+ 883997877,
3172
+ 958139571,
3173
+ 1322822218,
3174
+ 1537002063,
3175
+ 1747873779,
3176
+ 1955562222,
3177
+ 2024104815,
3178
+ 2227730452,
3179
+ 2361852424,
3180
+ 2428436474,
3181
+ 2756734187,
3182
+ 3204031479,
3183
+ 3329325298
3184
+ ]);
3185
+ function $n(e) {
3186
+ let t = e.length, n = Math.ceil((t + 9) / 64), r = new Uint8Array(n * 64);
3187
+ r.set(e), r[t] = 128;
3188
+ let i = new DataView(r.buffer);
3189
+ i.setUint32(r.length - 8, Math.floor(t / 536870912), !1), i.setUint32(r.length - 4, t * 8 >>> 0, !1);
3190
+ let a = new Uint32Array([
3191
+ 1779033703,
3192
+ 3144134277,
3193
+ 1013904242,
3194
+ 2773480762,
3195
+ 1359893119,
3196
+ 2600822924,
3197
+ 528734635,
3198
+ 1541459225
3199
+ ]), o = /* @__PURE__ */ new Uint32Array(64), s = (e, t) => e >>> t | e << 32 - t;
3200
+ for (let e = 0; e < n; e++) {
3201
+ for (let t = 0; t < 16; t++) o[t] = i.getUint32(e * 64 + t * 4, !1);
3202
+ for (let e = 16; e < 64; e++) {
3203
+ let t = o[e - 15], n = o[e - 2], r = s(t, 7) ^ s(t, 18) ^ t >>> 3, i = s(n, 17) ^ s(n, 19) ^ n >>> 10;
3204
+ o[e] = o[e - 16] + r + o[e - 7] + i >>> 0;
3205
+ }
3206
+ let [t, n, r, c, l, u, d, f] = a;
3207
+ for (let e = 0; e < 64; e++) {
3208
+ let i = s(l, 6) ^ s(l, 11) ^ s(l, 25), a = l & u ^ ~l & d, p = f + i + a + Qn[e] + o[e] >>> 0, m = (s(t, 2) ^ s(t, 13) ^ s(t, 22)) + (t & n ^ t & r ^ n & r) >>> 0;
3209
+ f = d, d = u, u = l, l = c + p >>> 0, c = r, r = n, n = t, t = p + m >>> 0;
3210
+ }
3211
+ a[0] = a[0] + t >>> 0, a[1] = a[1] + n >>> 0, a[2] = a[2] + r >>> 0, a[3] = a[3] + c >>> 0, a[4] = a[4] + l >>> 0, a[5] = a[5] + u >>> 0, a[6] = a[6] + d >>> 0, a[7] = a[7] + f >>> 0;
3212
+ }
3213
+ let c = /* @__PURE__ */ new Uint8Array(32), l = new DataView(c.buffer);
3214
+ for (let e = 0; e < 8; e++) l.setUint32(e * 4, a[e], !1);
3215
+ return c;
3216
+ }
3217
+ function er() {
3218
+ let e = /* @__PURE__ */ new Uint8Array(16);
3219
+ return crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
3220
+ }
3221
+ var tr = 1500, nr = /* @__PURE__ */ new WeakMap();
3222
+ function rr(e) {
3223
+ let t = nr.get(e);
3224
+ if (t !== void 0) return t;
3225
+ let n = (async () => {
3226
+ let t = e.defaultView;
3227
+ if (t === null) return !1;
3228
+ let n = er(), r = Z(`parent.postMessage({ type: 'bs-sandbox-probe', token: ${JSON.stringify(n)} }, '*');`), i = await Zn(r);
3229
+ return new Promise((a) => {
3230
+ let o = e.createElement("iframe");
3231
+ o.setAttribute("sandbox", "allow-scripts"), o.setAttribute("aria-hidden", "true"), o.setAttribute("tabindex", "-1"), o.setAttribute("data-base-screen-isolated-probe", ""), o.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none";
3232
+ let s = !1, c = (e) => {
3233
+ s || (s = !0, t.removeEventListener("message", l), clearTimeout(u), o.remove(), a(e));
3234
+ }, l = (e) => {
3235
+ let t = e.data;
3236
+ e.source === o.contentWindow && typeof t == "object" && t && t.type === "bs-sandbox-probe" && t.token === n && c(!0);
3237
+ };
3238
+ t.addEventListener("message", l);
3239
+ let u = setTimeout(() => c(!1), tr);
3240
+ o.srcdoc = [
3241
+ "<!doctype html><html><head><meta charset=\"utf-8\">",
3242
+ `<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src ${i}">`,
3243
+ `</head><body><script>${r}<\/script></body></html>`
3244
+ ].join(""), (e.body ?? e.documentElement).appendChild(o);
3245
+ });
3246
+ })();
3247
+ return nr.set(e, n), n;
3248
+ }
3249
+ function ir(e) {
3250
+ let t = [];
3251
+ for (let n of e.querySelectorAll("meta[http-equiv]")) {
3252
+ if (n.getAttribute("http-equiv")?.trim().toLowerCase() !== "content-security-policy") continue;
3253
+ let e = n.getAttribute("content")?.trim();
3254
+ e !== void 0 && e !== "" && t.push(e);
3255
+ }
3256
+ return t.length === 0 ? void 0 : t.join(" | ");
3257
+ }
3258
+ var ar = "宿主页面的 CSP 挡住了沙箱脚本(srcdoc 沙箱会继承宿主页面的 CSP),需要改用带独立 CSP 的沙箱路由。", or = "组件代码加载后一直没有结束(可能在顶层死循环或执行过久)。", sr = "沙箱握手超时:沙箱脚本没有回应。", cr = "沙箱握手超时:沙箱路由可能没有返回这份文档,或响应头里的 CSP 挡住了脚本。", lr = class {
3259
+ #e;
3260
+ #t;
3261
+ #n;
3262
+ #r;
3263
+ constructor(e, t, n) {
3264
+ this.#e = e, this.#t = t, this.#n = {
3265
+ libraries: t.map((e) => [e.name, e.global]),
3266
+ maxFps: n
3267
+ };
3268
+ }
3269
+ document() {
3270
+ return this.#r ??= this.#i(), this.#r;
3271
+ }
3272
+ async #i() {
3273
+ let e = [
3274
+ Z(`(${String(ln)})(${JSON.stringify(this.#n)});`),
3275
+ ...this.#t.map((e) => Z(e.source)),
3276
+ Z(`globalThis.__bsFormat = (${String(kn)});`)
3277
+ ], t = Z(`${this.#e}\n;globalThis.__bsCreate = typeof create === 'function' ? create : undefined;\n`), n = await Promise.all([...e, t].map(Zn)), r = [
3278
+ "<!doctype html><html><head><meta charset=\"utf-8\">",
3279
+ `<meta http-equiv="Content-Security-Policy" content="${on(n)}">`,
3280
+ "<style>html,body{margin:0;overflow:hidden;background:transparent}</style>",
3281
+ "</head><body>",
3282
+ ...e.map((e) => `<script>${e}<\/script>`),
3283
+ `<script type="module">${t}<\/script>`,
3284
+ "</body></html>"
3285
+ ].join(""), i = await Xn(r);
3286
+ return {
3287
+ html: r,
3288
+ hash: Array.from(i, (e) => e.toString(16).padStart(2, "0")).join(""),
3289
+ scriptHashes: n
3290
+ };
3291
+ }
3292
+ };
3293
+ function Q(e, t, n = []) {
3294
+ let r = Object.keys(e);
3295
+ return t.every((e) => r.includes(e)) && r.every((e) => t.includes(e) || n.includes(e));
3296
+ }
3297
+ var $ = (e, t) => typeof e == "string" && e.length <= t;
3298
+ function ur(t) {
3299
+ if (typeof t != "object" || !t || Array.isArray(t)) return;
3300
+ let n = t;
3301
+ if (n.type === "bitmap") return Q(n, [
3302
+ "type",
3303
+ "id",
3304
+ "bitmap"
3305
+ ]) && $(n.id, 64) && n.bitmap instanceof ImageBitmap ? {
3306
+ type: "bitmap",
3307
+ id: n.id,
3308
+ bitmap: n.bitmap
3309
+ } : void 0;
3310
+ let r = e(t, { maxBytes: Fn });
3311
+ if (!r.ok || r.value === null || typeof r.value != "object" || Array.isArray(r.value)) return;
3312
+ let i = r.value;
3313
+ switch (i.type) {
3314
+ case "ready": return Q(i, ["type"]) ? { type: "ready" } : void 0;
3315
+ case "tock": return Q(i, ["type", "pending"]) && Array.isArray(i.pending) && i.pending.length <= 1024 && i.pending.every((e) => $(e, 64)) ? {
3316
+ type: "tock",
3317
+ pending: i.pending
3318
+ } : void 0;
3319
+ case "event": return Q(i, [
3320
+ "type",
3321
+ "id",
3322
+ "name",
3323
+ "payload"
3324
+ ]) && $(i.id, 64) && $(i.name, 128) ? {
3325
+ type: "event",
3326
+ id: i.id,
3327
+ name: i.name,
3328
+ payload: i.payload
3329
+ } : void 0;
3330
+ case "error": return Q(i, ["type", "message"], ["id"]) && $(i.message, 200) && (i.id === void 0 || $(i.id, 64)) ? {
3331
+ type: "error",
3332
+ message: i.message,
3333
+ ...i.id === void 0 ? {} : { id: i.id }
3334
+ } : void 0;
3335
+ case "csp": return Q(i, [
3336
+ "type",
3337
+ "directive",
3338
+ "uri"
3339
+ ]) && $(i.directive, 64) && $(i.uri, 200) ? {
3340
+ type: "csp",
3341
+ directive: i.directive,
3342
+ uri: i.uri
3343
+ } : void 0;
3344
+ default: return;
3345
+ }
3346
+ }
3347
+ function dr(e) {
3348
+ if (Array.isArray(e)) return e.map(dr);
3349
+ if (typeof e == "object" && e) {
3350
+ let t = {};
3351
+ for (let [n, r] of Object.entries(e)) t[n] = dr(r);
3352
+ return t;
3353
+ }
3354
+ return e;
3355
+ }
3356
+ function fr(e) {
3357
+ let t = {};
3358
+ for (let [n, r] of Object.entries(e)) t[n] = dr(r);
3359
+ return t;
3360
+ }
3361
+ function pr(e, t) {
3362
+ if (typeof e != "string" || e.trim() === "") throw Error("沙箱路由没有返回地址。");
3363
+ let n = new URL(e, t.baseURI);
3364
+ if (n.protocol !== "https:" && n.protocol !== "http:") throw Error(`沙箱路由返回的地址不是 http(s):${n.protocol}`);
3365
+ return n;
3366
+ }
3367
+ function mr(e, t) {
3368
+ try {
3369
+ let n = new URL(e);
3370
+ return n.origin === t.origin && (n.pathname === t.pathname || n.pathname === "/");
3371
+ } catch {
3372
+ return !1;
3373
+ }
3374
+ }
3375
+ var hr = class {
3376
+ #e;
3377
+ #t;
3378
+ #n = /* @__PURE__ */ new Map();
3379
+ #r = /* @__PURE__ */ new Set();
3380
+ #i = [];
3381
+ #a;
3382
+ #o;
3383
+ #s = !1;
3384
+ #c;
3385
+ #l;
3386
+ #u;
3387
+ #d;
3388
+ #f = 0;
3389
+ #p = 0;
3390
+ #m = !1;
3391
+ #h;
3392
+ #g;
3393
+ #_ = 0;
3394
+ #v;
3395
+ constructor(e, t, n) {
3396
+ this.#e = e, this.#t = t, this.#v = n, this.#y();
3397
+ }
3398
+ get failed() {
3399
+ return this.#c;
3400
+ }
3401
+ async #y() {
3402
+ let e = er(), t;
3403
+ try {
3404
+ t = await this.#e.bundle.document();
3405
+ } catch (e) {
3406
+ this.fail(`沙箱文档生成失败:${String(e?.message ?? e)}`);
3407
+ return;
3408
+ }
3409
+ if (this.#c !== void 0) return;
3410
+ let n = this.#e.sandbox;
3411
+ if (n !== void 0) {
3412
+ try {
3413
+ this.#h = pr(await n.resolve(t), this.#t);
3414
+ } catch (e) {
3415
+ this.fail(`沙箱文档没能交给宿主的沙箱路由:${String(e?.message ?? e)}`.slice(0, 200), "sandbox-route");
3416
+ return;
3417
+ }
3418
+ if (this.#c !== void 0) return;
3419
+ }
3420
+ let r = this.#t.createElement("iframe");
3421
+ r.setAttribute("sandbox", "allow-scripts"), r.setAttribute("referrerpolicy", "no-referrer"), r.setAttribute("aria-hidden", "true"), r.setAttribute("tabindex", "-1"), r.setAttribute("data-base-screen-isolated-package", this.#e.tagName), r.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;border:0;opacity:0;pointer-events:none", r.name = e, this.#h === void 0 ? r.srcdoc = t.html : (this.#x(this.#h), r.src = this.#h.href), r.addEventListener("load", () => {
3422
+ this.#m = !0, this.#S(e);
3423
+ }, { once: !0 }), this.#a = r, (this.#t.body ?? this.#t.documentElement).appendChild(r), this.#u = setTimeout(() => {
3424
+ this.#s || this.#b();
3425
+ }, Ln);
3426
+ }
3427
+ async #b() {
3428
+ if (!this.#m) {
3429
+ this.fail(or, "startup");
3430
+ return;
3431
+ }
3432
+ if (this.#h !== void 0) {
3433
+ this.fail(cr, "handshake", ` 沙箱地址:${this.#h.href.slice(0, 160)}`);
3434
+ return;
3435
+ }
3436
+ let e = await rr(this.#t);
3437
+ if (this.#s || this.#c !== void 0) return;
3438
+ if (e) {
3439
+ this.fail(sr, "handshake");
3440
+ return;
3441
+ }
3442
+ let t = ir(this.#t);
3443
+ this.fail(ar, "host-csp", t === void 0 ? "宿主页面没有 <meta> CSP,挡住沙箱的 CSP 多半在 HTTP 响应头里。" : `宿主页面的 <meta> CSP:${t.slice(0, 200)}`);
3444
+ }
3445
+ #x(e) {
3446
+ let t = (t) => {
3447
+ if (this.#s || this.#c !== void 0) return;
3448
+ let n = t.effectiveDirective;
3449
+ (n === "frame-src" || n === "child-src" || n === "default-src") && mr(t.blockedURI, e) && this.fail(`宿主页面的 CSP 没有放行沙箱路由(${n}),需要在宿主 CSP 的 frame-src 里放行 ${e.origin}。`, "host-csp", ` 被拦地址:${String(t.blockedURI).slice(0, 160)}`);
3450
+ };
3451
+ this.#t.addEventListener("securitypolicyviolation", t), this.#g = () => this.#t.removeEventListener("securitypolicyviolation", t);
3452
+ }
3453
+ #S(e) {
3454
+ let t = this.#a?.contentWindow;
3455
+ if (t == null || this.#c !== void 0) return;
3456
+ let n = new MessageChannel();
3457
+ this.#o = n.port1, this.#o.onmessage = (e) => this.#w(e.data), t.postMessage({
3458
+ type: "bs-connect",
3459
+ token: e
3460
+ }, "*", [n.port2]);
3461
+ }
3462
+ #C(e, t, n, r) {
3463
+ this.#e.onAudit?.({
3464
+ kind: e,
3465
+ tagName: this.#e.tagName,
3466
+ message: t,
3467
+ ...n === void 0 ? {} : { componentId: n },
3468
+ ...r === void 0 ? {} : { cause: r }
3469
+ });
3470
+ }
3471
+ #w(e) {
3472
+ if (this.#c !== void 0) return;
3473
+ let t = ur(e);
3474
+ if (t === void 0) {
3475
+ typeof e == "object" && e && e.bitmap instanceof ImageBitmap && e.bitmap.close(), this.#_ += 1, this.#C("protocol", "沙箱消息格式不合法,已丢弃。"), this.#_ > Vn && this.fail("沙箱消息格式反复不合法。", "protocol");
3476
+ return;
3477
+ }
3478
+ switch (t.type) {
3479
+ case "ready":
3480
+ if (this.#s) return;
3481
+ this.#s = !0, this.#u !== void 0 && clearTimeout(this.#u), this.#g?.(), this.#g = void 0;
3482
+ for (let [e, t] of this.#i.splice(0)) this.#o?.postMessage(e, t);
3483
+ _r(this.#t).add(this);
3484
+ return;
3485
+ case "tock":
3486
+ this.#l = void 0;
3487
+ for (let e of t.pending) this.#n.has(e) && this.#r.add(e);
3488
+ return;
3489
+ case "bitmap": {
3490
+ let e = this.#n.get(t.id);
3491
+ e === void 0 ? t.bitmap.close() : e.receiveBitmap(t.bitmap);
3492
+ return;
3493
+ }
3494
+ case "event":
3495
+ this.#n.get(t.id)?.dispatchMaterialEvent(t.name, t.payload);
3496
+ return;
3497
+ case "error": {
3498
+ let e = t.id === void 0 ? void 0 : this.#n.get(t.id);
3499
+ this.#C("error", t.message, e?.componentId), e?.receiveError(t.message);
3500
+ return;
3501
+ }
3502
+ case "csp":
3503
+ this.#C("csp", `${t.directive} ${t.uri}`);
3504
+ return;
3505
+ }
3506
+ }
3507
+ post(e, t = []) {
3508
+ this.#c === void 0 && (this.#s && this.#o !== void 0 ? this.#o.postMessage(e, t) : this.#i.push([e, t]));
3509
+ }
3510
+ join(e, t) {
3511
+ if (this.#d !== void 0 && (clearTimeout(this.#d), this.#d = void 0), this.#c !== void 0) {
3512
+ e.shutdown(this.#c);
3513
+ return;
3514
+ }
3515
+ this.#n.set(e.instanceId, e), this.#r.add(e.instanceId), this.post({
3516
+ type: "mount",
3517
+ id: e.instanceId,
3518
+ state: t
3519
+ });
3520
+ }
3521
+ update(e, t) {
3522
+ this.#n.has(e.instanceId) && (this.#r.add(e.instanceId), this.post({
3523
+ type: "update",
3524
+ id: e.instanceId,
3525
+ state: t
3526
+ }));
3527
+ }
3528
+ leave(e) {
3529
+ this.#n.delete(e.instanceId) && (this.#r.delete(e.instanceId), this.post({
3530
+ type: "unmount",
3531
+ id: e.instanceId
3532
+ }), this.#n.size === 0 && (this.#d = setTimeout(() => {
3533
+ this.#n.size === 0 && this.dispose();
3534
+ }, Hn)));
3535
+ }
3536
+ tick(e) {
3537
+ if (!this.#s || this.#c !== void 0) return;
3538
+ let t = performance.now(), n = this.#p !== 0 && e - this.#p > 500;
3539
+ if (this.#p = e, this.#l !== void 0) {
3540
+ n ? this.#l = t : t - this.#l > Rn && this.fail("组件代码长时间没有响应(疑似死循环)。", "stall");
3541
+ return;
3542
+ }
3543
+ if (t - this.#f > Un) {
3544
+ this.#f = t;
3545
+ for (let e of this.#n.values()) {
3546
+ let t = e.recheckDpr();
3547
+ t !== void 0 && this.update(e, t);
3548
+ }
3549
+ }
3550
+ let r = [];
3551
+ for (let e of this.#n.values()) (e.continuous() || this.#r.has(e.instanceId)) && r.push(e.instanceId);
3552
+ this.#r.clear(), r.length !== 0 && (this.#l = t, this.#o?.postMessage({
3553
+ type: "tick",
3554
+ now: e,
3555
+ ids: r
3556
+ }));
3557
+ }
3558
+ fail(e, t, n) {
3559
+ if (this.#c === void 0) {
3560
+ this.#c = e, this.#C("circuit", n === void 0 ? e : `${e}${n}`, void 0, t);
3561
+ for (let t of this.#n.values()) t.shutdown(e);
3562
+ this.#T();
3563
+ }
3564
+ }
3565
+ dispose() {
3566
+ this.#T(), this.#v();
3567
+ }
3568
+ #T() {
3569
+ _r(this.#t).delete(this), this.#g?.(), this.#g = void 0, this.#u !== void 0 && clearTimeout(this.#u), this.#d !== void 0 && clearTimeout(this.#d), this.#o?.close(), this.#o = void 0, this.#a?.remove(), this.#a = void 0, this.#i.length = 0;
3570
+ }
3571
+ }, gr = /* @__PURE__ */ new WeakMap();
3572
+ function _r(e) {
3573
+ let t = gr.get(e);
3574
+ if (t !== void 0) return t;
3575
+ let n = /* @__PURE__ */ new Set(), r = e.defaultView, i = !1, a = (e) => {
3576
+ if (n.size === 0) {
3577
+ i = !1;
3578
+ return;
3579
+ }
3580
+ for (let t of n) t.tick(e);
3581
+ r?.requestAnimationFrame(a);
3582
+ }, o = {
3583
+ add(e) {
3584
+ n.add(e), !i && r !== null && (i = !0, r.requestAnimationFrame(a));
3585
+ },
3586
+ delete(e) {
3587
+ n.delete(e);
3588
+ }
3589
+ };
3590
+ return gr.set(e, o), o;
3591
+ }
3592
+ var vr = /* @__PURE__ */ new WeakMap();
3593
+ function yr(e, t) {
3594
+ let n = vr.get(t);
3595
+ n === void 0 && (n = /* @__PURE__ */ new Map(), vr.set(t, n));
3596
+ let r = n.get(e.tagName);
3597
+ if (r !== void 0) return r;
3598
+ let i = new hr(e, t, () => {
3599
+ n.get(e.tagName) === i && n.delete(e.tagName);
3600
+ });
3601
+ return n.set(e.tagName, i), i;
3602
+ }
3603
+ var br = 0;
3604
+ function xr(e) {
3605
+ let t = globalThis.HTMLElement ?? class {}, n = new Set(e.manifest.events);
3606
+ class r extends t {
3607
+ instanceId = `i${++br}`;
3608
+ #e;
3609
+ #t;
3610
+ #n;
3611
+ #r;
3612
+ #i = null;
3613
+ #a;
3614
+ #o = !1;
3615
+ #s = !0;
3616
+ #c;
3617
+ #l = 0;
3618
+ #u = 0;
3619
+ #d = 0;
3620
+ #f;
3621
+ #p;
3622
+ get componentId() {
3623
+ return this.#e?.componentId ?? "";
3624
+ }
3625
+ get model() {
3626
+ if (this.#e === void 0) throw Error("Material model has not been set.");
3627
+ return this.#e;
3628
+ }
3629
+ set model(e) {
3630
+ this.#e = e, this.setAttribute("data-base-screen-data-state", e.dataState.status), this.#y();
3631
+ }
3632
+ connectedCallback() {
3633
+ typeof IntersectionObserver == "function" && this.#c === void 0 && (this.#c = new IntersectionObserver((e) => {
3634
+ let t = e[e.length - 1];
3635
+ t !== void 0 && (this.#s = t.isIntersecting);
3636
+ }), this.#c.observe(this)), this.#y();
3637
+ }
3638
+ disconnectedCallback() {
3639
+ this.#c?.disconnect(), this.#c = void 0, this.#t?.leave(this), this.#t = void 0, this.#a = void 0, this.#o = !1;
3640
+ }
3641
+ #m() {
3642
+ if (this.#n !== void 0) return this.#n;
3643
+ let e = this.shadowRoot ?? this.attachShadow({ mode: "open" }), t = this.ownerDocument.createElement("style");
3644
+ t.textContent = Kn;
3645
+ let n = this.ownerDocument.createElement("div");
3646
+ return n.className = "frame", n.setAttribute("part", "frame"), e.replaceChildren(t, n), this.#n = n, n;
3647
+ }
3648
+ #h(e) {
3649
+ this.#m().replaceChildren(...e === void 0 ? [] : [e]);
3650
+ }
3651
+ #g() {
3652
+ if (this.#r !== void 0) return this.#r;
3653
+ let t = this.ownerDocument.createElement("canvas");
3654
+ return t.setAttribute("role", "img"), t.setAttribute("aria-label", e.manifest.name), t.addEventListener("click", (e) => {
3655
+ let t = this.#e;
3656
+ t === void 0 || t.mode === "design" || !t.interactive || this.#t?.post({
3657
+ type: "pointer",
3658
+ id: this.instanceId,
3659
+ x: e.offsetX,
3660
+ y: e.offsetY
3661
+ });
3662
+ }), this.#i = t.getContext("bitmaprenderer"), this.#r = t, t;
3663
+ }
3664
+ #_(e) {
3665
+ let t = this.getBoundingClientRect(), n = t.width > 0 && e.size.width > 0 ? Math.max(t.width / e.size.width, t.height / Math.max(1, e.size.height)) : 1, r = (this.ownerDocument.defaultView?.devicePixelRatio ?? 1) * n;
3666
+ return Math.round(Math.min(3, Math.max(.5, r)) * 100) / 100;
3667
+ }
3668
+ #v(t, n) {
3669
+ let r = It(e.data, n), i = this.#a, a = i !== void 0 && i.w === t.size.width && i.h === t.size.height ? i.dpr : this.#_(t);
3670
+ return {
3671
+ w: t.size.width,
3672
+ h: t.size.height,
3673
+ dpr: a,
3674
+ props: fr(t.props),
3675
+ style: fr(t.style),
3676
+ mode: t.mode,
3677
+ value: r.value,
3678
+ rows: r.rows,
3679
+ interactive: t.interactive
3680
+ };
3681
+ }
3682
+ #y() {
3683
+ let t = this.#e;
3684
+ if (t === void 0 || !this.isConnected || (this.#m(), this.#f !== void 0)) return;
3685
+ let n = t.dataState.status;
3686
+ if (e.data.kind !== "none" && n !== "ready") {
3687
+ if (this.#o && n !== "error") return;
3688
+ this.#o = !1, this.#h(b(this.ownerDocument, t.dataState));
3689
+ return;
3690
+ }
3691
+ let r = t.dataState.status === "ready" ? t.dataState.value : void 0, i = this.#v(t, r);
3692
+ if (e.data.kind === "rows" && i.rows.length === 0) {
3693
+ this.#o = !1, this.#h(x(this.ownerDocument));
3694
+ return;
3695
+ }
3696
+ this.#o || this.#h(b(this.ownerDocument, { status: "loading" }));
3697
+ let a = this.#a === void 0;
3698
+ this.#a = i, a ? (this.#t = yr(e, this.ownerDocument), this.#t.join(this, i)) : this.#t?.update(this, i);
3699
+ }
3700
+ continuous() {
3701
+ let e = this.#e;
3702
+ return e === void 0 || e.mode === "design" || !this.#s ? !1 : (this.#p === void 0 && (this.#p = this.ownerDocument.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)") ?? null), this.#p?.matches !== !0);
3703
+ }
3704
+ recheckDpr() {
3705
+ let e = this.#e, t = this.#a;
3706
+ if (e === void 0 || t === void 0) return;
3707
+ let n = this.#_(e);
3708
+ if (!(Math.abs(n - t.dpr) / t.dpr < .1)) return this.#a = {
3709
+ ...t,
3710
+ dpr: n
3711
+ }, this.#a;
3712
+ }
3713
+ receiveBitmap(t) {
3714
+ let n = this.#a, r = Math.max(1, n?.dpr ?? 1), i = Math.ceil((n?.w ?? 0) * r * 1.1) + 2, a = Math.ceil((n?.h ?? 0) * r * 1.1) + 2;
3715
+ if (n === void 0 || this.#f !== void 0 || t.width > i || t.height > a) {
3716
+ t.close();
3717
+ return;
3718
+ }
3719
+ let o = this.#g();
3720
+ o.width !== t.width && (o.width = t.width), o.height !== t.height && (o.height = t.height), this.#i?.transferFromImageBitmap(t), this.#l = 0, (!this.#o || this.#n?.firstChild !== o) && this.#h(o), this.#o = !0, e.onFrame?.(this.componentId);
3721
+ }
3722
+ receiveError(e) {
3723
+ if (this.#l += 1, this.#l >= Bn) {
3724
+ this.#t?.fail(`组件代码连续出错:${e}`, "errors");
3725
+ return;
3726
+ }
3727
+ this.#o = !1, this.#h(y(this.ownerDocument, "HOST_DATASET_INVALID", `组件渲染失败:${e}`.slice(0, 160)));
3728
+ }
3729
+ dispatchMaterialEvent(t, r) {
3730
+ if (!n.has(t)) {
3731
+ e.onAudit?.({
3732
+ kind: "protocol",
3733
+ tagName: e.tagName,
3734
+ componentId: this.componentId,
3735
+ message: `事件 ${t} 不在组件声明里,已丢弃。`
3736
+ });
3737
+ return;
3738
+ }
3739
+ let a = performance.now();
3740
+ if (a - this.#u >= 1e3 && (this.#u = a, this.#d = 0), this.#d += 1, this.#d > zn) {
3741
+ this.#d === 21 && e.onAudit?.({
3742
+ kind: "rate",
3743
+ tagName: e.tagName,
3744
+ componentId: this.componentId,
3745
+ message: `事件超过每秒 ${zn} 条,多余的已丢弃。`
3746
+ });
3747
+ return;
3748
+ }
3749
+ this.dispatchEvent(new CustomEvent(i, {
3750
+ bubbles: !0,
3751
+ composed: !0,
3752
+ detail: {
3753
+ name: t,
3754
+ payload: r
3755
+ }
3756
+ }));
3757
+ }
3758
+ shutdown(e) {
3759
+ this.#f = e, this.#o = !1, this.isConnected && this.#h(y(this.ownerDocument, "HOST_DATASET_INVALID", `组件已停用:${e}`.slice(0, 160)));
3760
+ }
3761
+ }
3762
+ Object.defineProperty(r, "manifest", {
3763
+ value: e.manifest,
3764
+ configurable: !0
3765
+ });
3766
+ let a = Ft(e.data);
3767
+ return a !== void 0 && Object.defineProperty(r, "tabularDataAdapter", { value: a }), r;
3768
+ }
3769
+ //#endregion
3770
+ //#region ../plugin-sdk/dist/material-package.js
3771
+ var Sr = 512;
3772
+ function Cr(e) {
3773
+ let t = e;
3774
+ if (typeof t != "object" || !t || Array.isArray(t)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", [], "Material package options must be an object.");
3775
+ let n = t, r, i;
3776
+ try {
3777
+ r = n.id, i = n.materials;
3778
+ } catch {
3779
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", [], "Material package options cannot be safely read.");
3780
+ }
3781
+ if (!Er(r)) return v("PLUGIN_CORE_IDENTITY_INVALID", ["id"], "Material package id must be an ASCII identifier.");
3782
+ if (!Array.isArray(i) || i.length === 0) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Material package must declare at least one material.");
3783
+ if (i.length > Sr) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Material package exceeds the material count limit.");
3784
+ let a = [], o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
3785
+ for (let e = 0; e < i.length; e++) {
3786
+ let t;
3787
+ try {
3788
+ let n = i[e];
3789
+ if (typeof n != "object" || !n || Array.isArray(n)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", ["materials", e], "Material package entry must be an object.");
3790
+ t = _(n);
3791
+ } catch {
3792
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials", e], "Material package entry cannot be safely read.");
3793
+ }
3794
+ if (!t.ok) return g(t.diagnostics, ["materials", e]);
3795
+ let n = t.value.manifest;
3796
+ if (o.has(n.type)) return v("PLUGIN_CORE_IDENTITY_CONFLICT", [
3797
+ "materials",
3798
+ e,
3799
+ "type"
3800
+ ], "Material package contains a duplicate material type.");
3801
+ if (s.has(n.tagName)) return v("PLUGIN_CORE_IDENTITY_CONFLICT", [
3802
+ "materials",
3803
+ e,
3804
+ "tagName"
3805
+ ], "Material package contains a duplicate tag name.");
3806
+ o.add(n.type), s.add(n.tagName), a.push(t.value);
3807
+ }
3808
+ let c = Object.freeze(a);
3809
+ return {
3810
+ ok: !0,
3811
+ value: {
3812
+ id: n.id,
3813
+ materials: c,
3814
+ define: (e) => wr(c, e)
3815
+ },
3816
+ diagnostics: []
3817
+ };
3818
+ }
3819
+ function wr(e, t) {
3820
+ let n = t ?? globalThis.customElements, r = [];
3821
+ for (let t = 0; t < e.length; t++) {
3822
+ let i = Tr(e[t], n);
3823
+ i !== void 0 && r.push({
3824
+ ...i,
3825
+ path: [
3826
+ "materials",
3827
+ t,
3828
+ "tagName"
3829
+ ]
3830
+ });
3831
+ }
3832
+ if (r.length > 0) return {
3833
+ ok: !1,
3834
+ diagnostics: h(r)
3835
+ };
3836
+ let i = [];
3837
+ for (let t = 0; t < e.length; t++) {
3838
+ let r = e[t].define(n);
3839
+ if (!r.ok) return {
3840
+ ok: !1,
3841
+ diagnostics: h(r.diagnostics.map((e) => ({
3842
+ ...e,
3843
+ path: [
3844
+ "materials",
3845
+ t,
3846
+ ...e.path
3847
+ ]
3848
+ })))
3849
+ };
3850
+ i.push(r.value);
3851
+ }
3852
+ return {
3853
+ ok: !0,
3854
+ value: Object.freeze(i),
3855
+ diagnostics: []
3856
+ };
3857
+ }
3858
+ function Tr(e, t) {
3859
+ if (t === void 0) return;
3860
+ let n;
3861
+ try {
3862
+ n = t.get(e.manifest.tagName);
3863
+ } catch {
3864
+ return;
3865
+ }
3866
+ if (n !== void 0 && n !== e.element) return {
3867
+ severity: "error",
3868
+ code: "PLUGIN_CORE_IDENTITY_CONFLICT",
3869
+ path: [],
3870
+ message: "Tag name is already bound to a different constructor."
3871
+ };
3872
+ }
3873
+ function Er(e) {
3874
+ return typeof e == "string" && e.length > 0 && e.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e);
3875
+ }
3876
+ //#endregion
3877
+ //#region ../plugin-sdk/dist/material-style-keys.js
3878
+ var Dr = /* @__PURE__ */ new Set(/* @__PURE__ */ "fill.backgroundColor.color.labelColor.accentColor.fontSize.labelFontSize.borderColor.borderWidth.borderRadius.strokeColor.strokeWidth.fontWeight.textAlign.verticalAlign.letterSpacing.lineHeight.lineSpacing.shadowColor.shadowBlur.shadowOffsetX.shadowOffsetY.criticalColor.warningColor.infoColor.runningColor.standbyColor.faultColor.offlineColor.unknownColor.positiveColor.negativeColor".split(".")), Or = /* @__PURE__ */ new Set([
3879
+ "accent",
3880
+ "background",
3881
+ "connectorColor",
3882
+ "connectorWidth",
3883
+ "dash",
3884
+ "fillColor",
3885
+ "fillGlow",
3886
+ "gridColor",
3887
+ "headerBackgroundColor",
3888
+ "headerColor",
3889
+ "lineWidth",
3890
+ "nodeBackground",
3891
+ "nodeBorderColor",
3892
+ "objectFit",
3893
+ "rowHeight",
3894
+ "seriesColor",
3895
+ "thickness",
3896
+ "tileGap",
3897
+ "tileRadius",
3898
+ "trackColor",
3899
+ "valueColor",
3900
+ "waterColor",
3901
+ "waveColor"
3902
+ ]), kr = [
3903
+ "title",
3904
+ "caption",
3905
+ "description",
3906
+ "subtitle",
3907
+ "showTitle",
3908
+ "titleText"
3909
+ ];
3910
+ //#endregion
3911
+ //#region ../plugin-sdk/dist/material-template-audit.js
3912
+ function Ar(e) {
3913
+ if (e.template === void 0) return [];
3914
+ let t = L(e.template, {
3915
+ fields: e.fields,
3916
+ data: e.data,
3917
+ ...e.events === void 0 ? {} : { events: e.events },
3918
+ sectionTarget: (t) => W(e, t)
3919
+ });
3920
+ if (!t.ok) return [];
3921
+ let n = U(e, { tagName: "base-screen-template-audit" });
3922
+ if (!n.ok) return [];
3923
+ let r = n.value.defaultProps ?? {}, i = n.value.defaultStyle ?? {}, a = e.data.kind === "scalar" ? e.data.sample : e.data.kind === "rows" ? Pt(e.data) : void 0, o = It(e.data, a), s = {
3924
+ value: o.value,
3925
+ rows: o.rows,
3926
+ props: r,
3927
+ style: i,
3928
+ size: e.defaultSize,
3929
+ formatNumber: (e) => kn(e, r),
3930
+ budget: { steps: be }
3931
+ };
3932
+ return new jr(t.value, i).run(s);
3933
+ }
3934
+ var jr = class {
3935
+ template;
3936
+ style;
3937
+ #e = [];
3938
+ #t = /* @__PURE__ */ new Map();
3939
+ #n = /* @__PURE__ */ new Set();
3940
+ #r = /* @__PURE__ */ new Set();
3941
+ constructor(e, t) {
3942
+ this.template = e, this.style = t;
3943
+ }
3944
+ run(e) {
3945
+ try {
3946
+ for (let t of this.template.nodes) this.#a(t, e, !1);
3947
+ } catch (e) {
3948
+ this.#e.push({
3949
+ rule: "TPL9",
3950
+ severity: "error",
3951
+ message: `示例数据下模板渲染失败:${e instanceof Error ? e.message : String(e)}`,
3952
+ path: ["template"]
3953
+ });
3954
+ }
3955
+ this.#c();
3956
+ for (let e of this.#n) {
3957
+ let t = this.template.index.get(e);
3958
+ this.#e.push({
3959
+ rule: "TPL10",
3960
+ severity: "warning",
3961
+ message: `节点 ${e} 在示例数据下超出 viewBox,会被裁掉(需要溢出时放进 clip)。`,
3962
+ ...t === void 0 ? {} : { path: ["template", ...t.path] }
3963
+ });
3964
+ }
3965
+ return this.#e;
3966
+ }
3967
+ #i(e, t, n, r) {
3968
+ let i = A(O(e, t));
3969
+ return !Number.isFinite(i) && !this.#r.has(`${n.id}.${r}`) && (this.#r.add(`${n.id}.${r}`), this.#e.push({
3970
+ rule: "TPL9",
3971
+ severity: "error",
3972
+ message: `示例数据下 ${n.id}.${r} 求不出数字(结果为 NaN 或无穷):检查除零、空数据与引号。`,
3973
+ path: [
3974
+ "template",
3975
+ ...n.path,
3976
+ r
3977
+ ]
3978
+ })), i;
3979
+ }
3980
+ #a(e, t, n) {
3981
+ switch (e.kind) {
3982
+ case "repeat": {
3983
+ let r = e.source;
3984
+ if (r === void 0) return;
3985
+ let i = r.k === "rows" ? t.rows.length : this.#i(r.n, t, e, "source"), a = Math.max(0, Math.min(P.repeat, Math.trunc(Number.isFinite(i) ? i : 0)));
3986
+ for (let i = 0; i < a; i += 1) {
3987
+ let o = {
3988
+ ...t,
3989
+ index: i,
3990
+ count: a,
3991
+ ...r.k === "rows" ? { row: t.rows[i] } : {}
3992
+ };
3993
+ for (let t of e.children ?? []) this.#a(t, o, n);
3994
+ }
3995
+ return;
3996
+ }
3997
+ case "when":
3998
+ e.test !== void 0 && O(e.test, t);
3999
+ for (let r of e.children ?? []) this.#a(r, t, n);
4000
+ return;
4001
+ case "clip":
4002
+ for (let n of e.children ?? []) this.#a(n, t, !0);
4003
+ return;
4004
+ case "g": {
4005
+ let r = e.num.x !== void 0 || e.num.y !== void 0 || e.num.rotate !== void 0 || e.num.scale !== void 0;
4006
+ for (let [n, r] of Object.entries(e.num)) this.#i(r, t, e, n);
4007
+ for (let i of e.children ?? []) this.#a(i, t, n || r);
4008
+ return;
4009
+ }
4010
+ }
4011
+ let r = {};
4012
+ for (let [n, i] of Object.entries(e.num)) r[n] = this.#i(i, t, e, n);
4013
+ e.content !== void 0 && O(e.content, t);
4014
+ for (let n of e.on?.payload ?? []) O(n.value, t);
4015
+ if (e.points !== void 0) {
4016
+ let r = e.points.source, i = r.k === "rows" ? t.rows.length : Math.max(0, Math.min(P.repeat, Math.trunc(this.#i(r.n, t, e, "points"))));
4017
+ for (let a = 0; a < i; a += 1) {
4018
+ let o = {
4019
+ ...t,
4020
+ index: a,
4021
+ count: i,
4022
+ ...r.k === "rows" ? { row: t.rows[a] } : {}
4023
+ }, s = this.#i(e.points.x, o, e, "points.x"), c = this.#i(e.points.y, o, e, "points.y");
4024
+ n || this.#s(e, [s, s], [c, c]);
4025
+ }
4026
+ }
4027
+ for (let [, n] of e.d ?? []) for (let r of n) this.#i(r, t, e, "d");
4028
+ if (e.kind === "text") {
4029
+ let t = this.#t.get(e.id), n = r.fontSize ?? 0;
4030
+ (t === void 0 || n < t.fontSize) && this.#t.set(e.id, {
4031
+ node: e,
4032
+ fontSize: n,
4033
+ fontWeight: e.fontWeight ?? 400
4034
+ });
4035
+ }
4036
+ n || this.#o(e, r);
4037
+ }
4038
+ #o(e, t) {
4039
+ let n = (e) => t[e] ?? 0;
4040
+ switch (e.kind) {
4041
+ case "rect":
4042
+ this.#s(e, [n("x"), n("x") + n("width")], [n("y"), n("y") + n("height")]);
4043
+ return;
4044
+ case "circle":
4045
+ this.#s(e, [n("cx") - n("r"), n("cx") + n("r")], [n("cy") - n("r"), n("cy") + n("r")]);
4046
+ return;
4047
+ case "ellipse":
4048
+ this.#s(e, [n("cx") - n("rx"), n("cx") + n("rx")], [n("cy") - n("ry"), n("cy") + n("ry")]);
4049
+ return;
4050
+ case "line":
4051
+ this.#s(e, [Math.min(n("x1"), n("x2")), Math.max(n("x1"), n("x2"))], [Math.min(n("y1"), n("y2")), Math.max(n("y1"), n("y2"))]);
4052
+ return;
4053
+ case "arc": {
4054
+ let t = n("r") + n("thickness") / 2;
4055
+ this.#s(e, [n("cx") - t, n("cx") + t], [n("cy") - t, n("cy") + t]);
4056
+ return;
4057
+ }
4058
+ case "text":
4059
+ this.#s(e, [n("x"), n("x")], [n("y"), n("y")]);
4060
+ return;
4061
+ default: return;
4062
+ }
4063
+ }
4064
+ #s(e, t, n) {
4065
+ let [r, i, a, o] = this.template.viewBox, s = .5;
4066
+ (!Number.isFinite(t[0] + t[1] + n[0] + n[1]) || t[0] < r - s || n[0] < i - s || t[1] > r + a + s || n[1] > i + o + s) && this.#n.add(e.id);
4067
+ }
4068
+ #c() {
4069
+ let e = m(1920);
4070
+ for (let t of this.#t.values()) {
4071
+ let n = ["template", ...t.node.path];
4072
+ t.fontSize < e - .01 && this.#e.push({
4073
+ rule: "TPL7",
4074
+ severity: "error",
4075
+ message: `文字 ${t.node.id} 的字号 ${Mr(t.fontSize)}px 低于下限 ${Mr(e)}px(1920 宽画布 16px 等比)。`,
4076
+ path: [...n, "fontSize"]
4077
+ });
4078
+ let r = t.node.backdrop;
4079
+ if (r === void 0 || r === "container") continue;
4080
+ let i = this.template.index.get(r);
4081
+ if (i === void 0) continue;
4082
+ let a = this.#l(t.node.fill), o = this.#l(i.fill);
4083
+ if (a.length === 0 || o.length === 0) continue;
4084
+ let s = d(t.fontSize, t.fontWeight), c;
4085
+ for (let e of a) for (let t of o) {
4086
+ let n = f(e), r = f(t);
4087
+ if (n === void 0 || r === void 0) continue;
4088
+ let i = p(n, r);
4089
+ (c === void 0 || i < c.ratio) && (c = {
4090
+ ratio: i,
4091
+ text: e,
4092
+ back: t
4093
+ });
4094
+ }
4095
+ c !== void 0 && c.ratio < s && this.#e.push({
4096
+ rule: "TPL8",
4097
+ severity: "warning",
4098
+ message: `文字 ${t.node.id}(${c.text})在底板 ${r}(${c.back})上的对比度 ${c.ratio.toFixed(2)},低于 ${s}。`,
4099
+ path: [...n, "fill"]
4100
+ });
4101
+ }
4102
+ }
4103
+ #l(e) {
4104
+ return e === void 0 ? [] : e.k === "color" ? [e.v] : e.k === "gradient" ? (this.template.gradients.find((t) => t.id === e.id)?.stops ?? []).flatMap((e) => this.#l(e.color)) : this.#u(e.e);
4105
+ }
4106
+ #u(e) {
4107
+ switch (e.k) {
4108
+ case "lit": return typeof e.v == "string" ? [e.v] : [];
4109
+ case "ref": {
4110
+ if (e.root !== "style" || e.key === void 0) return [];
4111
+ let t = this.style[e.key];
4112
+ return typeof t == "string" && I.test(t) ? [t] : [];
4113
+ }
4114
+ case "cond": return [...this.#u(e.a), ...this.#u(e.b)];
4115
+ case "call": return e.args.flatMap((t, n) => n === 0 || n % 2 == 1 && n !== e.args.length - 1 ? [] : this.#u(t));
4116
+ default: return [];
4117
+ }
4118
+ }
4119
+ };
4120
+ function Mr(e) {
4121
+ return Math.round(e * 10) / 10;
4122
+ }
4123
+ //#endregion
4124
+ //#region ../plugin-sdk/dist/material-spec-audit.js
4125
+ var Nr = "base-screen-spec-audit", Pr = /* @__PURE__ */ new Set([...kr, "label"]), Fr = /标题|副标题|说明|描述|备注|注释/, Ir = /^(?:empty|loading|error)(?:Text|Label|Message)$/, Lr = 1920, Rr = 1080;
4126
+ function zr(e) {
4127
+ let t = 0;
4128
+ for (let n of e) t += (n.codePointAt(0) ?? 0) > 11904 ? 2 : 1;
4129
+ return t;
4130
+ }
4131
+ var Br = /^(TPL\d+):/;
4132
+ function Vr(e, t = {}) {
4133
+ let n = H(e);
4134
+ if (!n.ok) return C(n.diagnostics.map((e) => {
4135
+ let t = Br.exec(e.message)?.[1];
4136
+ return {
4137
+ rule: t ?? "SPEC",
4138
+ severity: "error",
4139
+ message: t === void 0 ? e.message : e.message.slice(t.length + 1),
4140
+ path: e.path
4141
+ };
4142
+ }));
4143
+ let r = n.value, i = [];
4144
+ r.fields.forEach((e, t) => Hr(e, t, r, i)), (r.customSections ?? []).forEach((e, t) => {
4145
+ let n = [
4146
+ "customSections",
4147
+ t,
4148
+ "label"
4149
+ ];
4150
+ Fr.test(e.label) && i.push({
4151
+ rule: "T4",
4152
+ severity: "error",
4153
+ message: `分组「${e.label}」是描述性文案:分区标题不用「标题 / 说明」这类自我描述的词。`,
4154
+ path: n
4155
+ }), zr(e.label) > 12 && i.push({
4156
+ rule: "T4",
4157
+ severity: "error",
4158
+ message: `分组「${e.label}」超过 6 个汉字。`,
4159
+ path: n
4160
+ }), e.label.includes("是否") && i.push({
4161
+ rule: "T4",
4162
+ severity: "error",
4163
+ message: `分组「${e.label}」不写「是否」。`,
4164
+ path: n
4165
+ }), /[(())]|\b(?:px|ms)\b|%/.test(e.label) && i.push({
4166
+ rule: "T4",
4167
+ severity: "error",
4168
+ message: `分组「${e.label}」不带括号或单位,单位写进字段的 unit。`,
4169
+ path: n
4170
+ });
4171
+ });
4172
+ let a = U(r, { tagName: Nr });
4173
+ if (a.ok) for (let e of Gt(a.value)) i.push({
4174
+ rule: e.rule,
4175
+ severity: e.rule === "R9" ? "warning" : "error",
4176
+ message: e.message,
4177
+ ...e.field === void 0 ? {} : { path: qr(r, e.field) }
4178
+ });
4179
+ else for (let e of a.diagnostics) i.push({
4180
+ rule: "SPEC",
4181
+ severity: "error",
4182
+ message: e.message,
4183
+ path: e.path
4184
+ });
4185
+ return r.data.kind === "rows" && r.data.sample.length === 0 && i.push({
4186
+ rule: "D1",
4187
+ severity: "warning",
4188
+ message: "多行组件没有示例行:预览与新插入的组件只能显示空态。",
4189
+ path: ["data", "sample"]
4190
+ }), (r.defaultSize.width > Lr || r.defaultSize.height > Rr) && i.push({
4191
+ rule: "S1",
4192
+ severity: "warning",
4193
+ message: "默认尺寸超过一整屏:组件是上的一块,通常在 600×300 以内。",
4194
+ path: ["defaultSize"]
4195
+ }), r.template === void 0 ? t.renderSource !== void 0 && Wr(t.renderSource, r, i) : (i.push(...Ar(r)), t.renderSource !== void 0 && t.renderSource.trim() !== "" && i.push({
4196
+ rule: "TPL1",
4197
+ severity: "error",
4198
+ message: "规格带 template 时不能再写渲染代码:L2 物料只有数据。",
4199
+ path: ["template"]
4200
+ })), C(i);
4201
+ }
4202
+ function Hr(e, t, n, r) {
4203
+ let i = ["fields", t];
4204
+ (Pr.has(e.key) || Fr.test(e.label)) && r.push({
4205
+ rule: "T4",
4206
+ severity: "error",
4207
+ message: `「${e.label}」是描述性文案:组件只呈现读数,标题与说明用相邻的文本组件组合。`,
4208
+ path: i
4209
+ }), /(?:Column|Field)$/.test(e.key) && r.push({
4210
+ rule: "R7",
4211
+ severity: "error",
4212
+ message: `${e.key} 像是在手填列名:改成多行数据的一个角色,由数据面板绑定列。`,
4213
+ path: [...i, "key"]
4214
+ }), Ir.test(e.key) && r.push({
4215
+ rule: "R8",
4216
+ severity: "error",
4217
+ message: `${e.key} 是状态文案:空态 / 加载态 / 错误态由 SDK 状态视图统一提供。`,
4218
+ path: [...i, "key"]
4219
+ });
4220
+ let a = W(n, e.section);
4221
+ e.kind === "color" && a === "props" && r.push({
4222
+ rule: "P2",
4223
+ severity: "error",
4224
+ message: `颜色「${e.label}」是视觉量,放进文字 / 填充与描边 / 语义色分区,告警与主题才能改变它。`,
4225
+ path: [...i, "section"]
4226
+ }), a === "style" && !Dr.has(e.key) && !Or.has(e.key) && r.push({
4227
+ rule: "R4",
4228
+ severity: "warning",
4229
+ message: `${e.key} 不在样式键词典里:能复用 color / fillColor / trackColor 等通用键时优先复用。`,
4230
+ path: [...i, "key"]
4231
+ });
4232
+ }
4233
+ var Ur = [
4234
+ {
4235
+ pattern: /\bfetch\s*\(|\bXMLHttpRequest\b|\bWebSocket\b|\bEventSource\b|\bsendBeacon\b|\bimport\s*\(/,
4236
+ severity: "error",
4237
+ message: "渲染代码不自行发起网络请求或加载代码:数据经数据源进入 value / rows。"
4238
+ },
4239
+ {
4240
+ pattern: /\beval\s*\(|\bnew\s+Function\b|\bFunction\s*\(/,
4241
+ severity: "error",
4242
+ message: "渲染代码不动态执行代码:eval / Function 会绕过工坊体检。"
4243
+ },
4244
+ {
4245
+ pattern: /\blocalStorage\b|\bsessionStorage\b|\bindexedDB\b|document\.cookie/,
4246
+ severity: "error",
4247
+ message: "渲染代码不读写浏览器存储:组件状态只来自 props / style / 数据。"
4248
+ },
4249
+ {
4250
+ pattern: /\bpostMessage\s*\(|\bwindow\.(?:parent|top)\b/,
4251
+ severity: "error",
4252
+ message: "渲染代码不直接向页面发消息:事件用 emit 派发,数据经数据源进入。"
4253
+ },
4254
+ {
4255
+ pattern: /getRootNode\s*\(|\.host\b|ownerDocument\.body|document\.(?:body|head|documentElement)/,
4256
+ severity: "error",
4257
+ message: "只在 root 里绘制:宿主元素与页面归渲染器所有(物料渲染盒不变式)。"
4258
+ },
4259
+ {
4260
+ pattern: /\bsetInterval\s*\(|\brequestAnimationFrame\s*\(/,
4261
+ severity: "warning",
4262
+ message: "每次数据或配置变化都会整体重绘:定时器与动画帧不会随之清理,动画请用 CSS。"
4263
+ },
4264
+ {
4265
+ pattern: /\b(?:innerHTML|outerHTML)\s*=|insertAdjacentHTML\s*\(/,
4266
+ severity: "warning",
4267
+ message: "用 textContent 呈现数据,避免把读数当作 HTML 解释。"
4268
+ }
4269
+ ];
4270
+ function Wr(e, t, n) {
4271
+ let r = Gr(e);
4272
+ for (let e of Ur) e.pattern.test(r) && n.push({
4273
+ rule: "RENDER",
4274
+ severity: e.severity,
4275
+ message: e.message
4276
+ });
4277
+ r.trim() === "" && n.push({
4278
+ rule: "RENDER",
4279
+ severity: "error",
4280
+ message: "渲染代码为空。"
4281
+ }), t.data.kind === "none" && /\b(?:value|rows)\b/.test(r) && n.push({
4282
+ rule: "RENDER",
4283
+ severity: "warning",
4284
+ message: "组件声明为无数据,渲染代码却读了 value / rows:它们恒为空。"
4285
+ }), t.numberFormat !== void 0 && !/\bformatNumber\b/.test(r) && n.push({
4286
+ rule: "RENDER",
4287
+ severity: "warning",
4288
+ message: "开启了读数格式,但渲染代码没有调用 formatNumber:检查器里的小数位、单位不会生效。"
4289
+ });
4290
+ }
4291
+ function Gr(e) {
4292
+ return e.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1");
4293
+ }
4294
+ function Kr(e) {
4295
+ let t = Gr(e);
4296
+ return Ur.filter((e) => e.pattern.test(t)).map((e) => ({
4297
+ message: e.message,
4298
+ severity: e.severity
4299
+ }));
4300
+ }
4301
+ function qr(e, t) {
4302
+ let n = e.fields.findIndex((e) => e.key === t);
4303
+ return n < 0 ? ["numberFormat"] : ["fields", n];
4304
+ }
4305
+ //#endregion
4306
+ //#region ../plugin-sdk/dist/plugin-package.js
4307
+ function Jr(e) {
4308
+ let t = e;
4309
+ if (typeof t != "object" || !t || Array.isArray(t)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", [], "Plugin package options must be an object.");
4310
+ let n, r, i;
4311
+ try {
4312
+ n = t.id, r = t.plugin, i = t.materials;
4313
+ } catch {
4314
+ return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", [], "Plugin package options cannot be safely read.");
4315
+ }
4316
+ if (!Xr(n)) return v("PLUGIN_CORE_IDENTITY_INVALID", ["id"], "Plugin package id must be an ASCII identifier.");
4317
+ if (typeof r != "object" || !r || Array.isArray(r)) return v("PLUGIN_CORE_MANIFEST_NOT_OBJECT", ["plugin"], "Plugin package runtime must be an object.");
4318
+ let a = S(r);
4319
+ if (!a.ok) return g(a.diagnostics, ["plugin"]);
4320
+ let o;
4321
+ if (i !== void 0) {
4322
+ if (!Array.isArray(i)) return v("PLUGIN_CORE_MANIFEST_FIELD_INVALID", ["materials"], "Plugin package materials must be an array.");
4323
+ if (i.length > 0) {
4324
+ let e = Cr({
4325
+ id: n,
4326
+ materials: i
4327
+ });
4328
+ if (!e.ok) return e;
4329
+ o = e.value;
4330
+ }
4331
+ }
4332
+ let s = o?.materials ?? Object.freeze([]);
4333
+ return {
4334
+ ok: !0,
4335
+ value: {
4336
+ id: n,
4337
+ plugin: a.value,
4338
+ materials: s,
4339
+ define: (e) => Yr(a.value, o, e)
4340
+ },
4341
+ diagnostics: []
4342
+ };
4343
+ }
4344
+ function Yr(e, t, n) {
4345
+ if (t === void 0) return {
4346
+ ok: !0,
4347
+ value: {
4348
+ runtime: e,
4349
+ materials: Object.freeze([])
4350
+ },
4351
+ diagnostics: []
4352
+ };
4353
+ let r = t.define(n);
4354
+ return r.ok ? {
4355
+ ok: !0,
4356
+ value: {
4357
+ runtime: e,
4358
+ materials: r.value
4359
+ },
4360
+ diagnostics: []
4361
+ } : r;
4362
+ }
4363
+ function Xr(e) {
4364
+ return typeof e == "string" && e.length > 0 && e.length <= 128 && /^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(e);
4365
+ }
4366
+ //#endregion
4367
+ export { fe as $, Ft as A, $e as B, cn as C, Gt as D, sn as E, I as F, O as G, Se as H, P as I, A as J, M as K, Ne as L, It as M, H as N, z as O, W as P, ye as Q, F as R, en as S, on as T, be as U, E as V, Oe as W, _e as X, ve as Y, he as Z, kn as _, kr as a, nn as b, Cr as c, qn as d, ie as et, $n as f, Nn as g, On as h, Ar as i, Pt as j, U as k, Pn as l, An as m, Vr as n, C as nt, Or as o, jn as p, De as q, Kr as r, Dr as s, Jr as t, ee as tt, Jn as u, xn as v, tn as w, rn as x, dn as y, L as z };
4368
+
4369
+ //# sourceMappingURL=plugin-package-Cj-3iLv3.js.map