@ggraphic/editor 0.0.0-stage → 0.1.0-alpha.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 (843) hide show
  1. package/LICENSE +373 -0
  2. package/NOTICE +2 -0
  3. package/README.md +8 -2
  4. package/THIRD_PARTY_NOTICES +7 -0
  5. package/dist/CanvasEditorProvider.d.ts +214 -0
  6. package/dist/CanvasEditorProvider.js +10 -0
  7. package/dist/ai/applyOperation.d.ts +75 -0
  8. package/dist/ai/applyOperation.js +354 -0
  9. package/dist/ai/describeCanvasElements.d.ts +17 -0
  10. package/dist/ai/describeCanvasElements.js +148 -0
  11. package/dist/ai/illustrationCapability.d.ts +6 -0
  12. package/dist/ai/illustrationCapability.js +20 -0
  13. package/dist/ai/types.d.ts +91 -0
  14. package/dist/ai/types.js +1 -0
  15. package/dist/blocks/liftedBlock.d.ts +61 -0
  16. package/dist/blocks/liftedBlock.js +117 -0
  17. package/dist/brand/bindPick.d.ts +18 -0
  18. package/dist/brand/bindPick.js +28 -0
  19. package/dist/brand/bindableFields.d.ts +9 -0
  20. package/dist/brand/bindableFields.js +61 -0
  21. package/dist/brand/brandRegistry.d.ts +26 -0
  22. package/dist/brand/brandRegistry.js +56 -0
  23. package/dist/brand/composerBrand.d.ts +146 -0
  24. package/dist/brand/composerBrand.js +6 -0
  25. package/dist/brand/documentBrand.d.ts +16 -0
  26. package/dist/brand/documentBrand.js +6 -0
  27. package/dist/collab/documentVersion.d.ts +36 -0
  28. package/dist/collab/documentVersion.js +139 -0
  29. package/dist/collab/pageElementStateKeys.d.ts +33 -0
  30. package/dist/collab/pageElementStateKeys.js +148 -0
  31. package/dist/collab/pagesDoc.d.ts +152 -0
  32. package/dist/collab/pagesDoc.js +434 -0
  33. package/dist/collab/useAwarenessState.d.ts +12 -0
  34. package/dist/collab/useAwarenessState.js +47 -0
  35. package/dist/collab/useEmitHostStateChanges.d.ts +18 -0
  36. package/dist/collab/useEmitHostStateChanges.js +40 -0
  37. package/dist/collab/useSelectionAwareness.d.ts +22 -0
  38. package/dist/collab/useSelectionAwareness.js +60 -0
  39. package/dist/collab/useYjsCanvasBinding.d.ts +7 -0
  40. package/dist/collab/useYjsCanvasBinding.js +21 -0
  41. package/dist/collab/useYjsPageStateSync.d.ts +20 -0
  42. package/dist/collab/useYjsPageStateSync.js +49 -0
  43. package/dist/collab/useYjsPages.d.ts +73 -0
  44. package/dist/collab/useYjsPages.js +396 -0
  45. package/dist/collab/wrapCallbacksWithPageSync.d.ts +3 -0
  46. package/dist/collab/wrapCallbacksWithPageSync.js +62 -0
  47. package/dist/collab/ydocKeys.d.ts +50 -0
  48. package/dist/collab/ydocKeys.js +50 -0
  49. package/dist/collab/yjsBinding.d.ts +27 -0
  50. package/dist/collab/yjsBinding.js +105 -0
  51. package/dist/common/Lightbox.d.ts +8 -0
  52. package/dist/common/Lightbox.js +8 -0
  53. package/dist/common/imageSourceTypes.d.ts +1 -0
  54. package/dist/common/imageSourceTypes.js +1 -0
  55. package/dist/components/AddPageButton.d.ts +13 -0
  56. package/dist/components/AddPageButton.js +13 -0
  57. package/dist/components/CanvasAnnouncer.d.ts +8 -0
  58. package/dist/components/CanvasAnnouncer.js +10 -0
  59. package/dist/components/CanvasContextMenu/CanvasActionSheet.d.ts +12 -0
  60. package/dist/components/CanvasContextMenu/CanvasActionSheet.js +145 -0
  61. package/dist/components/CanvasContextMenu/CanvasContextMenu.d.ts +33 -0
  62. package/dist/components/CanvasContextMenu/CanvasContextMenu.js +107 -0
  63. package/dist/components/CanvasContextMenu/canvasMenuModel.d.ts +68 -0
  64. package/dist/components/CanvasContextMenu/canvasMenuModel.js +203 -0
  65. package/dist/components/CanvasEditor/CanvasEditorShell.d.ts +32 -0
  66. package/dist/components/CanvasEditor/CanvasEditorShell.js +1144 -0
  67. package/dist/components/CanvasEditor/PageWrapper.d.ts +7 -0
  68. package/dist/components/CanvasEditor/PageWrapper.js +103 -0
  69. package/dist/components/CanvasEditor/autoSwitchTab.d.ts +11 -0
  70. package/dist/components/CanvasEditor/autoSwitchTab.js +15 -0
  71. package/dist/components/CanvasEditor/blockInsertContext.d.ts +22 -0
  72. package/dist/components/CanvasEditor/blockInsertContext.js +5 -0
  73. package/dist/components/CanvasEditor/editorShell.d.ts +99 -0
  74. package/dist/components/CanvasEditor/editorShell.js +20 -0
  75. package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.d.ts +32 -0
  76. package/dist/components/CanvasEditor/hooks/useCanvasContextMenu.js +140 -0
  77. package/dist/components/CanvasEditor/hooks/useLoadedConfigs.d.ts +13 -0
  78. package/dist/components/CanvasEditor/hooks/useLoadedConfigs.js +29 -0
  79. package/dist/components/CanvasEditor/hooks/useMobileSheetFit.d.ts +14 -0
  80. package/dist/components/CanvasEditor/hooks/useMobileSheetFit.js +56 -0
  81. package/dist/components/CanvasEditor/hooks/usePageRefs.d.ts +18 -0
  82. package/dist/components/CanvasEditor/hooks/usePageRefs.js +36 -0
  83. package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.d.ts +25 -0
  84. package/dist/components/CanvasEditor/hooks/usePageUndoRedoShortcuts.js +49 -0
  85. package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.d.ts +17 -0
  86. package/dist/components/CanvasEditor/hooks/usePrintImpressumGate.js +70 -0
  87. package/dist/components/CanvasEditor/hooks/useScrollToAddedPage.d.ts +17 -0
  88. package/dist/components/CanvasEditor/hooks/useScrollToAddedPage.js +31 -0
  89. package/dist/components/CanvasEditor/hooks/useToolbarHandlers.d.ts +75 -0
  90. package/dist/components/CanvasEditor/hooks/useToolbarHandlers.js +69 -0
  91. package/dist/components/CanvasEditor/hooks/useWorkAreaDeselect.d.ts +6 -0
  92. package/dist/components/CanvasEditor/hooks/useWorkAreaDeselect.js +56 -0
  93. package/dist/components/CanvasEditor/layersTab.d.ts +13 -0
  94. package/dist/components/CanvasEditor/layersTab.js +27 -0
  95. package/dist/components/CanvasEditor/mobileSelectionArea.d.ts +8 -0
  96. package/dist/components/CanvasEditor/mobileSelectionArea.js +27 -0
  97. package/dist/components/CanvasEditor/types.d.ts +202 -0
  98. package/dist/components/CanvasEditor/types.js +1 -0
  99. package/dist/components/CanvasEditorSkeleton.d.ts +16 -0
  100. package/dist/components/CanvasEditorSkeleton.js +24 -0
  101. package/dist/components/CanvasMetaBar.d.ts +16 -0
  102. package/dist/components/CanvasMetaBar.js +33 -0
  103. package/dist/components/CanvasRenderLayer.d.ts +37 -0
  104. package/dist/components/CanvasRenderLayer.js +54 -0
  105. package/dist/components/CanvasTextOverlay.d.ts +126 -0
  106. package/dist/components/CanvasTextOverlay.js +527 -0
  107. package/dist/components/ConfigCanvas.d.ts +35 -0
  108. package/dist/components/ConfigCanvas.js +30 -0
  109. package/dist/components/CropGhostOverlay.d.ts +13 -0
  110. package/dist/components/CropGhostOverlay.js +56 -0
  111. package/dist/components/CustomColorSwatch.d.ts +35 -0
  112. package/dist/components/CustomColorSwatch.js +81 -0
  113. package/dist/components/DownloadNotice.d.ts +7 -0
  114. package/dist/components/DownloadNotice.js +7 -0
  115. package/dist/components/GenericCanvas.d.ts +309 -0
  116. package/dist/components/GenericCanvas.js +787 -0
  117. package/dist/components/GenericCanvasElement.d.ts +34 -0
  118. package/dist/components/GenericCanvasElement.js +267 -0
  119. package/dist/components/MultiSelectionTransformer.d.ts +39 -0
  120. package/dist/components/MultiSelectionTransformer.js +107 -0
  121. package/dist/components/PagePreview.d.ts +14 -0
  122. package/dist/components/PagePreview.js +63 -0
  123. package/dist/components/PageThumbnailStrip.d.ts +25 -0
  124. package/dist/components/PageThumbnailStrip.js +46 -0
  125. package/dist/components/PageToolbar.d.ts +12 -0
  126. package/dist/components/PageToolbar.js +20 -0
  127. package/dist/components/PrintGuides.d.ts +13 -0
  128. package/dist/components/PrintGuides.js +28 -0
  129. package/dist/components/RemoteSelectionOverlay.d.ts +15 -0
  130. package/dist/components/RemoteSelectionOverlay.js +29 -0
  131. package/dist/components/RichTextField.d.ts +34 -0
  132. package/dist/components/RichTextField.js +216 -0
  133. package/dist/components/SelectionPill.d.ts +56 -0
  134. package/dist/components/SelectionPill.js +123 -0
  135. package/dist/components/SlideNotesPanel.d.ts +13 -0
  136. package/dist/components/SlideNotesPanel.js +28 -0
  137. package/dist/components/SlotBudgetStatus.d.ts +12 -0
  138. package/dist/components/SlotBudgetStatus.js +64 -0
  139. package/dist/components/StandaloneCanvas.d.ts +33 -0
  140. package/dist/components/StandaloneCanvas.js +61 -0
  141. package/dist/components/TextFormatButtons.d.ts +61 -0
  142. package/dist/components/TextFormatButtons.js +107 -0
  143. package/dist/components/TextFormatControls.d.ts +26 -0
  144. package/dist/components/TextFormatControls.js +73 -0
  145. package/dist/components/Toolbar.d.ts +40 -0
  146. package/dist/components/Toolbar.js +26 -0
  147. package/dist/components/ToolbarStateBridge.d.ts +72 -0
  148. package/dist/components/ToolbarStateBridge.js +298 -0
  149. package/dist/components/TopBar/AutoSaveIndicator.d.ts +8 -0
  150. package/dist/components/TopBar/AutoSaveIndicator.js +44 -0
  151. package/dist/components/TopBar/ContextControls.d.ts +107 -0
  152. package/dist/components/TopBar/ContextControls.js +321 -0
  153. package/dist/components/TopBar/ContextToolbar.d.ts +14 -0
  154. package/dist/components/TopBar/ContextToolbar.js +20 -0
  155. package/dist/components/TopBar/CropModeControls.d.ts +35 -0
  156. package/dist/components/TopBar/CropModeControls.js +84 -0
  157. package/dist/components/TopBar/DownloadSection.d.ts +47 -0
  158. package/dist/components/TopBar/DownloadSection.js +102 -0
  159. package/dist/components/TopBar/MobileSelectionBar.d.ts +16 -0
  160. package/dist/components/TopBar/MobileSelectionBar.js +26 -0
  161. package/dist/components/TopBar/MobileSelectionControls.d.ts +10 -0
  162. package/dist/components/TopBar/MobileSelectionControls.js +43 -0
  163. package/dist/components/TopBar/MultiSelectionToolbar.d.ts +19 -0
  164. package/dist/components/TopBar/MultiSelectionToolbar.js +30 -0
  165. package/dist/components/TopBar/ShareDropdown.d.ts +54 -0
  166. package/dist/components/TopBar/ShareDropdown.js +110 -0
  167. package/dist/components/TopBar/TopBar.d.ts +6 -0
  168. package/dist/components/TopBar/TopBar.js +6 -0
  169. package/dist/components/TopBar/barTiles.d.ts +15 -0
  170. package/dist/components/TopBar/barTiles.js +34 -0
  171. package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.d.ts +28 -0
  172. package/dist/components/TopBar/modules/FloatingAiSuggestionBanner.js +26 -0
  173. package/dist/components/TopBar/modules/FloatingBackgroundControls.d.ts +38 -0
  174. package/dist/components/TopBar/modules/FloatingBackgroundControls.js +133 -0
  175. package/dist/components/TopBar/modules/FloatingColorPicker.d.ts +16 -0
  176. package/dist/components/TopBar/modules/FloatingColorPicker.js +89 -0
  177. package/dist/components/TopBar/modules/FloatingFontRoleControl.d.ts +17 -0
  178. package/dist/components/TopBar/modules/FloatingFontRoleControl.js +37 -0
  179. package/dist/components/TopBar/modules/FloatingFontSizeControl.d.ts +7 -0
  180. package/dist/components/TopBar/modules/FloatingFontSizeControl.js +22 -0
  181. package/dist/components/TopBar/modules/FloatingHistoryControls.d.ts +11 -0
  182. package/dist/components/TopBar/modules/FloatingHistoryControls.js +19 -0
  183. package/dist/components/TopBar/modules/FloatingImageLookControl.d.ts +9 -0
  184. package/dist/components/TopBar/modules/FloatingImageLookControl.js +15 -0
  185. package/dist/components/TopBar/modules/FloatingLayerControls.d.ts +9 -0
  186. package/dist/components/TopBar/modules/FloatingLayerControls.js +9 -0
  187. package/dist/components/TopBar/modules/FloatingOpacityControl.d.ts +11 -0
  188. package/dist/components/TopBar/modules/FloatingOpacityControl.js +19 -0
  189. package/dist/components/TopBar/modules/FloatingPositionControl.d.ts +38 -0
  190. package/dist/components/TopBar/modules/FloatingPositionControl.js +74 -0
  191. package/dist/components/TopBar/modules/FloatingTextAlignControl.d.ts +12 -0
  192. package/dist/components/TopBar/modules/FloatingTextAlignControl.js +27 -0
  193. package/dist/components/TransformHud.d.ts +11 -0
  194. package/dist/components/TransformHud.js +121 -0
  195. package/dist/components/WholeTextFormatControls.d.ts +10 -0
  196. package/dist/components/WholeTextFormatControls.js +37 -0
  197. package/dist/components/ZoomableViewport.d.ts +6 -0
  198. package/dist/components/ZoomableViewport.js +4 -0
  199. package/dist/components/accentMark.d.ts +20 -0
  200. package/dist/components/accentMark.js +24 -0
  201. package/dist/components/canvasItemLock.d.ts +13 -0
  202. package/dist/components/canvasItemLock.js +12 -0
  203. package/dist/components/kindRenderers.d.ts +118 -0
  204. package/dist/components/kindRenderers.js +151 -0
  205. package/dist/components/markColor.d.ts +13 -0
  206. package/dist/components/markColor.js +21 -0
  207. package/dist/components/markerMark.d.ts +24 -0
  208. package/dist/components/markerMark.js +22 -0
  209. package/dist/composer/cardFollowsText.d.ts +17 -0
  210. package/dist/composer/cardFollowsText.js +34 -0
  211. package/dist/composer/marks.d.ts +4 -0
  212. package/dist/composer/marks.js +15 -0
  213. package/dist/composer/steckbriefLayout.d.ts +147 -0
  214. package/dist/composer/steckbriefLayout.js +468 -0
  215. package/dist/composer/textFit.d.ts +31 -0
  216. package/dist/composer/textFit.js +89 -0
  217. package/dist/configs/buildSharepicText.d.ts +5 -0
  218. package/dist/configs/buildSharepicText.js +58 -0
  219. package/dist/configs/configLoader.d.ts +34 -0
  220. package/dist/configs/configLoader.js +60 -0
  221. package/dist/configs/factory/actionFactories.d.ts +201 -0
  222. package/dist/configs/factory/actionFactories.js +628 -0
  223. package/dist/configs/factory/baseTypes.d.ts +150 -0
  224. package/dist/configs/factory/baseTypes.js +8 -0
  225. package/dist/configs/factory/carryInstanceState.d.ts +82 -0
  226. package/dist/configs/factory/carryInstanceState.js +121 -0
  227. package/dist/configs/factory/createTextElement.d.ts +63 -0
  228. package/dist/configs/factory/createTextElement.js +63 -0
  229. package/dist/configs/factory/defineSection.d.ts +45 -0
  230. package/dist/configs/factory/defineSection.js +45 -0
  231. package/dist/configs/factory/layoutAccessors.d.ts +15 -0
  232. package/dist/configs/factory/layoutAccessors.js +20 -0
  233. package/dist/configs/featureInjector.d.ts +40 -0
  234. package/dist/configs/featureInjector.js +184 -0
  235. package/dist/configs/pageInheritance.d.ts +8 -0
  236. package/dist/configs/pageInheritance.js +82 -0
  237. package/dist/configs/placeholders.d.ts +14 -0
  238. package/dist/configs/placeholders.js +33 -0
  239. package/dist/configs/shareSection.d.ts +11 -0
  240. package/dist/configs/shareSection.js +65 -0
  241. package/dist/configs/types.d.ts +431 -0
  242. package/dist/configs/types.js +1 -0
  243. package/dist/configs/unifiedTabs.d.ts +26 -0
  244. package/dist/configs/unifiedTabs.js +6 -0
  245. package/dist/editorSeamTypes.d.ts +41 -0
  246. package/dist/editorSeamTypes.js +1 -0
  247. package/dist/export/pptx/buildPptxModel.d.ts +47 -0
  248. package/dist/export/pptx/buildPptxModel.js +612 -0
  249. package/dist/export/pptx/exportPptxDeck.d.ts +26 -0
  250. package/dist/export/pptx/exportPptxDeck.js +80 -0
  251. package/dist/export/pptx/pptxFonts.d.ts +26 -0
  252. package/dist/export/pptx/pptxFonts.js +41 -0
  253. package/dist/export/pptx/pptxUnits.d.ts +27 -0
  254. package/dist/export/pptx/pptxUnits.js +54 -0
  255. package/dist/export/pptx/textModel.d.ts +17 -0
  256. package/dist/export/pptx/textModel.js +118 -0
  257. package/dist/export/pptx/types.d.ts +161 -0
  258. package/dist/export/pptx/types.js +11 -0
  259. package/dist/export/pptx/writePptx.d.ts +40 -0
  260. package/dist/export/pptx/writePptx.js +206 -0
  261. package/dist/export/pptx/writeText.d.ts +19 -0
  262. package/dist/export/pptx/writeText.js +120 -0
  263. package/dist/export/printExport.d.ts +42 -0
  264. package/dist/export/printExport.js +94 -0
  265. package/dist/export/printPdf.d.ts +103 -0
  266. package/dist/export/printPdf.js +144 -0
  267. package/dist/export/slidesPdf.d.ts +9 -0
  268. package/dist/export/slidesPdf.js +31 -0
  269. package/dist/formats/index.d.ts +115 -0
  270. package/dist/formats/index.js +287 -0
  271. package/dist/groups/pageGroups.d.ts +32 -0
  272. package/dist/groups/pageGroups.js +91 -0
  273. package/dist/hooks/index.d.ts +29 -0
  274. package/dist/hooks/index.js +19 -0
  275. package/dist/hooks/useAiImageGeneration.d.ts +15 -0
  276. package/dist/hooks/useAiImageGeneration.js +73 -0
  277. package/dist/hooks/useAnnounce.d.ts +27 -0
  278. package/dist/hooks/useAnnounce.js +47 -0
  279. package/dist/hooks/useBoxSnap.d.ts +37 -0
  280. package/dist/hooks/useBoxSnap.js +49 -0
  281. package/dist/hooks/useCanvasAutoSave.d.ts +33 -0
  282. package/dist/hooks/useCanvasAutoSave.js +259 -0
  283. package/dist/hooks/useCanvasElementHandlers.d.ts +182 -0
  284. package/dist/hooks/useCanvasElementHandlers.js +326 -0
  285. package/dist/hooks/useCanvasHistorySetup.d.ts +37 -0
  286. package/dist/hooks/useCanvasHistorySetup.js +113 -0
  287. package/dist/hooks/useCanvasInteractions.d.ts +31 -0
  288. package/dist/hooks/useCanvasInteractions.js +103 -0
  289. package/dist/hooks/useCanvasKeyboardHandlers.d.ts +37 -0
  290. package/dist/hooks/useCanvasKeyboardHandlers.js +280 -0
  291. package/dist/hooks/useCanvasStoreReset.d.ts +25 -0
  292. package/dist/hooks/useCanvasStoreReset.js +35 -0
  293. package/dist/hooks/useCanvasUndoRedo.d.ts +34 -0
  294. package/dist/hooks/useCanvasUndoRedo.js +213 -0
  295. package/dist/hooks/useContextPress.d.ts +14 -0
  296. package/dist/hooks/useContextPress.js +45 -0
  297. package/dist/hooks/useCropSession.d.ts +23 -0
  298. package/dist/hooks/useCropSession.js +69 -0
  299. package/dist/hooks/useDebounce.d.ts +1 -0
  300. package/dist/hooks/useDebounce.js +14 -0
  301. package/dist/hooks/useDeckAutoSave.d.ts +30 -0
  302. package/dist/hooks/useDeckAutoSave.js +234 -0
  303. package/dist/hooks/useDeepSelect.d.ts +18 -0
  304. package/dist/hooks/useDeepSelect.js +135 -0
  305. package/dist/hooks/useElementSnapping.d.ts +13 -0
  306. package/dist/hooks/useElementSnapping.js +26 -0
  307. package/dist/hooks/useEmojiCatalog.d.ts +3 -0
  308. package/dist/hooks/useEmojiCatalog.js +13 -0
  309. package/dist/hooks/useFloatingModuleHandlers.d.ts +52 -0
  310. package/dist/hooks/useFloatingModuleHandlers.js +285 -0
  311. package/dist/hooks/useFloatingModuleState.d.ts +83 -0
  312. package/dist/hooks/useFloatingModuleState.js +250 -0
  313. package/dist/hooks/useFontGeneration.d.ts +10 -0
  314. package/dist/hooks/useFontGeneration.js +77 -0
  315. package/dist/hooks/useFontLoader.d.ts +53 -0
  316. package/dist/hooks/useFontLoader.js +129 -0
  317. package/dist/hooks/useGeometryReporter.d.ts +19 -0
  318. package/dist/hooks/useGeometryReporter.js +41 -0
  319. package/dist/hooks/useHoverOutline.d.ts +8 -0
  320. package/dist/hooks/useHoverOutline.js +78 -0
  321. package/dist/hooks/useIconCatalog.d.ts +12 -0
  322. package/dist/hooks/useIconCatalog.js +30 -0
  323. package/dist/hooks/useIconSearch.d.ts +2 -0
  324. package/dist/hooks/useIconSearch.js +14 -0
  325. package/dist/hooks/useIconSetsFor.d.ts +8 -0
  326. package/dist/hooks/useIconSetsFor.js +30 -0
  327. package/dist/hooks/useImageCoverFit.d.ts +17 -0
  328. package/dist/hooks/useImageCoverFit.js +35 -0
  329. package/dist/hooks/useIsCanvasMobile.d.ts +3 -0
  330. package/dist/hooks/useIsCanvasMobile.js +19 -0
  331. package/dist/hooks/useMarqueeSelection.d.ts +27 -0
  332. package/dist/hooks/useMarqueeSelection.js +140 -0
  333. package/dist/hooks/useMobileSheet.d.ts +48 -0
  334. package/dist/hooks/useMobileSheet.js +282 -0
  335. package/dist/hooks/useMultiPageExport.d.ts +30 -0
  336. package/dist/hooks/useMultiPageExport.js +117 -0
  337. package/dist/hooks/usePageManager.d.ts +132 -0
  338. package/dist/hooks/usePageManager.js +399 -0
  339. package/dist/hooks/usePageThumbnails.d.ts +10 -0
  340. package/dist/hooks/usePageThumbnails.js +122 -0
  341. package/dist/hooks/usePaginatedIcons.d.ts +11 -0
  342. package/dist/hooks/usePaginatedIcons.js +46 -0
  343. package/dist/hooks/useRovingToolbar.d.ts +17 -0
  344. package/dist/hooks/useRovingToolbar.js +76 -0
  345. package/dist/hooks/useSelectionAnnouncement.d.ts +13 -0
  346. package/dist/hooks/useSelectionAnnouncement.js +68 -0
  347. package/dist/hooks/useSnapScheduler.d.ts +20 -0
  348. package/dist/hooks/useSnapScheduler.js +61 -0
  349. package/dist/hooks/useTrackUnsplashDownload.d.ts +6 -0
  350. package/dist/hooks/useTrackUnsplashDownload.js +19 -0
  351. package/dist/hooks/useZoomGestures.d.ts +35 -0
  352. package/dist/hooks/useZoomGestures.js +185 -0
  353. package/dist/hostServices.d.ts +308 -0
  354. package/dist/hostServices.js +107 -0
  355. package/dist/i18n/de.d.ts +897 -0
  356. package/dist/i18n/de.js +961 -0
  357. package/dist/i18n/en.d.ts +3 -0
  358. package/dist/i18n/en.js +949 -0
  359. package/dist/i18n/messages.d.ts +28 -0
  360. package/dist/i18n/messages.js +66 -0
  361. package/dist/layouts/CanvasEditorLayout.d.ts +28 -0
  362. package/dist/layouts/CanvasEditorLayout.js +56 -0
  363. package/dist/layouts/index.d.ts +2 -0
  364. package/dist/layouts/index.js +2 -0
  365. package/dist/primitives/AssetPrimitive.d.ts +24 -0
  366. package/dist/primitives/AssetPrimitive.js +158 -0
  367. package/dist/primitives/CanvasBackground.d.ts +33 -0
  368. package/dist/primitives/CanvasBackground.js +44 -0
  369. package/dist/primitives/CanvasIcons.d.ts +19 -0
  370. package/dist/primitives/CanvasIcons.js +46 -0
  371. package/dist/primitives/CanvasImage.d.ts +73 -0
  372. package/dist/primitives/CanvasImage.js +460 -0
  373. package/dist/primitives/CanvasRichText.d.ts +25 -0
  374. package/dist/primitives/CanvasRichText.js +284 -0
  375. package/dist/primitives/CanvasStage.d.ts +84 -0
  376. package/dist/primitives/CanvasStage.js +292 -0
  377. package/dist/primitives/CanvasText.d.ts +91 -0
  378. package/dist/primitives/CanvasText.js +293 -0
  379. package/dist/primitives/ChartPrimitive.d.ts +24 -0
  380. package/dist/primitives/ChartPrimitive.js +318 -0
  381. package/dist/primitives/CircleBadge.d.ts +43 -0
  382. package/dist/primitives/CircleBadge.js +233 -0
  383. package/dist/primitives/FramePrimitive.d.ts +14 -0
  384. package/dist/primitives/FramePrimitive.js +406 -0
  385. package/dist/primitives/IconPrimitive.d.ts +28 -0
  386. package/dist/primitives/IconPrimitive.js +119 -0
  387. package/dist/primitives/IllustrationPrimitive.d.ts +16 -0
  388. package/dist/primitives/IllustrationPrimitive.js +184 -0
  389. package/dist/primitives/PillBadge.d.ts +45 -0
  390. package/dist/primitives/PillBadge.js +237 -0
  391. package/dist/primitives/ShapePrimitive.d.ts +12 -0
  392. package/dist/primitives/ShapePrimitive.js +521 -0
  393. package/dist/primitives/SnapGuidelines.d.ts +19 -0
  394. package/dist/primitives/SnapGuidelines.js +34 -0
  395. package/dist/primitives/UserImagePrimitive.d.ts +30 -0
  396. package/dist/primitives/UserImagePrimitive.js +496 -0
  397. package/dist/primitives/index.d.ts +18 -0
  398. package/dist/primitives/index.js +11 -0
  399. package/dist/sidebar/SidebarPanel.d.ts +8 -0
  400. package/dist/sidebar/SidebarPanel.js +219 -0
  401. package/dist/sidebar/SidebarTabBar.d.ts +2 -0
  402. package/dist/sidebar/SidebarTabBar.js +31 -0
  403. package/dist/sidebar/SubsectionTabBar.d.ts +13 -0
  404. package/dist/sidebar/SubsectionTabBar.js +30 -0
  405. package/dist/sidebar/UserUploadsProvider.d.ts +31 -0
  406. package/dist/sidebar/UserUploadsProvider.js +139 -0
  407. package/dist/sidebar/components/AltTextField.d.ts +21 -0
  408. package/dist/sidebar/components/AltTextField.js +60 -0
  409. package/dist/sidebar/components/SidebarHint.d.ts +7 -0
  410. package/dist/sidebar/components/SidebarHint.js +38 -0
  411. package/dist/sidebar/components/SidebarSlider.d.ts +16 -0
  412. package/dist/sidebar/components/SidebarSlider.js +9 -0
  413. package/dist/sidebar/components/TextFieldPrimitives.d.ts +26 -0
  414. package/dist/sidebar/components/TextFieldPrimitives.js +56 -0
  415. package/dist/sidebar/sections/ChartSettingsSection.d.ts +9 -0
  416. package/dist/sidebar/sections/ChartSettingsSection.js +78 -0
  417. package/dist/sidebar/sections/CombinedTextSection.d.ts +16 -0
  418. package/dist/sidebar/sections/CombinedTextSection.js +43 -0
  419. package/dist/sidebar/sections/DiagrammeSection.d.ts +9 -0
  420. package/dist/sidebar/sections/DiagrammeSection.js +40 -0
  421. package/dist/sidebar/sections/EffectsSection.d.ts +20 -0
  422. package/dist/sidebar/sections/EffectsSection.js +23 -0
  423. package/dist/sidebar/sections/FormenSection.d.ts +28 -0
  424. package/dist/sidebar/sections/FormenSection.js +440 -0
  425. package/dist/sidebar/sections/FrameSettingsSection.d.ts +8 -0
  426. package/dist/sidebar/sections/FrameSettingsSection.js +26 -0
  427. package/dist/sidebar/sections/GenericShareSection.d.ts +26 -0
  428. package/dist/sidebar/sections/GenericShareSection.js +262 -0
  429. package/dist/sidebar/sections/IconsSection.d.ts +8 -0
  430. package/dist/sidebar/sections/IconsSection.js +55 -0
  431. package/dist/sidebar/sections/IllustrationSettings.d.ts +9 -0
  432. package/dist/sidebar/sections/IllustrationSettings.js +33 -0
  433. package/dist/sidebar/sections/IllustrationThumb.d.ts +7 -0
  434. package/dist/sidebar/sections/IllustrationThumb.js +15 -0
  435. package/dist/sidebar/sections/ImageAdjustSection.d.ts +13 -0
  436. package/dist/sidebar/sections/ImageAdjustSection.js +85 -0
  437. package/dist/sidebar/sections/LayersSection.d.ts +25 -0
  438. package/dist/sidebar/sections/LayersSection.js +155 -0
  439. package/dist/sidebar/sections/RahmenSection.d.ts +7 -0
  440. package/dist/sidebar/sections/RahmenSection.js +18 -0
  441. package/dist/sidebar/sections/StudioGallery.d.ts +33 -0
  442. package/dist/sidebar/sections/StudioGallery.js +58 -0
  443. package/dist/sidebar/sections/UploadsSection.d.ts +11 -0
  444. package/dist/sidebar/sections/UploadsSection.js +130 -0
  445. package/dist/sidebar/sections/assets/AssetsSection.d.ts +59 -0
  446. package/dist/sidebar/sections/assets/AssetsSection.js +27 -0
  447. package/dist/sidebar/sections/assets/BackgroundCatalog.d.ts +9 -0
  448. package/dist/sidebar/sections/assets/BackgroundCatalog.js +49 -0
  449. package/dist/sidebar/sections/assets/CategoryCard.d.ts +14 -0
  450. package/dist/sidebar/sections/assets/CategoryCard.js +15 -0
  451. package/dist/sidebar/sections/assets/ElementGrid.d.ts +14 -0
  452. package/dist/sidebar/sections/assets/ElementGrid.js +34 -0
  453. package/dist/sidebar/sections/assets/ElementThumb.d.ts +10 -0
  454. package/dist/sidebar/sections/assets/ElementThumb.js +61 -0
  455. package/dist/sidebar/sections/assets/ElementTile.d.ts +32 -0
  456. package/dist/sidebar/sections/assets/ElementTile.js +60 -0
  457. package/dist/sidebar/sections/assets/ElementsPanel.d.ts +7 -0
  458. package/dist/sidebar/sections/assets/ElementsPanel.js +249 -0
  459. package/dist/sidebar/sections/assets/EmojiTonePicker.d.ts +8 -0
  460. package/dist/sidebar/sections/assets/EmojiTonePicker.js +26 -0
  461. package/dist/sidebar/sections/assets/FotosCatalog.d.ts +12 -0
  462. package/dist/sidebar/sections/assets/FotosCatalog.js +41 -0
  463. package/dist/sidebar/sections/assets/IconifyCatalog.d.ts +14 -0
  464. package/dist/sidebar/sections/assets/IconifyCatalog.js +133 -0
  465. package/dist/sidebar/sections/assets/RecentCarousel.d.ts +7 -0
  466. package/dist/sidebar/sections/assets/RecentCarousel.js +42 -0
  467. package/dist/sidebar/sections/assets/StickerCatalog.d.ts +14 -0
  468. package/dist/sidebar/sections/assets/StickerCatalog.js +49 -0
  469. package/dist/sidebar/sections/assets/constants.d.ts +4 -0
  470. package/dist/sidebar/sections/assets/constants.js +15 -0
  471. package/dist/sidebar/sections/assets/elementPanelHost.d.ts +45 -0
  472. package/dist/sidebar/sections/assets/elementPanelHost.js +1 -0
  473. package/dist/sidebar/sections/assets/elementSearch.d.ts +10 -0
  474. package/dist/sidebar/sections/assets/elementSearch.js +38 -0
  475. package/dist/sidebar/sections/assets/elementTypes.d.ts +67 -0
  476. package/dist/sidebar/sections/assets/elementTypes.js +24 -0
  477. package/dist/sidebar/sections/assets/index.d.ts +3 -0
  478. package/dist/sidebar/sections/assets/index.js +3 -0
  479. package/dist/sidebar/sections/assets/useElementCatalog.d.ts +43 -0
  480. package/dist/sidebar/sections/assets/useElementCatalog.js +386 -0
  481. package/dist/sidebar/sections/assets/useRecentElements.d.ts +21 -0
  482. package/dist/sidebar/sections/assets/useRecentElements.js +67 -0
  483. package/dist/sidebar/sections/assets/useStockPhotos.d.ts +22 -0
  484. package/dist/sidebar/sections/assets/useStockPhotos.js +96 -0
  485. package/dist/sidebar/sections/effects/EffectCard.d.ts +11 -0
  486. package/dist/sidebar/sections/effects/EffectCard.js +14 -0
  487. package/dist/sidebar/sections/effects/GradientSettings.d.ts +10 -0
  488. package/dist/sidebar/sections/effects/GradientSettings.js +34 -0
  489. package/dist/sidebar/sections/effects/OutlineSettings.d.ts +12 -0
  490. package/dist/sidebar/sections/effects/OutlineSettings.js +29 -0
  491. package/dist/sidebar/sections/effects/ShadowSettings.d.ts +13 -0
  492. package/dist/sidebar/sections/effects/ShadowSettings.js +38 -0
  493. package/dist/sidebar/sections/effects/effectsFor.d.ts +16 -0
  494. package/dist/sidebar/sections/effects/effectsFor.js +24 -0
  495. package/dist/sidebar/sections/index.d.ts +28 -0
  496. package/dist/sidebar/sections/index.js +36 -0
  497. package/dist/sidebar/sections/lazyWithPreload.d.ts +11 -0
  498. package/dist/sidebar/sections/lazyWithPreload.js +29 -0
  499. package/dist/sidebar/sections/tools/AiCreateTool.d.ts +4 -0
  500. package/dist/sidebar/sections/tools/AiCreateTool.js +58 -0
  501. package/dist/sidebar/sections/tools/AiEditTool.d.ts +4 -0
  502. package/dist/sidebar/sections/tools/AiEditTool.js +57 -0
  503. package/dist/sidebar/sections/tools/AltTextTool.d.ts +11 -0
  504. package/dist/sidebar/sections/tools/AltTextTool.js +78 -0
  505. package/dist/sidebar/sections/tools/BlobCreatorTool.d.ts +5 -0
  506. package/dist/sidebar/sections/tools/BlobCreatorTool.js +90 -0
  507. package/dist/sidebar/sections/tools/GradientTextTool.d.ts +5 -0
  508. package/dist/sidebar/sections/tools/GradientTextTool.js +104 -0
  509. package/dist/sidebar/sections/tools/ImageInputPicker.d.ts +7 -0
  510. package/dist/sidebar/sections/tools/ImageInputPicker.js +68 -0
  511. package/dist/sidebar/sections/tools/QRCodeTool.d.ts +5 -0
  512. package/dist/sidebar/sections/tools/QRCodeTool.js +63 -0
  513. package/dist/sidebar/sections/tools/RemoveBackgroundTool.d.ts +4 -0
  514. package/dist/sidebar/sections/tools/RemoveBackgroundTool.js +52 -0
  515. package/dist/sidebar/sections/tools/TextPathCreatorTool.d.ts +5 -0
  516. package/dist/sidebar/sections/tools/TextPathCreatorTool.js +125 -0
  517. package/dist/sidebar/sections/tools/ToolPanel.d.ts +26 -0
  518. package/dist/sidebar/sections/tools/ToolPanel.js +13 -0
  519. package/dist/sidebar/sections/tools/ToolTiles.d.ts +5 -0
  520. package/dist/sidebar/sections/tools/ToolTiles.js +76 -0
  521. package/dist/sidebar/sections/tools/ToolsSection.d.ts +15 -0
  522. package/dist/sidebar/sections/tools/ToolsSection.js +151 -0
  523. package/dist/sidebar/sections/tools/UnsplashLimitNotice.d.ts +8 -0
  524. package/dist/sidebar/sections/tools/UnsplashLimitNotice.js +22 -0
  525. package/dist/sidebar/sections/tools/UnsplashTool.d.ts +10 -0
  526. package/dist/sidebar/sections/tools/UnsplashTool.js +47 -0
  527. package/dist/sidebar/sections/tools/index.d.ts +1 -0
  528. package/dist/sidebar/sections/tools/index.js +2 -0
  529. package/dist/sidebar/sections/tools/toolTiles.css +335 -0
  530. package/dist/sidebar/sections/tools/useToolImagePlacement.d.ts +19 -0
  531. package/dist/sidebar/sections/tools/useToolImagePlacement.js +23 -0
  532. package/dist/sidebar/sections/whenIdle.d.ts +2 -0
  533. package/dist/sidebar/sections/whenIdle.js +10 -0
  534. package/dist/sidebar/sidebarStyles.d.ts +60 -0
  535. package/dist/sidebar/sidebarStyles.js +61 -0
  536. package/dist/sidebar/tabTypes.d.ts +27 -0
  537. package/dist/sidebar/tabTypes.js +1 -0
  538. package/dist/sidebar/types.d.ts +43 -0
  539. package/dist/sidebar/types.js +1 -0
  540. package/dist/sidebar/useImagePlacement.d.ts +17 -0
  541. package/dist/sidebar/useImagePlacement.js +28 -0
  542. package/dist/stores/AutoSaveStoreProvider.d.ts +28 -0
  543. package/dist/stores/AutoSaveStoreProvider.js +45 -0
  544. package/dist/stores/CanvasStoreProvider.d.ts +43 -0
  545. package/dist/stores/CanvasStoreProvider.js +74 -0
  546. package/dist/stores/createAutoSaveStore.d.ts +50 -0
  547. package/dist/stores/createAutoSaveStore.js +42 -0
  548. package/dist/stores/createCanvasEditorStore.d.ts +126 -0
  549. package/dist/stores/createCanvasEditorStore.js +266 -0
  550. package/dist/stores/useAutoSaveStore.d.ts +12 -0
  551. package/dist/stores/useAutoSaveStore.js +12 -0
  552. package/dist/styles/editor.css +445 -0
  553. package/dist/styles/index.css +4 -0
  554. package/dist/styles/tailwind.css +239 -0
  555. package/dist/styles/tokens.css +199 -0
  556. package/dist/templates/fontWidths.generated.d.ts +1 -0
  557. package/dist/templates/fontWidths.generated.js +17 -0
  558. package/dist/templates/registry.d.ts +59 -0
  559. package/dist/templates/registry.js +40 -0
  560. package/dist/templates/templateGeometry.d.ts +32 -0
  561. package/dist/templates/templateGeometry.js +887 -0
  562. package/dist/templates/testKinds.d.ts +15 -0
  563. package/dist/templates/testKinds.js +151 -0
  564. package/dist/testing/documentBrandConfig.d.ts +14 -0
  565. package/dist/testing/documentBrandConfig.js +60 -0
  566. package/dist/testing/documentBrandPacks.d.ts +10 -0
  567. package/dist/testing/documentBrandPacks.js +45 -0
  568. package/dist/testing/fixtureTemplates.d.ts +13 -0
  569. package/dist/testing/fixtureTemplates.js +376 -0
  570. package/dist/testing/stampKind.d.ts +91 -0
  571. package/dist/testing/stampKind.js +56 -0
  572. package/dist/types/editorTypes.d.ts +65 -0
  573. package/dist/types/editorTypes.js +21 -0
  574. package/dist/ui/alert-dialog.d.ts +18 -0
  575. package/dist/ui/alert-dialog.js +42 -0
  576. package/dist/ui/button.d.ts +10 -0
  577. package/dist/ui/button.js +29 -0
  578. package/dist/ui/dialog.d.ts +15 -0
  579. package/dist/ui/dialog.js +53 -0
  580. package/dist/ui/icon-button.d.ts +18 -0
  581. package/dist/ui/icon-button.js +54 -0
  582. package/dist/ui/input.d.ts +3 -0
  583. package/dist/ui/input.js +6 -0
  584. package/dist/ui/label.d.ts +4 -0
  585. package/dist/ui/label.js +8 -0
  586. package/dist/ui/masonry-grid.d.ts +11 -0
  587. package/dist/ui/masonry-grid.js +43 -0
  588. package/dist/ui/popover.d.ts +10 -0
  589. package/dist/ui/popover.js +26 -0
  590. package/dist/ui/select.d.ts +15 -0
  591. package/dist/ui/select.js +38 -0
  592. package/dist/ui/skeleton.d.ts +2 -0
  593. package/dist/ui/skeleton.js +7 -0
  594. package/dist/ui/switch.d.ts +6 -0
  595. package/dist/ui/switch.js +8 -0
  596. package/dist/utils/__snapshots__/kindSelection.vitest.ts.snap +1086 -0
  597. package/dist/utils/alignment.d.ts +21 -0
  598. package/dist/utils/alignment.js +54 -0
  599. package/dist/utils/axisLock.d.ts +30 -0
  600. package/dist/utils/axisLock.js +78 -0
  601. package/dist/utils/backgroundPhotoCrop.d.ts +28 -0
  602. package/dist/utils/backgroundPhotoCrop.js +28 -0
  603. package/dist/utils/canvasAssets.d.ts +140 -0
  604. package/dist/utils/canvasAssets.js +121 -0
  605. package/dist/utils/canvasClipboard.d.ts +51 -0
  606. package/dist/utils/canvasClipboard.js +37 -0
  607. package/dist/utils/canvasCommandRegistry.d.ts +207 -0
  608. package/dist/utils/canvasCommandRegistry.js +124 -0
  609. package/dist/utils/canvasCommands.d.ts +106 -0
  610. package/dist/utils/canvasCommands.js +564 -0
  611. package/dist/utils/canvasFontFamilies.d.ts +12 -0
  612. package/dist/utils/canvasFontFamilies.js +24 -0
  613. package/dist/utils/canvasIcons.d.ts +68 -0
  614. package/dist/utils/canvasIcons.js +293 -0
  615. package/dist/utils/canvasImageSource.d.ts +12 -0
  616. package/dist/utils/canvasImageSource.js +19 -0
  617. package/dist/utils/canvasItem.d.ts +102 -0
  618. package/dist/utils/canvasItem.js +1 -0
  619. package/dist/utils/canvasLayerManager.d.ts +51 -0
  620. package/dist/utils/canvasLayerManager.js +107 -0
  621. package/dist/utils/canvasValueResolver.d.ts +9 -0
  622. package/dist/utils/canvasValueResolver.js +13 -0
  623. package/dist/utils/captureStage.d.ts +59 -0
  624. package/dist/utils/captureStage.js +152 -0
  625. package/dist/utils/chartTypes.d.ts +6 -0
  626. package/dist/utils/chartTypes.js +2 -0
  627. package/dist/utils/chartUtils.d.ts +49 -0
  628. package/dist/utils/chartUtils.js +191 -0
  629. package/dist/utils/circleBadgeUtils.d.ts +30 -0
  630. package/dist/utils/circleBadgeUtils.js +85 -0
  631. package/dist/utils/cn.d.ts +2 -0
  632. package/dist/utils/cn.js +66 -0
  633. package/dist/utils/collectAltTextPages.d.ts +6 -0
  634. package/dist/utils/collectAltTextPages.js +20 -0
  635. package/dist/utils/colorLuminance.d.ts +3 -0
  636. package/dist/utils/colorLuminance.js +14 -0
  637. package/dist/utils/colorNames.d.ts +7 -0
  638. package/dist/utils/colorNames.js +17 -0
  639. package/dist/utils/colorOptions.d.ts +20 -0
  640. package/dist/utils/colorOptions.js +20 -0
  641. package/dist/utils/cornerRadius.d.ts +14 -0
  642. package/dist/utils/cornerRadius.js +27 -0
  643. package/dist/utils/cornerReservation.d.ts +19 -0
  644. package/dist/utils/cornerReservation.js +7 -0
  645. package/dist/utils/coverFit.d.ts +117 -0
  646. package/dist/utils/coverFit.js +207 -0
  647. package/dist/utils/cropAspect.d.ts +47 -0
  648. package/dist/utils/cropAspect.js +53 -0
  649. package/dist/utils/cropGhost.d.ts +63 -0
  650. package/dist/utils/cropGhost.js +216 -0
  651. package/dist/utils/cropSession.d.ts +23 -0
  652. package/dist/utils/cropSession.js +92 -0
  653. package/dist/utils/cropTarget.d.ts +22 -0
  654. package/dist/utils/cropTarget.js +33 -0
  655. package/dist/utils/deepSelect.d.ts +43 -0
  656. package/dist/utils/deepSelect.js +74 -0
  657. package/dist/utils/downloadError.d.ts +2 -0
  658. package/dist/utils/downloadError.js +13 -0
  659. package/dist/utils/duplicateElement.d.ts +127 -0
  660. package/dist/utils/duplicateElement.js +235 -0
  661. package/dist/utils/editorFocus.d.ts +36 -0
  662. package/dist/utils/editorFocus.js +67 -0
  663. package/dist/utils/editorToast.d.ts +21 -0
  664. package/dist/utils/editorToast.js +7 -0
  665. package/dist/utils/elementKinds.d.ts +212 -0
  666. package/dist/utils/elementKinds.js +137 -0
  667. package/dist/utils/emoji/emojiCatalog.d.ts +12 -0
  668. package/dist/utils/emoji/emojiCatalog.en.json +9997 -0
  669. package/dist/utils/emoji/emojiCatalog.js +53 -0
  670. package/dist/utils/emoji/emojiCatalog.json +9913 -0
  671. package/dist/utils/ensureFontsReady.d.ts +12 -0
  672. package/dist/utils/ensureFontsReady.js +23 -0
  673. package/dist/utils/expandImage.d.ts +17 -0
  674. package/dist/utils/expandImage.js +76 -0
  675. package/dist/utils/externalIcons.d.ts +67 -0
  676. package/dist/utils/externalIcons.js +168 -0
  677. package/dist/utils/filterCache.d.ts +16 -0
  678. package/dist/utils/filterCache.js +31 -0
  679. package/dist/utils/filterUtils.d.ts +2 -0
  680. package/dist/utils/filterUtils.js +89 -0
  681. package/dist/utils/followStage.d.ts +2 -0
  682. package/dist/utils/followStage.js +48 -0
  683. package/dist/utils/fontAliases.d.ts +14 -0
  684. package/dist/utils/fontAliases.js +32 -0
  685. package/dist/utils/fontMarkSupport.d.ts +26 -0
  686. package/dist/utils/fontMarkSupport.js +32 -0
  687. package/dist/utils/frameUtils.d.ts +20 -0
  688. package/dist/utils/frameUtils.js +283 -0
  689. package/dist/utils/gradientFill.d.ts +55 -0
  690. package/dist/utils/gradientFill.js +57 -0
  691. package/dist/utils/gradientHitArea.d.ts +22 -0
  692. package/dist/utils/gradientHitArea.js +94 -0
  693. package/dist/utils/grain.d.ts +29 -0
  694. package/dist/utils/grain.js +103 -0
  695. package/dist/utils/grainSpec.d.ts +2 -0
  696. package/dist/utils/grainSpec.js +3 -0
  697. package/dist/utils/groupSnap.d.ts +27 -0
  698. package/dist/utils/groupSnap.js +54 -0
  699. package/dist/utils/handDrawn.d.ts +92 -0
  700. package/dist/utils/handDrawn.js +523 -0
  701. package/dist/utils/historyStamp.d.ts +22 -0
  702. package/dist/utils/historyStamp.js +31 -0
  703. package/dist/utils/hostStorageKeys.d.ts +16 -0
  704. package/dist/utils/hostStorageKeys.js +27 -0
  705. package/dist/utils/iconInstances.d.ts +80 -0
  706. package/dist/utils/iconInstances.js +109 -0
  707. package/dist/utils/illustrations/gophers.d.ts +11 -0
  708. package/dist/utils/illustrations/gophers.js +1236 -0
  709. package/dist/utils/illustrations/humaaans.d.ts +8 -0
  710. package/dist/utils/illustrations/humaaans.js +265 -0
  711. package/dist/utils/illustrations/illlustrations.d.ts +11 -0
  712. package/dist/utils/illustrations/illlustrations.js +929 -0
  713. package/dist/utils/illustrations/kawaii.d.ts +6 -0
  714. package/dist/utils/illustrations/kawaii.js +73 -0
  715. package/dist/utils/illustrations/opendoodles.d.ts +6 -0
  716. package/dist/utils/illustrations/opendoodles.js +271 -0
  717. package/dist/utils/illustrations/openpeeps.d.ts +9 -0
  718. package/dist/utils/illustrations/openpeeps.js +1522 -0
  719. package/dist/utils/illustrations/prefetchAnalytics.d.ts +78 -0
  720. package/dist/utils/illustrations/prefetchAnalytics.js +162 -0
  721. package/dist/utils/illustrations/registry.d.ts +27 -0
  722. package/dist/utils/illustrations/registry.js +106 -0
  723. package/dist/utils/illustrations/svgCache.d.ts +60 -0
  724. package/dist/utils/illustrations/svgCache.js +349 -0
  725. package/dist/utils/illustrations/transhumans.d.ts +8 -0
  726. package/dist/utils/illustrations/transhumans.js +313 -0
  727. package/dist/utils/illustrations/types.d.ts +25 -0
  728. package/dist/utils/illustrations/types.js +45 -0
  729. package/dist/utils/imageElementComparison.d.ts +19 -0
  730. package/dist/utils/imageElementComparison.js +121 -0
  731. package/dist/utils/imageFilters.d.ts +94 -0
  732. package/dist/utils/imageFilters.js +304 -0
  733. package/dist/utils/imageLook.d.ts +18 -0
  734. package/dist/utils/imageLook.js +41 -0
  735. package/dist/utils/keyboardCrop.d.ts +25 -0
  736. package/dist/utils/keyboardCrop.js +98 -0
  737. package/dist/utils/keyboardOwnership.d.ts +30 -0
  738. package/dist/utils/keyboardOwnership.js +93 -0
  739. package/dist/utils/layerLabels.d.ts +39 -0
  740. package/dist/utils/layerLabels.js +181 -0
  741. package/dist/utils/layerLock.d.ts +24 -0
  742. package/dist/utils/layerLock.js +52 -0
  743. package/dist/utils/layerSelection.d.ts +24 -0
  744. package/dist/utils/layerSelection.js +16 -0
  745. package/dist/utils/markerBoxes.d.ts +38 -0
  746. package/dist/utils/markerBoxes.js +60 -0
  747. package/dist/utils/markerColors.d.ts +16 -0
  748. package/dist/utils/markerColors.js +32 -0
  749. package/dist/utils/mediaDrop.d.ts +76 -0
  750. package/dist/utils/mediaDrop.js +95 -0
  751. package/dist/utils/mediaPlacement.d.ts +6 -0
  752. package/dist/utils/mediaPlacement.js +17 -0
  753. package/dist/utils/motifSizes.d.ts +8 -0
  754. package/dist/utils/motifSizes.js +9 -0
  755. package/dist/utils/multiSelect.d.ts +44 -0
  756. package/dist/utils/multiSelect.js +139 -0
  757. package/dist/utils/notch.d.ts +17 -0
  758. package/dist/utils/notch.js +23 -0
  759. package/dist/utils/orientElement.d.ts +46 -0
  760. package/dist/utils/orientElement.js +108 -0
  761. package/dist/utils/orientation.d.ts +119 -0
  762. package/dist/utils/orientation.js +411 -0
  763. package/dist/utils/pageCounter.d.ts +15 -0
  764. package/dist/utils/pageCounter.js +17 -0
  765. package/dist/utils/pendingImages.d.ts +10 -0
  766. package/dist/utils/pendingImages.js +25 -0
  767. package/dist/utils/photoCredit.d.ts +9 -0
  768. package/dist/utils/photoCredit.js +29 -0
  769. package/dist/utils/photoCredits.d.ts +5 -0
  770. package/dist/utils/photoCredits.js +17 -0
  771. package/dist/utils/photoPlaceholder.d.ts +25 -0
  772. package/dist/utils/photoPlaceholder.js +38 -0
  773. package/dist/utils/pillBadgeUtils.d.ts +41 -0
  774. package/dist/utils/pillBadgeUtils.js +94 -0
  775. package/dist/utils/pixelHitArea.d.ts +13 -0
  776. package/dist/utils/pixelHitArea.js +33 -0
  777. package/dist/utils/plainTextLayout.d.ts +11 -0
  778. package/dist/utils/plainTextLayout.js +64 -0
  779. package/dist/utils/printImageInfo.d.ts +9 -0
  780. package/dist/utils/printImageInfo.js +14 -0
  781. package/dist/utils/recacheNextFrame.d.ts +6 -0
  782. package/dist/utils/recacheNextFrame.js +15 -0
  783. package/dist/utils/removeElement.d.ts +17 -0
  784. package/dist/utils/removeElement.js +47 -0
  785. package/dist/utils/renderedBoxes.d.ts +19 -0
  786. package/dist/utils/renderedBoxes.js +67 -0
  787. package/dist/utils/resolveElementValue.d.ts +44 -0
  788. package/dist/utils/resolveElementValue.js +72 -0
  789. package/dist/utils/scrollBehavior.d.ts +6 -0
  790. package/dist/utils/scrollBehavior.js +17 -0
  791. package/dist/utils/searchTranslations.d.ts +20 -0
  792. package/dist/utils/searchTranslations.js +366 -0
  793. package/dist/utils/selectionCapabilities.d.ts +53 -0
  794. package/dist/utils/selectionCapabilities.js +52 -0
  795. package/dist/utils/shade.d.ts +24 -0
  796. package/dist/utils/shade.js +55 -0
  797. package/dist/utils/shapeDevices.d.ts +72 -0
  798. package/dist/utils/shapeDevices.js +100 -0
  799. package/dist/utils/shapeTransform.d.ts +29 -0
  800. package/dist/utils/shapeTransform.js +69 -0
  801. package/dist/utils/shapes.d.ts +64 -0
  802. package/dist/utils/shapes.js +838 -0
  803. package/dist/utils/smartCrop.d.ts +30 -0
  804. package/dist/utils/smartCrop.js +163 -0
  805. package/dist/utils/snapping.d.ts +116 -0
  806. package/dist/utils/snapping.js +426 -0
  807. package/dist/utils/stageCssScale.d.ts +7 -0
  808. package/dist/utils/stageCssScale.js +11 -0
  809. package/dist/utils/stateTypeAssertions.d.ts +99 -0
  810. package/dist/utils/stateTypeAssertions.js +197 -0
  811. package/dist/utils/straighten.d.ts +51 -0
  812. package/dist/utils/straighten.js +254 -0
  813. package/dist/utils/surfaceGlow.d.ts +7 -0
  814. package/dist/utils/surfaceGlow.js +27 -0
  815. package/dist/utils/templateElementInstance.d.ts +43 -0
  816. package/dist/utils/templateElementInstance.js +100 -0
  817. package/dist/utils/templateRotation.d.ts +24 -0
  818. package/dist/utils/templateRotation.js +56 -0
  819. package/dist/utils/textAlign.d.ts +17 -0
  820. package/dist/utils/textAlign.js +30 -0
  821. package/dist/utils/textEditorOpeners.d.ts +12 -0
  822. package/dist/utils/textEditorOpeners.js +40 -0
  823. package/dist/utils/textRouting.d.ts +17 -0
  824. package/dist/utils/textRouting.js +22 -0
  825. package/dist/utils/textUtils.d.ts +102 -0
  826. package/dist/utils/textUtils.js +254 -0
  827. package/dist/utils/touchInput.d.ts +7 -0
  828. package/dist/utils/touchInput.js +19 -0
  829. package/dist/utils/transformHudLabel.d.ts +3 -0
  830. package/dist/utils/transformHudLabel.js +12 -0
  831. package/dist/utils/unsplashLinks.d.ts +2 -0
  832. package/dist/utils/unsplashLinks.js +7 -0
  833. package/dist/utils/userFacingError.d.ts +10 -0
  834. package/dist/utils/userFacingError.js +10 -0
  835. package/dist/utils/userImageCrop.d.ts +4 -0
  836. package/dist/utils/userImageCrop.js +26 -0
  837. package/dist/utils/userImageUtils.d.ts +44 -0
  838. package/dist/utils/userImageUtils.js +136 -0
  839. package/dist/utils/viewport.d.ts +16 -0
  840. package/dist/utils/viewport.js +30 -0
  841. package/dist/utils/zipPageImages.d.ts +9 -0
  842. package/dist/utils/zipPageImages.js +30 -0
  843. package/package.json +105 -3
