kritzel-stencil 0.0.172 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (403) hide show
  1. package/dist/cjs/app-globals-V2Kpy_OQ.js +0 -3
  2. package/dist/cjs/{default-line-tool.config-JuTDR6PF.js → default-line-tool.config-7eJND6Jb.js} +1516 -206
  3. package/dist/cjs/index-BeKMS-Zt.js +3280 -0
  4. package/dist/cjs/index.cjs.js +10 -7
  5. package/dist/cjs/kritzel-brush-style.cjs.entry.js +3 -4
  6. package/dist/cjs/kritzel-color_22.cjs.entry.js +103 -66
  7. package/dist/cjs/loader.cjs.js +2 -3
  8. package/dist/cjs/stencil.cjs.js +3 -4
  9. package/dist/collection/classes/core/core.class.js +0 -1
  10. package/dist/collection/classes/core/reviver.class.js +0 -1
  11. package/dist/collection/classes/core/store.class.js +0 -1
  12. package/dist/collection/classes/core/viewport.class.js +0 -1
  13. package/dist/collection/classes/core/workspace.class.js +0 -1
  14. package/dist/collection/classes/handlers/base.handler.js +0 -1
  15. package/dist/collection/classes/handlers/context-menu.handler.js +0 -1
  16. package/dist/collection/classes/handlers/hover.handler.js +0 -1
  17. package/dist/collection/classes/handlers/key.handler.js +0 -1
  18. package/dist/collection/classes/handlers/line-handle.handler.js +0 -1
  19. package/dist/collection/classes/handlers/move.handler.js +0 -1
  20. package/dist/collection/classes/handlers/resize.handler.js +0 -1
  21. package/dist/collection/classes/handlers/rotation.handler.js +0 -1
  22. package/dist/collection/classes/handlers/selection.handler.js +0 -1
  23. package/dist/collection/classes/managers/anchor.manager.js +0 -1
  24. package/dist/collection/classes/managers/cursor.manager.js +0 -1
  25. package/dist/collection/classes/objects/base-object.class.js +0 -1
  26. package/dist/collection/classes/objects/custom-element.class.js +0 -1
  27. package/dist/collection/classes/objects/group.class.js +0 -1
  28. package/dist/collection/classes/objects/image.class.js +0 -1
  29. package/dist/collection/classes/objects/line.class.js +0 -1
  30. package/dist/collection/classes/objects/path.class.js +0 -1
  31. package/dist/collection/classes/objects/selection-box.class.js +0 -1
  32. package/dist/collection/classes/objects/selection-group.class.js +0 -1
  33. package/dist/collection/classes/objects/shape.class.js +0 -1
  34. package/dist/collection/classes/objects/text.class.js +0 -1
  35. package/dist/collection/classes/providers/broadcast-sync-provider.class.js +0 -1
  36. package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js +0 -1
  37. package/dist/collection/classes/providers/indexeddb-sync-provider.class.js +0 -1
  38. package/dist/collection/classes/providers/websocket-sync-provider.class.js +0 -1
  39. package/dist/collection/classes/registries/icon-registry.class.js +0 -1
  40. package/dist/collection/classes/registries/tool.registry.js +0 -1
  41. package/dist/collection/classes/structures/app-state-map.structure.js +0 -1
  42. package/dist/collection/classes/structures/object-map.structure.js +0 -1
  43. package/dist/collection/classes/structures/quadtree.structure.js +0 -1
  44. package/dist/collection/classes/tools/base-tool.class.js +0 -1
  45. package/dist/collection/classes/tools/brush-tool.class.js +0 -1
  46. package/dist/collection/classes/tools/eraser-tool.class.js +0 -1
  47. package/dist/collection/classes/tools/image-tool.class.js +0 -1
  48. package/dist/collection/classes/tools/line-tool.class.js +0 -1
  49. package/dist/collection/classes/tools/selection-tool.class.js +0 -1
  50. package/dist/collection/classes/tools/shape-tool.class.js +0 -1
  51. package/dist/collection/classes/tools/text-tool.class.js +0 -1
  52. package/dist/collection/collection-manifest.json +2 -2
  53. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +0 -1
  54. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +1 -2
  55. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +3 -4
  56. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +0 -1
  57. package/dist/collection/components/shared/kritzel-color/kritzel-color.js +0 -1
  58. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +8 -3
  59. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +8 -20
  60. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +1 -2
  61. package/dist/collection/components/shared/kritzel-font/kritzel-font.js +0 -1
  62. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +0 -1
  63. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +8 -3
  64. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +0 -1
  65. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +0 -1
  66. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +0 -1
  67. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +0 -1
  68. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +0 -1
  69. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +0 -1
  70. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +0 -1
  71. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +0 -1
  72. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +0 -1
  73. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +1 -2
  74. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +0 -1
  75. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +0 -1
  76. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +0 -1
  77. package/dist/collection/configs/default-brush-tool.config.js +0 -1
  78. package/dist/collection/configs/default-engine-config.js +0 -1
  79. package/dist/collection/configs/default-line-tool.config.js +0 -1
  80. package/dist/collection/configs/default-shape-tool.config.js +0 -1
  81. package/dist/collection/configs/default-sync.config.js +0 -1
  82. package/dist/collection/configs/default-text-tool.config.js +0 -1
  83. package/dist/collection/constants/core.constants.js +0 -1
  84. package/dist/collection/constants/engine.constants.js +0 -1
  85. package/dist/collection/enums/event-button.enum.js +0 -1
  86. package/dist/collection/enums/handle-type.enum.js +0 -1
  87. package/dist/collection/enums/shape-type.enum.js +0 -1
  88. package/dist/collection/helpers/class.helper.js +0 -1
  89. package/dist/collection/helpers/cursor.helper.js +0 -1
  90. package/dist/collection/helpers/devices.helper.js +0 -1
  91. package/dist/collection/helpers/event.helper.js +0 -1
  92. package/dist/collection/helpers/geometry.helper.js +0 -1
  93. package/dist/collection/helpers/html.helper.js +0 -1
  94. package/dist/collection/helpers/keyboard.helper.js +0 -1
  95. package/dist/collection/helpers/math.helper.js +0 -1
  96. package/dist/collection/helpers/object.helper.js +0 -1
  97. package/dist/collection/index.js +0 -1
  98. package/dist/collection/interfaces/anchor.interface.js +0 -1
  99. package/dist/collection/interfaces/arrow-head.interface.js +0 -1
  100. package/dist/collection/interfaces/bounding-box.interface.js +0 -1
  101. package/dist/collection/interfaces/clonable.interface.js +0 -1
  102. package/dist/collection/interfaces/context-menu-item.interface.js +0 -1
  103. package/dist/collection/interfaces/debug-info.interface.js +0 -1
  104. package/dist/collection/interfaces/engine-state.interface.js +0 -1
  105. package/dist/collection/interfaces/line-options.interface.js +0 -1
  106. package/dist/collection/interfaces/menu-item.interface.js +0 -1
  107. package/dist/collection/interfaces/object.interface.js +0 -1
  108. package/dist/collection/interfaces/path-options.interface.js +0 -1
  109. package/dist/collection/interfaces/point.interface.js +0 -1
  110. package/dist/collection/interfaces/polygon.interface.js +0 -1
  111. package/dist/collection/interfaces/selection-state.interface.js +0 -1
  112. package/dist/collection/interfaces/serializable.interface.js +0 -1
  113. package/dist/collection/interfaces/shortcut.interface.js +0 -1
  114. package/dist/collection/interfaces/sync-config.interface.js +0 -1
  115. package/dist/collection/interfaces/sync-provider.interface.js +0 -1
  116. package/dist/collection/interfaces/tool.interface.js +0 -1
  117. package/dist/collection/interfaces/toolbar-control.interface.js +0 -1
  118. package/dist/collection/interfaces/undo-state.interface.js +0 -1
  119. package/dist/collection/types/deep-readonly.type.js +0 -1
  120. package/dist/collection/types/state.types.js +0 -1
  121. package/dist/components/index.d.ts +1 -0
  122. package/dist/components/index.js +1 -1477
  123. package/dist/components/kritzel-brush-style.js +1 -67
  124. package/dist/components/kritzel-color-palette.js +1 -9
  125. package/dist/components/kritzel-color.js +1 -9
  126. package/dist/components/kritzel-context-menu.js +1 -9
  127. package/dist/components/kritzel-control-brush-config.js +1 -9
  128. package/dist/components/kritzel-control-text-config.js +1 -9
  129. package/dist/components/kritzel-controls.js +1 -9
  130. package/dist/components/kritzel-cursor-trail.js +1 -9
  131. package/dist/components/kritzel-dropdown.js +1 -9
  132. package/dist/components/kritzel-editor.js +1 -605
  133. package/dist/components/kritzel-engine.js +1 -9
  134. package/dist/components/kritzel-font-family.js +1 -9
  135. package/dist/components/kritzel-font-size.js +1 -9
  136. package/dist/components/kritzel-font.js +1 -9
  137. package/dist/components/kritzel-icon.js +1 -9
  138. package/dist/components/kritzel-menu-item.js +1 -9
  139. package/dist/components/kritzel-menu.js +1 -9
  140. package/dist/components/kritzel-portal.js +1 -9
  141. package/dist/components/kritzel-split-button.js +1 -9
  142. package/dist/components/kritzel-stroke-size.js +1 -9
  143. package/dist/components/kritzel-tooltip.js +1 -9
  144. package/dist/components/kritzel-utility-panel.js +1 -9
  145. package/dist/components/kritzel-workspace-manager.js +1 -9
  146. package/dist/components/p-1z-ds26_.js +1 -0
  147. package/dist/components/p-4FEa4ADy.js +1 -0
  148. package/dist/components/p-B0kd2rUI.js +1 -16
  149. package/dist/components/p-B7Fdo5QJ.js +1 -0
  150. package/dist/components/p-BXaWhpO2.js +1 -0
  151. package/dist/components/p-Bj_Og27M.js +1 -0
  152. package/dist/components/p-BtuXeItZ.js +1 -0
  153. package/dist/components/p-C-d2IH4v.js +1 -0
  154. package/dist/components/p-C3UriJh7.js +1 -0
  155. package/dist/components/p-C4krHoUl.js +1 -0
  156. package/dist/components/p-C6qB08BS.js +1 -68
  157. package/dist/components/p-CF5L2Gdl.js +1 -0
  158. package/dist/components/p-CXzfYQ_u.js +1 -0
  159. package/dist/components/p-CeKT_dTd.js +1 -0
  160. package/dist/components/p-Cp15toXH.js +1 -0
  161. package/dist/components/p-Cy77SpWt.js +1 -0
  162. package/dist/components/p-D1tfzpy8.js +1 -0
  163. package/dist/components/p-D3LRBk2t.js +9 -0
  164. package/dist/components/p-D5ZsALCP.js +1 -0
  165. package/dist/components/p-D8W6LE-c.js +1 -11
  166. package/dist/components/p-DB5s1NY4.js +1 -0
  167. package/dist/components/p-DTezr6w9.js +1 -0
  168. package/dist/components/p-Du1vxHy8.js +1 -0
  169. package/dist/components/p-IAqZFssU.js +1 -0
  170. package/dist/components/p-g0N9j_uT.js +1 -0
  171. package/dist/components/p-l10It7Nm.js +1 -30
  172. package/dist/components/p-n789Y3S-.js +1 -45
  173. package/dist/esm/app-globals-DQuL1Twl.js +0 -3
  174. package/dist/esm/{default-line-tool.config-CuBm2vpW.js → default-line-tool.config-CD5sTKH-.js} +1515 -205
  175. package/dist/esm/index-BqhmuUH2.js +3253 -0
  176. package/dist/esm/index.js +11 -8
  177. package/dist/esm/kritzel-brush-style.entry.js +3 -4
  178. package/dist/esm/kritzel-color_22.entry.js +103 -66
  179. package/dist/esm/loader.js +3 -4
  180. package/dist/esm/stencil.js +4 -5
  181. package/dist/stencil/index.esm.js +1 -2
  182. package/dist/stencil/p-09295079.entry.js +1 -0
  183. package/dist/stencil/p-381c0e9c.entry.js +9 -0
  184. package/dist/stencil/p-BqhmuUH2.js +2 -0
  185. package/dist/stencil/p-CD5sTKH-.js +1 -0
  186. package/dist/stencil/p-DQuL1Twl.js +1 -2
  187. package/dist/stencil/stencil.esm.js +1 -2
  188. package/dist/types/components/shared/kritzel-color-palette/kritzel-color-palette.d.ts +1 -0
  189. package/dist/types/components/shared/kritzel-font-size/kritzel-font-size.d.ts +1 -0
  190. package/dist/types/stencil-public-runtime.d.ts +57 -3
  191. package/package.json +6 -1
  192. package/dist/cjs/app-globals-V2Kpy_OQ.js.map +0 -1
  193. package/dist/cjs/default-line-tool.config-JuTDR6PF.js.map +0 -1
  194. package/dist/cjs/index-Cj__YTlG.js +0 -1650
  195. package/dist/cjs/index-Cj__YTlG.js.map +0 -1
  196. package/dist/cjs/index.cjs.js.map +0 -1
  197. package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +0 -1
  198. package/dist/cjs/loader.cjs.js.map +0 -1
  199. package/dist/cjs/stencil.cjs.js.map +0 -1
  200. package/dist/collection/classes/core/core.class.js.map +0 -1
  201. package/dist/collection/classes/core/reviver.class.js.map +0 -1
  202. package/dist/collection/classes/core/store.class.js.map +0 -1
  203. package/dist/collection/classes/core/viewport.class.js.map +0 -1
  204. package/dist/collection/classes/core/workspace.class.js.map +0 -1
  205. package/dist/collection/classes/handlers/base.handler.js.map +0 -1
  206. package/dist/collection/classes/handlers/context-menu.handler.js.map +0 -1
  207. package/dist/collection/classes/handlers/hover.handler.js.map +0 -1
  208. package/dist/collection/classes/handlers/key.handler.js.map +0 -1
  209. package/dist/collection/classes/handlers/line-handle.handler.js.map +0 -1
  210. package/dist/collection/classes/handlers/move.handler.js.map +0 -1
  211. package/dist/collection/classes/handlers/resize.handler.js.map +0 -1
  212. package/dist/collection/classes/handlers/rotation.handler.js.map +0 -1
  213. package/dist/collection/classes/handlers/selection.handler.js.map +0 -1
  214. package/dist/collection/classes/managers/anchor.manager.js.map +0 -1
  215. package/dist/collection/classes/managers/cursor.manager.js.map +0 -1
  216. package/dist/collection/classes/objects/base-object.class.js.map +0 -1
  217. package/dist/collection/classes/objects/custom-element.class.js.map +0 -1
  218. package/dist/collection/classes/objects/group.class.js.map +0 -1
  219. package/dist/collection/classes/objects/image.class.js.map +0 -1
  220. package/dist/collection/classes/objects/line.class.js.map +0 -1
  221. package/dist/collection/classes/objects/path.class.js.map +0 -1
  222. package/dist/collection/classes/objects/selection-box.class.js.map +0 -1
  223. package/dist/collection/classes/objects/selection-group.class.js.map +0 -1
  224. package/dist/collection/classes/objects/shape.class.js.map +0 -1
  225. package/dist/collection/classes/objects/text.class.js.map +0 -1
  226. package/dist/collection/classes/providers/broadcast-sync-provider.class.js.map +0 -1
  227. package/dist/collection/classes/providers/hocuspocus-sync-provider.class.js.map +0 -1
  228. package/dist/collection/classes/providers/indexeddb-sync-provider.class.js.map +0 -1
  229. package/dist/collection/classes/providers/websocket-sync-provider.class.js.map +0 -1
  230. package/dist/collection/classes/registries/icon-registry.class.js.map +0 -1
  231. package/dist/collection/classes/registries/tool.registry.js.map +0 -1
  232. package/dist/collection/classes/structures/app-state-map.structure.js.map +0 -1
  233. package/dist/collection/classes/structures/object-map.structure.js.map +0 -1
  234. package/dist/collection/classes/structures/quadtree.structure.js.map +0 -1
  235. package/dist/collection/classes/tools/base-tool.class.js.map +0 -1
  236. package/dist/collection/classes/tools/brush-tool.class.js.map +0 -1
  237. package/dist/collection/classes/tools/eraser-tool.class.js.map +0 -1
  238. package/dist/collection/classes/tools/image-tool.class.js.map +0 -1
  239. package/dist/collection/classes/tools/line-tool.class.js.map +0 -1
  240. package/dist/collection/classes/tools/selection-tool.class.js.map +0 -1
  241. package/dist/collection/classes/tools/shape-tool.class.js.map +0 -1
  242. package/dist/collection/classes/tools/text-tool.class.js.map +0 -1
  243. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +0 -1
  244. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +0 -1
  245. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +0 -1
  246. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +0 -1
  247. package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +0 -1
  248. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +0 -1
  249. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +0 -1
  250. package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +0 -1
  251. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +0 -1
  252. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +0 -1
  253. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +0 -1
  254. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +0 -1
  255. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +0 -1
  256. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +0 -1
  257. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +0 -1
  258. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +0 -1
  259. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +0 -1
  260. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +0 -1
  261. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +0 -1
  262. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +0 -1
  263. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +0 -1
  264. package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +0 -1
  265. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +0 -1
  266. package/dist/collection/configs/default-brush-tool.config.js.map +0 -1
  267. package/dist/collection/configs/default-engine-config.js.map +0 -1
  268. package/dist/collection/configs/default-line-tool.config.js.map +0 -1
  269. package/dist/collection/configs/default-shape-tool.config.js.map +0 -1
  270. package/dist/collection/configs/default-sync.config.js.map +0 -1
  271. package/dist/collection/configs/default-text-tool.config.js.map +0 -1
  272. package/dist/collection/constants/core.constants.js.map +0 -1
  273. package/dist/collection/constants/engine.constants.js.map +0 -1
  274. package/dist/collection/enums/event-button.enum.js.map +0 -1
  275. package/dist/collection/enums/handle-type.enum.js.map +0 -1
  276. package/dist/collection/enums/shape-type.enum.js.map +0 -1
  277. package/dist/collection/helpers/class.helper.js.map +0 -1
  278. package/dist/collection/helpers/cursor.helper.js.map +0 -1
  279. package/dist/collection/helpers/devices.helper.js.map +0 -1
  280. package/dist/collection/helpers/event.helper.js.map +0 -1
  281. package/dist/collection/helpers/geometry.helper.js.map +0 -1
  282. package/dist/collection/helpers/html.helper.js.map +0 -1
  283. package/dist/collection/helpers/keyboard.helper.js.map +0 -1
  284. package/dist/collection/helpers/math.helper.js.map +0 -1
  285. package/dist/collection/helpers/object.helper.js.map +0 -1
  286. package/dist/collection/index.js.map +0 -1
  287. package/dist/collection/interfaces/anchor.interface.js.map +0 -1
  288. package/dist/collection/interfaces/arrow-head.interface.js.map +0 -1
  289. package/dist/collection/interfaces/bounding-box.interface.js.map +0 -1
  290. package/dist/collection/interfaces/clonable.interface.js.map +0 -1
  291. package/dist/collection/interfaces/context-menu-item.interface.js.map +0 -1
  292. package/dist/collection/interfaces/debug-info.interface.js.map +0 -1
  293. package/dist/collection/interfaces/engine-state.interface.js.map +0 -1
  294. package/dist/collection/interfaces/line-options.interface.js.map +0 -1
  295. package/dist/collection/interfaces/menu-item.interface.js.map +0 -1
  296. package/dist/collection/interfaces/object.interface.js.map +0 -1
  297. package/dist/collection/interfaces/path-options.interface.js.map +0 -1
  298. package/dist/collection/interfaces/point.interface.js.map +0 -1
  299. package/dist/collection/interfaces/polygon.interface.js.map +0 -1
  300. package/dist/collection/interfaces/selection-state.interface.js.map +0 -1
  301. package/dist/collection/interfaces/serializable.interface.js.map +0 -1
  302. package/dist/collection/interfaces/shortcut.interface.js.map +0 -1
  303. package/dist/collection/interfaces/sync-config.interface.js.map +0 -1
  304. package/dist/collection/interfaces/sync-provider.interface.js.map +0 -1
  305. package/dist/collection/interfaces/tool.interface.js.map +0 -1
  306. package/dist/collection/interfaces/toolbar-control.interface.js.map +0 -1
  307. package/dist/collection/interfaces/undo-state.interface.js.map +0 -1
  308. package/dist/collection/types/deep-readonly.type.js.map +0 -1
  309. package/dist/collection/types/state.types.js.map +0 -1
  310. package/dist/components/index.js.map +0 -1
  311. package/dist/components/kritzel-brush-style.js.map +0 -1
  312. package/dist/components/kritzel-color-palette.js.map +0 -1
  313. package/dist/components/kritzel-color.js.map +0 -1
  314. package/dist/components/kritzel-context-menu.js.map +0 -1
  315. package/dist/components/kritzel-control-brush-config.js.map +0 -1
  316. package/dist/components/kritzel-control-text-config.js.map +0 -1
  317. package/dist/components/kritzel-controls.js.map +0 -1
  318. package/dist/components/kritzel-cursor-trail.js.map +0 -1
  319. package/dist/components/kritzel-dropdown.js.map +0 -1
  320. package/dist/components/kritzel-editor.js.map +0 -1
  321. package/dist/components/kritzel-engine.js.map +0 -1
  322. package/dist/components/kritzel-font-family.js.map +0 -1
  323. package/dist/components/kritzel-font-size.js.map +0 -1
  324. package/dist/components/kritzel-font.js.map +0 -1
  325. package/dist/components/kritzel-icon.js.map +0 -1
  326. package/dist/components/kritzel-menu-item.js.map +0 -1
  327. package/dist/components/kritzel-menu.js.map +0 -1
  328. package/dist/components/kritzel-portal.js.map +0 -1
  329. package/dist/components/kritzel-split-button.js.map +0 -1
  330. package/dist/components/kritzel-stroke-size.js.map +0 -1
  331. package/dist/components/kritzel-tooltip.js.map +0 -1
  332. package/dist/components/kritzel-utility-panel.js.map +0 -1
  333. package/dist/components/kritzel-workspace-manager.js.map +0 -1
  334. package/dist/components/p-B0kd2rUI.js.map +0 -1
  335. package/dist/components/p-B80ry-r4.js +0 -103
  336. package/dist/components/p-B80ry-r4.js.map +0 -1
  337. package/dist/components/p-BC5-_yPs.js +0 -75
  338. package/dist/components/p-BC5-_yPs.js.map +0 -1
  339. package/dist/components/p-BUsg2vtg.js +0 -14897
  340. package/dist/components/p-BUsg2vtg.js.map +0 -1
  341. package/dist/components/p-Bo-NQ68K.js +0 -132
  342. package/dist/components/p-Bo-NQ68K.js.map +0 -1
  343. package/dist/components/p-C6qB08BS.js.map +0 -1
  344. package/dist/components/p-C720oASC.js +0 -201
  345. package/dist/components/p-C720oASC.js.map +0 -1
  346. package/dist/components/p-C92UCXyc.js +0 -308
  347. package/dist/components/p-C92UCXyc.js.map +0 -1
  348. package/dist/components/p-CAxHKvww.js +0 -119
  349. package/dist/components/p-CAxHKvww.js.map +0 -1
  350. package/dist/components/p-CD9cCvhR.js +0 -272
  351. package/dist/components/p-CD9cCvhR.js.map +0 -1
  352. package/dist/components/p-CIlIrPRp.js +0 -83
  353. package/dist/components/p-CIlIrPRp.js.map +0 -1
  354. package/dist/components/p-CIts5Uma.js +0 -110
  355. package/dist/components/p-CIts5Uma.js.map +0 -1
  356. package/dist/components/p-Cdw55iW6.js +0 -281
  357. package/dist/components/p-Cdw55iW6.js.map +0 -1
  358. package/dist/components/p-CwkUrTy1.js +0 -1367
  359. package/dist/components/p-CwkUrTy1.js.map +0 -1
  360. package/dist/components/p-D8W6LE-c.js.map +0 -1
  361. package/dist/components/p-DI7JQMsC.js +0 -46
  362. package/dist/components/p-DI7JQMsC.js.map +0 -1
  363. package/dist/components/p-DmYjCy-z.js +0 -62
  364. package/dist/components/p-DmYjCy-z.js.map +0 -1
  365. package/dist/components/p-DoD6F7Y4.js +0 -157
  366. package/dist/components/p-DoD6F7Y4.js.map +0 -1
  367. package/dist/components/p-DyVWaSSc.js +0 -55
  368. package/dist/components/p-DyVWaSSc.js.map +0 -1
  369. package/dist/components/p-WLXyD_eY.js +0 -111
  370. package/dist/components/p-WLXyD_eY.js.map +0 -1
  371. package/dist/components/p-c7AGmG3p.js +0 -73
  372. package/dist/components/p-c7AGmG3p.js.map +0 -1
  373. package/dist/components/p-fm-bG_zL.js +0 -231
  374. package/dist/components/p-fm-bG_zL.js.map +0 -1
  375. package/dist/components/p-fqLbEfE0.js +0 -39586
  376. package/dist/components/p-fqLbEfE0.js.map +0 -1
  377. package/dist/components/p-l10It7Nm.js.map +0 -1
  378. package/dist/components/p-n789Y3S-.js.map +0 -1
  379. package/dist/components/p-qWf2T62p.js +0 -57
  380. package/dist/components/p-qWf2T62p.js.map +0 -1
  381. package/dist/components/p-vLN8eXFe.js +0 -106
  382. package/dist/components/p-vLN8eXFe.js.map +0 -1
  383. package/dist/esm/app-globals-DQuL1Twl.js.map +0 -1
  384. package/dist/esm/default-line-tool.config-CuBm2vpW.js.map +0 -1
  385. package/dist/esm/index-SGde3HXB.js +0 -1623
  386. package/dist/esm/index-SGde3HXB.js.map +0 -1
  387. package/dist/esm/index.js.map +0 -1
  388. package/dist/esm/kritzel-brush-style.entry.js.map +0 -1
  389. package/dist/esm/loader.js.map +0 -1
  390. package/dist/esm/stencil.js.map +0 -1
  391. package/dist/stencil/index.esm.js.map +0 -1
  392. package/dist/stencil/kritzel-brush-style.entry.esm.js.map +0 -1
  393. package/dist/stencil/loader.esm.js.map +0 -1
  394. package/dist/stencil/p-0a9b6696.entry.js +0 -2
  395. package/dist/stencil/p-0a9b6696.entry.js.map +0 -1
  396. package/dist/stencil/p-0fdce6ce.entry.js +0 -10
  397. package/dist/stencil/p-0fdce6ce.entry.js.map +0 -1
  398. package/dist/stencil/p-CuBm2vpW.js +0 -2
  399. package/dist/stencil/p-CuBm2vpW.js.map +0 -1
  400. package/dist/stencil/p-DQuL1Twl.js.map +0 -1
  401. package/dist/stencil/p-SGde3HXB.js +0 -3
  402. package/dist/stencil/p-SGde3HXB.js.map +0 -1
  403. package/dist/stencil/stencil.esm.js.map +0 -1
