@jxsuite/studio 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (419) hide show
  1. package/canvas.html +21 -0
  2. package/dist/chunks/Overlay.dev-qfjzkms8.js +23 -0
  3. package/dist/chunks/{Overlay.dev-cszx7yn5.js.map → Overlay.dev-qfjzkms8.js.map} +1 -1
  4. package/dist/chunks/{adapter-z8fkmbmv.js → adapter-qfnesn5v.js} +2 -2
  5. package/dist/chunks/{cf-settings-mmyv436d.js → cf-settings-73sh5z4p.js} +3 -3
  6. package/dist/chunks/{components-799jpvhm.js → components-2bpqp4mq.js} +5 -7
  7. package/dist/chunks/{components-799jpvhm.js.map → components-2bpqp4mq.js.map} +1 -1
  8. package/dist/chunks/content-source-34gnkbnn.js +38 -0
  9. package/dist/chunks/content-source-34gnkbnn.js.map +9 -0
  10. package/dist/chunks/convert-to-repeater-t8kxre5s.js +258 -0
  11. package/dist/chunks/convert-to-repeater-t8kxre5s.js.map +10 -0
  12. package/dist/chunks/extension-sections-6mqydz35.js +301 -0
  13. package/dist/chunks/extension-sections-6mqydz35.js.map +11 -0
  14. package/dist/chunks/files-8kn321h1.js +70 -0
  15. package/dist/chunks/files-8kn321h1.js.map +9 -0
  16. package/dist/chunks/{format-host-8jxwts2p.js → format-host-mkwsmt8d.js} +3 -3
  17. package/dist/chunks/git-panel-tjbr191d.js +51 -0
  18. package/dist/chunks/git-panel-tjbr191d.js.map +9 -0
  19. package/dist/chunks/{index-baeg2x3y.js → index-7pxchcce.js} +4 -3
  20. package/dist/chunks/{index-baeg2x3y.js.map → index-7pxchcce.js.map} +3 -3
  21. package/dist/chunks/{jx-validate-qx8degj7.js → jx-validate-v6qgknrs.js} +3 -3
  22. package/dist/chunks/layers-panel-87pb25km.js +58 -0
  23. package/dist/chunks/layers-panel-87pb25km.js.map +9 -0
  24. package/dist/chunks/{monaco-setup-zjdp9zdw.js → monaco-setup-e0yh25j4.js} +4 -75
  25. package/dist/chunks/{monaco-setup-zjdp9zdw.js.map → monaco-setup-e0yh25j4.js.map} +3 -4
  26. package/dist/chunks/publish-panel-m0fcgdrt.js +21 -0
  27. package/dist/chunks/publish-panel-m0fcgdrt.js.map +9 -0
  28. package/dist/chunks/quick-search-rhs6cbsb.js +53 -0
  29. package/dist/chunks/quick-search-rhs6cbsb.js.map +9 -0
  30. package/dist/chunks/right-panel-zpdxd98t.js +37 -0
  31. package/dist/chunks/right-panel-zpdxd98t.js.map +9 -0
  32. package/dist/chunks/section-registry-zmckaxf4.js +30 -0
  33. package/dist/chunks/section-registry-zmckaxf4.js.map +9 -0
  34. package/dist/chunks/sp-overlay.dev-9ran0sfq.js +18 -0
  35. package/dist/chunks/sp-overlay.dev-9ran0sfq.js.map +9 -0
  36. package/dist/chunks/sp-popover.dev-rebmdncr.js +9 -0
  37. package/dist/chunks/sp-popover.dev-rebmdncr.js.map +9 -0
  38. package/dist/chunks/sp-progress-circle.dev-5vkppfkt.js +15 -0
  39. package/dist/chunks/sp-progress-circle.dev-5vkppfkt.js.map +9 -0
  40. package/dist/chunks/sp-tooltip.dev-ykqrg8h5.js +15 -0
  41. package/dist/chunks/sp-tooltip.dev-ykqrg8h5.js.map +9 -0
  42. package/dist/chunks/{sp-tray.dev-pb2fsd65.js → sp-tray.dev-ey59vfh7.js} +10 -8
  43. package/dist/chunks/{sp-tray.dev-pb2fsd65.js.map → sp-tray.dev-ey59vfh7.js.map} +2 -2
  44. package/dist/chunks/{studio-9qr6fq7p.js → studio-0rqqhrdy.js} +10 -378
  45. package/dist/chunks/{studio-9qr6fq7p.js.map → studio-0rqqhrdy.js.map} +4 -14
  46. package/dist/chunks/{studio-5x6tqqec.js → studio-2sj1jj3v.js} +10 -8
  47. package/dist/chunks/{studio-5x6tqqec.js.map → studio-2sj1jj3v.js.map} +2 -2
  48. package/dist/chunks/{studio-h3fw0wn8.js → studio-3fk1ac9z.js} +6 -4
  49. package/dist/chunks/{studio-h3fw0wn8.js.map → studio-3fk1ac9z.js.map} +2 -2
  50. package/dist/chunks/studio-41exgzhq.js +6690 -0
  51. package/dist/chunks/studio-41exgzhq.js.map +38 -0
  52. package/dist/chunks/{studio-7v2bpweq.js → studio-4mqb9a0j.js} +6 -4
  53. package/dist/chunks/{studio-7v2bpweq.js.map → studio-4mqb9a0j.js.map} +2 -2
  54. package/dist/chunks/studio-50k77cca.js +1787 -0
  55. package/dist/chunks/studio-50k77cca.js.map +18 -0
  56. package/dist/chunks/{studio-56v3zwk6.js → studio-6a0h7sne.js} +10 -8
  57. package/dist/chunks/{studio-56v3zwk6.js.map → studio-6a0h7sne.js.map} +2 -2
  58. package/dist/chunks/studio-6f0am8f2.js +53 -0
  59. package/dist/chunks/studio-6f0am8f2.js.map +10 -0
  60. package/dist/chunks/studio-6nmjc5qk.js +7002 -0
  61. package/dist/chunks/studio-6nmjc5qk.js.map +32 -0
  62. package/dist/chunks/studio-7afd21nw.js +67 -0
  63. package/dist/chunks/studio-7afd21nw.js.map +10 -0
  64. package/dist/chunks/{studio-xze4zrs1.js → studio-7bmdvzne.js} +2 -2
  65. package/dist/chunks/studio-7bmdvzne.js.map +10 -0
  66. package/dist/chunks/studio-8jpzqk5s.js +128 -0
  67. package/dist/chunks/studio-8jpzqk5s.js.map +10 -0
  68. package/dist/chunks/studio-94m77tgk.js +1482 -0
  69. package/dist/chunks/studio-94m77tgk.js.map +13 -0
  70. package/dist/chunks/studio-9je6w5sq.js +1000 -0
  71. package/dist/chunks/studio-9je6w5sq.js.map +16 -0
  72. package/dist/chunks/{studio-w7c6kvk7.js → studio-a7pzveq1.js} +2 -2
  73. package/dist/chunks/{studio-gs6kqdt1.js → studio-adn0z1k3.js} +14 -8
  74. package/dist/chunks/{studio-gs6kqdt1.js.map → studio-adn0z1k3.js.map} +3 -3
  75. package/dist/chunks/{studio-kr88ryr7.js → studio-bsxxx3x2.js} +17 -15
  76. package/dist/chunks/{studio-kr88ryr7.js.map → studio-bsxxx3x2.js.map} +7 -6
  77. package/dist/chunks/studio-bw5dz6km.js +608 -0
  78. package/dist/chunks/studio-bw5dz6km.js.map +21 -0
  79. package/dist/chunks/studio-c6s5getc.js +4232 -0
  80. package/dist/chunks/studio-c6s5getc.js.map +39 -0
  81. package/dist/chunks/studio-cjm7fdjf.js +451 -0
  82. package/dist/chunks/studio-cjm7fdjf.js.map +14 -0
  83. package/dist/chunks/{studio-cx91mnh8.js → studio-ckwz4d3x.js} +53 -53
  84. package/dist/chunks/{studio-cx91mnh8.js.map → studio-ckwz4d3x.js.map} +5 -5
  85. package/dist/chunks/studio-dg7zyt5x.js +28 -0
  86. package/dist/chunks/studio-dg7zyt5x.js.map +10 -0
  87. package/dist/chunks/studio-dzcyvvvz.js +166 -0
  88. package/dist/chunks/studio-dzcyvvvz.js.map +10 -0
  89. package/dist/chunks/{studio-7kqe41sa.js → studio-evkr5d3b.js} +15 -7
  90. package/dist/chunks/{studio-7kqe41sa.js.map → studio-evkr5d3b.js.map} +5 -4
  91. package/dist/chunks/studio-f12h6177.js +411 -0
  92. package/dist/chunks/studio-f12h6177.js.map +13 -0
  93. package/dist/chunks/studio-hbp1s8m9.js +1817 -0
  94. package/dist/chunks/studio-hbp1s8m9.js.map +14 -0
  95. package/dist/chunks/studio-k2sxjph5.js +15295 -0
  96. package/dist/chunks/studio-k2sxjph5.js.map +235 -0
  97. package/dist/chunks/studio-myje51t3.js +385 -0
  98. package/dist/chunks/studio-myje51t3.js.map +12 -0
  99. package/dist/chunks/studio-na6rwzhw.js +353 -0
  100. package/dist/chunks/studio-na6rwzhw.js.map +11 -0
  101. package/dist/chunks/{studio-4k0m4fmp.js → studio-p471gg5n.js} +126 -3
  102. package/dist/chunks/studio-p471gg5n.js.map +14 -0
  103. package/dist/chunks/{studio-9bjwf0d4.js → studio-rgwcpast.js} +5 -46
  104. package/dist/chunks/{studio-9bjwf0d4.js.map → studio-rgwcpast.js.map} +4 -5
  105. package/dist/chunks/{studio-esrewxap.js → studio-s519zc99.js} +3 -3
  106. package/dist/chunks/studio-sas7mt3k.js +75 -0
  107. package/dist/chunks/studio-sas7mt3k.js.map +10 -0
  108. package/dist/chunks/studio-t5wqwzdh.js +74 -0
  109. package/dist/chunks/studio-t5wqwzdh.js.map +10 -0
  110. package/dist/chunks/{studio-9qpspwfn.js → studio-temv5bw4.js} +5 -5
  111. package/dist/chunks/{studio-9qpspwfn.js.map → studio-temv5bw4.js.map} +1 -1
  112. package/dist/chunks/{studio-qkvt37c0.js → studio-tr20m8g8.js} +669 -18
  113. package/dist/chunks/studio-tr20m8g8.js.map +9 -0
  114. package/dist/chunks/{studio-v7jkjqng.js → studio-v96qfnww.js} +5514 -4291
  115. package/dist/chunks/studio-v96qfnww.js.map +54 -0
  116. package/dist/chunks/studio-vcetc91k.js +659 -0
  117. package/dist/chunks/studio-vcetc91k.js.map +10 -0
  118. package/dist/chunks/{studio-jm0z592w.js → studio-vmymjefp.js} +2972 -4937
  119. package/dist/chunks/studio-vmymjefp.js.map +98 -0
  120. package/dist/chunks/{studio-bghqfmea.js → studio-wwseqyw0.js} +2 -2
  121. package/dist/chunks/studio-x9hmy5kr.js +390 -0
  122. package/dist/chunks/studio-x9hmy5kr.js.map +10 -0
  123. package/dist/chunks/studio-xa0ce0n7.js +335 -0
  124. package/dist/chunks/studio-xa0ce0n7.js.map +10 -0
  125. package/dist/chunks/studio-xm3dbxvn.js +378 -0
  126. package/dist/chunks/studio-xm3dbxvn.js.map +19 -0
  127. package/dist/chunks/{studio-nqw433kv.js → studio-xmvbhg31.js} +2 -2
  128. package/dist/chunks/studio-zv37yrfa.js +1054 -0
  129. package/dist/chunks/studio-zv37yrfa.js.map +13 -0
  130. package/dist/chunks/{ws-client-q7hkz3j9.js → ws-client-654ts66j.js} +6 -4
  131. package/dist/chunks/ws-client-654ts66j.js.map +11 -0
  132. package/dist/iframe-entry.js +668 -230
  133. package/dist/studio.js +21080 -32585
  134. package/index.html +35 -4685
  135. package/package.json +17 -15
  136. package/src/about/about-modal.ts +42 -11
  137. package/src/browse/library-commands.ts +240 -0
  138. package/src/browse/library-layouts.ts +369 -0
  139. package/src/browse/library-model.ts +396 -0
  140. package/src/browse/library-pane.ts +1049 -0
  141. package/src/browse/library-preview.ts +252 -0
  142. package/src/browse/library-source.ts +150 -0
  143. package/src/canvas/canvas-helpers.ts +33 -9
  144. package/src/canvas/canvas-live-render.ts +45 -29
  145. package/src/canvas/canvas-patcher.ts +151 -31
  146. package/src/canvas/canvas-perf.ts +46 -7
  147. package/src/canvas/canvas-render.ts +1092 -220
  148. package/src/canvas/canvas-surface.ts +240 -0
  149. package/src/canvas/canvas-utils.ts +1166 -124
  150. package/src/canvas/iframe-drop.ts +2 -1
  151. package/src/canvas/iframe-entry.ts +241 -4
  152. package/src/canvas/iframe-host.ts +1226 -143
  153. package/src/canvas/iframe-inline-edit.ts +31 -0
  154. package/src/canvas/iframe-interaction.ts +76 -16
  155. package/src/canvas/iframe-keys.ts +107 -45
  156. package/src/canvas/iframe-overlay.ts +38 -1
  157. package/src/canvas/iframe-protocol.ts +137 -2
  158. package/src/canvas/iframe-render.ts +70 -2
  159. package/src/canvas/iframe-slash.ts +6 -0
  160. package/src/canvas/path-mapping.ts +56 -6
  161. package/src/canvas/surface-registry.ts +292 -0
  162. package/src/collab/collab-commands.ts +244 -0
  163. package/src/collab/collab-session.ts +198 -32
  164. package/src/collab/collab-state.ts +28 -2
  165. package/src/collab/presence-chips.ts +100 -9
  166. package/src/commands/active-registry.ts +42 -0
  167. package/src/commands/app-commands.ts +176 -0
  168. package/src/commands/budget.ts +158 -0
  169. package/src/commands/command-args.ts +253 -0
  170. package/src/commands/context.ts +387 -0
  171. package/src/commands/defaults.ts +580 -0
  172. package/src/commands/keymap.ts +571 -0
  173. package/src/commands/levels.ts +345 -0
  174. package/src/commands/live-context.ts +193 -0
  175. package/src/commands/reference.ts +227 -0
  176. package/src/commands/registry.ts +293 -0
  177. package/src/component-props.ts +3 -2
  178. package/src/content/draft-state.ts +106 -0
  179. package/src/content/entry-commands.ts +282 -0
  180. package/src/content/entry-editor.ts +327 -0
  181. package/src/content/entry-fields.ts +116 -0
  182. package/src/content/entry-model.ts +175 -0
  183. package/src/editor/canvas-context-menu.ts +17 -11
  184. package/src/editor/canvas-slash-bridge.ts +11 -4
  185. package/src/editor/context-menu.ts +804 -204
  186. package/src/editor/convert-to-component.ts +31 -10
  187. package/src/editor/convert-to-repeater.ts +3 -2
  188. package/src/editor/inline-edit-apply.ts +5 -5
  189. package/src/editor/inline-edit.ts +86 -50
  190. package/src/editor/insert-zone-action.ts +1 -1
  191. package/src/editor/shortcuts.ts +1043 -329
  192. package/src/editor/slash-menu.ts +1 -0
  193. package/src/files/elements.ts +166 -0
  194. package/src/files/file-ops.ts +178 -31
  195. package/src/files/files.ts +898 -268
  196. package/src/files/fs-events.ts +21 -0
  197. package/src/files/media-meta.ts +203 -0
  198. package/src/files/media-paths.ts +141 -0
  199. package/src/files/media-upload.ts +7 -3
  200. package/src/files/media-usage.ts +189 -0
  201. package/src/github/github-auth.ts +235 -33
  202. package/src/github/github-publish.ts +80 -21
  203. package/src/grid/grid-controller.ts +152 -12
  204. package/src/grid/grid-layout.ts +225 -20
  205. package/src/grid/grid-open.ts +120 -0
  206. package/src/grid/grid-panel.ts +554 -39
  207. package/src/grid/grid-source.ts +27 -1
  208. package/src/grid/redirects-grid.ts +599 -0
  209. package/src/grid/redirects.ts +398 -0
  210. package/src/grid/sources/content-source.ts +108 -2
  211. package/src/i18n/i18n-commands.ts +322 -0
  212. package/src/new-project/add-repo-modal.ts +8 -10
  213. package/src/new-project/import-tab.ts +7 -0
  214. package/src/new-project/location-fields.ts +9 -1
  215. package/src/new-project/new-project-modal.ts +221 -245
  216. package/src/packages/jxsuite-update.ts +97 -48
  217. package/src/packages/pull-package-sync.ts +18 -9
  218. package/src/page-params.ts +2 -1
  219. package/src/panels/activity-bar.ts +152 -91
  220. package/src/panels/activity-panel.ts +481 -0
  221. package/src/panels/ai-chat/chat-markdown.ts +8 -3
  222. package/src/panels/ai-chat/chat-view.ts +245 -18
  223. package/src/panels/ai-chat/composer.ts +31 -5
  224. package/src/panels/ai-chat/sessions-view.ts +17 -10
  225. package/src/panels/ai-panel.ts +279 -53
  226. package/src/panels/block-action-bar.ts +1115 -224
  227. package/src/panels/bottom-dock.ts +337 -0
  228. package/src/panels/canvas-dnd-bridge.ts +37 -8
  229. package/src/panels/chat-panel.ts +29 -12
  230. package/src/panels/data-explorer.ts +254 -112
  231. package/src/panels/data-grid.ts +10 -4
  232. package/src/panels/dnd.ts +28 -51
  233. package/src/panels/editors.ts +434 -107
  234. package/src/panels/elements-panel.ts +66 -2
  235. package/src/panels/empty-state.ts +112 -0
  236. package/src/panels/events-panel.ts +596 -82
  237. package/src/panels/formula-workspace.ts +408 -218
  238. package/src/panels/frontmatter-fields.ts +51 -10
  239. package/src/panels/frontmatter-panel.ts +357 -79
  240. package/src/panels/git-panel.ts +375 -164
  241. package/src/panels/head-panel.ts +791 -85
  242. package/src/panels/i18n-panel.ts +592 -0
  243. package/src/panels/imports-panel.ts +95 -85
  244. package/src/panels/jump-bar.ts +584 -0
  245. package/src/panels/layers-panel.ts +1106 -328
  246. package/src/panels/left-panel.ts +109 -204
  247. package/src/panels/navigator-panels.ts +131 -0
  248. package/src/panels/overlays.ts +7 -2
  249. package/src/panels/pane-context.ts +1477 -0
  250. package/src/panels/pane-grid.ts +406 -0
  251. package/src/panels/panel-registry.ts +340 -0
  252. package/src/panels/panel-scheduler.ts +75 -0
  253. package/src/panels/problems-panel.ts +234 -0
  254. package/src/panels/properties-panel.ts +946 -1139
  255. package/src/panels/provenance.ts +258 -0
  256. package/src/panels/quick-search.ts +791 -122
  257. package/src/panels/right-panel.ts +228 -102
  258. package/src/panels/seo-modal.ts +395 -0
  259. package/src/panels/settings-pane.ts +203 -0
  260. package/src/panels/signals-panel.ts +354 -137
  261. package/src/panels/statement-editor.ts +41 -25
  262. package/src/panels/statusbar.ts +342 -106
  263. package/src/panels/style-panel.ts +974 -463
  264. package/src/panels/style-utils.ts +3 -3
  265. package/src/panels/stylebook-doc.ts +4 -2
  266. package/src/panels/stylebook-layers-panel.ts +3 -2
  267. package/src/panels/stylebook-panel.ts +51 -26
  268. package/src/panels/tab-strip.ts +1058 -78
  269. package/src/panels/target-line.ts +274 -0
  270. package/src/panels/toolbar.ts +631 -484
  271. package/src/panels/welcome-screen.ts +301 -198
  272. package/src/platform-errors.ts +26 -3
  273. package/src/platform.ts +96 -2
  274. package/src/platforms/cloud.ts +71 -8
  275. package/src/platforms/devserver.ts +92 -29
  276. package/src/publish/deploy-checklist.ts +383 -0
  277. package/src/publish/pages-service.ts +10 -1
  278. package/src/publish/publish-commands.ts +218 -0
  279. package/src/publish/publish-panel.ts +110 -16
  280. package/src/recent-projects.ts +3 -2
  281. package/src/services/a11y-report.ts +505 -0
  282. package/src/services/ai-models.ts +30 -1
  283. package/src/services/ai-project-tools.ts +29 -10
  284. package/src/services/ai-system-prompt.ts +53 -14
  285. package/src/services/ai-tools.ts +39 -3
  286. package/src/services/ai-writes.ts +154 -0
  287. package/src/services/announce.ts +97 -0
  288. package/src/services/automation.ts +424 -175
  289. package/src/services/cem-export.ts +9 -4
  290. package/src/services/clock.ts +61 -0
  291. package/src/services/document-assistant.ts +36 -8
  292. package/src/services/idle.ts +179 -0
  293. package/src/services/import-client.ts +26 -0
  294. package/src/services/monaco-buffer.ts +627 -0
  295. package/src/services/monaco-lazy.ts +36 -0
  296. package/src/services/notify.ts +271 -0
  297. package/src/services/profile.ts +155 -0
  298. package/src/services/references.ts +0 -0
  299. package/src/services/token-lint.ts +3 -2
  300. package/src/services/tool-executor.ts +53 -7
  301. package/src/services/trusted-types.ts +123 -0
  302. package/src/settings/contexts-section.ts +427 -0
  303. package/src/settings/contributed-section.ts +149 -11
  304. package/src/settings/css-vars-editor.ts +306 -349
  305. package/src/settings/defs-editor.ts +93 -34
  306. package/src/settings/dependencies-editor.ts +7 -7
  307. package/src/settings/extension-sections.ts +37 -5
  308. package/src/settings/general-settings.ts +204 -121
  309. package/src/settings/locales-section.ts +347 -0
  310. package/src/settings/preferences-accounts.ts +140 -0
  311. package/src/settings/preferences-dialog.ts +620 -0
  312. package/src/settings/preferences-keymap.ts +270 -0
  313. package/src/settings/project-sections.ts +260 -0
  314. package/src/settings/section-registry.ts +169 -0
  315. package/src/settings/settings-document.ts +385 -0
  316. package/src/shell.ts +1549 -0
  317. package/src/site-context.ts +45 -20
  318. package/src/state.ts +14 -275
  319. package/src/store.ts +88 -43
  320. package/src/studio.ts +790 -346
  321. package/src/style/live-preview.ts +36 -0
  322. package/src/style/project-styles.ts +349 -0
  323. package/src/style/token-ref.ts +123 -0
  324. package/src/tabs/patch-ops.ts +16 -4
  325. package/src/tabs/project-config.ts +416 -0
  326. package/src/tabs/selection.ts +323 -0
  327. package/src/tabs/tab.ts +182 -47
  328. package/src/tabs/transact.ts +209 -28
  329. package/src/types.ts +68 -13
  330. package/src/ui/ai-credentials-form.ts +39 -35
  331. package/src/ui/ai-managed-connect.ts +7 -1
  332. package/src/ui/dynamic-slot.ts +224 -81
  333. package/src/ui/expression-editor.ts +71 -63
  334. package/src/ui/field-input.ts +4 -6
  335. package/src/ui/field-row.ts +215 -38
  336. package/src/ui/form-controls.ts +194 -7
  337. package/src/ui/layers.ts +492 -69
  338. package/src/ui/media-picker.ts +115 -25
  339. package/src/ui/panel-resize.ts +109 -91
  340. package/src/ui/progress-modal.ts +131 -50
  341. package/src/ui/regions.ts +462 -0
  342. package/src/ui/schema-form.ts +229 -45
  343. package/src/ui/spectrum.ts +24 -8
  344. package/src/ui/timing.ts +49 -0
  345. package/src/ui/value-selector.ts +20 -0
  346. package/src/ui/value-source.ts +348 -0
  347. package/src/ui/virtual-window.ts +400 -0
  348. package/src/utils/edit-display.ts +3 -2
  349. package/src/utils/inherited-style.ts +67 -37
  350. package/src/view.ts +64 -78
  351. package/src/workspace/pane-derive.ts +1258 -0
  352. package/src/workspace/session.ts +317 -0
  353. package/src/workspace/workspace.ts +1345 -23
  354. package/styles/canvas.css +653 -0
  355. package/styles/forced-colors.css +106 -0
  356. package/styles/inspector.css +1454 -0
  357. package/styles/overlays.css +2704 -0
  358. package/styles/panels.css +1701 -0
  359. package/styles/shell.css +1423 -0
  360. package/styles/tokens.css +151 -0
  361. package/dist/chunks/Overlay.dev-cszx7yn5.js +0 -22
  362. package/dist/chunks/extension-sections-qr3drkkw.js +0 -531
  363. package/dist/chunks/extension-sections-qr3drkkw.js.map +0 -12
  364. package/dist/chunks/files-j8a1t06k.js +0 -50
  365. package/dist/chunks/files-j8a1t06k.js.map +0 -9
  366. package/dist/chunks/git-panel-xtq5z81x.js +0 -28
  367. package/dist/chunks/git-panel-xtq5z81x.js.map +0 -9
  368. package/dist/chunks/layers-panel-ancn2wpq.js +0 -26
  369. package/dist/chunks/layers-panel-ancn2wpq.js.map +0 -9
  370. package/dist/chunks/settings-modal-17ttr96g.js +0 -29
  371. package/dist/chunks/settings-modal-17ttr96g.js.map +0 -9
  372. package/dist/chunks/sp-overlay.dev-earn5as8.js +0 -17
  373. package/dist/chunks/sp-overlay.dev-earn5as8.js.map +0 -9
  374. package/dist/chunks/sp-popover.dev-frxtfejn.js +0 -8
  375. package/dist/chunks/sp-popover.dev-frxtfejn.js.map +0 -9
  376. package/dist/chunks/sp-progress-circle.dev-7tvw34h8.js +0 -14
  377. package/dist/chunks/sp-progress-circle.dev-7tvw34h8.js.map +0 -9
  378. package/dist/chunks/sp-tooltip.dev-a9fywesm.js +0 -21
  379. package/dist/chunks/sp-tooltip.dev-a9fywesm.js.map +0 -10
  380. package/dist/chunks/studio-0xgs7xrs.js +0 -429
  381. package/dist/chunks/studio-0xgs7xrs.js.map +0 -13
  382. package/dist/chunks/studio-4d8hzcz5.js +0 -3427
  383. package/dist/chunks/studio-4d8hzcz5.js.map +0 -26
  384. package/dist/chunks/studio-4k0m4fmp.js.map +0 -13
  385. package/dist/chunks/studio-9smfzqhc.js +0 -19
  386. package/dist/chunks/studio-9smfzqhc.js.map +0 -10
  387. package/dist/chunks/studio-jm0z592w.js.map +0 -115
  388. package/dist/chunks/studio-m2t4mdg5.js +0 -1854
  389. package/dist/chunks/studio-m2t4mdg5.js.map +0 -18
  390. package/dist/chunks/studio-n4p11dfy.js +0 -853
  391. package/dist/chunks/studio-n4p11dfy.js.map +0 -12
  392. package/dist/chunks/studio-qkvt37c0.js.map +0 -9
  393. package/dist/chunks/studio-sjh1wt1a.js +0 -3744
  394. package/dist/chunks/studio-sjh1wt1a.js.map +0 -22
  395. package/dist/chunks/studio-v7jkjqng.js.map +0 -46
  396. package/dist/chunks/studio-xq0t7n5t.js +0 -140
  397. package/dist/chunks/studio-xq0t7n5t.js.map +0 -10
  398. package/dist/chunks/studio-xze4zrs1.js.map +0 -10
  399. package/dist/chunks/studio-yfcstdzy.js +0 -399
  400. package/dist/chunks/studio-yfcstdzy.js.map +0 -12
  401. package/dist/chunks/studio-zp7jncs8.js +0 -469
  402. package/dist/chunks/studio-zp7jncs8.js.map +0 -14
  403. package/dist/chunks/ws-client-q7hkz3j9.js.map +0 -11
  404. package/src/browse/browse-modal.ts +0 -69
  405. package/src/browse/browse.ts +0 -904
  406. package/src/canvas/canvas-diff.ts +0 -216
  407. package/src/canvas/nested-site-style.ts +0 -58
  408. package/src/new-project/design-fields.ts +0 -264
  409. package/src/new-project/templates.ts +0 -61
  410. package/src/panels/tab-bar.ts +0 -548
  411. package/src/settings/settings-modal.ts +0 -203
  412. /package/dist/chunks/{adapter-z8fkmbmv.js.map → adapter-qfnesn5v.js.map} +0 -0
  413. /package/dist/chunks/{cf-settings-mmyv436d.js.map → cf-settings-73sh5z4p.js.map} +0 -0
  414. /package/dist/chunks/{format-host-8jxwts2p.js.map → format-host-mkwsmt8d.js.map} +0 -0
  415. /package/dist/chunks/{jx-validate-qx8degj7.js.map → jx-validate-v6qgknrs.js.map} +0 -0
  416. /package/dist/chunks/{studio-w7c6kvk7.js.map → studio-a7pzveq1.js.map} +0 -0
  417. /package/dist/chunks/{studio-esrewxap.js.map → studio-s519zc99.js.map} +0 -0
  418. /package/dist/chunks/{studio-bghqfmea.js.map → studio-wwseqyw0.js.map} +0 -0
  419. /package/dist/chunks/{studio-nqw433kv.js.map → studio-xmvbhg31.js.map} +0 -0
