openplanr 3.4.0 → 3.6.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 (530) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/dist/cli/commands/backlog-commands.d.ts +3 -0
  3. package/dist/cli/commands/backlog-commands.d.ts.map +1 -0
  4. package/dist/cli/commands/backlog-commands.js +60 -0
  5. package/dist/cli/commands/backlog-commands.js.map +1 -0
  6. package/dist/cli/commands/company.d.ts.map +1 -1
  7. package/dist/cli/commands/company.js +17 -0
  8. package/dist/cli/commands/company.js.map +1 -1
  9. package/dist/cli/commands/design.d.ts +3 -0
  10. package/dist/cli/commands/design.d.ts.map +1 -0
  11. package/dist/cli/commands/design.js +137 -0
  12. package/dist/cli/commands/design.js.map +1 -0
  13. package/dist/cli/commands/groups/operations.d.ts.map +1 -1
  14. package/dist/cli/commands/groups/operations.js +2 -0
  15. package/dist/cli/commands/groups/operations.js.map +1 -1
  16. package/dist/cli/commands/planning-artifacts.d.ts.map +1 -1
  17. package/dist/cli/commands/planning-artifacts.js +13 -5
  18. package/dist/cli/commands/planning-artifacts.js.map +1 -1
  19. package/dist/dashboard/.vite/manifest.json +1 -1
  20. package/dist/dashboard/assets/{index-CvQAlBy3.js → index-C_OquZVk.js} +2 -2
  21. package/dist/dashboard/assets/{index-CvQAlBy3.js.map → index-C_OquZVk.js.map} +1 -1
  22. package/dist/dashboard/dashboard-manifest.json +13 -13
  23. package/dist/dashboard/index.html +1 -1
  24. package/dist/services/artifact-service.d.ts.map +1 -1
  25. package/dist/services/artifact-service.js +13 -6
  26. package/dist/services/artifact-service.js.map +1 -1
  27. package/dist/services/company-export-service.d.ts +41 -0
  28. package/dist/services/company-export-service.d.ts.map +1 -0
  29. package/dist/services/company-export-service.js +429 -0
  30. package/dist/services/company-export-service.js.map +1 -0
  31. package/dist/services/company-sync-service.d.ts +24 -1
  32. package/dist/services/company-sync-service.d.ts.map +1 -1
  33. package/dist/services/company-sync-service.js +36 -19
  34. package/dist/services/company-sync-service.js.map +1 -1
  35. package/dist/services/design-artifact-service.d.ts +22 -0
  36. package/dist/services/design-artifact-service.d.ts.map +1 -1
  37. package/dist/services/design-artifact-service.js +76 -16
  38. package/dist/services/design-artifact-service.js.map +1 -1
  39. package/dist/services/runtime-manager/runtime-package.js +1 -1
  40. package/dist/services/runtime-manager/runtime-package.js.map +1 -1
  41. package/docs/CLI.md +126 -1
  42. package/lib/backlog-item.d.mts +45 -1
  43. package/lib/backlog-item.mjs +302 -34
  44. package/lib/host-packages/adapter-registry.json +5 -5
  45. package/lib/host-packages/capability-map.json +1 -1
  46. package/lib/host-packages/claude/.claude-plugin/marketplace.json +2 -2
  47. package/lib/host-packages/claude/openplanr/.claude-plugin/icon.png +0 -0
  48. package/lib/host-packages/claude/openplanr/.claude-plugin/plugin.json +1 -1
  49. package/lib/host-packages/claude/openplanr/.openplanr-content.json +97 -413
  50. package/lib/host-packages/claude/openplanr/README.md +8 -8
  51. package/lib/host-packages/claude/openplanr/skills/artifact/references/design-sharing.md +2 -2
  52. package/lib/host-packages/claude/openplanr/skills/ceo-review/references/note-checklist.md +131 -0
  53. package/lib/host-packages/claude/openplanr/skills/ceo-review/references/operate-advisor-contract.md +2 -7
  54. package/lib/host-packages/claude/openplanr/skills/chair-review/SKILL.md +2 -7
  55. package/lib/host-packages/claude/openplanr/skills/chair-review/references/note-checklist.md +131 -0
  56. package/lib/host-packages/claude/openplanr/skills/challenger-review/SKILL.md +3 -7
  57. package/lib/host-packages/claude/openplanr/skills/challenger-review/references/note-checklist.md +131 -0
  58. package/lib/host-packages/claude/openplanr/skills/cmo-review/references/note-checklist.md +131 -0
  59. package/lib/host-packages/claude/openplanr/skills/cmo-review/references/operate-advisor-contract.md +2 -7
  60. package/lib/host-packages/claude/openplanr/skills/coo-review/references/note-checklist.md +131 -0
  61. package/lib/host-packages/claude/openplanr/skills/coo-review/references/operate-advisor-contract.md +2 -7
  62. package/lib/host-packages/claude/openplanr/skills/cpo-review/references/note-checklist.md +131 -0
  63. package/lib/host-packages/claude/openplanr/skills/cpo-review/references/operate-advisor-contract.md +2 -7
  64. package/lib/host-packages/claude/openplanr/skills/cto-review/references/note-checklist.md +131 -0
  65. package/lib/host-packages/claude/openplanr/skills/cto-review/references/operate-advisor-contract.md +2 -7
  66. package/lib/host-packages/claude/openplanr/skills/design/SKILL.md +23 -12
  67. package/lib/host-packages/claude/openplanr/skills/design/references/design-system.md +2 -2
  68. package/lib/host-packages/claude/openplanr/skills/design/references/generation.md +3 -3
  69. package/lib/host-packages/claude/openplanr/skills/design/references/hosted-canvas.md +6 -3
  70. package/lib/host-packages/claude/openplanr/skills/design/references/review.md +6 -6
  71. package/lib/host-packages/claude/openplanr/skills/design/references/team-review.md +3 -4
  72. package/lib/host-packages/claude/openplanr/skills/design/references/utilities.md +78 -38
  73. package/lib/host-packages/claude/openplanr/skills/design-loop/SKILL.md +15 -7
  74. package/lib/host-packages/claude/openplanr/skills/design-loop/references/design-system.md +2 -2
  75. package/lib/host-packages/claude/openplanr/skills/design-loop/references/generation.md +3 -3
  76. package/lib/host-packages/claude/openplanr/skills/design-loop/references/review.md +6 -6
  77. package/lib/host-packages/claude/openplanr/skills/design-loop/references/team-review.md +3 -4
  78. package/lib/host-packages/claude/openplanr/skills/design-loop/references/utilities.md +78 -38
  79. package/lib/host-packages/claude/openplanr/skills/design-review/SKILL.md +25 -5
  80. package/lib/host-packages/claude/openplanr/skills/design-review/references/design-system.md +2 -2
  81. package/lib/host-packages/claude/openplanr/skills/design-review/references/generation.md +3 -3
  82. package/lib/host-packages/claude/openplanr/skills/design-review/references/review.md +6 -6
  83. package/lib/host-packages/claude/openplanr/skills/design-review/references/team-review.md +3 -4
  84. package/lib/host-packages/claude/openplanr/skills/design-review/references/utilities.md +78 -38
  85. package/lib/host-packages/claude/openplanr/skills/investigate/SKILL.md +2 -3
  86. package/lib/host-packages/claude/openplanr/skills/investigate/references/backlog-filing.md +102 -0
  87. package/lib/host-packages/claude/openplanr/skills/investigate/references/findings.md +8 -16
  88. package/lib/host-packages/claude/openplanr/skills/operate/SKILL.md +73 -84
  89. package/lib/host-packages/claude/openplanr/skills/operate/references/note-checklist.md +131 -0
  90. package/lib/host-packages/claude/openplanr/skills/operate/references/return-contract.md +10 -0
  91. package/lib/host-packages/claude/openplanr/skills/plan/SKILL.md +23 -20
  92. package/lib/host-packages/claude/openplanr/skills/plan/references/planning-ids.md +53 -0
  93. package/lib/host-packages/claude/openplanr/skills/plan/references/return-contract.md +10 -0
  94. package/lib/host-packages/claude/openplanr/skills/plan-review/SKILL.md +6 -6
  95. package/lib/host-packages/claude/openplanr/skills/plan-review/references/return-contract.md +10 -0
  96. package/lib/host-packages/claude/openplanr/skills/release/SKILL.md +40 -139
  97. package/lib/host-packages/claude/openplanr/skills/release/references/cadence.md +10 -0
  98. package/lib/host-packages/claude/openplanr/skills/release/references/release-notes.md +1 -1
  99. package/lib/host-packages/claude/openplanr/skills/release/references/return-contract.md +10 -0
  100. package/lib/host-packages/claude/openplanr/skills/release/references/schemes.md +4 -2
  101. package/lib/host-packages/claude/openplanr/skills/ship/SKILL.md +37 -24
  102. package/lib/host-packages/claude/openplanr/skills/ship/references/backlog-filing.md +102 -0
  103. package/lib/host-packages/claude/openplanr/skills/ship/references/findings.md +8 -16
  104. package/lib/host-packages/claude/openplanr/skills/ship/references/return-contract.md +10 -0
  105. package/lib/host-packages/claude/openplanr/skills/spec/SKILL.md +9 -9
  106. package/lib/host-packages/claude/openplanr/skills/spec/references/return-contract.md +10 -0
  107. package/lib/host-packages/cursor/openplanr/.openplanr-content.json +94 -410
  108. package/lib/host-packages/cursor/openplanr/manifest.json +1 -1
  109. package/lib/host-packages/cursor/openplanr/rules/planr-artifact/references/design-sharing.md +2 -2
  110. package/lib/host-packages/cursor/openplanr/rules/planr-ceo-review/references/note-checklist.md +131 -0
  111. package/lib/host-packages/cursor/openplanr/rules/planr-ceo-review/references/operate-advisor-contract.md +2 -7
  112. package/lib/host-packages/cursor/openplanr/rules/planr-chair-review/references/note-checklist.md +131 -0
  113. package/lib/host-packages/cursor/openplanr/rules/planr-chair-review.mdc +2 -7
  114. package/lib/host-packages/cursor/openplanr/rules/planr-challenger-review/references/note-checklist.md +131 -0
  115. package/lib/host-packages/cursor/openplanr/rules/planr-challenger-review.mdc +3 -7
  116. package/lib/host-packages/cursor/openplanr/rules/planr-cmo-review/references/note-checklist.md +131 -0
  117. package/lib/host-packages/cursor/openplanr/rules/planr-cmo-review/references/operate-advisor-contract.md +2 -7
  118. package/lib/host-packages/cursor/openplanr/rules/planr-coo-review/references/note-checklist.md +131 -0
  119. package/lib/host-packages/cursor/openplanr/rules/planr-coo-review/references/operate-advisor-contract.md +2 -7
  120. package/lib/host-packages/cursor/openplanr/rules/planr-cpo-review/references/note-checklist.md +131 -0
  121. package/lib/host-packages/cursor/openplanr/rules/planr-cpo-review/references/operate-advisor-contract.md +2 -7
  122. package/lib/host-packages/cursor/openplanr/rules/planr-cto-review/references/note-checklist.md +131 -0
  123. package/lib/host-packages/cursor/openplanr/rules/planr-cto-review/references/operate-advisor-contract.md +2 -7
  124. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/design-system.md +2 -2
  125. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/generation.md +3 -3
  126. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/hosted-canvas.md +6 -3
  127. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/review.md +6 -6
  128. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/team-review.md +3 -4
  129. package/lib/host-packages/cursor/openplanr/rules/planr-design/references/utilities.md +78 -38
  130. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/design-system.md +2 -2
  131. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/generation.md +3 -3
  132. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/review.md +6 -6
  133. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/team-review.md +3 -4
  134. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/references/utilities.md +78 -38
  135. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop.mdc +15 -7
  136. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/design-system.md +2 -2
  137. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/generation.md +3 -3
  138. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/review.md +6 -6
  139. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/team-review.md +3 -4
  140. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/references/utilities.md +78 -38
  141. package/lib/host-packages/cursor/openplanr/rules/planr-design-review.mdc +25 -5
  142. package/lib/host-packages/cursor/openplanr/rules/planr-design.mdc +23 -12
  143. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/references/backlog-filing.md +102 -0
  144. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/references/findings.md +8 -16
  145. package/lib/host-packages/cursor/openplanr/rules/planr-investigate.mdc +2 -3
  146. package/lib/host-packages/cursor/openplanr/rules/planr-operate/references/note-checklist.md +131 -0
  147. package/lib/host-packages/cursor/openplanr/rules/planr-operate/references/return-contract.md +10 -0
  148. package/lib/host-packages/cursor/openplanr/rules/planr-operate.mdc +73 -84
  149. package/lib/host-packages/cursor/openplanr/rules/planr-plan/references/planning-ids.md +53 -0
  150. package/lib/host-packages/cursor/openplanr/rules/planr-plan/references/return-contract.md +10 -0
  151. package/lib/host-packages/cursor/openplanr/rules/planr-plan-review/references/return-contract.md +10 -0
  152. package/lib/host-packages/cursor/openplanr/rules/planr-plan-review.mdc +6 -6
  153. package/lib/host-packages/cursor/openplanr/rules/planr-plan.mdc +23 -20
  154. package/lib/host-packages/cursor/openplanr/rules/planr-release/references/cadence.md +10 -0
  155. package/lib/host-packages/cursor/openplanr/rules/planr-release/references/release-notes.md +1 -1
  156. package/lib/host-packages/cursor/openplanr/rules/planr-release/references/return-contract.md +10 -0
  157. package/lib/host-packages/cursor/openplanr/rules/planr-release/references/schemes.md +4 -2
  158. package/lib/host-packages/cursor/openplanr/rules/planr-release.mdc +40 -139
  159. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/backlog-filing.md +102 -0
  160. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/findings.md +8 -16
  161. package/lib/host-packages/cursor/openplanr/rules/planr-ship/references/return-contract.md +10 -0
  162. package/lib/host-packages/cursor/openplanr/rules/planr-ship.mdc +37 -24
  163. package/lib/host-packages/cursor/openplanr/rules/planr-spec/references/return-contract.md +10 -0
  164. package/lib/host-packages/cursor/openplanr/rules/planr-spec.mdc +9 -9
  165. package/lib/host-packages/openai/.claude-plugin/marketplace.json +2 -2
  166. package/lib/host-packages/openai/openplanr/.codex-plugin/plugin.json +1 -1
  167. package/lib/host-packages/openai/openplanr/.openplanr-content.json +112 -428
  168. package/lib/host-packages/openai/openplanr/skills/artifact/references/design-sharing.md +2 -2
  169. package/lib/host-packages/openai/openplanr/skills/ceo-review/openplanr.skill.json +4 -4
  170. package/lib/host-packages/openai/openplanr/skills/ceo-review/references/note-checklist.md +131 -0
  171. package/lib/host-packages/openai/openplanr/skills/ceo-review/references/operate-advisor-contract.md +2 -7
  172. package/lib/host-packages/openai/openplanr/skills/chair-review/SKILL.md +2 -7
  173. package/lib/host-packages/openai/openplanr/skills/chair-review/openplanr.skill.json +4 -4
  174. package/lib/host-packages/openai/openplanr/skills/chair-review/references/note-checklist.md +131 -0
  175. package/lib/host-packages/openai/openplanr/skills/challenger-review/SKILL.md +3 -7
  176. package/lib/host-packages/openai/openplanr/skills/challenger-review/openplanr.skill.json +4 -4
  177. package/lib/host-packages/openai/openplanr/skills/challenger-review/references/note-checklist.md +131 -0
  178. package/lib/host-packages/openai/openplanr/skills/cmo-review/openplanr.skill.json +4 -4
  179. package/lib/host-packages/openai/openplanr/skills/cmo-review/references/note-checklist.md +131 -0
  180. package/lib/host-packages/openai/openplanr/skills/cmo-review/references/operate-advisor-contract.md +2 -7
  181. package/lib/host-packages/openai/openplanr/skills/coo-review/openplanr.skill.json +4 -4
  182. package/lib/host-packages/openai/openplanr/skills/coo-review/references/note-checklist.md +131 -0
  183. package/lib/host-packages/openai/openplanr/skills/coo-review/references/operate-advisor-contract.md +2 -7
  184. package/lib/host-packages/openai/openplanr/skills/cpo-review/openplanr.skill.json +4 -4
  185. package/lib/host-packages/openai/openplanr/skills/cpo-review/references/note-checklist.md +131 -0
  186. package/lib/host-packages/openai/openplanr/skills/cpo-review/references/operate-advisor-contract.md +2 -7
  187. package/lib/host-packages/openai/openplanr/skills/cto-review/openplanr.skill.json +4 -4
  188. package/lib/host-packages/openai/openplanr/skills/cto-review/references/note-checklist.md +131 -0
  189. package/lib/host-packages/openai/openplanr/skills/cto-review/references/operate-advisor-contract.md +2 -7
  190. package/lib/host-packages/openai/openplanr/skills/design/SKILL.md +23 -12
  191. package/lib/host-packages/openai/openplanr/skills/design/openplanr.skill.json +0 -11
  192. package/lib/host-packages/openai/openplanr/skills/design/references/design-system.md +2 -2
  193. package/lib/host-packages/openai/openplanr/skills/design/references/generation.md +3 -3
  194. package/lib/host-packages/openai/openplanr/skills/design/references/hosted-canvas.md +6 -3
  195. package/lib/host-packages/openai/openplanr/skills/design/references/review.md +6 -6
  196. package/lib/host-packages/openai/openplanr/skills/design/references/team-review.md +3 -4
  197. package/lib/host-packages/openai/openplanr/skills/design/references/utilities.md +78 -38
  198. package/lib/host-packages/openai/openplanr/skills/design-loop/SKILL.md +15 -7
  199. package/lib/host-packages/openai/openplanr/skills/design-loop/openplanr.skill.json +0 -11
  200. package/lib/host-packages/openai/openplanr/skills/design-loop/references/design-system.md +2 -2
  201. package/lib/host-packages/openai/openplanr/skills/design-loop/references/generation.md +3 -3
  202. package/lib/host-packages/openai/openplanr/skills/design-loop/references/review.md +6 -6
  203. package/lib/host-packages/openai/openplanr/skills/design-loop/references/team-review.md +3 -4
  204. package/lib/host-packages/openai/openplanr/skills/design-loop/references/utilities.md +78 -38
  205. package/lib/host-packages/openai/openplanr/skills/design-review/SKILL.md +25 -5
  206. package/lib/host-packages/openai/openplanr/skills/design-review/openplanr.skill.json +0 -11
  207. package/lib/host-packages/openai/openplanr/skills/design-review/references/design-system.md +2 -2
  208. package/lib/host-packages/openai/openplanr/skills/design-review/references/generation.md +3 -3
  209. package/lib/host-packages/openai/openplanr/skills/design-review/references/review.md +6 -6
  210. package/lib/host-packages/openai/openplanr/skills/design-review/references/team-review.md +3 -4
  211. package/lib/host-packages/openai/openplanr/skills/design-review/references/utilities.md +78 -38
  212. package/lib/host-packages/openai/openplanr/skills/investigate/SKILL.md +2 -3
  213. package/lib/host-packages/openai/openplanr/skills/investigate/openplanr.skill.json +4 -4
  214. package/lib/host-packages/openai/openplanr/skills/investigate/references/backlog-filing.md +102 -0
  215. package/lib/host-packages/openai/openplanr/skills/investigate/references/findings.md +8 -16
  216. package/lib/host-packages/openai/openplanr/skills/operate/SKILL.md +73 -84
  217. package/lib/host-packages/openai/openplanr/skills/operate/openplanr.skill.json +15 -4
  218. package/lib/host-packages/openai/openplanr/skills/operate/references/note-checklist.md +131 -0
  219. package/lib/host-packages/openai/openplanr/skills/operate/references/return-contract.md +10 -0
  220. package/lib/host-packages/openai/openplanr/skills/plan/SKILL.md +23 -20
  221. package/lib/host-packages/openai/openplanr/skills/plan/openplanr.skill.json +8 -8
  222. package/lib/host-packages/openai/openplanr/skills/plan/references/planning-ids.md +53 -0
  223. package/lib/host-packages/openai/openplanr/skills/plan/references/return-contract.md +10 -0
  224. package/lib/host-packages/openai/openplanr/skills/plan-review/SKILL.md +6 -6
  225. package/lib/host-packages/openai/openplanr/skills/plan-review/openplanr.skill.json +12 -1
  226. package/lib/host-packages/openai/openplanr/skills/plan-review/references/return-contract.md +10 -0
  227. package/lib/host-packages/openai/openplanr/skills/release/SKILL.md +40 -139
  228. package/lib/host-packages/openai/openplanr/skills/release/openplanr.skill.json +4 -4
  229. package/lib/host-packages/openai/openplanr/skills/release/references/cadence.md +10 -0
  230. package/lib/host-packages/openai/openplanr/skills/release/references/release-notes.md +1 -1
  231. package/lib/host-packages/openai/openplanr/skills/release/references/return-contract.md +10 -0
  232. package/lib/host-packages/openai/openplanr/skills/release/references/schemes.md +4 -2
  233. package/lib/host-packages/openai/openplanr/skills/ship/SKILL.md +37 -24
  234. package/lib/host-packages/openai/openplanr/skills/ship/openplanr.skill.json +9 -9
  235. package/lib/host-packages/openai/openplanr/skills/ship/references/backlog-filing.md +102 -0
  236. package/lib/host-packages/openai/openplanr/skills/ship/references/findings.md +8 -16
  237. package/lib/host-packages/openai/openplanr/skills/ship/references/return-contract.md +10 -0
  238. package/lib/host-packages/openai/openplanr/skills/spec/SKILL.md +9 -9
  239. package/lib/host-packages/openai/openplanr/skills/spec/openplanr.skill.json +12 -1
  240. package/lib/host-packages/openai/openplanr/skills/spec/references/return-contract.md +10 -0
  241. package/package.json +2 -2
  242. package/lib/host-packages/claude/openplanr/.claude-plugin/icon.svg +0 -11
  243. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
  244. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
  245. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
  246. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
  247. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
  248. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
  249. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
  250. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
  251. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
  252. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
  253. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
  254. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
  255. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
  256. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
  257. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
  258. package/lib/host-packages/claude/openplanr/runtime/design/scripts/design.mjs +0 -1500
  259. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
  260. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
  261. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
  262. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
  263. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
  264. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
  265. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
  266. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
  267. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
  268. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
  269. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
  270. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
  271. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
  272. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
  273. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
  274. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
  275. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
  276. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
  277. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
  278. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +0 -914
  279. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +0 -2578
  280. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
  281. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
  282. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
  283. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
  284. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
  285. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
  286. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
  287. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
  288. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
  289. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
  290. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
  291. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
  292. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
  293. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
  294. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
  295. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
  296. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
  297. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
  298. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  299. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
  300. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
  301. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
  302. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
  303. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
  304. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
  305. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
  306. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
  307. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
  308. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
  309. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
  310. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
  311. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
  312. package/lib/host-packages/claude/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
  313. package/lib/host-packages/claude/openplanr/runtime/operate/scripts/errors.mjs +0 -8
  314. package/lib/host-packages/claude/openplanr/runtime/operate/scripts/operate-review-contract.mjs +0 -428
  315. package/lib/host-packages/claude/openplanr/runtime/operate/scripts/operate-review-note.mjs +0 -686
  316. package/lib/host-packages/claude/openplanr/runtime/operate/scripts/validate-note.mjs +0 -39
  317. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
  318. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/design.mjs +0 -2611
  319. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
  320. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
  321. package/lib/host-packages/claude/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  322. package/lib/host-packages/claude/openplanr/skills/ceo-review/scripts/validate-note.mjs +0 -12
  323. package/lib/host-packages/claude/openplanr/skills/chair-review/scripts/validate-note.mjs +0 -12
  324. package/lib/host-packages/claude/openplanr/skills/challenger-review/scripts/validate-note.mjs +0 -12
  325. package/lib/host-packages/claude/openplanr/skills/cmo-review/scripts/validate-note.mjs +0 -12
  326. package/lib/host-packages/claude/openplanr/skills/coo-review/scripts/validate-note.mjs +0 -12
  327. package/lib/host-packages/claude/openplanr/skills/cpo-review/scripts/validate-note.mjs +0 -12
  328. package/lib/host-packages/claude/openplanr/skills/cto-review/scripts/validate-note.mjs +0 -12
  329. package/lib/host-packages/claude/openplanr/skills/design/scripts/design.mjs +0 -12
  330. package/lib/host-packages/claude/openplanr/skills/design-loop/scripts/design.mjs +0 -12
  331. package/lib/host-packages/claude/openplanr/skills/design-review/scripts/design.mjs +0 -12
  332. package/lib/host-packages/claude/openplanr/skills/investigate/scripts/backlog-item.mjs +0 -339
  333. package/lib/host-packages/claude/openplanr/skills/operate/scripts/validate-note.mjs +0 -12
  334. package/lib/host-packages/claude/openplanr/skills/plan/scripts/design.mjs +0 -12
  335. package/lib/host-packages/claude/openplanr/skills/plan/scripts/planning-ids.mjs +0 -166
  336. package/lib/host-packages/claude/openplanr/skills/release/scripts/collect_changes.sh +0 -85
  337. package/lib/host-packages/claude/openplanr/skills/ship/scripts/backlog-item.mjs +0 -339
  338. package/lib/host-packages/claude/openplanr/skills/ship/scripts/discover-verification.mjs +0 -108
  339. package/lib/host-packages/cursor/openplanr/rules/planr-ceo-review/scripts/validate-note.mjs +0 -12
  340. package/lib/host-packages/cursor/openplanr/rules/planr-chair-review/scripts/validate-note.mjs +0 -12
  341. package/lib/host-packages/cursor/openplanr/rules/planr-challenger-review/scripts/validate-note.mjs +0 -12
  342. package/lib/host-packages/cursor/openplanr/rules/planr-cmo-review/scripts/validate-note.mjs +0 -12
  343. package/lib/host-packages/cursor/openplanr/rules/planr-coo-review/scripts/validate-note.mjs +0 -12
  344. package/lib/host-packages/cursor/openplanr/rules/planr-cpo-review/scripts/validate-note.mjs +0 -12
  345. package/lib/host-packages/cursor/openplanr/rules/planr-cto-review/scripts/validate-note.mjs +0 -12
  346. package/lib/host-packages/cursor/openplanr/rules/planr-design/scripts/design.mjs +0 -12
  347. package/lib/host-packages/cursor/openplanr/rules/planr-design-loop/scripts/design.mjs +0 -12
  348. package/lib/host-packages/cursor/openplanr/rules/planr-design-review/scripts/design.mjs +0 -12
  349. package/lib/host-packages/cursor/openplanr/rules/planr-investigate/scripts/backlog-item.mjs +0 -339
  350. package/lib/host-packages/cursor/openplanr/rules/planr-operate/scripts/validate-note.mjs +0 -12
  351. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/design.mjs +0 -12
  352. package/lib/host-packages/cursor/openplanr/rules/planr-plan/scripts/planning-ids.mjs +0 -166
  353. package/lib/host-packages/cursor/openplanr/rules/planr-release/scripts/collect_changes.sh +0 -85
  354. package/lib/host-packages/cursor/openplanr/rules/planr-ship/scripts/backlog-item.mjs +0 -339
  355. package/lib/host-packages/cursor/openplanr/rules/planr-ship/scripts/discover-verification.mjs +0 -108
  356. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
  357. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
  358. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
  359. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
  360. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
  361. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
  362. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
  363. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
  364. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
  365. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
  366. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
  367. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
  368. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
  369. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
  370. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
  371. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/design.mjs +0 -1500
  372. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
  373. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
  374. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
  375. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
  376. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
  377. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
  378. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
  379. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
  380. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
  381. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
  382. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
  383. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
  384. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
  385. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
  386. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
  387. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
  388. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
  389. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
  390. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
  391. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +0 -914
  392. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +0 -2578
  393. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
  394. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
  395. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
  396. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
  397. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
  398. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
  399. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
  400. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
  401. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
  402. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
  403. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
  404. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
  405. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
  406. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
  407. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
  408. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
  409. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
  410. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
  411. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  412. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
  413. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
  414. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
  415. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
  416. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
  417. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
  418. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
  419. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
  420. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
  421. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
  422. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
  423. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
  424. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
  425. package/lib/host-packages/cursor/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
  426. package/lib/host-packages/cursor/openplanr/runtime/operate/scripts/errors.mjs +0 -8
  427. package/lib/host-packages/cursor/openplanr/runtime/operate/scripts/operate-review-contract.mjs +0 -428
  428. package/lib/host-packages/cursor/openplanr/runtime/operate/scripts/operate-review-note.mjs +0 -686
  429. package/lib/host-packages/cursor/openplanr/runtime/operate/scripts/validate-note.mjs +0 -39
  430. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
  431. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/design.mjs +0 -2611
  432. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
  433. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
  434. package/lib/host-packages/cursor/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  435. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-artifact-shell.mjs +0 -1772
  436. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-document.mjs +0 -2937
  437. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-entities.mjs +0 -439
  438. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-handoff.mjs +0 -2370
  439. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-loopback-server.mjs +0 -359
  440. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-parse5-parser.mjs +0 -3970
  441. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-parse5-tokenizer.mjs +0 -3501
  442. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review-state-store.mjs +0 -45
  443. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-review.mjs +0 -3376
  444. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-runtime-home.mjs +0 -38
  445. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-sandbox-guards.mjs +0 -1102
  446. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-share-cli-bridge.mjs +0 -321
  447. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-dependencies-design-support-protocol-contracts-d707e49b.mjs +0 -1652
  448. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-artifact-support-protocol-contracts-9f6918b0.mjs +0 -1037
  449. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design-shared-design-support-0bac378d.mjs +0 -137
  450. package/lib/host-packages/openai/openplanr/runtime/design/scripts/design.mjs +0 -1500
  451. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -2023
  452. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/lib/artifact/ui/studio-shell.css +0 -2
  453. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/01-module-runtime.js +0 -18
  454. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/02-artifact-review-ui.js +0 -814
  455. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/03-protocol-contracts.js +0 -10
  456. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources/04-artifact-review-ui.js +0 -2568
  457. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/artifact/templates/artifact-review-stage.js.sources.json +0 -60
  458. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/package.json +0 -65
  459. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/enhancements.css +0 -388
  460. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/handoff-center.css +0 -81
  461. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.css +0 -1
  462. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/share.js +0 -139
  463. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.css +0 -1159
  464. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/01-module-runtime.js +0 -30
  465. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/02-react.js +0 -900
  466. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/03-react-dom-client-fiber-foundations.js +0 -2261
  467. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/04-react-dom-client-reconciliation-hooks.js +0 -1595
  468. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/05-react-dom-client-render-phases.js +0 -1467
  469. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/06-react-dom-client-commit-effects.js +0 -1860
  470. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/07-react-dom-client-work-loop-scheduling.js +0 -914
  471. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/08-react-dom-client-dom-events-properties-hydration.js +0 -2578
  472. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/09-react-dom-client-public-roots.js +0 -582
  473. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/10-react.js +0 -17
  474. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/11-artifact-review-ui.js +0 -12
  475. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/12-protocol-contracts.js +0 -285
  476. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/13-design-review-experience.js +0 -2773
  477. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/14-studio-shell.js +0 -134
  478. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/15-canvas-engine.js +0 -2207
  479. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/16-design-review-experience.js +0 -16
  480. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/17-studio-shell.js +0 -8
  481. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/18-interface-primitives.js +0 -3883
  482. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/19-interface-primitives.js +0 -966
  483. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/20-studio-shell.js +0 -520
  484. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources/21-design-studio.js +0 -1597
  485. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/design/templates/studio/studio.js.sources.json +0 -311
  486. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/package.json +0 -163
  487. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/registries/artifact-theme.json +0 -64
  488. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.0.0/design-manifest.schema.json +0 -90
  489. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-envelope.schema.json +0 -142
  490. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  491. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-bundle.schema.json +0 -584
  492. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-context.schema.json +0 -191
  493. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-handoff.schema.json +0 -407
  494. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.10.0/design-review-metadata-payload.schema.json +0 -106
  495. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-handoff-readiness.schema.json +0 -398
  496. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-implementation-handoff.schema.json +0 -518
  497. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-planning-lineage.schema.json +0 -106
  498. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.11.0/design-review-metadata-payload.schema.json +0 -107
  499. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.14.0/artifact-theme.schema.json +0 -316
  500. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/artifact-envelope.schema.json +0 -408
  501. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.16.0/design-review-bundle.schema.json +0 -590
  502. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-document.schema.json +0 -506
  503. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.22.0/design-review-bundle.schema.json +0 -822
  504. package/lib/host-packages/openai/openplanr/runtime/design/scripts/runtime/packages/protocol/schemas/v1.9.0/design-review-bundle.schema.json +0 -346
  505. package/lib/host-packages/openai/openplanr/runtime/operate/scripts/errors.mjs +0 -8
  506. package/lib/host-packages/openai/openplanr/runtime/operate/scripts/operate-review-contract.mjs +0 -428
  507. package/lib/host-packages/openai/openplanr/runtime/operate/scripts/operate-review-note.mjs +0 -686
  508. package/lib/host-packages/openai/openplanr/runtime/operate/scripts/validate-note.mjs +0 -39
  509. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design-protocol-contracts.mjs +0 -1232
  510. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/design.mjs +0 -2611
  511. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/notices/THIRD_PARTY_NOTICES.txt +0 -21
  512. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/package.json +0 -163
  513. package/lib/host-packages/openai/openplanr/runtime/plan/scripts/runtime/packages/protocol/schemas/v1.1.0/artifact-review.schema.json +0 -97
  514. package/lib/host-packages/openai/openplanr/skills/ceo-review/scripts/validate-note.mjs +0 -12
  515. package/lib/host-packages/openai/openplanr/skills/chair-review/scripts/validate-note.mjs +0 -12
  516. package/lib/host-packages/openai/openplanr/skills/challenger-review/scripts/validate-note.mjs +0 -12
  517. package/lib/host-packages/openai/openplanr/skills/cmo-review/scripts/validate-note.mjs +0 -12
  518. package/lib/host-packages/openai/openplanr/skills/coo-review/scripts/validate-note.mjs +0 -12
  519. package/lib/host-packages/openai/openplanr/skills/cpo-review/scripts/validate-note.mjs +0 -12
  520. package/lib/host-packages/openai/openplanr/skills/cto-review/scripts/validate-note.mjs +0 -12
  521. package/lib/host-packages/openai/openplanr/skills/design/scripts/design.mjs +0 -12
  522. package/lib/host-packages/openai/openplanr/skills/design-loop/scripts/design.mjs +0 -12
  523. package/lib/host-packages/openai/openplanr/skills/design-review/scripts/design.mjs +0 -12
  524. package/lib/host-packages/openai/openplanr/skills/investigate/scripts/backlog-item.mjs +0 -339
  525. package/lib/host-packages/openai/openplanr/skills/operate/scripts/validate-note.mjs +0 -12
  526. package/lib/host-packages/openai/openplanr/skills/plan/scripts/design.mjs +0 -12
  527. package/lib/host-packages/openai/openplanr/skills/plan/scripts/planning-ids.mjs +0 -166
  528. package/lib/host-packages/openai/openplanr/skills/release/scripts/collect_changes.sh +0 -85
  529. package/lib/host-packages/openai/openplanr/skills/ship/scripts/backlog-item.mjs +0 -339
  530. package/lib/host-packages/openai/openplanr/skills/ship/scripts/discover-verification.mjs +0 -108