@@ -3030,7 +3030,7 @@ creating and deserializing such documents.
3030
3030
  When given, the type parameters provide the names of the nodes and
3031
3031
  marks in this schema.
3032
3032
  */
3033
- class Schema {
3033
+ let Schema$1 = class Schema {
3034
3034
  /**
3035
3035
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
3036
3036
  */
@@ -3122,7 +3122,7 @@ class Schema {
3122
3122
  throw new RangeError("Unknown node type: " + name);
3123
3123
  return found;
3124
3124
  }
3125
- }
3125
+ };
3126
3126
  function gatherMarks(schema, marks) {
3127
3127
  let found = [];
3128
3128
  for (let i = 0; i < marks.length; i++) {
@@ -3889,7 +3889,7 @@ class DOMSerializer {
3889
3889
  */
3890
3890
  serializeFragment(fragment, options = {}, target) {
3891
3891
  if (!target)
3892
- target = doc$1(options).createDocumentFragment();
3892
+ target = doc$2(options).createDocumentFragment();
3893
3893
  let top = target, active = [];
3894
3894
  fragment.forEach(node => {
3895
3895
  if (active.length || node.marks.length) {
@@ -3925,7 +3925,7 @@ class DOMSerializer {
3925
3925
  @internal
3926
3926
  */
3927
3927
  serializeNodeInner(node, options) {
3928
- let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
3928
+ let { dom, contentDOM } = renderSpec(doc$2(options), this.nodes[node.type.name](node), null, node.attrs);
3929
3929
  if (contentDOM) {
3930
3930
  if (node.isLeaf)
3931
3931
  throw new RangeError("Content hole not allowed in a leaf node spec");
@@ -3956,7 +3956,7 @@ class DOMSerializer {
3956
3956
  */
3957
3957
  serializeMark(mark, inline, options = {}) {
3958
3958
  let toDOM = this.marks[mark.type.name];
3959
- return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
3959
+ return toDOM && renderSpec(doc$2(options), toDOM(mark, inline), null, mark.attrs);
3960
3960
  }
3961
3961
  static renderSpec(doc, structure, xmlNS = null, blockArraysIn) {
3962
3962
  return renderSpec(doc, structure, xmlNS, blockArraysIn);
@@ -3995,7 +3995,7 @@ function gatherToDOM(obj) {
3995
3995
  }
3996
3996
  return result;
3997
3997
  }
3998
- function doc$1(options) {
3998
+ function doc$2(options) {
3999
3999
  return options.document || window.document;
4000
4000
  }
4001
4001
  const suspiciousAttributeCache = new WeakMap();
@@ -7309,7 +7309,7 @@ function caretFromPoint(doc, x, y) {
7309
7309
  }
7310
7310
 
7311
7311
  const nav = typeof navigator != "undefined" ? navigator : null;
7312
- const doc = typeof document != "undefined" ? document : null;
7312
+ const doc$1 = typeof document != "undefined" ? document : null;
7313
7313
  const agent = (nav && nav.userAgent) || "";
7314
7314
  const ie_edge = /Edge\/(\d+)/.exec(agent);
7315
7315
  const ie_upto10 = /MSIE \d/.exec(agent);
@@ -7326,7 +7326,7 @@ const ios = safari && (/Mobile\/\w+/.test(agent) || !!nav && nav.maxTouchPoints
7326
7326
  const mac$3 = ios || (nav ? /Mac/.test(nav.platform) : false);
7327
7327
  const windows$1 = nav ? /Win/.test(nav.platform) : false;
7328
7328
  const android = /Android \d/.test(agent);
7329
- const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
7329
+ const webkit = !!doc$1 && "webkitFontSmoothing" in doc$1.documentElement.style;
7330
7330
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
7331
7331
 
7332
7332
  function windowRect(doc) {
@@ -7512,17 +7512,20 @@ function findOffsetInNode(node, coords) {
7512
7512
  }
7513
7513
  function findOffsetInText(node, coords) {
7514
7514
  let len = node.nodeValue.length;
7515
- let range = document.createRange();
7515
+ let range = document.createRange(), result;
7516
7516
  for (let i = 0; i < len; i++) {
7517
7517
  range.setEnd(node, i + 1);
7518
7518
  range.setStart(node, i);
7519
7519
  let rect = singleRect(range, 1);
7520
7520
  if (rect.top == rect.bottom)
7521
7521
  continue;
7522
- if (inRect(coords, rect))
7523
- return { node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0) };
7522
+ if (inRect(coords, rect)) {
7523
+ result = { node, offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0) };
7524
+ break;
7525
+ }
7524
7526
  }
7525
- return { node, offset: 0 };
7527
+ range.detach();
7528
+ return result || { node, offset: 0 };
7526
7529
  }
7527
7530
  function inRect(coords, rect) {
7528
7531
  return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 &&
@@ -10615,7 +10618,8 @@ editHandlers.compositionstart = editHandlers.compositionupdate = view => {
10615
10618
  let { state } = view, $pos = state.selection.$to;
10616
10619
  if (state.selection instanceof TextSelection &&
10617
10620
  (state.storedMarks ||
10618
- (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)))) {
10621
+ (!$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(m => m.type.spec.inclusive === false)) ||
10622
+ chrome && windows$1 && selectionBeforeUneditable(view))) { // Issue #1500
10619
10623
  // Need to wrap the cursor in mark nodes different from the ones in the DOM context
10620
10624
  view.markCursor = view.state.storedMarks || $pos.marks();
10621
10625
  endComposition(view, true);
@@ -10649,6 +10653,13 @@ editHandlers.compositionstart = editHandlers.compositionupdate = view => {
10649
10653
  }
10650
10654
  scheduleComposeEnd(view, timeoutComposition);
10651
10655
  };
10656
+ function selectionBeforeUneditable(view) {
10657
+ let { focusNode, focusOffset } = view.domSelectionRange();
10658
+ if (!focusNode || focusNode.nodeType != 1 || focusOffset >= focusNode.childNodes.length)
10659
+ return false;
10660
+ let next = focusNode.childNodes[focusOffset];
10661
+ return next.nodeType == 1 && next.contentEditable == "false";
10662
+ }
10652
10663
  editHandlers.compositionend = (view, event) => {
10653
10664
  if (view.composing) {
10654
10665
  view.input.composing = false;
@@ -10876,10 +10887,15 @@ handlers.dragend = view => {
10876
10887
  }, 50);
10877
10888
  };
10878
10889
  editHandlers.dragover = editHandlers.dragenter = (_, e) => e.preventDefault();
10879
- editHandlers.drop = (view, _event) => {
10880
- let event = _event;
10881
- let dragging = view.dragging;
10882
- view.dragging = null;
10890
+ editHandlers.drop = (view, event) => {
10891
+ try {
10892
+ handleDrop(view, event, view.dragging);
10893
+ }
10894
+ finally {
10895
+ view.dragging = null;
10896
+ }
10897
+ };
10898
+ function handleDrop(view, event, dragging) {
10883
10899
  if (!event.dataTransfer)
10884
10900
  return;
10885
10901
  let eventPos = view.posAtCoords(eventCoords(event));
@@ -10933,7 +10949,7 @@ editHandlers.drop = (view, _event) => {
10933
10949
  }
10934
10950
  view.focus();
10935
10951
  view.dispatch(tr.setMeta("uiEvent", "drop"));
10936
- };
10952
+ }
10937
10953
  handlers.focus = view => {
10938
10954
  view.input.lastFocus = Date.now();
10939
10955
  if (!view.focused) {
@@ -11859,6 +11875,17 @@ class DOMObserver {
11859
11875
  }
11860
11876
  }
11861
11877
  }
11878
+ else if ((chrome || safari) && added.some(n => n.nodeName == "BR") &&
11879
+ (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46)) {
11880
+ // Chrome/Safari sometimes insert a bogus break node if you
11881
+ // backspace out the last bit of text before an inline-flex node (#1552)
11882
+ for (let node of added)
11883
+ if (node.nodeName == "BR" && node.parentNode) {
11884
+ let after = node.nextSibling;
11885
+ if (after && after.nodeType == 1 && after.contentEditable == "false")
11886
+ node.parentNode.removeChild(node);
11887
+ }
11888
+ }
11862
11889
  let readSel = null;
11863
11890
  // If it looks like the browser has reset the selection to the
11864
11891
  // start of the document after focus, restore the selection from
@@ -13133,7 +13160,7 @@ module.
13133
13160
  To reuse elements from this schema, extend or read from its
13134
13161
  `spec.nodes` and `spec.marks` [properties](https://prosemirror.net/docs/ref/#model.Schema.spec).
13135
13162
  */
13136
- const schema = new Schema({ nodes, marks });
13163
+ const schema = new Schema$1({ nodes, marks });
13137
13164
 
13138
13165
  const olDOM = ["ol", 0], ulDOM = ["ul", 0], liDOM = ["li", 0];
13139
13166
  /**
@@ -13961,7 +13988,7 @@ class KritzelText extends KritzelBaseObject {
13961
13988
  isEditing = false;
13962
13989
  editor = null;
13963
13990
  content = null;
13964
- _schema = new Schema({
13991
+ _schema = new Schema$1({
13965
13992
  nodes: addListNodes(schema.spec.nodes, 'paragraph block*', 'block'),
13966
13993
  marks: schema.spec.marks,
13967
13994
  });
@@ -18149,6 +18176,12 @@ class KritzelSelectionTool extends KritzelBaseTool {
18149
18176
  * @module map
18150
18177
  */
18151
18178
 
18179
+ /**
18180
+ * @template K
18181
+ * @template V
18182
+ * @typedef {Map<K,V>} GlobalMap
18183
+ */
18184
+
18152
18185
  /**
18153
18186
  * Creates a new Map instance.
18154
18187
  *
@@ -18284,6 +18317,25 @@ const appendTo = (dest, src) => {
18284
18317
  */
18285
18318
  const from$1 = Array.from;
18286
18319
 
18320
+ /**
18321
+ * True iff condition holds on every element in the Array.
18322
+ *
18323
+ * @function
18324
+ * @template {ArrayLike<any>} ARR
18325
+ *
18326
+ * @param {ARR} arr
18327
+ * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f
18328
+ * @return {boolean}
18329
+ */
18330
+ const every$1 = (arr, f) => {
18331
+ for (let i = 0; i < arr.length; i++) {
18332
+ if (!f(arr[i], i, arr)) {
18333
+ return false
18334
+ }
18335
+ }
18336
+ return true
18337
+ };
18338
+
18287
18339
  /**
18288
18340
  * True iff condition holds on some element in the Array.
18289
18341
  *
@@ -18303,6 +18355,20 @@ const some = (arr, f) => {
18303
18355
  return false
18304
18356
  };
18305
18357
 
18358
+ /**
18359
+ * @template T
18360
+ * @param {number} len
18361
+ * @param {function(number, Array<T>):T} f
18362
+ * @return {Array<T>}
18363
+ */
18364
+ const unfold = (len, f) => {
18365
+ const array = new Array(len);
18366
+ for (let i = 0; i < len; i++) {
18367
+ array[i] = f(i, array);
18368
+ }
18369
+ return array
18370
+ };
18371
+
18306
18372
  const isArray = Array.isArray;
18307
18373
 
18308
18374
  /**
@@ -18492,8 +18558,10 @@ const max$2 = (a, b) => a > b ? a : b;
18492
18558
  const pow = Math.pow;
18493
18559
 
18494
18560
  /**
18561
+ * Check whether n is negative, while considering the -0 edge case. While `-0 < 0` is false, this
18562
+ * function returns true for -0,-1,,.. and returns false for 0,1,2,...
18495
18563
  * @param {number} n
18496
- * @return {boolean} Wether n is negative. This function also differentiates between -0 and +0
18564
+ * @return {boolean} Wether n is negative. This function also distinguishes between -0 and +0
18497
18565
  */
18498
18566
  const isNegativeZero = n => n !== 0 ? n < 0 : 1 / n < 0;
18499
18567
 
@@ -18533,6 +18601,7 @@ const BITS31 = 0x7FFFFFFF;
18533
18601
 
18534
18602
 
18535
18603
  const MAX_SAFE_INTEGER$2 = Number.MAX_SAFE_INTEGER;
18604
+ const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER;
18536
18605
 
18537
18606
  /* c8 ignore next */
18538
18607
  const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor$2(num) === num);
@@ -18570,7 +18639,7 @@ const fromCamelCase = (s, separator) => trimLeft(s.replace(fromCamelCaseRegex, m
18570
18639
 
18571
18640
  /**
18572
18641
  * @param {string} str
18573
- * @return {Uint8Array}
18642
+ * @return {Uint8Array<ArrayBuffer>}
18574
18643
  */
18575
18644
  const _encodeUtf8Polyfill$2 = str => {
18576
18645
  const encodedString = unescape(encodeURIComponent(str));
@@ -18587,7 +18656,7 @@ const utf8TextEncoder$2 = /** @type {TextEncoder} */ (typeof TextEncoder !== 'un
18587
18656
 
18588
18657
  /**
18589
18658
  * @param {string} str
18590
- * @return {Uint8Array}
18659
+ * @return {Uint8Array<ArrayBuffer>}
18591
18660
  */
18592
18661
  const _encodeUtf8Native$2 = str => utf8TextEncoder$2.encode(str);
18593
18662
 
@@ -18612,6 +18681,12 @@ if (utf8TextDecoder$2 && utf8TextDecoder$2.decode(new Uint8Array()).length === 1
18612
18681
  utf8TextDecoder$2 = null;
18613
18682
  }
18614
18683
 
18684
+ /**
18685
+ * @param {string} source
18686
+ * @param {number} n
18687
+ */
18688
+ const repeat = (source, n) => unfold(n, () => source).join('');
18689
+
18615
18690
  /**
18616
18691
  * Efficient schema-less binary encoding with support for variable length encoding.
18617
18692
  *
@@ -18668,7 +18743,7 @@ const createEncoder$1 = () => new Encoder$1();
18668
18743
  * @param {Encoder} encoder
18669
18744
  * @return {number}
18670
18745
  */
18671
- const length$3 = encoder => {
18746
+ const length$2 = encoder => {
18672
18747
  let len = encoder.cpos;
18673
18748
  for (let i = 0; i < encoder.bufs.length; i++) {
18674
18749
  len += encoder.bufs[i].length;
@@ -18681,10 +18756,10 @@ const length$3 = encoder => {
18681
18756
  *
18682
18757
  * @function
18683
18758
  * @param {Encoder} encoder
18684
- * @return {Uint8Array} The created ArrayBuffer.
18759
+ * @return {Uint8Array<ArrayBuffer>} The created ArrayBuffer.
18685
18760
  */
18686
18761
  const toUint8Array$1 = encoder => {
18687
- const uint8arr = new Uint8Array(length$3(encoder));
18762
+ const uint8arr = new Uint8Array(length$2(encoder));
18688
18763
  let curPos = 0;
18689
18764
  for (let i = 0; i < encoder.bufs.length; i++) {
18690
18765
  const d = encoder.bufs[i];
@@ -18922,6 +18997,14 @@ const isFloat32 = num => {
18922
18997
  return floatTestBed.getFloat32(0) === num
18923
18998
  };
18924
18999
 
19000
+ /**
19001
+ * @typedef {Array<AnyEncodable>} AnyEncodableArray
19002
+ */
19003
+
19004
+ /**
19005
+ * @typedef {undefined|null|number|bigint|boolean|string|{[k:string]:AnyEncodable}|AnyEncodableArray|Uint8Array} AnyEncodable
19006
+ */
19007
+
18925
19008
  /**
18926
19009
  * Encode data with efficient binary format.
18927
19010
  *
@@ -18957,7 +19040,7 @@ const isFloat32 = num => {
18957
19040
  * lib0/encoding.js
18958
19041
  *
18959
19042
  * @param {Encoder} encoder
18960
- * @param {undefined|null|number|bigint|boolean|string|Object<string,any>|Array<any>|Uint8Array} data
19043
+ * @param {AnyEncodable} data
18961
19044
  */
18962
19045
  const writeAny = (encoder, data) => {
18963
19046
  switch (typeof data) {
@@ -19311,16 +19394,17 @@ const errorIntegerOutOfRange$2 = create$7('Integer out of Range');
19311
19394
 
19312
19395
  /**
19313
19396
  * A Decoder handles the decoding of an Uint8Array.
19397
+ * @template {ArrayBufferLike} [Buf=ArrayBufferLike]
19314
19398
  */
19315
19399
  let Decoder$1 = class Decoder {
19316
19400
  /**
19317
- * @param {Uint8Array} uint8Array Binary data to decode
19401
+ * @param {Uint8Array<Buf>} uint8Array Binary data to decode
19318
19402
  */
19319
19403
  constructor (uint8Array) {
19320
19404
  /**
19321
19405
  * Decoding target.
19322
19406
  *
19323
- * @type {Uint8Array}
19407
+ * @type {Uint8Array<Buf>}
19324
19408
  */
19325
19409
  this.arr = uint8Array;
19326
19410
  /**
@@ -19334,8 +19418,9 @@ let Decoder$1 = class Decoder {
19334
19418
 
19335
19419
  /**
19336
19420
  * @function
19337
- * @param {Uint8Array} uint8Array
19338
- * @return {Decoder}
19421
+ * @template {ArrayBufferLike} Buf
19422
+ * @param {Uint8Array<Buf>} uint8Array
19423
+ * @return {Decoder<Buf>}
19339
19424
  */
19340
19425
  const createDecoder$1 = uint8Array => new Decoder$1(uint8Array);
19341
19426
 
@@ -19353,9 +19438,10 @@ const hasContent = decoder => decoder.pos !== decoder.arr.length;
19353
19438
  * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
19354
19439
  *
19355
19440
  * @function
19356
- * @param {Decoder} decoder The decoder instance
19441
+ * @template {ArrayBufferLike} Buf
19442
+ * @param {Decoder<Buf>} decoder The decoder instance
19357
19443
  * @param {number} len The length of bytes to read
19358
- * @return {Uint8Array}
19444
+ * @return {Uint8Array<Buf>}
19359
19445
  */
19360
19446
  const readUint8Array$2 = (decoder, len) => {
19361
19447
  const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
@@ -19370,8 +19456,9 @@ const readUint8Array$2 = (decoder, len) => {
19370
19456
  * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.
19371
19457
  *
19372
19458
  * @function
19373
- * @param {Decoder} decoder
19374
- * @return {Uint8Array}
19459
+ * @template {ArrayBufferLike} Buf
19460
+ * @param {Decoder<Buf>} decoder
19461
+ * @return {Uint8Array<Buf>}
19375
19462
  */
19376
19463
  const readVarUint8Array$2 = decoder => readUint8Array$2(decoder, readVarUint$2(decoder));
19377
19464
 
@@ -19859,12 +19946,38 @@ const onChange = eventHandler => usePolyfill || addEventListener('storage', /**
19859
19946
  /* c8 ignore next */
19860
19947
  const offChange = eventHandler => usePolyfill || removeEventListener('storage', /** @type {any} */ (eventHandler));
19861
19948
 
19949
+ const EqualityTraitSymbol = Symbol('Equality');
19950
+
19951
+ /**
19952
+ * @typedef {{ [EqualityTraitSymbol]:(other:EqualityTrait)=>boolean }} EqualityTrait
19953
+ */
19954
+
19862
19955
  /**
19863
- * Utility functions for working with EcmaScript objects.
19864
19956
  *
19865
- * @module object
19957
+ * Utility function to compare any two objects.
19958
+ *
19959
+ * Note that it is expected that the first parameter is more specific than the latter one.
19960
+ *
19961
+ * @example js
19962
+ * class X { [traits.EqualityTraitSymbol] (other) { return other === this } }
19963
+ * class X2 { [traits.EqualityTraitSymbol] (other) { return other === this }, x2 () { return 2 } }
19964
+ * // this is fine
19965
+ * traits.equals(new X2(), new X())
19966
+ * // this is not, because the left type is less specific than the right one
19967
+ * traits.equals(new X(), new X2())
19968
+ *
19969
+ * @template {EqualityTrait} T
19970
+ * @param {NoInfer<T>} a
19971
+ * @param {T} b
19972
+ * @return {boolean}
19866
19973
  */
19974
+ const equals = (a, b) => a === b || !!a?.[EqualityTraitSymbol]?.(b) || false;
19867
19975
 
19976
+ /**
19977
+ * @param {any} o
19978
+ * @return {o is { [k:string]:any }}
19979
+ */
19980
+ const isObject = o => typeof o === 'object';
19868
19981
 
19869
19982
  /**
19870
19983
  * Object.assign
@@ -19903,13 +20016,6 @@ const map = (obj, f) => {
19903
20016
  return results
19904
20017
  };
19905
20018
 
19906
- /**
19907
- * @deprecated use object.size instead
19908
- * @param {Object<string,any>} obj
19909
- * @return {number}
19910
- */
19911
- const length$2 = obj => keys$1(obj).length;
19912
-
19913
20019
  /**
19914
20020
  * @param {Object<string,any>} obj
19915
20021
  * @return {number}
@@ -19956,7 +20062,7 @@ const hasProperty$1 = (obj, key) => Object.prototype.hasOwnProperty.call(obj, ke
19956
20062
  * @param {Object<string,any>} b
19957
20063
  * @return {boolean}
19958
20064
  */
19959
- const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty$1(b, key)) && b[key] === val));
20065
+ const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty$1(b, key)) && equals(b[key], val)));
19960
20066
 
19961
20067
  /**
19962
20068
  * Make an object immutable. This hurts performance and is usually not needed if you perform good
@@ -19982,12 +20088,6 @@ const deepFreeze = (o) => {
19982
20088
  return freeze(o)
19983
20089
  };
19984
20090
 
19985
- const EqualityTraitSymbol = Symbol('Equality');
19986
-
19987
- /**
19988
- * @typedef {{ [EqualityTraitSymbol]:(other:EqualityTrait)=>boolean }} EqualityTrait
19989
- */
19990
-
19991
20091
  /**
19992
20092
  * Common functions and function call helpers.
19993
20093
  *
@@ -20032,7 +20132,7 @@ const equalityDeep$1 = (a, b) => {
20032
20132
  if (a === b) {
20033
20133
  return true
20034
20134
  }
20035
- if (a == null || b == null || a.constructor !== b.constructor) {
20135
+ if (a == null || b == null || (a.constructor !== b.constructor && (a.constructor || Object) !== (b.constructor || Object))) {
20036
20136
  return false
20037
20137
  }
20038
20138
  if (a[EqualityTraitSymbol] != null) {
@@ -20076,8 +20176,9 @@ const equalityDeep$1 = (a, b) => {
20076
20176
  }
20077
20177
  break
20078
20178
  }
20179
+ case undefined:
20079
20180
  case Object:
20080
- if (length$2(a) !== length$2(b)) {
20181
+ if (size(a) !== size(b)) {
20081
20182
  return false
20082
20183
  }
20083
20184
  for (const key in a) {
@@ -20199,7 +20300,7 @@ const hasConf = (name) =>
20199
20300
  hasParam('--' + name) || getVariable(name) !== null;
20200
20301
 
20201
20302
  /* c8 ignore next */
20202
- hasConf('production');
20303
+ const production = hasConf('production');
20203
20304
 
20204
20305
  /* c8 ignore next 2 */
20205
20306
  const forceColor = isNode &&
@@ -20277,7 +20378,7 @@ const toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.
20277
20378
  /* c8 ignore start */
20278
20379
  /**
20279
20380
  * @param {string} s
20280
- * @return {Uint8Array}
20381
+ * @return {Uint8Array<ArrayBuffer>}
20281
20382
  */
20282
20383
  const fromBase64Browser = s => {
20283
20384
  // eslint-disable-next-line no-undef
@@ -20344,182 +20445,1396 @@ class Pair {
20344
20445
  */
20345
20446
  const create$5 = (left, right) => new Pair(left, right);
20346
20447
 
20347
- /* eslint-env browser */
20448
+ /**
20449
+ * Fast Pseudo Random Number Generators.
20450
+ *
20451
+ * Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.
20452
+ * Two PRNGs must generate the same random sequence of numbers if given the same seed.
20453
+ *
20454
+ * @module prng
20455
+ */
20348
20456
 
20349
20457
 
20350
- /** @type {DOMParser} */ (typeof DOMParser !== 'undefined' ? new DOMParser() : null);
20458
+ /**
20459
+ * Generates a single random bool.
20460
+ *
20461
+ * @param {PRNG} gen A random number generator.
20462
+ * @return {Boolean} A random boolean
20463
+ */
20464
+ const bool = gen => (gen.next() >= 0.5);
20351
20465
 
20352
20466
  /**
20353
- * @param {Map<string,string>} m
20354
- * @return {string}
20467
+ * Generates a random integer with 53 bit resolution.
20468
+ *
20469
+ * @param {PRNG} gen A random number generator.
20470
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
20471
+ * @param {Number} max The upper bound of the allowed return values (inclusive).
20472
+ * @return {Number} A random integer on [min, max]
20355
20473
  */
20356
- const mapToStyleString = m => map$1(m, (value, key) => `${key}:${value};`).join('');
20357
- /* c8 ignore stop */
20474
+ const int53 = (gen, min, max) => floor$2(gen.next() * (max + 1 - min) + min);
20358
20475
 
20359
20476
  /**
20360
- * Utility module to work with EcmaScript Symbols.
20477
+ * Generates a random integer with 32 bit resolution.
20361
20478
  *
20362
- * @module symbol
20479
+ * @param {PRNG} gen A random number generator.
20480
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
20481
+ * @param {Number} max The upper bound of the allowed return values (inclusive).
20482
+ * @return {Number} A random integer on [min, max]
20363
20483
  */
20484
+ const int32 = (gen, min, max) => floor$2(gen.next() * (max + 1 - min) + min);
20364
20485
 
20365
20486
  /**
20366
- * Return fresh symbol.
20487
+ * @deprecated
20488
+ * Optimized version of prng.int32. It has the same precision as prng.int32, but should be preferred when
20489
+ * openaring on smaller ranges.
20490
+ *
20491
+ * @param {PRNG} gen A random number generator.
20492
+ * @param {Number} min The lower bound of the allowed return values (inclusive).
20493
+ * @param {Number} max The upper bound of the allowed return values (inclusive). The max inclusive number is `binary.BITS31-1`
20494
+ * @return {Number} A random integer on [min, max]
20367
20495
  */
20368
- const create$4 = Symbol;
20496
+ const int31 = (gen, min, max) => int32(gen, min, max);
20369
20497
 
20370
- const BOLD = create$4();
20371
- const UNBOLD = create$4();
20372
- const BLUE = create$4();
20373
- const GREY = create$4();
20374
- const GREEN = create$4();
20375
- const RED = create$4();
20376
- const PURPLE = create$4();
20377
- const ORANGE = create$4();
20378
- const UNCOLOR = create$4();
20498
+ /**
20499
+ * @param {PRNG} gen
20500
+ * @return {string} A single letter (a-z)
20501
+ */
20502
+ const letter = gen => fromCharCode(int31(gen, 97, 122));
20379
20503
 
20380
- /* c8 ignore start */
20381
20504
  /**
20382
- * @param {Array<undefined|string|Symbol|Object|number|function():any>} args
20383
- * @return {Array<string|object|number|undefined>}
20505
+ * @param {PRNG} gen
20506
+ * @param {number} [minLen=0]
20507
+ * @param {number} [maxLen=20]
20508
+ * @return {string} A random word (0-20 characters) without spaces consisting of letters (a-z)
20384
20509
  */
20385
- const computeNoColorLoggingArgs = args => {
20386
- if (args.length === 1 && args[0]?.constructor === Function) {
20387
- args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]());
20388
- }
20389
- const strBuilder = [];
20390
- const logArgs = [];
20391
- // try with formatting until we find something unsupported
20392
- let i = 0;
20393
- for (; i < args.length; i++) {
20394
- const arg = args[i];
20395
- if (arg === undefined) {
20396
- break
20397
- } else if (arg.constructor === String || arg.constructor === Number) {
20398
- strBuilder.push(arg);
20399
- } else if (arg.constructor === Object) {
20400
- break
20401
- }
20402
- }
20403
- if (i > 0) {
20404
- // create logArgs with what we have so far
20405
- logArgs.push(strBuilder.join(''));
20406
- }
20407
- // append the rest
20408
- for (; i < args.length; i++) {
20409
- const arg = args[i];
20410
- if (!(arg instanceof Symbol)) {
20411
- logArgs.push(arg);
20412
- }
20510
+ const word = (gen, minLen = 0, maxLen = 20) => {
20511
+ const len = int31(gen, minLen, maxLen);
20512
+ let str = '';
20513
+ for (let i = 0; i < len; i++) {
20514
+ str += letter(gen);
20413
20515
  }
20414
- return logArgs
20516
+ return str
20415
20517
  };
20518
+
20519
+ /**
20520
+ * Returns one element of a given array.
20521
+ *
20522
+ * @param {PRNG} gen A random number generator.
20523
+ * @param {Array<T>} array Non empty Array of possible values.
20524
+ * @return {T} One of the values of the supplied Array.
20525
+ * @template T
20526
+ */
20527
+ const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)];
20416
20528
  /* c8 ignore stop */
20417
20529
 
20418
20530
  /**
20419
- * Isomorphic logging module with support for colors!
20531
+ * @experimental WIP
20420
20532
  *
20421
- * @module logging
20533
+ * Simple & efficient schemas for your data.
20422
20534
  */
20423
20535
 
20424
20536
 
20425
20537
  /**
20426
- * @type {Object<Symbol,pair.Pair<string,string>>}
20538
+ * @typedef {string|number|bigint|boolean|null|undefined|symbol} Primitive
20427
20539
  */
20428
- const _browserStyleMap = {
20429
- [BOLD]: create$5('font-weight', 'bold'),
20430
- [UNBOLD]: create$5('font-weight', 'normal'),
20431
- [BLUE]: create$5('color', 'blue'),
20432
- [GREEN]: create$5('color', 'green'),
20433
- [GREY]: create$5('color', 'grey'),
20434
- [RED]: create$5('color', 'red'),
20435
- [PURPLE]: create$5('color', 'purple'),
20436
- [ORANGE]: create$5('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate
20437
- [UNCOLOR]: create$5('color', 'black')
20438
- };
20439
20540
 
20440
20541
  /**
20441
- * @param {Array<string|Symbol|Object|number|function():any>} args
20442
- * @return {Array<string|object|number>}
20542
+ * @typedef {{ [k:string|number|symbol]: any }} AnyObject
20443
20543
  */
20444
- /* c8 ignore start */
20445
- const computeBrowserLoggingArgs = (args) => {
20446
- if (args.length === 1 && args[0]?.constructor === Function) {
20447
- args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]());
20448
- }
20449
- const strBuilder = [];
20450
- const styles = [];
20451
- const currentStyle = create$9();
20452
- /**
20453
- * @type {Array<string|Object|number>}
20454
- */
20455
- let logArgs = [];
20456
- // try with formatting until we find something unsupported
20457
- let i = 0;
20458
- for (; i < args.length; i++) {
20459
- const arg = args[i];
20460
- // @ts-ignore
20461
- const style = _browserStyleMap[arg];
20462
- if (style !== undefined) {
20463
- currentStyle.set(style.left, style.right);
20464
- } else {
20465
- if (arg === undefined) {
20466
- break
20467
- }
20468
- if (arg.constructor === String || arg.constructor === Number) {
20469
- const style = mapToStyleString(currentStyle);
20470
- if (i > 0 || style.length > 0) {
20471
- strBuilder.push('%c' + arg);
20472
- styles.push(style);
20473
- } else {
20474
- strBuilder.push(arg);
20475
- }
20476
- } else {
20477
- break
20478
- }
20479
- }
20480
- }
20481
- if (i > 0) {
20482
- // create logArgs with what we have so far
20483
- logArgs = styles;
20484
- logArgs.unshift(strBuilder.join(''));
20485
- }
20486
- // append the rest
20487
- for (; i < args.length; i++) {
20488
- const arg = args[i];
20489
- if (!(arg instanceof Symbol)) {
20490
- logArgs.push(arg);
20491
- }
20492
- }
20493
- return logArgs
20494
- };
20495
- /* c8 ignore stop */
20496
-
20497
- /* c8 ignore start */
20498
- const computeLoggingArgs = supportsColor
20499
- ? computeBrowserLoggingArgs
20500
- : computeNoColorLoggingArgs;
20501
- /* c8 ignore stop */
20502
20544
 
20503
20545
  /**
20504
- * @param {Array<string|Symbol|Object|number>} args
20546
+ * @template T
20547
+ * @typedef {T extends Schema<infer X> ? X : T} Unwrap
20505
20548
  */
20506
- const print = (...args) => {
20507
- console.log(...computeLoggingArgs(args));
20508
- /* c8 ignore next */
20509
- vconsoles.forEach((vc) => vc.print(args));
20510
- };
20511
20549
 
20512
- /* c8 ignore start */
20513
20550
  /**
20514
- * @param {Array<string|Symbol|Object|number>} args
20551
+ * @template T
20552
+ * @typedef {T extends Schema<infer X> ? X : T} TypeOf
20515
20553
  */
20516
- const warn = (...args) => {
20517
- console.warn(...computeLoggingArgs(args));
20518
- args.unshift(ORANGE);
20519
- vconsoles.forEach((vc) => vc.print(args));
20520
- };
20521
-
20522
- const vconsoles = create$8();
20554
+
20555
+ /**
20556
+ * @template {readonly unknown[]} T
20557
+ * @typedef {T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : [] } UnwrapArray
20558
+ */
20559
+
20560
+ /**
20561
+ * @template T
20562
+ * @typedef {T extends Schema<infer S> ? Schema<S> : never} CastToSchema
20563
+ */
20564
+
20565
+ /**
20566
+ * @template {unknown[]} Arr
20567
+ * @typedef {Arr extends [...unknown[], infer L] ? L : never} TupleLast
20568
+ */
20569
+
20570
+ /**
20571
+ * @template {unknown[]} Arr
20572
+ * @typedef {Arr extends [...infer Fs, unknown] ? Fs : never} TuplePop
20573
+ */
20574
+
20575
+ /**
20576
+ * @template {readonly unknown[]} T
20577
+ * @typedef {T extends []
20578
+ * ? {}
20579
+ * : T extends [infer First]
20580
+ * ? First
20581
+ * : T extends [infer First, ...infer Rest]
20582
+ * ? First & Intersect<Rest>
20583
+ * : never
20584
+ * } Intersect
20585
+ */
20586
+
20587
+ const schemaSymbol = Symbol('0schema');
20588
+
20589
+ class ValidationError {
20590
+ constructor () {
20591
+ /**
20592
+ * Reverse errors
20593
+ * @type {Array<{ path: string?, expected: string, has: string, message: string? }>}
20594
+ */
20595
+ this._rerrs = [];
20596
+ }
20597
+
20598
+ /**
20599
+ * @param {string?} path
20600
+ * @param {string} expected
20601
+ * @param {string} has
20602
+ * @param {string?} message
20603
+ */
20604
+ extend (path, expected, has, message = null) {
20605
+ this._rerrs.push({ path, expected, has, message });
20606
+ }
20607
+
20608
+ toString () {
20609
+ const s = [];
20610
+ for (let i = this._rerrs.length - 1; i > 0; i--) {
20611
+ const r = this._rerrs[i];
20612
+ /* c8 ignore next */
20613
+ s.push(repeat(' ', (this._rerrs.length - i) * 2) + `${r.path != null ? `[${r.path}] ` : ''}${r.has} doesn't match ${r.expected}. ${r.message}`);
20614
+ }
20615
+ return s.join('\n')
20616
+ }
20617
+ }
20618
+
20619
+ /**
20620
+ * @param {any} a
20621
+ * @param {any} b
20622
+ * @return {boolean}
20623
+ */
20624
+ const shapeExtends = (a, b) => {
20625
+ if (a === b) return true
20626
+ if (a == null || b == null || a.constructor !== b.constructor) return false
20627
+ if (a[EqualityTraitSymbol]) return equals(a, b) // last resort: check equality (do this before array and obj check which don't implement the equality trait)
20628
+ if (isArray(a)) {
20629
+ return every$1(a, aitem =>
20630
+ some(b, bitem => shapeExtends(aitem, bitem))
20631
+ )
20632
+ } else if (isObject(a)) {
20633
+ return every(a, (aitem, akey) =>
20634
+ shapeExtends(aitem, b[akey])
20635
+ )
20636
+ }
20637
+ /* c8 ignore next */
20638
+ return false
20639
+ };
20640
+
20641
+ /**
20642
+ * @template T
20643
+ * @implements {equalityTraits.EqualityTrait}
20644
+ */
20645
+ class Schema {
20646
+ // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
20647
+ /**
20648
+ * If true, the more things are added to the shape the more objects this schema will accept (e.g.
20649
+ * union). By default, the more objects are added, the the fewer objects this schema will accept.
20650
+ * @protected
20651
+ */
20652
+ static _dilutes = false
20653
+
20654
+ /**
20655
+ * @param {Schema<any>} other
20656
+ */
20657
+ extends (other) {
20658
+ let [a, b] = [/** @type {any} */(this).shape, /** @type {any} */ (other).shape];
20659
+ if (/** @type {typeof Schema<any>} */ (this.constructor)._dilutes) [b, a] = [a, b];
20660
+ return shapeExtends(a, b)
20661
+ }
20662
+
20663
+ /**
20664
+ * Overwrite this when necessary. By default, we only check the `shape` property which every shape
20665
+ * should have.
20666
+ * @param {Schema<any>} other
20667
+ */
20668
+ equals (other) {
20669
+ // @ts-ignore
20670
+ return this.constructor === other.constructor && equalityDeep$1(this.shape, other.shape)
20671
+ }
20672
+
20673
+ [schemaSymbol] () { return true }
20674
+
20675
+ /**
20676
+ * @param {object} other
20677
+ */
20678
+ [EqualityTraitSymbol] (other) {
20679
+ return this.equals(/** @type {any} */ (other))
20680
+ }
20681
+
20682
+ /**
20683
+ * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of
20684
+ * Schema. Validate will check the structure of the parameter and return true iff the instance
20685
+ * really is an instance of Schema.
20686
+ *
20687
+ * @param {T} o
20688
+ * @return {boolean}
20689
+ */
20690
+ validate (o) {
20691
+ return this.check(o)
20692
+ }
20693
+
20694
+ /* c8 ignore start */
20695
+ /**
20696
+ * Similar to validate, but this method accepts untyped parameters.
20697
+ *
20698
+ * @param {any} _o
20699
+ * @param {ValidationError} [_err]
20700
+ * @return {_o is T}
20701
+ */
20702
+ check (_o, _err) {
20703
+ methodUnimplemented();
20704
+ }
20705
+ /* c8 ignore stop */
20706
+
20707
+ /**
20708
+ * @type {Schema<T?>}
20709
+ */
20710
+ get nullable () {
20711
+ // @ts-ignore
20712
+ return $union(this, $null)
20713
+ }
20714
+
20715
+ /**
20716
+ * @type {$Optional<Schema<T>>}
20717
+ */
20718
+ get optional () {
20719
+ return new $Optional(/** @type {Schema<T>} */ (this))
20720
+ }
20721
+
20722
+ /**
20723
+ * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise.
20724
+ * Use this if you know that the type is of a specific type and you just want to convince the type
20725
+ * system.
20726
+ *
20727
+ * **Do not rely on these error messages!**
20728
+ * Performs an assertion check only if not in a production environment.
20729
+ *
20730
+ * @template OO
20731
+ * @param {OO} o
20732
+ * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}
20733
+ */
20734
+ cast (o) {
20735
+ assert(o, this);
20736
+ return /** @type {any} */ (o)
20737
+ }
20738
+
20739
+ /**
20740
+ * EXPECTO PATRONUM!! 🪄
20741
+ * This function protects against type errors. Though it may not work in the real world.
20742
+ *
20743
+ * "After all this time?"
20744
+ * "Always." - Snape, talking about type safety
20745
+ *
20746
+ * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.
20747
+ * Use this if you know that the type is of a specific type and you just want to convince the type
20748
+ * system.
20749
+ *
20750
+ * Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`
20751
+ *
20752
+ * **Do not rely on these error messages!**
20753
+ * Performs an assertion check if not in a production environment.
20754
+ *
20755
+ * @param {T} o
20756
+ * @return {o extends T ? T : never}
20757
+ */
20758
+ expect (o) {
20759
+ assert(o, this);
20760
+ return o
20761
+ }
20762
+ }
20763
+
20764
+ /**
20765
+ * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} Constr
20766
+ * @typedef {Constr extends ((...args:any[]) => infer T) ? T : (Constr extends (new (...args:any[]) => any) ? InstanceType<Constr> : never)} Instance
20767
+ */
20768
+
20769
+ /**
20770
+ * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C
20771
+ * @extends {Schema<Instance<C>>}
20772
+ */
20773
+ class $ConstructedBy extends Schema {
20774
+ /**
20775
+ * @param {C} c
20776
+ * @param {((o:Instance<C>)=>boolean)|null} check
20777
+ */
20778
+ constructor (c, check) {
20779
+ super();
20780
+ this.shape = c;
20781
+ this._c = check;
20782
+ }
20783
+
20784
+ /**
20785
+ * @param {any} o
20786
+ * @param {ValidationError} [err]
20787
+ * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o
20788
+ */
20789
+ check (o, err = undefined) {
20790
+ const c = o?.constructor === this.shape && (this._c == null || this._c(o));
20791
+ /* c8 ignore next */
20792
+ !c && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? 'Constructor match failed' : 'Check failed');
20793
+ return c
20794
+ }
20795
+ }
20796
+
20797
+ /**
20798
+ * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C
20799
+ * @param {C} c
20800
+ * @param {((o:Instance<C>) => boolean)|null} check
20801
+ * @return {CastToSchema<$ConstructedBy<C>>}
20802
+ */
20803
+ const $constructedBy = (c, check = null) => new $ConstructedBy(c, check);
20804
+ $constructedBy($ConstructedBy);
20805
+
20806
+ /**
20807
+ * Check custom properties on any object. You may want to overwrite the generated Schema<any>.
20808
+ *
20809
+ * @extends {Schema<any>}
20810
+ */
20811
+ class $Custom extends Schema {
20812
+ /**
20813
+ * @param {(o:any) => boolean} check
20814
+ */
20815
+ constructor (check) {
20816
+ super();
20817
+ /**
20818
+ * @type {(o:any) => boolean}
20819
+ */
20820
+ this.shape = check;
20821
+ }
20822
+
20823
+ /**
20824
+ * @param {any} o
20825
+ * @param {ValidationError} err
20826
+ * @return {o is any}
20827
+ */
20828
+ check (o, err) {
20829
+ const c = this.shape(o);
20830
+ /* c8 ignore next */
20831
+ !c && err?.extend(null, 'custom prop', o?.constructor.name, 'failed to check custom prop');
20832
+ return c
20833
+ }
20834
+ }
20835
+
20836
+ /**
20837
+ * @param {(o:any) => boolean} check
20838
+ * @return {Schema<any>}
20839
+ */
20840
+ const $custom = (check) => new $Custom(check);
20841
+ $constructedBy($Custom);
20842
+
20843
+ /**
20844
+ * @template {Primitive} T
20845
+ * @extends {Schema<T>}
20846
+ */
20847
+ class $Literal extends Schema {
20848
+ /**
20849
+ * @param {Array<T>} literals
20850
+ */
20851
+ constructor (literals) {
20852
+ super();
20853
+ this.shape = literals;
20854
+ }
20855
+
20856
+ /**
20857
+ *
20858
+ * @param {any} o
20859
+ * @param {ValidationError} [err]
20860
+ * @return {o is T}
20861
+ */
20862
+ check (o, err) {
20863
+ const c = this.shape.some(a => a === o);
20864
+ /* c8 ignore next */
20865
+ !c && err?.extend(null, this.shape.join(' | '), o.toString());
20866
+ return c
20867
+ }
20868
+ }
20869
+
20870
+ /**
20871
+ * @template {Primitive[]} T
20872
+ * @param {T} literals
20873
+ * @return {CastToSchema<$Literal<T[number]>>}
20874
+ */
20875
+ const $literal = (...literals) => new $Literal(literals);
20876
+ const $$literal = $constructedBy($Literal);
20877
+
20878
+ /**
20879
+ * @template {Array<string|Schema<string|number>>} Ts
20880
+ * @typedef {Ts extends [] ? `` : (Ts extends [infer T] ? (Unwrap<T> extends (string|number) ? Unwrap<T> : never) : (Ts extends [infer T1, ...infer Rest] ? `${Unwrap<T1> extends (string|number) ? Unwrap<T1> : never}${Rest extends Array<string|Schema<string|number>> ? CastStringTemplateArgsToTemplate<Rest> : never}` : never))} CastStringTemplateArgsToTemplate
20881
+ */
20882
+
20883
+ /**
20884
+ * @param {string} str
20885
+ * @return {string}
20886
+ */
20887
+ const _regexEscape = /** @type {any} */ (RegExp).escape || /** @type {(str:string) => string} */ (str =>
20888
+ str.replace(/[().|&,$^[\]]/g, s => '\\' + s)
20889
+ );
20890
+
20891
+ /**
20892
+ * @param {string|Schema<any>} s
20893
+ * @return {string[]}
20894
+ */
20895
+ const _schemaStringTemplateToRegex = s => {
20896
+ if ($string.check(s)) {
20897
+ return [_regexEscape(s)]
20898
+ }
20899
+ if ($$literal.check(s)) {
20900
+ return /** @type {Array<string|number>} */ (s.shape).map(v => v + '')
20901
+ }
20902
+ if ($$number.check(s)) {
20903
+ return ['[+-]?\\d+.?\\d*']
20904
+ }
20905
+ if ($$string.check(s)) {
20906
+ return ['.*']
20907
+ }
20908
+ if ($$union.check(s)) {
20909
+ return s.shape.map(_schemaStringTemplateToRegex).flat(1)
20910
+ }
20911
+ /* c8 ignore next 2 */
20912
+ // unexpected schema structure (only supports unions and string in literal types)
20913
+ unexpectedCase();
20914
+ };
20915
+
20916
+ /**
20917
+ * @template {Array<string|Schema<string|number>>} T
20918
+ * @extends {Schema<CastStringTemplateArgsToTemplate<T>>}
20919
+ */
20920
+ class $StringTemplate extends Schema {
20921
+ /**
20922
+ * @param {T} shape
20923
+ */
20924
+ constructor (shape) {
20925
+ super();
20926
+ this.shape = shape;
20927
+ this._r = new RegExp('^' + shape.map(_schemaStringTemplateToRegex).map(opts => `(${opts.join('|')})`).join('') + '$');
20928
+ }
20929
+
20930
+ /**
20931
+ * @param {any} o
20932
+ * @param {ValidationError} [err]
20933
+ * @return {o is CastStringTemplateArgsToTemplate<T>}
20934
+ */
20935
+ check (o, err) {
20936
+ const c = this._r.exec(o) != null;
20937
+ /* c8 ignore next */
20938
+ !c && err?.extend(null, this._r.toString(), o.toString(), 'String doesn\'t match string template.');
20939
+ return c
20940
+ }
20941
+ }
20942
+ $constructedBy($StringTemplate);
20943
+
20944
+ const isOptionalSymbol = Symbol('optional');
20945
+ /**
20946
+ * @template {Schema<any>} S
20947
+ * @extends Schema<Unwrap<S>|undefined>
20948
+ */
20949
+ class $Optional extends Schema {
20950
+ /**
20951
+ * @param {S} shape
20952
+ */
20953
+ constructor (shape) {
20954
+ super();
20955
+ this.shape = shape;
20956
+ }
20957
+
20958
+ /**
20959
+ * @param {any} o
20960
+ * @param {ValidationError} [err]
20961
+ * @return {o is (Unwrap<S>|undefined)}
20962
+ */
20963
+ check (o, err) {
20964
+ const c = o === undefined || this.shape.check(o);
20965
+ /* c8 ignore next */
20966
+ !c && err?.extend(null, 'undefined (optional)', '()');
20967
+ return c
20968
+ }
20969
+
20970
+ get [isOptionalSymbol] () { return true }
20971
+ }
20972
+ const $$optional = $constructedBy($Optional);
20973
+
20974
+ /**
20975
+ * @extends Schema<never>
20976
+ */
20977
+ class $Never extends Schema {
20978
+ /**
20979
+ * @param {any} _o
20980
+ * @param {ValidationError} [err]
20981
+ * @return {_o is never}
20982
+ */
20983
+ check (_o, err) {
20984
+ /* c8 ignore next */
20985
+ err?.extend(null, 'never', typeof _o);
20986
+ return false
20987
+ }
20988
+ }
20989
+ $constructedBy($Never);
20990
+
20991
+ /**
20992
+ * @template {{ [key: string|symbol|number]: Schema<any> }} S
20993
+ * @typedef {{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never }} $ObjectToType
20994
+ */
20995
+
20996
+ /**
20997
+ * @template {{[key:string|symbol|number]: Schema<any>}} S
20998
+ * @extends {Schema<$ObjectToType<S>>}
20999
+ */
21000
+ class $Object extends Schema {
21001
+ /**
21002
+ * @param {S} shape
21003
+ * @param {boolean} partial
21004
+ */
21005
+ constructor (shape, partial = false) {
21006
+ super();
21007
+ /**
21008
+ * @type {S}
21009
+ */
21010
+ this.shape = shape;
21011
+ this._isPartial = partial;
21012
+ }
21013
+
21014
+ static _dilutes = true
21015
+
21016
+ /**
21017
+ * @type {Schema<Partial<$ObjectToType<S>>>}
21018
+ */
21019
+ get partial () {
21020
+ return new $Object(this.shape, true)
21021
+ }
21022
+
21023
+ /**
21024
+ * @param {any} o
21025
+ * @param {ValidationError} err
21026
+ * @return {o is $ObjectToType<S>}
21027
+ */
21028
+ check (o, err) {
21029
+ if (o == null) {
21030
+ /* c8 ignore next */
21031
+ err?.extend(null, 'object', 'null');
21032
+ return false
21033
+ }
21034
+ return every(this.shape, (vv, vk) => {
21035
+ const c = (this._isPartial && !hasProperty$1(o, vk)) || vv.check(o[vk], err);
21036
+ !c && err?.extend(vk.toString(), vv.toString(), typeof o[vk], 'Object property does not match');
21037
+ return c
21038
+ })
21039
+ }
21040
+ }
21041
+
21042
+ /**
21043
+ * @template S
21044
+ * @typedef {Schema<{ [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? Key : never]?: S[Key] extends $Optional<Schema<infer Type>> ? Type : never } & { [Key in keyof S as S[Key] extends $Optional<Schema<any>> ? never : Key]: S[Key] extends Schema<infer Type> ? Type : never }>} _ObjectDefToSchema
21045
+ */
21046
+
21047
+ // I used an explicit type annotation instead of $ObjectToType, so that the user doesn't see the
21048
+ // weird type definitions when inspecting type definions.
21049
+ /**
21050
+ * @template {{ [key:string|symbol|number]: Schema<any> }} S
21051
+ * @param {S} def
21052
+ * @return {_ObjectDefToSchema<S> extends Schema<infer S> ? Schema<{ [K in keyof S]: S[K] }> : never}
21053
+ */
21054
+ const $object = def => /** @type {any} */ (new $Object(def));
21055
+ const $$object = $constructedBy($Object);
21056
+ /**
21057
+ * @type {Schema<{[key:string]: any}>}
21058
+ */
21059
+ const $objectAny = $custom(o => o != null && (o.constructor === Object || o.constructor == null));
21060
+
21061
+ /**
21062
+ * @template {Schema<string|number|symbol>} Keys
21063
+ * @template {Schema<any>} Values
21064
+ * @extends {Schema<{ [key in Unwrap<Keys>]: Unwrap<Values> }>}
21065
+ */
21066
+ class $Record extends Schema {
21067
+ /**
21068
+ * @param {Keys} keys
21069
+ * @param {Values} values
21070
+ */
21071
+ constructor (keys, values) {
21072
+ super();
21073
+ this.shape = {
21074
+ keys, values
21075
+ };
21076
+ }
21077
+
21078
+ /**
21079
+ * @param {any} o
21080
+ * @param {ValidationError} err
21081
+ * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}
21082
+ */
21083
+ check (o, err) {
21084
+ return o != null && every(o, (vv, vk) => {
21085
+ const ck = this.shape.keys.check(vk, err);
21086
+ /* c8 ignore next */
21087
+ !ck && err?.extend(vk + '', 'Record', typeof o, ck ? 'Key doesn\'t match schema' : 'Value doesn\'t match value');
21088
+ return ck && this.shape.values.check(vv, err)
21089
+ })
21090
+ }
21091
+ }
21092
+
21093
+ /**
21094
+ * @template {Schema<string|number|symbol>} Keys
21095
+ * @template {Schema<any>} Values
21096
+ * @param {Keys} keys
21097
+ * @param {Values} values
21098
+ * @return {CastToSchema<$Record<Keys,Values>>}
21099
+ */
21100
+ const $record = (keys, values) => new $Record(keys, values);
21101
+ const $$record = $constructedBy($Record);
21102
+
21103
+ /**
21104
+ * @template {Schema<any>[]} S
21105
+ * @extends {Schema<{ [Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never }>}
21106
+ */
21107
+ class $Tuple extends Schema {
21108
+ /**
21109
+ * @param {S} shape
21110
+ */
21111
+ constructor (shape) {
21112
+ super();
21113
+ this.shape = shape;
21114
+ }
21115
+
21116
+ /**
21117
+ * @param {any} o
21118
+ * @param {ValidationError} err
21119
+ * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}
21120
+ */
21121
+ check (o, err) {
21122
+ return o != null && every(this.shape, (vv, vk) => {
21123
+ const c = /** @type {Schema<any>} */ (vv).check(o[vk], err);
21124
+ /* c8 ignore next */
21125
+ !c && err?.extend(vk.toString(), 'Tuple', typeof vv);
21126
+ return c
21127
+ })
21128
+ }
21129
+ }
21130
+
21131
+ /**
21132
+ * @template {Array<Schema<any>>} T
21133
+ * @param {T} def
21134
+ * @return {CastToSchema<$Tuple<T>>}
21135
+ */
21136
+ const $tuple = (...def) => new $Tuple(def);
21137
+ $constructedBy($Tuple);
21138
+
21139
+ /**
21140
+ * @template {Schema<any>} S
21141
+ * @extends {Schema<Array<S extends Schema<infer T> ? T : never>>}
21142
+ */
21143
+ class $Array extends Schema {
21144
+ /**
21145
+ * @param {Array<S>} v
21146
+ */
21147
+ constructor (v) {
21148
+ super();
21149
+ /**
21150
+ * @type {Schema<S extends Schema<infer T> ? T : never>}
21151
+ */
21152
+ this.shape = v.length === 1 ? v[0] : new $Union(v);
21153
+ }
21154
+
21155
+ /**
21156
+ * @param {any} o
21157
+ * @param {ValidationError} [err]
21158
+ * @return {o is Array<S extends Schema<infer T> ? T : never>} o
21159
+ */
21160
+ check (o, err) {
21161
+ const c = isArray(o) && every$1(o, oi => this.shape.check(oi));
21162
+ /* c8 ignore next */
21163
+ !c && err?.extend(null, 'Array', '');
21164
+ return c
21165
+ }
21166
+ }
21167
+
21168
+ /**
21169
+ * @template {Array<Schema<any>>} T
21170
+ * @param {T} def
21171
+ * @return {Schema<Array<T extends Array<Schema<infer S>> ? S : never>>}
21172
+ */
21173
+ const $array = (...def) => new $Array(def);
21174
+ const $$array = $constructedBy($Array);
21175
+ /**
21176
+ * @type {Schema<Array<any>>}
21177
+ */
21178
+ const $arrayAny = $custom(o => isArray(o));
21179
+
21180
+ /**
21181
+ * @template T
21182
+ * @extends {Schema<T>}
21183
+ */
21184
+ class $InstanceOf extends Schema {
21185
+ /**
21186
+ * @param {new (...args:any) => T} constructor
21187
+ * @param {((o:T) => boolean)|null} check
21188
+ */
21189
+ constructor (constructor, check) {
21190
+ super();
21191
+ this.shape = constructor;
21192
+ this._c = check;
21193
+ }
21194
+
21195
+ /**
21196
+ * @param {any} o
21197
+ * @param {ValidationError} err
21198
+ * @return {o is T}
21199
+ */
21200
+ check (o, err) {
21201
+ const c = o instanceof this.shape && (this._c == null || this._c(o));
21202
+ /* c8 ignore next */
21203
+ !c && err?.extend(null, this.shape.name, o?.constructor.name);
21204
+ return c
21205
+ }
21206
+ }
21207
+
21208
+ /**
21209
+ * @template T
21210
+ * @param {new (...args:any) => T} c
21211
+ * @param {((o:T) => boolean)|null} check
21212
+ * @return {Schema<T>}
21213
+ */
21214
+ const $instanceOf = (c, check = null) => new $InstanceOf(c, check);
21215
+ $constructedBy($InstanceOf);
21216
+
21217
+ const $$schema = $instanceOf(Schema);
21218
+
21219
+ /**
21220
+ * @template {Schema<any>[]} Args
21221
+ * @typedef {(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>} _LArgsToLambdaDef
21222
+ */
21223
+
21224
+ /**
21225
+ * @template {Array<Schema<any>>} Args
21226
+ * @extends {Schema<_LArgsToLambdaDef<Args>>}
21227
+ */
21228
+ class $Lambda extends Schema {
21229
+ /**
21230
+ * @param {Args} args
21231
+ */
21232
+ constructor (args) {
21233
+ super();
21234
+ this.len = args.length - 1;
21235
+ this.args = $tuple(...args.slice(-1));
21236
+ this.res = args[this.len];
21237
+ }
21238
+
21239
+ /**
21240
+ * @param {any} f
21241
+ * @param {ValidationError} err
21242
+ * @return {f is _LArgsToLambdaDef<Args>}
21243
+ */
21244
+ check (f, err) {
21245
+ const c = f.constructor === Function && f.length <= this.len;
21246
+ /* c8 ignore next */
21247
+ !c && err?.extend(null, 'function', typeof f);
21248
+ return c
21249
+ }
21250
+ }
21251
+ const $$lambda = $constructedBy($Lambda);
21252
+
21253
+ /**
21254
+ * @type {Schema<Function>}
21255
+ */
21256
+ const $function = $custom(o => typeof o === 'function');
21257
+
21258
+ /**
21259
+ * @template {Array<Schema<any>>} T
21260
+ * @extends {Schema<Intersect<UnwrapArray<T>>>}
21261
+ */
21262
+ class $Intersection extends Schema {
21263
+ /**
21264
+ * @param {T} v
21265
+ */
21266
+ constructor (v) {
21267
+ super();
21268
+ /**
21269
+ * @type {T}
21270
+ */
21271
+ this.shape = v;
21272
+ }
21273
+
21274
+ /**
21275
+ * @param {any} o
21276
+ * @param {ValidationError} [err]
21277
+ * @return {o is Intersect<UnwrapArray<T>>}
21278
+ */
21279
+ check (o, err) {
21280
+ // @ts-ignore
21281
+ const c = every$1(this.shape, check => check.check(o, err));
21282
+ /* c8 ignore next */
21283
+ !c && err?.extend(null, 'Intersectinon', typeof o);
21284
+ return c
21285
+ }
21286
+ }
21287
+ $constructedBy($Intersection, o => o.shape.length > 0); // Intersection with length=0 is considered "any"
21288
+
21289
+ /**
21290
+ * @template S
21291
+ * @extends {Schema<S>}
21292
+ */
21293
+ class $Union extends Schema {
21294
+ static _dilutes = true
21295
+
21296
+ /**
21297
+ * @param {Array<Schema<S>>} v
21298
+ */
21299
+ constructor (v) {
21300
+ super();
21301
+ this.shape = v;
21302
+ }
21303
+
21304
+ /**
21305
+ * @param {any} o
21306
+ * @param {ValidationError} [err]
21307
+ * @return {o is S}
21308
+ */
21309
+ check (o, err) {
21310
+ const c = some(this.shape, (vv) => vv.check(o, err));
21311
+ err?.extend(null, 'Union', typeof o);
21312
+ return c
21313
+ }
21314
+ }
21315
+
21316
+ /**
21317
+ * @template {Array<any>} T
21318
+ * @param {T} schemas
21319
+ * @return {CastToSchema<$Union<Unwrap<ReadSchema<T>>>>}
21320
+ */
21321
+ const $union = (...schemas) => schemas.findIndex($s => $$union.check($s)) >= 0
21322
+ ? $union(...schemas.map($s => $($s)).map($s => $$union.check($s) ? $s.shape : [$s]).flat(1))
21323
+ : (schemas.length === 1
21324
+ ? schemas[0]
21325
+ : new $Union(schemas));
21326
+ const $$union = /** @type {Schema<$Union<any>>} */ ($constructedBy($Union));
21327
+
21328
+ const _t = () => true;
21329
+ /**
21330
+ * @type {Schema<any>}
21331
+ */
21332
+ const $any = $custom(_t);
21333
+ const $$any = /** @type {Schema<Schema<any>>} */ ($constructedBy($Custom, o => o.shape === _t));
21334
+
21335
+ /**
21336
+ * @type {Schema<bigint>}
21337
+ */
21338
+ const $bigint = $custom(o => typeof o === 'bigint');
21339
+ const $$bigint = /** @type {Schema<Schema<BigInt>>} */ ($custom(o => o === $bigint));
21340
+
21341
+ /**
21342
+ * @type {Schema<symbol>}
21343
+ */
21344
+ const $symbol = $custom(o => typeof o === 'symbol');
21345
+ /** @type {Schema<Schema<Symbol>>} */ ($custom(o => o === $symbol));
21346
+
21347
+ /**
21348
+ * @type {Schema<number>}
21349
+ */
21350
+ const $number = $custom(o => typeof o === 'number');
21351
+ const $$number = /** @type {Schema<Schema<number>>} */ ($custom(o => o === $number));
21352
+
21353
+ /**
21354
+ * @type {Schema<string>}
21355
+ */
21356
+ const $string = $custom(o => typeof o === 'string');
21357
+ const $$string = /** @type {Schema<Schema<string>>} */ ($custom(o => o === $string));
21358
+
21359
+ /**
21360
+ * @type {Schema<boolean>}
21361
+ */
21362
+ const $boolean = $custom(o => typeof o === 'boolean');
21363
+ const $$boolean = /** @type {Schema<Schema<Boolean>>} */ ($custom(o => o === $boolean));
21364
+
21365
+ /**
21366
+ * @type {Schema<undefined>}
21367
+ */
21368
+ const $undefined = $literal(undefined);
21369
+ /** @type {Schema<Schema<undefined>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === undefined));
21370
+
21371
+ /**
21372
+ * @type {Schema<void>}
21373
+ */
21374
+ $literal(undefined);
21375
+
21376
+ const $null = $literal(null);
21377
+ const $$null = /** @type {Schema<Schema<null>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === null));
21378
+
21379
+ $constructedBy(Uint8Array);
21380
+ /** @type {Schema<Schema<Uint8Array>>} */ ($constructedBy($ConstructedBy, o => o.shape === Uint8Array));
21381
+
21382
+ /**
21383
+ * @type {Schema<Primitive>}
21384
+ */
21385
+ const $primitive = $union($number, $string, $null, $undefined, $bigint, $boolean, $symbol);
21386
+
21387
+ /**
21388
+ * @typedef {JSON[]} JSONArray
21389
+ */
21390
+ /**
21391
+ * @typedef {Primitive|JSONArray|{ [key:string]:JSON }} JSON
21392
+ */
21393
+ /**
21394
+ * @type {Schema<null|number|string|boolean|JSON[]|{[key:string]:JSON}>}
21395
+ */
21396
+ (() => {
21397
+ const $jsonArr = /** @type {$Array<$any>} */ ($array($any));
21398
+ const $jsonRecord = /** @type {$Record<$string,$any>} */ ($record($string, $any));
21399
+ const $json = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord);
21400
+ $jsonArr.shape = $json;
21401
+ $jsonRecord.shape.values = $json;
21402
+ return $json
21403
+ })();
21404
+
21405
+ /**
21406
+ * @template {any} IN
21407
+ * @typedef {IN extends Schema<any> ? IN
21408
+ * : (IN extends string|number|boolean|null ? Schema<IN>
21409
+ * : (IN extends new (...args:any[])=>any ? Schema<InstanceType<IN>>
21410
+ * : (IN extends any[] ? Schema<{ [K in keyof IN]: Unwrap<ReadSchema<IN[K]>> }[number]>
21411
+ * : (IN extends object ? (_ObjectDefToSchema<{[K in keyof IN]:ReadSchema<IN[K]>}> extends Schema<infer S> ? Schema<{ [K in keyof S]: S[K] }> : never)
21412
+ * : never)
21413
+ * )
21414
+ * )
21415
+ * )
21416
+ * } ReadSchemaOld
21417
+ */
21418
+
21419
+ /**
21420
+ * @template {any} IN
21421
+ * @typedef {[Extract<IN,Schema<any>>,Extract<IN,string|number|boolean|null>,Extract<IN,new (...args:any[])=>any>,Extract<IN,any[]>,Extract<Exclude<IN,Schema<any>|string|number|boolean|null|(new (...args:any[])=>any)|any[]>,object>] extends [infer Schemas, infer Primitives, infer Constructors, infer Arrs, infer Obj]
21422
+ * ? Schema<
21423
+ * (Schemas extends Schema<infer S> ? S : never)
21424
+ * | Primitives
21425
+ * | (Constructors extends new (...args:any[])=>any ? InstanceType<Constructors> : never)
21426
+ * | (Arrs extends any[] ? { [K in keyof Arrs]: Unwrap<ReadSchema<Arrs[K]>> }[number] : never)
21427
+ * | (Obj extends object ? Unwrap<(_ObjectDefToSchema<{[K in keyof Obj]:ReadSchema<Obj[K]>}> extends Schema<infer S> ? Schema<{ [K in keyof S]: S[K] }> : never)> : never)>
21428
+ * : never
21429
+ * } ReadSchema
21430
+ */
21431
+
21432
+ /**
21433
+ * @typedef {ReadSchema<{x:42}|{y:99}|Schema<string>|[1,2,{}]>} Q
21434
+ */
21435
+
21436
+ /**
21437
+ * @template IN
21438
+ * @param {IN} o
21439
+ * @return {ReadSchema<IN>}
21440
+ */
21441
+ const $ = o => {
21442
+ if ($$schema.check(o)) {
21443
+ return /** @type {any} */ (o)
21444
+ } else if ($objectAny.check(o)) {
21445
+ /**
21446
+ * @type {any}
21447
+ */
21448
+ const o2 = {};
21449
+ for (const k in o) {
21450
+ o2[k] = $(o[k]);
21451
+ }
21452
+ return /** @type {any} */ ($object(o2))
21453
+ } else if ($arrayAny.check(o)) {
21454
+ return /** @type {any} */ ($union(...o.map($)))
21455
+ } else if ($primitive.check(o)) {
21456
+ return /** @type {any} */ ($literal(o))
21457
+ } else if ($function.check(o)) {
21458
+ return /** @type {any} */ ($constructedBy(/** @type {any} */ (o)))
21459
+ }
21460
+ /* c8 ignore next */
21461
+ unexpectedCase();
21462
+ };
21463
+
21464
+ /* c8 ignore start */
21465
+ /**
21466
+ * Assert that a variable is of this specific type.
21467
+ * The assertion check is only performed in non-production environments.
21468
+ *
21469
+ * @type {<T>(o:any,schema:Schema<T>) => asserts o is T}
21470
+ */
21471
+ const assert = production
21472
+ ? () => {}
21473
+ : (o, schema) => {
21474
+ const err = new ValidationError();
21475
+ if (!schema.check(o, err)) {
21476
+ throw create$7(`Expected value to be of type ${schema.constructor.name}.\n${err.toString()}`)
21477
+ }
21478
+ };
21479
+ /* c8 ignore end */
21480
+
21481
+ /**
21482
+ * @template In
21483
+ * @template Out
21484
+ * @typedef {{ if: Schema<In>, h: (o:In,state?:any)=>Out }} Pattern
21485
+ */
21486
+
21487
+ /**
21488
+ * @template {Pattern<any,any>} P
21489
+ * @template In
21490
+ * @typedef {ReturnType<Extract<P,Pattern<In extends number ? number : (In extends string ? string : In),any>>['h']>} PatternMatchResult
21491
+ */
21492
+
21493
+ /**
21494
+ * @todo move this to separate library
21495
+ * @template {any} [State=undefined]
21496
+ * @template {Pattern<any,any>} [Patterns=never]
21497
+ */
21498
+ class PatternMatcher {
21499
+ /**
21500
+ * @param {Schema<State>} [$state]
21501
+ */
21502
+ constructor ($state) {
21503
+ /**
21504
+ * @type {Array<Patterns>}
21505
+ */
21506
+ this.patterns = [];
21507
+ this.$state = $state;
21508
+ }
21509
+
21510
+ /**
21511
+ * @template P
21512
+ * @template R
21513
+ * @param {P} pattern
21514
+ * @param {(o:NoInfer<Unwrap<ReadSchema<P>>>,s:State)=>R} handler
21515
+ * @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}
21516
+ */
21517
+ if (pattern, handler) {
21518
+ // @ts-ignore
21519
+ this.patterns.push({ if: $(pattern), h: handler });
21520
+ // @ts-ignore
21521
+ return this
21522
+ }
21523
+
21524
+ /**
21525
+ * @template R
21526
+ * @param {(o:any,s:State)=>R} h
21527
+ */
21528
+ else (h) {
21529
+ return this.if($any, h)
21530
+ }
21531
+
21532
+ /**
21533
+ * @return {State extends undefined
21534
+ * ? <In extends Unwrap<Patterns['if']>>(o:In,state?:undefined)=>PatternMatchResult<Patterns,In>
21535
+ * : <In extends Unwrap<Patterns['if']>>(o:In,state:State)=>PatternMatchResult<Patterns,In>}
21536
+ */
21537
+ done () {
21538
+ // @ts-ignore
21539
+ return /** @type {any} */ (o, s) => {
21540
+ for (let i = 0; i < this.patterns.length; i++) {
21541
+ const p = this.patterns[i];
21542
+ if (p.if.check(o)) {
21543
+ // @ts-ignore
21544
+ return p.h(o, s)
21545
+ }
21546
+ }
21547
+ throw create$7('Unhandled pattern')
21548
+ }
21549
+ }
21550
+ }
21551
+
21552
+ /**
21553
+ * @template [State=undefined]
21554
+ * @param {State} [state]
21555
+ * @return {PatternMatcher<State extends undefined ? undefined : Unwrap<ReadSchema<State>>>}
21556
+ */
21557
+ const match = state => new PatternMatcher(/** @type {any} */ (state));
21558
+
21559
+ /**
21560
+ * Helper function to generate a (non-exhaustive) sample set from a gives schema.
21561
+ *
21562
+ * @type {<T>(o:T,gen:prng.PRNG)=>T}
21563
+ */
21564
+ const _random = /** @type {any} */ (match(/** @type {Schema<prng.PRNG>} */ ($any))
21565
+ .if($$number, (_o, gen) => int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER$2))
21566
+ .if($$string, (_o, gen) => word(gen))
21567
+ .if($$boolean, (_o, gen) => bool(gen))
21568
+ .if($$bigint, (_o, gen) => BigInt(int53(gen, MIN_SAFE_INTEGER, MAX_SAFE_INTEGER$2)))
21569
+ .if($$union, (o, gen) => random(gen, oneOf(gen, o.shape)))
21570
+ .if($$object, (o, gen) => {
21571
+ /**
21572
+ * @type {any}
21573
+ */
21574
+ const res = {};
21575
+ for (const k in o.shape) {
21576
+ let prop = o.shape[k];
21577
+ if ($$optional.check(prop)) {
21578
+ if (bool(gen)) { continue }
21579
+ prop = prop.shape;
21580
+ }
21581
+ res[k] = _random(prop, gen);
21582
+ }
21583
+ return res
21584
+ })
21585
+ .if($$array, (o, gen) => {
21586
+ const arr = [];
21587
+ const n = int32(gen, 0, 42);
21588
+ for (let i = 0; i < n; i++) {
21589
+ arr.push(random(gen, o.shape));
21590
+ }
21591
+ return arr
21592
+ })
21593
+ .if($$literal, (o, gen) => {
21594
+ return oneOf(gen, o.shape)
21595
+ })
21596
+ .if($$null, (o, gen) => {
21597
+ return null
21598
+ })
21599
+ .if($$lambda, (o, gen) => {
21600
+ const res = random(gen, o.res);
21601
+ return () => res
21602
+ })
21603
+ .if($$any, (o, gen) => random(gen, oneOf(gen, [
21604
+ $number, $string, $null, $undefined, $bigint, $boolean,
21605
+ $array($number),
21606
+ $record($union('a', 'b', 'c'), $number)
21607
+ ])))
21608
+ .if($$record, (o, gen) => {
21609
+ /**
21610
+ * @type {any}
21611
+ */
21612
+ const res = {};
21613
+ const keysN = int53(gen, 0, 3);
21614
+ for (let i = 0; i < keysN; i++) {
21615
+ const key = random(gen, o.shape.keys);
21616
+ const val = random(gen, o.shape.values);
21617
+ res[key] = val;
21618
+ }
21619
+ return res
21620
+ })
21621
+ .done());
21622
+
21623
+ /**
21624
+ * @template S
21625
+ * @param {prng.PRNG} gen
21626
+ * @param {S} schema
21627
+ * @return {Unwrap<ReadSchema<S>>}
21628
+ */
21629
+ const random = (gen, schema) => /** @type {any} */ (_random($(schema), gen));
21630
+
21631
+ /* eslint-env browser */
21632
+
21633
+
21634
+ /* c8 ignore start */
21635
+ /**
21636
+ * @type {Document}
21637
+ */
21638
+ const doc = /** @type {Document} */ (typeof document !== 'undefined' ? document : {});
21639
+
21640
+ /**
21641
+ * @type {$.Schema<DocumentFragment>}
21642
+ */
21643
+ $custom(el => el.nodeType === DOCUMENT_FRAGMENT_NODE);
21644
+
21645
+ /** @type {DOMParser} */ (typeof DOMParser !== 'undefined' ? new DOMParser() : null);
21646
+
21647
+ /**
21648
+ * @type {$.Schema<Element>}
21649
+ */
21650
+ $custom(el => el.nodeType === ELEMENT_NODE);
21651
+
21652
+ /**
21653
+ * @type {$.Schema<Text>}
21654
+ */
21655
+ $custom(el => el.nodeType === TEXT_NODE);
21656
+
21657
+ /**
21658
+ * @param {Map<string,string>} m
21659
+ * @return {string}
21660
+ */
21661
+ const mapToStyleString = m => map$1(m, (value, key) => `${key}:${value};`).join('');
21662
+
21663
+ const ELEMENT_NODE = doc.ELEMENT_NODE;
21664
+ const TEXT_NODE = doc.TEXT_NODE;
21665
+ const DOCUMENT_NODE = doc.DOCUMENT_NODE;
21666
+ const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE;
21667
+
21668
+ /**
21669
+ * @type {$.Schema<Node>}
21670
+ */
21671
+ $custom(el => el.nodeType === DOCUMENT_NODE);
21672
+ /* c8 ignore stop */
21673
+
21674
+ /**
21675
+ * Utility module to work with EcmaScript Symbols.
21676
+ *
21677
+ * @module symbol
21678
+ */
21679
+
21680
+ /**
21681
+ * Return fresh symbol.
21682
+ */
21683
+ const create$4 = Symbol;
21684
+
21685
+ const BOLD = create$4();
21686
+ const UNBOLD = create$4();
21687
+ const BLUE = create$4();
21688
+ const GREY = create$4();
21689
+ const GREEN = create$4();
21690
+ const RED = create$4();
21691
+ const PURPLE = create$4();
21692
+ const ORANGE = create$4();
21693
+ const UNCOLOR = create$4();
21694
+
21695
+ /* c8 ignore start */
21696
+ /**
21697
+ * @param {Array<undefined|string|Symbol|Object|number|function():any>} args
21698
+ * @return {Array<string|object|number|undefined>}
21699
+ */
21700
+ const computeNoColorLoggingArgs = args => {
21701
+ if (args.length === 1 && args[0]?.constructor === Function) {
21702
+ args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]());
21703
+ }
21704
+ const strBuilder = [];
21705
+ const logArgs = [];
21706
+ // try with formatting until we find something unsupported
21707
+ let i = 0;
21708
+ for (; i < args.length; i++) {
21709
+ const arg = args[i];
21710
+ if (arg === undefined) {
21711
+ break
21712
+ } else if (arg.constructor === String || arg.constructor === Number) {
21713
+ strBuilder.push(arg);
21714
+ } else if (arg.constructor === Object) {
21715
+ break
21716
+ }
21717
+ }
21718
+ if (i > 0) {
21719
+ // create logArgs with what we have so far
21720
+ logArgs.push(strBuilder.join(''));
21721
+ }
21722
+ // append the rest
21723
+ for (; i < args.length; i++) {
21724
+ const arg = args[i];
21725
+ if (!(arg instanceof Symbol)) {
21726
+ logArgs.push(arg);
21727
+ }
21728
+ }
21729
+ return logArgs
21730
+ };
21731
+ /* c8 ignore stop */
21732
+
21733
+ /**
21734
+ * Isomorphic logging module with support for colors!
21735
+ *
21736
+ * @module logging
21737
+ */
21738
+
21739
+
21740
+ /**
21741
+ * @type {Object<Symbol,pair.Pair<string,string>>}
21742
+ */
21743
+ const _browserStyleMap = {
21744
+ [BOLD]: create$5('font-weight', 'bold'),
21745
+ [UNBOLD]: create$5('font-weight', 'normal'),
21746
+ [BLUE]: create$5('color', 'blue'),
21747
+ [GREEN]: create$5('color', 'green'),
21748
+ [GREY]: create$5('color', 'grey'),
21749
+ [RED]: create$5('color', 'red'),
21750
+ [PURPLE]: create$5('color', 'purple'),
21751
+ [ORANGE]: create$5('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate
21752
+ [UNCOLOR]: create$5('color', 'black')
21753
+ };
21754
+
21755
+ /**
21756
+ * @param {Array<string|Symbol|Object|number|function():any>} args
21757
+ * @return {Array<string|object|number>}
21758
+ */
21759
+ /* c8 ignore start */
21760
+ const computeBrowserLoggingArgs = (args) => {
21761
+ if (args.length === 1 && args[0]?.constructor === Function) {
21762
+ args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]());
21763
+ }
21764
+ const strBuilder = [];
21765
+ const styles = [];
21766
+ const currentStyle = create$9();
21767
+ /**
21768
+ * @type {Array<string|Object|number>}
21769
+ */
21770
+ let logArgs = [];
21771
+ // try with formatting until we find something unsupported
21772
+ let i = 0;
21773
+ for (; i < args.length; i++) {
21774
+ const arg = args[i];
21775
+ // @ts-ignore
21776
+ const style = _browserStyleMap[arg];
21777
+ if (style !== undefined) {
21778
+ currentStyle.set(style.left, style.right);
21779
+ } else {
21780
+ if (arg === undefined) {
21781
+ break
21782
+ }
21783
+ if (arg.constructor === String || arg.constructor === Number) {
21784
+ const style = mapToStyleString(currentStyle);
21785
+ if (i > 0 || style.length > 0) {
21786
+ strBuilder.push('%c' + arg);
21787
+ styles.push(style);
21788
+ } else {
21789
+ strBuilder.push(arg);
21790
+ }
21791
+ } else {
21792
+ break
21793
+ }
21794
+ }
21795
+ }
21796
+ if (i > 0) {
21797
+ // create logArgs with what we have so far
21798
+ logArgs = styles;
21799
+ logArgs.unshift(strBuilder.join(''));
21800
+ }
21801
+ // append the rest
21802
+ for (; i < args.length; i++) {
21803
+ const arg = args[i];
21804
+ if (!(arg instanceof Symbol)) {
21805
+ logArgs.push(arg);
21806
+ }
21807
+ }
21808
+ return logArgs
21809
+ };
21810
+ /* c8 ignore stop */
21811
+
21812
+ /* c8 ignore start */
21813
+ const computeLoggingArgs = supportsColor
21814
+ ? computeBrowserLoggingArgs
21815
+ : computeNoColorLoggingArgs;
21816
+ /* c8 ignore stop */
21817
+
21818
+ /**
21819
+ * @param {Array<string|Symbol|Object|number>} args
21820
+ */
21821
+ const print = (...args) => {
21822
+ console.log(...computeLoggingArgs(args));
21823
+ /* c8 ignore next */
21824
+ vconsoles.forEach((vc) => vc.print(args));
21825
+ };
21826
+
21827
+ /* c8 ignore start */
21828
+ /**
21829
+ * @param {Array<string|Symbol|Object|number>} args
21830
+ */
21831
+ const warn = (...args) => {
21832
+ console.warn(...computeLoggingArgs(args));
21833
+ args.unshift(ORANGE);
21834
+ vconsoles.forEach((vc) => vc.print(args));
21835
+ };
21836
+
21837
+ const vconsoles = create$8();
20523
21838
 
20524
21839
  /**
20525
21840
  * Utility module to create and manipulate Iterators.
@@ -24039,7 +25354,7 @@ class YEvent {
24039
25354
  */
24040
25355
  this._changes = null;
24041
25356
  /**
24042
- * @type {null | Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
25357
+ * @type {null | Map<string, { action: 'add' | 'update' | 'delete', oldValue: any }>}
24043
25358
  */
24044
25359
  this._keys = null;
24045
25360
  /**
@@ -24082,7 +25397,7 @@ class YEvent {
24082
25397
  }
24083
25398
 
24084
25399
  /**
24085
- * @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
25400
+ * @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any }>}
24086
25401
  */
24087
25402
  get keys () {
24088
25403
  if (this._keys === null) {
@@ -27457,12 +28772,10 @@ class YXmlElement extends YXmlFragment {
27457
28772
  const el = new YXmlElement(this.nodeName);
27458
28773
  const attrs = this.getAttributes();
27459
28774
  forEach(attrs, (value, key) => {
27460
- if (typeof value === 'string') {
27461
- el.setAttribute(key, value);
27462
- }
28775
+ el.setAttribute(key, /** @type {any} */ (value));
27463
28776
  });
27464
28777
  // @ts-ignore
27465
- el.insert(0, this.toArray().map(item => item instanceof AbstractType ? item.clone() : item));
28778
+ el.insert(0, this.toArray().map(v => v instanceof AbstractType ? v.clone() : v));
27466
28779
  return el
27467
28780
  }
27468
28781
 
@@ -34407,7 +35720,7 @@ exports.KritzelWorkspace = KritzelWorkspace;
34407
35720
  exports.ObjectHelper = ObjectHelper;
34408
35721
  exports.Observable = Observable$1;
34409
35722
  exports.ObservableV2 = ObservableV2;
34410
- exports.Schema = Schema;
35723
+ exports.Schema = Schema$1;
34411
35724
  exports.TextSelection = TextSelection;
34412
35725
  exports.UndoManager = UndoManager;
34413
35726
  exports.addListNodes = addListNodes;
@@ -34425,7 +35738,7 @@ exports.fromBase64 = fromBase64;
34425
35738
  exports.getUnixTime = getUnixTime$1;
34426
35739
  exports.isNode = isNode;
34427
35740
  exports.keymap = keymap;
34428
- exports.length = length$3;
35741
+ exports.length = length$2;
34429
35742
  exports.map = map;
34430
35743
  exports.min = min$2;
34431
35744
  exports.offChange = offChange;
@@ -34442,6 +35755,3 @@ exports.varStorage = varStorage;
34442
35755
  exports.writeVarString = writeVarString$2;
34443
35756
  exports.writeVarUint = writeVarUint$2;
34444
35757
  exports.writeVarUint8Array = writeVarUint8Array$2;
34445
- //# sourceMappingURL=default-line-tool.config-JuTDR6PF.js.map
34446
-
34447
- //# sourceMappingURL=default-line-tool.config-JuTDR6PF.js.map