@@ -0,0 +1,1817 @@
1
+ import {
2
+ INSPECTOR_TABS,
3
+ selectStylebookTag
4
+ } from "./studio-zv37yrfa.js";
5
+ import {
6
+ allConditionsPass,
7
+ autoOpenSections,
8
+ bindableSignalNames,
9
+ collectCssParts,
10
+ compressBorderSide,
11
+ compressShorthand,
12
+ css_meta_default,
13
+ defaultAsString,
14
+ expandBorderSide,
15
+ expandShorthand,
16
+ getCssInitialMap,
17
+ getLonghands,
18
+ isColorPopoverOpen,
19
+ isCustomElementDoc,
20
+ isInspectorSectionOpen,
21
+ livePreviewExpression,
22
+ mapSignalsFor,
23
+ openLogicTarget,
24
+ parseMediaEntries,
25
+ renderPropertiesPanelTemplate,
26
+ renderStatementEditor,
27
+ schemeOfQuery,
28
+ setInspectorSection,
29
+ spTextField,
30
+ widgetForType
31
+ } from "./studio-6nmjc5qk.js";
32
+ import {
33
+ createPanelScheduler
34
+ } from "./studio-8jpzqk5s.js";
35
+ import {
36
+ VALUE_SOURCE_LABELS,
37
+ capsForPosition,
38
+ countProvenance,
39
+ renderDynamicSlot,
40
+ renderExpressionEditor,
41
+ renderFieldRow,
42
+ renderProvenanceChip,
43
+ renderProvenanceDots,
44
+ renderStaticKvRow,
45
+ slotMode,
46
+ switchSlotMode
47
+ } from "./studio-c6s5getc.js";
48
+ import {
49
+ live
50
+ } from "./studio-xmvbhg31.js";
51
+ import {
52
+ loadUsages,
53
+ peekUsages,
54
+ usageFiles
55
+ } from "./studio-f12h6177.js";
56
+ import {
57
+ clickAnythingTo,
58
+ mediaDisplayName,
59
+ openPageAction,
60
+ renderEmptyState,
61
+ staleSelectionMessage
62
+ } from "./studio-v96qfnww.js";
63
+ import {
64
+ DEFAULT_INSPECTOR_TAB,
65
+ REGION_ATTR,
66
+ activeRegistry,
67
+ activeTab,
68
+ effect,
69
+ effectScope,
70
+ getEffectiveMedia,
71
+ getEffectiveStyle,
72
+ inferInputType,
73
+ inspectorStatementsRegion,
74
+ inspectorTabRegion,
75
+ isInspectorTabId,
76
+ mutateAddDef,
77
+ mutateAddSwitchCase,
78
+ mutateRemoveSwitchCase,
79
+ mutateRenameSwitchCase,
80
+ mutateUpdateMediaNestedStyle,
81
+ mutateUpdateMediaNestedStylePath,
82
+ mutateUpdateMediaStyle,
83
+ mutateUpdateNestedStyle,
84
+ mutateUpdateNestedStylePath,
85
+ mutateUpdateProperty,
86
+ mutateUpdateStyle,
87
+ primarySelection,
88
+ propLabel,
89
+ reactive,
90
+ shell,
91
+ showPromptDialog,
92
+ stringArg,
93
+ transactDoc,
94
+ unifyValues
95
+ } from "./studio-41exgzhq.js";
96
+ import {
97
+ classMap,
98
+ ifDefined
99
+ } from "./studio-ckwz4d3x.js";
100
+ import {
101
+ ref
102
+ } from "./studio-p471gg5n.js";
103
+ import {
104
+ html,
105
+ nothing,
106
+ render
107
+ } from "./studio-5x5774ak.js";
108
+ import {
109
+ COMMON_SELECTORS,
110
+ debouncedStyleCommit,
111
+ getEventBinding,
112
+ getNestedStyle,
113
+ getNodeAtPath,
114
+ isExpressionDef,
115
+ isFunctionDef,
116
+ isJsonObject,
117
+ isNestedSelector,
118
+ isRef,
119
+ nodeLabel,
120
+ renderOnly,
121
+ rightPanel,
122
+ updateUi
123
+ } from "./studio-cjm7fdjf.js";
124
+
125
+ // src/panels/events-panel.ts
126
+ var EVENT_NAMES = [
127
+ "onclick",
128
+ "oninput",
129
+ "onchange",
130
+ "onsubmit",
131
+ "onkeydown",
132
+ "onkeyup",
133
+ "onfocus",
134
+ "onblur",
135
+ "onmouseenter",
136
+ "onmouseleave"
137
+ ];
138
+ function eventNameOptions(declared) {
139
+ const seen = new Set;
140
+ const out = [];
141
+ for (const name of [...declared, ...EVENT_NAMES]) {
142
+ if (!seen.has(name)) {
143
+ seen.add(name);
144
+ out.push({ label: name, value: name });
145
+ }
146
+ }
147
+ return out;
148
+ }
149
+ var HANDLER_MODES = capsForPosition("eventHandler");
150
+ function seedForHandlerMode(mode, functionDefs) {
151
+ if (mode === "function") {
152
+ return { $prototype: "Function", body: "", parameters: [] };
153
+ }
154
+ if (mode === "expression") {
155
+ return { $expression: { operator: "=", target: null } };
156
+ }
157
+ const [firstFn] = functionDefs;
158
+ return firstFn ? { $ref: `#/state/${firstFn[0]}` } : { $ref: "" };
159
+ }
160
+ function bindableFieldRow({
161
+ prop,
162
+ label,
163
+ rawValue,
164
+ onChange,
165
+ onClear,
166
+ extraSignals = null,
167
+ fieldKey,
168
+ caps
169
+ }) {
170
+ const defs = activeTab.value.doc.document.state || {};
171
+ const boundRef = isRef(rawValue) ? rawValue.$ref : null;
172
+ const staticVal = slotMode(rawValue) === "literal" ? rawValue ?? "" : "";
173
+ const literalDefault = boundRef ? defaultAsString(defs[boundRef.startsWith("#/state/") ? boundRef.slice(8) : boundRef]) || undefined : undefined;
174
+ const slot = renderDynamicSlot({
175
+ caps,
176
+ extraSignals,
177
+ fieldKey,
178
+ literalDefault,
179
+ onChange,
180
+ staticWidget: spTextField(`prop:${label}`, String(staticVal), (v) => onChange(v)),
181
+ stateDefs: bindableSignalNames(activeTab.value.doc.document),
182
+ value: rawValue
183
+ });
184
+ return renderFieldRow({
185
+ hasValue: rawValue !== undefined && rawValue !== "",
186
+ label,
187
+ labelExtra: slot.modeButton,
188
+ prop,
189
+ widget: slot.widget,
190
+ ...onClear ? { onClear } : {}
191
+ });
192
+ }
193
+ function renderRepeaterFieldsTemplate(node, path) {
194
+ const key = path.join("/");
195
+ const clear = (name) => () => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, name));
196
+ const optional = (name, label) => bindableFieldRow({
197
+ caps: name === "filter" ? "repeaterFilter" : "repeaterSort",
198
+ fieldKey: `prop|${key}|${name}`,
199
+ label,
200
+ onChange: (v) => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, name, v || undefined)),
201
+ onClear: clear(name),
202
+ prop: name,
203
+ rawValue: node[name]
204
+ });
205
+ return html`
206
+ ${bindableFieldRow({
207
+ caps: "repeaterItems",
208
+ fieldKey: `prop|${key}|items`,
209
+ label: "Items",
210
+ onChange: (v) => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, "items", v)),
211
+ prop: "items",
212
+ rawValue: node.items
213
+ })}
214
+ ${optional("filter", "Filter")} ${optional("sort", "Sort")}
215
+ ${node.map ? html`
216
+ <sp-action-button
217
+ size="s"
218
+ class="logic-edit-template"
219
+ @click=${() => {
220
+ activeTab.value.session.selection = [[...path, "map"]];
221
+ }}
222
+ >Edit template →</sp-action-button
223
+ >
224
+ ` : nothing}
225
+ `;
226
+ }
227
+ function renderSwitchFieldsTemplate(node, path, mapSignals) {
228
+ const caseNames = Object.keys(node.cases || {});
229
+ return html`
230
+ ${bindableFieldRow({
231
+ caps: "switchDiscriminant",
232
+ extraSignals: mapSignals,
233
+ fieldKey: `prop|${path.join("/")}|$switch`,
234
+ label: "Expression",
235
+ onChange: (v) => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, path, "$switch", v)),
236
+ prop: "$switch",
237
+ rawValue: node.$switch
238
+ })}
239
+ <div class="logic-subhead">Cases</div>
240
+ ${caseNames.map((caseName) => {
241
+ let debounce;
242
+ return renderFieldRow({
243
+ hasValue: true,
244
+ label: "Case",
245
+ prop: `case:${caseName}`,
246
+ provenance: {
247
+ onClick: () => transactDoc(activeTab.value, (t) => mutateRemoveSwitchCase(t, path, caseName)),
248
+ state: "set",
249
+ title: `Remove case "${caseName}"`
250
+ },
251
+ widget: html`
252
+ <div class="logic-case-row">
253
+ <sp-textfield
254
+ size="s"
255
+ class="logic-case-name"
256
+ .value=${live(caseName)}
257
+ @input=${(e) => {
258
+ clearTimeout(debounce);
259
+ const next = e.target.value;
260
+ debounce = setTimeout(() => {
261
+ if (next && next !== caseName) {
262
+ transactDoc(activeTab.value, (t) => mutateRenameSwitchCase(t, path, caseName, next));
263
+ }
264
+ }, 500);
265
+ }}
266
+ ></sp-textfield>
267
+ <sp-action-button
268
+ size="xs"
269
+ quiet
270
+ class="logic-case-open"
271
+ title="Edit case"
272
+ @click=${(e) => {
273
+ e.stopPropagation();
274
+ activeTab.value.session.selection = [[...path, "cases", caseName]];
275
+ }}
276
+ >→</sp-action-button
277
+ >
278
+ </div>
279
+ `
280
+ });
281
+ })}
282
+ <span
283
+ class="kv-add"
284
+ @click=${() => {
285
+ transactDoc(activeTab.value, (t) => mutateAddSwitchCase(t, path, `case${caseNames.length + 1}`));
286
+ }}
287
+ >+ Add case</span
288
+ >
289
+ `;
290
+ }
291
+ function commitToTargets(targets, key, value) {
292
+ transactDoc(activeTab.value, (t) => {
293
+ for (const target of targets) {
294
+ mutateUpdateProperty(t, target, key, value);
295
+ }
296
+ });
297
+ }
298
+ function mixedEventCount(doc, targets, evKey) {
299
+ if (targets.length < 2) {
300
+ return 0;
301
+ }
302
+ const values = targets.map((path) => {
303
+ const n = getNodeAtPath(doc, path);
304
+ return n ? getEventBinding(n, evKey) ?? null : null;
305
+ });
306
+ return unifyValues(values).mixed ? targets.length : 0;
307
+ }
308
+ function renderEventsBody(node, selection, isCustomElement, targets = [selection]) {
309
+ const tab = activeTab.value;
310
+ const defs = tab.doc.document.state || {};
311
+ const functionDefs = Object.entries(defs).filter(([, d]) => d?.$prototype === "Function" || d?.$handler);
312
+ let declaredEventsT = nothing;
313
+ if (isCustomElement) {
314
+ const allEmits = [];
315
+ for (const [fnName, d] of Object.entries(defs)) {
316
+ if (isFunctionDef(d) && Array.isArray(d.emits)) {
317
+ for (const ev of d.emits) {
318
+ allEmits.push({ ...ev, _fn: fnName });
319
+ }
320
+ }
321
+ }
322
+ if (allEmits.length > 0) {
323
+ declaredEventsT = html`
324
+ <div class="events-section">
325
+ <sp-field-label size="s">Declared Events</sp-field-label>
326
+ ${allEmits.map((ev) => html`
327
+ <div class="declared-event-row" title=${ev.description || ""}>
328
+ <code class="event-code">${ev.name || "(unnamed)"}</code>
329
+ <span class="event-source">← ${ev._fn}</span>
330
+ ${isJsonObject(ev.type) && typeof ev.type.text === "string" ? html`<span class="event-type">${ev.type.text}</span>` : nothing}
331
+ </div>
332
+ `)}
333
+ </div>
334
+ <sp-divider size="s"></sp-divider>
335
+ `;
336
+ }
337
+ }
338
+ const eventEntries = Object.keys(node).filter((k) => k.startsWith("on")).map((k) => [k, getEventBinding(node, k)]).filter((pair) => pair[1] !== undefined);
339
+ return html`
340
+ <div class="events-panel">
341
+ ${declaredEventsT}
342
+ <div class="events-section">
343
+ ${eventEntries.length > 0 ? html` <sp-field-label size="s">Event Bindings</sp-field-label> ` : nothing}
344
+ ${eventEntries.map(([evKey, evVal]) => {
345
+ const inlineFn = isFunctionDef(evVal) ? evVal : null;
346
+ const expression = isExpressionDef(evVal) ? evVal.$expression : null;
347
+ const refValue = isRef(evVal) ? evVal.$ref : null;
348
+ const currentMode = slotMode(evVal);
349
+ const modeFieldKey = `event|${selection.join("/")}|${evKey}`;
350
+ return html`
351
+ <div class="event-binding">
352
+ <div class="event-row">
353
+ <jx-value-selector
354
+ size="s"
355
+ class="event-name"
356
+ .value=${evKey}
357
+ .options=${eventNameOptions(Object.keys(node).filter((k) => k.startsWith("on")))}
358
+ @change=${(e) => {
359
+ const newKey = e.target.value.trim();
360
+ if (newKey && newKey !== evKey && /^on[a-z][\da-z-]*$/i.test(newKey)) {
361
+ transactDoc(activeTab.value, (t) => {
362
+ for (const target of targets) {
363
+ const existing = getEventBinding(getNodeAtPath(t.doc.document, target), evKey);
364
+ if (existing === undefined) {
365
+ continue;
366
+ }
367
+ mutateUpdateProperty(t, target, evKey);
368
+ mutateUpdateProperty(t, target, newKey, existing);
369
+ }
370
+ });
371
+ }
372
+ }}
373
+ >
374
+ ></jx-value-selector
375
+ >
376
+ <sp-picker
377
+ size="s"
378
+ class="event-mode"
379
+ .value=${live(currentMode)}
380
+ @change=${(e) => {
381
+ const next = e.target.value;
382
+ commitToTargets(targets, evKey, switchSlotMode(modeFieldKey, currentMode, next, evVal, seedForHandlerMode(next, functionDefs)) ?? seedForHandlerMode(next, functionDefs));
383
+ }}
384
+ >
385
+ ${HANDLER_MODES.map((m) => html`<sp-menu-item value=${m}>${VALUE_SOURCE_LABELS[m]}</sp-menu-item>`)}
386
+ </sp-picker>
387
+ ${renderProvenanceChip(evKey, {
388
+ state: mixedEventCount(tab.doc.document, targets, evKey) > 0 ? "mixed" : "set",
389
+ donor: String(targets.length),
390
+ onClick: () => commitToTargets(targets, evKey),
391
+ title: mixedEventCount(tab.doc.document, targets, evKey) > 0 ? `${targets.length} selected elements bind ${evKey} differently — ` + `clearing removes it from all of them` : `Clear ${evKey}`
392
+ })}
393
+ <sp-action-button size="xs" quiet @click=${() => commitToTargets(targets, evKey)}>
394
+ <sp-icon-delete slot="icon"></sp-icon-delete>
395
+ </sp-action-button>
396
+ </div>
397
+ ${inlineFn ? html`
398
+ <div class="event-body-mode" style="display:flex;justify-content:flex-end">
399
+ <sp-action-group size="s" compact class="body-mode-toggle">
400
+ <sp-action-button
401
+ size="s"
402
+ class="body-mode-statements"
403
+ ?selected=${Array.isArray(inlineFn.body)}
404
+ @click=${() => {
405
+ if (!Array.isArray(inlineFn.body)) {
406
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
407
+ ...inlineFn,
408
+ body: []
409
+ }));
410
+ }
411
+ }}
412
+ >
413
+ Statements
414
+ </sp-action-button>
415
+ <sp-action-button
416
+ size="s"
417
+ class="body-mode-code"
418
+ ?selected=${!Array.isArray(inlineFn.body)}
419
+ @click=${() => {
420
+ if (Array.isArray(inlineFn.body)) {
421
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
422
+ ...inlineFn,
423
+ body: ""
424
+ }));
425
+ }
426
+ }}
427
+ >
428
+ Code
429
+ </sp-action-button>
430
+ </sp-action-group>
431
+ </div>
432
+ ${Array.isArray(inlineFn.body) ? renderStatementEditor(inlineFn.body, (next) => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
433
+ ...inlineFn,
434
+ body: next
435
+ })), {
436
+ allowEventRef: true,
437
+ emits: inlineFn.emits ?? [],
438
+ region: inspectorStatementsRegion(evKey),
439
+ stateDefs: Object.keys(defs),
440
+ stateEntries: defs
441
+ }) : html`
442
+ <div class="event-body-row">
443
+ <sp-textfield
444
+ size="s"
445
+ multiline
446
+ grows
447
+ placeholder="// handler body"
448
+ .value=${live(typeof inlineFn.body === "string" ? inlineFn.body : "")}
449
+ @input=${(e) => {
450
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
451
+ $prototype: "Function",
452
+ body: e.target.value,
453
+ parameters: inlineFn?.parameters || []
454
+ }));
455
+ }}
456
+ >
457
+ </sp-textfield>
458
+ <sp-action-button
459
+ size="xs"
460
+ quiet
461
+ title="Open in editor"
462
+ @click=${() => {
463
+ openLogicTarget({
464
+ editing: { eventKey: evKey, path: selection, type: "event" },
465
+ surface: "function"
466
+ });
467
+ }}
468
+ >
469
+ <sp-icon-code slot="icon"></sp-icon-code>
470
+ </sp-action-button>
471
+ </div>
472
+ `}
473
+ ` : expression ? html`
474
+ <div class="event-body-row">
475
+ <div style="flex:1;min-width:0">
476
+ ${renderExpressionEditor(expression, (newNode) => transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
477
+ $expression: newNode
478
+ })), {
479
+ allowEventRef: true,
480
+ preview: livePreviewExpression(tab, `event:${JSON.stringify(selection)}:${evKey}`, expression, selection, () => renderOnly("rightPanel")),
481
+ onInsertDef: (defName, def) => transactDoc(activeTab.value, (t) => mutateAddDef(t, defName, def)),
482
+ stateDefs: Object.keys(defs),
483
+ stateEntries: defs
484
+ })}
485
+ </div>
486
+ <sp-action-button
487
+ size="xs"
488
+ quiet
489
+ title="Open in formula workspace"
490
+ @click=${() => {
491
+ openLogicTarget({
492
+ editing: { eventKey: evKey, path: selection, type: "event" },
493
+ surface: "formula"
494
+ });
495
+ }}
496
+ >
497
+ <sp-icon-align-bottom slot="icon"></sp-icon-align-bottom>
498
+ </sp-action-button>
499
+ </div>
500
+ ` : html`
501
+ <sp-picker
502
+ size="s"
503
+ class="event-handler"
504
+ .value=${live(refValue || "__none__")}
505
+ @change=${(e) => {
506
+ if (e.target.value && e.target.value !== "__none__") {
507
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey, {
508
+ $ref: e.target.value
509
+ }));
510
+ } else {
511
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evKey));
512
+ }
513
+ }}
514
+ >
515
+ <sp-menu-item value="__none__">— none —</sp-menu-item>
516
+ ${functionDefs.map(([fName]) => html`<sp-menu-item value=${`#/state/${fName}`}
517
+ >${fName}</sp-menu-item
518
+ >`)}
519
+ </sp-picker>
520
+ `}
521
+ </div>
522
+ `;
523
+ })}
524
+ <sp-action-button
525
+ size="s"
526
+ quiet
527
+ @click=${() => {
528
+ let evName = "onclick";
529
+ for (const name of EVENT_NAMES) {
530
+ if (!node[name]) {
531
+ evName = name;
532
+ break;
533
+ }
534
+ }
535
+ if (functionDefs.length > 0) {
536
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evName, {
537
+ $ref: `#/state/${functionDefs[0][0]}`
538
+ }));
539
+ } else {
540
+ transactDoc(activeTab.value, (t) => mutateUpdateProperty(t, selection, evName, {
541
+ $prototype: "Function",
542
+ body: "",
543
+ parameters: []
544
+ }));
545
+ }
546
+ }}
547
+ >
548
+ <sp-icon-add slot="icon"></sp-icon-add>
549
+ Add Event
550
+ </sp-action-button>
551
+ </div>
552
+ </div>
553
+ `;
554
+ }
555
+ function renderObservedAttrsSection(document2) {
556
+ const state = document2.state || {};
557
+ const entries = Object.entries(state).filter(([, d]) => d.attribute);
558
+ return html`
559
+ <sp-accordion-item
560
+ label="Observed Attributes"
561
+ ?open=${isInspectorSectionOpen("__observed", false)}
562
+ @sp-accordion-item-toggle=${() => setInspectorSection("__observed", !isInspectorSectionOpen("__observed", false))}
563
+ >
564
+ <div class="style-section-body">
565
+ ${entries.length === 0 ? renderEmptyState({
566
+ compact: true,
567
+ message: "Attributes let a page set this component from markup. " + 'Name an "attribute" on a data entry to expose it here.'
568
+ }) : entries.map(([key, d]) => {
569
+ const def = d;
570
+ return renderStaticKvRow({
571
+ detail: `→ ${key}`,
572
+ name: String(def.attribute),
573
+ ...def.type ? { value: String(def.type) } : {},
574
+ ...def.reflects ? { tags: ["reflects"] } : {}
575
+ });
576
+ })}
577
+ </div>
578
+ </sp-accordion-item>
579
+ `;
580
+ }
581
+ function renderCssPropsSection(node) {
582
+ const style = node.style || {};
583
+ const cssProps = Object.entries(style).filter(([k]) => k.startsWith("--"));
584
+ if (cssProps.length === 0) {
585
+ return nothing;
586
+ }
587
+ return html`
588
+ <sp-accordion-item
589
+ label="CSS Properties"
590
+ ?open=${isInspectorSectionOpen("__cssprops", false)}
591
+ @sp-accordion-item-toggle=${() => setInspectorSection("__cssprops", !isInspectorSectionOpen("__cssprops", false))}
592
+ >
593
+ <div class="style-section-body">
594
+ ${cssProps.map(([prop, val]) => renderStaticKvRow({ name: prop, value: String(val) }))}
595
+ </div>
596
+ </sp-accordion-item>
597
+ `;
598
+ }
599
+ function renderCssPartsSection(document2) {
600
+ const parts = collectCssParts(document2);
601
+ if (parts.length === 0) {
602
+ return nothing;
603
+ }
604
+ return html`
605
+ <sp-accordion-item
606
+ label="CSS Parts"
607
+ ?open=${isInspectorSectionOpen("__cssparts", false)}
608
+ @sp-accordion-item-toggle=${() => setInspectorSection("__cssparts", !isInspectorSectionOpen("__cssparts", false))}
609
+ >
610
+ <div class="style-section-body">
611
+ ${parts.map((p) => renderStaticKvRow({ detail: `<${p.tag}>`, name: p.name }))}
612
+ </div>
613
+ </sp-accordion-item>
614
+ `;
615
+ }
616
+ function renderLogicPanelTemplate(helpers) {
617
+ const { isCustomElementDoc: isCustomElementDoc2 } = helpers;
618
+ const tab = activeTab.value;
619
+ const selection = primarySelection(tab?.session.selection);
620
+ const doc = tab?.doc.document;
621
+ if (!selection) {
622
+ return renderEmptyState({ message: clickAnythingTo("wire it up") });
623
+ }
624
+ const node = getNodeAtPath(doc, selection);
625
+ if (!node) {
626
+ return renderEmptyState({ message: staleSelectionMessage() });
627
+ }
628
+ const targets = tab.session.selection.length > 0 ? tab.session.selection : [selection];
629
+ const isMapNode = node.$prototype === "Array";
630
+ const isSwitchNode = Boolean(node.$switch);
631
+ const isRoot = selection.length === 0;
632
+ const isCustomElement = isCustomElementDoc2();
633
+ const mapSignals = mapSignalsFor(selection);
634
+ const repeaterT = isMapNode ? html`
635
+ <sp-accordion-item label="Repeating list" open>
636
+ <div class="style-section-body">${renderRepeaterFieldsTemplate(node, selection)}</div>
637
+ </sp-accordion-item>
638
+ ` : nothing;
639
+ const switchT = isSwitchNode ? html`
640
+ <sp-accordion-item label="Condition" open>
641
+ <div class="style-section-body">
642
+ ${renderSwitchFieldsTemplate(node, selection, mapSignals)}
643
+ </div>
644
+ </sp-accordion-item>
645
+ ` : nothing;
646
+ const eventsT = isMapNode ? nothing : html`
647
+ <sp-accordion-item label="Events" open>
648
+ <div class="style-section-body">
649
+ ${renderEventsBody(node, selection, isCustomElement, targets)}
650
+ </div>
651
+ </sp-accordion-item>
652
+ `;
653
+ const contractT = isCustomElement && isRoot ? html`
654
+ ${renderObservedAttrsSection(doc)} ${renderCssPropsSection(node)}
655
+ ${renderCssPartsSection(doc)}
656
+ ` : nothing;
657
+ return html`
658
+ <div class="style-sidebar">
659
+ <sp-accordion allow-multiple size="s">
660
+ ${repeaterT} ${switchT} ${eventsT} ${contractT}
661
+ </sp-accordion>
662
+ </div>
663
+ `;
664
+ }
665
+
666
+ // src/utils/inherited-style.ts
667
+ function computeInheritedSources(style, mediaNames, activeTab2, activeSelector = null) {
668
+ if (activeTab2 === null || mediaNames.length === 0) {
669
+ return {};
670
+ }
671
+ const inherited = {};
672
+ const layer = (block, donor) => {
673
+ for (const [p, v] of Object.entries(block)) {
674
+ if (typeof v !== "object") {
675
+ inherited[p] = { donor, value: v ?? "" };
676
+ }
677
+ }
678
+ };
679
+ if (activeSelector) {
680
+ layer(style[activeSelector] || {}, null);
681
+ for (const name of mediaNames) {
682
+ if (name === activeTab2) {
683
+ break;
684
+ }
685
+ layer((style[`@${name}`] || {})[activeSelector] || {}, name);
686
+ }
687
+ return inherited;
688
+ }
689
+ layer(style, null);
690
+ for (const name of mediaNames) {
691
+ if (name === activeTab2) {
692
+ break;
693
+ }
694
+ layer(style[`@${name}`] || {}, name);
695
+ }
696
+ return inherited;
697
+ }
698
+
699
+ // src/panels/target-line.ts
700
+ var _selectorTrigger = null;
701
+ function openSelectorMenu() {
702
+ if (!_selectorTrigger?.isConnected) {
703
+ throw new RangeError(`command "style.openSelectorMenu" needs the Inspector's Style tab rendered; its selector ` + `menu is not in the document`);
704
+ }
705
+ _selectorTrigger.open = "click";
706
+ }
707
+ function closeSelectorMenu() {
708
+ if (_selectorTrigger) {
709
+ _selectorTrigger.open = undefined;
710
+ }
711
+ }
712
+ function segmentTpl(segment) {
713
+ const cls = `tl-seg tl-seg--${segment.key}`;
714
+ if (!segment.onActivate) {
715
+ return html`<span class=${cls} data-seg=${segment.key} title=${segment.title}
716
+ >${segment.label}</span
717
+ >`;
718
+ }
719
+ return html`<button
720
+ type="button"
721
+ class=${cls}
722
+ data-seg=${segment.key}
723
+ title=${segment.title}
724
+ @click=${segment.onActivate}
725
+ >
726
+ ${segment.label}
727
+ </button>`;
728
+ }
729
+ var BASE_SELECTOR_LABEL = "base rule";
730
+ function selectorTpl(selector) {
731
+ const label = selector.value ?? BASE_SELECTOR_LABEL;
732
+ const choose = (value) => {
733
+ closeSelectorMenu();
734
+ selector.onSelect(value);
735
+ };
736
+ return html`
737
+ <overlay-trigger
738
+ placement="bottom-start"
739
+ triggered-by="click"
740
+ ${ref((el) => {
741
+ _selectorTrigger = el ?? null;
742
+ })}
743
+ >
744
+ <button
745
+ slot="trigger"
746
+ type="button"
747
+ class="tl-seg tl-seg--selector"
748
+ data-seg="selector"
749
+ title="The state or nested rule these edits land in — click to choose another"
750
+ >
751
+ ${label} ⌄
752
+ </button>
753
+ <sp-popover slot="click-content" tip class="tl-selector-popover">
754
+ <sp-menu class="tl-selector-menu">
755
+ <sp-menu-item value="__base__" @click=${() => choose(null)}>
756
+ ${BASE_SELECTOR_LABEL}
757
+ </sp-menu-item>
758
+ <sp-menu-divider></sp-menu-divider>
759
+ ${selector.options.map((option) => html`
760
+ <sp-menu-item value=${option} @click=${() => choose(option)}>
761
+ ${selector.declared.has(option) ? `${option} ●` : option}
762
+ </sp-menu-item>
763
+ `)}
764
+ <sp-menu-divider></sp-menu-divider>
765
+ <sp-menu-item
766
+ value="__add_custom__"
767
+ @click=${() => {
768
+ closeSelectorMenu();
769
+ selector.onAddCustom();
770
+ }}
771
+ >
772
+ + Add custom…
773
+ </sp-menu-item>
774
+ </sp-menu>
775
+ </sp-popover>
776
+ </overlay-trigger>
777
+ `;
778
+ }
779
+ function scopeTpl(scope) {
780
+ const classes = classMap({
781
+ "tl-scope": true,
782
+ [`tl-scope--${scope.kind}`]: true
783
+ });
784
+ const title = scope.kind === "element" ? "These edits apply to the selected element only" : `These edits apply to ${scope.label}`;
785
+ return html`<span class=${classes} data-scope=${scope.kind} title=${title}>${scope.label}</span>`;
786
+ }
787
+ function warningTpl(scope) {
788
+ if (scope.kind !== "project") {
789
+ return nothing;
790
+ }
791
+ const files = scope.affectedFiles ?? [];
792
+ return html`
793
+ <div class="tl-warning" role="status">
794
+ <p class="tl-warning-text">
795
+ Every edit here restyles ${scope.label} — ${scope.affected ?? "unknown"}.
796
+ </p>
797
+ ${scope.onToggleAffected ? html`<button type="button" class="tl-warning-action" @click=${scope.onToggleAffected}>
798
+ ${scope.showAffected ? "Hide affected" : "Show affected"}
799
+ </button>` : nothing}
800
+ ${scope.showAffected ? files.length > 0 ? html`<ul class="tl-affected">
801
+ ${files.map((file) => html`<li class="tl-affected-row">
802
+ <span class="tl-affected-path">${file.path}</span>
803
+ <span class="tl-affected-count">${file.count}</span>
804
+ </li>`)}
805
+ </ul>` : html`<p class="tl-affected-empty">
806
+ No file list — the project could not be searched.
807
+ </p>` : nothing}
808
+ </div>
809
+ `;
810
+ }
811
+ function renderTargetLine(model) {
812
+ return html`
813
+ <div class="target-line" data-jx-region="inspector/target">
814
+ <span class="tl-glyph" aria-hidden="true">⌖</span>
815
+ <div class="tl-segments">
816
+ ${model.segments.map((segment, index) => html`
817
+ ${index > 0 ? html`<span class="tl-sep" aria-hidden="true">·</span>` : nothing}
818
+ ${segmentTpl(segment)}
819
+ `)}
820
+ <span class="tl-sep" aria-hidden="true">·</span>
821
+ ${selectorTpl(model.selector)}
822
+ </div>
823
+ ${scopeTpl(model.scope)}
824
+ </div>
825
+ ${warningTpl(model.scope)}
826
+ `;
827
+ }
828
+
829
+ // src/panels/style-panel.ts
830
+ var DEFAULT_PROVENANCE = { state: "default" };
831
+ function isTagPath(selector) {
832
+ return /^[a-z]/.test(selector);
833
+ }
834
+ function resolveNestedTagStyle(style, tagPath) {
835
+ let obj = style;
836
+ for (const part of tagPath.split(" ")) {
837
+ obj = getNestedStyle(obj, part);
838
+ if (!obj) {
839
+ return {};
840
+ }
841
+ }
842
+ return obj;
843
+ }
844
+ function resolveContextStyle(style, activeSelector, editMedia) {
845
+ const base = editMedia ? getNestedStyle(style, `@${editMedia}`) ?? {} : style;
846
+ if (activeSelector) {
847
+ return isTagPath(activeSelector) ? resolveNestedTagStyle(base, activeSelector) : getNestedStyle(base, activeSelector) ?? {};
848
+ }
849
+ const flat = {};
850
+ for (const [p, v] of Object.entries(base)) {
851
+ if (typeof v !== "object") {
852
+ flat[p] = v;
853
+ }
854
+ }
855
+ return flat;
856
+ }
857
+ function contextMutate(sel, activeSelector, editMedia) {
858
+ if (activeSelector && isTagPath(activeSelector)) {
859
+ const stylePath = activeSelector.split(" ");
860
+ return editMedia ? (t, prop, val) => mutateUpdateMediaNestedStylePath(t, sel, editMedia, stylePath, prop, val) : (t, prop, val) => mutateUpdateNestedStylePath(t, sel, stylePath, prop, val);
861
+ }
862
+ if (activeSelector) {
863
+ return editMedia ? (t, prop, val) => mutateUpdateMediaNestedStyle(t, sel, editMedia, activeSelector, prop, val) : (t, prop, val) => mutateUpdateNestedStyle(t, sel, activeSelector, prop, val);
864
+ }
865
+ return editMedia ? (t, prop, val) => mutateUpdateMediaStyle(t, sel, editMedia, prop, val) : (t, prop, val) => mutateUpdateStyle(t, sel, prop, val);
866
+ }
867
+ function mixedStyleProps(tab, targets, activeSelector, editMedia) {
868
+ const mixed = new Set;
869
+ if (targets.length < 2) {
870
+ return mixed;
871
+ }
872
+ const blocks = targets.map((path) => {
873
+ const node = getNodeAtPath(tab.doc.document, path);
874
+ return resolveContextStyle(node?.style ?? {}, activeSelector, editMedia);
875
+ });
876
+ const props = new Set;
877
+ for (const block of blocks) {
878
+ for (const prop of Object.keys(block)) {
879
+ props.add(prop);
880
+ }
881
+ }
882
+ for (const prop of props) {
883
+ if (unifyValues(blocks.map((block) => block[prop] ?? null)).mixed) {
884
+ mixed.add(prop);
885
+ }
886
+ }
887
+ return mixed;
888
+ }
889
+ function renderStyleRow(entry, prop, value, onCommit, isWarning, gridMode, inheritedValue, templateSignals = [], fieldKey = prop, provenance) {
890
+ const chip = provenance ?? DEFAULT_PROVENANCE;
891
+ const type = inferInputType(entry);
892
+ const hasVal = value !== undefined && value !== "";
893
+ const placeholder = !hasVal && inheritedValue ? String(inheritedValue) : "";
894
+ const spanVal = gridMode && entry.$span === 2 ? 2 : undefined;
895
+ const slot = renderDynamicSlot({
896
+ caps: "styleProperty",
897
+ fieldKey,
898
+ onChange: (v) => onCommit(v === undefined || v === "" ? undefined : String(v)),
899
+ staticWidget: widgetForType(type, entry, prop, value, onCommit, { placeholder }),
900
+ stateDefs: templateSignals,
901
+ value
902
+ });
903
+ return renderFieldRow({
904
+ prop,
905
+ label: propLabel(entry, prop),
906
+ hasValue: false,
907
+ widget: slot.widget,
908
+ provenance: chip,
909
+ labelExtra: slot.modeButton,
910
+ ...spanVal != null && { span: spanVal },
911
+ warning: isWarning
912
+ });
913
+ }
914
+ function renderShorthandRow({
915
+ prop: shortProp,
916
+ entry,
917
+ style,
918
+ mutate,
919
+ inherited,
920
+ ctx
921
+ }) {
922
+ const tab = activeTab.value;
923
+ const longhands = getLonghands(shortProp);
924
+ const shortVal = style[shortProp];
925
+ const hasLonghands = longhands.some((l) => style[l.name] !== undefined);
926
+ const isExpanded = tab.session.ui.styleShorthands[shortProp] ?? hasLonghands;
927
+ const hasAnyVal = shortVal !== undefined || hasLonghands;
928
+ const writeShorthand = (val) => transactDoc(activeTab.value, (t) => {
929
+ for (const l of longhands) {
930
+ mutate(t, l.name);
931
+ }
932
+ mutate(t, shortProp, val);
933
+ });
934
+ const clearAll = () => transactDoc(activeTab.value, (t) => {
935
+ mutate(t, shortProp);
936
+ for (const l of longhands) {
937
+ mutate(t, l.name);
938
+ }
939
+ });
940
+ const headerWidget = html`
941
+ <div class="style-shorthand-header">
942
+ <sp-textfield
943
+ size="s"
944
+ .value=${live(shortVal || "")}
945
+ placeholder=${!shortVal && hasLonghands ? longhands.map((l) => style[l.name] || "0").join(" ") : !shortVal && inherited[shortProp] ? inherited[shortProp] : !shortVal && longhands.some((l) => inherited[l.name]) ? longhands.map((l) => inherited[l.name] || "0").join(" ") : ""}
946
+ @input=${debouncedStyleCommit(`short:${shortProp}`, 400, (e) => {
947
+ writeShorthand(e.target.value || undefined);
948
+ })}
949
+ ></sp-textfield>
950
+ <sp-action-button
951
+ size="xs"
952
+ quiet
953
+ @click=${(e) => {
954
+ e.stopPropagation();
955
+ activeTab.value.session.ui.styleShorthands = {
956
+ ...activeTab.value.session.ui.styleShorthands,
957
+ [shortProp]: !isExpanded
958
+ };
959
+ }}
960
+ >
961
+ ${isExpanded ? html`<sp-icon-chevron-down slot="icon"></sp-icon-chevron-down>` : html`<sp-icon-chevron-right slot="icon"></sp-icon-chevron-right>`}
962
+ </sp-action-button>
963
+ </div>
964
+ `;
965
+ return html`
966
+ ${renderFieldRow({
967
+ prop: shortProp,
968
+ label: propLabel(entry, shortProp),
969
+ hasValue: hasAnyVal,
970
+ widget: headerWidget,
971
+ provenance: shorthandProvenance(shortProp, ctx, hasAnyVal ? clearAll : undefined)
972
+ })}
973
+ ${isExpanded ? (() => {
974
+ const isBorderSide = entry.$shorthandType === "border-side";
975
+ const expanded = shortVal ? isBorderSide ? expandBorderSide(shortVal) : expandShorthand(shortVal, longhands.length) : null;
976
+ const compress = isBorderSide ? compressBorderSide : compressShorthand;
977
+ const emptyVal = isBorderSide ? "" : "0";
978
+ const recompress = (idx, val) => writeShorthand(compress(longhands.map((l, i) => i === idx ? val : style[l.name] ?? (expanded ? expanded[i] : emptyVal))));
979
+ return longhands.map(({ name, entry: lEntry }, idx) => {
980
+ const lVal = style[name] ?? (expanded ? expanded[idx] : "");
981
+ const hasLVal = lVal !== undefined && lVal !== "";
982
+ return html`
983
+ <div class="style-row style-row--child" data-prop=${name}>
984
+ <div class="style-row-label">
985
+ ${renderProvenanceChip(name, longhandProvenance(name, shortProp, hasLVal, ctx, () => recompress(idx, emptyVal)))}
986
+ <sp-field-label size="s" title=${name}
987
+ >${propLabel(lEntry, name)}</sp-field-label
988
+ >
989
+ </div>
990
+ ${widgetForType(inferInputType(lEntry), lEntry, name, lVal, (newVal) => recompress(idx, newVal || emptyVal), {
991
+ placeholder: !lVal && inherited[name] ? String(inherited[name]) : ""
992
+ })}
993
+ </div>
994
+ `;
995
+ });
996
+ })() : nothing}
997
+ `;
998
+ }
999
+ var _showAffected = false;
1000
+ function runCommand(id, args) {
1001
+ activeRegistry()?.run(id, args);
1002
+ }
1003
+ function stylebookTagOf(selector) {
1004
+ return selector && isTagPath(selector) ? selector.split(" ")[0] ?? null : null;
1005
+ }
1006
+ function isProjectStylesheet(path) {
1007
+ return /(?:^|\/)project\.json$/.test(path);
1008
+ }
1009
+ function resolveScope(tab, stylebookTag) {
1010
+ const path = tab.documentPath ?? "";
1011
+ const isProjectStyle = isProjectStylesheet(path);
1012
+ if (!stylebookTag) {
1013
+ return isProjectStyle ? projectScope("every page in this project", null) : { kind: "element", label: "this element" };
1014
+ }
1015
+ const shared = isProjectStyle || /^\.?\/?layouts\//.test(path);
1016
+ const label = `all <${stylebookTag}> in this ${shared ? "project" : "document"}`;
1017
+ return shared ? projectScope(label, stylebookTag) : { kind: "document", label };
1018
+ }
1019
+ function projectScope(label, tagName) {
1020
+ if (tagName === null) {
1021
+ return { affected: "how many pages that is, is unknown", kind: "project", label };
1022
+ }
1023
+ const query = { tagName };
1024
+ const state = peekUsages(query);
1025
+ if (state === null) {
1026
+ loadUsages(query).then(() => renderOnly("rightPanel"));
1027
+ }
1028
+ return {
1029
+ kind: "project",
1030
+ label,
1031
+ affected: affectedSentence(state),
1032
+ affectedFiles: state?.status === "ready" ? usageFiles(state.result) : [],
1033
+ showAffected: _showAffected,
1034
+ onToggleAffected: () => {
1035
+ _showAffected = !_showAffected;
1036
+ renderOnly("rightPanel");
1037
+ }
1038
+ };
1039
+ }
1040
+ function affectedSentence(state) {
1041
+ if (state === null || state.status === "pending") {
1042
+ return "counting the elements it affects…";
1043
+ }
1044
+ if (state.status !== "ready") {
1045
+ return "how many elements that is, is unknown";
1046
+ }
1047
+ const { files, refsTotal } = state.result;
1048
+ if (refsTotal === 0) {
1049
+ return "no element in the project uses it yet";
1050
+ }
1051
+ return `${refsTotal} element${refsTotal === 1 ? "" : "s"} in ${files.length} file${files.length === 1 ? "" : "s"}`;
1052
+ }
1053
+ function targetSegments(elementLabel, mediaTab, hasBreakpoints, schemeLayer) {
1054
+ const segments = [
1055
+ {
1056
+ key: "element",
1057
+ label: elementLabel,
1058
+ title: "What these edits are pointed at — click to find it in the Outline",
1059
+ onActivate: () => runCommand("view.setActivity", { tab: "layers" })
1060
+ },
1061
+ {
1062
+ key: "media",
1063
+ label: hasBreakpoints && mediaTab ? `@${mediaDisplayName(mediaTab)}` : "Base",
1064
+ title: "The breakpoint these edits land in. Choose it on the pane's Context control; click to " + "manage breakpoints.",
1065
+ onActivate: () => runCommand("settings.open", { section: "contexts" })
1066
+ }
1067
+ ];
1068
+ if (schemeLayer) {
1069
+ segments.push({
1070
+ key: "scheme",
1071
+ label: `${mediaDisplayName(schemeLayer)} variant`,
1072
+ title: "Edits land in this colour-scheme variant. Set the pane's Context control back to Auto " + "to edit base styles; click to manage schemes.",
1073
+ onActivate: () => runCommand("settings.open", { section: "contexts" })
1074
+ });
1075
+ }
1076
+ return segments;
1077
+ }
1078
+ function templateSignalOf(value) {
1079
+ if (typeof value !== "string") {
1080
+ return null;
1081
+ }
1082
+ return /\$\{\s*(?:state\.)?([A-Za-z_$][\w$]*)/.exec(value)?.[1] ?? null;
1083
+ }
1084
+ function isTemplateValue(value) {
1085
+ return typeof value === "string" && value.includes("${");
1086
+ }
1087
+ function provenanceOf(prop, ctx) {
1088
+ if (ctx.mixed?.props.has(prop)) {
1089
+ return {
1090
+ state: "mixed",
1091
+ donor: String(ctx.mixed.count),
1092
+ onClick: () => ctx.clear(prop)
1093
+ };
1094
+ }
1095
+ const value = ctx.active[prop];
1096
+ if (value !== undefined && ctx.own[prop] === undefined) {
1097
+ return {
1098
+ state: "inherited",
1099
+ donor: "site tokens",
1100
+ title: `Inherited from the project's site tokens — ${prop} is not set on this document`
1101
+ };
1102
+ }
1103
+ if (value !== undefined) {
1104
+ if (isTemplateValue(value)) {
1105
+ const signal = templateSignalOf(value);
1106
+ return {
1107
+ state: "bound",
1108
+ ...signal ? { donor: signal } : {},
1109
+ ...signal && ctx.signals.includes(signal) ? {
1110
+ onClick: () => {
1111
+ runCommand("view.setActivity", { tab: "data" });
1112
+ runCommand("data.expandRow", { name: signal });
1113
+ }
1114
+ } : {}
1115
+ };
1116
+ }
1117
+ return { state: "set", onClick: () => ctx.clear(prop) };
1118
+ }
1119
+ const inherited = ctx.inherited[prop];
1120
+ if (inherited) {
1121
+ return {
1122
+ state: "inherited",
1123
+ donor: inherited.donor,
1124
+ ...inherited.jump ? { onClick: inherited.jump } : {}
1125
+ };
1126
+ }
1127
+ return { state: "default" };
1128
+ }
1129
+ function shorthandProvenance(shortProp, ctx, clearAll) {
1130
+ const props = [shortProp, ...getLonghands(shortProp).map((l) => l.name)];
1131
+ const { mixed } = ctx;
1132
+ if (mixed && props.some((p) => mixed.props.has(p))) {
1133
+ return {
1134
+ state: "mixed",
1135
+ donor: String(mixed.count),
1136
+ ...clearAll ? { onClick: clearAll } : {}
1137
+ };
1138
+ }
1139
+ for (const p of props) {
1140
+ const prov = provenanceOf(p, ctx);
1141
+ if (prov.state === "default") {
1142
+ continue;
1143
+ }
1144
+ return prov.state === "set" && clearAll ? { ...prov, onClick: clearAll } : prov;
1145
+ }
1146
+ return DEFAULT_PROVENANCE;
1147
+ }
1148
+ function longhandProvenance(name, shortProp, hasValue, ctx, clearChild) {
1149
+ const { mixed } = ctx;
1150
+ if (mixed && (mixed.props.has(name) || hasValue && mixed.props.has(shortProp))) {
1151
+ return { state: "mixed", donor: String(mixed.count), onClick: clearChild };
1152
+ }
1153
+ const prov = provenanceOf(name, ctx);
1154
+ if (prov.state === "set" || prov.state === "default" && hasValue) {
1155
+ return { state: "set", onClick: clearChild };
1156
+ }
1157
+ return prov;
1158
+ }
1159
+ function sectionProvenance(entries, ctx) {
1160
+ return entries.map(({ prop, entry }) => inferInputType(entry) === "shorthand" ? shorthandProvenance(prop, ctx).state : provenanceOf(prop, ctx).state);
1161
+ }
1162
+ function styleSidebarTemplate(node, activeMediaTab, activeSelector, opts = {}) {
1163
+ const { effectiveStyle, stylebookSelector = null } = opts;
1164
+ const tab = activeTab.value;
1165
+ const sel = primarySelection(tab.session.selection);
1166
+ const ownRootStyle = node.style || {};
1167
+ const style = effectiveStyle ?? ownRootStyle;
1168
+ const templateSignals = Object.entries(tab.doc.document.state || {}).filter(([, d]) => !d?.$handler && d?.$prototype !== "Function").map(([defName]) => defName);
1169
+ const { sizeBreakpoints } = parseMediaEntries(getEffectiveMedia(tab.doc.document.$media));
1170
+ const mediaNames = sizeBreakpoints.map((bp) => bp.name);
1171
+ const mediaTab = activeMediaTab || null;
1172
+ const forcedScheme = tab.session.ui.previewColorScheme;
1173
+ const schemeLayer = mediaTab === null && (forcedScheme === "light" || forcedScheme === "dark") ? Object.entries(getEffectiveMedia(tab.doc.document.$media) ?? {}).find(([, q]) => schemeOfQuery(String(q)) === forcedScheme)?.[0] ?? null : null;
1174
+ const editMedia = mediaTab && mediaNames.length > 0 ? mediaTab : schemeLayer;
1175
+ const contextStyle = editMedia ? style[`@${editMedia}`] || {} : style;
1176
+ const declaredSelectors = new Set(Object.keys(contextStyle).filter((s) => isNestedSelector(s)));
1177
+ const selectorOptions = [
1178
+ ...new Set([
1179
+ ...COMMON_SELECTORS,
1180
+ ...declaredSelectors,
1181
+ ...activeSelector ? [activeSelector] : []
1182
+ ])
1183
+ ];
1184
+ const stylebookTag = stylebookTagOf(stylebookSelector);
1185
+ const elementLabel = stylebookTag ?? (typeof node.tagName === "string" ? node.tagName : "element");
1186
+ const targetLineT = renderTargetLine({
1187
+ segments: targetSegments(elementLabel, mediaTab, mediaNames.length > 0, schemeLayer),
1188
+ selector: {
1189
+ value: activeSelector,
1190
+ options: selectorOptions,
1191
+ declared: declaredSelectors,
1192
+ onSelect: (value) => {
1193
+ activeTab.value.session.ui.activeSelector = value;
1194
+ },
1195
+ onAddCustom: () => {
1196
+ showPromptDialog("Add Selector", {
1197
+ confirmLabel: "Use",
1198
+ message: "A state or nested rule to edit under this element.",
1199
+ placeholder: ":hover, .child, &.active, [attr]",
1200
+ validate: (v) => isNestedSelector(v.trim()) ? "" : 'A selector must start with ":", ".", "&" or "[".'
1201
+ }).then((value) => {
1202
+ if (value) {
1203
+ activeTab.value.session.ui.activeSelector = value.trim();
1204
+ renderOnly("rightPanel");
1205
+ }
1206
+ });
1207
+ }
1208
+ },
1209
+ scope: resolveScope(tab, stylebookTag)
1210
+ });
1211
+ const filterBarT = html`
1212
+ <div class="style-filter-bar">
1213
+ <sp-textfield
1214
+ size="s"
1215
+ class="style-filter-input"
1216
+ placeholder="Filter properties…"
1217
+ .value=${live(tab.session.ui.styleFilter || "")}
1218
+ @input=${(e) => {
1219
+ activeTab.value.session.ui.styleFilter = e.target.value;
1220
+ }}
1221
+ ></sp-textfield>
1222
+ </div>
1223
+ `;
1224
+ const activeStyle = resolveContextStyle(style, activeSelector, editMedia);
1225
+ const ownStyle = style === ownRootStyle ? activeStyle : resolveContextStyle(ownRootStyle, activeSelector, editMedia);
1226
+ const targets = tab.session.selection.length > 0 ? tab.session.selection : [sel];
1227
+ const mutateTargets = (t, prop, val) => {
1228
+ for (const target of targets) {
1229
+ contextMutate(target, activeSelector, editMedia)(t, prop, val);
1230
+ }
1231
+ };
1232
+ const commitStyle = (prop, val) => transactDoc(activeTab.value, (t) => mutateTargets(t, prop, val));
1233
+ const targetStyleOf = (t, target) => {
1234
+ const targetNode = getNodeAtPath(t.doc.document, target);
1235
+ return resolveContextStyle(targetNode?.style ?? {}, activeSelector, editMedia);
1236
+ };
1237
+ const inheritedInfo = {};
1238
+ if (schemeLayer) {
1239
+ const baseBlock = activeSelector ? getNestedStyle(style, activeSelector) ?? {} : style;
1240
+ for (const [p, v] of Object.entries(baseBlock)) {
1241
+ if (typeof v !== "object") {
1242
+ inheritedInfo[p] = {
1243
+ value: v ?? "",
1244
+ donor: "Base",
1245
+ jump: () => updateUi(activeTab.value, "previewColorScheme", "auto")
1246
+ };
1247
+ }
1248
+ }
1249
+ } else {
1250
+ for (const [p, source] of Object.entries(computeInheritedSources(style, mediaNames, mediaTab, activeSelector))) {
1251
+ inheritedInfo[p] = {
1252
+ value: source.value,
1253
+ donor: source.donor === null ? "Base" : mediaDisplayName(source.donor),
1254
+ jump: () => updateUi(activeTab.value, "activeMedia", source.donor)
1255
+ };
1256
+ }
1257
+ }
1258
+ const inheritedStyle = {};
1259
+ for (const [p, info] of Object.entries(inheritedInfo)) {
1260
+ inheritedStyle[p] = info.value;
1261
+ }
1262
+ const mixedProps = mixedStyleProps(tab, targets, activeSelector, editMedia);
1263
+ const provCtx = {
1264
+ own: ownStyle,
1265
+ active: activeStyle,
1266
+ inherited: inheritedInfo,
1267
+ signals: templateSignals,
1268
+ clear: (prop) => commitStyle(prop),
1269
+ ...mixedProps.size > 0 ? { mixed: { count: targets.length, props: mixedProps } } : {}
1270
+ };
1271
+ const newSections = autoOpenSections({ style: activeStyle }, tab.session.ui.styleSections);
1272
+ if (JSON.stringify(newSections) !== JSON.stringify(tab.session.ui.styleSections)) {
1273
+ tab.session.ui.styleSections = newSections;
1274
+ }
1275
+ const sectionProps = {};
1276
+ for (const sec of css_meta_default.$sections) {
1277
+ sectionProps[sec.key] = [];
1278
+ }
1279
+ for (const [prop, entry] of Object.entries(css_meta_default.$defs)) {
1280
+ if (typeof entry.$shorthand === "string") {
1281
+ continue;
1282
+ }
1283
+ const sec = entry.$section || "other";
1284
+ sectionProps[sec].push({ entry, prop });
1285
+ }
1286
+ for (const sec of css_meta_default.$sections) {
1287
+ sectionProps[sec.key].sort((a, b) => a.entry.$order - b.entry.$order);
1288
+ }
1289
+ const otherProps = [];
1290
+ for (const prop of Object.keys(activeStyle)) {
1291
+ if (!css_meta_default.$defs[prop]) {
1292
+ const val = activeStyle[prop];
1293
+ if (val !== null && typeof val === "object") {
1294
+ continue;
1295
+ }
1296
+ otherProps.push(prop);
1297
+ }
1298
+ }
1299
+ const nestedRules = [];
1300
+ for (const [prop, val] of Object.entries(activeStyle)) {
1301
+ if (val !== null && typeof val === "object" && !Array.isArray(val) && !prop.startsWith("@")) {
1302
+ nestedRules.push(prop);
1303
+ }
1304
+ }
1305
+ const filterText = (tab.session.ui.styleFilter || "").toLowerCase();
1306
+ const isFiltering = filterText.length > 0;
1307
+ const sectionTemplates = css_meta_default.$sections.filter((sec) => sec.key !== "other").map((sec) => {
1308
+ const entries = sectionProps[sec.key];
1309
+ const sectionActiveProps = entries.filter(({ prop, entry }) => {
1310
+ if (activeStyle[prop] !== undefined) {
1311
+ return true;
1312
+ }
1313
+ if (inferInputType(entry) === "shorthand") {
1314
+ return getLonghands(prop).some((l) => activeStyle[l.name] !== undefined);
1315
+ }
1316
+ return false;
1317
+ });
1318
+ const clearSection = () => {
1319
+ transactDoc(activeTab.value, (t) => {
1320
+ for (const { prop, entry } of sectionActiveProps) {
1321
+ if (activeStyle[prop] !== undefined) {
1322
+ mutateTargets(t, prop);
1323
+ }
1324
+ if (inferInputType(entry) === "shorthand") {
1325
+ for (const l of getLonghands(prop)) {
1326
+ mutateTargets(t, l.name);
1327
+ }
1328
+ }
1329
+ }
1330
+ });
1331
+ };
1332
+ const counts = countProvenance(sectionProvenance(entries, provCtx));
1333
+ const headingT = html`
1334
+ <span slot="heading" class="style-section-heading">
1335
+ ${sec.label}
1336
+ ${renderProvenanceDots(counts, {
1337
+ onClearSet: sectionActiveProps.length > 0 ? clearSection : undefined,
1338
+ clearTitle: `Clear all ${sec.label.toLowerCase()} properties`
1339
+ })}
1340
+ </span>
1341
+ `;
1342
+ const isOpen = isFiltering ? true : tab.session.ui.styleSections[sec.key] ?? false;
1343
+ if (!isOpen) {
1344
+ return html`
1345
+ <sp-accordion-item
1346
+ label=${sec.label}
1347
+ .open=${false}
1348
+ @sp-accordion-item-toggle=${(e) => {
1349
+ activeTab.value.session.ui.styleSections = {
1350
+ ...activeTab.value.session.ui.styleSections,
1351
+ [sec.key]: e.target.open
1352
+ };
1353
+ }}
1354
+ >
1355
+ ${headingT}
1356
+ </sp-accordion-item>
1357
+ `;
1358
+ }
1359
+ const rows = [];
1360
+ for (const { prop, entry } of entries) {
1361
+ const val = activeStyle[prop];
1362
+ const hasVal = val !== undefined;
1363
+ const condMet = allConditionsPass(entry, activeStyle);
1364
+ const type = inferInputType(entry);
1365
+ if (!hasVal && !condMet) {
1366
+ continue;
1367
+ }
1368
+ if (filterText) {
1369
+ const label = propLabel(entry, prop).toLowerCase();
1370
+ if (!prop.includes(filterText) && !label.includes(filterText)) {
1371
+ continue;
1372
+ }
1373
+ }
1374
+ if (type === "shorthand") {
1375
+ const longhands = getLonghands(prop);
1376
+ const hasAny = hasVal || longhands.some((l) => activeStyle[l.name] !== undefined);
1377
+ if (!hasAny && !condMet) {
1378
+ continue;
1379
+ }
1380
+ rows.push(renderShorthandRow({
1381
+ prop,
1382
+ entry,
1383
+ style: activeStyle,
1384
+ mutate: mutateTargets,
1385
+ inherited: inheritedStyle,
1386
+ ctx: provCtx
1387
+ }));
1388
+ } else {
1389
+ const isWarning = hasVal && !condMet;
1390
+ if (hasVal || condMet) {
1391
+ rows.push(renderStyleRow(entry, prop, val ?? "", (newVal) => commitStyle(prop, newVal || undefined), isWarning, sec.$layout === "grid", inheritedStyle[prop], templateSignals, `style|${sel.join("/")}|${editMedia ?? ""}|${activeSelector ?? ""}|${prop}`, provenanceOf(prop, provCtx)));
1392
+ }
1393
+ }
1394
+ }
1395
+ if (isFiltering && rows.length === 0) {
1396
+ return nothing;
1397
+ }
1398
+ return html`
1399
+ <sp-accordion-item
1400
+ label=${sec.label}
1401
+ .open=${isOpen}
1402
+ @sp-accordion-item-toggle=${(e) => {
1403
+ activeTab.value.session.ui.styleSections = {
1404
+ ...activeTab.value.session.ui.styleSections,
1405
+ [sec.key]: e.target.open
1406
+ };
1407
+ }}
1408
+ >
1409
+ ${headingT}
1410
+ <div class=${sec.$layout === "grid" ? "style-section-body--grid" : ""}>${rows}</div>
1411
+ </sp-accordion-item>
1412
+ `;
1413
+ });
1414
+ const cssInitialMap = getCssInitialMap();
1415
+ const customIsOpen = tab.session.ui.styleSections.other ?? otherProps.length > 0;
1416
+ const customSectionT = html`
1417
+ <sp-accordion-item
1418
+ label="Custom"
1419
+ .open=${customIsOpen}
1420
+ @sp-accordion-item-toggle=${(e) => {
1421
+ activeTab.value.session.ui.styleSections = {
1422
+ ...activeTab.value.session.ui.styleSections,
1423
+ other: e.target.open
1424
+ };
1425
+ }}
1426
+ >
1427
+ <div>
1428
+ ${otherProps.map((prop) => html`
1429
+ <div class="kv-row">
1430
+ <sp-textfield
1431
+ size="s"
1432
+ class="kv-key"
1433
+ .value=${live(prop)}
1434
+ @change=${(e) => {
1435
+ const newProp = e.target.value.trim();
1436
+ if (!newProp || newProp === prop) {
1437
+ return;
1438
+ }
1439
+ transactDoc(activeTab.value, (t) => {
1440
+ for (const target of targets) {
1441
+ const current = targetStyleOf(t, target)[prop];
1442
+ if (current === undefined) {
1443
+ continue;
1444
+ }
1445
+ const write = contextMutate(target, activeSelector, editMedia);
1446
+ write(t, prop);
1447
+ write(t, newProp, String(current));
1448
+ }
1449
+ });
1450
+ }}
1451
+ ></sp-textfield>
1452
+ <sp-textfield
1453
+ size="s"
1454
+ class="kv-val"
1455
+ .value=${live(String(activeStyle[prop]))}
1456
+ placeholder=${ifDefined(cssInitialMap.get(prop))}
1457
+ @input=${debouncedStyleCommit(`custom:${prop}`, 400, (e) => {
1458
+ commitStyle(prop, e.target.value);
1459
+ })}
1460
+ ></sp-textfield>
1461
+ <sp-action-button size="xs" quiet @click=${() => commitStyle(prop)}>
1462
+ <sp-icon-close slot="icon"></sp-icon-close>
1463
+ </sp-action-button>
1464
+ </div>
1465
+ `)}
1466
+ <div style="display:flex;gap:4px;padding-top:4px">
1467
+ <sp-textfield
1468
+ size="s"
1469
+ placeholder="Property name…"
1470
+ style="flex:1"
1471
+ @keydown=${(e) => {
1472
+ if (e.key === "Enter") {
1473
+ e.preventDefault();
1474
+ const prop = e.target.value.trim();
1475
+ if (prop) {
1476
+ const initial = cssInitialMap.get(prop) || "";
1477
+ commitStyle(prop, initial || "");
1478
+ e.target.value = "";
1479
+ }
1480
+ }
1481
+ }}
1482
+ ></sp-textfield>
1483
+ </div>
1484
+ </div>
1485
+ </sp-accordion-item>
1486
+ `;
1487
+ const nestedIsOpen = tab.session.ui.styleSections.nested ?? nestedRules.length > 0;
1488
+ const nestedSectionT = nestedRules.length > 0 ? html`
1489
+ <sp-accordion-item
1490
+ label="Relative Styling"
1491
+ .open=${nestedIsOpen}
1492
+ @sp-accordion-item-toggle=${(e) => {
1493
+ activeTab.value.session.ui.styleSections = {
1494
+ ...activeTab.value.session.ui.styleSections,
1495
+ nested: e.target.open
1496
+ };
1497
+ }}
1498
+ >
1499
+ <div style="display:flex;flex-direction:column;gap:4px;padding:4px 0">
1500
+ ${nestedRules.map((rule) => html`
1501
+ <div style="display:flex;align-items:center;gap:4px">
1502
+ <button
1503
+ style="flex:1;text-align:left;padding:6px 10px;background:var(--spectrum-gray-200, #1a1a1a);border:none;border-radius:var(--radius);color:var(--spectrum-gray-900, #fafafa);font-size:var(--spectrum-font-size-75, 12px);cursor:pointer"
1504
+ @click=${() => {
1505
+ const newSelector = activeSelector ? `${activeSelector} ${rule}` : rule;
1506
+ selectStylebookTag(newSelector, undefined, {
1507
+ panCanvas: true
1508
+ });
1509
+ }}
1510
+ >
1511
+ ${rule}
1512
+ </button>
1513
+ <sp-action-button size="xs" quiet @click=${() => commitStyle(rule)}>
1514
+ <sp-icon-delete slot="icon"></sp-icon-delete>
1515
+ </sp-action-button>
1516
+ </div>
1517
+ `)}
1518
+ <button
1519
+ style="padding:6px 10px;background:none;border:1px dashed var(--spectrum-gray-400, #333);border-radius:var(--radius);color:var(--spectrum-gray-700, #a1a1aa);font-size:var(--spectrum-font-size-75, 12px);cursor:pointer"
1520
+ @click=${async () => {
1521
+ const name = await showPromptDialog("Add Nested Selector", {
1522
+ confirmLabel: "Add",
1523
+ message: "Enter a selector to nest under the current rule.",
1524
+ placeholder: "th, :hover, .active",
1525
+ validate: (v) => v.trim() ? "" : "Enter a selector."
1526
+ });
1527
+ if (name) {
1528
+ commitStyle(name, {});
1529
+ }
1530
+ }}
1531
+ >
1532
+ + Add
1533
+ </button>
1534
+ </div>
1535
+ </sp-accordion-item>
1536
+ ` : nothing;
1537
+ return html`
1538
+ <div class="style-sidebar">
1539
+ ${targetLineT} ${filterBarT}
1540
+ <sp-accordion allow-multiple size="s">
1541
+ ${sectionTemplates} ${nestedSectionT} ${customSectionT}
1542
+ </sp-accordion>
1543
+ </div>
1544
+ `;
1545
+ }
1546
+ function renderStylePanelTemplate(ctx) {
1547
+ const tab = activeTab.value;
1548
+ const noDocument = () => renderEmptyState({
1549
+ actions: [openPageAction()],
1550
+ message: "Open a page to style what you click."
1551
+ });
1552
+ if (!tab) {
1553
+ return noDocument();
1554
+ }
1555
+ if (ctx.getCanvasMode() === "stylebook" && shell.stylebook.selection) {
1556
+ const node2 = tab.doc.document;
1557
+ if (!node2) {
1558
+ return noDocument();
1559
+ }
1560
+ return styleSidebarTemplate(node2, tab.session.ui.activeMedia, tab.session.ui.activeSelector, {
1561
+ effectiveStyle: getEffectiveStyle(node2.style),
1562
+ stylebookSelector: shell.stylebook.selection
1563
+ });
1564
+ }
1565
+ const selected = primarySelection(tab.session.selection);
1566
+ if (!selected) {
1567
+ return renderEmptyState({ message: clickAnythingTo("style it") });
1568
+ }
1569
+ const node = getNodeAtPath(tab.doc.document, selected);
1570
+ if (!node) {
1571
+ return renderEmptyState({ message: staleSelectionMessage() });
1572
+ }
1573
+ return styleSidebarTemplate(node, tab.session.ui.activeMedia, tab.session.ui.activeSelector);
1574
+ }
1575
+ function styleCommands() {
1576
+ const styleTabOpen = (ctx) => ctx.document.open && ctx.selection.count > 0;
1577
+ return [
1578
+ {
1579
+ category: "View",
1580
+ id: "style.openSelectorMenu",
1581
+ level: "selection",
1582
+ menus: ["palette"],
1583
+ group: "8_style",
1584
+ requires: "the Style tab showing a selected element",
1585
+ when: styleTabOpen,
1586
+ run: () => openSelectorMenu(),
1587
+ title: "Open Selector Menu"
1588
+ },
1589
+ {
1590
+ args: {
1591
+ additionalProperties: false,
1592
+ properties: {
1593
+ selector: pathlessSelectorProperty()
1594
+ },
1595
+ required: ["selector"],
1596
+ type: "object"
1597
+ },
1598
+ category: "View",
1599
+ id: "style.setSelector",
1600
+ level: "selection",
1601
+ menus: ["palette"],
1602
+ group: "8_style",
1603
+ requires: "an element selection",
1604
+ when: styleTabOpen,
1605
+ run: (_commandCtx, args) => {
1606
+ const { selector } = args;
1607
+ if (selector === null) {
1608
+ const tab2 = activeTab.value;
1609
+ if (tab2) {
1610
+ tab2.session.ui.activeSelector = null;
1611
+ }
1612
+ return;
1613
+ }
1614
+ const value = stringArg("style.setSelector", args, "selector");
1615
+ if (!isNestedSelector(value)) {
1616
+ throw new RangeError(`command "style.setSelector" argument "selector": "${value}" is not a nested ` + `selector — it must start with ":", ".", "&" or "["`);
1617
+ }
1618
+ const tab = activeTab.value;
1619
+ if (!tab) {
1620
+ throw new RangeError(`command "style.setSelector" needs an open document`);
1621
+ }
1622
+ tab.session.ui.activeSelector = value;
1623
+ },
1624
+ title: "Set Style Selector"
1625
+ }
1626
+ ];
1627
+ }
1628
+ function pathlessSelectorProperty() {
1629
+ return {
1630
+ description: 'A nested selector such as ":hover", ".child" or "[open]". null edits the base context.',
1631
+ oneOf: [{ type: "string" }, { type: "null" }]
1632
+ };
1633
+ }
1634
+ function registerStyleCommands(registry) {
1635
+ registry.registerAll(styleCommands());
1636
+ }
1637
+
1638
+ // src/panels/right-panel.ts
1639
+ var _ctx = null;
1640
+ var _scope = null;
1641
+ var _scheduler = null;
1642
+ var _detached = reactive({ tab: DEFAULT_INSPECTOR_TAB });
1643
+ function mount(ctx) {
1644
+ _ctx = ctx;
1645
+ _scheduler = createPanelScheduler({
1646
+ blockWhile: isColorPopoverOpen,
1647
+ render: _doRender,
1648
+ root: rightPanel
1649
+ });
1650
+ _scheduler.bindFocus();
1651
+ _scope = effectScope();
1652
+ _scope.run(() => {
1653
+ effect(() => {
1654
+ const tab = activeTab.value;
1655
+ shell.layoutSelection;
1656
+ if (tab) {
1657
+ tab.doc.document;
1658
+ tab.session.selection.map((path) => path.join("/")).join("|");
1659
+ tab.session.ui.rightTab;
1660
+ tab.session.ui.activeMedia;
1661
+ tab.session.ui.activeSelector;
1662
+ tab.session.ui.styleSections;
1663
+ tab.session.ui.styleShorthands;
1664
+ tab.session.ui.styleFilter;
1665
+ tab.session.ui.inspectorSections;
1666
+ }
1667
+ render2();
1668
+ });
1669
+ });
1670
+ }
1671
+ function unmount() {
1672
+ _scope?.stop();
1673
+ _scope = null;
1674
+ _ctx = null;
1675
+ _scheduler?.unbind();
1676
+ _scheduler = null;
1677
+ _containers = null;
1678
+ _detached.tab = DEFAULT_INSPECTOR_TAB;
1679
+ }
1680
+ function render2() {
1681
+ _scheduler?.schedule();
1682
+ }
1683
+ function inspectorTab() {
1684
+ const tab = activeTab.value;
1685
+ if (!tab) {
1686
+ return _detached.tab;
1687
+ }
1688
+ const stored = tab.session.ui.rightTab;
1689
+ return isInspectorTabId(stored) ? stored : DEFAULT_INSPECTOR_TAB;
1690
+ }
1691
+ function setInspectorTab(tab) {
1692
+ const aTab = activeTab.value;
1693
+ if (aTab) {
1694
+ aTab.session.ui.rightTab = tab;
1695
+ } else {
1696
+ _detached.tab = tab;
1697
+ }
1698
+ render2();
1699
+ }
1700
+ var _containers = null;
1701
+ function _ensureContainers(ctx) {
1702
+ if (_containers) {
1703
+ return _containers;
1704
+ }
1705
+ _containers = new Map(INSPECTOR_TABS.map((t) => {
1706
+ const el = document.createElement("div");
1707
+ el.className = "panel-body";
1708
+ el.setAttribute(REGION_ATTR, inspectorTabRegion(t.id));
1709
+ return [t.id, el];
1710
+ }));
1711
+ ctx.mountAssistant(_containers.get("assistant"));
1712
+ return _containers;
1713
+ }
1714
+ function inspectorTarget() {
1715
+ const tab = activeTab.value;
1716
+ if (!tab) {
1717
+ return "no document";
1718
+ }
1719
+ const layout = shell.layoutSelection;
1720
+ if (layout) {
1721
+ return `<${layout.tagName || "element"}> in ${layout.layoutFile || "the layout"}`;
1722
+ }
1723
+ const paths = tab.session.selection;
1724
+ const selection = primarySelection(paths);
1725
+ if (selection) {
1726
+ return paths.length > 1 ? `${paths.length} elements` : nodeLabel(getNodeAtPath(tab.doc.document, selection));
1727
+ }
1728
+ const path = tab.documentPath;
1729
+ return path ? path.split("/").at(-1) ?? "document" : "document";
1730
+ }
1731
+ function headerTpl(tab) {
1732
+ const title = INSPECTOR_TABS.find((t) => t.id === tab)?.title ?? tab;
1733
+ return html`
1734
+ <header class="panel-header">
1735
+ <span class="panel-header-title">${title}</span>
1736
+ <span class="panel-header-level">${inspectorTarget()}</span>
1737
+ </header>
1738
+ `;
1739
+ }
1740
+ function tabsTpl(tab) {
1741
+ return html`
1742
+ <div class="panel-tabs inspector-tabs">
1743
+ <sp-tabs
1744
+ selected=${tab}
1745
+ quiet
1746
+ size="s"
1747
+ @change=${(e) => {
1748
+ const sel = e.target.selected;
1749
+ if (sel && sel !== tab && isInspectorTabId(sel)) {
1750
+ setInspectorTab(sel);
1751
+ }
1752
+ }}
1753
+ >
1754
+ ${INSPECTOR_TABS.map((t) => html`<sp-tab value=${t.id} label=${t.title}></sp-tab>`)}
1755
+ </sp-tabs>
1756
+ </div>
1757
+ `;
1758
+ }
1759
+ function noDocumentTpl() {
1760
+ return renderEmptyState({
1761
+ actions: [openPageAction()],
1762
+ message: "Open a page to inspect and style what you click."
1763
+ });
1764
+ }
1765
+ function _doRender() {
1766
+ if (!_ctx) {
1767
+ return;
1768
+ }
1769
+ try {
1770
+ const ctx = _ctx;
1771
+ const aTab = activeTab.value;
1772
+ const tab = inspectorTab();
1773
+ render(html`${headerTpl(tab)}${tabsTpl(tab)}`, rightPanel);
1774
+ const containers = _ensureContainers(ctx);
1775
+ for (const [key, el] of containers) {
1776
+ el.style.display = key === tab ? "" : "none";
1777
+ if (!el.parentNode) {
1778
+ rightPanel.append(el);
1779
+ }
1780
+ }
1781
+ const body = containers.get(tab);
1782
+ if (tab === "assistant") {
1783
+ return;
1784
+ }
1785
+ if (!aTab) {
1786
+ render(noDocumentTpl(), body);
1787
+ return;
1788
+ }
1789
+ if (tab === "properties") {
1790
+ render(renderPropertiesPanelTemplate({
1791
+ navigateToComponent: ctx.navigateToComponent
1792
+ }), body);
1793
+ } else if (tab === "events") {
1794
+ render(renderLogicPanelTemplate({
1795
+ isCustomElementDoc: () => isCustomElementDoc({
1796
+ document: aTab.doc.document,
1797
+ mode: aTab.doc.mode,
1798
+ selection: aTab.session.selection,
1799
+ ui: aTab.session.ui
1800
+ })
1801
+ }), body);
1802
+ } else {
1803
+ try {
1804
+ render(renderStylePanelTemplate({ getCanvasMode: ctx.getCanvasMode }), body);
1805
+ } catch (error) {
1806
+ console.error("[renderStylePanelTemplate]", error);
1807
+ }
1808
+ }
1809
+ } catch (error) {
1810
+ console.error("right-panel render error:", error);
1811
+ }
1812
+ }
1813
+
1814
+ export { registerStyleCommands, mount, unmount, render2 as render, inspectorTab, setInspectorTab };
1815
+
1816
+ //# debugId=EE6BCDBC241C370964756E2164756E21
1817
+ //# sourceMappingURL=studio-hbp1s8m9.js.map