@@ -0,0 +1,887 @@
1
+ // SPDX-License-Identifier: MPL-2.0
2
+ /**
3
+ * How each element kind's numbers move when a template is placed on a page of
4
+ * another size (axes: x, y, w, h, font size `s`, icon scale `k`). Every top-level
5
+ * number of a kind is either here or in `UNSCALED_FIELDS` with the reason it stays;
6
+ * `templateGeometry.vitest.ts` builds each kind by its factory and goes red on a
7
+ * number (or number array) that is in neither; the guard runs over the factory default
8
+ * and a populated fixture that sets every optional number. Keyed by `stateKey`, as `BINDABLE_FIELDS` is.
9
+ */
10
+ import { minTextSizePx, parseColor, toHex, } from '@ggraphic/core';
11
+ import { fitFontSizeToSlot, layoutRichTextBlock, PLAIN_STYLE, slotFits, } from '@ggraphic/schema';
12
+ import { aliasFontFamily } from '../utils/fontAliases.js';
13
+ import { GRAIN_SPECK_ALPHA } from '../utils/grainSpec.js';
14
+ import { PAGE_COUNTER_PROBE } from '../utils/pageCounter.js';
15
+ import { plainTextLines } from '../utils/plainTextLayout.js';
16
+ import { bubbleExtent, ringGeometry, tailOf } from '../utils/shapeDevices.js';
17
+ import { usesRichText } from '../utils/textRouting.js';
18
+ import { createRunMeasurer } from '../utils/textUtils.js';
19
+ import { FONT_WIDTHS } from './fontWidths.generated.js';
20
+ import { ASSET_TARGET_SIZE } from '../utils/canvasAssets.js';
21
+ import { ILLUSTRATION_TARGET_SIZE } from '../utils/motifSizes.js';
22
+ import { getAllIllustrations } from '../utils/illustrations/registry.js';
23
+ import { BINDABLE_FIELDS } from '../brand/bindableFields.js';
24
+ import { catalogIconId } from '../utils/iconInstances.js';
25
+ export const TEMPLATE_GEOMETRY = {
26
+ additionalTexts: {
27
+ x: 'x',
28
+ y: 'y',
29
+ width: 'w',
30
+ fontSize: 's',
31
+ // The prototype's size, the ceiling of the fit: scaled like `fontSize`.
32
+ maxFontSize: 's',
33
+ strokeWidth: 's',
34
+ shadowBlur: 's',
35
+ shadowOffsetX: 's',
36
+ shadowOffsetY: 's',
37
+ },
38
+ shapeInstances: {
39
+ x: 'x',
40
+ y: 'y',
41
+ width: 'w',
42
+ height: 'h',
43
+ cornerRadius: 's',
44
+ textGrowth: 's',
45
+ strokeWidth: 's',
46
+ // A number array: every element is a px length and scales like `s`.
47
+ dash: 's',
48
+ shadowBlur: 's',
49
+ shadowOffsetX: 's',
50
+ shadowOffsetY: 's',
51
+ // Ring stroke thickness and speech-bubble tail length: px.
52
+ ringWidth: 's',
53
+ tailSize: 's',
54
+ },
55
+ userImageInstances: {
56
+ x: 'x',
57
+ y: 'y',
58
+ width: 'w',
59
+ height: 'h',
60
+ // A number or a list of four: px, scaled like the shapes' `cornerRadius`.
61
+ cornerRadius: 's',
62
+ blur: 's',
63
+ shadowBlur: 's',
64
+ shadowOffsetX: 's',
65
+ shadowOffsetY: 's',
66
+ },
67
+ chartInstances: { x: 'x', y: 'y', width: 'w', height: 'h' },
68
+ iconStates: { x: 'x', y: 'y', scale: 'k' },
69
+ frameInstances: {
70
+ x: 'x',
71
+ y: 'y',
72
+ width: 'w',
73
+ height: 'h',
74
+ borderWidth: 's',
75
+ cornerRadius: 's',
76
+ // Px inside the frame (`coverPhotoRect` adds them to the centred photo's position).
77
+ imageOffsetX: 's',
78
+ imageOffsetY: 's',
79
+ // A number array: every element is a px length and scales like `s`.
80
+ borderDash: 's',
81
+ shadowBlur: 's',
82
+ shadowOffsetX: 's',
83
+ shadowOffsetY: 's',
84
+ },
85
+ illustrationInstances: { x: 'x', y: 'y', scale: 'k' },
86
+ circleBadgeInstances: { x: 'x', y: 'y', radius: 's' },
87
+ pillBadgeInstances: {
88
+ x: 'x',
89
+ y: 'y',
90
+ fontSize: 's',
91
+ paddingX: 's',
92
+ paddingY: 's',
93
+ cornerRadius: 's',
94
+ },
95
+ page: {},
96
+ };
97
+ /** stateKey → numeric field → why it stays as it is. */
98
+ const RATIO = 'ratio; independent of the page size';
99
+ const ANGLE = 'angle; independent of the page size';
100
+ const OPACITY = 'opacity; independent of the page size';
101
+ const SHADOW_OPACITY = 'opacity; independent of the page size';
102
+ const EM = 'em, relative to the font size; independent of the page size';
103
+ const CANVAS_SHARE = 'a share of the canvas width; independent of the page size';
104
+ const ADJUSTMENT = 'image adjustment (a filter strength or a share); independent of the page size';
105
+ export const UNSCALED_FIELDS = {
106
+ iconStates: { rotation: ANGLE, opacity: OPACITY },
107
+ additionalTexts: {
108
+ rotation: ANGLE,
109
+ scale: RATIO,
110
+ opacity: OPACITY,
111
+ lineHeight: RATIO,
112
+ letterSpacing: EM,
113
+ shadowOpacity: SHADOW_OPACITY,
114
+ },
115
+ shapeInstances: {
116
+ rotation: ANGLE,
117
+ scaleX: RATIO,
118
+ scaleY: RATIO,
119
+ opacity: OPACITY,
120
+ shadowOpacity: SHADOW_OPACITY,
121
+ notch: CANVAS_SHARE,
122
+ grain: OPACITY,
123
+ patternSpacing: CANVAS_SHARE,
124
+ arc: 'a share of the circle; independent of the page size',
125
+ bend: 'a share of the arrow length; independent of the page size',
126
+ tailAt: 'a share of the edge; independent of the page size',
127
+ },
128
+ frameInstances: {
129
+ rotation: ANGLE,
130
+ scaleX: RATIO,
131
+ scaleY: RATIO,
132
+ opacity: OPACITY,
133
+ imageScale: RATIO,
134
+ tilt: ANGLE,
135
+ aspectRatioLock: RATIO,
136
+ },
137
+ illustrationInstances: { rotation: ANGLE, opacity: OPACITY },
138
+ circleBadgeInstances: { rotation: ANGLE, scale: RATIO, opacity: OPACITY },
139
+ pillBadgeInstances: { rotation: ANGLE, scale: RATIO, opacity: OPACITY },
140
+ userImageInstances: {
141
+ rotation: ANGLE,
142
+ scale: RATIO,
143
+ opacity: OPACITY,
144
+ shadowOpacity: SHADOW_OPACITY,
145
+ brightness: ADJUSTMENT,
146
+ contrast: ADJUSTMENT,
147
+ saturation: ADJUSTMENT,
148
+ hue: ADJUSTMENT,
149
+ temperature: ADJUSTMENT,
150
+ tintStrength: ADJUSTMENT,
151
+ vignette: ADJUSTMENT,
152
+ cropZoom: ADJUSTMENT,
153
+ panX: ADJUSTMENT,
154
+ panY: ADJUSTMENT,
155
+ cropRotation: ANGLE,
156
+ notch: CANVAS_SHARE,
157
+ },
158
+ chartInstances: { scale: RATIO, rotation: ANGLE, opacity: OPACITY },
159
+ };
160
+ const UNKNOWN = { kind: 'unknown' };
161
+ /** The square a notch cuts from the top-right corner of `box`, clamped as the renderer clamps it. */
162
+ function notchCut(box, side) {
163
+ if (!box)
164
+ return null;
165
+ const n = Math.min(side, Math.min(box.width, box.height) / 2);
166
+ return { x: box.x + box.width - n, y: box.y, width: n, height: n };
167
+ }
168
+ const ELLIPSE_INSET = 0.98;
169
+ /** The tail a shape record asks for (see `tailOf`), or null. */
170
+ function tailOfRecord(el) {
171
+ const side = el['tailSide'];
172
+ if (side !== 'top' && side !== 'right' && side !== 'bottom' && side !== 'left')
173
+ return null;
174
+ return tailOf({
175
+ type: str(el, 'type'),
176
+ tailSide: side,
177
+ ...(typeof el['tailAt'] === 'number' ? { tailAt: el['tailAt'] } : {}),
178
+ ...(typeof el['tailSize'] === 'number' ? { tailSize: el['tailSize'] } : {}),
179
+ });
180
+ }
181
+ /** A rounded rect's body box: the shape's centre x/y, its size times its scale. */
182
+ function bodyBox(el) {
183
+ const width = num(el, 'width') * Math.abs(num(el, 'scaleX', 1));
184
+ const height = num(el, 'height') * Math.abs(num(el, 'scaleY', 1));
185
+ return { x: num(el, 'x') - width / 2, y: num(el, 'y') - height / 2, width, height };
186
+ }
187
+ /** The largest corner radius of a rounded rect (the renderer's default is 32), clamped to half the short side. */
188
+ function maxRadius(el, body) {
189
+ const radius = el['cornerRadius'];
190
+ const r = Array.isArray(radius)
191
+ ? Math.max(0, ...radius.filter((v) => typeof v === 'number'))
192
+ : typeof radius === 'number'
193
+ ? radius
194
+ : 32;
195
+ return Math.min(Math.max(0, r), Math.min(body.width, body.height) / 2);
196
+ }
197
+ /** What a stroke-drawn shape (ring, arrow) paints: its colour at any strength, over whatever lies beneath. */
198
+ function strokeCover(el, cut) {
199
+ const fill = parseColor(str(el, 'fill'));
200
+ if (!fill || fill.a !== 1)
201
+ return UNKNOWN;
202
+ return {
203
+ kind: 'range',
204
+ fill: str(el, 'fill'),
205
+ alpha: [0, num(el, 'opacity', 1)],
206
+ ...(cut ? { cut } : {}),
207
+ };
208
+ }
209
+ /**
210
+ * What an image paints: every pixel lies between black and white, or between the duotone's two
211
+ * colours when both are set. Anything that can leave that range, or that does not fill the box
212
+ * (a mask, a partial opacity, a tint), is not provable.
213
+ */
214
+ function photoCover(el) {
215
+ const hasTint = str(el, 'tint') !== '' || num(el, 'tintStrength') !== 0;
216
+ // Rounded corners leave the box's corners bare, like a mask.
217
+ const rounded = Array.isArray(el['cornerRadius'])
218
+ ? el['cornerRadius'].some((r) => typeof r === 'number' && r > 0)
219
+ : num(el, 'cornerRadius') > 0;
220
+ if (hasTint || rounded || str(el, 'mask') !== '' || num(el, 'opacity', 1) < 1)
221
+ return UNKNOWN;
222
+ const low = str(el, 'duotoneLow');
223
+ const high = str(el, 'duotoneHigh');
224
+ if (low === '' || high === '')
225
+ return { kind: 'photo', low: '#000000', high: '#ffffff' };
226
+ // The filter chain (`imageFilters.ts`) runs the duotone after every other colour filter,
227
+ // which then maps the photo onto its ramp; only a vignette after it can leave that range.
228
+ const recoloured = num(el, 'vignette') !== 0;
229
+ return recoloured ? UNKNOWN : { kind: 'photo', low, high };
230
+ }
231
+ const isRecord = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
232
+ const str = (el, field) => (typeof el[field] === 'string' ? el[field] : '');
233
+ const num = (el, field, fallback = 0) => {
234
+ const v = el[field];
235
+ return typeof v === 'number' && Number.isFinite(v) ? v : fallback;
236
+ };
237
+ const ROTATED = 'rotated, not checkable';
238
+ const isRotated = (el) => num(el, 'rotation') % 360 !== 0;
239
+ /** The extent of a `width` x `height` rectangle centred on (x, y) and turned by the element's rotation. */
240
+ function turnedAboutCentre(x, y, width, height, el) {
241
+ const angle = (num(el, 'rotation') * Math.PI) / 180;
242
+ const cos = Math.abs(Math.cos(angle));
243
+ const sin = Math.abs(Math.sin(angle));
244
+ const w = width * cos + height * sin;
245
+ const h = width * sin + height * cos;
246
+ return { x: x - w / 2, y: y - h / 2, width: w, height: h };
247
+ }
248
+ /** Editor icons are drawn 120 px across at scale 1, centred on their x/y (as `boundsOf`). */
249
+ const ICON_SIZE = 120;
250
+ /**
251
+ * Text is laid out by the renderer's own code (`plainTextLines`, a port of Konva's wrap, and
252
+ * `layoutRichTextBlock`, routed by `usesRichText` as `CanvasText` routes), with the glyph
253
+ * measure replaced by the widest advance of each code point in the fonts the Studio ships
254
+ * (`fontWidths.generated.ts`, from `scripts/generate-font-widths.mjs`) plus a kerning margin per
255
+ * glyph pair. A width is thus never below what the font draws. A font family without a table, or a
256
+ * code point the tables do not cover (CJK, emoji, a code point the browser draws in a fallback
257
+ * font), cannot be measured: the gate then fails `bounds` closed.
258
+ */
259
+ /** Air kept between a fitted text and the element below it, in lines. */
260
+ const TEXT_GAP = 0.25;
261
+ const FLAT_EM = 1.2; // only to size a box that is flagged anyway
262
+ /**
263
+ * Kerning margin added for every glyph pair. The widest positive pair of the shipped fonts is
264
+ * about 0.15 em (Raleway `qj` is 0.08 em), so 0.06 em is not an upper bound per pair: it is an
265
+ * average margin, and the textLayoutReference fuzz against the real fonts is what holds it.
266
+ */
267
+ const KERN_EM = 0.06;
268
+ const tables = new Map();
269
+ /** `regular` is 400 and `bold` is 700; the other classes carry their weight as the name. */
270
+ const classWeight = (name) => name === 'regular' ? 400 : name === 'bold' ? 700 : Number(name);
271
+ /**
272
+ * The width class that measures `weight`: the class of that weight when the family ships one,
273
+ * else the next heavier one (never narrower than the face drawn), else the heaviest it has.
274
+ */
275
+ const classes = new Map();
276
+ function widthClass(family, weight) {
277
+ const memo = `${family}/${weight}`;
278
+ const known = classes.get(memo);
279
+ if (known !== undefined)
280
+ return known;
281
+ const prefix = `${family}/`;
282
+ const shipped = Object.keys(FONT_WIDTHS)
283
+ .filter((key) => key.startsWith(prefix))
284
+ .map((key) => key.slice(prefix.length))
285
+ .sort((a, b) => classWeight(a) - classWeight(b));
286
+ const picked = shipped.find((name) => classWeight(name) >= weight) ?? shipped.at(-1) ?? null;
287
+ classes.set(memo, picked);
288
+ return picked;
289
+ }
290
+ function widthTable(family, weight) {
291
+ const cls = widthClass(family, weight);
292
+ if (cls === null)
293
+ return null;
294
+ const key = `${family}/${cls}`;
295
+ const cached = tables.get(key);
296
+ if (cached)
297
+ return cached;
298
+ const raw = FONT_WIDTHS[key];
299
+ if (raw === undefined)
300
+ return null;
301
+ const table = new Map();
302
+ for (const entry of raw.split(',')) {
303
+ const [cp, w] = entry.split(':');
304
+ table.set(parseInt(cp, 16), Number(w));
305
+ }
306
+ tables.set(key, table);
307
+ return table;
308
+ }
309
+ /** The first family of a CSS font stack, unquoted and with legacy names replaced. */
310
+ function familyOf(fontFamily) {
311
+ const first = fontFamily
312
+ .split(',')[0]
313
+ ?.trim()
314
+ .replace(/^["']|["']$/g, '') ?? '';
315
+ return first === '' ? '' : aliasFontFamily(first);
316
+ }
317
+ /** The weight a style string asks for: a numeric token, else bold is 700 and the rest 400. */
318
+ function weightOfStyle(style) {
319
+ const numeric = /\b([1-9]00)\b/.exec(style);
320
+ if (numeric)
321
+ return Number(numeric[1]);
322
+ return style.includes('bold') ? 700 : 400;
323
+ }
324
+ /** `normal`, `italic`, `bold` or `bold italic`: a weight of 600 or more, or the word bold, is bold. */
325
+ function normalFontStyle(fontStyle) {
326
+ const tokens = fontStyle.toLowerCase().split(/\s+/);
327
+ const bold = tokens.some((t) => t === 'bold' || t === 'bolder' || (/^\d+$/.test(t) && Number(t) >= 600));
328
+ const italic = tokens.some((t) => t === 'italic' || t === 'oblique');
329
+ return bold ? (italic ? 'bold italic' : 'bold') : italic ? 'italic' : 'normal';
330
+ }
331
+ /** Width of `text` under one face, from the tables; records why it cannot when it cannot. */
332
+ function tableWidth(text, fontSize, family, weight, note) {
333
+ if (text === '')
334
+ return 0;
335
+ const table = widthTable(familyOf(family), weight);
336
+ if (!table) {
337
+ note.reason ??= `text width not checkable (no width table for font "${family}")`;
338
+ }
339
+ let units = 0;
340
+ let count = 0;
341
+ for (const ch of text) {
342
+ const w = table?.get(ch.codePointAt(0));
343
+ if (table && w === undefined) {
344
+ note.reason ??= `text width not checkable (U+${ch.codePointAt(0).toString(16).toUpperCase()} is outside the font tables)`;
345
+ }
346
+ units += w === undefined ? FLAT_EM * 1000 : w;
347
+ count += 1;
348
+ }
349
+ return (units / 1000 + KERN_EM * (count - 1)) * fontSize;
350
+ }
351
+ // No `wrap`, `padding` or `richText`: the renderer passes none of them to the text node, so a
352
+ // template that sets them is drawn with word wrap, no padding and routing by content.
353
+ const textPropsOf = (el) => {
354
+ const accent = el['accent'];
355
+ return {
356
+ // A page counter shows a different numeral on every page: the gate judges the widest one.
357
+ text: el['counter'] === 'page' ? PAGE_COUNTER_PROBE : str(el, 'text'),
358
+ fontSize: num(el, 'fontSize'),
359
+ fontFamily: str(el, 'fontFamily'),
360
+ fontStyle: normalFontStyle(str(el, 'fontStyle')),
361
+ fontWeight: typeof el['fontWeight'] === 'number' ? el['fontWeight'] : null,
362
+ width: num(el, 'width'),
363
+ // em, applied after every glyph by the run measure, as the renderer's Konva nodes do.
364
+ letterSpacing: num(el, 'letterSpacing'),
365
+ accent: isRecord(accent) ? accent : null,
366
+ };
367
+ };
368
+ /** The run measure of the renderer, backed by the tables. */
369
+ function tableRunMeasure(p, note) {
370
+ const accentBold = p.accent?.fontStyle
371
+ ? normalFontStyle(p.accent.fontStyle).includes('bold')
372
+ : false;
373
+ const measured = (text, size, family, style) => {
374
+ // A bold request on an italic run draws the italic face (maybe synthetically emboldened):
375
+ // use the bold table whenever bold is asked anywhere; a numeric weight is the base weight.
376
+ const weight = Math.max(weightOfStyle(style), p.fontWeight ?? (p.fontStyle.includes('bold') ? 700 : 400), accentBold ? 700 : 400);
377
+ return tableWidth(text, size, family, weight, note);
378
+ };
379
+ return createRunMeasurer(measured, p.fontSize, p.fontFamily, p.fontStyle, p.accent, p.fontWeight, p.letterSpacing);
380
+ }
381
+ /** Line count of a text by the renderer's own layout. */
382
+ function layoutText(p) {
383
+ const note = { reason: null };
384
+ const run = tableRunMeasure(p, note);
385
+ const inner = p.width > 0 ? p.width : Number.POSITIVE_INFINITY;
386
+ let widths;
387
+ if (usesRichText({ text: p.text, width: p.width }, run)) {
388
+ widths = layoutRichTextBlock(p.text, inner, run).map((line) => {
389
+ const last = line.runs.at(-1);
390
+ return last ? line.indent + last.x + run(last.text, last) : line.indent;
391
+ });
392
+ }
393
+ else {
394
+ widths = plainTextLines(p.text, inner, (text) => run(text, PLAIN_STYLE)).map((line) => run(line, PLAIN_STYLE));
395
+ }
396
+ return {
397
+ lines: Math.max(1, widths.length),
398
+ widest: Math.max(0, ...widths),
399
+ unmeasurable: note.reason,
400
+ };
401
+ }
402
+ /**
403
+ * Fits a text to its box in its own font: the largest size from the legibility floor up to
404
+ * `maxFontSize` at which no word is wider than the box (words are never broken) and the lines,
405
+ * counted by the same layout as the gate, stay within `maxLines` (or the box `height`, when the
406
+ * element has one). Measured with the width tables like `layoutText`, so fitting and gate agree.
407
+ */
408
+ function fitTextToBox(el, req) {
409
+ const props = textPropsOf(el);
410
+ const max = num(el, 'maxFontSize');
411
+ if (!(max > 0) || !(props.width > 0))
412
+ return null;
413
+ const height = num(el, 'height');
414
+ const slot = {
415
+ width: props.width,
416
+ maxHeight: height > 0 ? height : Number.POSITIVE_INFINITY,
417
+ ...(req.maxHeight === undefined ? {} : { room: req.maxHeight }),
418
+ // A quarter line of air above whatever lies below.
419
+ gap: req.maxHeight === undefined ? 0 : TEXT_GAP,
420
+ fontSize: max,
421
+ maxSize: max,
422
+ minSize: Math.min(minTextSizePx(req.canvasHeight), max),
423
+ lineHeight: num(el, 'lineHeight', 1.2),
424
+ wholeWords: true,
425
+ ...(req.maxLines === undefined ? {} : { maxLines: req.maxLines }),
426
+ countLines: (size) => layoutText({ ...props, fontSize: size }).lines,
427
+ };
428
+ const measureAt = (size) => (text) => tableRunMeasure({ ...props, fontSize: size }, { reason: null })(text, PLAIN_STYLE);
429
+ // The room below is a preference, not a rule the template can always keep: its own stacks are
430
+ // sometimes tighter than a quarter line. Try room plus air, then room alone, then width and
431
+ // lines only; a later step never makes a text that fitted under an earlier one worse.
432
+ const { room: _room, ...unlimited } = slot;
433
+ const steps = slot.room === undefined ? [slot] : [slot, { ...slot, gap: 0 }, { ...unlimited, gap: 0 }];
434
+ let last = { fontSize: max, fits: false };
435
+ for (const step of steps) {
436
+ const fontSize = fitFontSizeToSlot(props.text, step, measureAt);
437
+ last = { fontSize, fits: slotFits(props.text, step, measureAt, fontSize) };
438
+ if (last.fits)
439
+ break;
440
+ }
441
+ return last;
442
+ }
443
+ /** The widest explicit line of a text that does not wrap (a badge), and how many lines it has. */
444
+ function widestLine(text, fontSize, fontFamily, fontStyle) {
445
+ const note = { reason: null };
446
+ const weight = normalFontStyle(fontStyle).includes('bold') ? 700 : 400;
447
+ const parts = text.split('\n');
448
+ const width = Math.max(...parts.map((line) => tableWidth(line, fontSize, fontFamily, weight, note)));
449
+ return { width, lines: parts.length, unmeasurable: note.reason };
450
+ }
451
+ /**
452
+ * `BINDABLE_FIELDS` without the fields that are not colours: fonts, and `src` (bound only to the logo).
453
+ */
454
+ const COLOR_FIELDS = Object.fromEntries(Object.entries(BINDABLE_FIELDS).map(([key, fields]) => [
455
+ key,
456
+ fields.filter((field) => field !== 'src' && !field.startsWith('font')),
457
+ ]));
458
+ /**
459
+ * stateKey -> fields that name an image file. `templateGeometry.vitest.ts` goes red on a string
460
+ * field of a kind that looks like one (`src`, `imageSrc`, ...) and is not listed here.
461
+ */
462
+ export const ASSET_FIELDS = {
463
+ userImageInstances: ['src'],
464
+ frameInstances: ['imageSrc'],
465
+ assetInstances: ['src'],
466
+ };
467
+ /**
468
+ * The lookup over a list of definitions, first match wins (the registry's order: kawaii, then
469
+ * the SVG sets). A host builds it from its catalogue with `loadIllustrationLookup`.
470
+ */
471
+ export const illustrationLookup = (defs) => (id) => defs.find((def) => def.id === id);
472
+ /** The lookup over the registered catalogue: the same data `findIllustrationById` reads. */
473
+ export async function loadIllustrationLookup() {
474
+ return illustrationLookup(await getAllIllustrations());
475
+ }
476
+ /**
477
+ * The gate adapter. `lookup` resolves an illustration id the way the renderer does; the renderer
478
+ * ignores an element's declared `source`, so the gate must not trust it either.
479
+ */
480
+ export function createTemplateGateAdapter(lookup) {
481
+ const adapter = {
482
+ geometry: TEMPLATE_GEOMETRY,
483
+ colorFields: COLOR_FIELDS,
484
+ assetFields: ASSET_FIELDS,
485
+ nestedColors(stateKey, el) {
486
+ const out = [];
487
+ const add = (field, value) => {
488
+ if (typeof value === 'string')
489
+ out.push({ field, value });
490
+ };
491
+ const stops = (field, gradient) => {
492
+ const list = isRecord(gradient) ? gradient['stops'] : null;
493
+ if (Array.isArray(list))
494
+ for (const stop of list)
495
+ if (isRecord(stop))
496
+ add(field, stop['color']);
497
+ };
498
+ if (stateKey === 'shapeInstances' || stateKey === 'additionalTexts') {
499
+ stops('fillGradient', el['fillGradient']);
500
+ }
501
+ if (stateKey === 'additionalTexts') {
502
+ if (isRecord(el['accent']))
503
+ add('accent', el['accent']['fill']);
504
+ if (isRecord(el['marker'])) {
505
+ add('marker', el['marker']['fill']);
506
+ add('marker', el['marker']['color']);
507
+ }
508
+ }
509
+ if (stateKey === 'chartInstances' && Array.isArray(el['colors'])) {
510
+ for (const color of el['colors'])
511
+ add('colors', color);
512
+ }
513
+ return out;
514
+ },
515
+ assetRefs(stateKey, el, id) {
516
+ if (stateKey === 'illustrationInstances') {
517
+ const illustrationId = str(el, 'illustrationId');
518
+ const def = lookup(illustrationId);
519
+ // Kawaii art is drawn from the instance's own id when `source` says kawaii; any other
520
+ // source is resolved by id alone and the declared `source` is never read.
521
+ const kawaiiMismatch = el['source'] === 'kawaii' && def?.source !== 'kawaii';
522
+ return [
523
+ {
524
+ kind: 'illustration',
525
+ id: def && !kawaiiMismatch
526
+ ? `${def.source}:${illustrationId}`
527
+ : `unresolved:${illustrationId}`,
528
+ },
529
+ ];
530
+ }
531
+ if (stateKey === 'assetInstances') {
532
+ const assetId = str(el, 'assetId');
533
+ return [{ kind: assetId.startsWith('emoji-') ? 'emoji' : 'sticker', id: assetId }];
534
+ }
535
+ if (stateKey === 'iconStates') {
536
+ const catalogId = catalogIconId(id, { [id]: el });
537
+ // A stored SVG copy is what gets drawn, whatever `iconId` or `source` claim. It cannot be
538
+ // checked against the set offline, so a template may not carry one.
539
+ if (str(el, 'svg') !== '' || isRecord(el['source'])) {
540
+ return [{ kind: 'stored-svg', id: catalogId }];
541
+ }
542
+ return [{ kind: 'icon', id: catalogId.replace(/^iconify:/, '') }];
543
+ }
544
+ return [];
545
+ },
546
+ fitText: fitTextToBox,
547
+ textExtent(el) {
548
+ const p = textPropsOf(el);
549
+ if (!(p.width > 0) || !(p.fontSize > 0))
550
+ return null;
551
+ const { lines, widest, unmeasurable } = layoutText(p);
552
+ if (unmeasurable)
553
+ return null;
554
+ const scale = num(el, 'scale', 1) || 1;
555
+ return { lines, width: widest * scale };
556
+ },
557
+ placeBox(stateKey, el, box) {
558
+ // Only an upright plate: a shape is positioned by its centre, its size is the box over its scale.
559
+ if (stateKey !== 'shapeInstances' || isRotated(el))
560
+ return { ...el };
561
+ return {
562
+ ...el,
563
+ x: box.x + box.width / 2,
564
+ y: box.y + box.height / 2,
565
+ width: box.width / (num(el, 'scaleX', 1) || 1),
566
+ height: box.height / (num(el, 'scaleY', 1) || 1),
567
+ };
568
+ },
569
+ lineCount(stateKey, el) {
570
+ if (stateKey !== 'additionalTexts' || typeof el['text'] !== 'string')
571
+ return 1;
572
+ return layoutText(textPropsOf(el)).lines;
573
+ },
574
+ boundsProblem(stateKey, el) {
575
+ // Images, frames and charts turn about a pivot of their own and their paint is not
576
+ // modelled: a rotated one cannot be placed against a frame.
577
+ if ((stateKey === 'userImageInstances' ||
578
+ stateKey === 'frameInstances' ||
579
+ stateKey === 'chartInstances') &&
580
+ isRotated(el)) {
581
+ return ROTATED;
582
+ }
583
+ return null;
584
+ },
585
+ box(stateKey, el, lines) {
586
+ const x = num(el, 'x');
587
+ const y = num(el, 'y');
588
+ switch (stateKey) {
589
+ case 'additionalTexts': {
590
+ // The node is scaled as a whole: layout at the unscaled width, drawn `scale` times larger.
591
+ const scale = num(el, 'scale', 1) || 1;
592
+ return {
593
+ x,
594
+ y,
595
+ width: num(el, 'width') * scale,
596
+ height: num(el, 'fontSize') * num(el, 'lineHeight', 1.2) * lines * scale,
597
+ };
598
+ }
599
+ case 'shapeInstances': {
600
+ const width = num(el, 'width') * num(el, 'scaleX', 1);
601
+ const height = num(el, 'height') * num(el, 'scaleY', 1);
602
+ // A shape turns about its centre: its extent is the box of the turned rectangle.
603
+ const angle = (num(el, 'rotation') * Math.PI) / 180;
604
+ const cos = Math.abs(Math.cos(angle));
605
+ const sin = Math.abs(Math.sin(angle));
606
+ const w = width * cos + height * sin;
607
+ const h = width * sin + height * cos;
608
+ const turned = { x: x - w / 2, y: y - h / 2, width: w, height: h };
609
+ const sx = Math.abs(num(el, 'scaleX', 1));
610
+ const sy = Math.abs(num(el, 'scaleY', 1));
611
+ const rotated = isRotated(el);
612
+ // A speech bubble's tail lies outside its width × height.
613
+ const tail = tailOfRecord(el);
614
+ if (tail) {
615
+ if (rotated) {
616
+ const reach = tail.size * Math.max(sx, sy);
617
+ return {
618
+ x: turned.x - reach,
619
+ y: turned.y - reach,
620
+ width: turned.width + 2 * reach,
621
+ height: turned.height + 2 * reach,
622
+ };
623
+ }
624
+ const out = bubbleExtent(width, height, {
625
+ side: tail.side,
626
+ size: tail.size * (tail.side === 'left' || tail.side === 'right' ? sx : sy),
627
+ });
628
+ return {
629
+ x: turned.x + out.x,
630
+ y: turned.y + out.y,
631
+ width: out.width,
632
+ height: out.height,
633
+ };
634
+ }
635
+ // A bent arrow's curve lies off its (flat) box; the margin covers the head and the spline.
636
+ const bend = num(el, 'bend');
637
+ if (el['type'] === 'line-arrow' && bend !== 0) {
638
+ const stroke = num(el, 'strokeWidth', 6);
639
+ const sag = bend * num(el, 'width') * sy * 1.1;
640
+ const pad = Math.max(16, stroke * 2.5) / 2 + stroke / 2;
641
+ if (rotated) {
642
+ const reach = Math.abs(sag) + pad;
643
+ return {
644
+ x: turned.x - reach,
645
+ y: turned.y - reach,
646
+ width: turned.width + 2 * reach,
647
+ height: turned.height + 2 * reach,
648
+ };
649
+ }
650
+ const top = Math.min(turned.y, y + Math.min(0, sag) - pad);
651
+ const bottom = Math.max(turned.y + turned.height, y + Math.max(0, sag) + pad);
652
+ return { x: turned.x, y: top, width: turned.width, height: bottom - top };
653
+ }
654
+ return turned;
655
+ }
656
+ case 'chartInstances': {
657
+ const scale = num(el, 'scale', 1) || 1;
658
+ return { x, y, width: num(el, 'width') * scale, height: num(el, 'height') * scale };
659
+ }
660
+ case 'userImageInstances': {
661
+ // Scaled about its top-left, as the image group draws it.
662
+ const scale = num(el, 'scale', 1) || 1;
663
+ return { x, y, width: num(el, 'width') * scale, height: num(el, 'height') * scale };
664
+ }
665
+ case 'iconStates': {
666
+ // An icon turns about its centre: its extent is the box of the turned square.
667
+ const angle = (num(el, 'rotation') * Math.PI) / 180;
668
+ const turn = Math.abs(Math.cos(angle)) + Math.abs(Math.sin(angle));
669
+ const size = ICON_SIZE * num(el, 'scale', 1) * turn;
670
+ return { x: x - size / 2, y: y - size / 2, width: size, height: size };
671
+ }
672
+ case 'illustrationInstances':
673
+ case 'assetInstances': {
674
+ // Both turn about their centre. A sticker's image ratio is not known here: its longer
675
+ // side is ASSET_TARGET_SIZE, so the square of that side bounds it.
676
+ const target = stateKey === 'assetInstances' ? ASSET_TARGET_SIZE : ILLUSTRATION_TARGET_SIZE;
677
+ return turnedAboutCentre(x, y, target * num(el, 'scale', 1), target * num(el, 'scale', 1), el);
678
+ }
679
+ case 'frameInstances':
680
+ return turnedAboutCentre(x, y, num(el, 'width') * Math.abs(num(el, 'scaleX', 1)), num(el, 'height') * Math.abs(num(el, 'scaleY', 1)), el);
681
+ case 'pillBadgeInstances': {
682
+ // Top-left anchored; the text is as wide as its widest line, one line per break.
683
+ const scale = num(el, 'scale', 1);
684
+ const fontSize = num(el, 'fontSize');
685
+ const { width, lines: count } = widestLine(str(el, 'text'), fontSize, str(el, 'fontFamily'), str(el, 'fontStyle'));
686
+ return {
687
+ x,
688
+ y,
689
+ width: (width + num(el, 'paddingX') * 2) * scale,
690
+ height: (count * fontSize + num(el, 'paddingY') * 2) * scale,
691
+ };
692
+ }
693
+ case 'circleBadgeInstances': {
694
+ const radius = num(el, 'radius') * num(el, 'scale', 1);
695
+ return { x: x - radius, y: y - radius, width: radius * 2, height: radius * 2 };
696
+ }
697
+ default:
698
+ return null;
699
+ }
700
+ },
701
+ text(stateKey, el) {
702
+ const opacity = num(el, 'opacity', 1);
703
+ const rotated = isRotated(el);
704
+ const scale = num(el, 'scale', 1) || 1;
705
+ if (stateKey === 'additionalTexts') {
706
+ const props = textPropsOf(el);
707
+ const boundsProblem = rotated ? ROTATED : layoutText(props).unmeasurable;
708
+ return {
709
+ fill: typeof el['fill'] === 'string' ? el['fill'] : '',
710
+ fontSize: props.fontSize * scale,
711
+ bold: props.fontWeight !== null ? props.fontWeight >= 700 : props.fontStyle.includes('bold'),
712
+ opacity,
713
+ ...(boundsProblem ? { boundsProblem } : {}),
714
+ ...(el['fillGradient'] ? { notCheckable: 'text gradient not checkable' } : {}),
715
+ };
716
+ }
717
+ if (stateKey === 'pillBadgeInstances') {
718
+ const fontSize = num(el, 'fontSize');
719
+ const boundsProblem = rotated
720
+ ? ROTATED
721
+ : widestLine(str(el, 'text'), fontSize, str(el, 'fontFamily'), str(el, 'fontStyle'))
722
+ .unmeasurable;
723
+ return {
724
+ fill: str(el, 'textColor'),
725
+ fontSize: fontSize * scale,
726
+ bold: normalFontStyle(str(el, 'fontStyle')).includes('bold'),
727
+ opacity,
728
+ ground: str(el, 'backgroundColor'),
729
+ ...(boundsProblem ? { boundsProblem } : {}),
730
+ };
731
+ }
732
+ if (stateKey === 'circleBadgeInstances') {
733
+ // Judged on its smallest line, and bold only when every line is.
734
+ const lines = Array.isArray(el['textLines']) ? el['textLines'].filter(isRecord) : [];
735
+ // Each line is a centred, one-line box 2r wide; its rectangle must sit in the disc.
736
+ const radius = num(el, 'radius');
737
+ let boundsProblem = rotated ? ROTATED : null;
738
+ for (const l of lines) {
739
+ if (boundsProblem || str(l, 'text') === '')
740
+ continue;
741
+ const fontSize = num(l, 'fontSize');
742
+ const { width, lines: count, unmeasurable, } = widestLine(str(l, 'text'), fontSize, str(l, 'fontFamily'), l['fontWeight'] === 'bold' ? 'bold' : 'normal');
743
+ const reach = Math.abs(num(l, 'yOffset')) + fontSize / 2;
744
+ if (unmeasurable)
745
+ boundsProblem = unmeasurable;
746
+ else if (count > 1 || width > radius * 2)
747
+ boundsProblem = 'text wraps inside the disc';
748
+ else if (Math.hypot(width / 2, reach) > radius)
749
+ boundsProblem = 'text leaves the disc';
750
+ }
751
+ return {
752
+ fill: str(el, 'textColor'),
753
+ fontSize: (lines.length ? Math.min(...lines.map((l) => num(l, 'fontSize'))) : 0) * scale,
754
+ bold: lines.length > 0 && lines.every((l) => l['fontWeight'] === 'bold'),
755
+ opacity,
756
+ ground: str(el, 'backgroundColor'),
757
+ ...(boundsProblem ? { boundsProblem } : {}),
758
+ };
759
+ }
760
+ return null;
761
+ },
762
+ cover(stateKey, el, canvasWidth) {
763
+ // Texts paint no ground. A flat opaque shape is one, a photo is a range of grounds, a
764
+ // translucent shape, a glow, grain or a shade is an overlay; every other kind (frame,
765
+ // chart, badge, icon, sticker, illustration) is not provably any of them.
766
+ if (stateKey === 'additionalTexts')
767
+ return null;
768
+ const blend = el['blendMode'];
769
+ const untransformed = (blend === undefined || blend === 'normal') && !isRotated(el);
770
+ const notch = num(el, 'notch');
771
+ const cut = notch > 0 ? notchCut(adapter.box(stateKey, el, 1), notch * canvasWidth) : null;
772
+ if (stateKey === 'userImageInstances') {
773
+ const photo = untransformed ? photoCover(el) : UNKNOWN;
774
+ return cut && photo ? { ...photo, cut } : photo;
775
+ }
776
+ if (stateKey !== 'shapeInstances')
777
+ return UNKNOWN;
778
+ const type = el['type'];
779
+ const shade = el['shade'];
780
+ const gradientSet = el['fillGradient'] !== undefined && el['fillGradient'] !== null;
781
+ if (type === 'ring' || type === 'line-arrow') {
782
+ // A stroke is its colour at any strength over what lies beneath, wherever a text may meet it.
783
+ if (!untransformed || gradientSet || shade || el['glow'] === true)
784
+ return UNKNOWN;
785
+ if (type === 'line-arrow')
786
+ return strokeCover(el);
787
+ const width = num(el, 'width');
788
+ if (Math.abs(width - num(el, 'height')) > 0.5)
789
+ return UNKNOWN;
790
+ // The hole is bare: a text wholly inside the largest rectangle the inner ellipse holds is
791
+ // not on the ring. One half in it lies on two grounds (the gate fails that closed).
792
+ const { inner } = ringGeometry(width, typeof el['ringWidth'] === 'number' ? el['ringWidth'] : undefined, typeof el['arc'] === 'number' ? el['arc'] : undefined);
793
+ const halfW = (inner * Math.abs(num(el, 'scaleX', 1)) * ELLIPSE_INSET) / Math.SQRT2;
794
+ const halfH = (inner * Math.abs(num(el, 'scaleY', 1)) * ELLIPSE_INSET) / Math.SQRT2;
795
+ const hole = halfW > 0 && halfH > 0
796
+ ? {
797
+ x: num(el, 'x') - halfW,
798
+ y: num(el, 'y') - halfH,
799
+ width: 2 * halfW,
800
+ height: 2 * halfH,
801
+ }
802
+ : undefined;
803
+ return strokeCover(el, hole);
804
+ }
805
+ if (type === 'rounded-rect') {
806
+ // A flat opaque rounded box is a ground inside its corner arcs; a tail is part of the same
807
+ // fill but lies outside `inner`, so a text meeting it is not judged. Any further paint
808
+ // (gradient, shade, glow, texture) is not modelled here.
809
+ const paint = parseColor(str(el, 'fill'));
810
+ if (!untransformed || !paint || gradientSet || shade || el['glow'] === true)
811
+ return UNKNOWN;
812
+ if (el['pattern'] !== undefined || num(el, 'grain') > 0 || num(el, 'notch') > 0) {
813
+ return UNKNOWN;
814
+ }
815
+ const body = bodyBox(el);
816
+ const r = maxRadius(el, body);
817
+ // An arc of radius r leaves r(1 − 1/√2) ≈ 0.293 r bare on each axis; 0.3 keeps a margin.
818
+ const dx = 0.3 * r * Math.abs(num(el, 'scaleX', 1));
819
+ const dy = 0.3 * r * Math.abs(num(el, 'scaleY', 1));
820
+ const inner = {
821
+ x: body.x + dx,
822
+ y: body.y + dy,
823
+ width: Math.max(0, body.width - 2 * dx),
824
+ height: Math.max(0, body.height - 2 * dy),
825
+ };
826
+ const alpha = num(el, 'opacity', 1) * paint.a;
827
+ return alpha < 1
828
+ ? { kind: 'veil', fill: toHex({ ...paint, a: 1 }), alpha, inner }
829
+ : { kind: 'solid', fill: str(el, 'fill'), inner };
830
+ }
831
+ const glow = el['glow'] === true && (shade === undefined || shade === null);
832
+ // Only a plain rectangle fills its box; any other shape (or rounded corners) leaves
833
+ // parts of the box bare, and a text there sits on whatever lies below. A glow ellipse
834
+ // is the exception: its bare corners are glow alpha 0, inside the range it judges.
835
+ const plain = type === undefined || type === 'rect' || (glow && type === 'ellipse');
836
+ if (!plain || num(el, 'cornerRadius') !== 0)
837
+ return UNKNOWN;
838
+ const gradient = el['fillGradient'];
839
+ const fill = parseColor(str(el, 'fill'));
840
+ if (!untransformed || !fill)
841
+ return UNKNOWN;
842
+ // Stripes are judged by their colour as well as the fill; one that cannot be read is not provable.
843
+ const stripeColor = parseColor(str(el, 'patternColor'));
844
+ if (el['pattern'] === 'stripes' && (!stripeColor || stripeColor.a !== 1))
845
+ return UNKNOWN;
846
+ const stripes = el['pattern'] === 'stripes' ? str(el, 'patternColor') : null;
847
+ const grainAmount = Math.min(1, num(el, 'grain'));
848
+ const mods = {
849
+ ...(cut ? { cut } : {}),
850
+ ...(el['pattern'] === 'dots' ? { dots: true } : {}),
851
+ ...(stripes ? { stripes } : {}),
852
+ ...(grainAmount > 0
853
+ ? {
854
+ grain: {
855
+ fill: el['grainTone'] === 'light' ? '#ffffff' : '#000000',
856
+ alpha: [0, (grainAmount * GRAIN_SPECK_ALPHA) / 255],
857
+ },
858
+ }
859
+ : {}),
860
+ };
861
+ if (shade === 'bottom' || shade === 'top') {
862
+ return fill.a === 1 && num(el, 'opacity', 1) === 1
863
+ ? { kind: 'shade', fill: str(el, 'fill'), direction: shade, ...mods }
864
+ : UNKNOWN;
865
+ }
866
+ if (shade || (!glow && gradient !== undefined && gradient !== null))
867
+ return UNKNOWN;
868
+ if (glow) {
869
+ // Full `fill` at the centre, nothing at the edge: an alpha anywhere in [0, opacity].
870
+ return fill.a === 1
871
+ ? {
872
+ kind: 'range',
873
+ fill: str(el, 'fill'),
874
+ alpha: [0, num(el, 'opacity', 1)],
875
+ ...mods,
876
+ }
877
+ : UNKNOWN;
878
+ }
879
+ const alpha = num(el, 'opacity', 1) * fill.a;
880
+ if (alpha < 1)
881
+ return { kind: 'veil', fill: toHex({ ...fill, a: 1 }), alpha, ...mods };
882
+ return { kind: 'solid', fill: str(el, 'fill'), ...mods };
883
+ },
884
+ };
885
+ return adapter;
886
+ }
887
+ export const TEMPLATE_GATE_ADAPTER = createTemplateGateAdapter(() => undefined);