@@ -1,1597 +0,0 @@
1
-
2
-
3
- // lib/design/ui/studio-chrome.mjs
4
- function mountDesignChrome(input) {
5
- return mountDesignStudioChrome(input);
6
- }
7
- function mountDesignPanels(input) {
8
- return mountStudioPanelDialogs(input);
9
- }
10
-
11
- // lib/design/ui/studio.mjs
12
- function mountDesignStudio({ payload, stage: artifactStage }) {
13
- let design = payload.document, entries = payload.entries, options2 = globalThis.__OPENPLANR_DESIGN_STUDIO_OPTIONS__ ?? {}, storageKey = `openplanr.design-studio.${design.id}`, q = (selector) => document.querySelector(selector), qa = (selector) => [...document.querySelectorAll(selector)], clone = (value) => JSON.parse(JSON.stringify(value)), clamp2 = (value, min2, max2) => Math.min(max2, Math.max(min2, value)), readyVariants = design.variants.filter(({ status: status2 }) => status2 === "ready"), views = ["canvas", "prototype", "walkthrough"], validId = (items, id, fallback) => items.some((item) => (typeof item == "string" ? item : item.id) === id) ? id : fallback, normalizedViewport = (value) => !Number.isFinite(value?.x) || !Number.isFinite(value?.y) || !Number.isFinite(value?.zoom) ? null : {
14
- x: clamp2(value.x, -1e7, 1e7),
15
- y: clamp2(value.y, -1e7, 1e7),
16
- zoom: clamp2(value.zoom, 0.05, 2)
17
- };
18
- function normalizeState(input = {}) {
19
- let view = views.includes(input.view) ? input.view : design.defaultView, viewports = {};
20
- for (let name of views) {
21
- let viewport = normalizedViewport(input.viewports?.[name]);
22
- viewport && (viewports[name] = viewport);
23
- }
24
- let legacyViewport = Number.isFinite(input.zoom) ? normalizedViewport({
25
- x: Number.isFinite(input.camera?.x) ? input.camera.x : 40,
26
- y: Number.isFinite(input.camera?.y) ? input.camera.y : 40,
27
- zoom: input.zoom
28
- }) : null, activeViewport = viewports[view] ?? legacyViewport ?? { x: 40, y: 40, zoom: 0.5 }, state2 = {
29
- schemaVersion: "1.1.0",
30
- view,
31
- screenId: validId(design.screenOrder, input.screenId, design.screenOrder[0]),
32
- frameId: validId(design.frames, input.frameId, design.frames[0].id),
33
- variantId: validId(readyVariants, input.variantId, design.selectedVariant),
34
- selectedVariant: validId(readyVariants, input.selectedVariant, design.selectedVariant),
35
- compare: !!input.compare,
36
- navOpen: input.navOpen === void 0 ? !0 : !!input.navOpen,
37
- reviewOpen: input.reviewOpen === void 0 ? !0 : !!input.reviewOpen,
38
- inspectionScale: input.inspectionScale === "actual" ? "actual" : "fit",
39
- zoom: activeViewport.zoom,
40
- camera: { x: activeViewport.x, y: activeViewport.y },
41
- viewports,
42
- ratings: {},
43
- remix: {},
44
- preferences: { selected: [], rejected: [] }
45
- };
46
- for (let variant of readyVariants) {
47
- let rating = input.ratings?.[variant.id];
48
- Number.isInteger(rating) && rating >= 1 && rating <= 5 && (state2.ratings[variant.id] = rating), typeof input.remix?.[variant.id] == "string" && (state2.remix[variant.id] = input.remix[variant.id].slice(0, 8192));
49
- }
50
- for (let kind of ["selected", "rejected"])
51
- state2.preferences[kind] = [
52
- ...new Set(
53
- (Array.isArray(input.preferences?.[kind]) ? input.preferences[kind] : []).filter(
54
- (id) => readyVariants.some((variant) => variant.id === id)
55
- )
56
- )
57
- ];
58
- return state2;
59
- }
60
- let savedDraft = null;
61
- try {
62
- savedDraft = JSON.parse(localStorage.getItem(storageKey) ?? "null");
63
- } catch {
64
- }
65
- let state = normalizeState({
66
- ...savedDraft?.state ?? {},
67
- ...payload.state ?? {}
68
- });
69
- function linkedState() {
70
- let params = new URLSearchParams(location.hash.slice(1)), linked = {};
71
- for (let [key, query] of [
72
- ["screenId", "screen"],
73
- ["frameId", "frame"],
74
- ["variantId", "direction"],
75
- ["view", "view"]
76
- ])
77
- params.has(query) && (linked[key] = params.get(query));
78
- return linked;
79
- }
80
- state = normalizeState({ ...state, ...linkedState() });
81
- function recordLocation() {
82
- let next = `#${new URLSearchParams({
83
- screen: state.screenId,
84
- frame: state.frameId,
85
- direction: state.variantId,
86
- view: state.view
87
- })}`;
88
- location.hash !== next && history.pushState(null, "", next);
89
- }
90
- let revision = payload.revision, layout = clone(design.layout ?? {}), undoMoves = [], redoMoves = [], layoutOperations = [], pendingLayoutDraft = savedDraft?.pendingLayout ?? null, layoutSaving = !1, layoutFailed = !1, sessionLost = !1, startupSettled = !1, layoutDragDirty = !1, activeLayoutOperation = null, layoutBlocked = !1, legacyMigrated = !1, legacyServerPositions = payload.state?.positions, stateVersion = null, stage = null, root = null, chrome = null, scroll = null, scrollSize = null, surface = null, grid = null, canvasAttached = !1, canvas = createCanvas({
91
- label: "Design canvas",
92
- zoom: { min: 0.05, max: 2 },
93
- lod: !1,
94
- motion: "none",
95
- keyboard: { arrows: "none" },
96
- shortcutsEnabled: () => !1
97
- }), cameraFrame = null, selectionOutline = null, dirty = !1, contentDirty = !1, contentSerial = 0, reviewDirty = !1, reviewSerial = 0, reviewSaving = Promise.resolve(), reviewTimer = null, latestReview = null, serial = 0, saveTimer = null, saving = Promise.resolve(), pollTimer = null, noticeTimer = null, activeNotice = null, dismissedNotices = /* @__PURE__ */ new Map(), readyReported = !1, readyReporting = !1, destroyed = !1, panEnabled = !1, spacePan = !1, spaceReturnTool = null, activeTool = "interact", changingTool = !1, previousReviewMode = "interact", gesture = null, rendering = !1, previousStageZoom = 100, compactViewport = !1, activeArtifactId = "", inspectedSelection = null, viewContextTimer = null, viewContextPending = null, viewContextSignature = null, viewContextConflictRevision = null, viewContextSaving = !1, framesUsedWithComments = /* @__PURE__ */ new Set(), frameReload = 0, walkthroughTransition = null, pendingScreen = null, screenRequest = 0, frameDemandTimer = null, failedSelection = null, frameDemandKey = "", frameDemandGeneration = 0, queuedSelection = null, noteScreenId = null, notesReturnFocus = null, panels = /* @__PURE__ */ new Map(), sectionHeadings = [], sectionZoom = null, canvasPointers = /* @__PURE__ */ new Set(), cleanup = [];
98
- function listen(target, event, handler, settings) {
99
- target?.addEventListener(event, handler, settings), cleanup.push(() => target?.removeEventListener(event, handler, settings));
100
- }
101
- function status(message, phase = "saved") {
102
- if (!destroyed && !(phase === "saved" && hasPendingLayout())) {
103
- if (chrome) chrome.update({ saveLabel: message, savePhase: phase });
104
- else {
105
- let node = q("[data-design-save-state]");
106
- node.textContent = message, node.dataset.status = phase;
107
- }
108
- q("[data-design-save-state]").title = message;
109
- }
110
- }
111
- function hideNotice() {
112
- clearTimeout(noticeTimer);
113
- let node = q(".design-notice"), restoreFocus = node.contains(document.activeElement);
114
- node.hidden = !0, activeNotice = null, q("[data-design-retry-layout]")?.remove(), q("[data-design-reload-studio]")?.remove(), restoreFocus && q(`button[data-design-view="${state.view}"]`)?.focus();
115
- }
116
- function clearNotice(key) {
117
- dismissedNotices.delete(key), activeNotice?.key === key && hideNotice();
118
- }
119
- function clearFailedSelection() {
120
- failedSelection && clearNotice(`preview-load:${failedSelection.artifactId}`), failedSelection = null;
121
- }
122
- function notice(message, persistent = !1, key = message) {
123
- if (destroyed || dismissedNotices.get(key) === message || sessionLost && key !== "studio-restart" || layoutFailed && hasPendingLayout() && !["layout-save", "studio-restart"].includes(key))
124
- return;
125
- let node = q(".design-notice");
126
- clearTimeout(noticeTimer), q("[data-design-retry-layout]")?.remove(), q("[data-design-reload-studio]")?.remove(), activeNotice = { key, message, persistent }, q("[data-design-notice-message]").textContent = message, node.hidden = !1, persistent || (noticeTimer = setTimeout(hideNotice, 6e3));
127
- }
128
- function storeDraft() {
129
- try {
130
- localStorage.setItem(
131
- storageKey,
132
- JSON.stringify({
133
- revision,
134
- stateVersion,
135
- state: !legacyMigrated && (legacyServerPositions || savedDraft?.state?.positions) ? {
136
- ...state,
137
- positions: { ...savedDraft?.state?.positions, ...legacyServerPositions }
138
- } : state,
139
- unsaved: contentDirty,
140
- personalPending: dirty && !contentDirty,
141
- pendingLayout: pendingLayoutDraft ?? (layoutOperations.length ? {
142
- contentIdentity: payload.contentIdentity,
143
- operations: layoutOperations.map((operation) => ({
144
- revision: operation.revision ?? revision,
145
- boards: operation.replayBoards ?? operation.input().boards
146
- }))
147
- } : void 0)
148
- })
149
- );
150
- } catch (error) {
151
- notice(`The browser draft could not be stored: ${error.message}`, !0, "draft-storage");
152
- }
153
- }
154
- async function jsonRequest(url, init = {}) {
155
- let response = await fetch(url, { credentials: "same-origin", ...init }), result = await response.json().catch(() => ({}));
156
- if (!response.ok) {
157
- let error = new Error(
158
- result.error?.message ?? result.error ?? result.message ?? `Save failed (${response.status}).`
159
- );
160
- throw error.conflict = response.status === 409, error.statusCode = response.status, error;
161
- }
162
- return result;
163
- }
164
- function stageSize() {
165
- let size4 = scrollSize ?? { width: scroll.clientWidth, height: scroll.clientHeight };
166
- return typeof ResizeObserver == "function" && (scrollSize = size4), size4;
167
- }
168
- function scheduleViewContext() {
169
- if (!options2.viewContextUrl || !stage || !scroll || destroyed || state.view === "canvas" && !canvasAttached || viewContextConflictRevision !== null && revision === viewContextConflictRevision) return;
170
- viewContextConflictRevision = null, inspectedSelection?.artifactId !== activeArtifactId && (inspectedSelection = null);
171
- let board = ({ screenId, frameId, variantId }) => ({ screenId, frameId, variantId }), viewport = state.view === "canvas" ? stageSize() : null, visible = state.view === "canvas" ? visibleEntries().filter((entry) => {
172
- let bounds = placedBoardBounds(entry);
173
- if (!bounds) return !1;
174
- let { width, height } = bounds, { x, y } = canvas.worldToScreen(bounds);
175
- return x < viewport.width && y < viewport.height && x + width * state.zoom > 0 && y + height * state.zoom > 0;
176
- }) : [entryFor()];
177
- visible.sort(
178
- (a, b) => design.screenOrder.indexOf(a.screenId) - design.screenOrder.indexOf(b.screenId)
179
- );
180
- let context = {
181
- revision,
182
- view: state.view,
183
- visibleScreens: visible.map(board),
184
- selected: { ...board(state), planrId: inspectedSelection?.planrId ?? null },
185
- dirty: contentDirty || reviewDirty || layoutDragDirty || layoutOperations.length > 0
186
- }, signature = JSON.stringify(context);
187
- signature !== viewContextSignature && (viewContextSignature = signature, viewContextPending = signature, clearTimeout(viewContextTimer), viewContextTimer = setTimeout(() => {
188
- viewContextTimer = null, flushViewContext();
189
- }, 250));
190
- }
191
- async function flushViewContext() {
192
- if (viewContextSaving || !viewContextPending || destroyed) return;
193
- let body = viewContextPending;
194
- viewContextPending = null, viewContextSaving = !0;
195
- try {
196
- await jsonRequest(options2.viewContextUrl, {
197
- method: "PUT",
198
- headers: { "Content-Type": "application/json", "x-openplanr-design": "1" },
199
- body
200
- }), clearNotice("view-context");
201
- } catch (error) {
202
- viewContextSignature = null, error.conflict ? (viewContextConflictRevision = JSON.parse(body).revision, viewContextPending = null, clearTimeout(viewContextTimer), viewContextTimer = null, clearNotice("view-context"), revision !== viewContextConflictRevision && scheduleViewContext()) : notice(`View context could not be synchronized: ${error.message}`, !1, "view-context");
203
- } finally {
204
- viewContextSaving = !1, viewContextPending && viewContextTimer === null && flushViewContext();
205
- }
206
- }
207
- function persist({ content = !1 } = {}) {
208
- dirty = !0, serial += 1, content && (contentDirty = !0, contentSerial += 1, status("Saving changes", "saving")), storeDraft(), scheduleViewContext(), root.dispatchEvent(
209
- new CustomEvent("planr:design-state-change", {
210
- bubbles: !0,
211
- detail: clone(state)
212
- })
213
- ), clearTimeout(saveTimer), saveTimer = setTimeout(flush, 180);
214
- }
215
- function flushState() {
216
- if (clearTimeout(saveTimer), !dirty) return saving;
217
- let captured = clone(state), capturedSerial = serial, capturedContent = contentDirty, capturedContentSerial = contentSerial;
218
- return saving = saving.catch(() => {
219
- }).then(async () => {
220
- if (!destroyed)
221
- try {
222
- !legacyMigrated && (legacyServerPositions || savedDraft?.state?.positions) && (captured.positions = { ...savedDraft?.state?.positions, ...legacyServerPositions });
223
- let result;
224
- !capturedContent && typeof options2.savePersonalState == "function" ? result = await options2.savePersonalState(captured, { revision, stateVersion }) : typeof options2.saveState == "function" ? result = await options2.saveState(captured, {
225
- revision,
226
- stateVersion,
227
- personal: !capturedContent
228
- }) : options2.stateUrl && (result = await jsonRequest(options2.stateUrl, {
229
- method: "PUT",
230
- headers: { "Content-Type": "application/json" },
231
- body: JSON.stringify({ state: captured, revision, stateVersion })
232
- })), result?.stateVersion !== void 0 && (stateVersion = result.stateVersion), result?.revision !== void 0 && (revision = result.revision), clearNotice("personal-save"), capturedContent && clearNotice("content-save"), capturedSerial === serial && (dirty = !1), capturedContent && capturedContentSerial === contentSerial && (contentDirty = !1, !reviewDirty && !layoutOperations.length && status(
233
- options2.stateUrl || options2.saveState ? "All changes saved" : "Saved in this browser"
234
- )), storeDraft(), scheduleViewContext();
235
- } catch (error) {
236
- capturedContent && status(
237
- error.conflict ? "Save conflict" : "Disconnected · unsaved",
238
- error.conflict ? "failed" : "disconnected"
239
- ), notice(
240
- capturedContent ? error.conflict ? "This review changed in another window. Your unsaved edits remain in this browser. Reload to read the saved review before applying them again." : "Changes could not be saved. Your draft remains in this browser; reconnect to retry." : "Canvas preferences could not be synchronized. Your arrangement remains saved in this browser.",
241
- !0,
242
- capturedContent ? "content-save" : "personal-save"
243
- ), storeDraft();
244
- }
245
- }), saving;
246
- }
247
- function layoutUrl() {
248
- return options2.layoutUrl ?? options2.stateUrl?.replace(/design-state$/, "design-layout");
249
- }
250
- function canSaveLayout() {
251
- return !!(options2.saveLayout || layoutUrl());
252
- }
253
- function hasPendingLayout() {
254
- return !!(pendingLayoutDraft || layoutOperations.length || layoutSaving || layoutDragDirty);
255
- }
256
- function studioRestarted() {
257
- sessionLost = !0, storeDraft(), status(hasPendingLayout() ? "Layout unsaved · reload required" : "Reload required", "failed"), notice(
258
- "Studio restarted. Reload to reconnect; pending board moves remain in this browser.",
259
- !0,
260
- "studio-restart"
261
- );
262
- let reload = document.createElement("button");
263
- reload.type = "button", reload.dataset.designReloadStudio = "", reload.textContent = "Reload", reload.addEventListener("click", () => {
264
- storeDraft(), window.location.reload();
265
- }), q(".design-notice").append(reload);
266
- }
267
- function applyBoardMoves(boards) {
268
- for (let [key, point2] of Object.entries(boards))
269
- layout.boards ??= {}, point2 === null ? delete layout.boards[key] : layout.boards[key] = { ...layout.boards[key], ...point2 };
270
- }
271
- function restorePendingLayout() {
272
- if (!pendingLayoutDraft) return;
273
- let pending = pendingLayoutDraft;
274
- if (pendingLayoutDraft = null, layoutBlocked || !payload.contentIdentity || pending.contentIdentity !== payload.contentIdentity) {
275
- storeDraft(), notice(
276
- "Pending board moves were dropped because authored content changed. Review the current design before moving boards again.",
277
- !0,
278
- "layout-dropped"
279
- );
280
- return;
281
- }
282
- if (!(Array.isArray(pending.operations) && pending.operations.every(
283
- (operation) => typeof operation?.revision == "string" && operation.boards && typeof operation.boards == "object" && !Array.isArray(operation.boards) && Object.entries(operation.boards).every(
284
- ([key, point2]) => entries.some((entry) => boardKey(entry) === key) && (point2 === null || Number.isFinite(point2?.x) && Number.isFinite(point2?.y) && Math.abs(point2.x) <= 1e7 && Math.abs(point2.y) <= 1e7)
285
- )
286
- ))) {
287
- storeDraft(), notice(
288
- "Pending board moves could not be recovered because the browser draft contains invalid positions.",
289
- !0,
290
- "layout-dropped"
291
- );
292
- return;
293
- }
294
- for (let operation of pending.operations) {
295
- let boards = clone(operation.boards);
296
- applyBoardMoves(boards), layoutOperations.push({ revision, input: () => ({ boards }) });
297
- }
298
- storeDraft(), render(), layoutOperations.length && status("Recovering layout", "saving");
299
- }
300
- function newRevisionNotice() {
301
- notice(
302
- "A new design revision is ready. Save or recover this browser’s unsaved changes before reloading.",
303
- !0,
304
- "new-revision"
305
- );
306
- }
307
- async function rebaseLayout({ announce = !0, expectedRevision = revision } = {}) {
308
- let url = options2.statusUrl ?? options2.stateUrl?.replace(/design-state$/, "design-status");
309
- if (!url) throw new Error("Layout conflict recovery requires a design status URL.");
310
- let current = await jsonRequest(url);
311
- if (revision !== expectedRevision) return !0;
312
- if (typeof current.revision != "string" || typeof current.contentIdentity != "string")
313
- throw new Error("Design status did not return a revision and authored content identity.");
314
- if (current.contentIdentity !== payload.contentIdentity)
315
- return layoutBlocked = !0, layoutOperations.length = 0, layoutFailed = !1, storeDraft(), status("Design changed · reload required", "failed"), notice(
316
- "A new design revision is ready. Pending board moves were dropped because authored content changed. Reload to read the current design.",
317
- !0,
318
- "new-revision"
319
- ), !1;
320
- revision = current.revision, layout = clone(current.layout ?? {});
321
- let discardedRestores = layoutOperations.some((operation) => operation.restore);
322
- for (let index2 = layoutOperations.length - 1; index2 >= 0; index2--)
323
- layoutOperations[index2].restore && layoutOperations.splice(index2, 1);
324
- for (let moves of [undoMoves, redoMoves])
325
- for (let index2 = moves.length - 1; index2 >= 0; index2--)
326
- moves[index2].afterRevision !== null && moves.splice(index2, 1);
327
- for (let operation of layoutOperations) {
328
- operation.revision = revision;
329
- let boards = operation.input().boards;
330
- if (operation.move?.applied && (operation.move.before = clone(layout)), applyBoardMoves(boards), operation.move?.applied) operation.move.after = clone(layout);
331
- else if (operation.move) {
332
- let move = operation.move, movedBoard = move.after.boards?.[move.key];
333
- move.before = clone(layout), move.after = clone(layout), movedBoard ? move.after.boards = { ...move.after.boards, [move.key]: movedBoard } : move.after.boards && delete move.after.boards[move.key];
334
- }
335
- }
336
- return storeDraft(), render(), announce && notice(
337
- `The layout changed in another window. Pending board moves were rebased onto the current revision.${discardedRestores ? " Stale undo and redo operations were dropped." : ""}`,
338
- !0,
339
- "layout-rebase"
340
- ), !0;
341
- }
342
- function flushLayout() {
343
- return layoutSaving || layoutBlocked || sessionLost || !layoutOperations.length || (layoutSaving = !0, status("Saving layout", "saving"), saving = saving.then(async () => {
344
- let rebased = !1;
345
- try {
346
- for (; layoutOperations.length; ) {
347
- let operation = layoutOperations[0], input = { revision, ...operation.input() };
348
- activeLayoutOperation = operation, operation.attempted = !0, operation.appliedAtSave = operation.move?.applied, status("Saving layout", "saving");
349
- let result;
350
- try {
351
- if (typeof options2.saveLayout == "function") result = await options2.saveLayout(input);
352
- else if (layoutUrl())
353
- result = await jsonRequest(layoutUrl(), {
354
- method: "PUT",
355
- headers: { "Content-Type": "application/json", "x-openplanr-design": "1" },
356
- body: JSON.stringify(input)
357
- });
358
- else
359
- throw new Error("Layout save requires a studio layout URL or saveLayout callback.");
360
- } catch (error) {
361
- if (activeLayoutOperation = null, operation.canceled = !1, !error.conflict || rebased) throw error;
362
- if (rebased = !0, !await rebaseLayout()) return;
363
- continue;
364
- }
365
- if (typeof result.revision != "string")
366
- throw new Error("Layout save did not return a design revision.");
367
- operation.saved?.(revision, result.revision), revision = result.revision, layoutOperations.shift(), activeLayoutOperation = null, storeDraft(), scheduleViewContext();
368
- }
369
- layoutFailed = !1, clearNotice("layout-save");
370
- } catch (error) {
371
- if (layoutFailed = !0, storeDraft(), error.statusCode === 404) {
372
- studioRestarted();
373
- return;
374
- }
375
- status(error.conflict ? "Layout conflict" : "Layout unsaved", "failed"), notice(`Board layout could not be saved: ${error.message}`, !0, "layout-save");
376
- let retry = document.createElement("button");
377
- retry.type = "button", retry.dataset.designRetryLayout = "", retry.textContent = "Retry", retry.addEventListener("click", () => {
378
- flushLayout();
379
- }), q(".design-notice").append(retry);
380
- } finally {
381
- activeLayoutOperation = null, layoutSaving = !1, !hasPendingLayout() && !contentDirty && !reviewDirty && !layoutBlocked && !sessionLost && status("All changes saved");
382
- }
383
- })), saving;
384
- }
385
- function boardKey(entry) {
386
- return `${entry.screenId}/${entry.frameId}/${entry.variantId}`;
387
- }
388
- function queueMove(move) {
389
- let point2 = (value) => {
390
- let board = value.boards?.[move.key];
391
- return board ? { x: board.x, y: board.y } : null;
392
- }, operation = {
393
- revision,
394
- move,
395
- boards: { [move.key]: point2(move.after) },
396
- input: () => ({ boards: operation.boards }),
397
- saved(previous, next) {
398
- if (operation.appliedAtSave && (move.beforeRevision = previous, move.afterRevision = next), operation.canceled) {
399
- let boards = { [move.key]: point2(layout) };
400
- layoutOperations.push({ input: () => ({ boards }) });
401
- }
402
- }
403
- };
404
- layoutOperations.push(operation), storeDraft(), scheduleViewContext(), flushLayout();
405
- }
406
- function completeMove(entry, before) {
407
- let after = clone(layout);
408
- if (JSON.stringify(before) === JSON.stringify(after)) return;
409
- let move = {
410
- key: boardKey(entry),
411
- before,
412
- after,
413
- beforeRevision: null,
414
- afterRevision: null,
415
- applied: !0
416
- };
417
- undoMoves.push(move), redoMoves.length = 0, storeDraft(), canSaveLayout() && queueMove(move);
418
- }
419
- function restoreMove(redo) {
420
- let source = redo ? redoMoves : undoMoves, target = redo ? undoMoves : redoMoves, move = source.pop();
421
- if (move && (move.applied = redo, layout = clone(redo ? move.after : move.before), target.push(move), render(), !!canSaveLayout())) {
422
- if (move.beforeRevision === null || move.afterRevision === null) {
423
- let pending = layoutOperations.find((operation) => operation.move === move);
424
- if (pending) {
425
- let board = layout.boards?.[move.key];
426
- pending.boards = { [move.key]: board ? { x: board.x, y: board.y } : null };
427
- }
428
- pending === activeLayoutOperation && pending ? pending.canceled = !redo : pending?.attempted || (pending && layoutOperations.splice(layoutOperations.indexOf(pending), 1), redo && queueMove(move)), !layoutOperations.length && !layoutSaving && (layoutFailed = !1, clearNotice("layout-save"), !contentDirty && !reviewDirty && status("All changes saved")), storeDraft(), scheduleViewContext();
429
- return;
430
- }
431
- layoutOperations.push({
432
- revision,
433
- restore: !0,
434
- replayBoards: {
435
- [move.key]: layout.boards?.[move.key] ? {
436
- x: layout.boards[move.key].x,
437
- y: layout.boards[move.key].y
438
- } : null
439
- },
440
- input: () => ({ restoreRevision: redo ? move.afterRevision : move.beforeRevision })
441
- }), storeDraft(), scheduleViewContext(), flushLayout();
442
- }
443
- }
444
- function migrateLegacyPositions() {
445
- if (layoutBlocked) return;
446
- if (!legacyServerPositions && !savedDraft?.state?.positions) {
447
- legacyMigrated = !0;
448
- return;
449
- }
450
- let boards = {};
451
- for (let positions of [legacyServerPositions, savedDraft?.state?.positions])
452
- for (let entry of entries) {
453
- let key = boardKey(entry), point2 = positions?.[entry.artifactId];
454
- layout.boards?.[key] !== void 0 || boards[key] !== void 0 || !point2 || !Number.isFinite(point2.x) || !Number.isFinite(point2.y) || Math.abs(point2.x) > 1e7 || Math.abs(point2.y) > 1e7 || (boards[key] = { x: Math.round(point2.x), y: Math.round(point2.y) });
455
- }
456
- Object.keys(boards).length && (layout.boards = { ...layout.boards, ...boards }), render();
457
- let migrated = () => {
458
- legacyMigrated = !0, legacyServerPositions = void 0, storeDraft(), options2.stateUrl && persist();
459
- };
460
- Object.keys(boards).length && canSaveLayout() ? (layoutOperations.push({ revision, input: () => ({ boards }), saved: migrated }), storeDraft()) : canSaveLayout() && migrated();
461
- }
462
- function reviewUrl() {
463
- return options2.reviewUrl ?? (options2.stateUrl ? options2.stateUrl.replace(/design-state$/, "review") : null);
464
- }
465
- function storeReviewDraft() {
466
- if (latestReview)
467
- try {
468
- localStorage.setItem(
469
- `${storageKey}.review`,
470
- JSON.stringify({ review: latestReview, unsaved: reviewDirty })
471
- );
472
- } catch {
473
- }
474
- }
475
- function flushReview() {
476
- if (clearTimeout(reviewTimer), !reviewDirty || !latestReview) return reviewSaving;
477
- let captured = clone(latestReview), capturedSerial = reviewSerial;
478
- return reviewSaving = reviewSaving.catch(() => {
479
- }).then(async () => {
480
- try {
481
- reviewUrl() && await jsonRequest(reviewUrl(), {
482
- method: "PUT",
483
- headers: { "Content-Type": "application/json" },
484
- body: JSON.stringify({ review: captured })
485
- }), clearNotice("review-save"), capturedSerial === reviewSerial && (reviewDirty = !1, !contentDirty && !layoutOperations.length && status(reviewUrl() ? "All changes saved" : "Saved in this browser")), storeReviewDraft(), scheduleViewContext();
486
- } catch (error) {
487
- status("Comments unsaved", "disconnected"), notice(
488
- `Comments could not be saved: ${error.message} Your draft remains in this browser.`,
489
- !0,
490
- "review-save"
491
- ), storeReviewDraft();
492
- }
493
- }), reviewSaving;
494
- }
495
- function flush() {
496
- return Promise.all([flushState(), flushLayout(), flushReview()]);
497
- }
498
- function entryFor(screenId = state.screenId, variantId = state.variantId, frameId = state.frameId) {
499
- return entries.find(
500
- (entry) => entry.screenId === screenId && entry.variantId === variantId && entry.frameId === frameId
501
- );
502
- }
503
- function viewportFor(entry) {
504
- let frame = design.frames.find(({ id }) => id === entry.frameId);
505
- return stage.getState().artifacts.find(({ id }) => id === entry.artifactId)?.viewport ?? designFrameViewport(design, frame);
506
- }
507
- function visibleEntries() {
508
- return entries.filter(
509
- (entry) => (state.view === "canvas" && state.compare || entry.variantId === state.variantId) && (state.view === "canvas" || entry.screenId === state.screenId && entry.frameId === state.frameId)
510
- );
511
- }
512
- function syncFrameGestures(frame, panel) {
513
- frame?.__openPlanrBridge?.setViewportGestures?.(state.view === "canvas" && !panel.hidden);
514
- }
515
- function updatePan() {
516
- root.dataset.designPanActive = String(state.view === "canvas" && (panEnabled || spacePan)), root.dataset.designTool = activeTool, canvas.setPointerMode(root.dataset.designInspect === "true" ? "none" : "pan"), q("[data-design-pan]").setAttribute("aria-pressed", String(activeTool === "pan")), q('[data-planr-mode="interact"]').setAttribute(
517
- "aria-pressed",
518
- String(activeTool === "interact")
519
- ), q('[data-planr-mode="comment"]').setAttribute(
520
- "aria-pressed",
521
- String(activeTool === "annotate")
522
- ), q("[data-design-inspect-mode]")?.setAttribute("aria-pressed", String(activeTool === "inspect"));
523
- for (let [id, panel] of panels) {
524
- let frame = stage.getFrame(id);
525
- if (frame) {
526
- let tabIndex = activeTool === "interact" && !panel.hidden && stage.getState().status === "ready" ? 0 : -1;
527
- frame.tabIndex !== tabIndex && (frame.tabIndex = tabIndex), syncFrameGestures(frame, panel);
528
- }
529
- }
530
- }
531
- function finishGesture() {
532
- if (!gesture) return;
533
- let completed = gesture, pointerId = completed.pointerId;
534
- gesture = null, layoutDragDirty = !1;
535
- try {
536
- scroll.hasPointerCapture?.(pointerId) && scroll.releasePointerCapture(pointerId);
537
- } catch {
538
- }
539
- updatePan(), completed.mode === "artboard" ? completeMove(
540
- entries.find((entry) => entry.artifactId === completed.artifactId),
541
- completed.before
542
- ) : persist(), scheduleViewContext();
543
- }
544
- function noteFramesUsedWithComments() {
545
- if (!(state.view !== "canvas" || activeTool !== "annotate"))
546
- for (let id of stage.getLoadedArtifactIds()) framesUsedWithComments.add(id);
547
- }
548
- function reloadFrameUsedWithComments(artifactId) {
549
- if (!framesUsedWithComments.delete(artifactId) || !stage.getLoadedArtifactIds().includes(artifactId)) return;
550
- let reload = ++frameReload;
551
- root.dataset.designScreenLoading = "true";
552
- let settle = () => destroyed || reload !== frameReload ? !1 : (pendingScreen || delete root.dataset.designScreenLoading, updateFramePlaceholders(), !0);
553
- stage.retryFrames([artifactId]).then(settle, (error) => {
554
- !settle() || error.name === "AbortError" || notice(
555
- "This screen could not reload. Select it again to retry; your review is preserved.",
556
- !0,
557
- `preview-load:${artifactId}`
558
- );
559
- });
560
- }
561
- function setTool(tool) {
562
- if (["interact", "annotate", "pan", "inspect"].includes(tool) && !(tool === "pan" && state.view !== "canvas") && !(tool === "annotate" && root.hasAttribute("data-planr-room-comments-paused"))) {
563
- if (finishWalkthroughTransition(), finishGesture(), canvasAttached && canvasPointers.size) {
564
- saveViewport();
565
- for (let pointerId of canvasPointers)
566
- scroll.hasPointerCapture?.(pointerId) && scroll.releasePointerCapture(pointerId);
567
- canvasPointers.clear();
568
- }
569
- spacePan = !1, spaceReturnTool = null, activeTool = tool, panEnabled = tool === "pan", previousReviewMode = tool === "annotate" ? "comment" : "interact", changingTool = !0;
570
- try {
571
- stage.dispatch({ type: "set-review-mode", reviewMode: previousReviewMode });
572
- } finally {
573
- changingTool = !1;
574
- }
575
- noteFramesUsedWithComments(), root.dispatchEvent(new CustomEvent("planr:design-tool-change", { detail: { tool } })), updatePan();
576
- }
577
- }
578
- function releaseTemporaryPan() {
579
- let previous = spaceReturnTool;
580
- finishGesture(), spacePan && setTool(previous || "interact");
581
- }
582
- function readCanvasCamera() {
583
- if (!canvasAttached || state.view !== "canvas") return;
584
- let { x, y, scale } = cameraToScreenTranslate(canvas.getCamera());
585
- state.camera = { x, y }, state.zoom = scale;
586
- }
587
- function applyCanvasCamera() {
588
- canvas.setCamera(cameraFromScreenTranslate({ ...state.camera, scale: state.zoom })), saveViewport();
589
- }
590
- function saveViewport() {
591
- readCanvasCamera(), state.viewports[state.view] = {
592
- x: state.camera.x,
593
- y: state.camera.y,
594
- zoom: state.zoom
595
- };
596
- }
597
- function restoreViewport(view) {
598
- let viewport = state.viewports[view];
599
- return viewport ? (state.camera = { x: viewport.x, y: viewport.y }, state.zoom = viewport.zoom, canvasAttached && view === "canvas" && applyCanvasCamera(), !0) : !1;
600
- }
601
- function switchView(view, { save = !0 } = {}) {
602
- if (!views.includes(view)) throw new TypeError(`Unknown design view: ${view}`);
603
- if (view === state.view) return;
604
- let queued = pendingScreen ? null : queuedSelection;
605
- finishWalkthroughTransition(), closeDesignNotes(), saveViewport(), state.view = view;
606
- let restored = view === "canvas" && restoreViewport(view);
607
- setTool(view === "canvas" && activeTool === "annotate" ? "annotate" : "interact"), root.dispatchEvent(new CustomEvent("planr:design-view-change", { detail: { view } })), render(), restored || fit({ save: !1 }), queued && selectEntry(queued.entry, { ...queued.settings, save: !1 }), save && (persist(), recordLocation());
608
- }
609
- function syncCanvasChrome() {
610
- if (!canvasAttached) return;
611
- let stageRect = scroll.getBoundingClientRect();
612
- for (let [id, selector, open] of [
613
- ["toolbar", ".design-toolbar", !0],
614
- ["tools", ".design-canvas-tools", !0],
615
- ["context", ".design-stage-context", !0],
616
- ["navigator", ".design-navigator", state.navOpen],
617
- ["review", ".planr-review-rail", stage.getState().railOpen]
618
- ]) {
619
- let rect2 = q(selector).getBoundingClientRect(), x = Math.max(0, rect2.left - stageRect.left), y = Math.max(0, rect2.top - stageRect.top), width = Math.max(0, Math.min(stageRect.width, rect2.right - stageRect.left) - x), height = Math.max(0, Math.min(stageRect.height, rect2.bottom - stageRect.top) - y), edge = width >= height ? y + height / 2 < stageRect.height / 2 ? "top" : "bottom" : x + width / 2 < stageRect.width / 2 ? "left" : "right";
620
- canvas.setChrome({
621
- id,
622
- edge,
623
- rect: { x, y, width, height },
624
- open: open && width > 0 && height > 0
625
- });
626
- }
627
- }
628
- function placedBoardBounds(entry) {
629
- let panel = panels.get(entry.artifactId);
630
- if (!panel || panel.hidden) return null;
631
- let bounds = {
632
- ...viewportFor(entry),
633
- x: parseFloat(panel.style.left),
634
- y: parseFloat(panel.style.top)
635
- };
636
- return Object.values(bounds).every(Number.isFinite) ? bounds : null;
637
- }
638
- function syncCanvasNodes() {
639
- if (!canvasAttached) return;
640
- grid.style.setProperty("--design-zoom", String(state.zoom));
641
- let placed = visibleEntries().flatMap((entry) => {
642
- let bounds = placedBoardBounds(entry);
643
- return bounds ? [{ entry, bounds }] : [];
644
- }), nodes = placed.flatMap(({ entry, bounds }) => [
645
- { id: entry.artifactId, bounds },
646
- {
647
- id: `label:${entry.artifactId}`,
648
- bounds: { ...bounds, y: bounds.y - 34 / state.zoom, height: 28 / state.zoom }
649
- }
650
- ]), labels = placed.map(({ entry }) => {
651
- let label = panels.get(entry.artifactId).querySelector(".design-artboard-label"), title = label.querySelector("strong"), size4 = label.querySelector("span");
652
- return label.title = `${title.textContent} · ${size4.textContent}`, size4.hidden = !1, { title, size: size4 };
653
- });
654
- sectionHeadings.forEach((heading, index2) => {
655
- let section = layout.sections[index2];
656
- heading.hidden = !1, heading.style.fontSize = `${clamp2(28 * state.zoom, 14, 28) / state.zoom}px`, section.maxW && (heading.style.maxWidth = `${section.maxW / state.zoom}px`);
657
- });
658
- let headingSizes = sectionHeadings.map((heading) => ({
659
- width: heading.offsetWidth,
660
- height: heading.offsetHeight
661
- })), truncated = labels.map(
662
- ({ title, size: size4 }) => title.scrollWidth > title.clientWidth || size4.scrollWidth > size4.clientWidth
663
- );
664
- sectionHeadings.forEach((heading, index2) => {
665
- let section = layout.sections[index2], { width, height } = headingSizes[index2], below = placed.filter(
666
- ({ bounds: board }) => board.y >= section.y && section.x < board.x + board.width && section.x + width > board.x
667
- ), bottom = Math.min(section.y, ...below.map(({ bounds: bounds2 }) => bounds2.y - 42 / state.zoom));
668
- heading.style.top = `${bottom - height}px`;
669
- let bounds = {
670
- x: parseFloat(heading.style.left),
671
- y: parseFloat(heading.style.top),
672
- width,
673
- height
674
- };
675
- heading.hidden = nodes.some(
676
- ({ bounds: other }) => bounds.x < other.x + other.width && bounds.x + bounds.width > other.x && bounds.y < other.y + other.height && bounds.y + bounds.height > other.y
677
- ), !heading.hidden && Object.values(bounds).every(Number.isFinite) && nodes.push({ id: `section:${section.id}`, bounds });
678
- }), labels.forEach(({ size: size4 }, index2) => {
679
- size4.hidden = truncated[index2];
680
- }), sectionZoom = state.zoom, canvas.setNodes(nodes);
681
- for (let { entry } of placed)
682
- canvas.registerNodeElement(entry.artifactId, panels.get(entry.artifactId));
683
- canvas.setSelection(
684
- placed.some(({ entry }) => entry.artifactId === activeArtifactId) ? [activeArtifactId] : []
685
- );
686
- }
687
- function syncCanvas() {
688
- if (state.view !== "canvas") {
689
- canvasAttached && canvas.detach(), canvasPointers.clear(), canvasAttached = !1;
690
- return;
691
- }
692
- canvasAttached || (canvas.attach({ stage: scroll, world: grid }), canvasAttached = !0, applyCanvasCamera()), syncCanvasNodes(), syncCanvasChrome();
693
- }
694
- function centerEntry(entry) {
695
- state.view !== "canvas" || !placedBoardBounds(entry) || fit({ selection: entry, save: !1, maxZoom: state.zoom });
696
- }
697
- function updateDesignNotes() {
698
- let notes = q("[data-design-notes]");
699
- if (!notes) return;
700
- notes.querySelector(":scope > summary").setAttribute("aria-expanded", String(notes.open));
701
- for (let button of qa("[data-design-note]"))
702
- button.setAttribute(
703
- "aria-expanded",
704
- String(notes.open && button.dataset.designNote === noteScreenId)
705
- );
706
- if (!notes.open) return;
707
- let panel = q(".design-guidance-panel"), anchor = notes.querySelector(":scope > summary").getBoundingClientRect(), width = panel.getBoundingClientRect().width || Math.min(340, window.innerWidth - 24), top = clamp2(anchor.bottom + 7, 12, Math.max(12, window.innerHeight - 100));
708
- panel.style.left = `${clamp2(anchor.right - width, 12, Math.max(12, window.innerWidth - width - 12))}px`, panel.style.top = `${top}px`, panel.style.maxHeight = `${Math.min(520, Math.max(60, window.innerHeight - top - 12))}px`;
709
- }
710
- function closeDesignNotes({ restoreFocus = !1 } = {}) {
711
- let notes = q("[data-design-notes]");
712
- notes?.open && (notes.open = !1, noteScreenId = null, updateDesignNotes(), restoreFocus && (notesReturnFocus?.isConnected ? notesReturnFocus : notes.querySelector(":scope > summary"))?.focus({ preventScroll: !0 }), notesReturnFocus = null);
713
- }
714
- function openDesignNote(screenId, trigger) {
715
- let notes = q("[data-design-notes]");
716
- if (!notes) return;
717
- if (notes.open && noteScreenId === screenId) {
718
- closeDesignNotes();
719
- return;
720
- }
721
- notesReturnFocus = trigger, noteScreenId = screenId, notes.open = !0;
722
- let target = null;
723
- for (let item of qa("[data-design-note-screen]")) {
724
- let selected = item.dataset.designNoteScreen === screenId;
725
- item.open = selected, item.dataset.active = String(selected), selected && (target = item);
726
- }
727
- updateDesignNotes();
728
- let panel = q(".design-guidance-panel");
729
- target && (panel.scrollTop = Math.max(0, target.offsetTop - panel.querySelector("header").offsetHeight));
730
- }
731
- function render() {
732
- if (!(!stage || rendering || destroyed)) {
733
- rendering = !0;
734
- try {
735
- window.innerWidth <= 680 ? root.style.setProperty(
736
- "--planr-toolbar-height",
737
- `${q(".design-toolbar").getBoundingClientRect().height}px`
738
- ) : root.style.removeProperty("--planr-toolbar-height");
739
- let screen = design.screens.find(({ id }) => id === state.screenId), variant = design.variants.find(({ id }) => id === state.variantId), stageState = stage.getState();
740
- root.dataset.designView = state.view, root.dataset.designNavOpen = String(state.navOpen);
741
- let navigator2 = q(".design-navigator");
742
- navigator2.inert = !state.navOpen, navigator2.setAttribute("aria-hidden", String(!state.navOpen));
743
- for (let toggle of qa("[data-design-toggle-nav]"))
744
- toggle.setAttribute("aria-expanded", String(state.navOpen));
745
- for (let button of qa("[data-design-view]"))
746
- button.tagName === "BUTTON" && button.setAttribute("aria-pressed", String(button.dataset.designView === state.view));
747
- for (let button of qa("[data-design-screen]"))
748
- button.setAttribute(
749
- "aria-current",
750
- button.dataset.designScreen === state.screenId ? "page" : "false"
751
- );
752
- q("[data-design-variant]").value = failedSelection?.variantId ?? state.variantId, q("[data-design-frame]").value = failedSelection?.frameId ?? state.frameId, q("[data-design-compare]") && (q("[data-design-compare]").checked = state.compare), q("[data-design-screen-title]").textContent = state.view === "canvas" ? design.title : screen.title, q("[data-design-stage-description]").textContent = state.view === "canvas" ? `${design.screenOrder.length} screens · ${design.frames.length} responsive ${design.frames.length === 1 ? "frame" : "frames"}${state.compare ? ` · ${readyVariants.length} directions` : ""}` : state.view === "prototype" ? "Explore the working journey" : "A guided journey through the design", q("[data-design-direction-label]").textContent = variant.label;
753
- let chosen = state.selectedVariant === state.variantId && state.preferences.selected.includes(state.variantId);
754
- q("[data-design-selected-direction]").textContent = chosen ? "Selected" : "", q("[data-design-select-direction]").disabled = chosen, q("[data-design-select-direction]").textContent = chosen ? "Selected direction" : "Use this direction";
755
- for (let button of qa("[data-design-rating]")) {
756
- let selected = Number(button.dataset.designRating) <= (state.ratings[state.variantId] ?? 0);
757
- button.setAttribute("aria-pressed", String(selected)), button.textContent = selected ? "★" : "☆";
758
- }
759
- document.activeElement !== q("[data-design-remix]") && (q("[data-design-remix]").value = state.remix[state.variantId] ?? ""), q("[data-design-pan]").hidden = state.view !== "canvas";
760
- for (let control of qa("[data-design-zoom]")) control.hidden = state.view !== "canvas";
761
- q("[data-design-actual-size]").hidden = state.view === "canvas", q("[data-design-actual-size]").setAttribute(
762
- "aria-pressed",
763
- String(state.inspectionScale === "actual")
764
- ), root.dataset.designInspectionScale = state.inspectionScale, q(".design-canvas-tools").setAttribute(
765
- "aria-label",
766
- state.view === "canvas" ? "Canvas controls" : "Screen controls"
767
- );
768
- let fitControl = q("[data-design-fit]");
769
- fitControl.textContent = state.view === "canvas" ? "Fit" : "Fit screen", fitControl.setAttribute(
770
- "aria-label",
771
- state.view === "canvas" ? "Fit all visible artboards" : "Fit screen"
772
- );
773
- let comparison = q("[data-design-compare]");
774
- comparison && (comparison.closest("label").hidden = state.view !== "canvas");
775
- let caption = q(".design-walkthrough-caption");
776
- caption.hidden = state.view !== "walkthrough", q("[data-design-step]").textContent = `Step ${design.screenOrder.indexOf(state.screenId) + 1} of ${design.screenOrder.length}`, q("[data-design-narrative-title]").textContent = screen.title, q("[data-design-narrative]").textContent = screen.description ?? design.flows?.find((flow) => flow.screens.includes(screen.id))?.title ?? design.brief?.text ?? "", q('[data-design-step-change="-1"]').disabled = requestedScreen() === design.screenOrder[0], q('[data-design-step-change="1"]').disabled = requestedScreen() === design.screenOrder.at(-1);
777
- for (let item of qa("[data-design-note-screen]"))
778
- item.dataset.active = String(item.dataset.designNoteScreen === state.screenId);
779
- for (let heading of sectionHeadings) heading.hidden = state.view !== "canvas";
780
- let visible = visibleEntries(), visibleIds = new Set(visible.map(({ artifactId }) => artifactId));
781
- for (let entry of entries) {
782
- let panel = panels.get(entry.artifactId), isVisible = visibleIds.has(entry.artifactId), outgoing = walkthroughTransition?.from === entry.artifactId;
783
- panel.hidden = !isVisible && !outgoing, panel.dataset.designActive = String(entry.artifactId === activeArtifactId);
784
- let frameElement = stage.getFrame(entry.artifactId), layer = panel.querySelector("[data-planr-annotation-layer]"), ready = stageState.status === "ready" && (!stage.frameBudget || frameElement.dataset.planrFrameState === "ready");
785
- if (frameElement.tabIndex = isVisible && ready && stageState.reviewMode === "interact" ? 0 : -1, layer.tabIndex = isVisible && ready && stageState.reviewMode === "comment" ? 0 : -1, layer.setAttribute("aria-disabled", String(layer.tabIndex < 0)), !isVisible && !outgoing) continue;
786
- let placement = boardPlacement(design, entry, {
787
- layout,
788
- compare: state.compare,
789
- variantId: state.variantId
790
- }), { x, y } = placement;
791
- state.view !== "canvas" && (x = 0, y = 0), panel.style.left = `${x}px`, panel.style.top = `${y}px`, panel.querySelector(".design-artboard-drag strong").textContent = placement.title;
792
- }
793
- grid.style.width = "1px", grid.style.height = "1px", surface.style.width = "100%", surface.style.height = "100%", syncCanvas(), updatePan(), renderCamera(), chrome?.update({ view: state.view, navOpen: state.navOpen, reviewOpen: stageState.railOpen }), state.view !== "canvas" && activeArtifactId && reloadFrameUsedWithComments(activeArtifactId), root.dispatchEvent(new CustomEvent("planr:design-render", { detail: clone(state) }));
794
- } finally {
795
- rendering = !1;
796
- }
797
- }
798
- }
799
- function scheduleCamera() {
800
- cameraFrame !== null || destroyed || (cameraFrame = requestAnimationFrame(() => {
801
- cameraFrame = null, renderCamera();
802
- }));
803
- }
804
- function renderCamera() {
805
- if (!stage || destroyed) return;
806
- if (cameraFrame !== null && (cancelAnimationFrame(cameraFrame), cameraFrame = null), readCanvasCamera(), state.view !== "canvas") {
807
- let frame = viewportFor(entryFor()), inset = window.innerWidth <= 680 ? 12 : 24;
808
- state.zoom = state.inspectionScale === "actual" ? 1 : Math.max(
809
- 1e-3,
810
- Math.min(
811
- 1,
812
- Math.max(1, scroll.clientWidth - inset * 2) / frame.width,
813
- Math.max(1, scroll.clientHeight - inset * 2) / frame.height
814
- )
815
- ), state.camera = {
816
- x: state.inspectionScale === "actual" ? inset : (scroll.clientWidth - frame.width * state.zoom) / 2,
817
- y: state.inspectionScale === "actual" ? inset : (scroll.clientHeight - frame.height * state.zoom) / 2
818
- }, state.inspectionScale === "actual" && (surface.style.width = `${Math.max(scroll.clientWidth, frame.width + inset * 2)}px`, surface.style.height = `${Math.max(scroll.clientHeight, frame.height + inset * 2)}px`), saveViewport();
819
- }
820
- let zoom = String(state.zoom);
821
- grid.style.getPropertyValue("--design-zoom") !== zoom && grid.style.setProperty("--design-zoom", zoom), state.view === "canvas" && sectionZoom !== state.zoom && syncCanvasNodes(), state.view !== "canvas" && (grid.style.transform = `translate(${state.camera.x}px, ${state.camera.y}px) scale(${state.zoom})`);
822
- let active = entries.find((entry) => entry.artifactId === activeArtifactId), bounds = active ? placedBoardBounds(active) : null;
823
- if (selectionOutline && (selectionOutline.hidden = state.view !== "canvas" || !bounds, !selectionOutline.hidden)) {
824
- let frame = design.frames.find((item) => item.id === active.frameId), ratio = window.devicePixelRatio || 1, pixel = (value) => Math.round(value * ratio) / ratio, x = pixel(state.camera.x + bounds.x * state.zoom), y = pixel(state.camera.y + bounds.y * state.zoom);
825
- selectionOutline.style.transform = `translate3d(${x - 3}px, ${y - 3}px, 0)`, selectionOutline.style.width = `${pixel(frame.width * state.zoom) + 6}px`, selectionOutline.style.height = `${pixel(viewportFor(active).height * state.zoom) + 6}px`;
826
- }
827
- let label = `${Math.round(state.zoom * 100)}%`, reset = q('[data-design-zoom="reset"]');
828
- reset.textContent !== label && (reset.textContent = label), scheduleFrameDemand(), root.dispatchEvent(
829
- new CustomEvent("planr:design-camera", {
830
- detail: { view: state.view, zoom: state.zoom, camera: { ...state.camera } }
831
- })
832
- );
833
- }
834
- function updateFramePlaceholders() {
835
- if (!(!stage?.frameBudget || destroyed))
836
- for (let [id, panel] of panels) {
837
- let frame = stage.getFrame(id), placeholder = panel.querySelector("[data-design-load-frame]");
838
- if (syncFrameGestures(frame, panel), !placeholder) continue;
839
- let status2 = frame.dataset.planrFrameState || "unloaded";
840
- placeholder.hidden = status2 === "ready", placeholder.disabled = status2 === "loading";
841
- let copy = status2 === "loading" ? "Loading screen…" : status2 === "error" ? "Retry screen" : "Open screen";
842
- placeholder.textContent !== copy && (placeholder.textContent = copy), frame.style.visibility = status2 === "ready" ? "" : "hidden";
843
- }
844
- }
845
- function scheduleFrameDemand() {
846
- if (!stage?.frameBudget || destroyed) return;
847
- clearTimeout(frameDemandTimer);
848
- let generation = frameDemandGeneration;
849
- frameDemandTimer = setTimeout(() => {
850
- if (destroyed || generation !== frameDemandGeneration || !readyReported || pendingScreen || walkthroughTransition || state.view !== "canvas" || root.dataset.sharedOpening || document.querySelector(".design-welcome[open]"))
851
- return;
852
- let box = scroll.getBoundingClientRect(), nearby = visibleEntries().map((entry) => {
853
- let rect2 = panels.get(entry.artifactId).getBoundingClientRect();
854
- return {
855
- id: entry.artifactId,
856
- visible: rect2.right > box.left && rect2.left < box.right && rect2.bottom > box.top && rect2.top < box.bottom,
857
- distance: Math.hypot(
858
- (rect2.left + rect2.right - box.left - box.right) / 2,
859
- (rect2.top + rect2.bottom - box.top - box.bottom) / 2
860
- )
861
- };
862
- }).filter((item) => item.visible).sort((a, b) => a.distance - b.distance), ids = [
863
- ...new Set([activeArtifactId, ...nearby.map((item) => item.id)].filter(Boolean))
864
- ].slice(0, stage.frameBudget), key = ids.join("|");
865
- key !== frameDemandKey && (frameDemandKey = key, stage.ensureFrames(ids, () => !destroyed && generation === frameDemandGeneration).then(() => {
866
- noteFramesUsedWithComments(), updateFramePlaceholders();
867
- }).catch((error) => {
868
- !destroyed && error.name !== "AbortError" && (frameDemandKey = "", updateFramePlaceholders());
869
- }));
870
- }, 120);
871
- }
872
- function finishWalkthroughTransition({ continueQueued = !1 } = {}) {
873
- let transition = walkthroughTransition, queued = continueQueued ? queuedSelection : null;
874
- if (queuedSelection = null, !!transition) {
875
- walkthroughTransition = null, cancelAnimationFrame(transition.frame), clearTimeout(transition.timeout);
876
- for (let animation of transition.animations ?? []) animation.cancel();
877
- for (let visual of transition.visuals ?? []) delete visual.dataset.designTransitionVisual;
878
- for (let id of [transition.from, transition.to]) {
879
- let panel = panels.get(id);
880
- panel.inert = !1, panel.removeAttribute("aria-hidden"), delete panel.dataset.designTransitionOutgoing, delete panel.dataset.designTransitionIncoming;
881
- }
882
- delete root.dataset.designTransition, render(), queued && !destroyed && selectEntry(queued.entry, queued.settings);
883
- }
884
- }
885
- function prepareWalkthroughTransition(entry) {
886
- let from = activeArtifactId, outgoing = panels.get(from), incoming = panels.get(entry.artifactId), direction = design.screenOrder.indexOf(entry.screenId) < design.screenOrder.indexOf(state.screenId) ? -1 : 1, transition = {
887
- from,
888
- to: entry.artifactId,
889
- direction,
890
- frame: null,
891
- timeout: null,
892
- animations: [],
893
- visuals: []
894
- };
895
- walkthroughTransition = transition, root.dataset.designTransition = "preparing", outgoing.dataset.designTransitionOutgoing = "", incoming.dataset.designTransitionIncoming = "", outgoing.contains(document.activeElement) && q(`[data-design-step-change="${direction}"]`).focus({ preventScroll: !0 }), outgoing.inert = incoming.inert = !0, outgoing.setAttribute("aria-hidden", "true");
896
- let finish = () => {
897
- walkthroughTransition === transition && finishWalkthroughTransition({ continueQueued: !0 });
898
- };
899
- transition.timeout = setTimeout(finish, 1e3), transition.frame = requestAnimationFrame(() => {
900
- transition.frame = requestAnimationFrame(() => {
901
- if (walkthroughTransition !== transition || destroyed) return;
902
- if (document.hidden || window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches || typeof incoming.animate != "function") {
903
- finish();
904
- return;
905
- }
906
- root.dataset.designTransition = "running";
907
- let frameVisual = incoming.querySelector(".planr-frame iframe"), annotationVisual = incoming.querySelector("[data-planr-annotation-layer]");
908
- transition.visuals = [frameVisual, annotationVisual].filter(Boolean);
909
- for (let visual of transition.visuals) visual.dataset.designTransitionVisual = "";
910
- let options3 = { duration: 220, easing: "cubic-bezier(0.22, 1, 0.36, 1)", fill: "both" };
911
- transition.animations = [
912
- frameVisual.animate(
913
- [
914
- { opacity: 0, transform: `translate3d(${direction * 12 / state.zoom}px, 0, 0)` },
915
- { opacity: 1, transform: "translate3d(0, 0, 0)" }
916
- ],
917
- options3
918
- )
919
- ], annotationVisual && transition.animations.push(
920
- annotationVisual.animate([{ opacity: 0 }, { opacity: 1 }], options3)
921
- ), Promise.all(transition.animations.map((animation) => animation.finished)).then(
922
- finish,
923
- () => {
924
- }
925
- );
926
- });
927
- });
928
- }
929
- function requestedSelection() {
930
- return pendingScreen?.entry ?? queuedSelection?.entry ?? failedSelection ?? state;
931
- }
932
- function requestedEntry(changes = {}) {
933
- let requested = requestedSelection();
934
- return entryFor(
935
- changes.screenId ?? requested.screenId,
936
- changes.variantId ?? requested.variantId,
937
- changes.frameId ?? requested.frameId
938
- );
939
- }
940
- function requestedScreen() {
941
- return requestedSelection().screenId;
942
- }
943
- function selectEntry(entry, { save = !0, reveal = !1, loaded = !1 } = {}) {
944
- if (!entry) return !1;
945
- if (stage.frameBudget && !loaded && (pendingScreen || !stage.getLoadedArtifactIds().includes(entry.artifactId))) {
946
- if (queuedSelection = null, pendingScreen?.entry.artifactId === entry.artifactId) return !0;
947
- clearFailedSelection();
948
- let request = ++screenRequest;
949
- pendingScreen = { entry }, root.dataset.designScreenLoading = "true";
950
- let ids = [...new Set([activeArtifactId, entry.artifactId].filter(Boolean))];
951
- return stage.ensureFrames(ids).then(() => {
952
- destroyed || request !== screenRequest || (pendingScreen = null, delete root.dataset.designScreenLoading, selectEntry(entry, { save, reveal, loaded: !0 }), updateFramePlaceholders());
953
- }).catch((error) => {
954
- destroyed || request !== screenRequest || error.name === "AbortError" || (pendingScreen = null, failedSelection = entry, delete root.dataset.designScreenLoading, notice(
955
- "This screen could not load. Select it again to retry; your review is preserved.",
956
- !0,
957
- `preview-load:${entry.artifactId}`
958
- ), render(), updateFramePlaceholders());
959
- }), !0;
960
- }
961
- clearFailedSelection();
962
- let sameFrame = entry.frameId === state.frameId && entry.variantId === state.variantId;
963
- return walkthroughTransition && state.view === "walkthrough" && sameFrame ? (queuedSelection = entry.artifactId === activeArtifactId ? null : { entry, settings: { save, reveal } }, q('[data-design-step-change="-1"]').disabled = requestedScreen() === design.screenOrder[0], q('[data-design-step-change="1"]').disabled = requestedScreen() === design.screenOrder.at(-1), !0) : (finishWalkthroughTransition(), state.view === "walkthrough" && sameFrame && readyReported && entry.artifactId !== activeArtifactId && !document.hidden && prepareWalkthroughTransition(entry), state.screenId = entry.screenId, state.frameId = entry.frameId, state.variantId = entry.variantId, activeArtifactId = entry.artifactId, stage.dispatch({ type: "set-active", artifactId: entry.artifactId }), render(), reveal && centerEntry(entry), save && (persist(), recordLocation()), !0);
964
- }
965
- function fit({ save = !0, selection = null, maxZoom = 1 } = {}) {
966
- if (state.inspectionScale = "fit", render(), state.view !== "canvas") {
967
- save && persist();
968
- return;
969
- }
970
- syncCanvasChrome();
971
- for (let attempt = 0; attempt < 12; attempt++) {
972
- let previousZoom = state.zoom;
973
- if (canvas.fit(selection ? [selection.artifactId, `label:${selection.artifactId}`] : "all", {
974
- padding: 36,
975
- maxZoom
976
- }), saveViewport(), renderCamera(), Math.abs(state.zoom - previousZoom) < 1e-6) break;
977
- }
978
- save && persist();
979
- }
980
- function zoomTo(value, point2 = null) {
981
- if (state.view !== "canvas") return;
982
- let rect2 = scroll.getBoundingClientRect();
983
- canvas.zoomAt(
984
- value / canvas.getCamera().zoom,
985
- point2 ? { x: point2.x - rect2.left, y: point2.y - rect2.top } : void 0
986
- ), saveViewport(), renderCamera(), persist();
987
- }
988
- async function exportArtifact(kind) {
989
- let artifactId = activeArtifactId;
990
- try {
991
- let blob;
992
- if (kind === "png") {
993
- let result = typeof options2.exportPng == "function" ? await options2.exportPng({ artifactId }) : await stage.getFrame(artifactId)?.__openPlanrBridge?.exportPng("screen"), dataUrl = typeof result == "string" ? result : result?.dataUrl;
994
- if (!dataUrl?.startsWith("data:image/png;base64,"))
995
- throw new Error(
996
- "PNG capture is unavailable. Open the local review with the artifact bridge and retry."
997
- );
998
- let bytes = Uint8Array.from(
999
- atob(dataUrl.split(",")[1]),
1000
- (character) => character.charCodeAt(0)
1001
- );
1002
- blob = new Blob([bytes], { type: "image/png" });
1003
- } else {
1004
- let result = typeof options2.exportHtml == "function" ? await options2.exportHtml({ artifactId }) : null;
1005
- if (result instanceof Blob) blob = result;
1006
- else if (typeof result == "string")
1007
- blob = new Blob([result], { type: "text/html;charset=utf-8" });
1008
- else
1009
- throw new Error(
1010
- "Portable export is unavailable in this viewer. Use the design export utility from the project."
1011
- );
1012
- }
1013
- let url = URL.createObjectURL(blob), anchor = document.createElement("a");
1014
- anchor.href = url, anchor.download = `${design.id}-${state.screenId}.${kind === "png" ? "png" : "html"}`, anchor.click(), setTimeout(() => URL.revokeObjectURL(url), 1e3), q(".design-export").open = !1, notice(kind === "png" ? "Screen PNG exported." : "Portable HTML exported.");
1015
- } catch (error) {
1016
- notice(error.message, !0);
1017
- }
1018
- }
1019
- function editable2(target) {
1020
- return !!target?.closest?.('input,textarea,select,[contenteditable="true"]');
1021
- }
1022
- function installEvents() {
1023
- if (listen(scroll, "focusin", (event) => {
1024
- event.target.closest("[data-design-note]") && event.stopImmediatePropagation();
1025
- }), listen(scroll, "keydown", (event) => {
1026
- if (state.view === "canvas") {
1027
- if (["Escape", " ", "Enter", "Home", "End"].includes(event.key) || event.code === "Space") {
1028
- if (event.stopImmediatePropagation(), event.key !== "Escape" || event.defaultPrevented || event.isComposing || editable2(event.target) || event.ctrlKey || event.metaKey || event.altKey)
1029
- return;
1030
- if (q(".planr-more-menu:not([hidden])")) {
1031
- q('[data-planr-action="more"]')?.click();
1032
- return;
1033
- }
1034
- if (!root.dispatchEvent(new CustomEvent("planr:design-escape", { cancelable: !0 })))
1035
- return;
1036
- stage.getState().railOpen && (stage.dispatch({ type: "set-rail-open", railOpen: !1 }), q('[data-planr-action="feedback"]')?.focus());
1037
- return;
1038
- }
1039
- canvas.handleKey(event) && event.stopPropagation();
1040
- }
1041
- }), listen(scroll, "gotpointercapture", (event) => {
1042
- canvasAttached && gesture?.pointerId !== event.pointerId && canvasPointers.add(event.pointerId);
1043
- }), listen(root, "planr:design-camera", scheduleViewContext), listen(root, "planr:design-inspection-change", (event) => {
1044
- let { screenId, frameId, variantId, planrId } = event.detail;
1045
- screenId !== state.screenId || frameId !== state.frameId || variantId !== state.variantId || (inspectedSelection = { artifactId: activeArtifactId, planrId }, scheduleViewContext());
1046
- }), listen(window, "message", (event) => {
1047
- if (event.origin !== "null" || !["openplanr:design-size", "openplanr:design-size-error"].includes(event.data?.type))
1048
- return;
1049
- let entry = entries.find(
1050
- ({ artifactId }) => stage.getFrame(artifactId)?.contentWindow === event.source
1051
- );
1052
- if (!entry) return;
1053
- let frame = design.frames.find(({ id }) => id === entry.frameId);
1054
- if (frame.height !== "auto") return;
1055
- if (event.data.type === "openplanr:design-size-error") {
1056
- notice(`Could not measure ${entry.screenId}: ${event.data.message}`, !0);
1057
- return;
1058
- }
1059
- let { screenId, width, height } = event.data;
1060
- if (screenId !== entry.screenId || width !== frame.width || !Number.isInteger(height) || height < 1 || height > 16384)
1061
- return;
1062
- let viewport = viewportFor(entry);
1063
- viewport.height !== height && (viewport.height = height, panels.get(entry.artifactId).style.setProperty("--planr-artifact-height", `${height}px`), render());
1064
- }), listen(root, "planr:artifact-viewport-zoom", (event) => {
1065
- if (state.view !== "canvas") return;
1066
- let entry = entries.find((item) => stage.getFrame(item.artifactId) === event.target);
1067
- if (!entry || panels.get(entry.artifactId)?.hidden) return;
1068
- let { x, y, deltaY } = event.detail, frame = design.frames.find((item) => item.id === entry.frameId), rect2 = event.target.getBoundingClientRect();
1069
- chrome?.update({ exportMenuOpen: !1 }), zoomTo(
1070
- canvas.getCamera().zoom * clamp2(Math.exp(-deltaY * 0.01), 0.8, 1.25),
1071
- {
1072
- x: rect2.left + x * rect2.width / frame.width,
1073
- y: rect2.top + y * rect2.height / viewportFor(entry).height
1074
- },
1075
- { scheduled: !0 }
1076
- );
1077
- }), listen(root, "planr:artifact-viewport-pan", (event) => {
1078
- if (state.view !== "canvas") return;
1079
- let entry = entries.find((item) => stage.getFrame(item.artifactId) === event.target);
1080
- !entry || panels.get(entry.artifactId)?.hidden || (chrome?.update({ exportMenuOpen: !1 }), canvas.panBy(event.detail.deltaX, event.detail.deltaY), saveViewport(), scheduleCamera(), persist());
1081
- }), listen(
1082
- root,
1083
- "click",
1084
- (event) => {
1085
- let button = event.target.closest('[data-planr-mode],[data-planr-action="add-comment"]');
1086
- !button || button.disabled || setTool(button.dataset.planrMode === "interact" ? "interact" : "annotate");
1087
- },
1088
- !0
1089
- ), listen(
1090
- document,
1091
- "keydown",
1092
- (event) => {
1093
- if (editable2(event.target) || event.altKey || event.ctrlKey || event.metaKey || document.querySelector("dialog[open],[role=dialog][data-state=open]"))
1094
- return;
1095
- let key = event.key.toLowerCase();
1096
- if (["i", "c", "h"].includes(key)) {
1097
- if (key === "h" && state.view !== "canvas") return;
1098
- event.preventDefault(), setTool({ i: "interact", c: "annotate", h: "pan" }[key]);
1099
- } else event.key === "Escape" && (panEnabled || spacePan || gesture || activeTool === "inspect") && !q("[data-design-notes][open]") && !q("[data-planr-annotation-composer]") && (event.preventDefault(), setTool("interact"), event.stopPropagation(), q('[data-planr-mode="interact"]').focus());
1100
- },
1101
- !0
1102
- ), typeof ResizeObserver == "function") {
1103
- let observer = new ResizeObserver(() => {
1104
- scrollSize = null, state.view !== "canvas" && root.dataset.designRestoring !== "true" && fit({ save: !1 }), syncCanvasChrome(), updateDesignNotes(), scheduleViewContext();
1105
- });
1106
- for (let selector of [
1107
- ".design-toolbar",
1108
- ".design-canvas-tools",
1109
- ".design-stage-context",
1110
- ".design-navigator",
1111
- ".planr-review-rail"
1112
- ])
1113
- observer.observe(q(selector));
1114
- observer.observe(scroll), cleanup.push(() => observer.disconnect());
1115
- }
1116
- let notes = q("[data-design-notes]");
1117
- listen(notes?.querySelector(":scope > summary"), "click", (event) => {
1118
- event.preventDefault(), notes.open ? closeDesignNotes() : (notesReturnFocus = event.currentTarget, notes.open = !0, updateDesignNotes());
1119
- }), listen(notes, "toggle", updateDesignNotes), listen(
1120
- document,
1121
- "pointerdown",
1122
- (event) => {
1123
- notes?.open && !notes.contains(event.target) && !event.target.closest?.("[data-design-note]") && closeDesignNotes();
1124
- },
1125
- !0
1126
- ), listen(
1127
- document,
1128
- "keydown",
1129
- (event) => {
1130
- event.key === "Escape" && notes?.open && (event.preventDefault(), event.stopPropagation(), closeDesignNotes({ restoreFocus: !0 }));
1131
- },
1132
- !0
1133
- ), listen(root, "click", (event) => {
1134
- let button = event.target.closest("button");
1135
- if (button)
1136
- if (button.dataset.designLoadFrame)
1137
- selectEntry(
1138
- entries.find((item) => item.artifactId === button.dataset.designLoadFrame),
1139
- { reveal: !0 }
1140
- );
1141
- else if (button.hasAttribute("data-design-actual-size"))
1142
- state.inspectionScale = "actual", render(), persist();
1143
- else if (button.hasAttribute("data-design-focus"))
1144
- state.navOpen = !1, state.reviewOpen = !1, stage.dispatch({ type: "set-rail-open", railOpen: !1 }), state.view === "canvas" && switchView("prototype"), render(), persist();
1145
- else if (button.dataset.designView)
1146
- switchView(button.dataset.designView);
1147
- else if (button.hasAttribute("data-design-toggle-nav"))
1148
- state.navOpen = !state.navOpen, !state.navOpen && button.closest(".design-navigator") && q(".design-toolbar [data-design-toggle-nav]").focus(), render(), persist();
1149
- else if (button.dataset.designScreen)
1150
- selectEntry(requestedEntry({ screenId: button.dataset.designScreen }), {
1151
- reveal: state.view === "canvas"
1152
- });
1153
- else if (button.dataset.designNote)
1154
- openDesignNote(button.dataset.designNote, button);
1155
- else if (button.hasAttribute("data-design-close-notes"))
1156
- closeDesignNotes({ restoreFocus: !0 });
1157
- else if (button.hasAttribute("data-design-fit")) fit();
1158
- else if (button.dataset.designZoom)
1159
- zoomTo(
1160
- button.dataset.designZoom === "reset" ? 1 : state.zoom * (button.dataset.designZoom === "in" ? 1.2 : 1 / 1.2)
1161
- );
1162
- else if (button.hasAttribute("data-design-pan")) {
1163
- if (state.view !== "canvas") return;
1164
- setTool(activeTool === "pan" ? "interact" : "pan");
1165
- } else if (button.dataset.designStepChange) {
1166
- let index2 = clamp2(
1167
- design.screenOrder.indexOf(requestedScreen()) + Number(button.dataset.designStepChange),
1168
- 0,
1169
- design.screenOrder.length - 1
1170
- );
1171
- selectEntry(requestedEntry({ screenId: design.screenOrder[index2] }));
1172
- } else if (button.dataset.designRating) {
1173
- let rating = Number(button.dataset.designRating);
1174
- state.ratings[state.variantId] = rating, rating <= 2 ? state.preferences.rejected = [
1175
- .../* @__PURE__ */ new Set([...state.preferences.rejected, state.variantId])
1176
- ] : state.preferences.rejected = state.preferences.rejected.filter(
1177
- (id) => id !== state.variantId
1178
- ), render(), persist({ content: !0 });
1179
- } else button.hasAttribute("data-design-select-direction") ? (state.selectedVariant = state.variantId, state.preferences.selected = [.../* @__PURE__ */ new Set([...state.preferences.selected, state.variantId])], state.preferences.rejected = state.preferences.rejected.filter(
1180
- (id) => id !== state.variantId
1181
- ), render(), persist({ content: !0 })) : button.hasAttribute("data-design-save-remix") ? (state.remix[state.variantId] = q("[data-design-remix]").value.trim(), persist({ content: !0 }), notice("Refinement note saved for the next design iteration.")) : button.dataset.designExport && exportArtifact(button.dataset.designExport);
1182
- }), listen(
1183
- q("[data-design-variant]"),
1184
- "change",
1185
- (event) => selectEntry(requestedEntry({ variantId: event.target.value }))
1186
- ), listen(q("[data-design-frame]"), "change", (event) => {
1187
- selectEntry(requestedEntry({ frameId: event.target.value }), {
1188
- reveal: state.view === "canvas"
1189
- });
1190
- }), listen(q("[data-design-compare]"), "change", (event) => {
1191
- state.compare = event.target.checked, render(), persist();
1192
- }), listen(root, "planr:stage-change", (event) => {
1193
- let next = event.detail;
1194
- !changingTool && next.reviewMode !== previousReviewMode && setTool(next.reviewMode === "comment" ? "annotate" : "interact");
1195
- let reviewChanged = typeof next.railOpen == "boolean" && next.railOpen !== state.reviewOpen;
1196
- reviewChanged && (state.reviewOpen = next.railOpen);
1197
- let entry = entries.find(({ artifactId }) => artifactId === next.activeArtifactId);
1198
- entry && entry.artifactId !== activeArtifactId && (stage.frameBudget && !stage.getLoadedArtifactIds().includes(entry.artifactId) ? selectEntry(entry, { save: !1 }) : (finishWalkthroughTransition(), activeArtifactId = entry.artifactId, state.screenId = entry.screenId, state.frameId = entry.frameId, state.variantId = entry.variantId)), next.zoom !== previousStageZoom && (state.zoom = clamp2(next.zoom / 100, 0.05, 2), canvasAttached && applyCanvasCamera(), previousStageZoom = next.zoom, saveViewport()), render(), reviewChanged && persist();
1199
- }), listen(root, "planr:artifact-review-change", (event) => {
1200
- latestReview = clone(event.detail), reviewDirty = !0, scheduleViewContext(), reviewSerial += 1, status("Saving comments", "saving"), storeReviewDraft(), clearTimeout(reviewTimer), reviewTimer = setTimeout(flushReview, 180);
1201
- }), listen(
1202
- root,
1203
- "pointerdown",
1204
- (event) => {
1205
- let panel = event.target.closest(".planr-artifact-panel");
1206
- event.button === 0 && panel && !panEnabled && !spacePan && !event.target.closest("[data-design-note]") && selectEntry(
1207
- entries.find(({ artifactId }) => artifactId === panel.dataset.artifactId),
1208
- { save: !1 }
1209
- );
1210
- },
1211
- !0
1212
- ), listen(scroll, "pointerdown", (event) => {
1213
- if (state.view !== "canvas" || root.dataset.designInspect === "true" || event.button !== 0 && event.button !== 1) return;
1214
- let label = event.target.closest("[data-design-drag]");
1215
- if (!(event.button === 0 && state.view === "canvas" && label && !panEnabled && !spacePan)) return;
1216
- event.preventDefault();
1217
- let panel = label?.closest(".planr-artifact-panel"), entry = entries.find((item) => item.artifactId === panel.dataset.artifactId), bounds = placedBoardBounds(entry);
1218
- bounds && (gesture = {
1219
- pointerId: event.pointerId,
1220
- x: event.clientX,
1221
- y: event.clientY,
1222
- mode: "artboard",
1223
- artifactId: panel.dataset.artifactId,
1224
- left: bounds.x,
1225
- top: bounds.y,
1226
- before: clone(layout)
1227
- }, scroll.setPointerCapture?.(event.pointerId), updatePan());
1228
- }), listen(scroll, "pointermove", (event) => {
1229
- if (!gesture || gesture.pointerId !== event.pointerId) return;
1230
- let dx = event.clientX - gesture.x, dy = event.clientY - gesture.y, entry = entries.find((item) => item.artifactId === gesture.artifactId), key = boardKey(entry), point2 = {
1231
- x: Math.round(clamp2(gesture.left + dx / state.zoom, -1e7, 1e7)),
1232
- y: Math.round(clamp2(gesture.top + dy / state.zoom, -1e7, 1e7))
1233
- };
1234
- layout.boards = { ...layout.boards, [key]: { ...layout.boards?.[key], ...point2 } };
1235
- let panel = panels.get(gesture.artifactId);
1236
- layoutDragDirty = point2.x !== gesture.left || point2.y !== gesture.top, layoutDragDirty && status("Moving board", "saving"), panel.style.left = `${point2.x}px`, panel.style.top = `${point2.y}px`, syncCanvasNodes(), scheduleCamera();
1237
- });
1238
- for (let eventName of ["pointerup", "pointercancel", "lostpointercapture"])
1239
- listen(scroll, eventName, (event) => {
1240
- canvasPointers.delete(event.pointerId), !(!gesture || gesture.pointerId !== event.pointerId) && (eventName === "pointerup" ? finishGesture() : releaseTemporaryPan());
1241
- });
1242
- listen(
1243
- document,
1244
- "keydown",
1245
- (event) => {
1246
- if (!editable2(event.target) && state.view === "canvas" && event.code === "Space" && !event.defaultPrevented && !event.ctrlKey && !event.metaKey && !event.altKey && !document.querySelector("dialog[open],[role=dialog][data-state=open]") && !event.target.closest("button,[data-planr-annotation-layer]")) {
1247
- if (event.preventDefault(), event.stopPropagation(), event.repeat) return;
1248
- let previous = activeTool;
1249
- setTool("pan"), panEnabled = !1, spacePan = !0, spaceReturnTool = previous, updatePan();
1250
- }
1251
- },
1252
- !0
1253
- ), listen(document, "keydown", (event) => {
1254
- if (editable2(event.target)) return;
1255
- if (state.view === "canvas" && !event.defaultPrevented && !event.altKey && (event.metaKey || event.ctrlKey) && event.key.toLowerCase() === "z" && !document.querySelector("dialog[open],[role=dialog][data-state=open]")) {
1256
- event.preventDefault(), restoreMove(event.shiftKey);
1257
- return;
1258
- }
1259
- let label = event.target.closest("[data-design-drag]");
1260
- if (label && state.view === "canvas" && ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"].includes(event.key)) {
1261
- event.preventDefault();
1262
- let panel = label.closest(".planr-artifact-panel"), distance = event.shiftKey ? 40 : 8, entry = entries.find((item) => item.artifactId === panel.dataset.artifactId), bounds = placedBoardBounds(entry);
1263
- if (!bounds) return;
1264
- let key = boardKey(entry), before = clone(layout), point2 = {
1265
- x: Math.round(
1266
- clamp2(
1267
- bounds.x + (event.key === "ArrowRight" ? distance : event.key === "ArrowLeft" ? -distance : 0),
1268
- -1e7,
1269
- 1e7
1270
- )
1271
- ),
1272
- y: Math.round(
1273
- clamp2(
1274
- bounds.y + (event.key === "ArrowDown" ? distance : event.key === "ArrowUp" ? -distance : 0),
1275
- -1e7,
1276
- 1e7
1277
- )
1278
- )
1279
- };
1280
- layout.boards = { ...layout.boards, [key]: { ...layout.boards?.[key], ...point2 } }, render(), completeMove(entry, before);
1281
- } else if (state.view === "walkthrough" && ["ArrowLeft", "ArrowRight"].includes(event.key) && !event.target.closest('button,[role="radio"]')) {
1282
- event.preventDefault();
1283
- let index2 = clamp2(
1284
- design.screenOrder.indexOf(requestedScreen()) + (event.key === "ArrowRight" ? 1 : -1),
1285
- 0,
1286
- design.screenOrder.length - 1
1287
- );
1288
- selectEntry(requestedEntry({ screenId: design.screenOrder[index2] }));
1289
- }
1290
- }), listen(document, "keyup", (event) => {
1291
- event.code === "Space" && releaseTemporaryPan();
1292
- }), listen(window, "blur", () => {
1293
- releaseTemporaryPan(), document.activeElement?.tagName === "IFRAME" && closeDesignNotes();
1294
- }), listen(document, "visibilitychange", () => {
1295
- document.hidden && (releaseTemporaryPan(), finishWalkthroughTransition());
1296
- }), listen(
1297
- window.matchMedia?.("(prefers-reduced-motion: reduce)"),
1298
- "change",
1299
- () => finishWalkthroughTransition()
1300
- ), listen(window, "resize", () => {
1301
- let compact = window.innerWidth <= 960;
1302
- compact && !compactViewport && (state.navOpen = !1, state.reviewOpen = !1, stage.dispatch({ type: "set-rail-open", railOpen: !1 }), persist()), compactViewport = compact, render(), state.view !== "canvas" && root.dataset.designRestoring !== "true" && fit({ save: !1 }), updateDesignNotes();
1303
- }), listen(window, "online", () => {
1304
- (dirty || reviewDirty || layoutOperations.length) && flush(), viewContextSignature = null, scheduleViewContext();
1305
- }), listen(window, "beforeunload", (event) => {
1306
- clearTimeout(frameDemandTimer), frameDemandGeneration += 1, frameDemandKey = "", storeDraft(), storeReviewDraft(), (contentDirty || reviewDirty || layoutOperations.length) && (options2.stateUrl || options2.saveState || options2.layoutUrl || options2.saveLayout || reviewUrl()) && (event.preventDefault(), event.returnValue = "");
1307
- }), listen(window, "message", (event) => {
1308
- if (event.origin !== "null" || !["openplanr:design-navigate", "navigate"].includes(event.data?.type) || typeof event.data.screenId != "string")
1309
- return;
1310
- let source = entries.find(
1311
- ({ artifactId }) => stage.getFrame(artifactId)?.contentWindow === event.source
1312
- );
1313
- if (!source || !design.screenOrder.includes(event.data.screenId)) return;
1314
- let nonce = stage.getFrame(source.artifactId)?.__openPlanrBridge?.getPrototypeNonce?.();
1315
- nonce && (event.data.type === "navigate" && (event.data.channel !== nonce || event.data.viewId !== source.artifactId || event.data.schemaVersion !== "1.0.0") || state.view !== "canvas" && (source.artifactId !== activeArtifactId || walkthroughTransition) || (chrome?.update({ exportMenuOpen: !1 }), selectEntry(entryFor(event.data.screenId, source.variantId, source.frameId))));
1316
- });
1317
- }
1318
- async function refreshSavedState() {
1319
- if (options2.stateUrl)
1320
- try {
1321
- let observedRevision = revision, result = await jsonRequest(options2.stateUrl);
1322
- if (destroyed) return;
1323
- observedRevision === revision && result.revision !== void 0 && result.revision !== revision && await rebaseLayout({ announce: !1, expectedRevision: observedRevision }), result.stateVersion !== void 0 && (stateVersion = result.stateVersion), legacyServerPositions = result.state?.positions ?? legacyServerPositions, result.state && !dirty && (state = normalizeState({ ...result.state, ...linkedState() }), canvasAttached && state.view === "canvas" && applyCanvasCamera(), compactViewport && (state.navOpen = !1, state.reviewOpen = !1), stage.dispatch({ type: "set-rail-open", railOpen: state.reviewOpen })), savedDraft?.unsaved && notice(
1324
- "A previous unsaved draft is available in this browser. The saved review is shown; your draft has not overwritten it.",
1325
- !0
1326
- ), selectEntry(entryFor(), { save: !1 }), layoutOperations.length || status("All changes saved");
1327
- } catch {
1328
- status("Disconnected · local draft", "disconnected");
1329
- }
1330
- }
1331
- function renderVerification(verification) {
1332
- q("[data-design-verification]").textContent = verification === "verified" ? "Browser inspection complete" : verification === "failed" ? "Browser inspection failed" : "Browser inspection pending";
1333
- }
1334
- async function pollRevision() {
1335
- if (!(!options2.statusUrl || destroyed || sessionLost)) {
1336
- try {
1337
- let observedRevision = revision, result = await jsonRequest(options2.statusUrl);
1338
- if (destroyed) return;
1339
- if (typeof result.verification == "string" && renderVerification(result.verification), observedRevision === revision && result.revision !== void 0 && revision !== null && result.revision !== revision)
1340
- if (contentDirty || reviewDirty || layoutOperations.length || layoutSaving)
1341
- newRevisionNotice();
1342
- else {
1343
- storeDraft(), window.location.reload();
1344
- return;
1345
- }
1346
- result.status === "failed" && notice(
1347
- result.message ?? "The new revision failed. This working design remains available.",
1348
- !0
1349
- );
1350
- } catch (error) {
1351
- error.statusCode === 404 ? studioRestarted() : !dirty && !hasPendingLayout() && status("Disconnected", "disconnected");
1352
- }
1353
- pollTimer = setTimeout(pollRevision, 4e3);
1354
- }
1355
- }
1356
- async function reportReady() {
1357
- if (!(!startupSettled || readyReported || readyReporting || destroyed)) {
1358
- readyReporting = !0;
1359
- try {
1360
- let requiredEntries = [entryFor()];
1361
- if (await stage.ensureFrames(requiredEntries.map((entry) => entry.artifactId)), destroyed) return;
1362
- let loaded = requiredEntries.filter(({ artifactId }) => {
1363
- let frame = stage.getFrame(artifactId);
1364
- return (frame?.src?.startsWith("blob:") || !!frame?.srcdoc) && frame.dataset.planrFrameState === "ready" && frame.dataset.planrArtifactDigest && (!frame.__openPlanrBridge || frame.dataset.planrBridgeTrusted === "true");
1365
- });
1366
- if (loaded.length !== requiredEntries.length) throw new Error("Preview bridge is not ready.");
1367
- if (readyReported = !0, render(), await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve))), destroyed) return;
1368
- root.dataset.designReady = "true", root.dataset.sharedOpening || delete document.documentElement.dataset.designOpening, chrome?.update({ previewLabel: "Preview ready" }), chrome || (q("[data-design-preview-state]").textContent = "Preview ready"), !contentDirty && !reviewDirty && !layoutOperations.length && (!options2.stateUrl || stateVersion !== null) && status(options2.stateUrl ? "All changes saved" : "Local preview");
1369
- let detail = {
1370
- revision,
1371
- status: "ready",
1372
- artifacts: loaded.map((entry) => entry.artifactId)
1373
- };
1374
- if (root.dispatchEvent(new CustomEvent("planr:design-ready", { bubbles: !0, detail })), typeof options2.onReady == "function" && await options2.onReady(detail), options2.readyUrl)
1375
- try {
1376
- await jsonRequest(options2.readyUrl, {
1377
- method: "POST",
1378
- headers: { "Content-Type": "application/json" },
1379
- body: JSON.stringify(detail)
1380
- });
1381
- } catch {
1382
- status("Server disconnected · local draft", "disconnected");
1383
- }
1384
- } catch {
1385
- if (destroyed) return;
1386
- delete document.documentElement.dataset.designOpening, chrome?.update({ previewLabel: "Preview unavailable" }), chrome || (q("[data-design-preview-state]").textContent = "Preview unavailable"), notice(
1387
- "This preview could not load. Use Retry screen; your saved feedback remains available.",
1388
- !0
1389
- );
1390
- } finally {
1391
- readyReporting = !1;
1392
- }
1393
- }
1394
- }
1395
- function mount() {
1396
- if (stage = artifactStage, !stage)
1397
- return status("Review runtime unavailable", "failed"), null;
1398
- root = q(".planr-shell");
1399
- let structuralStyle = document.createElement("style");
1400
- structuralStyle.textContent = styles_default, document.head.prepend(structuralStyle), cleanup.push(() => structuralStyle.remove()), cleanup.push(
1401
- canvas.on("camera", () => {
1402
- if (!canvasAttached || state.view !== "canvas") return;
1403
- let previous = state.viewports.canvas;
1404
- saveViewport(), renderCamera();
1405
- let next = state.viewports.canvas;
1406
- (previous?.x !== next.x || previous?.y !== next.y || previous?.zoom !== next.zoom) && persist();
1407
- })
1408
- ), chrome = mountDesignChrome({ root, title: design.title, state }), hasPendingLayout() && status("Recovering layout", "saving"), chrome && cleanup.push(() => chrome.destroy()), previousReviewMode = stage.getState().reviewMode, activeTool = previousReviewMode === "comment" ? "annotate" : "interact", scroll = q(".planr-stage-scroll"), surface = q(".planr-stage-surface"), grid = q(".planr-frame-grid"), selectionOutline = document.createElement("div"), selectionOutline.className = "design-selection-outline", selectionOutline.setAttribute("aria-hidden", "true"), selectionOutline.hidden = !0, scroll.append(selectionOutline);
1409
- for (let section of layout.sections ?? []) {
1410
- let heading = document.createElement("div");
1411
- heading.className = "design-section-heading", heading.setAttribute("role", "heading"), heading.setAttribute("aria-level", "2"), heading.textContent = section.text, heading.style.left = `${section.x}px`, heading.style.top = `${section.y}px`, section.maxW && (heading.style.maxWidth = `${section.maxW}px`), grid.append(heading), sectionHeadings.push(heading);
1412
- }
1413
- for (let entry of entries) {
1414
- let panel = stage.getPanel(entry.artifactId);
1415
- if (!panel)
1416
- return status("Missing design preview", "failed"), null;
1417
- panels.set(entry.artifactId, panel);
1418
- let nodeId = panel.getAttribute("data-canvas-node-id");
1419
- panel.dataset.canvasNodeId = entry.artifactId, cleanup.push(() => {
1420
- nodeId === null ? panel.removeAttribute("data-canvas-node-id") : panel.setAttribute("data-canvas-node-id", nodeId);
1421
- });
1422
- let screen = design.screens.find(({ id }) => id === entry.screenId), variant = design.variants.find(({ id }) => id === entry.variantId), frame = design.frames.find(({ id }) => id === entry.frameId), iframe = stage.getFrame(entry.artifactId), syncGestures = () => syncFrameGestures(iframe, panel);
1423
- if (listen(iframe, "planr:artifact-bridge-ready", syncGestures), listen(iframe, "load", syncGestures), frame.height === "auto") {
1424
- let measure = () => iframe.contentWindow?.postMessage({ type: "openplanr:design-measure" }, "*");
1425
- listen(iframe, "planr:artifact-bridge-ready", measure), listen(iframe, "load", measure), measure();
1426
- }
1427
- let label = document.createElement("div");
1428
- label.className = "design-artboard-label", label.setAttribute("role", "group");
1429
- let drag = document.createElement("button");
1430
- drag.type = "button", drag.className = "design-artboard-drag", drag.dataset.designDrag = entry.artifactId, drag.setAttribute(
1431
- "aria-label",
1432
- `Move ${screen.title}, ${variant.label}, ${frame.label}. Use arrow keys to arrange.`
1433
- );
1434
- let title = document.createElement("strong");
1435
- title.textContent = `${screen.title}${readyVariants.length > 1 ? ` / ${variant.label}` : ""}`;
1436
- let size4 = document.createElement("span");
1437
- if (size4.textContent = designFrameLabel(frame), drag.append(title, size4), label.append(drag), screen.description) {
1438
- let note = document.createElement("button");
1439
- note.type = "button", note.className = "design-artboard-note", note.dataset.designNote = screen.id, note.setAttribute("aria-controls", "design-guidance-panel"), note.setAttribute("aria-expanded", "false"), note.title = screen.description, note.setAttribute("aria-label", `Open design notes for ${screen.title}`), note.textContent = "i", label.append(note);
1440
- }
1441
- if (panel.prepend(label), stage.frameBudget) {
1442
- let load = document.createElement("button");
1443
- load.type = "button", load.className = "design-frame-placeholder", load.dataset.designLoadFrame = entry.artifactId, load.setAttribute("aria-label", `Open screen: ${screen.title}, ${frame.label}`), load.textContent = "Open screen", panel.querySelector(".planr-frame").append(load);
1444
- }
1445
- }
1446
- renderVerification(payload.verification?.status);
1447
- let prototypeState = createPrototypeStateRelay({
1448
- contextId: `${design.id}:${payload.revision ?? payload.reviewOf ?? "local"}`,
1449
- parentWindow: window,
1450
- frames: () => entries.map((entry) => ({
1451
- screenId: entry.screenId,
1452
- viewId: entry.artifactId,
1453
- window: stage.getFrame(entry.artifactId)?.contentWindow ?? null,
1454
- nonce: stage.getFrame(entry.artifactId)?.__openPlanrBridge?.getPrototypeNonce?.() ?? null,
1455
- generation: stage.getFrame(entry.artifactId)?.__openPlanrBridge?.getPrototypeGeneration?.(),
1456
- aliases: options2.prototypeStateAliases?.[entry.screenId]
1457
- }))
1458
- });
1459
- cleanup.push(() => prototypeState.dispose()), installEvents(), listen(q("[data-design-dismiss-notice]"), "click", () => {
1460
- activeNotice?.persistent && dismissedNotices.set(activeNotice.key, activeNotice.message), hideNotice();
1461
- });
1462
- function previewHealth() {
1463
- for (let entry of entries) {
1464
- let frame = stage.getFrame(entry.artifactId), nonce = frame?.__openPlanrBridge?.getPrototypeNonce?.() ?? null;
1465
- nonce && prototypeState.restore({
1466
- screenId: entry.screenId,
1467
- viewId: entry.artifactId,
1468
- window: frame.contentWindow,
1469
- nonce,
1470
- generation: frame.__openPlanrBridge?.getPrototypeGeneration?.(),
1471
- aliases: options2.prototypeStateAliases?.[entry.screenId]
1472
- });
1473
- }
1474
- let selected = stage.getFrameDiagnostics?.().find((item) => item.artifactId === activeArtifactId), node = q("[data-design-preview-state]"), phase = selected?.status ?? stage.getState().status, previewLabel = phase === "ready" ? "Preview ready" : phase === "error" || phase === "invalid" ? "Preview unavailable" : "Loading preview";
1475
- chrome ? chrome.update({ previewLabel }) : node.textContent = previewLabel, node.dataset.status = phase, selected && (node.title = `${selected.phase} · ${Math.round(selected.elapsedMs ?? 0)} ms${selected.code ? ` · ${selected.code}` : ""}`), !readyReported && phase === "ready" && reportReady();
1476
- }
1477
- listen(root, "planr:artifact-frame-state", previewHealth), listen(root, "planr:artifact-state", previewHealth), previewHealth();
1478
- let search = q("[data-design-screen-search]"), group = q("[data-design-screen-group]");
1479
- function filterScreens() {
1480
- let term = search.value.trim().toLocaleLowerCase(), flow = design.flows?.find((item) => item.id === group?.value), count3 = 0;
1481
- for (let button of qa("[data-design-screen]"))
1482
- button.hidden = !(button.textContent.toLocaleLowerCase().includes(term) && (!flow || flow.screens.includes(button.dataset.designScreen))), button.hidden || count3++;
1483
- q("[data-design-search-empty]").hidden = count3 > 0;
1484
- }
1485
- listen(search, "input", filterScreens), listen(group, "change", filterScreens);
1486
- function followLocation() {
1487
- let next = normalizeState({ ...state, ...linkedState() });
1488
- next.view !== state.view && switchView(next.view, { save: !1 }), selectEntry(entryFor(next.screenId, next.variantId, next.frameId), { save: !1 });
1489
- }
1490
- if (listen(window, "popstate", followLocation), listen(window, "hashchange", followLocation), stage.frameBudget && (listen(root, "planr:artifact-frame-state", updateFramePlaceholders), updateFramePlaceholders()), compactViewport = window.innerWidth <= 960, compactViewport ? (state.navOpen = !1, state.reviewOpen = !1, stage.dispatch({ type: "set-rail-open", railOpen: !1 })) : stage.dispatch({ type: "set-rail-open", railOpen: state.reviewOpen }), selectEntry(entryFor(), { save: !1 }), !reviewUrl() && !stage.review.getState().review)
1491
- try {
1492
- let storedReview = JSON.parse(localStorage.getItem(`${storageKey}.review`) ?? "null");
1493
- storedReview?.review && stage.review.replaceReview(storedReview.review);
1494
- } catch {
1495
- }
1496
- let panelDialogs = mountDesignPanels({
1497
- root,
1498
- closePanel(side) {
1499
- side === "left" ? state.navOpen = !1 : (state.reviewOpen = !1, stage.dispatch({ type: "set-rail-open", railOpen: !1 })), render(), persist(), q(
1500
- side === "left" ? ".design-toolbar [data-design-toggle-nav]" : ".design-toolbar [data-planr-action=feedback]"
1501
- )?.focus();
1502
- }
1503
- });
1504
- cleanup.push(() => panelDialogs.destroy());
1505
- let controller = Object.freeze({
1506
- setTool,
1507
- getTool: () => activeTool,
1508
- getState: () => (readCanvasCamera(), clone(state)),
1509
- getLayout: () => clone(layout),
1510
- getViewport: (artifactId) => ({
1511
- ...viewportFor(entries.find((entry) => entry.artifactId === artifactId))
1512
- }),
1513
- getRevision: () => revision,
1514
- getSaveState: () => ({
1515
- dirty: contentDirty || reviewDirty || hasPendingLayout(),
1516
- personalPending: dirty && !contentDirty,
1517
- commentsPending: reviewDirty,
1518
- revision,
1519
- stateVersion
1520
- }),
1521
- selectScreen: (screenId) => selectEntry(requestedEntry({ screenId })),
1522
- selectEntry: (entry) => selectEntry(entry),
1523
- fitSelection: ({ save = !0 } = {}) => fit({ selection: entryFor(), save }),
1524
- setCamera(camera) {
1525
- state.view === "canvas" && (!Number.isFinite(camera?.x) || !Number.isFinite(camera?.y) || (state.camera = { x: clamp2(camera.x, -1e7, 1e7), y: clamp2(camera.y, -1e7, 1e7) }, Number.isFinite(camera.zoom) && (state.zoom = clamp2(camera.zoom, 0.05, 2)), applyCanvasCamera(), saveViewport(), renderCamera(), persist()));
1526
- },
1527
- setPanels({ navOpen = state.navOpen, reviewOpen = state.reviewOpen }, { save = !0 } = {}) {
1528
- state.navOpen = !!navOpen, state.reviewOpen = !!reviewOpen, stage.dispatch({ type: "set-rail-open", railOpen: state.reviewOpen }), render(), save && persist();
1529
- },
1530
- restorePresentation(snapshot) {
1531
- finishWalkthroughTransition();
1532
- let personal = {};
1533
- for (let key of [
1534
- "view",
1535
- "screenId",
1536
- "frameId",
1537
- "variantId",
1538
- "compare",
1539
- "navOpen",
1540
- "reviewOpen",
1541
- "inspectionScale",
1542
- "zoom",
1543
- "camera",
1544
- "viewports"
1545
- ])
1546
- snapshot[key] !== void 0 && (personal[key] = clone(snapshot[key]));
1547
- state = normalizeState({ ...state, ...personal }), canvasAttached && state.view === "canvas" && applyCanvasCamera(), stage.dispatch({ type: "set-rail-open", railOpen: state.reviewOpen }), selectEntry(entryFor(), { save: !1 }), render(), persist();
1548
- },
1549
- setView(view) {
1550
- switchView(view);
1551
- },
1552
- fit,
1553
- flush,
1554
- exportArtifact,
1555
- destroy() {
1556
- if (!destroyed) {
1557
- finishWalkthroughTransition(), root.dispatchEvent(new CustomEvent("planr:design-destroy"));
1558
- for (let { artifactId } of entries)
1559
- stage.getFrame(artifactId)?.__openPlanrBridge?.setViewportGestures?.(!1);
1560
- destroyed = !0, canvasAttached = !1, canvas.destroy(), ++screenRequest, pendingScreen = null, failedSelection = null, clearTimeout(frameDemandTimer), clearTimeout(saveTimer), clearTimeout(reviewTimer), clearTimeout(pollTimer), clearTimeout(noticeTimer), clearTimeout(viewContextTimer), cameraFrame !== null && cancelAnimationFrame(cameraFrame);
1561
- for (let heading of sectionHeadings) heading.remove();
1562
- selectionOutline?.remove();
1563
- for (let remove of cleanup.splice(0)) remove();
1564
- }
1565
- }
1566
- });
1567
- return refreshSavedState().then(async () => (restorePendingLayout(), migrateLegacyPositions(), await flushLayout(), startupSettled = !0, reportReady())), pollTimer = setTimeout(pollRevision, 4e3), controller;
1568
- }
1569
- return mount();
1570
- }
1571
-
1572
- // lib/design/ui/studio-runtime.mjs
1573
- var PAYLOAD_ID = "planr-design-studio-payload", STAGE_TIMEOUT_MS = 15e3;
1574
- function documentReady() {
1575
- return document.readyState !== "loading" ? Promise.resolve() : new Promise((resolve) => {
1576
- document.addEventListener("DOMContentLoaded", resolve, { once: !0 });
1577
- });
1578
- }
1579
- function stageBefore(deadline) {
1580
- let timer, timeout = new Promise((resolve) => {
1581
- timer = setTimeout(resolve, Math.max(0, deadline - Date.now()), null);
1582
- });
1583
- return Promise.race([whenArtifactStage(window), timeout]).finally(() => clearTimeout(timer));
1584
- }
1585
- async function start(payloadNode2, payload, deadline) {
1586
- let current = () => document.getElementById(PAYLOAD_ID) === payloadNode2;
1587
- if (await documentReady(), !current()) return;
1588
- let stage = await stageBefore(deadline);
1589
- if (!current()) return;
1590
- let studio = mountDesignStudio({ payload, stage });
1591
- if (!studio) return;
1592
- window.__openPlanrDesignStudio = studio;
1593
- let { experience, handoffCenter } = mountDesignEnhancements({ payload, studio, stage });
1594
- window.__openPlanrDesignExperience = experience, handoffCenter && (window.__openPlanrDesignHandoffCenter = handoffCenter);
1595
- }
1596
- var script = document.currentScript, payloadNode = document.getElementById(PAYLOAD_ID);
1597
- (!script || script.isConnected) && payloadNode && start(payloadNode, JSON.parse(payloadNode.textContent), Date.now() + STAGE_TIMEOUT_MS);