@ketvietlab/ketsuite 0.1.1 → 0.1.3

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 (2606) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +15 -1
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +59 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/deployment.d.ts +5 -0
  8. package/dist/deployment.d.ts.map +1 -0
  9. package/dist/deployment.js +152 -0
  10. package/dist/deployment.js.map +1 -0
  11. package/dist/development.d.ts +8 -0
  12. package/dist/development.d.ts.map +1 -0
  13. package/dist/development.js +40 -0
  14. package/dist/development.js.map +1 -0
  15. package/dist/index.d.ts +77 -6
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +66 -6
  18. package/dist/index.js.map +1 -1
  19. package/dist/modules/account/analytics.d.ts +32 -0
  20. package/dist/modules/account/analytics.d.ts.map +1 -0
  21. package/dist/modules/account/analytics.js +457 -0
  22. package/dist/modules/account/analytics.js.map +1 -0
  23. package/dist/modules/account/assets-costing.d.ts +4 -0
  24. package/dist/modules/account/assets-costing.d.ts.map +1 -0
  25. package/dist/modules/account/assets-costing.js +1134 -0
  26. package/dist/modules/account/assets-costing.js.map +1 -0
  27. package/dist/modules/account/audit.d.ts +3 -0
  28. package/dist/modules/account/audit.d.ts.map +1 -0
  29. package/dist/modules/account/audit.js +14 -0
  30. package/dist/modules/account/audit.js.map +1 -0
  31. package/dist/modules/account/books.d.ts +4 -0
  32. package/dist/modules/account/books.d.ts.map +1 -0
  33. package/dist/modules/account/books.js +150 -0
  34. package/dist/modules/account/books.js.map +1 -0
  35. package/dist/modules/account/cash-receivables.d.ts +3 -0
  36. package/dist/modules/account/cash-receivables.d.ts.map +1 -0
  37. package/dist/modules/account/cash-receivables.js +1087 -0
  38. package/dist/modules/account/cash-receivables.js.map +1 -0
  39. package/dist/modules/account/close.d.ts +4 -0
  40. package/dist/modules/account/close.d.ts.map +1 -0
  41. package/dist/modules/account/close.js +343 -0
  42. package/dist/modules/account/close.js.map +1 -0
  43. package/dist/modules/account/date.d.ts +21 -0
  44. package/dist/modules/account/date.d.ts.map +1 -0
  45. package/dist/modules/account/date.js +70 -0
  46. package/dist/modules/account/date.js.map +1 -0
  47. package/dist/modules/account/functions.d.ts +131 -3
  48. package/dist/modules/account/functions.d.ts.map +1 -1
  49. package/dist/modules/account/functions.js +2570 -389
  50. package/dist/modules/account/functions.js.map +1 -1
  51. package/dist/modules/account/index.d.ts +1 -2
  52. package/dist/modules/account/index.d.ts.map +1 -1
  53. package/dist/modules/account/index.js +403 -8
  54. package/dist/modules/account/index.js.map +1 -1
  55. package/dist/modules/account/models.d.ts.map +1 -1
  56. package/dist/modules/account/models.js +748 -0
  57. package/dist/modules/account/models.js.map +1 -1
  58. package/dist/modules/account/money.d.ts +60 -0
  59. package/dist/modules/account/money.d.ts.map +1 -0
  60. package/dist/modules/account/money.js +237 -0
  61. package/dist/modules/account/money.js.map +1 -0
  62. package/dist/modules/account/open-items.d.ts +3 -0
  63. package/dist/modules/account/open-items.d.ts.map +1 -0
  64. package/dist/modules/account/open-items.js +390 -0
  65. package/dist/modules/account/open-items.js.map +1 -0
  66. package/dist/modules/account/opening.d.ts +3 -0
  67. package/dist/modules/account/opening.d.ts.map +1 -0
  68. package/dist/modules/account/opening.js +323 -0
  69. package/dist/modules/account/opening.js.map +1 -0
  70. package/dist/modules/account/period.d.ts +21 -0
  71. package/dist/modules/account/period.d.ts.map +1 -0
  72. package/dist/modules/account/period.js +155 -0
  73. package/dist/modules/account/period.js.map +1 -0
  74. package/dist/modules/account/relations.d.ts.map +1 -1
  75. package/dist/modules/account/relations.js +46 -0
  76. package/dist/modules/account/relations.js.map +1 -1
  77. package/dist/modules/account/reports.d.ts +4 -0
  78. package/dist/modules/account/reports.d.ts.map +1 -0
  79. package/dist/modules/account/reports.js +125 -0
  80. package/dist/modules/account/reports.js.map +1 -0
  81. package/dist/modules/account/setup.d.ts +3 -1
  82. package/dist/modules/account/setup.d.ts.map +1 -1
  83. package/dist/modules/account/setup.js +45 -160
  84. package/dist/modules/account/setup.js.map +1 -1
  85. package/dist/modules/account_activity_backend/index.d.ts.map +1 -1
  86. package/dist/modules/account_activity_backend/index.js +0 -1
  87. package/dist/modules/account_activity_backend/index.js.map +1 -1
  88. package/dist/modules/account_backend/index.js +3339 -494
  89. package/dist/modules/account_backend/index.js.map +1 -1
  90. package/dist/modules/account_backend/overview.d.ts +92 -0
  91. package/dist/modules/account_backend/overview.d.ts.map +1 -0
  92. package/dist/modules/account_backend/overview.js +257 -0
  93. package/dist/modules/account_backend/overview.js.map +1 -0
  94. package/dist/modules/account_backend/relation-control.d.ts +48 -0
  95. package/dist/modules/account_backend/relation-control.d.ts.map +1 -0
  96. package/dist/modules/account_backend/relation-control.js +67 -0
  97. package/dist/modules/account_backend/relation-control.js.map +1 -0
  98. package/dist/modules/account_backend/screens/account-defaults.d.ts +28 -0
  99. package/dist/modules/account_backend/screens/account-defaults.d.ts.map +1 -0
  100. package/dist/modules/account_backend/screens/account-defaults.js +60 -0
  101. package/dist/modules/account_backend/screens/account-defaults.js.map +1 -0
  102. package/dist/modules/account_backend/screens/account-form.d.ts +16 -0
  103. package/dist/modules/account_backend/screens/account-form.d.ts.map +1 -0
  104. package/dist/modules/account_backend/screens/account-form.js +53 -0
  105. package/dist/modules/account_backend/screens/account-form.js.map +1 -0
  106. package/dist/modules/account_backend/screens/accounting-books.d.ts +15 -0
  107. package/dist/modules/account_backend/screens/accounting-books.d.ts.map +1 -0
  108. package/dist/modules/account_backend/screens/accounting-books.js +86 -0
  109. package/dist/modules/account_backend/screens/accounting-books.js.map +1 -0
  110. package/dist/modules/account_backend/screens/accounts-list.d.ts +50 -0
  111. package/dist/modules/account_backend/screens/accounts-list.d.ts.map +1 -0
  112. package/dist/modules/account_backend/screens/accounts-list.js +66 -0
  113. package/dist/modules/account_backend/screens/accounts-list.js.map +1 -0
  114. package/dist/modules/account_backend/screens/customer-invoice-form.d.ts +13 -0
  115. package/dist/modules/account_backend/screens/customer-invoice-form.d.ts.map +1 -0
  116. package/dist/modules/account_backend/screens/customer-invoice-form.js +20 -0
  117. package/dist/modules/account_backend/screens/customer-invoice-form.js.map +1 -0
  118. package/dist/modules/account_backend/screens/customer-invoices-list.d.ts +62 -0
  119. package/dist/modules/account_backend/screens/customer-invoices-list.d.ts.map +1 -0
  120. package/dist/modules/account_backend/screens/customer-invoices-list.js +82 -0
  121. package/dist/modules/account_backend/screens/customer-invoices-list.js.map +1 -0
  122. package/dist/modules/account_backend/screens/general-ledger.d.ts +24 -0
  123. package/dist/modules/account_backend/screens/general-ledger.d.ts.map +1 -0
  124. package/dist/modules/account_backend/screens/general-ledger.js +73 -0
  125. package/dist/modules/account_backend/screens/general-ledger.js.map +1 -0
  126. package/dist/modules/account_backend/screens/index.d.ts +27 -0
  127. package/dist/modules/account_backend/screens/index.d.ts.map +1 -0
  128. package/dist/modules/account_backend/screens/index.js +27 -0
  129. package/dist/modules/account_backend/screens/index.js.map +1 -0
  130. package/dist/modules/account_backend/screens/journal-entries-list.d.ts +48 -0
  131. package/dist/modules/account_backend/screens/journal-entries-list.d.ts.map +1 -0
  132. package/dist/modules/account_backend/screens/journal-entries-list.js +58 -0
  133. package/dist/modules/account_backend/screens/journal-entries-list.js.map +1 -0
  134. package/dist/modules/account_backend/screens/journal-entry-create.d.ts +14 -0
  135. package/dist/modules/account_backend/screens/journal-entry-create.d.ts.map +1 -0
  136. package/dist/modules/account_backend/screens/journal-entry-create.js +41 -0
  137. package/dist/modules/account_backend/screens/journal-entry-create.js.map +1 -0
  138. package/dist/modules/account_backend/screens/journal-form.d.ts +15 -0
  139. package/dist/modules/account_backend/screens/journal-form.d.ts.map +1 -0
  140. package/dist/modules/account_backend/screens/journal-form.js +53 -0
  141. package/dist/modules/account_backend/screens/journal-form.js.map +1 -0
  142. package/dist/modules/account_backend/screens/journals-list.d.ts +51 -0
  143. package/dist/modules/account_backend/screens/journals-list.d.ts.map +1 -0
  144. package/dist/modules/account_backend/screens/journals-list.js +70 -0
  145. package/dist/modules/account_backend/screens/journals-list.js.map +1 -0
  146. package/dist/modules/account_backend/screens/move-detail.d.ts +26 -0
  147. package/dist/modules/account_backend/screens/move-detail.d.ts.map +1 -0
  148. package/dist/modules/account_backend/screens/move-detail.js +130 -0
  149. package/dist/modules/account_backend/screens/move-detail.js.map +1 -0
  150. package/dist/modules/account_backend/screens/opening-balances.d.ts +28 -0
  151. package/dist/modules/account_backend/screens/opening-balances.d.ts.map +1 -0
  152. package/dist/modules/account_backend/screens/opening-balances.js +96 -0
  153. package/dist/modules/account_backend/screens/opening-balances.js.map +1 -0
  154. package/dist/modules/account_backend/screens/overview.d.ts +62 -0
  155. package/dist/modules/account_backend/screens/overview.d.ts.map +1 -0
  156. package/dist/modules/account_backend/screens/overview.js +215 -0
  157. package/dist/modules/account_backend/screens/overview.js.map +1 -0
  158. package/dist/modules/account_backend/screens/partner-statement.d.ts +26 -0
  159. package/dist/modules/account_backend/screens/partner-statement.d.ts.map +1 -0
  160. package/dist/modules/account_backend/screens/partner-statement.js +82 -0
  161. package/dist/modules/account_backend/screens/partner-statement.js.map +1 -0
  162. package/dist/modules/account_backend/screens/payment-form.d.ts +14 -0
  163. package/dist/modules/account_backend/screens/payment-form.d.ts.map +1 -0
  164. package/dist/modules/account_backend/screens/payment-form.js +21 -0
  165. package/dist/modules/account_backend/screens/payment-form.js.map +1 -0
  166. package/dist/modules/account_backend/screens/payment-term-form.d.ts +25 -0
  167. package/dist/modules/account_backend/screens/payment-term-form.d.ts.map +1 -0
  168. package/dist/modules/account_backend/screens/payment-term-form.js +96 -0
  169. package/dist/modules/account_backend/screens/payment-term-form.js.map +1 -0
  170. package/dist/modules/account_backend/screens/payment-terms-list.d.ts +23 -0
  171. package/dist/modules/account_backend/screens/payment-terms-list.d.ts.map +1 -0
  172. package/dist/modules/account_backend/screens/payment-terms-list.js +104 -0
  173. package/dist/modules/account_backend/screens/payment-terms-list.js.map +1 -0
  174. package/dist/modules/account_backend/screens/payments-list.d.ts +62 -0
  175. package/dist/modules/account_backend/screens/payments-list.d.ts.map +1 -0
  176. package/dist/modules/account_backend/screens/payments-list.js +71 -0
  177. package/dist/modules/account_backend/screens/payments-list.js.map +1 -0
  178. package/dist/modules/account_backend/screens/period-closes.d.ts +21 -0
  179. package/dist/modules/account_backend/screens/period-closes.d.ts.map +1 -0
  180. package/dist/modules/account_backend/screens/period-closes.js +123 -0
  181. package/dist/modules/account_backend/screens/period-closes.js.map +1 -0
  182. package/dist/modules/account_backend/screens/shared.d.ts +16 -0
  183. package/dist/modules/account_backend/screens/shared.d.ts.map +1 -0
  184. package/dist/modules/account_backend/screens/shared.js +15 -0
  185. package/dist/modules/account_backend/screens/shared.js.map +1 -0
  186. package/dist/modules/account_backend/screens/tax-form.d.ts +14 -0
  187. package/dist/modules/account_backend/screens/tax-form.d.ts.map +1 -0
  188. package/dist/modules/account_backend/screens/tax-form.js +25 -0
  189. package/dist/modules/account_backend/screens/tax-form.js.map +1 -0
  190. package/dist/modules/account_backend/screens/taxes-list.d.ts +55 -0
  191. package/dist/modules/account_backend/screens/taxes-list.d.ts.map +1 -0
  192. package/dist/modules/account_backend/screens/taxes-list.js +83 -0
  193. package/dist/modules/account_backend/screens/taxes-list.js.map +1 -0
  194. package/dist/modules/account_backend/screens/trial-balance.d.ts +19 -0
  195. package/dist/modules/account_backend/screens/trial-balance.d.ts.map +1 -0
  196. package/dist/modules/account_backend/screens/trial-balance.js +75 -0
  197. package/dist/modules/account_backend/screens/trial-balance.js.map +1 -0
  198. package/dist/modules/account_backend/screens/vendor-bill-form.d.ts +13 -0
  199. package/dist/modules/account_backend/screens/vendor-bill-form.d.ts.map +1 -0
  200. package/dist/modules/account_backend/screens/vendor-bill-form.js +20 -0
  201. package/dist/modules/account_backend/screens/vendor-bill-form.js.map +1 -0
  202. package/dist/modules/account_backend/screens/vendor-bills-list.d.ts +62 -0
  203. package/dist/modules/account_backend/screens/vendor-bills-list.d.ts.map +1 -0
  204. package/dist/modules/account_backend/screens/vendor-bills-list.js +84 -0
  205. package/dist/modules/account_backend/screens/vendor-bills-list.js.map +1 -0
  206. package/dist/modules/account_mail_backend/index.d.ts.map +1 -1
  207. package/dist/modules/account_mail_backend/index.js +0 -1
  208. package/dist/modules/account_mail_backend/index.js.map +1 -1
  209. package/dist/modules/account_partner/index.js +0 -2
  210. package/dist/modules/account_partner/index.js.map +1 -1
  211. package/dist/modules/account_partner_backend/index.d.ts +1 -1
  212. package/dist/modules/account_partner_backend/index.d.ts.map +1 -1
  213. package/dist/modules/account_partner_backend/index.js +2 -3
  214. package/dist/modules/account_partner_backend/index.js.map +1 -1
  215. package/dist/modules/account_partner_backend/routes.d.ts.map +1 -1
  216. package/dist/modules/account_partner_backend/routes.js +19 -25
  217. package/dist/modules/account_partner_backend/routes.js.map +1 -1
  218. package/dist/modules/account_partner_backend/screens/accounting-terms.d.ts +20 -0
  219. package/dist/modules/account_partner_backend/screens/accounting-terms.d.ts.map +1 -0
  220. package/dist/modules/account_partner_backend/screens/accounting-terms.js +63 -0
  221. package/dist/modules/account_partner_backend/screens/accounting-terms.js.map +1 -0
  222. package/dist/modules/account_partner_backend/screens/index.d.ts +2 -0
  223. package/dist/modules/account_partner_backend/screens/index.d.ts.map +1 -0
  224. package/dist/modules/account_partner_backend/screens/index.js +2 -0
  225. package/dist/modules/account_partner_backend/screens/index.js.map +1 -0
  226. package/dist/modules/account_staff_channel/channel-routes.d.ts +2 -0
  227. package/dist/modules/account_staff_channel/channel-routes.d.ts.map +1 -0
  228. package/dist/modules/account_staff_channel/channel-routes.js +787 -0
  229. package/dist/modules/account_staff_channel/channel-routes.js.map +1 -0
  230. package/dist/modules/account_staff_channel/functions.d.ts.map +1 -0
  231. package/dist/modules/account_staff_channel/functions.js +143 -0
  232. package/dist/modules/account_staff_channel/functions.js.map +1 -0
  233. package/dist/modules/account_staff_channel/index.d.ts +5 -0
  234. package/dist/modules/account_staff_channel/index.d.ts.map +1 -0
  235. package/dist/modules/account_staff_channel/index.js +42 -0
  236. package/dist/modules/account_staff_channel/index.js.map +1 -0
  237. package/dist/modules/account_staff_channel/models.d.ts.map +1 -0
  238. package/dist/modules/account_staff_channel/models.js +30 -0
  239. package/dist/modules/account_staff_channel/models.js.map +1 -0
  240. package/dist/modules/activity/index.d.ts.map +1 -1
  241. package/dist/modules/activity/index.js +0 -1
  242. package/dist/modules/activity/index.js.map +1 -1
  243. package/dist/modules/activity_backend/index.d.ts +1 -1
  244. package/dist/modules/activity_backend/index.d.ts.map +1 -1
  245. package/dist/modules/activity_backend/index.js +3 -12
  246. package/dist/modules/activity_backend/index.js.map +1 -1
  247. package/dist/modules/activity_backend/routes.d.ts.map +1 -1
  248. package/dist/modules/activity_backend/routes.js +36 -22
  249. package/dist/modules/activity_backend/routes.js.map +1 -1
  250. package/dist/modules/activity_backend/screens/activities-list.d.ts +15 -0
  251. package/dist/modules/activity_backend/screens/activities-list.d.ts.map +1 -0
  252. package/dist/modules/activity_backend/screens/activities-list.js +40 -0
  253. package/dist/modules/activity_backend/screens/activities-list.js.map +1 -0
  254. package/dist/modules/activity_backend/screens/index.d.ts +2 -0
  255. package/dist/modules/activity_backend/screens/index.d.ts.map +1 -0
  256. package/dist/modules/activity_backend/screens/index.js +2 -0
  257. package/dist/modules/activity_backend/screens/index.js.map +1 -0
  258. package/dist/modules/address/data/VN/NOTICE.md +1 -1
  259. package/dist/modules/address/index.d.ts.map +1 -1
  260. package/dist/modules/address/index.js +0 -1
  261. package/dist/modules/address/index.js.map +1 -1
  262. package/dist/modules/address_backend/index.d.ts +1 -1
  263. package/dist/modules/address_backend/index.d.ts.map +1 -1
  264. package/dist/modules/address_backend/index.js +1 -3
  265. package/dist/modules/address_backend/index.js.map +1 -1
  266. package/dist/modules/address_backend/routes.d.ts.map +1 -1
  267. package/dist/modules/address_backend/routes.js +20 -27
  268. package/dist/modules/address_backend/routes.js.map +1 -1
  269. package/dist/modules/address_backend/screens/catalogs-list.d.ts +14 -0
  270. package/dist/modules/address_backend/screens/catalogs-list.d.ts.map +1 -0
  271. package/dist/modules/address_backend/screens/catalogs-list.js +38 -0
  272. package/dist/modules/address_backend/screens/catalogs-list.js.map +1 -0
  273. package/dist/modules/address_backend/screens/country-browser.d.ts +12 -0
  274. package/dist/modules/address_backend/screens/country-browser.d.ts.map +1 -0
  275. package/dist/modules/address_backend/screens/country-browser.js +74 -0
  276. package/dist/modules/address_backend/screens/country-browser.js.map +1 -0
  277. package/dist/modules/address_backend/screens/index.d.ts +4 -0
  278. package/dist/modules/address_backend/screens/index.d.ts.map +1 -0
  279. package/dist/modules/address_backend/screens/index.js +3 -0
  280. package/dist/modules/address_backend/screens/index.js.map +1 -0
  281. package/dist/modules/address_backend/screens/types.d.ts +20 -0
  282. package/dist/modules/address_backend/screens/types.d.ts.map +1 -0
  283. package/dist/modules/address_backend/screens/types.js.map +1 -0
  284. package/dist/modules/attendance/channel-routes.d.ts +2 -0
  285. package/dist/modules/attendance/channel-routes.d.ts.map +1 -0
  286. package/dist/modules/attendance/channel-routes.js +234 -0
  287. package/dist/modules/attendance/channel-routes.js.map +1 -0
  288. package/dist/modules/attendance/functions.d.ts.map +1 -1
  289. package/dist/modules/attendance/functions.js +171 -22
  290. package/dist/modules/attendance/functions.js.map +1 -1
  291. package/dist/modules/attendance/index.d.ts.map +1 -1
  292. package/dist/modules/attendance/index.js +4 -2
  293. package/dist/modules/attendance/index.js.map +1 -1
  294. package/dist/modules/attendance/messages.d.ts +6 -0
  295. package/dist/modules/attendance/messages.d.ts.map +1 -1
  296. package/dist/modules/attendance/messages.js +6 -0
  297. package/dist/modules/attendance/messages.js.map +1 -1
  298. package/dist/modules/attendance/models.d.ts.map +1 -1
  299. package/dist/modules/attendance/models.js +1 -0
  300. package/dist/modules/attendance/models.js.map +1 -1
  301. package/dist/modules/attendance_backend/index.d.ts +3 -1
  302. package/dist/modules/attendance_backend/index.d.ts.map +1 -1
  303. package/dist/modules/attendance_backend/index.js +65 -4
  304. package/dist/modules/attendance_backend/index.js.map +1 -1
  305. package/dist/modules/attendance_backend/routes.d.ts.map +1 -1
  306. package/dist/modules/attendance_backend/routes.js +240 -53
  307. package/dist/modules/attendance_backend/routes.js.map +1 -1
  308. package/dist/modules/attendance_backend/screens/credentials.d.ts +32 -0
  309. package/dist/modules/attendance_backend/screens/credentials.d.ts.map +1 -0
  310. package/dist/modules/attendance_backend/screens/credentials.js +84 -0
  311. package/dist/modules/attendance_backend/screens/credentials.js.map +1 -0
  312. package/dist/modules/attendance_backend/screens/index.d.ts +4 -0
  313. package/dist/modules/attendance_backend/screens/index.d.ts.map +1 -0
  314. package/dist/modules/attendance_backend/screens/index.js +4 -0
  315. package/dist/modules/attendance_backend/screens/index.js.map +1 -0
  316. package/dist/modules/attendance_backend/screens/my-work.d.ts +35 -0
  317. package/dist/modules/attendance_backend/screens/my-work.d.ts.map +1 -0
  318. package/dist/modules/attendance_backend/screens/my-work.js +189 -0
  319. package/dist/modules/attendance_backend/screens/my-work.js.map +1 -0
  320. package/dist/modules/attendance_backend/screens/period.d.ts +22 -0
  321. package/dist/modules/attendance_backend/screens/period.d.ts.map +1 -0
  322. package/dist/modules/attendance_backend/screens/period.js +85 -0
  323. package/dist/modules/attendance_backend/screens/period.js.map +1 -0
  324. package/dist/modules/attendance_backend/screens.d.ts +0 -4
  325. package/dist/modules/attendance_backend/screens.d.ts.map +1 -1
  326. package/dist/modules/attendance_backend/screens.js +1 -209
  327. package/dist/modules/attendance_backend/screens.js.map +1 -1
  328. package/dist/modules/backend/catalogue.d.ts.map +1 -1
  329. package/dist/modules/backend/catalogue.js +53 -115
  330. package/dist/modules/backend/catalogue.js.map +1 -1
  331. package/dist/modules/backend/chart.d.ts +42 -0
  332. package/dist/modules/backend/chart.d.ts.map +1 -0
  333. package/dist/modules/backend/chart.js +39 -0
  334. package/dist/modules/backend/chart.js.map +1 -0
  335. package/dist/modules/backend/design/HANDOFF.md +118 -38
  336. package/dist/modules/backend/design/auth.css +463 -0
  337. package/dist/modules/backend/design/brand/logo-dark.png +0 -0
  338. package/dist/modules/backend/design/brand/logo-light.png +0 -0
  339. package/dist/modules/backend/design/charts.css +229 -0
  340. package/dist/modules/backend/design/client/chart.d.mts +31 -0
  341. package/dist/modules/backend/design/client/chart.d.mts.map +1 -0
  342. package/dist/modules/backend/design/client/chart.mjs +23 -0
  343. package/dist/modules/backend/design/client/chart.mjs.map +7 -0
  344. package/dist/modules/backend/design/client/relation-select.d.mts +6 -1
  345. package/dist/modules/backend/design/client/relation-select.d.mts.map +1 -1
  346. package/dist/modules/backend/design/client/relation-select.mjs +2 -7
  347. package/dist/modules/backend/design/client/relation-select.mjs.map +7 -1
  348. package/dist/modules/backend/design/client/table-selection.d.mts +7 -0
  349. package/dist/modules/backend/design/client/table-selection.d.mts.map +1 -0
  350. package/dist/modules/backend/design/client/table-selection.mjs +2 -0
  351. package/dist/modules/backend/design/client/table-selection.mjs.map +7 -0
  352. package/dist/modules/backend/design/content.css +766 -0
  353. package/dist/modules/backend/design/controls.css +451 -0
  354. package/dist/modules/backend/design/design-system.css +2 -0
  355. package/dist/modules/backend/design/forms.css +1134 -0
  356. package/dist/modules/backend/design/foundation.css +423 -0
  357. package/dist/modules/backend/design/lists.css +1462 -0
  358. package/dist/modules/backend/design/record.css +526 -0
  359. package/dist/modules/backend/design/responsive.css +331 -0
  360. package/dist/modules/backend/design/tokens.css +317 -92
  361. package/dist/modules/backend/index.d.ts +12 -5
  362. package/dist/modules/backend/index.d.ts.map +1 -1
  363. package/dist/modules/backend/index.js +32 -15
  364. package/dist/modules/backend/index.js.map +1 -1
  365. package/dist/modules/backend/islands.d.ts.map +1 -1
  366. package/dist/modules/backend/islands.js +22 -4
  367. package/dist/modules/backend/islands.js.map +1 -1
  368. package/dist/modules/backend/joints.d.ts +1 -1
  369. package/dist/modules/backend/joints.d.ts.map +1 -1
  370. package/dist/modules/backend/joints.js +14 -6
  371. package/dist/modules/backend/joints.js.map +1 -1
  372. package/dist/modules/backend/list-search.d.ts +33 -0
  373. package/dist/modules/backend/list-search.d.ts.map +1 -0
  374. package/dist/modules/backend/list-search.js +232 -0
  375. package/dist/modules/backend/list-search.js.map +1 -0
  376. package/dist/modules/backend/menus.d.ts.map +1 -1
  377. package/dist/modules/backend/menus.js +3 -12
  378. package/dist/modules/backend/menus.js.map +1 -1
  379. package/dist/modules/backend/messages.d.ts +1 -1
  380. package/dist/modules/backend/messages.d.ts.map +1 -1
  381. package/dist/modules/backend/messages.js +48 -35
  382. package/dist/modules/backend/messages.js.map +1 -1
  383. package/dist/modules/backend/paging.d.ts +1 -1
  384. package/dist/modules/backend/paging.d.ts.map +1 -1
  385. package/dist/modules/backend/paging.js +1 -1
  386. package/dist/modules/backend/paging.js.map +1 -1
  387. package/dist/modules/backend/relation-select.d.ts +2 -57
  388. package/dist/modules/backend/relation-select.d.ts.map +1 -1
  389. package/dist/modules/backend/relation-select.js +2 -0
  390. package/dist/modules/backend/relation-select.js.map +1 -1
  391. package/dist/modules/backend/routes.d.ts +1 -8
  392. package/dist/modules/backend/routes.d.ts.map +1 -1
  393. package/dist/modules/backend/routes.js +36 -111
  394. package/dist/modules/backend/routes.js.map +1 -1
  395. package/dist/modules/backend/screen.d.ts +130 -0
  396. package/dist/modules/backend/screen.d.ts.map +1 -0
  397. package/dist/modules/backend/screen.js +205 -0
  398. package/dist/modules/backend/screen.js.map +1 -0
  399. package/dist/modules/backend/screens.d.ts +11 -14
  400. package/dist/modules/backend/screens.d.ts.map +1 -1
  401. package/dist/modules/backend/screens.js +13 -70
  402. package/dist/modules/backend/screens.js.map +1 -1
  403. package/dist/modules/business_report_staff_channel/channel-routes.d.ts +2 -0
  404. package/dist/modules/business_report_staff_channel/channel-routes.d.ts.map +1 -0
  405. package/dist/modules/business_report_staff_channel/channel-routes.js +438 -0
  406. package/dist/modules/business_report_staff_channel/channel-routes.js.map +1 -0
  407. package/dist/modules/business_report_staff_channel/index.d.ts +5 -0
  408. package/dist/modules/business_report_staff_channel/index.d.ts.map +1 -0
  409. package/dist/modules/business_report_staff_channel/index.js +18 -0
  410. package/dist/modules/business_report_staff_channel/index.js.map +1 -0
  411. package/dist/modules/calendar/index.d.ts.map +1 -1
  412. package/dist/modules/calendar/index.js +0 -1
  413. package/dist/modules/calendar/index.js.map +1 -1
  414. package/dist/modules/calendar/recurrence.d.ts.map +1 -1
  415. package/dist/modules/calendar/recurrence.js +3 -11
  416. package/dist/modules/calendar/recurrence.js.map +1 -1
  417. package/dist/modules/calendar_activity/index.d.ts.map +1 -1
  418. package/dist/modules/calendar_activity/index.js +0 -2
  419. package/dist/modules/calendar_activity/index.js.map +1 -1
  420. package/dist/modules/calendar_backend/index.d.ts +1 -1
  421. package/dist/modules/calendar_backend/index.d.ts.map +1 -1
  422. package/dist/modules/calendar_backend/index.js +1 -3
  423. package/dist/modules/calendar_backend/index.js.map +1 -1
  424. package/dist/modules/calendar_backend/routes.d.ts.map +1 -1
  425. package/dist/modules/calendar_backend/routes.js +10 -22
  426. package/dist/modules/calendar_backend/routes.js.map +1 -1
  427. package/dist/modules/calendar_backend/screens/calendar.d.ts +5 -0
  428. package/dist/modules/calendar_backend/screens/calendar.d.ts.map +1 -0
  429. package/dist/modules/calendar_backend/screens/calendar.js +10 -0
  430. package/dist/modules/calendar_backend/screens/calendar.js.map +1 -0
  431. package/dist/modules/calendar_backend/screens/index.d.ts +2 -0
  432. package/dist/modules/calendar_backend/screens/index.d.ts.map +1 -0
  433. package/dist/modules/calendar_backend/screens/index.js +2 -0
  434. package/dist/modules/calendar_backend/screens/index.js.map +1 -0
  435. package/dist/modules/calendar_mail_transport/index.d.ts.map +1 -1
  436. package/dist/modules/calendar_mail_transport/index.js +0 -2
  437. package/dist/modules/calendar_mail_transport/index.js.map +1 -1
  438. package/dist/modules/channel_api/core.d.ts +253 -0
  439. package/dist/modules/channel_api/core.d.ts.map +1 -0
  440. package/dist/modules/channel_api/core.js +587 -0
  441. package/dist/modules/channel_api/core.js.map +1 -0
  442. package/dist/modules/channel_api/customer.d.ts +21 -0
  443. package/dist/modules/channel_api/customer.d.ts.map +1 -0
  444. package/dist/modules/channel_api/customer.js +368 -0
  445. package/dist/modules/channel_api/customer.js.map +1 -0
  446. package/dist/modules/channel_api/index.d.ts +6 -0
  447. package/dist/modules/channel_api/index.d.ts.map +1 -0
  448. package/dist/modules/channel_api/index.js +66 -0
  449. package/dist/modules/channel_api/index.js.map +1 -0
  450. package/dist/modules/channel_api/openapi.d.ts +17 -0
  451. package/dist/modules/channel_api/openapi.d.ts.map +1 -0
  452. package/dist/modules/channel_api/openapi.js +105 -0
  453. package/dist/modules/channel_api/openapi.js.map +1 -0
  454. package/dist/modules/channel_api/staff.d.ts +7 -0
  455. package/dist/modules/channel_api/staff.d.ts.map +1 -0
  456. package/dist/modules/channel_api/staff.js +209 -0
  457. package/dist/modules/channel_api/staff.js.map +1 -0
  458. package/dist/modules/company/functions.d.ts.map +1 -1
  459. package/dist/modules/company/functions.js +93 -12
  460. package/dist/modules/company/functions.js.map +1 -1
  461. package/dist/modules/company/index.js +3 -3
  462. package/dist/modules/company/index.js.map +1 -1
  463. package/dist/modules/company/messages.d.ts +8 -0
  464. package/dist/modules/company/messages.d.ts.map +1 -1
  465. package/dist/modules/company/messages.js +8 -0
  466. package/dist/modules/company/messages.js.map +1 -1
  467. package/dist/modules/company/models.d.ts +2 -2
  468. package/dist/modules/company/models.d.ts.map +1 -1
  469. package/dist/modules/company/models.js +12 -2
  470. package/dist/modules/company/models.js.map +1 -1
  471. package/dist/modules/company_backend/index.d.ts +2 -1
  472. package/dist/modules/company_backend/index.d.ts.map +1 -1
  473. package/dist/modules/company_backend/index.js +25 -4
  474. package/dist/modules/company_backend/index.js.map +1 -1
  475. package/dist/modules/company_backend/routes.d.ts.map +1 -1
  476. package/dist/modules/company_backend/routes.js +314 -96
  477. package/dist/modules/company_backend/routes.js.map +1 -1
  478. package/dist/modules/company_backend/screens/branch-form.d.ts +18 -0
  479. package/dist/modules/company_backend/screens/branch-form.d.ts.map +1 -0
  480. package/dist/modules/company_backend/screens/branch-form.js +63 -0
  481. package/dist/modules/company_backend/screens/branch-form.js.map +1 -0
  482. package/dist/modules/company_backend/screens/companies-list.d.ts +18 -0
  483. package/dist/modules/company_backend/screens/companies-list.d.ts.map +1 -0
  484. package/dist/modules/company_backend/screens/companies-list.js +49 -0
  485. package/dist/modules/company_backend/screens/companies-list.js.map +1 -0
  486. package/dist/modules/company_backend/screens/company-form.d.ts +25 -0
  487. package/dist/modules/company_backend/screens/company-form.d.ts.map +1 -0
  488. package/dist/modules/company_backend/screens/company-form.js +159 -0
  489. package/dist/modules/company_backend/screens/company-form.js.map +1 -0
  490. package/dist/modules/company_backend/screens/context.d.ts +30 -0
  491. package/dist/modules/company_backend/screens/context.d.ts.map +1 -0
  492. package/dist/modules/company_backend/screens/context.js +48 -0
  493. package/dist/modules/company_backend/screens/context.js.map +1 -0
  494. package/dist/modules/company_backend/screens/hierarchy.d.ts +16 -0
  495. package/dist/modules/company_backend/screens/hierarchy.d.ts.map +1 -0
  496. package/dist/modules/company_backend/screens/hierarchy.js +41 -0
  497. package/dist/modules/company_backend/screens/hierarchy.js.map +1 -0
  498. package/dist/modules/company_backend/screens/index.d.ts +7 -0
  499. package/dist/modules/company_backend/screens/index.d.ts.map +1 -0
  500. package/dist/modules/company_backend/screens/index.js +6 -0
  501. package/dist/modules/company_backend/screens/index.js.map +1 -0
  502. package/dist/modules/company_backend/screens/types.d.ts +22 -0
  503. package/dist/modules/company_backend/screens/types.d.ts.map +1 -0
  504. package/dist/modules/company_backend/screens/types.js +2 -0
  505. package/dist/modules/company_backend/screens/types.js.map +1 -0
  506. package/dist/modules/crm/functions.d.ts +1 -1
  507. package/dist/modules/crm/functions.d.ts.map +1 -1
  508. package/dist/modules/crm/functions.js +534 -75
  509. package/dist/modules/crm/functions.js.map +1 -1
  510. package/dist/modules/crm/index.d.ts +2 -1
  511. package/dist/modules/crm/index.d.ts.map +1 -1
  512. package/dist/modules/crm/index.js +3 -4
  513. package/dist/modules/crm/index.js.map +1 -1
  514. package/dist/modules/crm/jobs.d.ts +10 -0
  515. package/dist/modules/crm/jobs.d.ts.map +1 -1
  516. package/dist/modules/crm/jobs.js +50 -1
  517. package/dist/modules/crm/jobs.js.map +1 -1
  518. package/dist/modules/crm/messages.d.ts +14 -1
  519. package/dist/modules/crm/messages.d.ts.map +1 -1
  520. package/dist/modules/crm/messages.js +26 -0
  521. package/dist/modules/crm/messages.js.map +1 -1
  522. package/dist/modules/crm/models.d.ts.map +1 -1
  523. package/dist/modules/crm/models.js +25 -0
  524. package/dist/modules/crm/models.js.map +1 -1
  525. package/dist/modules/crm/operations.d.ts +110 -1
  526. package/dist/modules/crm/operations.d.ts.map +1 -1
  527. package/dist/modules/crm/operations.js +612 -84
  528. package/dist/modules/crm/operations.js.map +1 -1
  529. package/dist/modules/crm_backend/client/crm-kanban-view.d.mts.map +1 -1
  530. package/dist/modules/crm_backend/client/crm-kanban-view.mjs +132 -32
  531. package/dist/modules/crm_backend/client/crm-kanban-view.mjs.map +1 -1
  532. package/dist/modules/crm_backend/client/crm.css +398 -63
  533. package/dist/modules/crm_backend/index.d.ts.map +1 -1
  534. package/dist/modules/crm_backend/index.js +12 -4
  535. package/dist/modules/crm_backend/index.js.map +1 -1
  536. package/dist/modules/crm_backend/messages.d.ts +212 -0
  537. package/dist/modules/crm_backend/messages.d.ts.map +1 -1
  538. package/dist/modules/crm_backend/messages.js +212 -0
  539. package/dist/modules/crm_backend/messages.js.map +1 -1
  540. package/dist/modules/crm_backend/relation-control.d.ts +51 -0
  541. package/dist/modules/crm_backend/relation-control.d.ts.map +1 -0
  542. package/dist/modules/crm_backend/relation-control.js +107 -0
  543. package/dist/modules/crm_backend/relation-control.js.map +1 -0
  544. package/dist/modules/crm_backend/routes.d.ts.map +1 -1
  545. package/dist/modules/crm_backend/routes.js +1068 -260
  546. package/dist/modules/crm_backend/routes.js.map +1 -1
  547. package/dist/modules/crm_backend/screens/activity-planner.d.ts +22 -0
  548. package/dist/modules/crm_backend/screens/activity-planner.d.ts.map +1 -0
  549. package/dist/modules/crm_backend/screens/activity-planner.js +159 -0
  550. package/dist/modules/crm_backend/screens/activity-planner.js.map +1 -0
  551. package/dist/modules/crm_backend/screens/case-create.d.ts +15 -0
  552. package/dist/modules/crm_backend/screens/case-create.d.ts.map +1 -0
  553. package/dist/modules/crm_backend/screens/case-create.js +19 -0
  554. package/dist/modules/crm_backend/screens/case-create.js.map +1 -0
  555. package/dist/modules/crm_backend/screens/case-detail.d.ts +46 -0
  556. package/dist/modules/crm_backend/screens/case-detail.d.ts.map +1 -0
  557. package/dist/modules/crm_backend/screens/case-detail.js +506 -0
  558. package/dist/modules/crm_backend/screens/case-detail.js.map +1 -0
  559. package/dist/modules/crm_backend/screens/cases-list.d.ts +16 -0
  560. package/dist/modules/crm_backend/screens/cases-list.d.ts.map +1 -0
  561. package/dist/modules/crm_backend/screens/cases-list.js +86 -0
  562. package/dist/modules/crm_backend/screens/cases-list.js.map +1 -0
  563. package/dist/modules/crm_backend/screens/configuration.d.ts +28 -0
  564. package/dist/modules/crm_backend/screens/configuration.d.ts.map +1 -0
  565. package/dist/modules/crm_backend/screens/configuration.js +115 -0
  566. package/dist/modules/crm_backend/screens/configuration.js.map +1 -0
  567. package/dist/modules/crm_backend/screens/index.d.ts +14 -0
  568. package/dist/modules/crm_backend/screens/index.d.ts.map +1 -0
  569. package/dist/modules/crm_backend/screens/index.js +8 -0
  570. package/dist/modules/crm_backend/screens/index.js.map +1 -0
  571. package/dist/modules/crm_backend/screens/leaderboard.d.ts +12 -0
  572. package/dist/modules/crm_backend/screens/leaderboard.d.ts.map +1 -0
  573. package/dist/modules/crm_backend/screens/leaderboard.js +89 -0
  574. package/dist/modules/crm_backend/screens/leaderboard.js.map +1 -0
  575. package/dist/modules/crm_backend/screens/pipeline.d.ts +21 -0
  576. package/dist/modules/crm_backend/screens/pipeline.d.ts.map +1 -0
  577. package/dist/modules/crm_backend/screens/pipeline.js +22 -0
  578. package/dist/modules/crm_backend/screens/pipeline.js.map +1 -0
  579. package/dist/modules/crm_sale/index.d.ts.map +1 -1
  580. package/dist/modules/crm_sale/index.js +3 -4
  581. package/dist/modules/crm_sale/index.js.map +1 -1
  582. package/dist/modules/crm_sale/messages.d.ts +3 -1
  583. package/dist/modules/crm_sale/messages.d.ts.map +1 -1
  584. package/dist/modules/crm_sale/messages.js +4 -0
  585. package/dist/modules/crm_sale/messages.js.map +1 -1
  586. package/dist/modules/crm_sale/sale-functions.d.ts +8 -1
  587. package/dist/modules/crm_sale/sale-functions.d.ts.map +1 -1
  588. package/dist/modules/crm_sale/sale-functions.js +184 -55
  589. package/dist/modules/crm_sale/sale-functions.js.map +1 -1
  590. package/dist/modules/crm_staff_channel/channel-routes.d.ts +2 -0
  591. package/dist/modules/crm_staff_channel/channel-routes.d.ts.map +1 -0
  592. package/dist/modules/crm_staff_channel/channel-routes.js +788 -0
  593. package/dist/modules/crm_staff_channel/channel-routes.js.map +1 -0
  594. package/dist/modules/crm_staff_channel/index.d.ts +5 -0
  595. package/dist/modules/crm_staff_channel/index.d.ts.map +1 -0
  596. package/dist/modules/crm_staff_channel/index.js +30 -0
  597. package/dist/modules/crm_staff_channel/index.js.map +1 -0
  598. package/dist/modules/crm_website/functions.d.ts.map +1 -1
  599. package/dist/modules/crm_website/functions.js +89 -10
  600. package/dist/modules/crm_website/functions.js.map +1 -1
  601. package/dist/modules/crm_website/index.js +1 -2
  602. package/dist/modules/crm_website/index.js.map +1 -1
  603. package/dist/modules/crm_website/messages.d.ts +4 -1
  604. package/dist/modules/crm_website/messages.d.ts.map +1 -1
  605. package/dist/modules/crm_website/messages.js +6 -0
  606. package/dist/modules/crm_website/messages.js.map +1 -1
  607. package/dist/modules/crm_website/models.d.ts.map +1 -1
  608. package/dist/modules/crm_website/models.js +18 -0
  609. package/dist/modules/crm_website/models.js.map +1 -1
  610. package/dist/modules/crm_website/routes.d.ts.map +1 -1
  611. package/dist/modules/crm_website/routes.js +44 -12
  612. package/dist/modules/crm_website/routes.js.map +1 -1
  613. package/dist/modules/crm_website/screens.d.ts +7 -1
  614. package/dist/modules/crm_website/screens.d.ts.map +1 -1
  615. package/dist/modules/crm_website/screens.js +13 -8
  616. package/dist/modules/crm_website/screens.js.map +1 -1
  617. package/dist/modules/flow/functions.d.ts +3 -0
  618. package/dist/modules/flow/functions.d.ts.map +1 -0
  619. package/dist/modules/flow/functions.js +1876 -0
  620. package/dist/modules/flow/functions.js.map +1 -0
  621. package/dist/modules/flow/index.d.ts +12 -0
  622. package/dist/modules/flow/index.d.ts.map +1 -0
  623. package/dist/modules/flow/index.js +30 -0
  624. package/dist/modules/flow/index.js.map +1 -0
  625. package/dist/modules/flow/jobs.d.ts +3 -0
  626. package/dist/modules/flow/jobs.d.ts.map +1 -0
  627. package/dist/modules/flow/jobs.js +136 -0
  628. package/dist/modules/flow/jobs.js.map +1 -0
  629. package/dist/modules/flow/membership.d.ts +72 -0
  630. package/dist/modules/flow/membership.d.ts.map +1 -0
  631. package/dist/modules/flow/membership.js +176 -0
  632. package/dist/modules/flow/membership.js.map +1 -0
  633. package/dist/modules/flow/messages.d.ts +79 -0
  634. package/dist/modules/flow/messages.d.ts.map +1 -0
  635. package/dist/modules/flow/messages.js +152 -0
  636. package/dist/modules/flow/messages.js.map +1 -0
  637. package/dist/modules/flow/models.d.ts +3 -0
  638. package/dist/modules/flow/models.d.ts.map +1 -0
  639. package/dist/modules/flow/models.js +453 -0
  640. package/dist/modules/flow/models.js.map +1 -0
  641. package/dist/modules/flow/operations.d.ts +408 -0
  642. package/dist/modules/flow/operations.d.ts.map +1 -0
  643. package/dist/modules/flow/operations.js +1665 -0
  644. package/dist/modules/flow/operations.js.map +1 -0
  645. package/dist/modules/flow/pages.d.ts +146 -0
  646. package/dist/modules/flow/pages.d.ts.map +1 -0
  647. package/dist/modules/flow/pages.js +394 -0
  648. package/dist/modules/flow/pages.js.map +1 -0
  649. package/dist/modules/flow/projects.d.ts +41 -0
  650. package/dist/modules/flow/projects.d.ts.map +1 -0
  651. package/dist/modules/flow/projects.js +74 -0
  652. package/dist/modules/flow/projects.js.map +1 -0
  653. package/dist/modules/flow/search.d.ts +57 -0
  654. package/dist/modules/flow/search.d.ts.map +1 -0
  655. package/dist/modules/flow/search.js +110 -0
  656. package/dist/modules/flow/search.js.map +1 -0
  657. package/dist/modules/flow/types.d.ts +17 -0
  658. package/dist/modules/flow/types.d.ts.map +1 -0
  659. package/dist/modules/flow/types.js +13 -0
  660. package/dist/modules/flow/types.js.map +1 -0
  661. package/dist/modules/flow_backend/functions.d.ts +3 -0
  662. package/dist/modules/flow_backend/functions.d.ts.map +1 -0
  663. package/dist/modules/flow_backend/functions.js +162 -0
  664. package/dist/modules/flow_backend/functions.js.map +1 -0
  665. package/dist/modules/flow_backend/index.d.ts +3 -0
  666. package/dist/modules/flow_backend/index.d.ts.map +1 -0
  667. package/dist/modules/flow_backend/index.js +96 -0
  668. package/dist/modules/flow_backend/index.js.map +1 -0
  669. package/dist/modules/flow_backend/islands.d.ts +3 -0
  670. package/dist/modules/flow_backend/islands.d.ts.map +1 -0
  671. package/dist/modules/flow_backend/islands.js +31 -0
  672. package/dist/modules/flow_backend/islands.js.map +1 -0
  673. package/dist/modules/flow_backend/messages.d.ts +248 -0
  674. package/dist/modules/flow_backend/messages.d.ts.map +1 -0
  675. package/dist/modules/flow_backend/messages.js +470 -0
  676. package/dist/modules/flow_backend/messages.js.map +1 -0
  677. package/dist/modules/flow_backend/relation-control.d.ts +53 -0
  678. package/dist/modules/flow_backend/relation-control.d.ts.map +1 -0
  679. package/dist/modules/flow_backend/relation-control.js +106 -0
  680. package/dist/modules/flow_backend/relation-control.js.map +1 -0
  681. package/dist/modules/flow_backend/routes.d.ts +3 -0
  682. package/dist/modules/flow_backend/routes.d.ts.map +1 -0
  683. package/dist/modules/flow_backend/routes.js +2519 -0
  684. package/dist/modules/flow_backend/routes.js.map +1 -0
  685. package/dist/modules/flow_backend/screens/all-epics.d.ts +19 -0
  686. package/dist/modules/flow_backend/screens/all-epics.d.ts.map +1 -0
  687. package/dist/modules/flow_backend/screens/all-epics.js +59 -0
  688. package/dist/modules/flow_backend/screens/all-epics.js.map +1 -0
  689. package/dist/modules/flow_backend/screens/all-pages.d.ts +19 -0
  690. package/dist/modules/flow_backend/screens/all-pages.d.ts.map +1 -0
  691. package/dist/modules/flow_backend/screens/all-pages.js +65 -0
  692. package/dist/modules/flow_backend/screens/all-pages.js.map +1 -0
  693. package/dist/modules/flow_backend/screens/board.d.ts +5 -0
  694. package/dist/modules/flow_backend/screens/board.d.ts.map +1 -0
  695. package/dist/modules/flow_backend/screens/board.js +7 -0
  696. package/dist/modules/flow_backend/screens/board.js.map +1 -0
  697. package/dist/modules/flow_backend/screens/epic-detail.d.ts +22 -0
  698. package/dist/modules/flow_backend/screens/epic-detail.d.ts.map +1 -0
  699. package/dist/modules/flow_backend/screens/epic-detail.js +41 -0
  700. package/dist/modules/flow_backend/screens/epic-detail.js.map +1 -0
  701. package/dist/modules/flow_backend/screens/gantt.d.ts +21 -0
  702. package/dist/modules/flow_backend/screens/gantt.d.ts.map +1 -0
  703. package/dist/modules/flow_backend/screens/gantt.js +42 -0
  704. package/dist/modules/flow_backend/screens/gantt.js.map +1 -0
  705. package/dist/modules/flow_backend/screens/index.d.ts +29 -0
  706. package/dist/modules/flow_backend/screens/index.d.ts.map +1 -0
  707. package/dist/modules/flow_backend/screens/index.js +23 -0
  708. package/dist/modules/flow_backend/screens/index.js.map +1 -0
  709. package/dist/modules/flow_backend/screens/issue-detail.d.ts +38 -0
  710. package/dist/modules/flow_backend/screens/issue-detail.d.ts.map +1 -0
  711. package/dist/modules/flow_backend/screens/issue-detail.js +336 -0
  712. package/dist/modules/flow_backend/screens/issue-detail.js.map +1 -0
  713. package/dist/modules/flow_backend/screens/issues.d.ts +34 -0
  714. package/dist/modules/flow_backend/screens/issues.d.ts.map +1 -0
  715. package/dist/modules/flow_backend/screens/issues.js +118 -0
  716. package/dist/modules/flow_backend/screens/issues.js.map +1 -0
  717. package/dist/modules/flow_backend/screens/map.d.ts +13 -0
  718. package/dist/modules/flow_backend/screens/map.d.ts.map +1 -0
  719. package/dist/modules/flow_backend/screens/map.js +16 -0
  720. package/dist/modules/flow_backend/screens/map.js.map +1 -0
  721. package/dist/modules/flow_backend/screens/my-work.d.ts +42 -0
  722. package/dist/modules/flow_backend/screens/my-work.d.ts.map +1 -0
  723. package/dist/modules/flow_backend/screens/my-work.js +157 -0
  724. package/dist/modules/flow_backend/screens/my-work.js.map +1 -0
  725. package/dist/modules/flow_backend/screens/nav.d.ts +3 -0
  726. package/dist/modules/flow_backend/screens/nav.d.ts.map +1 -0
  727. package/dist/modules/flow_backend/screens/nav.js +79 -0
  728. package/dist/modules/flow_backend/screens/nav.js.map +1 -0
  729. package/dist/modules/flow_backend/screens/page-detail.d.ts +31 -0
  730. package/dist/modules/flow_backend/screens/page-detail.d.ts.map +1 -0
  731. package/dist/modules/flow_backend/screens/page-detail.js +113 -0
  732. package/dist/modules/flow_backend/screens/page-detail.js.map +1 -0
  733. package/dist/modules/flow_backend/screens/project-create.d.ts +26 -0
  734. package/dist/modules/flow_backend/screens/project-create.d.ts.map +1 -0
  735. package/dist/modules/flow_backend/screens/project-create.js +56 -0
  736. package/dist/modules/flow_backend/screens/project-create.js.map +1 -0
  737. package/dist/modules/flow_backend/screens/project-epics.d.ts +33 -0
  738. package/dist/modules/flow_backend/screens/project-epics.d.ts.map +1 -0
  739. package/dist/modules/flow_backend/screens/project-epics.js +90 -0
  740. package/dist/modules/flow_backend/screens/project-epics.js.map +1 -0
  741. package/dist/modules/flow_backend/screens/project-pages.d.ts +34 -0
  742. package/dist/modules/flow_backend/screens/project-pages.d.ts.map +1 -0
  743. package/dist/modules/flow_backend/screens/project-pages.js +66 -0
  744. package/dist/modules/flow_backend/screens/project-pages.js.map +1 -0
  745. package/dist/modules/flow_backend/screens/project-settings.d.ts +69 -0
  746. package/dist/modules/flow_backend/screens/project-settings.d.ts.map +1 -0
  747. package/dist/modules/flow_backend/screens/project-settings.js +248 -0
  748. package/dist/modules/flow_backend/screens/project-settings.js.map +1 -0
  749. package/dist/modules/flow_backend/screens/projects-list.d.ts +30 -0
  750. package/dist/modules/flow_backend/screens/projects-list.d.ts.map +1 -0
  751. package/dist/modules/flow_backend/screens/projects-list.js +121 -0
  752. package/dist/modules/flow_backend/screens/projects-list.js.map +1 -0
  753. package/dist/modules/flow_backend/screens/shared.d.ts +28 -0
  754. package/dist/modules/flow_backend/screens/shared.d.ts.map +1 -0
  755. package/dist/modules/flow_backend/screens/shared.js +46 -0
  756. package/dist/modules/flow_backend/screens/shared.js.map +1 -0
  757. package/dist/modules/flow_backend/screens/sprints.d.ts +33 -0
  758. package/dist/modules/flow_backend/screens/sprints.d.ts.map +1 -0
  759. package/dist/modules/flow_backend/screens/sprints.js +159 -0
  760. package/dist/modules/flow_backend/screens/sprints.js.map +1 -0
  761. package/dist/modules/flow_staff_channel/channel-routes.d.ts +2 -0
  762. package/dist/modules/flow_staff_channel/channel-routes.d.ts.map +1 -0
  763. package/dist/modules/flow_staff_channel/channel-routes.js +444 -0
  764. package/dist/modules/flow_staff_channel/channel-routes.js.map +1 -0
  765. package/dist/modules/flow_staff_channel/index.d.ts +5 -0
  766. package/dist/modules/flow_staff_channel/index.d.ts.map +1 -0
  767. package/dist/modules/flow_staff_channel/index.js +30 -0
  768. package/dist/modules/flow_staff_channel/index.js.map +1 -0
  769. package/dist/modules/hospitality_billing/functions.d.ts +18 -0
  770. package/dist/modules/hospitality_billing/functions.d.ts.map +1 -0
  771. package/dist/modules/hospitality_billing/functions.js +426 -0
  772. package/dist/modules/hospitality_billing/functions.js.map +1 -0
  773. package/dist/modules/hospitality_billing/index.d.ts +3 -0
  774. package/dist/modules/hospitality_billing/index.d.ts.map +1 -0
  775. package/dist/modules/hospitality_billing/index.js +25 -0
  776. package/dist/modules/hospitality_billing/index.js.map +1 -0
  777. package/dist/modules/hospitality_billing/jobs.d.ts +17 -0
  778. package/dist/modules/hospitality_billing/jobs.d.ts.map +1 -0
  779. package/dist/modules/hospitality_billing/jobs.js +83 -0
  780. package/dist/modules/hospitality_billing/jobs.js.map +1 -0
  781. package/dist/modules/hospitality_billing/menus.d.ts +9 -0
  782. package/dist/modules/hospitality_billing/menus.d.ts.map +1 -0
  783. package/dist/modules/hospitality_billing/menus.js +25 -0
  784. package/dist/modules/hospitality_billing/menus.js.map +1 -0
  785. package/dist/modules/hospitality_billing/messages.d.ts +3 -0
  786. package/dist/modules/hospitality_billing/messages.d.ts.map +1 -0
  787. package/dist/modules/hospitality_billing/messages.js +163 -0
  788. package/dist/modules/hospitality_billing/messages.js.map +1 -0
  789. package/dist/modules/hospitality_billing/models.d.ts +3 -0
  790. package/dist/modules/hospitality_billing/models.d.ts.map +1 -0
  791. package/dist/modules/hospitality_billing/models.js +65 -0
  792. package/dist/modules/hospitality_billing/models.js.map +1 -0
  793. package/dist/modules/hospitality_billing/routes.d.ts +3 -0
  794. package/dist/modules/hospitality_billing/routes.d.ts.map +1 -0
  795. package/dist/modules/hospitality_billing/routes.js +189 -0
  796. package/dist/modules/hospitality_billing/routes.js.map +1 -0
  797. package/dist/modules/hospitality_billing/screens/billing.d.ts +3 -0
  798. package/dist/modules/hospitality_billing/screens/billing.d.ts.map +1 -0
  799. package/dist/modules/hospitality_billing/screens/billing.js +20 -0
  800. package/dist/modules/hospitality_billing/screens/billing.js.map +1 -0
  801. package/dist/modules/hospitality_billing/screens/charge-rules.d.ts +12 -0
  802. package/dist/modules/hospitality_billing/screens/charge-rules.d.ts.map +1 -0
  803. package/dist/modules/hospitality_billing/screens/charge-rules.js +86 -0
  804. package/dist/modules/hospitality_billing/screens/charge-rules.js.map +1 -0
  805. package/dist/modules/hospitality_billing/screens/index.d.ts +4 -0
  806. package/dist/modules/hospitality_billing/screens/index.d.ts.map +1 -0
  807. package/dist/modules/hospitality_billing/screens/index.js +4 -0
  808. package/dist/modules/hospitality_billing/screens/index.js.map +1 -0
  809. package/dist/modules/hospitality_billing/screens/page-frame.d.ts +14 -0
  810. package/dist/modules/hospitality_billing/screens/page-frame.d.ts.map +1 -0
  811. package/dist/modules/hospitality_billing/screens/page-frame.js +6 -0
  812. package/dist/modules/hospitality_billing/screens/page-frame.js.map +1 -0
  813. package/dist/modules/hospitality_billing/screens/shared.d.ts +64 -0
  814. package/dist/modules/hospitality_billing/screens/shared.d.ts.map +1 -0
  815. package/dist/modules/hospitality_billing/screens/shared.js +117 -0
  816. package/dist/modules/hospitality_billing/screens/shared.js.map +1 -0
  817. package/dist/modules/hospitality_core/calendar.d.ts.map +1 -1
  818. package/dist/modules/hospitality_core/calendar.js +2 -1
  819. package/dist/modules/hospitality_core/calendar.js.map +1 -1
  820. package/dist/modules/hospitality_core/catalog.d.ts +3 -0
  821. package/dist/modules/hospitality_core/catalog.d.ts.map +1 -0
  822. package/dist/modules/hospitality_core/catalog.js +284 -0
  823. package/dist/modules/hospitality_core/catalog.js.map +1 -0
  824. package/dist/modules/hospitality_core/functions.d.ts.map +1 -1
  825. package/dist/modules/hospitality_core/functions.js +131 -14
  826. package/dist/modules/hospitality_core/functions.js.map +1 -1
  827. package/dist/modules/hospitality_core/index.d.ts +2 -2
  828. package/dist/modules/hospitality_core/index.d.ts.map +1 -1
  829. package/dist/modules/hospitality_core/index.js +6 -3
  830. package/dist/modules/hospitality_core/index.js.map +1 -1
  831. package/dist/modules/hospitality_core/inventory.d.ts +53 -4
  832. package/dist/modules/hospitality_core/inventory.d.ts.map +1 -1
  833. package/dist/modules/hospitality_core/inventory.js +121 -14
  834. package/dist/modules/hospitality_core/inventory.js.map +1 -1
  835. package/dist/modules/hospitality_core/menus.d.ts.map +1 -1
  836. package/dist/modules/hospitality_core/menus.js +31 -0
  837. package/dist/modules/hospitality_core/menus.js.map +1 -1
  838. package/dist/modules/hospitality_core/messages.d.ts.map +1 -1
  839. package/dist/modules/hospitality_core/messages.js +393 -183
  840. package/dist/modules/hospitality_core/messages.js.map +1 -1
  841. package/dist/modules/hospitality_core/models.d.ts +1 -1
  842. package/dist/modules/hospitality_core/models.d.ts.map +1 -1
  843. package/dist/modules/hospitality_core/models.js +48 -2
  844. package/dist/modules/hospitality_core/models.js.map +1 -1
  845. package/dist/modules/hospitality_core/night-audit.d.ts +1 -0
  846. package/dist/modules/hospitality_core/night-audit.d.ts.map +1 -1
  847. package/dist/modules/hospitality_core/night-audit.js +39 -1
  848. package/dist/modules/hospitality_core/night-audit.js.map +1 -1
  849. package/dist/modules/hospitality_core/online-booking.d.ts +5 -0
  850. package/dist/modules/hospitality_core/online-booking.d.ts.map +1 -0
  851. package/dist/modules/hospitality_core/online-booking.js +775 -0
  852. package/dist/modules/hospitality_core/online-booking.js.map +1 -0
  853. package/dist/modules/hospitality_core/operations.d.ts +21 -1
  854. package/dist/modules/hospitality_core/operations.d.ts.map +1 -1
  855. package/dist/modules/hospitality_core/operations.js +432 -67
  856. package/dist/modules/hospitality_core/operations.js.map +1 -1
  857. package/dist/modules/hospitality_core/relations.d.ts.map +1 -1
  858. package/dist/modules/hospitality_core/relations.js +1 -0
  859. package/dist/modules/hospitality_core/relations.js.map +1 -1
  860. package/dist/modules/hospitality_core/routes.d.ts.map +1 -1
  861. package/dist/modules/hospitality_core/routes.js +514 -107
  862. package/dist/modules/hospitality_core/routes.js.map +1 -1
  863. package/dist/modules/hospitality_core/screens/amenities.d.ts +10 -0
  864. package/dist/modules/hospitality_core/screens/amenities.d.ts.map +1 -0
  865. package/dist/modules/hospitality_core/screens/amenities.js +65 -0
  866. package/dist/modules/hospitality_core/screens/amenities.js.map +1 -0
  867. package/dist/modules/hospitality_core/screens/building-detail.d.ts +3 -0
  868. package/dist/modules/hospitality_core/screens/building-detail.d.ts.map +1 -0
  869. package/dist/modules/hospitality_core/screens/building-detail.js +69 -0
  870. package/dist/modules/hospitality_core/screens/building-detail.js.map +1 -0
  871. package/dist/modules/hospitality_core/screens/cleaning-task-detail.d.ts +7 -0
  872. package/dist/modules/hospitality_core/screens/cleaning-task-detail.d.ts.map +1 -0
  873. package/dist/modules/hospitality_core/screens/cleaning-task-detail.js +109 -0
  874. package/dist/modules/hospitality_core/screens/cleaning-task-detail.js.map +1 -0
  875. package/dist/modules/hospitality_core/screens/cleaning-tasks.d.ts +20 -0
  876. package/dist/modules/hospitality_core/screens/cleaning-tasks.d.ts.map +1 -0
  877. package/dist/modules/hospitality_core/screens/cleaning-tasks.js +139 -0
  878. package/dist/modules/hospitality_core/screens/cleaning-tasks.js.map +1 -0
  879. package/dist/modules/hospitality_core/screens/content.d.ts +3 -0
  880. package/dist/modules/hospitality_core/screens/content.d.ts.map +1 -0
  881. package/dist/modules/hospitality_core/screens/content.js +114 -0
  882. package/dist/modules/hospitality_core/screens/content.js.map +1 -0
  883. package/dist/modules/hospitality_core/screens/floor-detail.d.ts +3 -0
  884. package/dist/modules/hospitality_core/screens/floor-detail.d.ts.map +1 -0
  885. package/dist/modules/hospitality_core/screens/floor-detail.js +74 -0
  886. package/dist/modules/hospitality_core/screens/floor-detail.js.map +1 -0
  887. package/dist/modules/hospitality_core/screens/folio-detail.d.ts +3 -0
  888. package/dist/modules/hospitality_core/screens/folio-detail.d.ts.map +1 -0
  889. package/dist/modules/hospitality_core/screens/folio-detail.js +142 -0
  890. package/dist/modules/hospitality_core/screens/folio-detail.js.map +1 -0
  891. package/dist/modules/hospitality_core/screens/folios.d.ts +3 -0
  892. package/dist/modules/hospitality_core/screens/folios.d.ts.map +1 -0
  893. package/dist/modules/hospitality_core/screens/folios.js +7 -0
  894. package/dist/modules/hospitality_core/screens/folios.js.map +1 -0
  895. package/dist/modules/hospitality_core/screens/front-desk.d.ts +35 -0
  896. package/dist/modules/hospitality_core/screens/front-desk.d.ts.map +1 -0
  897. package/dist/modules/hospitality_core/screens/front-desk.js +195 -0
  898. package/dist/modules/hospitality_core/screens/front-desk.js.map +1 -0
  899. package/dist/modules/hospitality_core/screens/housekeeping-room-detail.d.ts +3 -0
  900. package/dist/modules/hospitality_core/screens/housekeeping-room-detail.d.ts.map +1 -0
  901. package/dist/modules/hospitality_core/screens/housekeeping-room-detail.js +121 -0
  902. package/dist/modules/hospitality_core/screens/housekeeping-room-detail.js.map +1 -0
  903. package/dist/modules/hospitality_core/screens/housekeeping-rooms.d.ts +9 -0
  904. package/dist/modules/hospitality_core/screens/housekeeping-rooms.d.ts.map +1 -0
  905. package/dist/modules/hospitality_core/screens/housekeeping-rooms.js +54 -0
  906. package/dist/modules/hospitality_core/screens/housekeeping-rooms.js.map +1 -0
  907. package/dist/modules/hospitality_core/screens/index.d.ts +33 -0
  908. package/dist/modules/hospitality_core/screens/index.d.ts.map +1 -0
  909. package/dist/modules/hospitality_core/screens/index.js +33 -0
  910. package/dist/modules/hospitality_core/screens/index.js.map +1 -0
  911. package/dist/modules/hospitality_core/screens/inventory.d.ts +8 -0
  912. package/dist/modules/hospitality_core/screens/inventory.d.ts.map +1 -0
  913. package/dist/modules/hospitality_core/screens/inventory.js +122 -0
  914. package/dist/modules/hospitality_core/screens/inventory.js.map +1 -0
  915. package/dist/modules/hospitality_core/screens/new-property.d.ts +3 -0
  916. package/dist/modules/hospitality_core/screens/new-property.d.ts.map +1 -0
  917. package/dist/modules/hospitality_core/screens/new-property.js +8 -0
  918. package/dist/modules/hospitality_core/screens/new-property.js.map +1 -0
  919. package/dist/modules/hospitality_core/screens/new-room-type.d.ts +3 -0
  920. package/dist/modules/hospitality_core/screens/new-room-type.d.ts.map +1 -0
  921. package/dist/modules/hospitality_core/screens/new-room-type.js +8 -0
  922. package/dist/modules/hospitality_core/screens/new-room-type.js.map +1 -0
  923. package/dist/modules/hospitality_core/screens/new-room.d.ts +3 -0
  924. package/dist/modules/hospitality_core/screens/new-room.d.ts.map +1 -0
  925. package/dist/modules/hospitality_core/screens/new-room.js +8 -0
  926. package/dist/modules/hospitality_core/screens/new-room.js.map +1 -0
  927. package/dist/modules/hospitality_core/screens/night-audit.d.ts +10 -0
  928. package/dist/modules/hospitality_core/screens/night-audit.d.ts.map +1 -0
  929. package/dist/modules/hospitality_core/screens/night-audit.js +67 -0
  930. package/dist/modules/hospitality_core/screens/night-audit.js.map +1 -0
  931. package/dist/modules/hospitality_core/screens/page-frame.d.ts +15 -0
  932. package/dist/modules/hospitality_core/screens/page-frame.d.ts.map +1 -0
  933. package/dist/modules/hospitality_core/screens/page-frame.js +10 -0
  934. package/dist/modules/hospitality_core/screens/page-frame.js.map +1 -0
  935. package/dist/modules/hospitality_core/screens/policies.d.ts +10 -0
  936. package/dist/modules/hospitality_core/screens/policies.d.ts.map +1 -0
  937. package/dist/modules/hospitality_core/screens/policies.js +72 -0
  938. package/dist/modules/hospitality_core/screens/policies.js.map +1 -0
  939. package/dist/modules/hospitality_core/screens/properties.d.ts +7 -0
  940. package/dist/modules/hospitality_core/screens/properties.d.ts.map +1 -0
  941. package/dist/modules/hospitality_core/screens/properties.js +45 -0
  942. package/dist/modules/hospitality_core/screens/properties.js.map +1 -0
  943. package/dist/modules/hospitality_core/screens/property-detail.d.ts +3 -0
  944. package/dist/modules/hospitality_core/screens/property-detail.d.ts.map +1 -0
  945. package/dist/modules/hospitality_core/screens/property-detail.js +92 -0
  946. package/dist/modules/hospitality_core/screens/property-detail.js.map +1 -0
  947. package/dist/modules/hospitality_core/screens/rate-plans.d.ts +10 -0
  948. package/dist/modules/hospitality_core/screens/rate-plans.d.ts.map +1 -0
  949. package/dist/modules/hospitality_core/screens/rate-plans.js +123 -0
  950. package/dist/modules/hospitality_core/screens/rate-plans.js.map +1 -0
  951. package/dist/modules/hospitality_core/screens/reservation-detail.d.ts +11 -0
  952. package/dist/modules/hospitality_core/screens/reservation-detail.d.ts.map +1 -0
  953. package/dist/modules/hospitality_core/screens/reservation-detail.js +237 -0
  954. package/dist/modules/hospitality_core/screens/reservation-detail.js.map +1 -0
  955. package/dist/modules/hospitality_core/screens/reservations.d.ts +17 -0
  956. package/dist/modules/hospitality_core/screens/reservations.d.ts.map +1 -0
  957. package/dist/modules/hospitality_core/screens/reservations.js +166 -0
  958. package/dist/modules/hospitality_core/screens/reservations.js.map +1 -0
  959. package/dist/modules/hospitality_core/screens/room-detail.d.ts +3 -0
  960. package/dist/modules/hospitality_core/screens/room-detail.d.ts.map +1 -0
  961. package/dist/modules/hospitality_core/screens/room-detail.js +75 -0
  962. package/dist/modules/hospitality_core/screens/room-detail.js.map +1 -0
  963. package/dist/modules/hospitality_core/screens/room-type-detail.d.ts +3 -0
  964. package/dist/modules/hospitality_core/screens/room-type-detail.d.ts.map +1 -0
  965. package/dist/modules/hospitality_core/screens/room-type-detail.js +91 -0
  966. package/dist/modules/hospitality_core/screens/room-type-detail.js.map +1 -0
  967. package/dist/modules/hospitality_core/screens/room-types.d.ts +3 -0
  968. package/dist/modules/hospitality_core/screens/room-types.d.ts.map +1 -0
  969. package/dist/modules/hospitality_core/screens/room-types.js +61 -0
  970. package/dist/modules/hospitality_core/screens/room-types.js.map +1 -0
  971. package/dist/modules/hospitality_core/screens/rooms.d.ts +10 -0
  972. package/dist/modules/hospitality_core/screens/rooms.d.ts.map +1 -0
  973. package/dist/modules/hospitality_core/screens/rooms.js +150 -0
  974. package/dist/modules/hospitality_core/screens/rooms.js.map +1 -0
  975. package/dist/modules/hospitality_core/screens/services.d.ts +18 -0
  976. package/dist/modules/hospitality_core/screens/services.d.ts.map +1 -0
  977. package/dist/modules/hospitality_core/screens/services.js +196 -0
  978. package/dist/modules/hospitality_core/screens/services.js.map +1 -0
  979. package/dist/modules/hospitality_core/screens/shared.d.ts +777 -0
  980. package/dist/modules/hospitality_core/screens/shared.d.ts.map +1 -0
  981. package/dist/modules/hospitality_core/screens/shared.js +1586 -0
  982. package/dist/modules/hospitality_core/screens/shared.js.map +1 -0
  983. package/dist/modules/hospitality_core/screens/stay-detail.d.ts +3 -0
  984. package/dist/modules/hospitality_core/screens/stay-detail.d.ts.map +1 -0
  985. package/dist/modules/hospitality_core/screens/stay-detail.js +233 -0
  986. package/dist/modules/hospitality_core/screens/stay-detail.js.map +1 -0
  987. package/dist/modules/hospitality_core/screens/stay-notices.d.ts +9 -0
  988. package/dist/modules/hospitality_core/screens/stay-notices.d.ts.map +1 -0
  989. package/dist/modules/hospitality_core/screens/stay-notices.js +87 -0
  990. package/dist/modules/hospitality_core/screens/stay-notices.js.map +1 -0
  991. package/dist/modules/hospitality_core/screens/stays.d.ts +3 -0
  992. package/dist/modules/hospitality_core/screens/stays.d.ts.map +1 -0
  993. package/dist/modules/hospitality_core/screens/stays.js +7 -0
  994. package/dist/modules/hospitality_core/screens/stays.js.map +1 -0
  995. package/dist/modules/hospitality_core/screens/tape-chart.d.ts +7 -0
  996. package/dist/modules/hospitality_core/screens/tape-chart.d.ts.map +1 -0
  997. package/dist/modules/hospitality_core/screens/tape-chart.js +99 -0
  998. package/dist/modules/hospitality_core/screens/tape-chart.js.map +1 -0
  999. package/dist/modules/hospitality_core/services.d.ts.map +1 -1
  1000. package/dist/modules/hospitality_core/services.js +133 -30
  1001. package/dist/modules/hospitality_core/services.js.map +1 -1
  1002. package/dist/modules/hospitality_core/stay-notices.js +2 -2
  1003. package/dist/modules/hospitality_core/stay-notices.js.map +1 -1
  1004. package/dist/modules/hospitality_core/types.d.ts +26 -5
  1005. package/dist/modules/hospitality_core/types.d.ts.map +1 -1
  1006. package/dist/modules/hospitality_core/types.js +47 -5
  1007. package/dist/modules/hospitality_core/types.js.map +1 -1
  1008. package/dist/modules/hospitality_staff_channel/channel-routes.d.ts +2 -0
  1009. package/dist/modules/hospitality_staff_channel/channel-routes.d.ts.map +1 -0
  1010. package/dist/modules/hospitality_staff_channel/channel-routes.js +1227 -0
  1011. package/dist/modules/hospitality_staff_channel/channel-routes.js.map +1 -0
  1012. package/dist/modules/hospitality_staff_channel/index.d.ts +5 -0
  1013. package/dist/modules/hospitality_staff_channel/index.d.ts.map +1 -0
  1014. package/dist/modules/hospitality_staff_channel/index.js +34 -0
  1015. package/dist/modules/hospitality_staff_channel/index.js.map +1 -0
  1016. package/dist/modules/hr/functions.d.ts.map +1 -1
  1017. package/dist/modules/hr/functions.js +108 -44
  1018. package/dist/modules/hr/functions.js.map +1 -1
  1019. package/dist/modules/hr/index.d.ts.map +1 -1
  1020. package/dist/modules/hr/index.js +0 -1
  1021. package/dist/modules/hr/index.js.map +1 -1
  1022. package/dist/modules/hr_backend/index.d.ts +2 -1
  1023. package/dist/modules/hr_backend/index.d.ts.map +1 -1
  1024. package/dist/modules/hr_backend/index.js +39 -7
  1025. package/dist/modules/hr_backend/index.js.map +1 -1
  1026. package/dist/modules/hr_backend/routes.d.ts.map +1 -1
  1027. package/dist/modules/hr_backend/routes.js +279 -42
  1028. package/dist/modules/hr_backend/routes.js.map +1 -1
  1029. package/dist/modules/hr_backend/screens/employee-form.d.ts +28 -0
  1030. package/dist/modules/hr_backend/screens/employee-form.d.ts.map +1 -0
  1031. package/dist/modules/hr_backend/screens/employee-form.js +110 -0
  1032. package/dist/modules/hr_backend/screens/employee-form.js.map +1 -0
  1033. package/dist/modules/hr_backend/screens/employees-list.d.ts +22 -0
  1034. package/dist/modules/hr_backend/screens/employees-list.d.ts.map +1 -0
  1035. package/dist/modules/hr_backend/screens/employees-list.js +53 -0
  1036. package/dist/modules/hr_backend/screens/employees-list.js.map +1 -0
  1037. package/dist/modules/hr_backend/screens/index.d.ts +5 -0
  1038. package/dist/modules/hr_backend/screens/index.d.ts.map +1 -0
  1039. package/dist/modules/hr_backend/screens/index.js +5 -0
  1040. package/dist/modules/hr_backend/screens/index.js.map +1 -0
  1041. package/dist/modules/hr_backend/screens/leaves-list.d.ts +22 -0
  1042. package/dist/modules/hr_backend/screens/leaves-list.d.ts.map +1 -0
  1043. package/dist/modules/hr_backend/screens/leaves-list.js +78 -0
  1044. package/dist/modules/hr_backend/screens/leaves-list.js.map +1 -0
  1045. package/dist/modules/hr_backend/screens/roster.d.ts +19 -0
  1046. package/dist/modules/hr_backend/screens/roster.d.ts.map +1 -0
  1047. package/dist/modules/hr_backend/screens/roster.js +83 -0
  1048. package/dist/modules/hr_backend/screens/roster.js.map +1 -0
  1049. package/dist/modules/inventory_staff_channel/channel-routes.d.ts +2 -0
  1050. package/dist/modules/inventory_staff_channel/channel-routes.d.ts.map +1 -0
  1051. package/dist/modules/inventory_staff_channel/channel-routes.js +724 -0
  1052. package/dist/modules/inventory_staff_channel/channel-routes.js.map +1 -0
  1053. package/dist/modules/inventory_staff_channel/index.d.ts +5 -0
  1054. package/dist/modules/inventory_staff_channel/index.d.ts.map +1 -0
  1055. package/dist/modules/inventory_staff_channel/index.js +38 -0
  1056. package/dist/modules/inventory_staff_channel/index.js.map +1 -0
  1057. package/dist/modules/livedoc/documents.d.ts +48 -0
  1058. package/dist/modules/livedoc/documents.d.ts.map +1 -0
  1059. package/dist/modules/livedoc/documents.js +99 -0
  1060. package/dist/modules/livedoc/documents.js.map +1 -0
  1061. package/dist/modules/livedoc/functions.d.ts +3 -0
  1062. package/dist/modules/livedoc/functions.d.ts.map +1 -0
  1063. package/dist/modules/livedoc/functions.js +47 -0
  1064. package/dist/modules/livedoc/functions.js.map +1 -0
  1065. package/dist/modules/livedoc/index.d.ts +22 -0
  1066. package/dist/modules/livedoc/index.d.ts.map +1 -0
  1067. package/dist/modules/livedoc/index.js +37 -0
  1068. package/dist/modules/livedoc/index.js.map +1 -0
  1069. package/dist/modules/livedoc/islands.d.ts +3 -0
  1070. package/dist/modules/livedoc/islands.d.ts.map +1 -0
  1071. package/dist/modules/livedoc/islands.js +22 -0
  1072. package/dist/modules/livedoc/islands.js.map +1 -0
  1073. package/dist/modules/livedoc/routes.d.ts +11 -0
  1074. package/dist/modules/livedoc/routes.d.ts.map +1 -0
  1075. package/dist/modules/livedoc/routes.js +232 -0
  1076. package/dist/modules/livedoc/routes.js.map +1 -0
  1077. package/dist/modules/livedoc/sync.d.ts +124 -0
  1078. package/dist/modules/livedoc/sync.d.ts.map +1 -0
  1079. package/dist/modules/livedoc/sync.js +218 -0
  1080. package/dist/modules/livedoc/sync.js.map +1 -0
  1081. package/dist/modules/loyalty/admin-functions.d.ts.map +1 -1
  1082. package/dist/modules/loyalty/admin-functions.js +42 -6
  1083. package/dist/modules/loyalty/admin-functions.js.map +1 -1
  1084. package/dist/modules/loyalty/engine.d.ts +1 -0
  1085. package/dist/modules/loyalty/engine.d.ts.map +1 -1
  1086. package/dist/modules/loyalty/engine.js +88 -28
  1087. package/dist/modules/loyalty/engine.js.map +1 -1
  1088. package/dist/modules/loyalty/index.d.ts.map +1 -1
  1089. package/dist/modules/loyalty/index.js +10 -2
  1090. package/dist/modules/loyalty/index.js.map +1 -1
  1091. package/dist/modules/loyalty/ledger.d.ts.map +1 -1
  1092. package/dist/modules/loyalty/ledger.js +11 -0
  1093. package/dist/modules/loyalty/ledger.js.map +1 -1
  1094. package/dist/modules/loyalty/membership-functions.d.ts.map +1 -1
  1095. package/dist/modules/loyalty/membership-functions.js +23 -7
  1096. package/dist/modules/loyalty/membership-functions.js.map +1 -1
  1097. package/dist/modules/loyalty/messages.d.ts +8 -0
  1098. package/dist/modules/loyalty/messages.d.ts.map +1 -1
  1099. package/dist/modules/loyalty/messages.js +8 -0
  1100. package/dist/modules/loyalty/messages.js.map +1 -1
  1101. package/dist/modules/loyalty/models.d.ts.map +1 -1
  1102. package/dist/modules/loyalty/models.js +20 -0
  1103. package/dist/modules/loyalty/models.js.map +1 -1
  1104. package/dist/modules/loyalty/order-functions.d.ts +16 -1
  1105. package/dist/modules/loyalty/order-functions.d.ts.map +1 -1
  1106. package/dist/modules/loyalty/order-functions.js +513 -291
  1107. package/dist/modules/loyalty/order-functions.js.map +1 -1
  1108. package/dist/modules/loyalty/stats.d.ts +17 -0
  1109. package/dist/modules/loyalty/stats.d.ts.map +1 -0
  1110. package/dist/modules/loyalty/stats.js +178 -0
  1111. package/dist/modules/loyalty/stats.js.map +1 -0
  1112. package/dist/modules/loyalty/stored-value.d.ts +42 -0
  1113. package/dist/modules/loyalty/stored-value.d.ts.map +1 -0
  1114. package/dist/modules/loyalty/stored-value.js +368 -0
  1115. package/dist/modules/loyalty/stored-value.js.map +1 -0
  1116. package/dist/modules/loyalty/types.d.ts +6 -4
  1117. package/dist/modules/loyalty/types.d.ts.map +1 -1
  1118. package/dist/modules/loyalty/types.js +1 -1
  1119. package/dist/modules/loyalty/types.js.map +1 -1
  1120. package/dist/modules/loyalty_backend/index.js +443 -172
  1121. package/dist/modules/loyalty_backend/index.js.map +1 -1
  1122. package/dist/modules/loyalty_backend/messages.d.ts +58 -1
  1123. package/dist/modules/loyalty_backend/messages.d.ts.map +1 -1
  1124. package/dist/modules/loyalty_backend/messages.js +114 -0
  1125. package/dist/modules/loyalty_backend/messages.js.map +1 -1
  1126. package/dist/modules/loyalty_backend/screens/index.d.ts +90 -0
  1127. package/dist/modules/loyalty_backend/screens/index.d.ts.map +1 -0
  1128. package/dist/modules/loyalty_backend/screens/index.js +912 -0
  1129. package/dist/modules/loyalty_backend/screens/index.js.map +1 -0
  1130. package/dist/modules/loyalty_backend/screens/page-frame.d.ts +14 -0
  1131. package/dist/modules/loyalty_backend/screens/page-frame.d.ts.map +1 -0
  1132. package/dist/modules/loyalty_backend/screens/page-frame.js +13 -0
  1133. package/dist/modules/loyalty_backend/screens/page-frame.js.map +1 -0
  1134. package/dist/modules/loyalty_pos/channel.d.ts +2 -0
  1135. package/dist/modules/loyalty_pos/channel.d.ts.map +1 -0
  1136. package/dist/modules/loyalty_pos/channel.js +270 -0
  1137. package/dist/modules/loyalty_pos/channel.js.map +1 -0
  1138. package/dist/modules/loyalty_pos/functions.d.ts +11 -17
  1139. package/dist/modules/loyalty_pos/functions.d.ts.map +1 -1
  1140. package/dist/modules/loyalty_pos/functions.js +454 -94
  1141. package/dist/modules/loyalty_pos/functions.js.map +1 -1
  1142. package/dist/modules/loyalty_pos/index.js +6 -16
  1143. package/dist/modules/loyalty_pos/index.js.map +1 -1
  1144. package/dist/modules/loyalty_pos/jobs.d.ts +3 -0
  1145. package/dist/modules/loyalty_pos/jobs.d.ts.map +1 -0
  1146. package/dist/modules/loyalty_pos/jobs.js +30 -0
  1147. package/dist/modules/loyalty_pos/jobs.js.map +1 -0
  1148. package/dist/modules/loyalty_sale/functions.d.ts +2 -2
  1149. package/dist/modules/loyalty_sale/functions.d.ts.map +1 -1
  1150. package/dist/modules/loyalty_sale/functions.js +53 -34
  1151. package/dist/modules/loyalty_sale/functions.js.map +1 -1
  1152. package/dist/modules/loyalty_sale/index.js +0 -2
  1153. package/dist/modules/loyalty_sale/index.js.map +1 -1
  1154. package/dist/modules/mail/functions.d.ts.map +1 -1
  1155. package/dist/modules/mail/functions.js +48 -6
  1156. package/dist/modules/mail/functions.js.map +1 -1
  1157. package/dist/modules/mail/index.d.ts.map +1 -1
  1158. package/dist/modules/mail/index.js +0 -1
  1159. package/dist/modules/mail/index.js.map +1 -1
  1160. package/dist/modules/mail/operations.d.ts +19 -0
  1161. package/dist/modules/mail/operations.d.ts.map +1 -1
  1162. package/dist/modules/mail/operations.js +69 -0
  1163. package/dist/modules/mail/operations.js.map +1 -1
  1164. package/dist/modules/mail_backend/index.d.ts +1 -1
  1165. package/dist/modules/mail_backend/index.d.ts.map +1 -1
  1166. package/dist/modules/mail_backend/index.js +5 -14
  1167. package/dist/modules/mail_backend/index.js.map +1 -1
  1168. package/dist/modules/mail_backend/islands.js +2 -2
  1169. package/dist/modules/mail_backend/islands.js.map +1 -1
  1170. package/dist/modules/mail_backend/routes.d.ts.map +1 -1
  1171. package/dist/modules/mail_backend/routes.js +25 -20
  1172. package/dist/modules/mail_backend/routes.js.map +1 -1
  1173. package/dist/modules/mail_backend/screens/inbox-list.d.ts +9 -0
  1174. package/dist/modules/mail_backend/screens/inbox-list.d.ts.map +1 -0
  1175. package/dist/modules/mail_backend/screens/inbox-list.js +13 -0
  1176. package/dist/modules/mail_backend/screens/inbox-list.js.map +1 -0
  1177. package/dist/modules/mail_backend/screens/index.d.ts +3 -0
  1178. package/dist/modules/mail_backend/screens/index.d.ts.map +1 -0
  1179. package/dist/modules/mail_backend/screens/index.js +2 -0
  1180. package/dist/modules/mail_backend/screens/index.js.map +1 -0
  1181. package/dist/modules/mail_inbound/index.d.ts.map +1 -1
  1182. package/dist/modules/mail_inbound/index.js +0 -1
  1183. package/dist/modules/mail_inbound/index.js.map +1 -1
  1184. package/dist/modules/mail_inbound_backend/index.d.ts +1 -1
  1185. package/dist/modules/mail_inbound_backend/index.d.ts.map +1 -1
  1186. package/dist/modules/mail_inbound_backend/index.js +3 -12
  1187. package/dist/modules/mail_inbound_backend/index.js.map +1 -1
  1188. package/dist/modules/mail_inbound_backend/routes.d.ts.map +1 -1
  1189. package/dist/modules/mail_inbound_backend/routes.js +6 -21
  1190. package/dist/modules/mail_inbound_backend/routes.js.map +1 -1
  1191. package/dist/modules/mail_inbound_backend/screens/inbound-list.d.ts +8 -0
  1192. package/dist/modules/mail_inbound_backend/screens/inbound-list.d.ts.map +1 -0
  1193. package/dist/modules/mail_inbound_backend/screens/inbound-list.js +20 -0
  1194. package/dist/modules/mail_inbound_backend/screens/inbound-list.js.map +1 -0
  1195. package/dist/modules/mail_inbound_backend/screens/index.d.ts +3 -0
  1196. package/dist/modules/mail_inbound_backend/screens/index.d.ts.map +1 -0
  1197. package/dist/modules/mail_inbound_backend/screens/index.js +2 -0
  1198. package/dist/modules/mail_inbound_backend/screens/index.js.map +1 -0
  1199. package/dist/modules/mail_staff_channel/channel-routes.d.ts +2 -0
  1200. package/dist/modules/mail_staff_channel/channel-routes.d.ts.map +1 -0
  1201. package/dist/modules/mail_staff_channel/channel-routes.js +183 -0
  1202. package/dist/modules/mail_staff_channel/channel-routes.js.map +1 -0
  1203. package/dist/modules/mail_staff_channel/index.d.ts +5 -0
  1204. package/dist/modules/mail_staff_channel/index.d.ts.map +1 -0
  1205. package/dist/modules/mail_staff_channel/index.js +28 -0
  1206. package/dist/modules/mail_staff_channel/index.js.map +1 -0
  1207. package/dist/modules/mail_transport/index.d.ts.map +1 -1
  1208. package/dist/modules/mail_transport/index.js +0 -1
  1209. package/dist/modules/mail_transport/index.js.map +1 -1
  1210. package/dist/modules/mail_transport_backend/index.d.ts +1 -1
  1211. package/dist/modules/mail_transport_backend/index.d.ts.map +1 -1
  1212. package/dist/modules/mail_transport_backend/index.js +3 -12
  1213. package/dist/modules/mail_transport_backend/index.js.map +1 -1
  1214. package/dist/modules/mail_transport_backend/routes.d.ts.map +1 -1
  1215. package/dist/modules/mail_transport_backend/routes.js +23 -22
  1216. package/dist/modules/mail_transport_backend/routes.js.map +1 -1
  1217. package/dist/modules/mail_transport_backend/screens/index.d.ts +3 -0
  1218. package/dist/modules/mail_transport_backend/screens/index.d.ts.map +1 -0
  1219. package/dist/modules/mail_transport_backend/screens/index.js +2 -0
  1220. package/dist/modules/mail_transport_backend/screens/index.js.map +1 -0
  1221. package/dist/modules/mail_transport_backend/screens/outbox-list.d.ts +9 -0
  1222. package/dist/modules/mail_transport_backend/screens/outbox-list.d.ts.map +1 -0
  1223. package/dist/modules/mail_transport_backend/screens/outbox-list.js +29 -0
  1224. package/dist/modules/mail_transport_backend/screens/outbox-list.js.map +1 -0
  1225. package/dist/modules/manufacturing/functions.d.ts +3 -0
  1226. package/dist/modules/manufacturing/functions.d.ts.map +1 -0
  1227. package/dist/modules/manufacturing/functions.js +912 -0
  1228. package/dist/modules/manufacturing/functions.js.map +1 -0
  1229. package/dist/modules/manufacturing/index.d.ts +6 -0
  1230. package/dist/modules/manufacturing/index.d.ts.map +1 -0
  1231. package/dist/modules/manufacturing/index.js +42 -0
  1232. package/dist/modules/manufacturing/index.js.map +1 -0
  1233. package/dist/modules/manufacturing/models.d.ts +8 -0
  1234. package/dist/modules/manufacturing/models.d.ts.map +1 -0
  1235. package/dist/modules/manufacturing/models.js +145 -0
  1236. package/dist/modules/manufacturing/models.js.map +1 -0
  1237. package/dist/modules/manufacturing/relations.d.ts.map +1 -0
  1238. package/dist/modules/manufacturing/relations.js +37 -0
  1239. package/dist/modules/manufacturing/relations.js.map +1 -0
  1240. package/dist/modules/manufacturing/types.d.ts +7 -0
  1241. package/dist/modules/manufacturing/types.d.ts.map +1 -0
  1242. package/dist/modules/manufacturing/types.js +11 -0
  1243. package/dist/modules/manufacturing/types.js.map +1 -0
  1244. package/dist/modules/manufacturing_backend/index.d.ts +5 -0
  1245. package/dist/modules/manufacturing_backend/index.d.ts.map +1 -0
  1246. package/dist/modules/manufacturing_backend/index.js +146 -0
  1247. package/dist/modules/manufacturing_backend/index.js.map +1 -0
  1248. package/dist/modules/manufacturing_backend/routes.d.ts +3 -0
  1249. package/dist/modules/manufacturing_backend/routes.d.ts.map +1 -0
  1250. package/dist/modules/manufacturing_backend/routes.js +477 -0
  1251. package/dist/modules/manufacturing_backend/routes.js.map +1 -0
  1252. package/dist/modules/manufacturing_backend/screens/bom-create.d.ts +15 -0
  1253. package/dist/modules/manufacturing_backend/screens/bom-create.d.ts.map +1 -0
  1254. package/dist/modules/manufacturing_backend/screens/bom-create.js +39 -0
  1255. package/dist/modules/manufacturing_backend/screens/bom-create.js.map +1 -0
  1256. package/dist/modules/manufacturing_backend/screens/boms-list.d.ts +18 -0
  1257. package/dist/modules/manufacturing_backend/screens/boms-list.d.ts.map +1 -0
  1258. package/dist/modules/manufacturing_backend/screens/boms-list.js +36 -0
  1259. package/dist/modules/manufacturing_backend/screens/boms-list.js.map +1 -0
  1260. package/dist/modules/manufacturing_backend/screens/index.d.ts +8 -0
  1261. package/dist/modules/manufacturing_backend/screens/index.d.ts.map +1 -0
  1262. package/dist/modules/manufacturing_backend/screens/index.js +8 -0
  1263. package/dist/modules/manufacturing_backend/screens/index.js.map +1 -0
  1264. package/dist/modules/manufacturing_backend/screens/order-create.d.ts +13 -0
  1265. package/dist/modules/manufacturing_backend/screens/order-create.d.ts.map +1 -0
  1266. package/dist/modules/manufacturing_backend/screens/order-create.js +20 -0
  1267. package/dist/modules/manufacturing_backend/screens/order-create.js.map +1 -0
  1268. package/dist/modules/manufacturing_backend/screens/order-execution.d.ts +7 -0
  1269. package/dist/modules/manufacturing_backend/screens/order-execution.d.ts.map +1 -0
  1270. package/dist/modules/manufacturing_backend/screens/order-execution.js +129 -0
  1271. package/dist/modules/manufacturing_backend/screens/order-execution.js.map +1 -0
  1272. package/dist/modules/manufacturing_backend/screens/orders-list.d.ts +21 -0
  1273. package/dist/modules/manufacturing_backend/screens/orders-list.d.ts.map +1 -0
  1274. package/dist/modules/manufacturing_backend/screens/orders-list.js +49 -0
  1275. package/dist/modules/manufacturing_backend/screens/orders-list.js.map +1 -0
  1276. package/dist/modules/manufacturing_backend/screens/work-center-form.d.ts +24 -0
  1277. package/dist/modules/manufacturing_backend/screens/work-center-form.d.ts.map +1 -0
  1278. package/dist/modules/manufacturing_backend/screens/work-center-form.js +80 -0
  1279. package/dist/modules/manufacturing_backend/screens/work-center-form.js.map +1 -0
  1280. package/dist/modules/manufacturing_backend/screens/work-centers-list.d.ts +23 -0
  1281. package/dist/modules/manufacturing_backend/screens/work-centers-list.d.ts.map +1 -0
  1282. package/dist/modules/manufacturing_backend/screens/work-centers-list.js +61 -0
  1283. package/dist/modules/manufacturing_backend/screens/work-centers-list.js.map +1 -0
  1284. package/dist/modules/oauth/index.d.ts.map +1 -1
  1285. package/dist/modules/oauth/index.js +0 -1
  1286. package/dist/modules/oauth/index.js.map +1 -1
  1287. package/dist/modules/oauth/models.d.ts.map +1 -1
  1288. package/dist/modules/oauth/models.js +2 -1
  1289. package/dist/modules/oauth/models.js.map +1 -1
  1290. package/dist/modules/oauth_backend/index.d.ts +1 -1
  1291. package/dist/modules/oauth_backend/index.d.ts.map +1 -1
  1292. package/dist/modules/oauth_backend/index.js +3 -5
  1293. package/dist/modules/oauth_backend/index.js.map +1 -1
  1294. package/dist/modules/oauth_backend/messages.d.ts +4 -0
  1295. package/dist/modules/oauth_backend/messages.d.ts.map +1 -1
  1296. package/dist/modules/oauth_backend/messages.js +4 -0
  1297. package/dist/modules/oauth_backend/messages.js.map +1 -1
  1298. package/dist/modules/oauth_backend/routes.d.ts.map +1 -1
  1299. package/dist/modules/oauth_backend/routes.js +28 -30
  1300. package/dist/modules/oauth_backend/routes.js.map +1 -1
  1301. package/dist/modules/oauth_backend/screens/index.d.ts +66 -0
  1302. package/dist/modules/oauth_backend/screens/index.d.ts.map +1 -0
  1303. package/dist/modules/oauth_backend/screens/index.js +306 -0
  1304. package/dist/modules/oauth_backend/screens/index.js.map +1 -0
  1305. package/dist/modules/partner/functions.d.ts.map +1 -1
  1306. package/dist/modules/partner/functions.js +74 -6
  1307. package/dist/modules/partner/functions.js.map +1 -1
  1308. package/dist/modules/partner/index.d.ts.map +1 -1
  1309. package/dist/modules/partner/index.js +0 -1
  1310. package/dist/modules/partner/index.js.map +1 -1
  1311. package/dist/modules/partner/models.d.ts +4 -4
  1312. package/dist/modules/partner/models.d.ts.map +1 -1
  1313. package/dist/modules/partner/models.js +9 -7
  1314. package/dist/modules/partner/models.js.map +1 -1
  1315. package/dist/modules/partner/types.d.ts +2 -2
  1316. package/dist/modules/partner/types.js +2 -2
  1317. package/dist/modules/partner_backend/client/address-view.mjs +5 -5
  1318. package/dist/modules/partner_backend/client/address-view.mjs.map +1 -1
  1319. package/dist/modules/partner_backend/client/address.css +22 -10
  1320. package/dist/modules/partner_backend/client/partner.css +116 -0
  1321. package/dist/modules/partner_backend/index.d.ts +1 -1
  1322. package/dist/modules/partner_backend/index.d.ts.map +1 -1
  1323. package/dist/modules/partner_backend/index.js +34 -4
  1324. package/dist/modules/partner_backend/index.js.map +1 -1
  1325. package/dist/modules/partner_backend/menus.js +2 -2
  1326. package/dist/modules/partner_backend/menus.js.map +1 -1
  1327. package/dist/modules/partner_backend/routes.d.ts +3 -1
  1328. package/dist/modules/partner_backend/routes.d.ts.map +1 -1
  1329. package/dist/modules/partner_backend/routes.js +236 -91
  1330. package/dist/modules/partner_backend/routes.js.map +1 -1
  1331. package/dist/modules/partner_backend/screens/form.d.ts +21 -0
  1332. package/dist/modules/partner_backend/screens/form.d.ts.map +1 -0
  1333. package/dist/modules/partner_backend/screens/form.js +101 -0
  1334. package/dist/modules/partner_backend/screens/form.js.map +1 -0
  1335. package/dist/modules/partner_backend/screens/index.d.ts +5 -0
  1336. package/dist/modules/partner_backend/screens/index.d.ts.map +1 -0
  1337. package/dist/modules/partner_backend/screens/index.js +4 -0
  1338. package/dist/modules/partner_backend/screens/index.js.map +1 -0
  1339. package/dist/modules/partner_backend/screens/list.d.ts +6 -0
  1340. package/dist/modules/partner_backend/screens/list.d.ts.map +1 -0
  1341. package/dist/modules/partner_backend/screens/list.js +94 -0
  1342. package/dist/modules/partner_backend/screens/list.js.map +1 -0
  1343. package/dist/modules/partner_backend/screens/new.d.ts +5 -0
  1344. package/dist/modules/partner_backend/screens/new.d.ts.map +1 -0
  1345. package/dist/modules/partner_backend/screens/new.js +58 -0
  1346. package/dist/modules/partner_backend/screens/new.js.map +1 -0
  1347. package/dist/modules/partner_backend/screens/types.d.ts +44 -0
  1348. package/dist/modules/partner_backend/screens/types.d.ts.map +1 -0
  1349. package/dist/modules/partner_backend/screens/types.js +2 -0
  1350. package/dist/modules/partner_backend/screens/types.js.map +1 -0
  1351. package/dist/modules/partner_mail_backend/index.d.ts +5 -0
  1352. package/dist/modules/partner_mail_backend/index.d.ts.map +1 -0
  1353. package/dist/modules/partner_mail_backend/index.js +29 -0
  1354. package/dist/modules/partner_mail_backend/index.js.map +1 -0
  1355. package/dist/modules/pos/functions.d.ts +18 -2
  1356. package/dist/modules/pos/functions.d.ts.map +1 -1
  1357. package/dist/modules/pos/functions.js +3279 -345
  1358. package/dist/modules/pos/functions.js.map +1 -1
  1359. package/dist/modules/pos/index.d.ts +2 -1
  1360. package/dist/modules/pos/index.d.ts.map +1 -1
  1361. package/dist/modules/pos/index.js +5 -5
  1362. package/dist/modules/pos/index.js.map +1 -1
  1363. package/dist/modules/pos/models.d.ts.map +1 -1
  1364. package/dist/modules/pos/models.js +189 -1
  1365. package/dist/modules/pos/models.js.map +1 -1
  1366. package/dist/modules/pos/relations.d.ts.map +1 -1
  1367. package/dist/modules/pos/relations.js +11 -0
  1368. package/dist/modules/pos/relations.js.map +1 -1
  1369. package/dist/modules/pos_backend/index.js +182 -154
  1370. package/dist/modules/pos_backend/index.js.map +1 -1
  1371. package/dist/modules/pos_backend/screens.d.ts +1 -0
  1372. package/dist/modules/pos_backend/screens.d.ts.map +1 -1
  1373. package/dist/modules/pos_backend/screens.js +28 -38
  1374. package/dist/modules/pos_backend/screens.js.map +1 -1
  1375. package/dist/modules/pos_channel/catalog.d.ts +27 -0
  1376. package/dist/modules/pos_channel/catalog.d.ts.map +1 -0
  1377. package/dist/modules/pos_channel/catalog.js +310 -0
  1378. package/dist/modules/pos_channel/catalog.js.map +1 -0
  1379. package/dist/modules/pos_channel/index.d.ts +7 -0
  1380. package/dist/modules/pos_channel/index.d.ts.map +1 -0
  1381. package/dist/modules/pos_channel/index.js +61 -0
  1382. package/dist/modules/pos_channel/index.js.map +1 -0
  1383. package/dist/modules/pos_channel/offline.d.ts +66 -0
  1384. package/dist/modules/pos_channel/offline.d.ts.map +1 -0
  1385. package/dist/modules/pos_channel/offline.js +16 -0
  1386. package/dist/modules/pos_channel/offline.js.map +1 -0
  1387. package/dist/modules/pos_channel/operations.d.ts +422 -0
  1388. package/dist/modules/pos_channel/operations.d.ts.map +1 -0
  1389. package/dist/modules/pos_channel/operations.js +1781 -0
  1390. package/dist/modules/pos_channel/operations.js.map +1 -0
  1391. package/dist/modules/pos_channel/sync.d.ts +6 -0
  1392. package/dist/modules/pos_channel/sync.d.ts.map +1 -0
  1393. package/dist/modules/pos_channel/sync.js +1161 -0
  1394. package/dist/modules/pos_channel/sync.js.map +1 -0
  1395. package/dist/modules/pricing/index.d.ts.map +1 -1
  1396. package/dist/modules/pricing/index.js +3 -4
  1397. package/dist/modules/pricing/index.js.map +1 -1
  1398. package/dist/modules/pricing_backend/index.js +135 -78
  1399. package/dist/modules/pricing_backend/index.js.map +1 -1
  1400. package/dist/modules/pricing_backend/screens/index.d.ts +5 -0
  1401. package/dist/modules/pricing_backend/screens/index.d.ts.map +1 -0
  1402. package/dist/modules/pricing_backend/screens/index.js +4 -0
  1403. package/dist/modules/pricing_backend/screens/index.js.map +1 -0
  1404. package/dist/modules/pricing_backend/screens/pricelist-create.d.ts +10 -0
  1405. package/dist/modules/pricing_backend/screens/pricelist-create.d.ts.map +1 -0
  1406. package/dist/modules/pricing_backend/screens/pricelist-create.js +30 -0
  1407. package/dist/modules/pricing_backend/screens/pricelist-create.js.map +1 -0
  1408. package/dist/modules/pricing_backend/screens/pricelist-detail.d.ts +15 -0
  1409. package/dist/modules/pricing_backend/screens/pricelist-detail.d.ts.map +1 -0
  1410. package/dist/modules/pricing_backend/screens/pricelist-detail.js +164 -0
  1411. package/dist/modules/pricing_backend/screens/pricelist-detail.js.map +1 -0
  1412. package/dist/modules/pricing_backend/screens/pricelists-list.d.ts +11 -0
  1413. package/dist/modules/pricing_backend/screens/pricelists-list.d.ts.map +1 -0
  1414. package/dist/modules/pricing_backend/screens/pricelists-list.js +27 -0
  1415. package/dist/modules/pricing_backend/screens/pricelists-list.js.map +1 -0
  1416. package/dist/modules/pricing_backend/screens/shared.d.ts +21 -0
  1417. package/dist/modules/pricing_backend/screens/shared.d.ts.map +1 -0
  1418. package/dist/modules/pricing_backend/screens/shared.js +3 -0
  1419. package/dist/modules/pricing_backend/screens/shared.js.map +1 -0
  1420. package/dist/modules/product/functions.d.ts.map +1 -1
  1421. package/dist/modules/product/functions.js +679 -50
  1422. package/dist/modules/product/functions.js.map +1 -1
  1423. package/dist/modules/product/index.d.ts +2 -0
  1424. package/dist/modules/product/index.d.ts.map +1 -1
  1425. package/dist/modules/product/index.js +2 -2
  1426. package/dist/modules/product/index.js.map +1 -1
  1427. package/dist/modules/product/models.d.ts +1 -1
  1428. package/dist/modules/product/models.d.ts.map +1 -1
  1429. package/dist/modules/product/models.js +27 -4
  1430. package/dist/modules/product/models.js.map +1 -1
  1431. package/dist/modules/product/relations.d.ts.map +1 -1
  1432. package/dist/modules/product/relations.js +4 -0
  1433. package/dist/modules/product/relations.js.map +1 -1
  1434. package/dist/modules/product/sellable.d.ts +26 -0
  1435. package/dist/modules/product/sellable.d.ts.map +1 -0
  1436. package/dist/modules/product/sellable.js +56 -0
  1437. package/dist/modules/product/sellable.js.map +1 -0
  1438. package/dist/modules/product/types.d.ts +2 -2
  1439. package/dist/modules/product/views.d.ts.map +1 -1
  1440. package/dist/modules/product/views.js +5 -1
  1441. package/dist/modules/product/views.js.map +1 -1
  1442. package/dist/modules/product_activity_backend/index.d.ts.map +1 -1
  1443. package/dist/modules/product_activity_backend/index.js +2 -3
  1444. package/dist/modules/product_activity_backend/index.js.map +1 -1
  1445. package/dist/modules/product_backend/client/media-upload-view.d.mts +2 -0
  1446. package/dist/modules/product_backend/client/media-upload-view.d.mts.map +1 -0
  1447. package/dist/modules/product_backend/client/media-upload-view.mjs +27 -0
  1448. package/dist/modules/product_backend/client/media-upload-view.mjs.map +1 -0
  1449. package/dist/modules/product_backend/client/product.css +964 -0
  1450. package/dist/modules/product_backend/client/product.d.mts +2 -0
  1451. package/dist/modules/product_backend/client/product.d.mts.map +1 -1
  1452. package/dist/modules/product_backend/client/product.mjs +3 -0
  1453. package/dist/modules/product_backend/client/product.mjs.map +1 -1
  1454. package/dist/modules/product_backend/index.d.ts +5 -6
  1455. package/dist/modules/product_backend/index.d.ts.map +1 -1
  1456. package/dist/modules/product_backend/index.js +205 -14
  1457. package/dist/modules/product_backend/index.js.map +1 -1
  1458. package/dist/modules/product_backend/islands.d.ts.map +1 -1
  1459. package/dist/modules/product_backend/islands.js +8 -0
  1460. package/dist/modules/product_backend/islands.js.map +1 -1
  1461. package/dist/modules/product_backend/menus.js +2 -2
  1462. package/dist/modules/product_backend/menus.js.map +1 -1
  1463. package/dist/modules/product_backend/relation-control.d.ts +85 -0
  1464. package/dist/modules/product_backend/relation-control.d.ts.map +1 -0
  1465. package/dist/modules/product_backend/relation-control.js +129 -0
  1466. package/dist/modules/product_backend/relation-control.js.map +1 -0
  1467. package/dist/modules/product_backend/routes.d.ts.map +1 -1
  1468. package/dist/modules/product_backend/routes.js +514 -194
  1469. package/dist/modules/product_backend/routes.js.map +1 -1
  1470. package/dist/modules/product_backend/screens/attributes.d.ts +7 -0
  1471. package/dist/modules/product_backend/screens/attributes.d.ts.map +1 -0
  1472. package/dist/modules/product_backend/screens/attributes.js +66 -0
  1473. package/dist/modules/product_backend/screens/attributes.js.map +1 -0
  1474. package/dist/modules/product_backend/screens/create.d.ts +16 -0
  1475. package/dist/modules/product_backend/screens/create.d.ts.map +1 -0
  1476. package/dist/modules/product_backend/screens/create.js +86 -0
  1477. package/dist/modules/product_backend/screens/create.js.map +1 -0
  1478. package/dist/modules/product_backend/screens/detail.d.ts +87 -0
  1479. package/dist/modules/product_backend/screens/detail.d.ts.map +1 -0
  1480. package/dist/modules/product_backend/screens/detail.js +381 -0
  1481. package/dist/modules/product_backend/screens/detail.js.map +1 -0
  1482. package/dist/modules/product_backend/screens/favorite.d.ts +6 -0
  1483. package/dist/modules/product_backend/screens/favorite.d.ts.map +1 -0
  1484. package/dist/modules/product_backend/screens/favorite.js +43 -0
  1485. package/dist/modules/product_backend/screens/favorite.js.map +1 -0
  1486. package/dist/modules/product_backend/screens/index.d.ts +10 -0
  1487. package/dist/modules/product_backend/screens/index.d.ts.map +1 -0
  1488. package/dist/modules/product_backend/screens/index.js +7 -0
  1489. package/dist/modules/product_backend/screens/index.js.map +1 -0
  1490. package/dist/modules/product_backend/screens/list.d.ts +54 -0
  1491. package/dist/modules/product_backend/screens/list.d.ts.map +1 -0
  1492. package/dist/modules/product_backend/screens/list.js +124 -0
  1493. package/dist/modules/product_backend/screens/list.js.map +1 -0
  1494. package/dist/modules/product_backend/screens/variant.d.ts +9 -0
  1495. package/dist/modules/product_backend/screens/variant.d.ts.map +1 -0
  1496. package/dist/modules/product_backend/screens/variant.js +113 -0
  1497. package/dist/modules/product_backend/screens/variant.js.map +1 -0
  1498. package/dist/modules/product_mail_backend/index.d.ts.map +1 -1
  1499. package/dist/modules/product_mail_backend/index.js +2 -3
  1500. package/dist/modules/product_mail_backend/index.js.map +1 -1
  1501. package/dist/modules/product_media/functions.d.ts.map +1 -1
  1502. package/dist/modules/product_media/functions.js +59 -6
  1503. package/dist/modules/product_media/functions.js.map +1 -1
  1504. package/dist/modules/product_media/index.js +0 -1
  1505. package/dist/modules/product_media/index.js.map +1 -1
  1506. package/dist/modules/product_variant_activity_backend/index.d.ts.map +1 -1
  1507. package/dist/modules/product_variant_activity_backend/index.js +2 -3
  1508. package/dist/modules/product_variant_activity_backend/index.js.map +1 -1
  1509. package/dist/modules/product_variant_mail_backend/index.d.ts.map +1 -1
  1510. package/dist/modules/product_variant_mail_backend/index.js +2 -3
  1511. package/dist/modules/product_variant_mail_backend/index.js.map +1 -1
  1512. package/dist/modules/purchase/functions.d.ts.map +1 -1
  1513. package/dist/modules/purchase/functions.js +852 -225
  1514. package/dist/modules/purchase/functions.js.map +1 -1
  1515. package/dist/modules/purchase/index.d.ts.map +1 -1
  1516. package/dist/modules/purchase/index.js +30 -5
  1517. package/dist/modules/purchase/index.js.map +1 -1
  1518. package/dist/modules/purchase/models.d.ts.map +1 -1
  1519. package/dist/modules/purchase/models.js +1 -0
  1520. package/dist/modules/purchase/models.js.map +1 -1
  1521. package/dist/modules/purchase/reports.d.ts +4 -0
  1522. package/dist/modules/purchase/reports.d.ts.map +1 -0
  1523. package/dist/modules/purchase/reports.js +86 -0
  1524. package/dist/modules/purchase/reports.js.map +1 -0
  1525. package/dist/modules/purchase_backend/index.js +513 -112
  1526. package/dist/modules/purchase_backend/index.js.map +1 -1
  1527. package/dist/modules/purchase_backend/screens/index.d.ts +10 -0
  1528. package/dist/modules/purchase_backend/screens/index.d.ts.map +1 -0
  1529. package/dist/modules/purchase_backend/screens/index.js +10 -0
  1530. package/dist/modules/purchase_backend/screens/index.js.map +1 -0
  1531. package/dist/modules/purchase_backend/screens/order-detail.d.ts +31 -0
  1532. package/dist/modules/purchase_backend/screens/order-detail.d.ts.map +1 -0
  1533. package/dist/modules/purchase_backend/screens/order-detail.js +204 -0
  1534. package/dist/modules/purchase_backend/screens/order-detail.js.map +1 -0
  1535. package/dist/modules/purchase_backend/screens/order-list-shared.d.ts +7 -0
  1536. package/dist/modules/purchase_backend/screens/order-list-shared.d.ts.map +1 -0
  1537. package/dist/modules/purchase_backend/screens/order-list-shared.js +58 -0
  1538. package/dist/modules/purchase_backend/screens/order-list-shared.js.map +1 -0
  1539. package/dist/modules/purchase_backend/screens/overview.d.ts +19 -0
  1540. package/dist/modules/purchase_backend/screens/overview.d.ts.map +1 -0
  1541. package/dist/modules/purchase_backend/screens/overview.js +52 -0
  1542. package/dist/modules/purchase_backend/screens/overview.js.map +1 -0
  1543. package/dist/modules/purchase_backend/screens/purchase-orders-list.d.ts +14 -0
  1544. package/dist/modules/purchase_backend/screens/purchase-orders-list.d.ts.map +1 -0
  1545. package/dist/modules/purchase_backend/screens/purchase-orders-list.js +26 -0
  1546. package/dist/modules/purchase_backend/screens/purchase-orders-list.js.map +1 -0
  1547. package/dist/modules/purchase_backend/screens/rfq-create.d.ts +16 -0
  1548. package/dist/modules/purchase_backend/screens/rfq-create.d.ts.map +1 -0
  1549. package/dist/modules/purchase_backend/screens/rfq-create.js +24 -0
  1550. package/dist/modules/purchase_backend/screens/rfq-create.js.map +1 -0
  1551. package/dist/modules/purchase_backend/screens/rfqs-list.d.ts +18 -0
  1552. package/dist/modules/purchase_backend/screens/rfqs-list.d.ts.map +1 -0
  1553. package/dist/modules/purchase_backend/screens/rfqs-list.js +28 -0
  1554. package/dist/modules/purchase_backend/screens/rfqs-list.js.map +1 -0
  1555. package/dist/modules/purchase_backend/screens/shared.d.ts +18 -0
  1556. package/dist/modules/purchase_backend/screens/shared.d.ts.map +1 -0
  1557. package/dist/modules/purchase_backend/screens/shared.js +30 -0
  1558. package/dist/modules/purchase_backend/screens/shared.js.map +1 -0
  1559. package/dist/modules/purchase_backend/screens/vendor-pricelist-create.d.ts +20 -0
  1560. package/dist/modules/purchase_backend/screens/vendor-pricelist-create.d.ts.map +1 -0
  1561. package/dist/modules/purchase_backend/screens/vendor-pricelist-create.js +25 -0
  1562. package/dist/modules/purchase_backend/screens/vendor-pricelist-create.js.map +1 -0
  1563. package/dist/modules/purchase_backend/screens/vendor-pricelists-list.d.ts +33 -0
  1564. package/dist/modules/purchase_backend/screens/vendor-pricelists-list.d.ts.map +1 -0
  1565. package/dist/modules/purchase_backend/screens/vendor-pricelists-list.js +73 -0
  1566. package/dist/modules/purchase_backend/screens/vendor-pricelists-list.js.map +1 -0
  1567. package/dist/modules/purchase_staff_channel/channel-routes.d.ts +2 -0
  1568. package/dist/modules/purchase_staff_channel/channel-routes.d.ts.map +1 -0
  1569. package/dist/modules/purchase_staff_channel/channel-routes.js +119 -0
  1570. package/dist/modules/purchase_staff_channel/channel-routes.js.map +1 -0
  1571. package/dist/modules/purchase_staff_channel/index.d.ts +8 -0
  1572. package/dist/modules/purchase_staff_channel/index.d.ts.map +1 -0
  1573. package/dist/modules/purchase_staff_channel/index.js +45 -0
  1574. package/dist/modules/purchase_staff_channel/index.js.map +1 -0
  1575. package/dist/modules/purchase_staff_channel/order-routes.d.ts +2 -0
  1576. package/dist/modules/purchase_staff_channel/order-routes.d.ts.map +1 -0
  1577. package/dist/modules/purchase_staff_channel/order-routes.js +754 -0
  1578. package/dist/modules/purchase_staff_channel/order-routes.js.map +1 -0
  1579. package/dist/modules/purchase_staff_channel/product-routes.d.ts +2 -0
  1580. package/dist/modules/purchase_staff_channel/product-routes.d.ts.map +1 -0
  1581. package/dist/modules/purchase_staff_channel/product-routes.js +183 -0
  1582. package/dist/modules/purchase_staff_channel/product-routes.js.map +1 -0
  1583. package/dist/modules/purchase_staff_channel/vendor-bill-routes.d.ts +2 -0
  1584. package/dist/modules/purchase_staff_channel/vendor-bill-routes.d.ts.map +1 -0
  1585. package/dist/modules/purchase_staff_channel/vendor-bill-routes.js +189 -0
  1586. package/dist/modules/purchase_staff_channel/vendor-bill-routes.js.map +1 -0
  1587. package/dist/modules/quality/functions.d.ts +3 -0
  1588. package/dist/modules/quality/functions.d.ts.map +1 -0
  1589. package/dist/modules/quality/functions.js +381 -0
  1590. package/dist/modules/quality/functions.js.map +1 -0
  1591. package/dist/modules/quality/index.d.ts +5 -0
  1592. package/dist/modules/quality/index.d.ts.map +1 -0
  1593. package/dist/modules/quality/index.js +19 -0
  1594. package/dist/modules/quality/index.js.map +1 -0
  1595. package/dist/modules/quality/models.d.ts +3 -0
  1596. package/dist/modules/quality/models.d.ts.map +1 -0
  1597. package/dist/modules/quality/models.js +91 -0
  1598. package/dist/modules/quality/models.js.map +1 -0
  1599. package/dist/modules/quality_staff_channel/channel-routes.d.ts +2 -0
  1600. package/dist/modules/quality_staff_channel/channel-routes.d.ts.map +1 -0
  1601. package/dist/modules/quality_staff_channel/channel-routes.js +495 -0
  1602. package/dist/modules/quality_staff_channel/channel-routes.js.map +1 -0
  1603. package/dist/modules/quality_staff_channel/index.d.ts +5 -0
  1604. package/dist/modules/quality_staff_channel/index.d.ts.map +1 -0
  1605. package/dist/modules/quality_staff_channel/index.js +30 -0
  1606. package/dist/modules/quality_staff_channel/index.js.map +1 -0
  1607. package/dist/modules/report/functions.d.ts +3 -0
  1608. package/dist/modules/report/functions.d.ts.map +1 -0
  1609. package/dist/modules/report/functions.js +197 -0
  1610. package/dist/modules/report/functions.js.map +1 -0
  1611. package/dist/modules/report/index.d.ts +3 -0
  1612. package/dist/modules/report/index.d.ts.map +1 -0
  1613. package/dist/modules/report/index.js +21 -0
  1614. package/dist/modules/report/index.js.map +1 -0
  1615. package/dist/modules/report/jobs.d.ts +3 -0
  1616. package/dist/modules/report/jobs.d.ts.map +1 -0
  1617. package/dist/modules/report/jobs.js +18 -0
  1618. package/dist/modules/report/jobs.js.map +1 -0
  1619. package/dist/modules/report/models.d.ts +3 -0
  1620. package/dist/modules/report/models.d.ts.map +1 -0
  1621. package/dist/modules/report/models.js +45 -0
  1622. package/dist/modules/report/models.js.map +1 -0
  1623. package/dist/modules/report/routes.d.ts +19 -0
  1624. package/dist/modules/report/routes.d.ts.map +1 -0
  1625. package/dist/modules/report/routes.js +138 -0
  1626. package/dist/modules/report/routes.js.map +1 -0
  1627. package/dist/modules/report_backend/index.d.ts +3 -0
  1628. package/dist/modules/report_backend/index.d.ts.map +1 -0
  1629. package/dist/modules/report_backend/index.js +67 -0
  1630. package/dist/modules/report_backend/index.js.map +1 -0
  1631. package/dist/modules/report_backend/routes.d.ts +10 -0
  1632. package/dist/modules/report_backend/routes.d.ts.map +1 -0
  1633. package/dist/modules/report_backend/routes.js +87 -0
  1634. package/dist/modules/report_backend/routes.js.map +1 -0
  1635. package/dist/modules/report_backend/screens/index.d.ts +13 -0
  1636. package/dist/modules/report_backend/screens/index.d.ts.map +1 -0
  1637. package/dist/modules/report_backend/screens/index.js +91 -0
  1638. package/dist/modules/report_backend/screens/index.js.map +1 -0
  1639. package/dist/modules/sale/functions.d.ts.map +1 -1
  1640. package/dist/modules/sale/functions.js +796 -238
  1641. package/dist/modules/sale/functions.js.map +1 -1
  1642. package/dist/modules/sale/index.d.ts.map +1 -1
  1643. package/dist/modules/sale/index.js +44 -5
  1644. package/dist/modules/sale/index.js.map +1 -1
  1645. package/dist/modules/sale/models.d.ts.map +1 -1
  1646. package/dist/modules/sale/models.js +47 -1
  1647. package/dist/modules/sale/models.js.map +1 -1
  1648. package/dist/modules/sale/relations.d.ts.map +1 -1
  1649. package/dist/modules/sale/relations.js +6 -0
  1650. package/dist/modules/sale/relations.js.map +1 -1
  1651. package/dist/modules/sale/reports.d.ts +4 -0
  1652. package/dist/modules/sale/reports.d.ts.map +1 -0
  1653. package/dist/modules/sale/reports.js +132 -0
  1654. package/dist/modules/sale/reports.js.map +1 -0
  1655. package/dist/modules/sale/scope.d.ts +31 -0
  1656. package/dist/modules/sale/scope.d.ts.map +1 -0
  1657. package/dist/modules/sale/scope.js +34 -0
  1658. package/dist/modules/sale/scope.js.map +1 -0
  1659. package/dist/modules/sale_activity_backend/index.d.ts.map +1 -1
  1660. package/dist/modules/sale_activity_backend/index.js +0 -1
  1661. package/dist/modules/sale_activity_backend/index.js.map +1 -1
  1662. package/dist/modules/sale_backend/index.js +338 -121
  1663. package/dist/modules/sale_backend/index.js.map +1 -1
  1664. package/dist/modules/sale_backend/screens/index.d.ts +9 -0
  1665. package/dist/modules/sale_backend/screens/index.d.ts.map +1 -0
  1666. package/dist/modules/sale_backend/screens/index.js +9 -0
  1667. package/dist/modules/sale_backend/screens/index.js.map +1 -0
  1668. package/dist/modules/sale_backend/screens/invoicing-policies-list.d.ts +14 -0
  1669. package/dist/modules/sale_backend/screens/invoicing-policies-list.d.ts.map +1 -0
  1670. package/dist/modules/sale_backend/screens/invoicing-policies-list.js +48 -0
  1671. package/dist/modules/sale_backend/screens/invoicing-policies-list.js.map +1 -0
  1672. package/dist/modules/sale_backend/screens/invoicing-policy-create.d.ts +14 -0
  1673. package/dist/modules/sale_backend/screens/invoicing-policy-create.d.ts.map +1 -0
  1674. package/dist/modules/sale_backend/screens/invoicing-policy-create.js +38 -0
  1675. package/dist/modules/sale_backend/screens/invoicing-policy-create.js.map +1 -0
  1676. package/dist/modules/sale_backend/screens/order-detail.d.ts +43 -0
  1677. package/dist/modules/sale_backend/screens/order-detail.d.ts.map +1 -0
  1678. package/dist/modules/sale_backend/screens/order-detail.js +226 -0
  1679. package/dist/modules/sale_backend/screens/order-detail.js.map +1 -0
  1680. package/dist/modules/sale_backend/screens/overview.d.ts +31 -0
  1681. package/dist/modules/sale_backend/screens/overview.d.ts.map +1 -0
  1682. package/dist/modules/sale_backend/screens/overview.js +73 -0
  1683. package/dist/modules/sale_backend/screens/overview.js.map +1 -0
  1684. package/dist/modules/sale_backend/screens/quotation-create.d.ts +13 -0
  1685. package/dist/modules/sale_backend/screens/quotation-create.d.ts.map +1 -0
  1686. package/dist/modules/sale_backend/screens/quotation-create.js +19 -0
  1687. package/dist/modules/sale_backend/screens/quotation-create.js.map +1 -0
  1688. package/dist/modules/sale_backend/screens/quotations-list.d.ts +25 -0
  1689. package/dist/modules/sale_backend/screens/quotations-list.d.ts.map +1 -0
  1690. package/dist/modules/sale_backend/screens/quotations-list.js +96 -0
  1691. package/dist/modules/sale_backend/screens/quotations-list.js.map +1 -0
  1692. package/dist/modules/sale_backend/screens/sales-orders-list.d.ts +25 -0
  1693. package/dist/modules/sale_backend/screens/sales-orders-list.d.ts.map +1 -0
  1694. package/dist/modules/sale_backend/screens/sales-orders-list.js +100 -0
  1695. package/dist/modules/sale_backend/screens/sales-orders-list.js.map +1 -0
  1696. package/dist/modules/sale_backend/screens/shared.d.ts +4 -0
  1697. package/dist/modules/sale_backend/screens/shared.d.ts.map +1 -0
  1698. package/dist/modules/sale_backend/screens/shared.js +4 -0
  1699. package/dist/modules/sale_backend/screens/shared.js.map +1 -0
  1700. package/dist/modules/sale_mail_backend/index.d.ts.map +1 -1
  1701. package/dist/modules/sale_mail_backend/index.js +0 -1
  1702. package/dist/modules/sale_mail_backend/index.js.map +1 -1
  1703. package/dist/modules/sale_staff_channel/channel-routes.d.ts +2 -0
  1704. package/dist/modules/sale_staff_channel/channel-routes.d.ts.map +1 -0
  1705. package/dist/modules/sale_staff_channel/channel-routes.js +296 -0
  1706. package/dist/modules/sale_staff_channel/channel-routes.js.map +1 -0
  1707. package/dist/modules/sale_staff_channel/index.d.ts +7 -0
  1708. package/dist/modules/sale_staff_channel/index.d.ts.map +1 -0
  1709. package/dist/modules/sale_staff_channel/index.js +44 -0
  1710. package/dist/modules/sale_staff_channel/index.js.map +1 -0
  1711. package/dist/modules/sale_staff_channel/order-routes.d.ts +2 -0
  1712. package/dist/modules/sale_staff_channel/order-routes.d.ts.map +1 -0
  1713. package/dist/modules/sale_staff_channel/order-routes.js +658 -0
  1714. package/dist/modules/sale_staff_channel/order-routes.js.map +1 -0
  1715. package/dist/modules/sale_staff_channel/product-routes.d.ts +2 -0
  1716. package/dist/modules/sale_staff_channel/product-routes.d.ts.map +1 -0
  1717. package/dist/modules/sale_staff_channel/product-routes.js +183 -0
  1718. package/dist/modules/sale_staff_channel/product-routes.js.map +1 -0
  1719. package/dist/modules/stock/functions.d.ts.map +1 -1
  1720. package/dist/modules/stock/functions.js +1239 -332
  1721. package/dist/modules/stock/functions.js.map +1 -1
  1722. package/dist/modules/stock/index.d.ts +2 -0
  1723. package/dist/modules/stock/index.d.ts.map +1 -1
  1724. package/dist/modules/stock/index.js +29 -6
  1725. package/dist/modules/stock/index.js.map +1 -1
  1726. package/dist/modules/stock/models.d.ts.map +1 -1
  1727. package/dist/modules/stock/models.js +1 -0
  1728. package/dist/modules/stock/models.js.map +1 -1
  1729. package/dist/modules/stock/reports.d.ts +4 -0
  1730. package/dist/modules/stock/reports.d.ts.map +1 -0
  1731. package/dist/modules/stock/reports.js +100 -0
  1732. package/dist/modules/stock/reports.js.map +1 -0
  1733. package/dist/modules/stock/routing.d.ts +1 -1
  1734. package/dist/modules/stock/routing.d.ts.map +1 -1
  1735. package/dist/modules/stock/routing.js +35 -30
  1736. package/dist/modules/stock/routing.js.map +1 -1
  1737. package/dist/modules/stock/scope.d.ts +23 -0
  1738. package/dist/modules/stock/scope.d.ts.map +1 -0
  1739. package/dist/modules/stock/scope.js +26 -0
  1740. package/dist/modules/stock/scope.js.map +1 -0
  1741. package/dist/modules/stock/units.d.ts +14 -0
  1742. package/dist/modules/stock/units.d.ts.map +1 -0
  1743. package/dist/modules/stock/units.js +50 -0
  1744. package/dist/modules/stock/units.js.map +1 -0
  1745. package/dist/modules/stock_activity_backend/index.d.ts.map +1 -1
  1746. package/dist/modules/stock_activity_backend/index.js +0 -1
  1747. package/dist/modules/stock_activity_backend/index.js.map +1 -1
  1748. package/dist/modules/stock_backend/client/editor-view.d.mts.map +1 -1
  1749. package/dist/modules/stock_backend/client/editor-view.mjs +12 -10
  1750. package/dist/modules/stock_backend/client/editor-view.mjs.map +1 -1
  1751. package/dist/modules/stock_backend/index.js +27 -20
  1752. package/dist/modules/stock_backend/index.js.map +1 -1
  1753. package/dist/modules/stock_backend/routes.d.ts.map +1 -1
  1754. package/dist/modules/stock_backend/routes.js +485 -232
  1755. package/dist/modules/stock_backend/routes.js.map +1 -1
  1756. package/dist/modules/stock_backend/screens/forecast.d.ts +28 -0
  1757. package/dist/modules/stock_backend/screens/forecast.d.ts.map +1 -0
  1758. package/dist/modules/stock_backend/screens/forecast.js +108 -0
  1759. package/dist/modules/stock_backend/screens/forecast.js.map +1 -0
  1760. package/dist/modules/stock_backend/screens/index.d.ts +22 -0
  1761. package/dist/modules/stock_backend/screens/index.d.ts.map +1 -0
  1762. package/dist/modules/stock_backend/screens/index.js +22 -0
  1763. package/dist/modules/stock_backend/screens/index.js.map +1 -0
  1764. package/dist/modules/stock_backend/screens/inventory.d.ts +27 -0
  1765. package/dist/modules/stock_backend/screens/inventory.d.ts.map +1 -0
  1766. package/dist/modules/stock_backend/screens/inventory.js +128 -0
  1767. package/dist/modules/stock_backend/screens/inventory.js.map +1 -0
  1768. package/dist/modules/stock_backend/screens/location-create.d.ts +15 -0
  1769. package/dist/modules/stock_backend/screens/location-create.d.ts.map +1 -0
  1770. package/dist/modules/stock_backend/screens/location-create.js +75 -0
  1771. package/dist/modules/stock_backend/screens/location-create.js.map +1 -0
  1772. package/dist/modules/stock_backend/screens/locations-list.d.ts +21 -0
  1773. package/dist/modules/stock_backend/screens/locations-list.d.ts.map +1 -0
  1774. package/dist/modules/stock_backend/screens/locations-list.js +62 -0
  1775. package/dist/modules/stock_backend/screens/locations-list.js.map +1 -0
  1776. package/dist/modules/stock_backend/screens/lot-create.d.ts +14 -0
  1777. package/dist/modules/stock_backend/screens/lot-create.d.ts.map +1 -0
  1778. package/dist/modules/stock_backend/screens/lot-create.js +60 -0
  1779. package/dist/modules/stock_backend/screens/lot-create.js.map +1 -0
  1780. package/dist/modules/stock_backend/screens/lot-detail.d.ts +30 -0
  1781. package/dist/modules/stock_backend/screens/lot-detail.d.ts.map +1 -0
  1782. package/dist/modules/stock_backend/screens/lot-detail.js +84 -0
  1783. package/dist/modules/stock_backend/screens/lot-detail.js.map +1 -0
  1784. package/dist/modules/stock_backend/screens/lots-list.d.ts +25 -0
  1785. package/dist/modules/stock_backend/screens/lots-list.d.ts.map +1 -0
  1786. package/dist/modules/stock_backend/screens/lots-list.js +54 -0
  1787. package/dist/modules/stock_backend/screens/lots-list.js.map +1 -0
  1788. package/dist/modules/stock_backend/screens/picking-type-create.d.ts +15 -0
  1789. package/dist/modules/stock_backend/screens/picking-type-create.d.ts.map +1 -0
  1790. package/dist/modules/stock_backend/screens/picking-type-create.js +89 -0
  1791. package/dist/modules/stock_backend/screens/picking-type-create.js.map +1 -0
  1792. package/dist/modules/stock_backend/screens/picking-types-list.d.ts +22 -0
  1793. package/dist/modules/stock_backend/screens/picking-types-list.d.ts.map +1 -0
  1794. package/dist/modules/stock_backend/screens/picking-types-list.js +80 -0
  1795. package/dist/modules/stock_backend/screens/picking-types-list.js.map +1 -0
  1796. package/dist/modules/stock_backend/screens/replenishment-create.d.ts +17 -0
  1797. package/dist/modules/stock_backend/screens/replenishment-create.d.ts.map +1 -0
  1798. package/dist/modules/stock_backend/screens/replenishment-create.js +74 -0
  1799. package/dist/modules/stock_backend/screens/replenishment-create.js.map +1 -0
  1800. package/dist/modules/stock_backend/screens/replenishment-list.d.ts +29 -0
  1801. package/dist/modules/stock_backend/screens/replenishment-list.d.ts.map +1 -0
  1802. package/dist/modules/stock_backend/screens/replenishment-list.js +84 -0
  1803. package/dist/modules/stock_backend/screens/replenishment-list.js.map +1 -0
  1804. package/dist/modules/stock_backend/screens/shared.d.ts +12 -0
  1805. package/dist/modules/stock_backend/screens/shared.d.ts.map +1 -0
  1806. package/dist/modules/stock_backend/screens/shared.js +29 -0
  1807. package/dist/modules/stock_backend/screens/shared.js.map +1 -0
  1808. package/dist/modules/stock_backend/screens/stock-route-create.d.ts +13 -0
  1809. package/dist/modules/stock_backend/screens/stock-route-create.d.ts.map +1 -0
  1810. package/dist/modules/stock_backend/screens/stock-route-create.js +52 -0
  1811. package/dist/modules/stock_backend/screens/stock-route-create.js.map +1 -0
  1812. package/dist/modules/stock_backend/screens/stock-route-detail.d.ts +30 -0
  1813. package/dist/modules/stock_backend/screens/stock-route-detail.d.ts.map +1 -0
  1814. package/dist/modules/stock_backend/screens/stock-route-detail.js +131 -0
  1815. package/dist/modules/stock_backend/screens/stock-route-detail.js.map +1 -0
  1816. package/dist/modules/stock_backend/screens/stock-routes-list.d.ts +22 -0
  1817. package/dist/modules/stock_backend/screens/stock-routes-list.d.ts.map +1 -0
  1818. package/dist/modules/stock_backend/screens/stock-routes-list.js +51 -0
  1819. package/dist/modules/stock_backend/screens/stock-routes-list.js.map +1 -0
  1820. package/dist/modules/stock_backend/screens/stock.d.ts +7 -0
  1821. package/dist/modules/stock_backend/screens/stock.d.ts.map +1 -0
  1822. package/dist/modules/stock_backend/screens/stock.js +13 -0
  1823. package/dist/modules/stock_backend/screens/stock.js.map +1 -0
  1824. package/dist/modules/stock_backend/screens/transfer-create.d.ts +13 -0
  1825. package/dist/modules/stock_backend/screens/transfer-create.d.ts.map +1 -0
  1826. package/dist/modules/stock_backend/screens/transfer-create.js +38 -0
  1827. package/dist/modules/stock_backend/screens/transfer-create.js.map +1 -0
  1828. package/dist/modules/stock_backend/screens/transfer-detail.d.ts +27 -0
  1829. package/dist/modules/stock_backend/screens/transfer-detail.d.ts.map +1 -0
  1830. package/dist/modules/stock_backend/screens/transfer-detail.js +91 -0
  1831. package/dist/modules/stock_backend/screens/transfer-detail.js.map +1 -0
  1832. package/dist/modules/stock_backend/screens/transfers-list.d.ts +25 -0
  1833. package/dist/modules/stock_backend/screens/transfers-list.d.ts.map +1 -0
  1834. package/dist/modules/stock_backend/screens/transfers-list.js +81 -0
  1835. package/dist/modules/stock_backend/screens/transfers-list.js.map +1 -0
  1836. package/dist/modules/stock_backend/screens/warehouse-create.d.ts +13 -0
  1837. package/dist/modules/stock_backend/screens/warehouse-create.d.ts.map +1 -0
  1838. package/dist/modules/stock_backend/screens/warehouse-create.js +79 -0
  1839. package/dist/modules/stock_backend/screens/warehouse-create.js.map +1 -0
  1840. package/dist/modules/stock_backend/screens/warehouses-list.d.ts +21 -0
  1841. package/dist/modules/stock_backend/screens/warehouses-list.d.ts.map +1 -0
  1842. package/dist/modules/stock_backend/screens/warehouses-list.js +60 -0
  1843. package/dist/modules/stock_backend/screens/warehouses-list.js.map +1 -0
  1844. package/dist/modules/stock_lot_activity_backend/index.d.ts.map +1 -1
  1845. package/dist/modules/stock_lot_activity_backend/index.js +0 -1
  1846. package/dist/modules/stock_lot_activity_backend/index.js.map +1 -1
  1847. package/dist/modules/stock_lot_mail_backend/index.d.ts.map +1 -1
  1848. package/dist/modules/stock_lot_mail_backend/index.js +0 -1
  1849. package/dist/modules/stock_lot_mail_backend/index.js.map +1 -1
  1850. package/dist/modules/stock_mail_backend/index.d.ts.map +1 -1
  1851. package/dist/modules/stock_mail_backend/index.js +0 -1
  1852. package/dist/modules/stock_mail_backend/index.js.map +1 -1
  1853. package/dist/modules/stock_mail_inbound/index.d.ts.map +1 -1
  1854. package/dist/modules/stock_mail_inbound/index.js +0 -2
  1855. package/dist/modules/stock_mail_inbound/index.js.map +1 -1
  1856. package/dist/modules/stock_staff_channel/channel-routes.d.ts +656 -0
  1857. package/dist/modules/stock_staff_channel/channel-routes.d.ts.map +1 -0
  1858. package/dist/modules/stock_staff_channel/channel-routes.js +445 -0
  1859. package/dist/modules/stock_staff_channel/channel-routes.js.map +1 -0
  1860. package/dist/modules/stock_staff_channel/functions.d.ts +3 -0
  1861. package/dist/modules/stock_staff_channel/functions.d.ts.map +1 -0
  1862. package/dist/modules/stock_staff_channel/functions.js +954 -0
  1863. package/dist/modules/stock_staff_channel/functions.js.map +1 -0
  1864. package/dist/modules/stock_staff_channel/index.d.ts +8 -0
  1865. package/dist/modules/stock_staff_channel/index.d.ts.map +1 -0
  1866. package/dist/modules/stock_staff_channel/index.js +37 -0
  1867. package/dist/modules/stock_staff_channel/index.js.map +1 -0
  1868. package/dist/modules/stock_staff_channel/models.d.ts +4 -0
  1869. package/dist/modules/stock_staff_channel/models.d.ts.map +1 -0
  1870. package/dist/modules/stock_staff_channel/models.js +119 -0
  1871. package/dist/modules/stock_staff_channel/models.js.map +1 -0
  1872. package/dist/modules/stock_staff_channel/operation-routes.d.ts +2 -0
  1873. package/dist/modules/stock_staff_channel/operation-routes.d.ts.map +1 -0
  1874. package/dist/modules/stock_staff_channel/operation-routes.js +1269 -0
  1875. package/dist/modules/stock_staff_channel/operation-routes.js.map +1 -0
  1876. package/dist/modules/storage/functions.d.ts.map +1 -1
  1877. package/dist/modules/storage/functions.js +18 -5
  1878. package/dist/modules/storage/functions.js.map +1 -1
  1879. package/dist/modules/storage/index.js +0 -1
  1880. package/dist/modules/storage/index.js.map +1 -1
  1881. package/dist/modules/storage/jobs.d.ts +21 -1
  1882. package/dist/modules/storage/jobs.d.ts.map +1 -1
  1883. package/dist/modules/storage/jobs.js +142 -2
  1884. package/dist/modules/storage/jobs.js.map +1 -1
  1885. package/dist/modules/storage/models.d.ts.map +1 -1
  1886. package/dist/modules/storage/models.js +2 -0
  1887. package/dist/modules/storage/models.js.map +1 -1
  1888. package/dist/modules/storage/policy.d.ts +5 -0
  1889. package/dist/modules/storage/policy.d.ts.map +1 -0
  1890. package/dist/modules/storage/policy.js +13 -0
  1891. package/dist/modules/storage/policy.js.map +1 -0
  1892. package/dist/modules/storage/routes.d.ts +1 -0
  1893. package/dist/modules/storage/routes.d.ts.map +1 -1
  1894. package/dist/modules/storage/routes.js +19 -15
  1895. package/dist/modules/storage/routes.js.map +1 -1
  1896. package/dist/modules/uom/convert.d.ts +1 -1
  1897. package/dist/modules/uom/convert.js +2 -2
  1898. package/dist/modules/uom/convert.js.map +1 -1
  1899. package/dist/modules/uom/functions.d.ts.map +1 -1
  1900. package/dist/modules/uom/functions.js +39 -4
  1901. package/dist/modules/uom/functions.js.map +1 -1
  1902. package/dist/modules/uom/index.d.ts.map +1 -1
  1903. package/dist/modules/uom/index.js +1 -2
  1904. package/dist/modules/uom/index.js.map +1 -1
  1905. package/dist/modules/uom/messages.js +2 -2
  1906. package/dist/modules/uom/messages.js.map +1 -1
  1907. package/dist/modules/uom/models.d.ts +1 -1
  1908. package/dist/modules/uom/models.d.ts.map +1 -1
  1909. package/dist/modules/uom/models.js +1 -1
  1910. package/dist/modules/uom/models.js.map +1 -1
  1911. package/dist/modules/user/authorization.d.ts +80 -0
  1912. package/dist/modules/user/authorization.d.ts.map +1 -0
  1913. package/dist/modules/user/authorization.js +1039 -0
  1914. package/dist/modules/user/authorization.js.map +1 -0
  1915. package/dist/modules/user/functions.d.ts.map +1 -1
  1916. package/dist/modules/user/functions.js +188 -32
  1917. package/dist/modules/user/functions.js.map +1 -1
  1918. package/dist/modules/user/index.d.ts +4 -1
  1919. package/dist/modules/user/index.d.ts.map +1 -1
  1920. package/dist/modules/user/index.js +2 -3
  1921. package/dist/modules/user/index.js.map +1 -1
  1922. package/dist/modules/user/login.d.ts +1 -27
  1923. package/dist/modules/user/login.d.ts.map +1 -1
  1924. package/dist/modules/user/login.js +5 -45
  1925. package/dist/modules/user/login.js.map +1 -1
  1926. package/dist/modules/user/messages.d.ts +6 -0
  1927. package/dist/modules/user/messages.d.ts.map +1 -1
  1928. package/dist/modules/user/messages.js +6 -0
  1929. package/dist/modules/user/messages.js.map +1 -1
  1930. package/dist/modules/user/models.d.ts +1 -1
  1931. package/dist/modules/user/models.d.ts.map +1 -1
  1932. package/dist/modules/user/models.js +73 -9
  1933. package/dist/modules/user/models.js.map +1 -1
  1934. package/dist/modules/user/relations.d.ts.map +1 -1
  1935. package/dist/modules/user/relations.js +6 -0
  1936. package/dist/modules/user/relations.js.map +1 -1
  1937. package/dist/modules/user/roles.d.ts +11 -1
  1938. package/dist/modules/user/roles.d.ts.map +1 -1
  1939. package/dist/modules/user/roles.js +402 -117
  1940. package/dist/modules/user/roles.js.map +1 -1
  1941. package/dist/modules/user/routes.js +1 -1
  1942. package/dist/modules/user/routes.js.map +1 -1
  1943. package/dist/modules/user_backend/index.d.ts +1 -1
  1944. package/dist/modules/user_backend/index.d.ts.map +1 -1
  1945. package/dist/modules/user_backend/index.js +1 -3
  1946. package/dist/modules/user_backend/index.js.map +1 -1
  1947. package/dist/modules/user_backend/messages.d.ts +60 -0
  1948. package/dist/modules/user_backend/messages.d.ts.map +1 -1
  1949. package/dist/modules/user_backend/messages.js +60 -0
  1950. package/dist/modules/user_backend/messages.js.map +1 -1
  1951. package/dist/modules/user_backend/routes.d.ts.map +1 -1
  1952. package/dist/modules/user_backend/routes.js +352 -69
  1953. package/dist/modules/user_backend/routes.js.map +1 -1
  1954. package/dist/modules/user_backend/screens/index.d.ts +11 -0
  1955. package/dist/modules/user_backend/screens/index.d.ts.map +1 -0
  1956. package/dist/modules/user_backend/screens/index.js +8 -0
  1957. package/dist/modules/user_backend/screens/index.js.map +1 -0
  1958. package/dist/modules/user_backend/screens/presets-form.d.ts +16 -0
  1959. package/dist/modules/user_backend/screens/presets-form.d.ts.map +1 -0
  1960. package/dist/modules/user_backend/screens/presets-form.js +37 -0
  1961. package/dist/modules/user_backend/screens/presets-form.js.map +1 -0
  1962. package/dist/modules/user_backend/screens/profile-form.d.ts +14 -0
  1963. package/dist/modules/user_backend/screens/profile-form.d.ts.map +1 -0
  1964. package/dist/modules/user_backend/screens/profile-form.js +37 -0
  1965. package/dist/modules/user_backend/screens/profile-form.js.map +1 -0
  1966. package/dist/modules/user_backend/screens/role-form.d.ts +21 -0
  1967. package/dist/modules/user_backend/screens/role-form.d.ts.map +1 -0
  1968. package/dist/modules/user_backend/screens/role-form.js +93 -0
  1969. package/dist/modules/user_backend/screens/role-form.js.map +1 -0
  1970. package/dist/modules/user_backend/screens/roles-list.d.ts +15 -0
  1971. package/dist/modules/user_backend/screens/roles-list.d.ts.map +1 -0
  1972. package/dist/modules/user_backend/screens/roles-list.js +48 -0
  1973. package/dist/modules/user_backend/screens/roles-list.js.map +1 -0
  1974. package/dist/modules/user_backend/screens/sessions.d.ts +5 -0
  1975. package/dist/modules/user_backend/screens/sessions.d.ts.map +1 -0
  1976. package/dist/modules/user_backend/screens/sessions.js +35 -0
  1977. package/dist/modules/user_backend/screens/sessions.js.map +1 -0
  1978. package/dist/modules/user_backend/screens/types.d.ts +68 -0
  1979. package/dist/modules/user_backend/screens/types.d.ts.map +1 -0
  1980. package/dist/modules/user_backend/screens/types.js +2 -0
  1981. package/dist/modules/user_backend/screens/types.js.map +1 -0
  1982. package/dist/modules/user_backend/screens/user-form.d.ts +55 -0
  1983. package/dist/modules/user_backend/screens/user-form.d.ts.map +1 -0
  1984. package/dist/modules/user_backend/screens/user-form.js +174 -0
  1985. package/dist/modules/user_backend/screens/user-form.js.map +1 -0
  1986. package/dist/modules/user_backend/screens/users-list.d.ts +17 -0
  1987. package/dist/modules/user_backend/screens/users-list.d.ts.map +1 -0
  1988. package/dist/modules/user_backend/screens/users-list.js +56 -0
  1989. package/dist/modules/user_backend/screens/users-list.js.map +1 -0
  1990. package/dist/modules/website/cms.d.ts +18 -1
  1991. package/dist/modules/website/cms.d.ts.map +1 -1
  1992. package/dist/modules/website/cms.js +373 -38
  1993. package/dist/modules/website/cms.js.map +1 -1
  1994. package/dist/modules/website/customer.d.ts.map +1 -1
  1995. package/dist/modules/website/customer.js +249 -1
  1996. package/dist/modules/website/customer.js.map +1 -1
  1997. package/dist/modules/website/index.d.ts.map +1 -1
  1998. package/dist/modules/website/index.js +26 -4
  1999. package/dist/modules/website/index.js.map +1 -1
  2000. package/dist/modules/website/models.d.ts.map +1 -1
  2001. package/dist/modules/website/models.js +101 -0
  2002. package/dist/modules/website/models.js.map +1 -1
  2003. package/dist/modules/website/paths.d.ts +31 -0
  2004. package/dist/modules/website/paths.d.ts.map +1 -0
  2005. package/dist/modules/website/paths.js +48 -0
  2006. package/dist/modules/website/paths.js.map +1 -0
  2007. package/dist/modules/website/publication.d.ts +3 -0
  2008. package/dist/modules/website/publication.d.ts.map +1 -0
  2009. package/dist/modules/website/publication.js +366 -0
  2010. package/dist/modules/website/publication.js.map +1 -0
  2011. package/dist/modules/website/renderable.d.ts +32 -0
  2012. package/dist/modules/website/renderable.d.ts.map +1 -0
  2013. package/dist/modules/website/renderable.js +59 -0
  2014. package/dist/modules/website/renderable.js.map +1 -0
  2015. package/dist/modules/website/sections.d.ts.map +1 -1
  2016. package/dist/modules/website/sections.js +13 -0
  2017. package/dist/modules/website/sections.js.map +1 -1
  2018. package/dist/modules/website_backend/csv.d.ts +23 -0
  2019. package/dist/modules/website_backend/csv.d.ts.map +1 -0
  2020. package/dist/modules/website_backend/csv.js +31 -0
  2021. package/dist/modules/website_backend/csv.js.map +1 -0
  2022. package/dist/modules/website_backend/index.js +260 -2
  2023. package/dist/modules/website_backend/index.js.map +1 -1
  2024. package/dist/modules/website_backend/menus.d.ts.map +1 -1
  2025. package/dist/modules/website_backend/menus.js +28 -6
  2026. package/dist/modules/website_backend/menus.js.map +1 -1
  2027. package/dist/modules/website_backend/routes.d.ts.map +1 -1
  2028. package/dist/modules/website_backend/routes.js +684 -126
  2029. package/dist/modules/website_backend/routes.js.map +1 -1
  2030. package/dist/modules/website_backend/screens/index.d.ts +333 -0
  2031. package/dist/modules/website_backend/screens/index.d.ts.map +1 -0
  2032. package/dist/modules/website_backend/screens/index.js +1332 -0
  2033. package/dist/modules/website_backend/screens/index.js.map +1 -0
  2034. package/dist/modules/website_backend/screens/page-frame.d.ts +14 -0
  2035. package/dist/modules/website_backend/screens/page-frame.d.ts.map +1 -0
  2036. package/dist/modules/website_backend/screens/page-frame.js +13 -0
  2037. package/dist/modules/website_backend/screens/page-frame.js.map +1 -0
  2038. package/dist/modules/website_form/audit.d.ts +27 -0
  2039. package/dist/modules/website_form/audit.d.ts.map +1 -0
  2040. package/dist/modules/website_form/audit.js +30 -0
  2041. package/dist/modules/website_form/audit.js.map +1 -0
  2042. package/dist/modules/website_form/functions.d.ts.map +1 -1
  2043. package/dist/modules/website_form/functions.js +416 -12
  2044. package/dist/modules/website_form/functions.js.map +1 -1
  2045. package/dist/modules/website_form/index.js +24 -2
  2046. package/dist/modules/website_form/index.js.map +1 -1
  2047. package/dist/modules/website_form/jobs.d.ts +11 -0
  2048. package/dist/modules/website_form/jobs.d.ts.map +1 -0
  2049. package/dist/modules/website_form/jobs.js +80 -0
  2050. package/dist/modules/website_form/jobs.js.map +1 -0
  2051. package/dist/modules/website_form/models.d.ts.map +1 -1
  2052. package/dist/modules/website_form/models.js +89 -0
  2053. package/dist/modules/website_form/models.js.map +1 -1
  2054. package/dist/modules/website_form/purge.d.ts +22 -0
  2055. package/dist/modules/website_form/purge.d.ts.map +1 -0
  2056. package/dist/modules/website_form/purge.js +59 -0
  2057. package/dist/modules/website_form/purge.js.map +1 -0
  2058. package/dist/modules/website_form/retention.d.ts +70 -0
  2059. package/dist/modules/website_form/retention.d.ts.map +1 -0
  2060. package/dist/modules/website_form/retention.js +145 -0
  2061. package/dist/modules/website_form/retention.js.map +1 -0
  2062. package/dist/modules/website_form/routes.d.ts.map +1 -1
  2063. package/dist/modules/website_form/routes.js +37 -3
  2064. package/dist/modules/website_form/routes.js.map +1 -1
  2065. package/dist/modules/website_form_mail/index.d.ts +36 -0
  2066. package/dist/modules/website_form_mail/index.d.ts.map +1 -0
  2067. package/dist/modules/website_form_mail/index.js +137 -0
  2068. package/dist/modules/website_form_mail/index.js.map +1 -0
  2069. package/dist/modules/website_hospitality/channel-routes.d.ts +2 -0
  2070. package/dist/modules/website_hospitality/channel-routes.d.ts.map +1 -0
  2071. package/dist/modules/website_hospitality/channel-routes.js +355 -0
  2072. package/dist/modules/website_hospitality/channel-routes.js.map +1 -0
  2073. package/dist/modules/website_hospitality/functions.d.ts.map +1 -1
  2074. package/dist/modules/website_hospitality/functions.js +27 -2
  2075. package/dist/modules/website_hospitality/functions.js.map +1 -1
  2076. package/dist/modules/website_hospitality/index.js +4 -3
  2077. package/dist/modules/website_hospitality/index.js.map +1 -1
  2078. package/dist/modules/website_hospitality/models.d.ts.map +1 -1
  2079. package/dist/modules/website_hospitality/models.js +2 -0
  2080. package/dist/modules/website_hospitality/models.js.map +1 -1
  2081. package/dist/modules/website_menu/functions.d.ts.map +1 -1
  2082. package/dist/modules/website_menu/functions.js +184 -9
  2083. package/dist/modules/website_menu/functions.js.map +1 -1
  2084. package/dist/modules/website_menu/index.js +6 -1
  2085. package/dist/modules/website_menu/index.js.map +1 -1
  2086. package/dist/modules/website_retail/channel-routes.d.ts +2 -0
  2087. package/dist/modules/website_retail/channel-routes.d.ts.map +1 -0
  2088. package/dist/modules/website_retail/channel-routes.js +305 -0
  2089. package/dist/modules/website_retail/channel-routes.js.map +1 -0
  2090. package/dist/modules/website_retail/functions.d.ts +14 -1
  2091. package/dist/modules/website_retail/functions.d.ts.map +1 -1
  2092. package/dist/modules/website_retail/functions.js +6 -6
  2093. package/dist/modules/website_retail/functions.js.map +1 -1
  2094. package/dist/modules/website_retail/index.js +24 -3
  2095. package/dist/modules/website_retail/index.js.map +1 -1
  2096. package/dist/modules/website_retail/models.d.ts.map +1 -1
  2097. package/dist/modules/website_retail/models.js +30 -0
  2098. package/dist/modules/website_retail/models.js.map +1 -1
  2099. package/dist/modules/website_retail/online.d.ts +3 -0
  2100. package/dist/modules/website_retail/online.d.ts.map +1 -0
  2101. package/dist/modules/website_retail/online.js +710 -0
  2102. package/dist/modules/website_retail/online.js.map +1 -0
  2103. package/dist/modules/website_search/client/search.d.mts +16 -2
  2104. package/dist/modules/website_search/client/search.d.mts.map +1 -1
  2105. package/dist/modules/website_search/client/search.mjs +112 -6
  2106. package/dist/modules/website_search/client/search.mjs.map +1 -1
  2107. package/dist/modules/website_search/functions.d.ts +3 -0
  2108. package/dist/modules/website_search/functions.d.ts.map +1 -0
  2109. package/dist/modules/website_search/functions.js +239 -0
  2110. package/dist/modules/website_search/functions.js.map +1 -0
  2111. package/dist/modules/website_search/index.js +4 -1
  2112. package/dist/modules/website_search/index.js.map +1 -1
  2113. package/dist/modules/website_search/islands.d.ts +6 -0
  2114. package/dist/modules/website_search/islands.d.ts.map +1 -1
  2115. package/dist/modules/website_search/islands.js +8 -2
  2116. package/dist/modules/website_search/islands.js.map +1 -1
  2117. package/dist/modules/website_search/models.d.ts +15 -0
  2118. package/dist/modules/website_search/models.d.ts.map +1 -0
  2119. package/dist/modules/website_search/models.js +58 -0
  2120. package/dist/modules/website_search/models.js.map +1 -0
  2121. package/dist/modules/website_seo/functions.d.ts +3 -0
  2122. package/dist/modules/website_seo/functions.d.ts.map +1 -0
  2123. package/dist/modules/website_seo/functions.js +164 -0
  2124. package/dist/modules/website_seo/functions.js.map +1 -0
  2125. package/dist/modules/website_seo/index.js +15 -5
  2126. package/dist/modules/website_seo/index.js.map +1 -1
  2127. package/dist/modules/website_seo/projection.d.ts +52 -0
  2128. package/dist/modules/website_seo/projection.d.ts.map +1 -0
  2129. package/dist/modules/website_seo/projection.js +129 -0
  2130. package/dist/modules/website_seo/projection.js.map +1 -0
  2131. package/dist/modules/website_seo/routes.d.ts +3 -0
  2132. package/dist/modules/website_seo/routes.d.ts.map +1 -0
  2133. package/dist/modules/website_seo/routes.js +56 -0
  2134. package/dist/modules/website_seo/routes.js.map +1 -0
  2135. package/dist/permission-catalogue.d.ts +5 -0
  2136. package/dist/permission-catalogue.d.ts.map +1 -0
  2137. package/dist/permission-catalogue.js +1505 -0
  2138. package/dist/permission-catalogue.js.map +1 -0
  2139. package/dist/scaffold/index.d.ts +2 -0
  2140. package/dist/scaffold/index.d.ts.map +1 -0
  2141. package/dist/scaffold/index.js +31 -0
  2142. package/dist/scaffold/index.js.map +1 -0
  2143. package/dist/scaffold/templates/README.md.tmpl +17 -0
  2144. package/dist/scaffold/templates/gitignore.tmpl +2 -0
  2145. package/dist/scaffold/templates/ket.workspace.mjs.tmpl +1 -0
  2146. package/dist/scaffold/templates/package.json.tmpl +15 -0
  2147. package/dist/themes/hospitality/templates/website.columns.ktl +4 -0
  2148. package/dist/themes/paper/templates/website.columns.ktl +4 -0
  2149. package/dist/ui/actions.d.ts +4 -0
  2150. package/dist/ui/actions.d.ts.map +1 -1
  2151. package/dist/ui/actions.js +1 -1
  2152. package/dist/ui/actions.js.map +1 -1
  2153. package/dist/ui/activity.d.ts +1 -1
  2154. package/dist/ui/activity.d.ts.map +1 -1
  2155. package/dist/ui/activity.js +3 -5
  2156. package/dist/ui/activity.js.map +1 -1
  2157. package/dist/ui/attachments.js +1 -1
  2158. package/dist/ui/attachments.js.map +1 -1
  2159. package/dist/ui/auth.d.ts +36 -0
  2160. package/dist/ui/auth.d.ts.map +1 -1
  2161. package/dist/ui/auth.js +55 -0
  2162. package/dist/ui/auth.js.map +1 -1
  2163. package/dist/ui/board-page.d.ts +6 -0
  2164. package/dist/ui/board-page.d.ts.map +1 -0
  2165. package/dist/ui/board-page.js +4 -0
  2166. package/dist/ui/board-page.js.map +1 -0
  2167. package/dist/ui/charts.d.ts +83 -0
  2168. package/dist/ui/charts.d.ts.map +1 -0
  2169. package/dist/ui/charts.js +105 -0
  2170. package/dist/ui/charts.js.map +1 -0
  2171. package/dist/ui/chrome.d.ts +37 -2
  2172. package/dist/ui/chrome.d.ts.map +1 -1
  2173. package/dist/ui/chrome.js +39 -5
  2174. package/dist/ui/chrome.js.map +1 -1
  2175. package/dist/ui/client/activity-view.mjs +7 -7
  2176. package/dist/ui/client/activity-view.mjs.map +1 -1
  2177. package/dist/ui/client/activity.css +6 -34
  2178. package/dist/ui/client/calendar-view.d.mts.map +1 -1
  2179. package/dist/ui/client/calendar-view.mjs +7 -6
  2180. package/dist/ui/client/calendar-view.mjs.map +1 -1
  2181. package/dist/ui/client/calendar.css +4 -14
  2182. package/dist/ui/client/chart-view.d.ts +51 -0
  2183. package/dist/ui/client/chart-view.d.ts.map +1 -0
  2184. package/dist/ui/client/chart-view.js +192 -0
  2185. package/dist/ui/client/chart-view.js.map +1 -0
  2186. package/dist/ui/client/flow-app.css +387 -0
  2187. package/dist/ui/client/flow-board-view.d.mts +8 -0
  2188. package/dist/ui/client/flow-board-view.d.mts.map +1 -0
  2189. package/dist/ui/client/flow-board-view.mjs +161 -0
  2190. package/dist/ui/client/flow-board-view.mjs.map +1 -0
  2191. package/dist/ui/client/flow-board.d.mts +3 -0
  2192. package/dist/ui/client/flow-board.d.mts.map +1 -0
  2193. package/dist/ui/client/flow-board.mjs +7 -0
  2194. package/dist/ui/client/flow-board.mjs.map +1 -0
  2195. package/dist/ui/client/flow-map-view.d.mts +2 -0
  2196. package/dist/ui/client/flow-map-view.d.mts.map +1 -0
  2197. package/dist/ui/client/flow-map-view.mjs +235 -0
  2198. package/dist/ui/client/flow-map-view.mjs.map +1 -0
  2199. package/dist/ui/client/flow-map.d.mts +3 -0
  2200. package/dist/ui/client/flow-map.d.mts.map +1 -0
  2201. package/dist/ui/client/flow-map.mjs +7 -0
  2202. package/dist/ui/client/flow-map.mjs.map +1 -0
  2203. package/dist/ui/client/live-doc-blocks.d.ts +19 -0
  2204. package/dist/ui/client/live-doc-blocks.d.ts.map +1 -0
  2205. package/dist/ui/client/live-doc-blocks.js +23 -0
  2206. package/dist/ui/client/live-doc-blocks.js.map +1 -0
  2207. package/dist/ui/client/live-doc-markdown.d.ts +18 -0
  2208. package/dist/ui/client/live-doc-markdown.d.ts.map +1 -0
  2209. package/dist/ui/client/live-doc-markdown.js +175 -0
  2210. package/dist/ui/client/live-doc-markdown.js.map +1 -0
  2211. package/dist/ui/client/live-doc-shell.d.ts +101 -0
  2212. package/dist/ui/client/live-doc-shell.d.ts.map +1 -0
  2213. package/dist/ui/client/live-doc-shell.js +251 -0
  2214. package/dist/ui/client/live-doc-shell.js.map +1 -0
  2215. package/dist/ui/client/live-doc-view.d.ts +33 -0
  2216. package/dist/ui/client/live-doc-view.d.ts.map +1 -0
  2217. package/dist/ui/client/live-doc-view.js +1237 -0
  2218. package/dist/ui/client/live-doc-view.js.map +1 -0
  2219. package/dist/ui/client/live-doc.css +243 -0
  2220. package/dist/ui/client/live-doc.d.mts +12 -0
  2221. package/dist/ui/client/live-doc.d.mts.map +1 -0
  2222. package/dist/ui/client/live-doc.mjs +11 -0
  2223. package/dist/ui/client/live-doc.mjs.map +7 -0
  2224. package/dist/ui/client/mail-bundle.d.mts +9 -0
  2225. package/dist/ui/client/mail-bundle.d.mts.map +1 -0
  2226. package/dist/ui/client/mail-bundle.mjs +50 -0
  2227. package/dist/ui/client/mail-bundle.mjs.map +7 -0
  2228. package/dist/ui/client/mail-entry.d.mts +11 -0
  2229. package/dist/ui/client/mail-entry.d.mts.map +1 -0
  2230. package/dist/ui/client/mail-entry.mjs +9 -0
  2231. package/dist/ui/client/mail-entry.mjs.map +1 -0
  2232. package/dist/ui/client/mail-view.d.mts.map +1 -1
  2233. package/dist/ui/client/mail-view.mjs +5 -3
  2234. package/dist/ui/client/mail-view.mjs.map +1 -1
  2235. package/dist/ui/client/mail.css +3 -3
  2236. package/dist/ui/client/relation-select-view.d.ts +77 -0
  2237. package/dist/ui/client/relation-select-view.d.ts.map +1 -0
  2238. package/dist/ui/client/relation-select-view.js +216 -0
  2239. package/dist/ui/client/relation-select-view.js.map +1 -0
  2240. package/dist/ui/client/table-selection-view.d.ts +4 -0
  2241. package/dist/ui/client/table-selection-view.d.ts.map +1 -0
  2242. package/dist/ui/client/table-selection-view.js +283 -0
  2243. package/dist/ui/client/table-selection-view.js.map +1 -0
  2244. package/dist/ui/dashboard-page.d.ts +6 -0
  2245. package/dist/ui/dashboard-page.d.ts.map +1 -0
  2246. package/dist/ui/dashboard-page.js +4 -0
  2247. package/dist/ui/dashboard-page.js.map +1 -0
  2248. package/dist/ui/data.d.ts +51 -1
  2249. package/dist/ui/data.d.ts.map +1 -1
  2250. package/dist/ui/data.js +87 -1
  2251. package/dist/ui/data.js.map +1 -1
  2252. package/dist/ui/date-picker.d.ts.map +1 -1
  2253. package/dist/ui/date-picker.js +2 -2
  2254. package/dist/ui/date-picker.js.map +1 -1
  2255. package/dist/ui/form-page.d.ts +6 -0
  2256. package/dist/ui/form-page.d.ts.map +1 -0
  2257. package/dist/ui/form-page.js +5 -0
  2258. package/dist/ui/form-page.js.map +1 -0
  2259. package/dist/ui/form.d.ts +4 -1
  2260. package/dist/ui/form.d.ts.map +1 -1
  2261. package/dist/ui/form.js +7 -5
  2262. package/dist/ui/form.js.map +1 -1
  2263. package/dist/ui/format.d.ts +13 -2
  2264. package/dist/ui/format.d.ts.map +1 -1
  2265. package/dist/ui/format.js +28 -7
  2266. package/dist/ui/format.js.map +1 -1
  2267. package/dist/ui/gantt.d.ts +52 -0
  2268. package/dist/ui/gantt.d.ts.map +1 -0
  2269. package/dist/ui/gantt.js +92 -0
  2270. package/dist/ui/gantt.js.map +1 -0
  2271. package/dist/ui/hooks.d.ts.map +1 -1
  2272. package/dist/ui/hooks.js +14 -0
  2273. package/dist/ui/hooks.js.map +1 -1
  2274. package/dist/ui/icons.d.ts.map +1 -1
  2275. package/dist/ui/icons.js +6 -1
  2276. package/dist/ui/icons.js.map +1 -1
  2277. package/dist/ui/index.d.ts +95 -14
  2278. package/dist/ui/index.d.ts.map +1 -1
  2279. package/dist/ui/index.js +78 -13
  2280. package/dist/ui/index.js.map +1 -1
  2281. package/dist/ui/layout.d.ts +43 -38
  2282. package/dist/ui/layout.d.ts.map +1 -1
  2283. package/dist/ui/layout.js +29 -37
  2284. package/dist/ui/layout.js.map +1 -1
  2285. package/dist/ui/list-page.d.ts +19 -0
  2286. package/dist/ui/list-page.d.ts.map +1 -0
  2287. package/dist/ui/list-page.js +21 -0
  2288. package/dist/ui/list-page.js.map +1 -0
  2289. package/dist/ui/media.d.ts +2 -0
  2290. package/dist/ui/media.d.ts.map +1 -1
  2291. package/dist/ui/media.js +1 -1
  2292. package/dist/ui/media.js.map +1 -1
  2293. package/dist/ui/modal.d.ts +26 -1
  2294. package/dist/ui/modal.d.ts.map +1 -1
  2295. package/dist/ui/modal.js +18 -2
  2296. package/dist/ui/modal.js.map +1 -1
  2297. package/dist/ui/nav.d.ts +21 -1
  2298. package/dist/ui/nav.d.ts.map +1 -1
  2299. package/dist/ui/nav.js +43 -8
  2300. package/dist/ui/nav.js.map +1 -1
  2301. package/dist/ui/navigation.d.ts +36 -2
  2302. package/dist/ui/navigation.d.ts.map +1 -1
  2303. package/dist/ui/navigation.js +60 -5
  2304. package/dist/ui/navigation.js.map +1 -1
  2305. package/dist/ui/partner.d.ts +18 -0
  2306. package/dist/ui/partner.d.ts.map +1 -0
  2307. package/dist/ui/partner.js +11 -0
  2308. package/dist/ui/partner.js.map +1 -0
  2309. package/dist/ui/primitives.d.ts +28 -10
  2310. package/dist/ui/primitives.d.ts.map +1 -1
  2311. package/dist/ui/primitives.js +21 -7
  2312. package/dist/ui/primitives.js.map +1 -1
  2313. package/dist/ui/product-media.d.ts +47 -0
  2314. package/dist/ui/product-media.d.ts.map +1 -0
  2315. package/dist/ui/product-media.js +67 -0
  2316. package/dist/ui/product-media.js.map +1 -0
  2317. package/dist/ui/product-variants.d.ts +68 -0
  2318. package/dist/ui/product-variants.d.ts.map +1 -0
  2319. package/dist/ui/product-variants.js +81 -0
  2320. package/dist/ui/product-variants.js.map +1 -0
  2321. package/dist/ui/record-detail.d.ts +70 -0
  2322. package/dist/ui/record-detail.d.ts.map +1 -0
  2323. package/dist/ui/record-detail.js +35 -0
  2324. package/dist/ui/record-detail.js.map +1 -0
  2325. package/dist/ui/record-page.d.ts +16 -0
  2326. package/dist/ui/record-page.d.ts.map +1 -0
  2327. package/dist/ui/record-page.js +13 -0
  2328. package/dist/ui/record-page.js.map +1 -0
  2329. package/dist/ui/record.d.ts +15 -3
  2330. package/dist/ui/record.d.ts.map +1 -1
  2331. package/dist/ui/record.js +6 -5
  2332. package/dist/ui/record.js.map +1 -1
  2333. package/dist/ui/surfaces.d.ts +30 -2
  2334. package/dist/ui/surfaces.d.ts.map +1 -1
  2335. package/dist/ui/surfaces.js +39 -2
  2336. package/dist/ui/surfaces.js.map +1 -1
  2337. package/dist/ui/table.d.ts +25 -2
  2338. package/dist/ui/table.d.ts.map +1 -1
  2339. package/dist/ui/table.js +10 -6
  2340. package/dist/ui/table.js.map +1 -1
  2341. package/dist/ui/timeframe.d.ts +39 -0
  2342. package/dist/ui/timeframe.d.ts.map +1 -0
  2343. package/dist/ui/timeframe.js +36 -0
  2344. package/dist/ui/timeframe.js.map +1 -0
  2345. package/dist/ui/workspace-page.d.ts +16 -0
  2346. package/dist/ui/workspace-page.d.ts.map +1 -0
  2347. package/dist/ui/workspace-page.js +15 -0
  2348. package/dist/ui/workspace-page.js.map +1 -0
  2349. package/package.json +16 -3
  2350. package/dist/modules/account/tt99.d.ts +0 -30
  2351. package/dist/modules/account/tt99.d.ts.map +0 -1
  2352. package/dist/modules/account/tt99.js +0 -1661
  2353. package/dist/modules/account/tt99.js.map +0 -1
  2354. package/dist/modules/account_backend/accounting-overview-screen.d.ts +0 -18
  2355. package/dist/modules/account_backend/accounting-overview-screen.d.ts.map +0 -1
  2356. package/dist/modules/account_backend/accounting-overview-screen.js +0 -104
  2357. package/dist/modules/account_backend/accounting-overview-screen.js.map +0 -1
  2358. package/dist/modules/account_backend/accounts-screen.d.ts +0 -13
  2359. package/dist/modules/account_backend/accounts-screen.d.ts.map +0 -1
  2360. package/dist/modules/account_backend/accounts-screen.js +0 -49
  2361. package/dist/modules/account_backend/accounts-screen.js.map +0 -1
  2362. package/dist/modules/account_backend/customer-invoices-screen.d.ts +0 -14
  2363. package/dist/modules/account_backend/customer-invoices-screen.d.ts.map +0 -1
  2364. package/dist/modules/account_backend/customer-invoices-screen.js +0 -63
  2365. package/dist/modules/account_backend/customer-invoices-screen.js.map +0 -1
  2366. package/dist/modules/account_backend/general-ledger-screen.d.ts +0 -13
  2367. package/dist/modules/account_backend/general-ledger-screen.d.ts.map +0 -1
  2368. package/dist/modules/account_backend/general-ledger-screen.js +0 -56
  2369. package/dist/modules/account_backend/general-ledger-screen.js.map +0 -1
  2370. package/dist/modules/account_backend/journal-entries-screen.d.ts +0 -14
  2371. package/dist/modules/account_backend/journal-entries-screen.d.ts.map +0 -1
  2372. package/dist/modules/account_backend/journal-entries-screen.js +0 -45
  2373. package/dist/modules/account_backend/journal-entries-screen.js.map +0 -1
  2374. package/dist/modules/account_backend/journals-screen.d.ts +0 -14
  2375. package/dist/modules/account_backend/journals-screen.d.ts.map +0 -1
  2376. package/dist/modules/account_backend/journals-screen.js +0 -53
  2377. package/dist/modules/account_backend/journals-screen.js.map +0 -1
  2378. package/dist/modules/account_backend/move-detail-screen.d.ts +0 -10
  2379. package/dist/modules/account_backend/move-detail-screen.d.ts.map +0 -1
  2380. package/dist/modules/account_backend/move-detail-screen.js +0 -100
  2381. package/dist/modules/account_backend/move-detail-screen.js.map +0 -1
  2382. package/dist/modules/account_backend/partner-ledger-screen.d.ts +0 -14
  2383. package/dist/modules/account_backend/partner-ledger-screen.d.ts.map +0 -1
  2384. package/dist/modules/account_backend/partner-ledger-screen.js +0 -69
  2385. package/dist/modules/account_backend/partner-ledger-screen.js.map +0 -1
  2386. package/dist/modules/account_backend/payment-terms-screen.d.ts +0 -14
  2387. package/dist/modules/account_backend/payment-terms-screen.d.ts.map +0 -1
  2388. package/dist/modules/account_backend/payment-terms-screen.js +0 -40
  2389. package/dist/modules/account_backend/payment-terms-screen.js.map +0 -1
  2390. package/dist/modules/account_backend/payments-screen.d.ts +0 -14
  2391. package/dist/modules/account_backend/payments-screen.d.ts.map +0 -1
  2392. package/dist/modules/account_backend/payments-screen.js +0 -54
  2393. package/dist/modules/account_backend/payments-screen.js.map +0 -1
  2394. package/dist/modules/account_backend/screens.d.ts +0 -7
  2395. package/dist/modules/account_backend/screens.d.ts.map +0 -1
  2396. package/dist/modules/account_backend/screens.js +0 -7
  2397. package/dist/modules/account_backend/screens.js.map +0 -1
  2398. package/dist/modules/account_backend/taxes-screen.d.ts +0 -15
  2399. package/dist/modules/account_backend/taxes-screen.d.ts.map +0 -1
  2400. package/dist/modules/account_backend/taxes-screen.js +0 -73
  2401. package/dist/modules/account_backend/taxes-screen.js.map +0 -1
  2402. package/dist/modules/account_backend/trial-balance-screen.d.ts +0 -13
  2403. package/dist/modules/account_backend/trial-balance-screen.d.ts.map +0 -1
  2404. package/dist/modules/account_backend/trial-balance-screen.js +0 -62
  2405. package/dist/modules/account_backend/trial-balance-screen.js.map +0 -1
  2406. package/dist/modules/account_backend/vendor-bills-screen.d.ts +0 -14
  2407. package/dist/modules/account_backend/vendor-bills-screen.d.ts.map +0 -1
  2408. package/dist/modules/account_backend/vendor-bills-screen.js +0 -59
  2409. package/dist/modules/account_backend/vendor-bills-screen.js.map +0 -1
  2410. package/dist/modules/account_partner_backend/screens.d.ts +0 -16
  2411. package/dist/modules/account_partner_backend/screens.d.ts.map +0 -1
  2412. package/dist/modules/account_partner_backend/screens.js +0 -26
  2413. package/dist/modules/account_partner_backend/screens.js.map +0 -1
  2414. package/dist/modules/activity_backend/screens.d.ts +0 -5
  2415. package/dist/modules/activity_backend/screens.d.ts.map +0 -1
  2416. package/dist/modules/activity_backend/screens.js +0 -52
  2417. package/dist/modules/activity_backend/screens.js.map +0 -1
  2418. package/dist/modules/address_backend/screens.d.ts +0 -31
  2419. package/dist/modules/address_backend/screens.d.ts.map +0 -1
  2420. package/dist/modules/address_backend/screens.js +0 -147
  2421. package/dist/modules/address_backend/screens.js.map +0 -1
  2422. package/dist/modules/backend/design/admin.css +0 -4229
  2423. package/dist/modules/backend/design/client/relation-select-view.d.mts +0 -5
  2424. package/dist/modules/backend/design/client/relation-select-view.d.mts.map +0 -1
  2425. package/dist/modules/backend/design/client/relation-select-view.mjs +0 -335
  2426. package/dist/modules/backend/design/client/relation-select-view.mjs.map +0 -1
  2427. package/dist/modules/calendar_backend/screens.d.ts +0 -5
  2428. package/dist/modules/calendar_backend/screens.d.ts.map +0 -1
  2429. package/dist/modules/calendar_backend/screens.js +0 -4
  2430. package/dist/modules/calendar_backend/screens.js.map +0 -1
  2431. package/dist/modules/company_backend/screens.d.ts +0 -62
  2432. package/dist/modules/company_backend/screens.d.ts.map +0 -1
  2433. package/dist/modules/company_backend/screens.js +0 -268
  2434. package/dist/modules/company_backend/screens.js.map +0 -1
  2435. package/dist/modules/crm_backend/list-search.d.ts +0 -21
  2436. package/dist/modules/crm_backend/list-search.d.ts.map +0 -1
  2437. package/dist/modules/crm_backend/list-search.js +0 -220
  2438. package/dist/modules/crm_backend/list-search.js.map +0 -1
  2439. package/dist/modules/crm_backend/screens.d.ts +0 -32
  2440. package/dist/modules/crm_backend/screens.d.ts.map +0 -1
  2441. package/dist/modules/crm_backend/screens.js +0 -405
  2442. package/dist/modules/crm_backend/screens.js.map +0 -1
  2443. package/dist/modules/hospitality_core/screens.d.ts +0 -763
  2444. package/dist/modules/hospitality_core/screens.d.ts.map +0 -1
  2445. package/dist/modules/hospitality_core/screens.js +0 -4138
  2446. package/dist/modules/hospitality_core/screens.js.map +0 -1
  2447. package/dist/modules/hr_backend/screens.d.ts +0 -9
  2448. package/dist/modules/hr_backend/screens.d.ts.map +0 -1
  2449. package/dist/modules/hr_backend/screens.js +0 -144
  2450. package/dist/modules/hr_backend/screens.js.map +0 -1
  2451. package/dist/modules/loyalty_backend/screens.d.ts +0 -33
  2452. package/dist/modules/loyalty_backend/screens.d.ts.map +0 -1
  2453. package/dist/modules/loyalty_backend/screens.js +0 -562
  2454. package/dist/modules/loyalty_backend/screens.js.map +0 -1
  2455. package/dist/modules/mail_backend/screens.d.ts +0 -5
  2456. package/dist/modules/mail_backend/screens.d.ts.map +0 -1
  2457. package/dist/modules/mail_backend/screens.js +0 -11
  2458. package/dist/modules/mail_backend/screens.js.map +0 -1
  2459. package/dist/modules/mail_inbound_backend/screens.d.ts +0 -5
  2460. package/dist/modules/mail_inbound_backend/screens.d.ts.map +0 -1
  2461. package/dist/modules/mail_inbound_backend/screens.js +0 -25
  2462. package/dist/modules/mail_inbound_backend/screens.js.map +0 -1
  2463. package/dist/modules/mail_transport_backend/screens.d.ts +0 -5
  2464. package/dist/modules/mail_transport_backend/screens.d.ts.map +0 -1
  2465. package/dist/modules/mail_transport_backend/screens.js +0 -35
  2466. package/dist/modules/mail_transport_backend/screens.js.map +0 -1
  2467. package/dist/modules/oauth_backend/screens.d.ts +0 -66
  2468. package/dist/modules/oauth_backend/screens.d.ts.map +0 -1
  2469. package/dist/modules/oauth_backend/screens.js +0 -323
  2470. package/dist/modules/oauth_backend/screens.js.map +0 -1
  2471. package/dist/modules/odoo_collaboration_import/functions.d.ts.map +0 -1
  2472. package/dist/modules/odoo_collaboration_import/functions.js +0 -128
  2473. package/dist/modules/odoo_collaboration_import/functions.js.map +0 -1
  2474. package/dist/modules/odoo_collaboration_import/index.d.ts +0 -6
  2475. package/dist/modules/odoo_collaboration_import/index.d.ts.map +0 -1
  2476. package/dist/modules/odoo_collaboration_import/index.js +0 -31
  2477. package/dist/modules/odoo_collaboration_import/index.js.map +0 -1
  2478. package/dist/modules/odoo_collaboration_import/models.d.ts.map +0 -1
  2479. package/dist/modules/odoo_collaboration_import/models.js +0 -76
  2480. package/dist/modules/odoo_collaboration_import/models.js.map +0 -1
  2481. package/dist/modules/odoo_collaboration_import/operations.d.ts +0 -14
  2482. package/dist/modules/odoo_collaboration_import/operations.d.ts.map +0 -1
  2483. package/dist/modules/odoo_collaboration_import/operations.js +0 -1139
  2484. package/dist/modules/odoo_collaboration_import/operations.js.map +0 -1
  2485. package/dist/modules/odoo_collaboration_import/relations.d.ts.map +0 -1
  2486. package/dist/modules/odoo_collaboration_import/relations.js +0 -19
  2487. package/dist/modules/odoo_collaboration_import/relations.js.map +0 -1
  2488. package/dist/modules/odoo_collaboration_import/types.d.ts +0 -58
  2489. package/dist/modules/odoo_collaboration_import/types.d.ts.map +0 -1
  2490. package/dist/modules/odoo_collaboration_import/types.js.map +0 -1
  2491. package/dist/modules/partner_backend/screens.d.ts +0 -53
  2492. package/dist/modules/partner_backend/screens.d.ts.map +0 -1
  2493. package/dist/modules/partner_backend/screens.js +0 -169
  2494. package/dist/modules/partner_backend/screens.js.map +0 -1
  2495. package/dist/modules/pricing_backend/screens.d.ts +0 -13
  2496. package/dist/modules/pricing_backend/screens.d.ts.map +0 -1
  2497. package/dist/modules/pricing_backend/screens.js +0 -182
  2498. package/dist/modules/pricing_backend/screens.js.map +0 -1
  2499. package/dist/modules/product_backend/attributes-screen.d.ts +0 -7
  2500. package/dist/modules/product_backend/attributes-screen.d.ts.map +0 -1
  2501. package/dist/modules/product_backend/attributes-screen.js +0 -76
  2502. package/dist/modules/product_backend/attributes-screen.js.map +0 -1
  2503. package/dist/modules/product_backend/create-screen.d.ts +0 -12
  2504. package/dist/modules/product_backend/create-screen.d.ts.map +0 -1
  2505. package/dist/modules/product_backend/create-screen.js +0 -83
  2506. package/dist/modules/product_backend/create-screen.js.map +0 -1
  2507. package/dist/modules/product_backend/screens.d.ts +0 -68
  2508. package/dist/modules/product_backend/screens.d.ts.map +0 -1
  2509. package/dist/modules/product_backend/screens.js +0 -388
  2510. package/dist/modules/product_backend/screens.js.map +0 -1
  2511. package/dist/modules/purchase_backend/screens.d.ts +0 -29
  2512. package/dist/modules/purchase_backend/screens.d.ts.map +0 -1
  2513. package/dist/modules/purchase_backend/screens.js +0 -324
  2514. package/dist/modules/purchase_backend/screens.js.map +0 -1
  2515. package/dist/modules/sale_backend/invoicing-policies-screen.d.ts +0 -14
  2516. package/dist/modules/sale_backend/invoicing-policies-screen.d.ts.map +0 -1
  2517. package/dist/modules/sale_backend/invoicing-policies-screen.js +0 -36
  2518. package/dist/modules/sale_backend/invoicing-policies-screen.js.map +0 -1
  2519. package/dist/modules/sale_backend/order-detail-screen.d.ts +0 -18
  2520. package/dist/modules/sale_backend/order-detail-screen.d.ts.map +0 -1
  2521. package/dist/modules/sale_backend/order-detail-screen.js +0 -217
  2522. package/dist/modules/sale_backend/order-detail-screen.js.map +0 -1
  2523. package/dist/modules/sale_backend/quotations-screen.d.ts +0 -15
  2524. package/dist/modules/sale_backend/quotations-screen.d.ts.map +0 -1
  2525. package/dist/modules/sale_backend/quotations-screen.js +0 -64
  2526. package/dist/modules/sale_backend/quotations-screen.js.map +0 -1
  2527. package/dist/modules/sale_backend/sales-orders-screen.d.ts +0 -12
  2528. package/dist/modules/sale_backend/sales-orders-screen.d.ts.map +0 -1
  2529. package/dist/modules/sale_backend/sales-orders-screen.js +0 -65
  2530. package/dist/modules/sale_backend/sales-orders-screen.js.map +0 -1
  2531. package/dist/modules/sale_backend/screens.d.ts +0 -23
  2532. package/dist/modules/sale_backend/screens.d.ts.map +0 -1
  2533. package/dist/modules/sale_backend/screens.js +0 -275
  2534. package/dist/modules/sale_backend/screens.js.map +0 -1
  2535. package/dist/modules/stock_backend/forecast-screen.d.ts +0 -28
  2536. package/dist/modules/stock_backend/forecast-screen.d.ts.map +0 -1
  2537. package/dist/modules/stock_backend/forecast-screen.js +0 -108
  2538. package/dist/modules/stock_backend/forecast-screen.js.map +0 -1
  2539. package/dist/modules/stock_backend/inventory-screen.d.ts +0 -27
  2540. package/dist/modules/stock_backend/inventory-screen.d.ts.map +0 -1
  2541. package/dist/modules/stock_backend/inventory-screen.js +0 -141
  2542. package/dist/modules/stock_backend/inventory-screen.js.map +0 -1
  2543. package/dist/modules/stock_backend/locations-screen.d.ts +0 -18
  2544. package/dist/modules/stock_backend/locations-screen.d.ts.map +0 -1
  2545. package/dist/modules/stock_backend/locations-screen.js +0 -92
  2546. package/dist/modules/stock_backend/locations-screen.js.map +0 -1
  2547. package/dist/modules/stock_backend/lot-screen.d.ts +0 -30
  2548. package/dist/modules/stock_backend/lot-screen.d.ts.map +0 -1
  2549. package/dist/modules/stock_backend/lot-screen.js +0 -86
  2550. package/dist/modules/stock_backend/lot-screen.js.map +0 -1
  2551. package/dist/modules/stock_backend/lots-screen.d.ts +0 -21
  2552. package/dist/modules/stock_backend/lots-screen.d.ts.map +0 -1
  2553. package/dist/modules/stock_backend/lots-screen.js +0 -79
  2554. package/dist/modules/stock_backend/lots-screen.js.map +0 -1
  2555. package/dist/modules/stock_backend/picking-types-screen.d.ts +0 -21
  2556. package/dist/modules/stock_backend/picking-types-screen.d.ts.map +0 -1
  2557. package/dist/modules/stock_backend/picking-types-screen.js +0 -110
  2558. package/dist/modules/stock_backend/picking-types-screen.js.map +0 -1
  2559. package/dist/modules/stock_backend/replenishment-screen.d.ts +0 -29
  2560. package/dist/modules/stock_backend/replenishment-screen.d.ts.map +0 -1
  2561. package/dist/modules/stock_backend/replenishment-screen.js +0 -131
  2562. package/dist/modules/stock_backend/replenishment-screen.js.map +0 -1
  2563. package/dist/modules/stock_backend/screens.d.ts +0 -14
  2564. package/dist/modules/stock_backend/screens.d.ts.map +0 -1
  2565. package/dist/modules/stock_backend/screens.js +0 -40
  2566. package/dist/modules/stock_backend/screens.js.map +0 -1
  2567. package/dist/modules/stock_backend/stock-route-screen.d.ts +0 -30
  2568. package/dist/modules/stock_backend/stock-route-screen.d.ts.map +0 -1
  2569. package/dist/modules/stock_backend/stock-route-screen.js +0 -129
  2570. package/dist/modules/stock_backend/stock-route-screen.js.map +0 -1
  2571. package/dist/modules/stock_backend/stock-routes-screen.d.ts +0 -17
  2572. package/dist/modules/stock_backend/stock-routes-screen.d.ts.map +0 -1
  2573. package/dist/modules/stock_backend/stock-routes-screen.js +0 -60
  2574. package/dist/modules/stock_backend/stock-routes-screen.js.map +0 -1
  2575. package/dist/modules/stock_backend/transfer-screen.d.ts +0 -26
  2576. package/dist/modules/stock_backend/transfer-screen.d.ts.map +0 -1
  2577. package/dist/modules/stock_backend/transfer-screen.js +0 -95
  2578. package/dist/modules/stock_backend/transfer-screen.js.map +0 -1
  2579. package/dist/modules/stock_backend/transfers-screen.d.ts +0 -21
  2580. package/dist/modules/stock_backend/transfers-screen.d.ts.map +0 -1
  2581. package/dist/modules/stock_backend/transfers-screen.js +0 -88
  2582. package/dist/modules/stock_backend/transfers-screen.js.map +0 -1
  2583. package/dist/modules/stock_backend/warehouses-screen.d.ts +0 -17
  2584. package/dist/modules/stock_backend/warehouses-screen.d.ts.map +0 -1
  2585. package/dist/modules/stock_backend/warehouses-screen.js +0 -96
  2586. package/dist/modules/stock_backend/warehouses-screen.js.map +0 -1
  2587. package/dist/modules/user_backend/screens.d.ts +0 -70
  2588. package/dist/modules/user_backend/screens.d.ts.map +0 -1
  2589. package/dist/modules/user_backend/screens.js +0 -308
  2590. package/dist/modules/user_backend/screens.js.map +0 -1
  2591. package/dist/modules/website/customer-routes.d.ts +0 -3
  2592. package/dist/modules/website/customer-routes.d.ts.map +0 -1
  2593. package/dist/modules/website/customer-routes.js +0 -322
  2594. package/dist/modules/website/customer-routes.js.map +0 -1
  2595. package/dist/modules/website_backend/screens.d.ts +0 -114
  2596. package/dist/modules/website_backend/screens.d.ts.map +0 -1
  2597. package/dist/modules/website_backend/screens.js +0 -625
  2598. package/dist/modules/website_backend/screens.js.map +0 -1
  2599. package/dist/ui/client/mail.d.mts +0 -11
  2600. package/dist/ui/client/mail.d.mts.map +0 -1
  2601. package/dist/ui/client/mail.mjs +0 -10
  2602. package/dist/ui/client/mail.mjs.map +0 -1
  2603. /package/dist/modules/{odoo_collaboration_import → account_staff_channel}/functions.d.ts +0 -0
  2604. /package/dist/modules/{odoo_collaboration_import → account_staff_channel}/models.d.ts +0 -0
  2605. /package/dist/modules/{odoo_collaboration_import → address_backend/screens}/types.js +0 -0
  2606. /package/dist/modules/{odoo_collaboration_import → manufacturing}/relations.d.ts +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../node_modules/lib0/map.js", "../../../../../node_modules/lib0/set.js", "../../../../../node_modules/lib0/array.js", "../../../../../node_modules/lib0/observable.js", "../../../../../node_modules/lib0/math.js", "../../../../../node_modules/lib0/number.js", "../../../../../node_modules/lib0/string.js", "../../../../../node_modules/lib0/encoding.js", "../../../../../node_modules/lib0/error.js", "../../../../../node_modules/lib0/decoding.js", "../../../../../node_modules/lib0/webcrypto.js", "../../../../../node_modules/lib0/random.js", "../../../../../node_modules/lib0/time.js", "../../../../../node_modules/lib0/promise.js", "../../../../../node_modules/lib0/conditions.js", "../../../../../node_modules/lib0/storage.js", "../../../../../node_modules/lib0/trait/equality.js", "../../../../../node_modules/lib0/object.js", "../../../../../node_modules/lib0/function.js", "../../../../../node_modules/lib0/environment.js", "../../../../../node_modules/lib0/buffer.js", "../../../../../node_modules/lib0/pair.js", "../../../../../node_modules/lib0/prng.js", "../../../../../node_modules/lib0/schema.js", "../../../../../node_modules/lib0/dom.js", "../../../../../node_modules/lib0/symbol.js", "../../../../../node_modules/lib0/logging.common.js", "../../../../../node_modules/lib0/logging.js", "../../../../../node_modules/lib0/iterator.js", "../../../../../node_modules/yjs/src/utils/AbstractConnector.js", "../../../../../node_modules/yjs/src/utils/DeleteSet.js", "../../../../../node_modules/yjs/src/utils/Doc.js", "../../../../../node_modules/yjs/src/utils/UpdateDecoder.js", "../../../../../node_modules/yjs/src/utils/UpdateEncoder.js", "../../../../../node_modules/yjs/src/utils/encoding.js", "../../../../../node_modules/yjs/src/utils/EventHandler.js", "../../../../../node_modules/yjs/src/utils/ID.js", "../../../../../node_modules/yjs/src/utils/isParentOf.js", "../../../../../node_modules/yjs/src/utils/logging.js", "../../../../../node_modules/yjs/src/utils/PermanentUserData.js", "../../../../../node_modules/yjs/src/utils/RelativePosition.js", "../../../../../node_modules/yjs/src/utils/Snapshot.js", "../../../../../node_modules/yjs/src/utils/StructStore.js", "../../../../../node_modules/yjs/src/utils/Transaction.js", "../../../../../node_modules/yjs/src/utils/UndoManager.js", "../../../../../node_modules/yjs/src/utils/updates.js", "../../../../../node_modules/yjs/src/utils/YEvent.js", "../../../../../node_modules/yjs/src/types/AbstractType.js", "../../../../../node_modules/yjs/src/types/YArray.js", "../../../../../node_modules/yjs/src/types/YMap.js", "../../../../../node_modules/yjs/src/types/YText.js", "../../../../../node_modules/yjs/src/types/YXmlFragment.js", "../../../../../node_modules/yjs/src/types/YXmlElement.js", "../../../../../node_modules/yjs/src/types/YXmlEvent.js", "../../../../../node_modules/yjs/src/types/YXmlHook.js", "../../../../../node_modules/yjs/src/types/YXmlText.js", "../../../../../node_modules/yjs/src/structs/AbstractStruct.js", "../../../../../node_modules/yjs/src/structs/GC.js", "../../../../../node_modules/yjs/src/structs/ContentBinary.js", "../../../../../node_modules/yjs/src/structs/ContentDeleted.js", "../../../../../node_modules/yjs/src/structs/ContentDoc.js", "../../../../../node_modules/yjs/src/structs/ContentEmbed.js", "../../../../../node_modules/yjs/src/structs/ContentFormat.js", "../../../../../node_modules/yjs/src/structs/ContentJSON.js", "../../../../../node_modules/yjs/src/structs/ContentAny.js", "../../../../../node_modules/yjs/src/structs/ContentString.js", "../../../../../node_modules/yjs/src/structs/ContentType.js", "../../../../../node_modules/yjs/src/structs/Item.js", "../../../../../node_modules/yjs/src/structs/Skip.js", "../../../../../node_modules/yjs/src/index.js", "live-doc-shell.tsx", "live-doc-blocks.ts", "live-doc-markdown.ts", "live-doc-view.tsx"],
4
+ "sourcesContent": ["/**\n * Utility module to work with key-value stores.\n *\n * @module map\n */\n\n/**\n * @template K\n * @template V\n * @typedef {Map<K,V>} GlobalMap\n */\n\n/**\n * Creates a new Map instance.\n *\n * @function\n * @return {Map<any, any>}\n *\n * @function\n */\nexport const create = () => new Map()\n\n/**\n * Copy a Map object into a fresh Map object.\n *\n * @function\n * @template K,V\n * @param {Map<K,V>} m\n * @return {Map<K,V>}\n */\nexport const copy = m => {\n const r = create()\n m.forEach((v, k) => { r.set(k, v) })\n return r\n}\n\n/**\n * Get map property. Create T if property is undefined and set T on map.\n *\n * ```js\n * const listeners = map.setIfUndefined(events, 'eventName', set.create)\n * listeners.add(listener)\n * ```\n *\n * @function\n * @template {Map<any, any>} MAP\n * @template {MAP extends Map<any,infer V> ? function():V : unknown} CF\n * @param {MAP} map\n * @param {MAP extends Map<infer K,any> ? K : unknown} key\n * @param {CF} createT\n * @return {ReturnType<CF>}\n */\nexport const setIfUndefined = (map, key, createT) => {\n let set = map.get(key)\n if (set === undefined) {\n map.set(key, set = createT())\n }\n return set\n}\n\n/**\n * Creates an Array and populates it with the content of all key-value pairs using the `f(value, key)` function.\n *\n * @function\n * @template K\n * @template V\n * @template R\n * @param {Map<K,V>} m\n * @param {function(V,K):R} f\n * @return {Array<R>}\n */\nexport const map = (m, f) => {\n const res = []\n for (const [key, value] of m) {\n res.push(f(value, key))\n }\n return res\n}\n\n/**\n * Tests whether any key-value pairs pass the test implemented by `f(value, key)`.\n *\n * @todo should rename to some - similarly to Array.some\n *\n * @function\n * @template K\n * @template V\n * @param {Map<K,V>} m\n * @param {function(V,K):boolean} f\n * @return {boolean}\n */\nexport const any = (m, f) => {\n for (const [key, value] of m) {\n if (f(value, key)) {\n return true\n }\n }\n return false\n}\n\n/**\n * Tests whether all key-value pairs pass the test implemented by `f(value, key)`.\n *\n * @function\n * @template K\n * @template V\n * @param {Map<K,V>} m\n * @param {function(V,K):boolean} f\n * @return {boolean}\n */\nexport const all = (m, f) => {\n for (const [key, value] of m) {\n if (!f(value, key)) {\n return false\n }\n }\n return true\n}\n", "/**\n * Utility module to work with sets.\n *\n * @module set\n */\n\nexport const create = () => new Set()\n\n/**\n * @template T\n * @param {Set<T>} set\n * @return {Array<T>}\n */\nexport const toArray = set => Array.from(set)\n\n/**\n * @template T\n * @param {Set<T>} set\n * @return {T|undefined}\n */\nexport const first = set => set.values().next().value\n\n/**\n * @template T\n * @param {Iterable<T>} entries\n * @return {Set<T>}\n */\nexport const from = entries => new Set(entries)\n", "/**\n * Utility module to work with Arrays.\n *\n * @module array\n */\n\nimport * as set from './set.js'\n\n/**\n * Return the last element of an array. The element must exist\n *\n * @template L\n * @param {ArrayLike<L>} arr\n * @return {L}\n */\nexport const last = arr => arr[arr.length - 1]\n\n/**\n * @template C\n * @return {Array<C>}\n */\nexport const create = () => /** @type {Array<C>} */ ([])\n\n/**\n * @template D\n * @param {Array<D>} a\n * @return {Array<D>}\n */\nexport const copy = a => /** @type {Array<D>} */ (a.slice())\n\n/**\n * Append elements from src to dest\n *\n * @template M\n * @param {Array<M>} dest\n * @param {Array<M>} src\n */\nexport const appendTo = (dest, src) => {\n for (let i = 0; i < src.length; i++) {\n dest.push(src[i])\n }\n}\n\n/**\n * Transforms something array-like to an actual Array.\n *\n * @function\n * @template T\n * @param {ArrayLike<T>|Iterable<T>} arraylike\n * @return {T}\n */\nexport const from = Array.from\n\n/**\n * True iff condition holds on every element in the Array.\n *\n * @function\n * @template {ArrayLike<any>} ARR\n *\n * @param {ARR} arr\n * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : any} f\n * @return {boolean}\n */\nexport const every = (arr, f) => {\n for (let i = 0; i < arr.length; i++) {\n if (!f(arr[i], i, arr)) {\n return false\n }\n }\n return true\n}\n\n/**\n * True iff condition holds on some element in the Array.\n *\n * @function\n * @template {ArrayLike<any>} ARR\n *\n * @param {ARR} arr\n * @param {ARR extends ArrayLike<infer S> ? ((value:S, index:number, arr:ARR) => boolean) : never} f\n * @return {boolean}\n */\nexport const some = (arr, f) => {\n for (let i = 0; i < arr.length; i++) {\n if (f(arr[i], i, arr)) {\n return true\n }\n }\n return false\n}\n\n/**\n * @template ELEM\n *\n * @param {ArrayLike<ELEM>} a\n * @param {ArrayLike<ELEM>} b\n * @return {boolean}\n */\nexport const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index])\n\n/**\n * @template ELEM\n * @param {Array<Array<ELEM>>} arr\n * @return {Array<ELEM>}\n */\nexport const flatten = arr => fold(arr, /** @type {Array<ELEM>} */ ([]), (acc, val) => acc.concat(val))\n\n/**\n * @template T\n * @param {number} len\n * @param {function(number, Array<T>):T} f\n * @return {Array<T>}\n */\nexport const unfold = (len, f) => {\n const array = new Array(len)\n for (let i = 0; i < len; i++) {\n array[i] = f(i, array)\n }\n return array\n}\n\n/**\n * @template T\n * @template RESULT\n * @param {Array<T>} arr\n * @param {RESULT} seed\n * @param {function(RESULT, T, number):RESULT} folder\n */\nexport const fold = (arr, seed, folder) => arr.reduce(folder, seed)\n\nexport const isArray = Array.isArray\n\n/**\n * @template T\n * @param {Array<T>} arr\n * @return {Array<T>}\n */\nexport const unique = arr => from(set.from(arr))\n\n/**\n * @template T\n * @template M\n * @param {ArrayLike<T>} arr\n * @param {function(T):M} mapper\n * @return {Array<T>}\n */\nexport const uniqueBy = (arr, mapper) => {\n /**\n * @type {Set<M>}\n */\n const happened = set.create()\n /**\n * @type {Array<T>}\n */\n const result = []\n for (let i = 0; i < arr.length; i++) {\n const el = arr[i]\n const mapped = mapper(el)\n if (!happened.has(mapped)) {\n happened.add(mapped)\n result.push(el)\n }\n }\n return result\n}\n\n/**\n * @template {ArrayLike<any>} ARR\n * @template {function(ARR extends ArrayLike<infer T> ? T : never, number, ARR):any} MAPPER\n * @param {ARR} arr\n * @param {MAPPER} mapper\n * @return {Array<MAPPER extends function(...any): infer M ? M : never>}\n */\nexport const map = (arr, mapper) => {\n /**\n * @type {Array<any>}\n */\n const res = Array(arr.length)\n for (let i = 0; i < arr.length; i++) {\n res[i] = mapper(/** @type {any} */ (arr[i]), i, /** @type {any} */ (arr))\n }\n return /** @type {any} */ (res)\n}\n\n/**\n * This function bubble-sorts a single item to the correct position. The sort happens in-place and\n * might be useful to ensure that a single item is at the correct position in an otherwise sorted\n * array.\n *\n * @example\n * const arr = [3, 2, 5]\n * arr.sort((a, b) => a - b)\n * arr // => [2, 3, 5]\n * arr.splice(1, 0, 7)\n * array.bubbleSortItem(arr, 1, (a, b) => a - b)\n * arr // => [2, 3, 5, 7]\n *\n * @template T\n * @param {Array<T>} arr\n * @param {number} i\n * @param {(a:T,b:T) => number} compareFn\n */\nexport const bubblesortItem = (arr, i, compareFn) => {\n const n = arr[i]\n let j = i\n // try to sort to the right\n while (j + 1 < arr.length && compareFn(n, arr[j + 1]) > 0) {\n arr[j] = arr[j + 1]\n arr[++j] = n\n }\n if (i === j && j > 0) { // no change yet\n // sort to the left\n while (j > 0 && compareFn(arr[j - 1], n) > 0) {\n arr[j] = arr[j - 1]\n arr[--j] = n\n }\n }\n return j\n}\n", "/**\n * Observable class prototype.\n *\n * @module observable\n */\n\nimport * as map from './map.js'\nimport * as set from './set.js'\nimport * as array from './array.js'\n\n/**\n * Handles named events.\n * @experimental\n *\n * This is basically a (better typed) duplicate of Observable, which will replace Observable in the\n * next release.\n *\n * @template {{[key in keyof EVENTS]: function(...any):void}} EVENTS\n */\nexport class ObservableV2 {\n constructor () {\n /**\n * Some desc.\n * @type {Map<string, Set<any>>}\n */\n this._observers = map.create()\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n on (name, f) {\n map.setIfUndefined(this._observers, /** @type {string} */ (name), set.create).add(f)\n return f\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n once (name, f) {\n /**\n * @param {...any} args\n */\n const _f = (...args) => {\n this.off(name, /** @type {any} */ (_f))\n f(...args)\n }\n this.on(name, /** @type {any} */ (_f))\n }\n\n /**\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name\n * @param {EVENTS[NAME]} f\n */\n off (name, f) {\n const observers = this._observers.get(name)\n if (observers !== undefined) {\n observers.delete(f)\n if (observers.size === 0) {\n this._observers.delete(name)\n }\n }\n }\n\n /**\n * Emit a named event. All registered event listeners that listen to the\n * specified name will receive the event.\n *\n * @todo This should catch exceptions\n *\n * @template {keyof EVENTS & string} NAME\n * @param {NAME} name The event name.\n * @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.\n */\n emit (name, args) {\n // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.\n return array.from((this._observers.get(name) || map.create()).values()).forEach(f => f(...args))\n }\n\n destroy () {\n this._observers = map.create()\n }\n}\n\n/* c8 ignore start */\n/**\n * Handles named events.\n *\n * @deprecated\n * @template N\n */\nexport class Observable {\n constructor () {\n /**\n * Some desc.\n * @type {Map<N, any>}\n */\n this._observers = map.create()\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n on (name, f) {\n map.setIfUndefined(this._observers, name, set.create).add(f)\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n once (name, f) {\n /**\n * @param {...any} args\n */\n const _f = (...args) => {\n this.off(name, _f)\n f(...args)\n }\n this.on(name, _f)\n }\n\n /**\n * @param {N} name\n * @param {function} f\n */\n off (name, f) {\n const observers = this._observers.get(name)\n if (observers !== undefined) {\n observers.delete(f)\n if (observers.size === 0) {\n this._observers.delete(name)\n }\n }\n }\n\n /**\n * Emit a named event. All registered event listeners that listen to the\n * specified name will receive the event.\n *\n * @todo This should catch exceptions\n *\n * @param {N} name The event name.\n * @param {Array<any>} args The arguments that are applied to the event listener.\n */\n emit (name, args) {\n // copy all listeners to an array first to make sure that no event is emitted to listeners that are subscribed while the event handler is called.\n return array.from((this._observers.get(name) || map.create()).values()).forEach(f => f(...args))\n }\n\n destroy () {\n this._observers = map.create()\n }\n}\n/* c8 ignore end */\n", "/**\n * Common Math expressions.\n *\n * @module math\n */\n\nexport const floor = Math.floor\nexport const ceil = Math.ceil\nexport const abs = Math.abs\nexport const imul = Math.imul\nexport const round = Math.round\nexport const log10 = Math.log10\nexport const log2 = Math.log2\nexport const log = Math.log\nexport const sqrt = Math.sqrt\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The sum of a and b\n */\nexport const add = (a, b) => a + b\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The smaller element of a and b\n */\nexport const min = (a, b) => a < b ? a : b\n\n/**\n * @function\n * @param {number} a\n * @param {number} b\n * @return {number} The bigger element of a and b\n */\nexport const max = (a, b) => a > b ? a : b\n\nexport const isNaN = Number.isNaN\n\nexport const pow = Math.pow\n/**\n * Base 10 exponential function. Returns the value of 10 raised to the power of pow.\n *\n * @param {number} exp\n * @return {number}\n */\nexport const exp10 = exp => Math.pow(10, exp)\n\nexport const sign = Math.sign\n\n/**\n * Check whether n is negative, while considering the -0 edge case. While `-0 < 0` is false, this\n * function returns true for -0,-1,,.. and returns false for 0,1,2,...\n * @param {number} n\n * @return {boolean} Wether n is negative. This function also distinguishes between -0 and +0\n */\nexport const isNegativeZero = n => n !== 0 ? n < 0 : 1 / n < 0\n", "/**\n * Utility helpers for working with numbers.\n *\n * @module number\n */\n\nimport * as math from './math.js'\nimport * as binary from './binary.js'\n\nexport const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER\nexport const MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER\n\nexport const LOWEST_INT32 = 1 << 31\nexport const HIGHEST_INT32 = binary.BITS31\nexport const HIGHEST_UINT32 = binary.BITS32\n\n/* c8 ignore next */\nexport const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && math.floor(num) === num)\nexport const isNaN = Number.isNaN\nexport const parseInt = Number.parseInt\n\n/**\n * Count the number of \"1\" bits in an unsigned 32bit number.\n *\n * Super fun bitcount algorithm by Brian Kernighan.\n *\n * @param {number} n\n */\nexport const countBits = n => {\n n &= binary.BITS32\n let count = 0\n while (n) {\n n &= (n - 1)\n count++\n }\n return count\n}\n", "import * as array from './array.js'\n\n/**\n * Utility module to work with strings.\n *\n * @module string\n */\n\nexport const fromCharCode = String.fromCharCode\nexport const fromCodePoint = String.fromCodePoint\n\n/**\n * The largest utf16 character.\n * Corresponds to Uint8Array([255, 255]) or charcodeof(2x2^8)\n */\nexport const MAX_UTF16_CHARACTER = fromCharCode(65535)\n\n/**\n * @param {string} s\n * @return {string}\n */\nconst toLowerCase = s => s.toLowerCase()\n\nconst trimLeftRegex = /^\\s*/g\n\n/**\n * @param {string} s\n * @return {string}\n */\nexport const trimLeft = s => s.replace(trimLeftRegex, '')\n\nconst fromCamelCaseRegex = /([A-Z])/g\n\n/**\n * @param {string} s\n * @param {string} separator\n * @return {string}\n */\nexport const fromCamelCase = (s, separator) => trimLeft(s.replace(fromCamelCaseRegex, match => `${separator}${toLowerCase(match)}`))\n\n/**\n * Compute the utf8ByteLength\n * @param {string} str\n * @return {number}\n */\nexport const utf8ByteLength = str => unescape(encodeURIComponent(str)).length\n\n/**\n * @param {string} str\n * @return {Uint8Array<ArrayBuffer>}\n */\nexport const _encodeUtf8Polyfill = str => {\n const encodedString = unescape(encodeURIComponent(str))\n const len = encodedString.length\n const buf = new Uint8Array(len)\n for (let i = 0; i < len; i++) {\n buf[i] = /** @type {number} */ (encodedString.codePointAt(i))\n }\n return buf\n}\n\n/* c8 ignore next */\nexport const utf8TextEncoder = /** @type {TextEncoder} */ (typeof TextEncoder !== 'undefined' ? new TextEncoder() : null)\n\n/**\n * @param {string} str\n * @return {Uint8Array<ArrayBuffer>}\n */\nexport const _encodeUtf8Native = str => utf8TextEncoder.encode(str)\n\n/**\n * @param {string} str\n * @return {Uint8Array}\n */\n/* c8 ignore next */\nexport const encodeUtf8 = utf8TextEncoder ? _encodeUtf8Native : _encodeUtf8Polyfill\n\n/**\n * @param {Uint8Array} buf\n * @return {string}\n */\nexport const _decodeUtf8Polyfill = buf => {\n let remainingLen = buf.length\n let encodedString = ''\n let bufPos = 0\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n const bytes = buf.subarray(bufPos, bufPos + nextLen)\n bufPos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint.apply(null, /** @type {any} */ (bytes))\n remainingLen -= nextLen\n }\n return decodeURIComponent(escape(encodedString))\n}\n\n/* c8 ignore next */\nexport let utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf-8', { fatal: true, ignoreBOM: true })\n\n/* c8 ignore start */\nif (utf8TextDecoder && utf8TextDecoder.decode(new Uint8Array()).length === 1) {\n // Safari doesn't handle BOM correctly.\n // This fixes a bug in Safari 13.0.5 where it produces a BOM the first time it is called.\n // utf8TextDecoder.decode(new Uint8Array()).length === 1 on the first call and\n // utf8TextDecoder.decode(new Uint8Array()).length === 1 on the second call\n // Another issue is that from then on no BOM chars are recognized anymore\n /* c8 ignore next */\n utf8TextDecoder = null\n}\n/* c8 ignore stop */\n\n/**\n * @param {Uint8Array} buf\n * @return {string}\n */\nexport const _decodeUtf8Native = buf => /** @type {TextDecoder} */ (utf8TextDecoder).decode(buf)\n\n/**\n * @param {Uint8Array} buf\n * @return {string}\n */\n/* c8 ignore next */\nexport const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill\n\n/**\n * @param {string} str The initial string\n * @param {number} index Starting position\n * @param {number} remove Number of characters to remove\n * @param {string} insert New content to insert\n */\nexport const splice = (str, index, remove, insert = '') => str.slice(0, index) + insert + str.slice(index + remove)\n\n/**\n * @param {string} source\n * @param {number} n\n */\nexport const repeat = (source, n) => array.unfold(n, () => source).join('')\n\n/**\n * Escape HTML characters &,<,>,',\" to their respective HTML entities &amp;,&lt;,&gt;,&#39;,&quot;\n *\n * @param {string} str\n */\nexport const escapeHTML = str =>\n str.replace(/[&<>'\"]/g, r => /** @type {string} */ ({\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n \"'\": '&#39;',\n '\"': '&quot;'\n }[r]))\n\n/**\n * Reverse of `escapeHTML`\n *\n * @param {string} str\n */\nexport const unescapeHTML = str =>\n str.replace(/&amp;|&lt;|&gt;|&#39;|&quot;/g, r => /** @type {string} */ ({\n '&amp;': '&',\n '&lt;': '<',\n '&gt;': '>',\n '&#39;': \"'\",\n '&quot;': '\"'\n }[r]))\n", "/**\n * Efficient schema-less binary encoding with support for variable length encoding.\n *\n * Use [lib0/encoding] with [lib0/decoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n *\n * @module encoding\n */\n\nimport * as math from './math.js'\nimport * as number from './number.js'\nimport * as binary from './binary.js'\nimport * as string from './string.js'\nimport * as array from './array.js'\n\n/**\n * A BinaryEncoder handles the encoding to an Uint8Array.\n */\nexport class Encoder {\n constructor () {\n this.cpos = 0\n this.cbuf = new Uint8Array(100)\n /**\n * @type {Array<Uint8Array>}\n */\n this.bufs = []\n }\n}\n\n/**\n * @function\n * @return {Encoder}\n */\nexport const createEncoder = () => new Encoder()\n\n/**\n * @param {function(Encoder):void} f\n */\nexport const encode = (f) => {\n const encoder = createEncoder()\n f(encoder)\n return toUint8Array(encoder)\n}\n\n/**\n * The current length of the encoded data.\n *\n * @function\n * @param {Encoder} encoder\n * @return {number}\n */\nexport const length = encoder => {\n let len = encoder.cpos\n for (let i = 0; i < encoder.bufs.length; i++) {\n len += encoder.bufs[i].length\n }\n return len\n}\n\n/**\n * Check whether encoder is empty.\n *\n * @function\n * @param {Encoder} encoder\n * @return {boolean}\n */\nexport const hasContent = encoder => encoder.cpos > 0 || encoder.bufs.length > 0\n\n/**\n * Transform to Uint8Array.\n *\n * @function\n * @param {Encoder} encoder\n * @return {Uint8Array<ArrayBuffer>} The created ArrayBuffer.\n */\nexport const toUint8Array = encoder => {\n const uint8arr = new Uint8Array(length(encoder))\n let curPos = 0\n for (let i = 0; i < encoder.bufs.length; i++) {\n const d = encoder.bufs[i]\n uint8arr.set(d, curPos)\n curPos += d.length\n }\n uint8arr.set(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos), curPos)\n return uint8arr\n}\n\n/**\n * Verify that it is possible to write `len` bytes wtihout checking. If\n * necessary, a new Buffer with the required length is attached.\n *\n * @param {Encoder} encoder\n * @param {number} len\n */\nexport const verifyLen = (encoder, len) => {\n const bufferLen = encoder.cbuf.length\n if (bufferLen - encoder.cpos < len) {\n encoder.bufs.push(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos))\n encoder.cbuf = new Uint8Array(math.max(bufferLen, len) * 2)\n encoder.cpos = 0\n }\n}\n\n/**\n * Write one byte to the encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The byte that is to be encoded.\n */\nexport const write = (encoder, num) => {\n const bufferLen = encoder.cbuf.length\n if (encoder.cpos === bufferLen) {\n encoder.bufs.push(encoder.cbuf)\n encoder.cbuf = new Uint8Array(bufferLen * 2)\n encoder.cpos = 0\n }\n encoder.cbuf[encoder.cpos++] = num\n}\n\n/**\n * Write one byte at a specific position.\n * Position must already be written (i.e. encoder.length > pos)\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos Position to which to write data\n * @param {number} num Unsigned 8-bit integer\n */\nexport const set = (encoder, pos, num) => {\n let buffer = null\n // iterate all buffers and adjust position\n for (let i = 0; i < encoder.bufs.length && buffer === null; i++) {\n const b = encoder.bufs[i]\n if (pos < b.length) {\n buffer = b // found buffer\n } else {\n pos -= b.length\n }\n }\n if (buffer === null) {\n // use current buffer\n buffer = encoder.cbuf\n }\n buffer[pos] = num\n}\n\n/**\n * Write one byte as an unsigned integer.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint8 = write\n\n/**\n * Write one byte as an unsigned Integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint8 = set\n\n/**\n * Write two bytes as an unsigned integer.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint16 = (encoder, num) => {\n write(encoder, num & binary.BITS8)\n write(encoder, (num >>> 8) & binary.BITS8)\n}\n/**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint16 = (encoder, pos, num) => {\n set(encoder, pos, num & binary.BITS8)\n set(encoder, pos + 1, (num >>> 8) & binary.BITS8)\n}\n\n/**\n * Write two bytes as an unsigned integer\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint32 = (encoder, num) => {\n for (let i = 0; i < 4; i++) {\n write(encoder, num & binary.BITS8)\n num >>>= 8\n }\n}\n\n/**\n * Write two bytes as an unsigned integer in big endian order.\n * (most significant byte first)\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeUint32BigEndian = (encoder, num) => {\n for (let i = 3; i >= 0; i--) {\n write(encoder, (num >>> (8 * i)) & binary.BITS8)\n }\n}\n\n/**\n * Write two bytes as an unsigned integer at a specific location.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} pos The location where the data will be written.\n * @param {number} num The number that is to be encoded.\n */\nexport const setUint32 = (encoder, pos, num) => {\n for (let i = 0; i < 4; i++) {\n set(encoder, pos + i, num & binary.BITS8)\n num >>>= 8\n }\n}\n\n/**\n * Write a variable length unsigned integer. Max encodable integer is 2^53.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeVarUint = (encoder, num) => {\n while (num > binary.BITS7) {\n write(encoder, binary.BIT8 | (binary.BITS7 & num))\n num = math.floor(num / 128) // shift >>> 7\n }\n write(encoder, binary.BITS7 & num)\n}\n\n/**\n * Write a variable length integer.\n *\n * We use the 7th bit instead for signaling that this is a negative number.\n *\n * @function\n * @param {Encoder} encoder\n * @param {number} num The number that is to be encoded.\n */\nexport const writeVarInt = (encoder, num) => {\n const isNegative = math.isNegativeZero(num)\n if (isNegative) {\n num = -num\n }\n // |- whether to continue reading |- whether is negative |- number\n write(encoder, (num > binary.BITS6 ? binary.BIT8 : 0) | (isNegative ? binary.BIT7 : 0) | (binary.BITS6 & num))\n num = math.floor(num / 64) // shift >>> 6\n // We don't need to consider the case of num === 0 so we can use a different\n // pattern here than above.\n while (num > 0) {\n write(encoder, (num > binary.BITS7 ? binary.BIT8 : 0) | (binary.BITS7 & num))\n num = math.floor(num / 128) // shift >>> 7\n }\n}\n\n/**\n * A cache to store strings temporarily\n */\nconst _strBuffer = new Uint8Array(30000)\nconst _maxStrBSize = _strBuffer.length / 3\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const _writeVarStringNative = (encoder, str) => {\n if (str.length < _maxStrBSize) {\n // We can encode the string into the existing buffer\n /* c8 ignore next */\n const written = string.utf8TextEncoder.encodeInto(str, _strBuffer).written || 0\n writeVarUint(encoder, written)\n for (let i = 0; i < written; i++) {\n write(encoder, _strBuffer[i])\n }\n } else {\n writeVarUint8Array(encoder, string.encodeUtf8(str))\n }\n}\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const _writeVarStringPolyfill = (encoder, str) => {\n const encodedString = unescape(encodeURIComponent(str))\n const len = encodedString.length\n writeVarUint(encoder, len)\n for (let i = 0; i < len; i++) {\n write(encoder, /** @type {number} */ (encodedString.codePointAt(i)))\n }\n}\n\n/**\n * Write a variable length string.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\n/* c8 ignore next */\nexport const writeVarString = (string.utf8TextEncoder && /** @type {any} */ (string.utf8TextEncoder).encodeInto) ? _writeVarStringNative : _writeVarStringPolyfill\n\n/**\n * Write a string terminated by a special byte sequence. This is not very performant and is\n * generally discouraged. However, the resulting byte arrays are lexiographically ordered which\n * makes this a nice feature for databases.\n *\n * The string will be encoded using utf8 and then terminated and escaped using writeTerminatingUint8Array.\n *\n * @function\n * @param {Encoder} encoder\n * @param {String} str The string that is to be encoded.\n */\nexport const writeTerminatedString = (encoder, str) =>\n writeTerminatedUint8Array(encoder, string.encodeUtf8(str))\n\n/**\n * Write a terminating Uint8Array. Note that this is not performant and is generally\n * discouraged. There are few situations when this is needed.\n *\n * We use 0x0 as a terminating character. 0x1 serves as an escape character for 0x0 and 0x1.\n *\n * Example: [0,1,2] is encoded to [1,0,1,1,2,0]. 0x0, and 0x1 needed to be escaped using 0x1. Then\n * the result is terminated using the 0x0 character.\n *\n * This is basically how many systems implement null terminated strings. However, we use an escape\n * character 0x1 to avoid issues and potenial attacks on our database (if this is used as a key\n * encoder for NoSql databases).\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} buf The string that is to be encoded.\n */\nexport const writeTerminatedUint8Array = (encoder, buf) => {\n for (let i = 0; i < buf.length; i++) {\n const b = buf[i]\n if (b === 0 || b === 1) {\n write(encoder, 1)\n }\n write(encoder, buf[i])\n }\n write(encoder, 0)\n}\n\n/**\n * Write the content of another Encoder.\n *\n * @TODO: can be improved!\n * - Note: Should consider that when appending a lot of small Encoders, we should rather clone than referencing the old structure.\n * Encoders start with a rather big initial buffer.\n *\n * @function\n * @param {Encoder} encoder The enUint8Arr\n * @param {Encoder} append The BinaryEncoder to be written.\n */\nexport const writeBinaryEncoder = (encoder, append) => writeUint8Array(encoder, toUint8Array(append))\n\n/**\n * Append fixed-length Uint8Array to the encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} uint8Array\n */\nexport const writeUint8Array = (encoder, uint8Array) => {\n const bufferLen = encoder.cbuf.length\n const cpos = encoder.cpos\n const leftCopyLen = math.min(bufferLen - cpos, uint8Array.length)\n const rightCopyLen = uint8Array.length - leftCopyLen\n encoder.cbuf.set(uint8Array.subarray(0, leftCopyLen), cpos)\n encoder.cpos += leftCopyLen\n if (rightCopyLen > 0) {\n // Still something to write, write right half..\n // Append new buffer\n encoder.bufs.push(encoder.cbuf)\n // must have at least size of remaining buffer\n encoder.cbuf = new Uint8Array(math.max(bufferLen * 2, rightCopyLen))\n // copy array\n encoder.cbuf.set(uint8Array.subarray(leftCopyLen))\n encoder.cpos = rightCopyLen\n }\n}\n\n/**\n * Append an Uint8Array to Encoder.\n *\n * @function\n * @param {Encoder} encoder\n * @param {Uint8Array} uint8Array\n */\nexport const writeVarUint8Array = (encoder, uint8Array) => {\n writeVarUint(encoder, uint8Array.byteLength)\n writeUint8Array(encoder, uint8Array)\n}\n\n/**\n * Create an DataView of the next `len` bytes. Use it to write data after\n * calling this function.\n *\n * ```js\n * // write float32 using DataView\n * const dv = writeOnDataView(encoder, 4)\n * dv.setFloat32(0, 1.1)\n * // read float32 using DataView\n * const dv = readFromDataView(encoder, 4)\n * dv.getFloat32(0) // => 1.100000023841858 (leaving it to the reader to find out why this is the correct result)\n * ```\n *\n * @param {Encoder} encoder\n * @param {number} len\n * @return {DataView}\n */\nexport const writeOnDataView = (encoder, len) => {\n verifyLen(encoder, len)\n const dview = new DataView(encoder.cbuf.buffer, encoder.cpos, len)\n encoder.cpos += len\n return dview\n}\n\n/**\n * @param {Encoder} encoder\n * @param {number} num\n */\nexport const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {number} num\n */\nexport const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {bigint} num\n */\nexport const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num, false)\n\n/**\n * @param {Encoder} encoder\n * @param {bigint} num\n */\nexport const writeBigUint64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigUint64(0, num, false)\n\nconst floatTestBed = new DataView(new ArrayBuffer(4))\n/**\n * Check if a number can be encoded as a 32 bit float.\n *\n * @param {number} num\n * @return {boolean}\n */\nconst isFloat32 = num => {\n floatTestBed.setFloat32(0, num)\n return floatTestBed.getFloat32(0) === num\n}\n\n/**\n * @typedef {Array<AnyEncodable>} AnyEncodableArray\n */\n\n/**\n * @typedef {undefined|null|number|bigint|boolean|string|{[k:string]:AnyEncodable}|AnyEncodableArray|Uint8Array} AnyEncodable\n */\n\n/**\n * Encode data with efficient binary format.\n *\n * Differences to JSON:\n * \u2022 Transforms data to a binary format (not to a string)\n * \u2022 Encodes undefined, NaN, and ArrayBuffer (these can't be represented in JSON)\n * \u2022 Numbers are efficiently encoded either as a variable length integer, as a\n * 32 bit float, as a 64 bit float, or as a 64 bit bigint.\n *\n * Encoding table:\n *\n * | Data Type | Prefix | Encoding Method | Comment |\n * | ------------------- | -------- | ------------------ | ------- |\n * | undefined | 127 | | Functions, symbol, and everything that cannot be identified is encoded as undefined |\n * | null | 126 | | |\n * | integer | 125 | writeVarInt | Only encodes 32 bit signed integers |\n * | float32 | 124 | writeFloat32 | |\n * | float64 | 123 | writeFloat64 | |\n * | bigint | 122 | writeBigInt64 | |\n * | boolean (false) | 121 | | True and false are different data types so we save the following byte |\n * | boolean (true) | 120 | | - 0b01111000 so the last bit determines whether true or false |\n * | string | 119 | writeVarString | |\n * | object<string,any> | 118 | custom | Writes {length} then {length} key-value pairs |\n * | array<any> | 117 | custom | Writes {length} then {length} json values |\n * | Uint8Array | 116 | writeVarUint8Array | We use Uint8Array for any kind of binary data |\n *\n * Reasons for the decreasing prefix:\n * We need the first bit for extendability (later we may want to encode the\n * prefix with writeVarUint). The remaining 7 bits are divided as follows:\n * [0-30] the beginning of the data range is used for custom purposes\n * (defined by the function that uses this library)\n * [31-127] the end of the data range is used for data encoding by\n * lib0/encoding.js\n *\n * @param {Encoder} encoder\n * @param {AnyEncodable} data\n */\nexport const writeAny = (encoder, data) => {\n switch (typeof data) {\n case 'string':\n // TYPE 119: STRING\n write(encoder, 119)\n writeVarString(encoder, data)\n break\n case 'number':\n if (number.isInteger(data) && math.abs(data) <= binary.BITS31) {\n // TYPE 125: INTEGER\n write(encoder, 125)\n writeVarInt(encoder, data)\n } else if (isFloat32(data)) {\n // TYPE 124: FLOAT32\n write(encoder, 124)\n writeFloat32(encoder, data)\n } else {\n // TYPE 123: FLOAT64\n write(encoder, 123)\n writeFloat64(encoder, data)\n }\n break\n case 'bigint':\n // TYPE 122: BigInt\n write(encoder, 122)\n writeBigInt64(encoder, data)\n break\n case 'object':\n if (data === null) {\n // TYPE 126: null\n write(encoder, 126)\n } else if (array.isArray(data)) {\n // TYPE 117: Array\n write(encoder, 117)\n writeVarUint(encoder, data.length)\n for (let i = 0; i < data.length; i++) {\n writeAny(encoder, data[i])\n }\n } else if (data instanceof Uint8Array) {\n // TYPE 116: ArrayBuffer\n write(encoder, 116)\n writeVarUint8Array(encoder, data)\n } else {\n // TYPE 118: Object\n write(encoder, 118)\n const keys = Object.keys(data)\n writeVarUint(encoder, keys.length)\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i]\n writeVarString(encoder, key)\n writeAny(encoder, data[key])\n }\n }\n break\n case 'boolean':\n // TYPE 120/121: boolean (true/false)\n write(encoder, data ? 120 : 121)\n break\n default:\n // TYPE 127: undefined\n write(encoder, 127)\n }\n}\n\n/**\n * Now come a few stateful encoder that have their own classes.\n */\n\n/**\n * Basic Run Length Encoder - a basic compression implementation.\n *\n * Encodes [1,1,1,7] to [1,3,7,1] (3 times 1, 1 time 7). This encoder might do more harm than good if there are a lot of values that are not repeated.\n *\n * It was originally used for image compression. Cool .. article http://csbruce.com/cbm/transactor/pdfs/trans_v7_i06.pdf\n *\n * @note T must not be null!\n *\n * @template T\n */\nexport class RleEncoder extends Encoder {\n /**\n * @param {function(Encoder, T):void} writer\n */\n constructor (writer) {\n super()\n /**\n * The writer\n */\n this.w = writer\n /**\n * Current state\n * @type {T|null}\n */\n this.s = null\n this.count = 0\n }\n\n /**\n * @param {T} v\n */\n write (v) {\n if (this.s === v) {\n this.count++\n } else {\n if (this.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw\n }\n this.count = 1\n // write first value\n this.w(this, v)\n this.s = v\n }\n }\n}\n\n/**\n * Basic diff decoder using variable length encoding.\n *\n * Encodes the values [3, 1100, 1101, 1050, 0] to [3, 1097, 1, -51, -1050] using writeVarInt.\n */\nexport class IntDiffEncoder extends Encoder {\n /**\n * @param {number} start\n */\n constructor (start) {\n super()\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n writeVarInt(this, v - this.s)\n this.s = v\n }\n}\n\n/**\n * A combination of IntDiffEncoder and RleEncoder.\n *\n * Basically first writes the IntDiffEncoder and then counts duplicate diffs using RleEncoding.\n *\n * Encodes the values [1,1,1,2,3,4,5,6] as [1,1,0,2,1,5] (RLE([1,0,0,1,1,1,1,1]) \u21D2 RleIntDiff[1,1,0,2,1,5])\n */\nexport class RleIntDiffEncoder extends Encoder {\n /**\n * @param {number} start\n */\n constructor (start) {\n super()\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s === v && this.count > 0) {\n this.count++\n } else {\n if (this.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n writeVarUint(this, this.count - 1) // since count is always > 0, we can decrement by one. non-standard encoding ftw\n }\n this.count = 1\n // write first value\n writeVarInt(this, v - this.s)\n this.s = v\n }\n }\n}\n\n/**\n * @param {UintOptRleEncoder} encoder\n */\nconst flushUintOptRleEncoder = encoder => {\n if (encoder.count > 0) {\n // flush counter, unless this is the first value (count = 0)\n // case 1: just a single value. set sign to positive\n // case 2: write several values. set sign to negative to indicate that there is a length coming\n writeVarInt(encoder.encoder, encoder.count === 1 ? encoder.s : -encoder.s)\n if (encoder.count > 1) {\n writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw\n }\n }\n}\n\n/**\n * Optimized Rle encoder that does not suffer from the mentioned problem of the basic Rle encoder.\n *\n * Internally uses VarInt encoder to write unsigned integers. If the input occurs multiple times, we write\n * write it as a negative number. The UintOptRleDecoder then understands that it needs to read a count.\n *\n * Encodes [1,2,3,3,3] as [1,2,-3,3] (once 1, once 2, three times 3)\n */\nexport class UintOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s === v) {\n this.count++\n } else {\n flushUintOptRleEncoder(this)\n this.count = 1\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushUintOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * Increasing Uint Optimized RLE Encoder\n *\n * The RLE encoder counts the number of same occurences of the same value.\n * The IncUintOptRle encoder counts if the value increases.\n * I.e. 7, 8, 9, 10 will be encoded as [-7, 4]. 1, 3, 5 will be encoded\n * as [1, 3, 5].\n */\nexport class IncUintOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.s + this.count === v) {\n this.count++\n } else {\n flushUintOptRleEncoder(this)\n this.count = 1\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushUintOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * @param {IntDiffOptRleEncoder} encoder\n */\nconst flushIntDiffOptRleEncoder = encoder => {\n if (encoder.count > 0) {\n // 31 bit making up the diff | wether to write the counter\n // const encodedDiff = encoder.diff << 1 | (encoder.count === 1 ? 0 : 1)\n const encodedDiff = encoder.diff * 2 + (encoder.count === 1 ? 0 : 1)\n // flush counter, unless this is the first value (count = 0)\n // case 1: just a single value. set first bit to positive\n // case 2: write several values. set first bit to negative to indicate that there is a length coming\n writeVarInt(encoder.encoder, encodedDiff)\n if (encoder.count > 1) {\n writeVarUint(encoder.encoder, encoder.count - 2) // since count is always > 1, we can decrement by one. non-standard encoding ftw\n }\n }\n}\n\n/**\n * A combination of the IntDiffEncoder and the UintOptRleEncoder.\n *\n * The count approach is similar to the UintDiffOptRleEncoder, but instead of using the negative bitflag, it encodes\n * in the LSB whether a count is to be read. Therefore this Encoder only supports 31 bit integers!\n *\n * Encodes [1, 2, 3, 2] as [3, 1, 6, -1] (more specifically [(1 << 1) | 1, (3 << 0) | 0, -1])\n *\n * Internally uses variable length encoding. Contrary to normal UintVar encoding, the first byte contains:\n * * 1 bit that denotes whether the next value is a count (LSB)\n * * 1 bit that denotes whether this value is negative (MSB - 1)\n * * 1 bit that denotes whether to continue reading the variable length integer (MSB)\n *\n * Therefore, only five bits remain to encode diff ranges.\n *\n * Use this Encoder only when appropriate. In most cases, this is probably a bad idea.\n */\nexport class IntDiffOptRleEncoder {\n constructor () {\n this.encoder = new Encoder()\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n this.diff = 0\n }\n\n /**\n * @param {number} v\n */\n write (v) {\n if (this.diff === v - this.s) {\n this.s = v\n this.count++\n } else {\n flushIntDiffOptRleEncoder(this)\n this.count = 1\n this.diff = v - this.s\n this.s = v\n }\n }\n\n /**\n * Flush the encoded state and transform this to a Uint8Array.\n *\n * Note that this should only be called once.\n */\n toUint8Array () {\n flushIntDiffOptRleEncoder(this)\n return toUint8Array(this.encoder)\n }\n}\n\n/**\n * Optimized String Encoder.\n *\n * Encoding many small strings in a simple Encoder is not very efficient. The function call to decode a string takes some time and creates references that must be eventually deleted.\n * In practice, when decoding several million small strings, the GC will kick in more and more often to collect orphaned string objects (or maybe there is another reason?).\n *\n * This string encoder solves the above problem. All strings are concatenated and written as a single string using a single encoding call.\n *\n * The lengths are encoded using a UintOptRleEncoder.\n */\nexport class StringEncoder {\n constructor () {\n /**\n * @type {Array<string>}\n */\n this.sarr = []\n this.s = ''\n this.lensE = new UintOptRleEncoder()\n }\n\n /**\n * @param {string} string\n */\n write (string) {\n this.s += string\n if (this.s.length > 19) {\n this.sarr.push(this.s)\n this.s = ''\n }\n this.lensE.write(string.length)\n }\n\n toUint8Array () {\n const encoder = new Encoder()\n this.sarr.push(this.s)\n this.s = ''\n writeVarString(encoder, this.sarr.join(''))\n writeUint8Array(encoder, this.lensE.toUint8Array())\n return toUint8Array(encoder)\n }\n}\n", "/**\n * Error helpers.\n *\n * @module error\n */\n\n/**\n * @param {string} s\n * @return {Error}\n */\n/* c8 ignore next */\nexport const create = s => new Error(s)\n\n/**\n * @throws {Error}\n * @return {never}\n */\n/* c8 ignore next 3 */\nexport const methodUnimplemented = () => {\n throw create('Method unimplemented')\n}\n\n/**\n * @throws {Error}\n * @return {never}\n */\n/* c8 ignore next 3 */\nexport const unexpectedCase = () => {\n throw create('Unexpected case')\n}\n\n/**\n * @param {boolean} property\n * @return {asserts property is true}\n */\nexport const assert = property => { if (!property) throw create('Assert failed') }\n", "/**\n * Efficient schema-less binary decoding with support for variable length encoding.\n *\n * Use [lib0/decoding] with [lib0/encoding]. Every encoding function has a corresponding decoding function.\n *\n * Encodes numbers in little-endian order (least to most significant byte order)\n * and is compatible with Golang's binary encoding (https://golang.org/pkg/encoding/binary/)\n * which is also used in Protocol Buffers.\n *\n * ```js\n * // encoding step\n * const encoder = encoding.createEncoder()\n * encoding.writeVarUint(encoder, 256)\n * encoding.writeVarString(encoder, 'Hello world!')\n * const buf = encoding.toUint8Array(encoder)\n * ```\n *\n * ```js\n * // decoding step\n * const decoder = decoding.createDecoder(buf)\n * decoding.readVarUint(decoder) // => 256\n * decoding.readVarString(decoder) // => 'Hello world!'\n * decoding.hasContent(decoder) // => false - all data is read\n * ```\n *\n * @module decoding\n */\n\nimport * as binary from './binary.js'\nimport * as math from './math.js'\nimport * as number from './number.js'\nimport * as string from './string.js'\nimport * as error from './error.js'\nimport * as encoding from './encoding.js'\n\nconst errorUnexpectedEndOfArray = error.create('Unexpected end of array')\nconst errorIntegerOutOfRange = error.create('Integer out of Range')\n\n/**\n * A Decoder handles the decoding of an Uint8Array.\n * @template {ArrayBufferLike} [Buf=ArrayBufferLike]\n */\nexport class Decoder {\n /**\n * @param {Uint8Array<Buf>} uint8Array Binary data to decode\n */\n constructor (uint8Array) {\n /**\n * Decoding target.\n *\n * @type {Uint8Array<Buf>}\n */\n this.arr = uint8Array\n /**\n * Current decoding position.\n *\n * @type {number}\n */\n this.pos = 0\n }\n}\n\n/**\n * @function\n * @template {ArrayBufferLike} Buf\n * @param {Uint8Array<Buf>} uint8Array\n * @return {Decoder<Buf>}\n */\nexport const createDecoder = uint8Array => new Decoder(uint8Array)\n\n/**\n * @function\n * @param {Decoder} decoder\n * @return {boolean}\n */\nexport const hasContent = decoder => decoder.pos !== decoder.arr.length\n\n/**\n * Clone a decoder instance.\n * Optionally set a new position parameter.\n *\n * @function\n * @param {Decoder} decoder The decoder instance\n * @param {number} [newPos] Defaults to current position\n * @return {Decoder} A clone of `decoder`\n */\nexport const clone = (decoder, newPos = decoder.pos) => {\n const _decoder = createDecoder(decoder.arr)\n _decoder.pos = newPos\n return _decoder\n}\n\n/**\n * Create an Uint8Array view of the next `len` bytes and advance the position by `len`.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n *\n * @function\n * @template {ArrayBufferLike} Buf\n * @param {Decoder<Buf>} decoder The decoder instance\n * @param {number} len The length of bytes to read\n * @return {Uint8Array<Buf>}\n */\nexport const readUint8Array = (decoder, len) => {\n const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len)\n decoder.pos += len\n return view\n}\n\n/**\n * Read variable length Uint8Array.\n *\n * Important: The Uint8Array still points to the underlying ArrayBuffer. Make sure to discard the result as soon as possible to prevent any memory leaks.\n * Use `buffer.copyUint8Array` to copy the result into a new Uint8Array.\n *\n * @function\n * @template {ArrayBufferLike} Buf\n * @param {Decoder<Buf>} decoder\n * @return {Uint8Array<Buf>}\n */\nexport const readVarUint8Array = decoder => readUint8Array(decoder, readVarUint(decoder))\n\n/**\n * Read the rest of the content as an ArrayBuffer\n * @function\n * @param {Decoder} decoder\n * @return {Uint8Array}\n */\nexport const readTailAsUint8Array = decoder => readUint8Array(decoder, decoder.arr.length - decoder.pos)\n\n/**\n * Skip one byte, jump to the next position.\n * @function\n * @param {Decoder} decoder The decoder instance\n * @return {number} The next position\n */\nexport const skip8 = decoder => decoder.pos++\n\n/**\n * Read one byte as unsigned integer.\n * @function\n * @param {Decoder} decoder The decoder instance\n * @return {number} Unsigned 8-bit integer\n */\nexport const readUint8 = decoder => decoder.arr[decoder.pos++]\n\n/**\n * Read 2 bytes as unsigned integer.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const readUint16 = decoder => {\n const uint =\n decoder.arr[decoder.pos] +\n (decoder.arr[decoder.pos + 1] << 8)\n decoder.pos += 2\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const readUint32 = decoder => {\n const uint =\n (decoder.arr[decoder.pos] +\n (decoder.arr[decoder.pos + 1] << 8) +\n (decoder.arr[decoder.pos + 2] << 16) +\n (decoder.arr[decoder.pos + 3] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Read 4 bytes as unsigned integer in big endian order.\n * (most significant byte first)\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const readUint32BigEndian = decoder => {\n const uint =\n (decoder.arr[decoder.pos + 3] +\n (decoder.arr[decoder.pos + 2] << 8) +\n (decoder.arr[decoder.pos + 1] << 16) +\n (decoder.arr[decoder.pos] << 24)) >>> 0\n decoder.pos += 4\n return uint\n}\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const peekUint8 = decoder => decoder.arr[decoder.pos]\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const peekUint16 = decoder =>\n decoder.arr[decoder.pos] +\n (decoder.arr[decoder.pos + 1] << 8)\n\n/**\n * Look ahead without incrementing the position\n * to the next byte and read it as unsigned integer.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.\n */\nexport const peekUint32 = decoder => (\n decoder.arr[decoder.pos] +\n (decoder.arr[decoder.pos + 1] << 8) +\n (decoder.arr[decoder.pos + 2] << 16) +\n (decoder.arr[decoder.pos + 3] << 24)\n) >>> 0\n\n/**\n * Read unsigned integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * * numbers < 2^7 is stored in one bytlength\n * * numbers < 2^14 is stored in two bylength\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.length\n */\nexport const readVarUint = decoder => {\n let num = 0\n let mult = 1\n const len = decoder.arr.length\n while (decoder.pos < len) {\n const r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & binary.BITS7) * mult // shift $r << (7*#iterations) and add it to num\n mult *= 128 // next iteration, shift 7 \"more\" to the left\n if (r < binary.BIT8) {\n return num\n }\n /* c8 ignore start */\n if (num > number.MAX_SAFE_INTEGER) {\n throw errorIntegerOutOfRange\n }\n /* c8 ignore stop */\n }\n throw errorUnexpectedEndOfArray\n}\n\n/**\n * Read signed integer (32bit) with variable length.\n * 1/8th of the storage is used as encoding overhead.\n * * numbers < 2^7 is stored in one bytlength\n * * numbers < 2^14 is stored in two bylength\n * @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.\n *\n * @function\n * @param {Decoder} decoder\n * @return {number} An unsigned integer.length\n */\nexport const readVarInt = decoder => {\n let r = decoder.arr[decoder.pos++]\n let num = r & binary.BITS6\n let mult = 64\n const sign = (r & binary.BIT7) > 0 ? -1 : 1\n if ((r & binary.BIT8) === 0) {\n // don't continue reading\n return sign * num\n }\n const len = decoder.arr.length\n while (decoder.pos < len) {\n r = decoder.arr[decoder.pos++]\n // num = num | ((r & binary.BITS7) << len)\n num = num + (r & binary.BITS7) * mult\n mult *= 128\n if (r < binary.BIT8) {\n return sign * num\n }\n /* c8 ignore start */\n if (num > number.MAX_SAFE_INTEGER) {\n throw errorIntegerOutOfRange\n }\n /* c8 ignore stop */\n }\n throw errorUnexpectedEndOfArray\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n *\n * @function\n * @param {Decoder} decoder\n * @return {number}\n */\nexport const peekVarUint = decoder => {\n const pos = decoder.pos\n const s = readVarUint(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * Look ahead and read varUint without incrementing position\n *\n * @function\n * @param {Decoder} decoder\n * @return {number}\n */\nexport const peekVarInt = decoder => {\n const pos = decoder.pos\n const s = readVarInt(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * We don't test this function anymore as we use native decoding/encoding by default now.\n * Better not modify this anymore..\n *\n * Transforming utf8 to a string is pretty expensive. The code performs 10x better\n * when String.fromCodePoint is fed with all characters as arguments.\n * But most environments have a maximum number of arguments per functions.\n * For effiency reasons we apply a maximum of 10000 characters at once.\n *\n * @function\n * @param {Decoder} decoder\n * @return {String} The read String.\n */\n/* c8 ignore start */\nexport const _readVarStringPolyfill = decoder => {\n let remainingLen = readVarUint(decoder)\n if (remainingLen === 0) {\n return ''\n } else {\n let encodedString = String.fromCodePoint(readUint8(decoder)) // remember to decrease remainingLen\n if (--remainingLen < 100) { // do not create a Uint8Array for small strings\n while (remainingLen--) {\n encodedString += String.fromCodePoint(readUint8(decoder))\n }\n } else {\n while (remainingLen > 0) {\n const nextLen = remainingLen < 10000 ? remainingLen : 10000\n // this is dangerous, we create a fresh array view from the existing buffer\n const bytes = decoder.arr.subarray(decoder.pos, decoder.pos + nextLen)\n decoder.pos += nextLen\n // Starting with ES5.1 we can supply a generic array-like object as arguments\n encodedString += String.fromCodePoint.apply(null, /** @type {any} */ (bytes))\n remainingLen -= nextLen\n }\n }\n return decodeURIComponent(escape(encodedString))\n }\n}\n/* c8 ignore stop */\n\n/**\n * @function\n * @param {Decoder} decoder\n * @return {String} The read String\n */\nexport const _readVarStringNative = decoder =>\n /** @type any */ (string.utf8TextDecoder).decode(readVarUint8Array(decoder))\n\n/**\n * Read string of variable length\n * * varUint is used to store the length of the string\n *\n * @function\n * @param {Decoder} decoder\n * @return {String} The read String\n *\n */\n/* c8 ignore next */\nexport const readVarString = string.utf8TextDecoder ? _readVarStringNative : _readVarStringPolyfill\n\n/**\n * @param {Decoder} decoder\n * @return {Uint8Array}\n */\nexport const readTerminatedUint8Array = decoder => {\n const encoder = encoding.createEncoder()\n let b\n while (true) {\n b = readUint8(decoder)\n if (b === 0) {\n return encoding.toUint8Array(encoder)\n }\n if (b === 1) {\n b = readUint8(decoder)\n }\n encoding.write(encoder, b)\n }\n}\n\n/**\n * @param {Decoder} decoder\n * @return {string}\n */\nexport const readTerminatedString = decoder => string.decodeUtf8(readTerminatedUint8Array(decoder))\n\n/**\n * Look ahead and read varString without incrementing position\n *\n * @function\n * @param {Decoder} decoder\n * @return {string}\n */\nexport const peekVarString = decoder => {\n const pos = decoder.pos\n const s = readVarString(decoder)\n decoder.pos = pos\n return s\n}\n\n/**\n * @param {Decoder} decoder\n * @param {number} len\n * @return {DataView}\n */\nexport const readFromDataView = (decoder, len) => {\n const dv = new DataView(decoder.arr.buffer, decoder.arr.byteOffset + decoder.pos, len)\n decoder.pos += len\n return dv\n}\n\n/**\n * @param {Decoder} decoder\n */\nexport const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0, false)\n\n/**\n * @param {Decoder} decoder\n */\nexport const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0, false)\n\n/**\n * @param {Decoder} decoder\n */\nexport const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0, false)\n\n/**\n * @param {Decoder} decoder\n */\nexport const readBigUint64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigUint64(0, false)\n\n/**\n * @type {Array<function(Decoder):any>}\n */\nconst readAnyLookupTable = [\n decoder => undefined, // CASE 127: undefined\n decoder => null, // CASE 126: null\n readVarInt, // CASE 125: integer\n readFloat32, // CASE 124: float32\n readFloat64, // CASE 123: float64\n readBigInt64, // CASE 122: bigint\n decoder => false, // CASE 121: boolean (false)\n decoder => true, // CASE 120: boolean (true)\n readVarString, // CASE 119: string\n decoder => { // CASE 118: object<string,any>\n const len = readVarUint(decoder)\n /**\n * @type {Object<string,any>}\n */\n const obj = {}\n for (let i = 0; i < len; i++) {\n const key = readVarString(decoder)\n obj[key] = readAny(decoder)\n }\n return obj\n },\n decoder => { // CASE 117: array<any>\n const len = readVarUint(decoder)\n const arr = []\n for (let i = 0; i < len; i++) {\n arr.push(readAny(decoder))\n }\n return arr\n },\n readVarUint8Array // CASE 116: Uint8Array\n]\n\n/**\n * @param {Decoder} decoder\n */\nexport const readAny = decoder => readAnyLookupTable[127 - readUint8(decoder)](decoder)\n\n/**\n * T must not be null.\n *\n * @template T\n */\nexport class RleDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n * @param {function(Decoder):T} reader\n */\n constructor (uint8Array, reader) {\n super(uint8Array)\n /**\n * The reader\n */\n this.reader = reader\n /**\n * Current state\n * @type {T|null}\n */\n this.s = null\n this.count = 0\n }\n\n read () {\n if (this.count === 0) {\n this.s = this.reader(this)\n if (hasContent(this)) {\n this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented\n } else {\n this.count = -1 // read the current value forever\n }\n }\n this.count--\n return /** @type {T} */ (this.s)\n }\n}\n\nexport class IntDiffDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n * @param {number} start\n */\n constructor (uint8Array, start) {\n super(uint8Array)\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n }\n\n /**\n * @return {number}\n */\n read () {\n this.s += readVarInt(this)\n return this.s\n }\n}\n\nexport class RleIntDiffDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n * @param {number} start\n */\n constructor (uint8Array, start) {\n super(uint8Array)\n /**\n * Current state\n * @type {number}\n */\n this.s = start\n this.count = 0\n }\n\n /**\n * @return {number}\n */\n read () {\n if (this.count === 0) {\n this.s += readVarInt(this)\n if (hasContent(this)) {\n this.count = readVarUint(this) + 1 // see encoder implementation for the reason why this is incremented\n } else {\n this.count = -1 // read the current value forever\n }\n }\n this.count--\n return /** @type {number} */ (this.s)\n }\n}\n\nexport class UintOptRleDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n */\n constructor (uint8Array) {\n super(uint8Array)\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n read () {\n if (this.count === 0) {\n this.s = readVarInt(this)\n // if the sign is negative, we read the count too, otherwise count is 1\n const isNegative = math.isNegativeZero(this.s)\n this.count = 1\n if (isNegative) {\n this.s = -this.s\n this.count = readVarUint(this) + 2\n }\n }\n this.count--\n return /** @type {number} */ (this.s)\n }\n}\n\nexport class IncUintOptRleDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n */\n constructor (uint8Array) {\n super(uint8Array)\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n }\n\n read () {\n if (this.count === 0) {\n this.s = readVarInt(this)\n // if the sign is negative, we read the count too, otherwise count is 1\n const isNegative = math.isNegativeZero(this.s)\n this.count = 1\n if (isNegative) {\n this.s = -this.s\n this.count = readVarUint(this) + 2\n }\n }\n this.count--\n return /** @type {number} */ (this.s++)\n }\n}\n\nexport class IntDiffOptRleDecoder extends Decoder {\n /**\n * @param {Uint8Array} uint8Array\n */\n constructor (uint8Array) {\n super(uint8Array)\n /**\n * @type {number}\n */\n this.s = 0\n this.count = 0\n this.diff = 0\n }\n\n /**\n * @return {number}\n */\n read () {\n if (this.count === 0) {\n const diff = readVarInt(this)\n // if the first bit is set, we read more data\n const hasCount = diff & 1\n this.diff = math.floor(diff / 2) // shift >> 1\n this.count = 1\n if (hasCount) {\n this.count = readVarUint(this) + 2\n }\n }\n this.s += this.diff\n this.count--\n return this.s\n }\n}\n\nexport class StringDecoder {\n /**\n * @param {Uint8Array} uint8Array\n */\n constructor (uint8Array) {\n this.decoder = new UintOptRleDecoder(uint8Array)\n this.str = readVarString(this.decoder)\n /**\n * @type {number}\n */\n this.spos = 0\n }\n\n /**\n * @return {string}\n */\n read () {\n const end = this.spos + this.decoder.read()\n const res = this.str.slice(this.spos, end)\n this.spos = end\n return res\n }\n}\n", "/* eslint-env browser */\n\nexport const subtle = crypto.subtle\nexport const getRandomValues = crypto.getRandomValues.bind(crypto)\n", "/**\n * Isomorphic module for true random numbers / buffers / uuids.\n *\n * Attention: falls back to Math.random if the browser does not support crypto.\n *\n * @module random\n */\n\nimport * as math from './math.js'\nimport * as binary from './binary.js'\nimport { getRandomValues } from 'lib0/webcrypto'\n\nexport const rand = Math.random\n\nexport const uint32 = () => getRandomValues(new Uint32Array(1))[0]\n\nexport const uint53 = () => {\n const arr = getRandomValues(new Uint32Array(8))\n return (arr[0] & binary.BITS21) * (binary.BITS32 + 1) + (arr[1] >>> 0)\n}\n\n/**\n * @template T\n * @param {Array<T>} arr\n * @return {T}\n */\nexport const oneOf = arr => arr[math.floor(rand() * arr.length)]\n\n// @ts-ignore\nconst uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11\n\n/**\n * @return {string}\n */\nexport const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>\n (c ^ uint32() & 15 >> c / 4).toString(16)\n)\n", "/**\n * Utility module to work with time.\n *\n * @module time\n */\n\nimport * as metric from './metric.js'\nimport * as math from './math.js'\n\n/**\n * Return current time.\n *\n * @return {Date}\n */\nexport const getDate = () => new Date()\n\n/**\n * Return current unix time.\n *\n * @return {number}\n */\nexport const getUnixTime = Date.now\n\n/**\n * Transform time (in ms) to a human readable format. E.g. 1100 => 1.1s. 60s => 1min. .001 => 10\u03BCs.\n *\n * @param {number} d duration in milliseconds\n * @return {string} humanized approximation of time\n */\nexport const humanizeDuration = d => {\n if (d < 60000) {\n const p = metric.prefix(d, -1)\n return math.round(p.n * 100) / 100 + p.prefix + 's'\n }\n d = math.floor(d / 1000)\n const seconds = d % 60\n const minutes = math.floor(d / 60) % 60\n const hours = math.floor(d / 3600) % 24\n const days = math.floor(d / 86400)\n if (days > 0) {\n return days + 'd' + ((hours > 0 || minutes > 30) ? ' ' + (minutes > 30 ? hours + 1 : hours) + 'h' : '')\n }\n if (hours > 0) {\n /* c8 ignore next */\n return hours + 'h' + ((minutes > 0 || seconds > 30) ? ' ' + (seconds > 30 ? minutes + 1 : minutes) + 'min' : '')\n }\n return minutes + 'min' + (seconds > 0 ? ' ' + seconds + 's' : '')\n}\n", "/**\n * Utility helpers to work with promises.\n *\n * @module promise\n */\n\nimport * as time from './time.js'\n\n/**\n * @template T\n * @callback PromiseResolve\n * @param {T|PromiseLike<T>} [result]\n */\n\n/**\n * @template T\n * @param {function(PromiseResolve<T>,function(Error):void):any} f\n * @return {Promise<T>}\n */\nexport const create = f => /** @type {Promise<T>} */ (new Promise(f))\n\n/**\n * @param {function(function():void,function(Error):void):void} f\n * @return {Promise<void>}\n */\nexport const createEmpty = f => new Promise(f)\n\n/**\n * `Promise.all` wait for all promises in the array to resolve and return the result\n * @template {unknown[] | []} PS\n *\n * @param {PS} ps\n * @return {Promise<{ -readonly [P in keyof PS]: Awaited<PS[P]> }>}\n */\nexport const all = Promise.all.bind(Promise)\n\n/**\n * @param {Error} [reason]\n * @return {Promise<never>}\n */\nexport const reject = reason => Promise.reject(reason)\n\n/**\n * @template T\n * @param {T|void} res\n * @return {Promise<T|void>}\n */\nexport const resolve = res => Promise.resolve(res)\n\n/**\n * @template T\n * @param {T} res\n * @return {Promise<T>}\n */\nexport const resolveWith = res => Promise.resolve(res)\n\n/**\n * @todo Next version, reorder parameters: check, [timeout, [intervalResolution]]\n * @deprecated use untilAsync instead\n *\n * @param {number} timeout\n * @param {function():boolean} check\n * @param {number} [intervalResolution]\n * @return {Promise<void>}\n */\nexport const until = (timeout, check, intervalResolution = 10) => create((resolve, reject) => {\n const startTime = time.getUnixTime()\n const hasTimeout = timeout > 0\n const untilInterval = () => {\n if (check()) {\n clearInterval(intervalHandle)\n resolve()\n } else if (hasTimeout) {\n /* c8 ignore else */\n if (time.getUnixTime() - startTime > timeout) {\n clearInterval(intervalHandle)\n reject(new Error('Timeout'))\n }\n }\n }\n const intervalHandle = setInterval(untilInterval, intervalResolution)\n})\n\n/**\n * @param {()=>Promise<boolean>|boolean} check\n * @param {number} timeout\n * @param {number} intervalResolution\n * @return {Promise<void>}\n */\nexport const untilAsync = async (check, timeout = 0, intervalResolution = 10) => {\n const startTime = time.getUnixTime()\n const noTimeout = timeout <= 0\n // eslint-disable-next-line no-unmodified-loop-condition\n while (noTimeout || time.getUnixTime() - startTime <= timeout) {\n if (await check()) return\n await wait(intervalResolution)\n }\n throw new Error('Timeout')\n}\n\n/**\n * @param {number} timeout\n * @return {Promise<undefined>}\n */\nexport const wait = timeout => create((resolve, _reject) => setTimeout(resolve, timeout))\n\n/**\n * Checks if an object is a promise using ducktyping.\n *\n * Promises are often polyfilled, so it makes sense to add some additional guarantees if the user of this\n * library has some insane environment where global Promise objects are overwritten.\n *\n * @param {any} p\n * @return {boolean}\n */\nexport const isPromise = p => p instanceof Promise || (p && p.then && p.catch && p.finally)\n", "/**\n * Often used conditions.\n *\n * @module conditions\n */\n\n/**\n * @template T\n * @param {T|null|undefined} v\n * @return {T|null}\n */\n/* c8 ignore next */\nexport const undefinedToNull = v => v === undefined ? null : v\n", "/* eslint-env browser */\n\n/**\n * Isomorphic variable storage.\n *\n * Uses LocalStorage in the browser and falls back to in-memory storage.\n *\n * @module storage\n */\n\n/* c8 ignore start */\nclass VarStoragePolyfill {\n constructor () {\n this.map = new Map()\n }\n\n /**\n * @param {string} key\n * @param {any} newValue\n */\n setItem (key, newValue) {\n this.map.set(key, newValue)\n }\n\n /**\n * @param {string} key\n */\n getItem (key) {\n return this.map.get(key)\n }\n}\n/* c8 ignore stop */\n\n/**\n * @type {any}\n */\nlet _localStorage = new VarStoragePolyfill()\nlet usePolyfill = true\n\n/* c8 ignore start */\ntry {\n // if the same-origin rule is violated, accessing localStorage might thrown an error\n if (typeof localStorage !== 'undefined' && localStorage) {\n _localStorage = localStorage\n usePolyfill = false\n }\n} catch (e) { }\n/* c8 ignore stop */\n\n/**\n * This is basically localStorage in browser, or a polyfill in nodejs\n */\n/* c8 ignore next */\nexport const varStorage = _localStorage\n\n/**\n * A polyfill for `addEventListener('storage', event => {..})` that does nothing if the polyfill is being used.\n *\n * @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler\n * @function\n */\n/* c8 ignore next */\nexport const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler))\n\n/**\n * A polyfill for `removeEventListener('storage', event => {..})` that does nothing if the polyfill is being used.\n *\n * @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler\n * @function\n */\n/* c8 ignore next */\nexport const offChange = eventHandler => usePolyfill || removeEventListener('storage', /** @type {any} */ (eventHandler))\n", "export const EqualityTraitSymbol = Symbol('Equality')\n\n/**\n * @typedef {{ [EqualityTraitSymbol]:(other:EqualityTrait)=>boolean }} EqualityTrait\n */\n\n/**\n *\n * Utility function to compare any two objects.\n *\n * Note that it is expected that the first parameter is more specific than the latter one.\n *\n * @example js\n * class X { [traits.EqualityTraitSymbol] (other) { return other === this } }\n * class X2 { [traits.EqualityTraitSymbol] (other) { return other === this }, x2 () { return 2 } }\n * // this is fine\n * traits.equals(new X2(), new X())\n * // this is not, because the left type is less specific than the right one\n * traits.equals(new X(), new X2())\n *\n * @template {EqualityTrait} T\n * @param {NoInfer<T>} a\n * @param {T} b\n * @return {boolean}\n */\nexport const equals = (a, b) => a === b || !!a?.[EqualityTraitSymbol]?.(b) || false\n", "import * as equalityTrait from './trait/equality.js'\n\n/**\n * Utility functions for working with EcmaScript objects.\n *\n * @module object\n */\n\n/**\n * @return {Object<string,any>} obj\n */\nexport const create = () => Object.create(null)\n\n/**\n * @param {any} o\n * @return {o is { [k:string]:any }}\n */\nexport const isObject = o => typeof o === 'object'\n\n/**\n * Object.assign\n */\nexport const assign = Object.assign\n\n/**\n * @param {Object<string,any>} obj\n */\nexport const keys = Object.keys\n\n/**\n * @template V\n * @param {{[key:string]: V}} obj\n * @return {Array<V>}\n */\nexport const values = Object.values\n\n/**\n * @template V\n * @param {{[k:string]:V}} obj\n * @param {function(V,string):any} f\n */\nexport const forEach = (obj, f) => {\n for (const key in obj) {\n f(obj[key], key)\n }\n}\n\n/**\n * @todo implement mapToArray & map\n *\n * @template R\n * @param {Object<string,any>} obj\n * @param {function(any,string):R} f\n * @return {Array<R>}\n */\nexport const map = (obj, f) => {\n const results = []\n for (const key in obj) {\n results.push(f(obj[key], key))\n }\n return results\n}\n\n/**\n * @deprecated use object.size instead\n * @param {Object<string,any>} obj\n * @return {number}\n */\nexport const length = obj => keys(obj).length\n\n/**\n * @param {Object<string,any>} obj\n * @return {number}\n */\nexport const size = obj => keys(obj).length\n\n/**\n * @template {{ [key:string|number|symbol]: any }} T\n * @param {T} obj\n * @param {(v:T[keyof T],k:keyof T)=>boolean} f\n * @return {boolean}\n */\nexport const some = (obj, f) => {\n for (const key in obj) {\n if (f(obj[key], key)) {\n return true\n }\n }\n return false\n}\n\n/**\n * @param {Object|null|undefined} obj\n */\nexport const isEmpty = obj => {\n // eslint-disable-next-line no-unreachable-loop\n for (const _k in obj) {\n return false\n }\n return true\n}\n\n/**\n * @template {{ [key:string|number|symbol]: any }} T\n * @param {T} obj\n * @param {(v:T[keyof T],k:keyof T)=>boolean} f\n * @return {boolean}\n */\nexport const every = (obj, f) => {\n for (const key in obj) {\n if (!f(obj[key], key)) {\n return false\n }\n }\n return true\n}\n\n/**\n * Calls `Object.prototype.hasOwnProperty`.\n *\n * @param {any} obj\n * @param {string|number|symbol} key\n * @return {boolean}\n */\nexport const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)\n\n/**\n * @param {Object<string,any>} a\n * @param {Object<string,any>} b\n * @return {boolean}\n */\nexport const equalFlat = (a, b) => a === b || (size(a) === size(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && equalityTrait.equals(b[key], val)))\n\n/**\n * Make an object immutable. This hurts performance and is usually not needed if you perform good\n * coding practices.\n */\nexport const freeze = Object.freeze\n\n/**\n * Make an object and all its children immutable.\n * This *really* hurts performance and is usually not needed if you perform good coding practices.\n *\n * @template {any} T\n * @param {T} o\n * @return {Readonly<T>}\n */\nexport const deepFreeze = (o) => {\n for (const key in o) {\n const c = o[key]\n if (typeof c === 'object' || typeof c === 'function') {\n deepFreeze(o[key])\n }\n }\n return freeze(o)\n}\n\n/**\n * Get object property. Create T if property is undefined and set T on object.\n *\n * @function\n * @template {object} KV\n * @template {keyof KV} [K=keyof KV]\n * @param {KV} o\n * @param {K} key\n * @param {() => KV[K]} createT\n * @return {KV[K]}\n */\nexport const setIfUndefined = (o, key, createT) => hasProperty(o, key) ? o[key] : (o[key] = createT())\n", "/**\n * Common functions and function call helpers.\n *\n * @module function\n */\n\nimport * as array from './array.js'\nimport * as object from './object.js'\nimport * as equalityTrait from './trait/equality.js'\n\n/**\n * Calls all functions in `fs` with args. Only throws after all functions were called.\n *\n * @param {Array<function>} fs\n * @param {Array<any>} args\n */\nexport const callAll = (fs, args, i = 0) => {\n try {\n for (; i < fs.length; i++) {\n fs[i](...args)\n }\n } finally {\n if (i < fs.length) {\n callAll(fs, args, i + 1)\n }\n }\n}\n\nexport const nop = () => {}\n\n/**\n * @template T\n * @param {function():T} f\n * @return {T}\n */\nexport const apply = f => f()\n\n/**\n * @template A\n *\n * @param {A} a\n * @return {A}\n */\nexport const id = a => a\n\n/**\n * @template T\n *\n * @param {T} a\n * @param {T} b\n * @return {boolean}\n */\nexport const equalityStrict = (a, b) => a === b\n\n/**\n * @template T\n *\n * @param {Array<T>|object} a\n * @param {Array<T>|object} b\n * @return {boolean}\n */\nexport const equalityFlat = (a, b) => a === b || (a != null && b != null && a.constructor === b.constructor && ((array.isArray(a) && array.equalFlat(a, /** @type {Array<T>} */ (b))) || (typeof a === 'object' && object.equalFlat(a, b))))\n\n/* c8 ignore start */\n\n/**\n * @param {any} a\n * @param {any} b\n * @return {boolean}\n */\nexport const equalityDeep = (a, b) => {\n if (a === b) {\n return true\n }\n if (a == null || b == null || (a.constructor !== b.constructor && (a.constructor || Object) !== (b.constructor || Object))) {\n return false\n }\n if (a[equalityTrait.EqualityTraitSymbol] != null) {\n return a[equalityTrait.EqualityTraitSymbol](b)\n }\n switch (a.constructor) {\n case ArrayBuffer:\n a = new Uint8Array(a)\n b = new Uint8Array(b)\n // eslint-disable-next-line no-fallthrough\n case Uint8Array: {\n if (a.byteLength !== b.byteLength) {\n return false\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false\n }\n }\n break\n }\n case Set: {\n if (a.size !== b.size) {\n return false\n }\n for (const value of a) {\n if (!b.has(value)) {\n return false\n }\n }\n break\n }\n case Map: {\n if (a.size !== b.size) {\n return false\n }\n for (const key of a.keys()) {\n if (!b.has(key) || !equalityDeep(a.get(key), b.get(key))) {\n return false\n }\n }\n break\n }\n case undefined:\n case Object:\n if (object.size(a) !== object.size(b)) {\n return false\n }\n for (const key in a) {\n if (!object.hasProperty(a, key) || !equalityDeep(a[key], b[key])) {\n return false\n }\n }\n break\n case Array:\n if (a.length !== b.length) {\n return false\n }\n for (let i = 0; i < a.length; i++) {\n if (!equalityDeep(a[i], b[i])) {\n return false\n }\n }\n break\n default:\n return false\n }\n return true\n}\n\n/**\n * @template V\n * @template {V} OPTS\n *\n * @param {V} value\n * @param {Array<OPTS>} options\n */\n// @ts-ignore\nexport const isOneOf = (value, options) => options.includes(value)\n/* c8 ignore stop */\n\nexport const isArray = array.isArray\n\n/**\n * @param {any} s\n * @return {s is String}\n */\nexport const isString = (s) => s && s.constructor === String\n\n/**\n * @param {any} n\n * @return {n is Number}\n */\nexport const isNumber = n => n != null && n.constructor === Number\n\n/**\n * @template {abstract new (...args: any) => any} TYPE\n * @param {any} n\n * @param {TYPE} T\n * @return {n is InstanceType<TYPE>}\n */\nexport const is = (n, T) => n && n.constructor === T\n\n/**\n * @template {abstract new (...args: any) => any} TYPE\n * @param {TYPE} T\n */\nexport const isTemplate = (T) =>\n /**\n * @param {any} n\n * @return {n is InstanceType<TYPE>}\n **/\n n => n && n.constructor === T\n", "/**\n * Isomorphic module to work access the environment (query params, env variables).\n *\n * @module environment\n */\n\nimport * as map from './map.js'\nimport * as string from './string.js'\nimport * as conditions from './conditions.js'\nimport * as storage from './storage.js'\nimport * as f from './function.js'\n\n/* c8 ignore next 2 */\n// @ts-ignore\nexport const isNode = typeof process !== 'undefined' && process.release && /node|io\\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]'\n\n/* c8 ignore next */\nexport const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && !isNode\n/* c8 ignore next 3 */\nexport const isMac = typeof navigator !== 'undefined'\n ? /Mac/.test(navigator.platform)\n : false\n\n/**\n * @type {Map<string,string>}\n */\nlet params\nconst args = []\n\n/* c8 ignore start */\nconst computeParams = () => {\n if (params === undefined) {\n if (isNode) {\n params = map.create()\n const pargs = process.argv\n let currParamName = null\n for (let i = 0; i < pargs.length; i++) {\n const parg = pargs[i]\n if (parg[0] === '-') {\n if (currParamName !== null) {\n params.set(currParamName, '')\n }\n currParamName = parg\n } else {\n if (currParamName !== null) {\n params.set(currParamName, parg)\n currParamName = null\n } else {\n args.push(parg)\n }\n }\n }\n if (currParamName !== null) {\n params.set(currParamName, '')\n }\n // in ReactNative for example this would not be true (unless connected to the Remote Debugger)\n } else if (typeof location === 'object') {\n params = map.create(); // eslint-disable-next-line no-undef\n (location.search || '?').slice(1).split('&').forEach((kv) => {\n if (kv.length !== 0) {\n const [key, value] = kv.split('=')\n params.set(`--${string.fromCamelCase(key, '-')}`, value)\n params.set(`-${string.fromCamelCase(key, '-')}`, value)\n }\n })\n } else {\n params = map.create()\n }\n }\n return params\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} name\n * @return {boolean}\n */\n/* c8 ignore next */\nexport const hasParam = (name) => computeParams().has(name)\n\n/**\n * @param {string} name\n * @param {string} defaultVal\n * @return {string}\n */\n/* c8 ignore next 2 */\nexport const getParam = (name, defaultVal) =>\n computeParams().get(name) || defaultVal\n\n/**\n * @param {string} name\n * @return {string|null}\n */\n/* c8 ignore next 4 */\nexport const getVariable = (name) =>\n isNode\n ? conditions.undefinedToNull(process.env[name.toUpperCase().replaceAll('-', '_')])\n : conditions.undefinedToNull(storage.varStorage.getItem(name))\n\n/**\n * @param {string} name\n * @return {string|null}\n */\n/* c8 ignore next 2 */\nexport const getConf = (name) =>\n computeParams().get('--' + name) || getVariable(name)\n\n/**\n * @param {string} name\n * @return {string}\n */\n/* c8 ignore next 5 */\nexport const ensureConf = (name) => {\n const c = getConf(name)\n if (c == null) throw new Error(`Expected configuration \"${name.toUpperCase().replaceAll('-', '_')}\"`)\n return c\n}\n\n/**\n * @param {string} name\n * @return {boolean}\n */\n/* c8 ignore next 2 */\nexport const hasConf = (name) =>\n hasParam('--' + name) || getVariable(name) !== null\n\n/* c8 ignore next */\nexport const production = hasConf('production')\n\n/* c8 ignore next 2 */\nconst forceColor = isNode &&\n f.isOneOf(process.env.FORCE_COLOR, ['true', '1', '2'])\n\n/* c8 ignore start */\n/**\n * Color is enabled by default if the terminal supports it.\n *\n * Explicitly enable color using `--color` parameter\n * Disable color using `--no-color` parameter or using `NO_COLOR=1` environment variable.\n * `FORCE_COLOR=1` enables color and takes precedence over all.\n */\nexport const supportsColor = forceColor || (\n !hasParam('--no-colors') && // @todo deprecate --no-colors\n !hasConf('no-color') &&\n (!isNode || process.stdout.isTTY) && (\n !isNode ||\n hasParam('--color') ||\n getVariable('COLORTERM') !== null ||\n (getVariable('TERM') || '').includes('color')\n )\n)\n/* c8 ignore stop */\n", "/**\n * Utility functions to work with buffers (Uint8Array).\n *\n * @module buffer\n */\n\nimport * as string from './string.js'\nimport * as env from './environment.js'\nimport * as array from './array.js'\nimport * as math from './math.js'\nimport * as encoding from './encoding.js'\nimport * as decoding from './decoding.js'\n\n/**\n * @param {number} len\n */\nexport const createUint8ArrayFromLen = len => new Uint8Array(len)\n\n/**\n * Create Uint8Array with initial content from buffer\n *\n * @param {ArrayBuffer} buffer\n * @param {number} byteOffset\n * @param {number} length\n */\nexport const createUint8ArrayViewFromArrayBuffer = (buffer, byteOffset, length) => new Uint8Array(buffer, byteOffset, length)\n\n/**\n * Create Uint8Array with initial content from buffer\n *\n * @param {ArrayBuffer} buffer\n */\nexport const createUint8ArrayFromArrayBuffer = buffer => new Uint8Array(buffer)\n\n/* c8 ignore start */\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nconst toBase64Browser = bytes => {\n let s = ''\n for (let i = 0; i < bytes.byteLength; i++) {\n s += string.fromCharCode(bytes[i])\n }\n // eslint-disable-next-line no-undef\n return btoa(s)\n}\n/* c8 ignore stop */\n\n/**\n * @param {Uint8Array} bytes\n * @return {string}\n */\nconst toBase64Node = bytes => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString('base64')\n\n/* c8 ignore start */\n/**\n * @param {string} s\n * @return {Uint8Array<ArrayBuffer>}\n */\nconst fromBase64Browser = s => {\n // eslint-disable-next-line no-undef\n const a = atob(s)\n const bytes = createUint8ArrayFromLen(a.length)\n for (let i = 0; i < a.length; i++) {\n bytes[i] = a.charCodeAt(i)\n }\n return bytes\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} s\n */\nconst fromBase64Node = s => {\n const buf = Buffer.from(s, 'base64')\n return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength)\n}\n\n/* c8 ignore next */\nexport const toBase64 = env.isBrowser ? toBase64Browser : toBase64Node\n\n/* c8 ignore next */\nexport const fromBase64 = env.isBrowser ? fromBase64Browser : fromBase64Node\n\n/**\n * Implements base64url - see https://datatracker.ietf.org/doc/html/rfc4648#section-5\n * @param {Uint8Array} buf\n */\nexport const toBase64UrlEncoded = buf => toBase64(buf).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '')\n\n/**\n * @param {string} base64\n */\nexport const fromBase64UrlEncoded = base64 => fromBase64(base64.replaceAll('-', '+').replaceAll('_', '/'))\n\n/**\n * Base64 is always a more efficient choice. This exists for utility purposes only.\n *\n * @param {Uint8Array} buf\n */\nexport const toHexString = buf => array.map(buf, b => b.toString(16).padStart(2, '0')).join('')\n\n/**\n * Note: This function expects that the hex doesn't start with 0x..\n *\n * @param {string} hex\n */\nexport const fromHexString = hex => {\n const hlen = hex.length\n const buf = new Uint8Array(math.ceil(hlen / 2))\n for (let i = 0; i < hlen; i += 2) {\n buf[buf.length - i / 2 - 1] = Number.parseInt(hex.slice(hlen - i - 2, hlen - i), 16)\n }\n return buf\n}\n\n/**\n * Copy the content of an Uint8Array view to a new ArrayBuffer.\n *\n * @param {Uint8Array} uint8Array\n * @return {Uint8Array}\n */\nexport const copyUint8Array = uint8Array => {\n const newBuf = createUint8ArrayFromLen(uint8Array.byteLength)\n newBuf.set(uint8Array)\n return newBuf\n}\n\n/**\n * Encode anything as a UInt8Array. It's a pun on typescripts's `any` type.\n * See encoding.writeAny for more information.\n *\n * @param {any} data\n * @return {Uint8Array}\n */\nexport const encodeAny = data =>\n encoding.encode(encoder => encoding.writeAny(encoder, data))\n\n/**\n * Decode an any-encoded value.\n *\n * @param {Uint8Array} buf\n * @return {any}\n */\nexport const decodeAny = buf => decoding.readAny(decoding.createDecoder(buf))\n\n/**\n * Shift Byte Array {N} bits to the left. Does not expand byte array.\n *\n * @param {Uint8Array} bs\n * @param {number} N should be in the range of [0-7]\n */\nexport const shiftNBitsLeft = (bs, N) => {\n if (N === 0) return bs\n bs = new Uint8Array(bs)\n bs[0] <<= N\n for (let i = 1; i < bs.length; i++) {\n bs[i - 1] |= bs[i] >>> (8 - N)\n bs[i] <<= N\n }\n return bs\n}\n", "/**\n * Working with value pairs.\n *\n * @module pair\n */\n\n/**\n * @template L,R\n */\nexport class Pair {\n /**\n * @param {L} left\n * @param {R} right\n */\n constructor (left, right) {\n this.left = left\n this.right = right\n }\n}\n\n/**\n * @template L,R\n * @param {L} left\n * @param {R} right\n * @return {Pair<L,R>}\n */\nexport const create = (left, right) => new Pair(left, right)\n\n/**\n * @template L,R\n * @param {R} right\n * @param {L} left\n * @return {Pair<L,R>}\n */\nexport const createReversed = (right, left) => new Pair(left, right)\n\n/**\n * @template L,R\n * @param {Array<Pair<L,R>>} arr\n * @param {function(L, R):any} f\n */\nexport const forEach = (arr, f) => arr.forEach(p => f(p.left, p.right))\n\n/**\n * @template L,R,X\n * @param {Array<Pair<L,R>>} arr\n * @param {function(L, R):X} f\n * @return {Array<X>}\n */\nexport const map = (arr, f) => arr.map(p => f(p.left, p.right))\n", "/**\n * Fast Pseudo Random Number Generators.\n *\n * Given a seed a PRNG generates a sequence of numbers that cannot be reasonably predicted.\n * Two PRNGs must generate the same random sequence of numbers if given the same seed.\n *\n * @module prng\n */\n\nimport * as binary from './binary.js'\nimport { fromCharCode, fromCodePoint } from './string.js'\nimport * as math from './math.js'\nimport { Xoroshiro128plus } from './prng/Xoroshiro128plus.js'\nimport * as buffer from './buffer.js'\n\n/**\n * Description of the function\n * @callback generatorNext\n * @return {number} A random float in the cange of [0,1)\n */\n\n/**\n * A random type generator.\n *\n * @typedef {Object} PRNG\n * @property {generatorNext} next Generate new number\n */\nexport const DefaultPRNG = Xoroshiro128plus\n\n/**\n * Create a Xoroshiro128plus Pseudo-Random-Number-Generator.\n * This is the fastest full-period generator passing BigCrush without systematic failures.\n * But there are more PRNGs available in ./PRNG/.\n *\n * @param {number} seed A positive 32bit integer. Do not use negative numbers.\n * @return {PRNG}\n */\nexport const create = seed => new DefaultPRNG(seed)\n\n/**\n * Generates a single random bool.\n *\n * @param {PRNG} gen A random number generator.\n * @return {Boolean} A random boolean\n */\nexport const bool = gen => (gen.next() >= 0.5)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const int53 = (gen, min, max) => math.floor(gen.next() * (max + 1 - min) + min)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const uint53 = (gen, min, max) => math.abs(int53(gen, min, max))\n\n/**\n * Generates a random integer with 32 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const int32 = (gen, min, max) => math.floor(gen.next() * (max + 1 - min) + min)\n\n/**\n * Generates a random integer with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive).\n * @return {Number} A random integer on [min, max]\n */\nexport const uint32 = (gen, min, max) => int32(gen, min, max) >>> 0\n\n/**\n * @deprecated\n * Optimized version of prng.int32. It has the same precision as prng.int32, but should be preferred when\n * openaring on smaller ranges.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Number} min The lower bound of the allowed return values (inclusive).\n * @param {Number} max The upper bound of the allowed return values (inclusive). The max inclusive number is `binary.BITS31-1`\n * @return {Number} A random integer on [min, max]\n */\nexport const int31 = (gen, min, max) => int32(gen, min, max)\n\n/**\n * Generates a random real on [0, 1) with 53 bit resolution.\n *\n * @param {PRNG} gen A random number generator.\n * @return {Number} A random real number on [0, 1).\n */\nexport const real53 = gen => gen.next() // (((gen.next() >>> 5) * binary.BIT26) + (gen.next() >>> 6)) / MAX_SAFE_INTEGER\n\n/**\n * Generates a random character from char code 32 - 126. I.e. Characters, Numbers, special characters, and Space:\n *\n * @param {PRNG} gen A random number generator.\n * @return {string}\n *\n * (Space)!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_`abcdefghijklmnopqrstuvwxyz{|}~\n */\nexport const char = gen => fromCharCode(int31(gen, 32, 126))\n\n/**\n * @param {PRNG} gen\n * @return {string} A single letter (a-z)\n */\nexport const letter = gen => fromCharCode(int31(gen, 97, 122))\n\n/**\n * @param {PRNG} gen\n * @param {number} [minLen=0]\n * @param {number} [maxLen=20]\n * @return {string} A random word (0-20 characters) without spaces consisting of letters (a-z)\n */\nexport const word = (gen, minLen = 0, maxLen = 20) => {\n const len = int31(gen, minLen, maxLen)\n let str = ''\n for (let i = 0; i < len; i++) {\n str += letter(gen)\n }\n return str\n}\n\n/**\n * TODO: this function produces invalid runes. Does not cover all of utf16!!\n *\n * @param {PRNG} gen\n * @return {string}\n */\nexport const utf16Rune = gen => {\n const codepoint = int31(gen, 0, 256)\n return fromCodePoint(codepoint)\n}\n\n/**\n * @param {PRNG} gen\n * @param {number} [maxlen = 20]\n */\nexport const utf16String = (gen, maxlen = 20) => {\n const len = int31(gen, 0, maxlen)\n let str = ''\n for (let i = 0; i < len; i++) {\n str += utf16Rune(gen)\n }\n return str\n}\n\n/**\n * Returns one element of a given array.\n *\n * @param {PRNG} gen A random number generator.\n * @param {Array<T>} array Non empty Array of possible values.\n * @return {T} One of the values of the supplied Array.\n * @template T\n */\nexport const oneOf = (gen, array) => array[int31(gen, 0, array.length - 1)]\n\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint8Array<ArrayBuffer>}\n */\nexport const uint8Array = (gen, len) => {\n const buf = buffer.createUint8ArrayFromLen(len)\n for (let i = 0; i < buf.length; i++) {\n buf[i] = int32(gen, 0, binary.BITS8)\n }\n return buf\n}\n\n/* c8 ignore start */\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint16Array}\n */\nexport const uint16Array = (gen, len) => new Uint16Array(uint8Array(gen, len * 2).buffer)\n\n/**\n * @param {PRNG} gen\n * @param {number} len\n * @return {Uint32Array}\n */\nexport const uint32Array = (gen, len) => new Uint32Array(uint8Array(gen, len * 4).buffer)\n/* c8 ignore stop */\n", "/**\n * @experimental WIP\n *\n * Simple & efficient schemas for your data.\n */\n\nimport * as obj from './object.js'\nimport * as arr from './array.js'\nimport * as error from './error.js'\nimport * as env from './environment.js'\nimport * as equalityTraits from './trait/equality.js'\nimport * as fun from './function.js'\nimport * as string from './string.js'\nimport * as prng from './prng.js'\nimport * as number from './number.js'\n\n/**\n * @typedef {string|number|bigint|boolean|null|undefined|symbol} Primitive\n */\n\n/**\n * @typedef {{ [k:string|number|symbol]: any }} AnyObject\n */\n\n/**\n * @template T\n * @typedef {T extends Schema<infer X> ? X : T} Unwrap\n */\n\n/**\n * @template T\n * @typedef {T extends Schema<infer X> ? X : T} TypeOf\n */\n\n/**\n * @template {readonly unknown[]} T\n * @typedef {T extends readonly [Schema<infer First>, ...infer Rest] ? [First, ...UnwrapArray<Rest>] : [] } UnwrapArray\n */\n\n/**\n * @template T\n * @typedef {T extends Schema<infer S> ? Schema<S> : never} CastToSchema\n */\n\n/**\n * @template {unknown[]} Arr\n * @typedef {Arr extends [...unknown[], infer L] ? L : never} TupleLast\n */\n\n/**\n * @template {unknown[]} Arr\n * @typedef {Arr extends [...infer Fs, unknown] ? Fs : never} TuplePop\n */\n\n/**\n * @template {readonly unknown[]} T\n * @typedef {T extends []\n * ? {}\n * : T extends [infer First]\n * ? First\n * : T extends [infer First, ...infer Rest]\n * ? First & Intersect<Rest>\n * : never\n * } Intersect\n */\n\nconst schemaSymbol = Symbol('0schema')\n\nexport class ValidationError {\n constructor () {\n /**\n * Reverse errors\n * @type {Array<{ path: string?, expected: string, has: string, message: string? }>}\n */\n this._rerrs = []\n }\n\n /**\n * @param {string?} path\n * @param {string} expected\n * @param {string} has\n * @param {string?} message\n */\n extend (path, expected, has, message = null) {\n this._rerrs.push({ path, expected, has, message })\n }\n\n toString () {\n const s = []\n for (let i = this._rerrs.length - 1; i > 0; i--) {\n const r = this._rerrs[i]\n /* c8 ignore next */\n s.push(string.repeat(' ', (this._rerrs.length - i) * 2) + `${r.path != null ? `[${r.path}] ` : ''}${r.has} doesn't match ${r.expected}. ${r.message}`)\n }\n return s.join('\\n')\n }\n}\n\n/**\n * @param {any} a\n * @param {any} b\n * @return {boolean}\n */\nconst shapeExtends = (a, b) => {\n if (a === b) return true\n if (a == null || b == null || a.constructor !== b.constructor) return false\n if (a[equalityTraits.EqualityTraitSymbol]) return equalityTraits.equals(a, b) // last resort: check equality (do this before array and obj check which don't implement the equality trait)\n if (arr.isArray(a)) {\n return arr.every(a, aitem =>\n arr.some(b, bitem => shapeExtends(aitem, bitem))\n )\n } else if (obj.isObject(a)) {\n return obj.every(a, (aitem, akey) =>\n shapeExtends(aitem, b[akey])\n )\n }\n /* c8 ignore next */\n return false\n}\n\n/**\n * @template T\n * @implements {equalityTraits.EqualityTrait}\n */\nexport class Schema {\n // this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore\n /**\n * If true, the more things are added to the shape the more objects this schema will accept (e.g.\n * union). By default, the more objects are added, the the fewer objects this schema will accept.\n * @protected\n */\n static _dilutes = false\n\n /**\n * @param {Schema<any>} other\n */\n extends (other) {\n let [a, b] = [/** @type {any} */(this).shape, /** @type {any} */ (other).shape]\n if (/** @type {typeof Schema<any>} */ (this.constructor)._dilutes) [b, a] = [a, b]\n return shapeExtends(a, b)\n }\n\n /**\n * Overwrite this when necessary. By default, we only check the `shape` property which every shape\n * should have.\n * @param {Schema<any>} other\n */\n equals (other) {\n // @ts-ignore\n return this.constructor === other.constructor && fun.equalityDeep(this.shape, other.shape)\n }\n\n [schemaSymbol] () { return true }\n\n /**\n * @param {object} other\n */\n [equalityTraits.EqualityTraitSymbol] (other) {\n return this.equals(/** @type {any} */ (other))\n }\n\n /**\n * Use `schema.validate(obj)` with a typed parameter that is already of typed to be an instance of\n * Schema. Validate will check the structure of the parameter and return true iff the instance\n * really is an instance of Schema.\n *\n * @param {T} o\n * @return {boolean}\n */\n validate (o) {\n return this.check(o)\n }\n\n /* c8 ignore start */\n /**\n * Similar to validate, but this method accepts untyped parameters.\n *\n * @param {any} _o\n * @param {ValidationError} [_err]\n * @return {_o is T}\n */\n check (_o, _err) {\n error.methodUnimplemented()\n }\n /* c8 ignore stop */\n\n /**\n * @type {Schema<T?>}\n */\n get nullable () {\n // @ts-ignore\n return $union(this, $null)\n }\n\n /**\n * @type {$Optional<Schema<T>>}\n */\n get optional () {\n return new $Optional(/** @type {Schema<T>} */ (this))\n }\n\n /**\n * Cast a variable to a specific type. Returns the casted value, or throws an exception otherwise.\n * Use this if you know that the type is of a specific type and you just want to convince the type\n * system.\n *\n * **Do not rely on these error messages!**\n * Performs an assertion check only if not in a production environment.\n *\n * @template OO\n * @param {OO} o\n * @return {Extract<OO, T> extends never ? T : (OO extends Array<never> ? T : Extract<OO,T>)}\n */\n cast (o) {\n assert(o, this)\n return /** @type {any} */ (o)\n }\n\n /**\n * EXPECTO PATRONUM!! \uD83E\uDE84\n * This function protects against type errors. Though it may not work in the real world.\n *\n * \"After all this time?\"\n * \"Always.\" - Snape, talking about type safety\n *\n * Ensures that a variable is a a specific type. Returns the value, or throws an exception if the assertion check failed.\n * Use this if you know that the type is of a specific type and you just want to convince the type\n * system.\n *\n * Can be useful when defining lambdas: `s.lambda(s.$number, s.$void).expect((n) => n + 1)`\n *\n * **Do not rely on these error messages!**\n * Performs an assertion check if not in a production environment.\n *\n * @param {T} o\n * @return {o extends T ? T : never}\n */\n expect (o) {\n assert(o, this)\n return o\n }\n}\n\n/**\n * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} Constr\n * @typedef {Constr extends ((...args:any[]) => infer T) ? T : (Constr extends (new (...args:any[]) => any) ? InstanceType<Constr> : never)} Instance\n */\n\n/**\n * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C\n * @extends {Schema<Instance<C>>}\n */\nexport class $ConstructedBy extends Schema {\n /**\n * @param {C} c\n * @param {((o:Instance<C>)=>boolean)|null} check\n */\n constructor (c, check) {\n super()\n this.shape = c\n this._c = check\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is C extends ((...args:any[]) => infer T) ? T : (C extends (new (...args:any[]) => any) ? InstanceType<C> : never)} o\n */\n check (o, err = undefined) {\n const c = o?.constructor === this.shape && (this._c == null || this._c(o))\n /* c8 ignore next */\n !c && err?.extend(null, this.shape.name, o?.constructor.name, o?.constructor !== this.shape ? 'Constructor match failed' : 'Check failed')\n return c\n }\n}\n\n/**\n * @template {(new (...args:any[]) => any) | ((...args:any[]) => any)} C\n * @param {C} c\n * @param {((o:Instance<C>) => boolean)|null} check\n * @return {CastToSchema<$ConstructedBy<C>>}\n */\nexport const $constructedBy = (c, check = null) => new $ConstructedBy(c, check)\nexport const $$constructedBy = $constructedBy($ConstructedBy)\n\n/**\n * Check custom properties on any object. You may want to overwrite the generated Schema<any>.\n *\n * @extends {Schema<any>}\n */\nexport class $Custom extends Schema {\n /**\n * @param {(o:any) => boolean} check\n */\n constructor (check) {\n super()\n /**\n * @type {(o:any) => boolean}\n */\n this.shape = check\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} err\n * @return {o is any}\n */\n check (o, err) {\n const c = this.shape(o)\n /* c8 ignore next */\n !c && err?.extend(null, 'custom prop', o?.constructor.name, 'failed to check custom prop')\n return c\n }\n}\n\n/**\n * @param {(o:any) => boolean} check\n * @return {Schema<any>}\n */\nexport const $custom = (check) => new $Custom(check)\nexport const $$custom = $constructedBy($Custom)\n\n/**\n * @template {Primitive} T\n * @extends {Schema<T>}\n */\nexport class $Literal extends Schema {\n /**\n * @param {Array<T>} literals\n */\n constructor (literals) {\n super()\n this.shape = literals\n }\n\n /**\n *\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is T}\n */\n check (o, err) {\n const c = this.shape.some(a => a === o)\n /* c8 ignore next */\n !c && err?.extend(null, this.shape.join(' | '), o.toString())\n return c\n }\n}\n\n/**\n * @template {Primitive[]} T\n * @param {T} literals\n * @return {CastToSchema<$Literal<T[number]>>}\n */\nexport const $literal = (...literals) => new $Literal(literals)\nexport const $$literal = $constructedBy($Literal)\n\n/**\n * @template {Array<string|Schema<string|number>>} Ts\n * @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\n */\n\n/**\n * @param {string} str\n * @return {string}\n */\nconst _regexEscape = /** @type {any} */ (RegExp).escape || /** @type {(str:string) => string} */ (str =>\n str.replace(/[().|&,$^[\\]]/g, s => '\\\\' + s)\n)\n\n/**\n * @param {string|Schema<any>} s\n * @return {string[]}\n */\nconst _schemaStringTemplateToRegex = s => {\n if ($string.check(s)) {\n return [_regexEscape(s)]\n }\n if ($$literal.check(s)) {\n return /** @type {Array<string|number>} */ (s.shape).map(v => v + '')\n }\n if ($$number.check(s)) {\n return ['[+-]?\\\\d+.?\\\\d*']\n }\n if ($$string.check(s)) {\n return ['.*']\n }\n if ($$union.check(s)) {\n return s.shape.map(_schemaStringTemplateToRegex).flat(1)\n }\n /* c8 ignore next 2 */\n // unexpected schema structure (only supports unions and string in literal types)\n error.unexpectedCase()\n}\n\n/**\n * @template {Array<string|Schema<string|number>>} T\n * @extends {Schema<CastStringTemplateArgsToTemplate<T>>}\n */\nexport class $StringTemplate extends Schema {\n /**\n * @param {T} shape\n */\n constructor (shape) {\n super()\n this.shape = shape\n this._r = new RegExp('^' + shape.map(_schemaStringTemplateToRegex).map(opts => `(${opts.join('|')})`).join('') + '$')\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is CastStringTemplateArgsToTemplate<T>}\n */\n check (o, err) {\n const c = this._r.exec(o) != null\n /* c8 ignore next */\n !c && err?.extend(null, this._r.toString(), o.toString(), 'String doesn\\'t match string template.')\n return c\n }\n}\n\n/**\n * @template {Array<string|Schema<string|number>>} T\n * @param {T} literals\n * @return {CastToSchema<$StringTemplate<T>>}\n */\nexport const $stringTemplate = (...literals) => new $StringTemplate(literals)\nexport const $$stringTemplate = $constructedBy($StringTemplate)\n\nconst isOptionalSymbol = Symbol('optional')\n/**\n * @template {Schema<any>} S\n * @extends Schema<Unwrap<S>|undefined>\n */\nclass $Optional extends Schema {\n /**\n * @param {S} shape\n */\n constructor (shape) {\n super()\n this.shape = shape\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is (Unwrap<S>|undefined)}\n */\n check (o, err) {\n const c = o === undefined || this.shape.check(o)\n /* c8 ignore next */\n !c && err?.extend(null, 'undefined (optional)', '()')\n return c\n }\n\n get [isOptionalSymbol] () { return true }\n}\nexport const $$optional = $constructedBy($Optional)\n\n/**\n * @extends Schema<never>\n */\nclass $Never extends Schema {\n /**\n * @param {any} _o\n * @param {ValidationError} [err]\n * @return {_o is never}\n */\n check (_o, err) {\n /* c8 ignore next */\n err?.extend(null, 'never', typeof _o)\n return false\n }\n}\n\n/**\n * @type {Schema<never>}\n */\nexport const $never = new $Never()\nexport const $$never = $constructedBy($Never)\n\n/**\n * @template {{ [key: string|symbol|number]: Schema<any> }} S\n * @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\n */\n\n/**\n * @template {{[key:string|symbol|number]: Schema<any>}} S\n * @extends {Schema<$ObjectToType<S>>}\n */\nexport class $Object extends Schema {\n /**\n * @param {S} shape\n * @param {boolean} partial\n */\n constructor (shape, partial = false) {\n super()\n /**\n * @type {S}\n */\n this.shape = shape\n this._isPartial = partial\n }\n\n static _dilutes = true\n\n /**\n * @type {Schema<Partial<$ObjectToType<S>>>}\n */\n get partial () {\n return new $Object(this.shape, true)\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} err\n * @return {o is $ObjectToType<S>}\n */\n check (o, err) {\n if (o == null) {\n /* c8 ignore next */\n err?.extend(null, 'object', 'null')\n return false\n }\n return obj.every(this.shape, (vv, vk) => {\n const c = (this._isPartial && !obj.hasProperty(o, vk)) || vv.check(o[vk], err)\n !c && err?.extend(vk.toString(), vv.toString(), typeof o[vk], 'Object property does not match')\n return c\n })\n }\n}\n\n/**\n * @template S\n * @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\n */\n\n// I used an explicit type annotation instead of $ObjectToType, so that the user doesn't see the\n// weird type definitions when inspecting type definions.\n/**\n * @template {{ [key:string|symbol|number]: Schema<any> }} S\n * @param {S} def\n * @return {_ObjectDefToSchema<S> extends Schema<infer S> ? Schema<{ [K in keyof S]: S[K] }> : never}\n */\nexport const $object = def => /** @type {any} */ (new $Object(def))\nexport const $$object = $constructedBy($Object)\n/**\n * @type {Schema<{[key:string]: any}>}\n */\nexport const $objectAny = $custom(o => o != null && (o.constructor === Object || o.constructor == null))\n\n/**\n * @template {Schema<string|number|symbol>} Keys\n * @template {Schema<any>} Values\n * @extends {Schema<{ [key in Unwrap<Keys>]: Unwrap<Values> }>}\n */\nexport class $Record extends Schema {\n /**\n * @param {Keys} keys\n * @param {Values} values\n */\n constructor (keys, values) {\n super()\n this.shape = {\n keys, values\n }\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} err\n * @return {o is { [key in Unwrap<Keys>]: Unwrap<Values> }}\n */\n check (o, err) {\n return o != null && obj.every(o, (vv, vk) => {\n const ck = this.shape.keys.check(vk, err)\n /* c8 ignore next */\n !ck && err?.extend(vk + '', 'Record', typeof o, ck ? 'Key doesn\\'t match schema' : 'Value doesn\\'t match value')\n return ck && this.shape.values.check(vv, err)\n })\n }\n}\n\n/**\n * @template {Schema<string|number|symbol>} Keys\n * @template {Schema<any>} Values\n * @param {Keys} keys\n * @param {Values} values\n * @return {CastToSchema<$Record<Keys,Values>>}\n */\nexport const $record = (keys, values) => new $Record(keys, values)\nexport const $$record = $constructedBy($Record)\n\n/**\n * @template {Schema<any>[]} S\n * @extends {Schema<{ [Key in keyof S]: S[Key] extends Schema<infer Type> ? Type : never }>}\n */\nexport class $Tuple extends Schema {\n /**\n * @param {S} shape\n */\n constructor (shape) {\n super()\n this.shape = shape\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} err\n * @return {o is { [K in keyof S]: S[K] extends Schema<infer Type> ? Type : never }}\n */\n check (o, err) {\n return o != null && obj.every(this.shape, (vv, vk) => {\n const c = /** @type {Schema<any>} */ (vv).check(o[vk], err)\n /* c8 ignore next */\n !c && err?.extend(vk.toString(), 'Tuple', typeof vv)\n return c\n })\n }\n}\n\n/**\n * @template {Array<Schema<any>>} T\n * @param {T} def\n * @return {CastToSchema<$Tuple<T>>}\n */\nexport const $tuple = (...def) => new $Tuple(def)\nexport const $$tuple = $constructedBy($Tuple)\n\n/**\n * @template {Schema<any>} S\n * @extends {Schema<Array<S extends Schema<infer T> ? T : never>>}\n */\nexport class $Array extends Schema {\n /**\n * @param {Array<S>} v\n */\n constructor (v) {\n super()\n /**\n * @type {Schema<S extends Schema<infer T> ? T : never>}\n */\n this.shape = v.length === 1 ? v[0] : new $Union(v)\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is Array<S extends Schema<infer T> ? T : never>} o\n */\n check (o, err) {\n const c = arr.isArray(o) && arr.every(o, oi => this.shape.check(oi))\n /* c8 ignore next */\n !c && err?.extend(null, 'Array', '')\n return c\n }\n}\n\n/**\n * @template {Array<Schema<any>>} T\n * @param {T} def\n * @return {Schema<Array<T extends Array<Schema<infer S>> ? S : never>>}\n */\nexport const $array = (...def) => new $Array(def)\nexport const $$array = $constructedBy($Array)\n/**\n * @type {Schema<Array<any>>}\n */\nexport const $arrayAny = $custom(o => arr.isArray(o))\n\n/**\n * @template T\n * @extends {Schema<T>}\n */\nexport class $InstanceOf extends Schema {\n /**\n * @param {new (...args:any) => T} constructor\n * @param {((o:T) => boolean)|null} check\n */\n constructor (constructor, check) {\n super()\n this.shape = constructor\n this._c = check\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} err\n * @return {o is T}\n */\n check (o, err) {\n const c = o instanceof this.shape && (this._c == null || this._c(o))\n /* c8 ignore next */\n !c && err?.extend(null, this.shape.name, o?.constructor.name)\n return c\n }\n}\n\n/**\n * @template T\n * @param {new (...args:any) => T} c\n * @param {((o:T) => boolean)|null} check\n * @return {Schema<T>}\n */\nexport const $instanceOf = (c, check = null) => new $InstanceOf(c, check)\nexport const $$instanceOf = $constructedBy($InstanceOf)\n\nexport const $$schema = $instanceOf(Schema)\n\n/**\n * @template {Schema<any>[]} Args\n * @typedef {(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>} _LArgsToLambdaDef\n */\n\n/**\n * @template {Array<Schema<any>>} Args\n * @extends {Schema<_LArgsToLambdaDef<Args>>}\n */\nexport class $Lambda extends Schema {\n /**\n * @param {Args} args\n */\n constructor (args) {\n super()\n this.len = args.length - 1\n this.args = $tuple(...args.slice(-1))\n this.res = args[this.len]\n }\n\n /**\n * @param {any} f\n * @param {ValidationError} err\n * @return {f is _LArgsToLambdaDef<Args>}\n */\n check (f, err) {\n const c = f.constructor === Function && f.length <= this.len\n /* c8 ignore next */\n !c && err?.extend(null, 'function', typeof f)\n return c\n }\n}\n\n/**\n * @template {Schema<any>[]} Args\n * @param {Args} args\n * @return {Schema<(...args:UnwrapArray<TuplePop<Args>>)=>Unwrap<TupleLast<Args>>>}\n */\nexport const $lambda = (...args) => new $Lambda(args.length > 0 ? args : [$void])\nexport const $$lambda = $constructedBy($Lambda)\n\n/**\n * @type {Schema<Function>}\n */\nexport const $function = $custom(o => typeof o === 'function')\n\n/**\n * @template {Array<Schema<any>>} T\n * @extends {Schema<Intersect<UnwrapArray<T>>>}\n */\nexport class $Intersection extends Schema {\n /**\n * @param {T} v\n */\n constructor (v) {\n super()\n /**\n * @type {T}\n */\n this.shape = v\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is Intersect<UnwrapArray<T>>}\n */\n check (o, err) {\n // @ts-ignore\n const c = arr.every(this.shape, check => check.check(o, err))\n /* c8 ignore next */\n !c && err?.extend(null, 'Intersectinon', typeof o)\n return c\n }\n}\n\n/**\n * @template {Schema<any>[]} T\n * @param {T} def\n * @return {CastToSchema<$Intersection<T>>}\n */\nexport const $intersect = (...def) => new $Intersection(def)\nexport const $$intersect = $constructedBy($Intersection, o => o.shape.length > 0) // Intersection with length=0 is considered \"any\"\n\n/**\n * @template S\n * @extends {Schema<S>}\n */\nexport class $Union extends Schema {\n static _dilutes = true\n\n /**\n * @param {Array<Schema<S>>} v\n */\n constructor (v) {\n super()\n this.shape = v\n }\n\n /**\n * @param {any} o\n * @param {ValidationError} [err]\n * @return {o is S}\n */\n check (o, err) {\n const c = arr.some(this.shape, (vv) => vv.check(o, err))\n err?.extend(null, 'Union', typeof o)\n return c\n }\n}\n\n/**\n * @template {Array<any>} T\n * @param {T} schemas\n * @return {CastToSchema<$Union<Unwrap<ReadSchema<T>>>>}\n */\nexport const $union = (...schemas) => schemas.findIndex($s => $$union.check($s)) >= 0\n ? $union(...schemas.map($s => $($s)).map($s => $$union.check($s) ? $s.shape : [$s]).flat(1))\n : (schemas.length === 1\n ? schemas[0]\n : new $Union(schemas))\nexport const $$union = /** @type {Schema<$Union<any>>} */ ($constructedBy($Union))\n\nconst _t = () => true\n/**\n * @type {Schema<any>}\n */\nexport const $any = $custom(_t)\nexport const $$any = /** @type {Schema<Schema<any>>} */ ($constructedBy($Custom, o => o.shape === _t))\n\n/**\n * @type {Schema<bigint>}\n */\nexport const $bigint = $custom(o => typeof o === 'bigint')\nexport const $$bigint = /** @type {Schema<Schema<BigInt>>} */ ($custom(o => o === $bigint))\n\n/**\n * @type {Schema<symbol>}\n */\nexport const $symbol = $custom(o => typeof o === 'symbol')\nexport const $$symbol = /** @type {Schema<Schema<Symbol>>} */ ($custom(o => o === $symbol))\n\n/**\n * @type {Schema<number>}\n */\nexport const $number = $custom(o => typeof o === 'number')\nexport const $$number = /** @type {Schema<Schema<number>>} */ ($custom(o => o === $number))\n\n/**\n * @type {Schema<string>}\n */\nexport const $string = $custom(o => typeof o === 'string')\nexport const $$string = /** @type {Schema<Schema<string>>} */ ($custom(o => o === $string))\n\n/**\n * @type {Schema<boolean>}\n */\nexport const $boolean = $custom(o => typeof o === 'boolean')\nexport const $$boolean = /** @type {Schema<Schema<Boolean>>} */ ($custom(o => o === $boolean))\n\n/**\n * @type {Schema<undefined>}\n */\nexport const $undefined = $literal(undefined)\nexport const $$undefined = /** @type {Schema<Schema<undefined>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === undefined))\n\n/**\n * @type {Schema<void>}\n */\nexport const $void = $literal(undefined)\nexport const $$void = /** @type {Schema<Schema<void>>} */ ($$undefined)\n\nexport const $null = $literal(null)\nexport const $$null = /** @type {Schema<Schema<null>>} */ ($constructedBy($Literal, o => o.shape.length === 1 && o.shape[0] === null))\n\nexport const $uint8Array = $constructedBy(Uint8Array)\nexport const $$uint8Array = /** @type {Schema<Schema<Uint8Array>>} */ ($constructedBy($ConstructedBy, o => o.shape === Uint8Array))\n\n/**\n * @type {Schema<Primitive>}\n */\nexport const $primitive = $union($number, $string, $null, $undefined, $bigint, $boolean, $symbol)\n\n/**\n * @typedef {JSON[]} JSONArray\n */\n/**\n * @typedef {Primitive|JSONArray|{ [key:string]:JSON }} JSON\n */\n/**\n * @type {Schema<null|number|string|boolean|JSON[]|{[key:string]:JSON}>}\n */\nexport const $json = (() => {\n const $jsonArr = /** @type {$Array<$any>} */ ($array($any))\n const $jsonRecord = /** @type {$Record<$string,$any>} */ ($record($string, $any))\n const $json = $union($number, $string, $null, $boolean, $jsonArr, $jsonRecord)\n $jsonArr.shape = $json\n $jsonRecord.shape.values = $json\n return $json\n})()\n\n/**\n * @template {any} IN\n * @typedef {IN extends Schema<any> ? IN\n * : (IN extends string|number|boolean|null ? Schema<IN>\n * : (IN extends new (...args:any[])=>any ? Schema<InstanceType<IN>>\n * : (IN extends any[] ? Schema<{ [K in keyof IN]: Unwrap<ReadSchema<IN[K]>> }[number]>\n * : (IN extends object ? (_ObjectDefToSchema<{[K in keyof IN]:ReadSchema<IN[K]>}> extends Schema<infer S> ? Schema<{ [K in keyof S]: S[K] }> : never)\n * : never)\n * )\n * )\n * )\n * } ReadSchemaOld\n */\n\n/**\n * @template {any} IN\n * @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]\n * ? Schema<\n * (Schemas extends Schema<infer S> ? S : never)\n * | Primitives\n * | (Constructors extends new (...args:any[])=>any ? InstanceType<Constructors> : never)\n * | (Arrs extends any[] ? { [K in keyof Arrs]: Unwrap<ReadSchema<Arrs[K]>> }[number] : never)\n * | (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)>\n * : never\n * } ReadSchema\n */\n\n/**\n * @typedef {ReadSchema<{x:42}|{y:99}|Schema<string>|[1,2,{}]>} Q\n */\n\n/**\n * @template IN\n * @param {IN} o\n * @return {ReadSchema<IN>}\n */\nexport const $ = o => {\n if ($$schema.check(o)) {\n return /** @type {any} */ (o)\n } else if ($objectAny.check(o)) {\n /**\n * @type {any}\n */\n const o2 = {}\n for (const k in o) {\n o2[k] = $(o[k])\n }\n return /** @type {any} */ ($object(o2))\n } else if ($arrayAny.check(o)) {\n return /** @type {any} */ ($union(...o.map($)))\n } else if ($primitive.check(o)) {\n return /** @type {any} */ ($literal(o))\n } else if ($function.check(o)) {\n return /** @type {any} */ ($constructedBy(/** @type {any} */ (o)))\n }\n /* c8 ignore next */\n error.unexpectedCase()\n}\n\n/* c8 ignore start */\n/**\n * Assert that a variable is of this specific type.\n * The assertion check is only performed in non-production environments.\n *\n * @type {<T>(o:any,schema:Schema<T>) => asserts o is T}\n */\nexport const assert = env.production\n ? () => {}\n : (o, schema) => {\n const err = new ValidationError()\n if (!schema.check(o, err)) {\n throw error.create(`Expected value to be of type ${schema.constructor.name}.\\n${err.toString()}`)\n }\n }\n/* c8 ignore end */\n\n/**\n * @template In\n * @template Out\n * @typedef {{ if: Schema<In>, h: (o:In,state?:any)=>Out }} Pattern\n */\n\n/**\n * @template {Pattern<any,any>} P\n * @template In\n * @typedef {ReturnType<Extract<P,Pattern<In extends number ? number : (In extends string ? string : In),any>>['h']>} PatternMatchResult\n */\n\n/**\n * @todo move this to separate library\n * @template {any} [State=undefined]\n * @template {Pattern<any,any>} [Patterns=never]\n */\nexport class PatternMatcher {\n /**\n * @param {Schema<State>} [$state]\n */\n constructor ($state) {\n /**\n * @type {Array<Patterns>}\n */\n this.patterns = []\n this.$state = $state\n }\n\n /**\n * @template P\n * @template R\n * @param {P} pattern\n * @param {(o:NoInfer<Unwrap<ReadSchema<P>>>,s:State)=>R} handler\n * @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}\n */\n if (pattern, handler) {\n // @ts-ignore\n this.patterns.push({ if: $(pattern), h: handler })\n // @ts-ignore\n return this\n }\n\n /**\n * @template R\n * @param {(o:any,s:State)=>R} h\n */\n else (h) {\n return this.if($any, h)\n }\n\n /**\n * @return {State extends undefined\n * ? <In extends Unwrap<Patterns['if']>>(o:In,state?:undefined)=>PatternMatchResult<Patterns,In>\n * : <In extends Unwrap<Patterns['if']>>(o:In,state:State)=>PatternMatchResult<Patterns,In>}\n */\n done () {\n // @ts-ignore\n return /** @type {any} */ (o, s) => {\n for (let i = 0; i < this.patterns.length; i++) {\n const p = this.patterns[i]\n if (p.if.check(o)) {\n // @ts-ignore\n return p.h(o, s)\n }\n }\n throw error.create('Unhandled pattern')\n }\n }\n}\n\n/**\n * @template [State=undefined]\n * @param {State} [state]\n * @return {PatternMatcher<State extends undefined ? undefined : Unwrap<ReadSchema<State>>>}\n */\nexport const match = state => new PatternMatcher(/** @type {any} */ (state))\n\n/**\n * Helper function to generate a (non-exhaustive) sample set from a gives schema.\n *\n * @type {<T>(o:T,gen:prng.PRNG)=>T}\n */\nconst _random = /** @type {any} */ (match(/** @type {Schema<prng.PRNG>} */ ($any))\n .if($$number, (_o, gen) => prng.int53(gen, number.MIN_SAFE_INTEGER, number.MAX_SAFE_INTEGER))\n .if($$string, (_o, gen) => prng.word(gen))\n .if($$boolean, (_o, gen) => prng.bool(gen))\n .if($$bigint, (_o, gen) => BigInt(prng.int53(gen, number.MIN_SAFE_INTEGER, number.MAX_SAFE_INTEGER)))\n .if($$union, (o, gen) => random(gen, prng.oneOf(gen, o.shape)))\n .if($$object, (o, gen) => {\n /**\n * @type {any}\n */\n const res = {}\n for (const k in o.shape) {\n let prop = o.shape[k]\n if ($$optional.check(prop)) {\n if (prng.bool(gen)) { continue }\n prop = prop.shape\n }\n res[k] = _random(prop, gen)\n }\n return res\n })\n .if($$array, (o, gen) => {\n const arr = []\n const n = prng.int32(gen, 0, 42)\n for (let i = 0; i < n; i++) {\n arr.push(random(gen, o.shape))\n }\n return arr\n })\n .if($$literal, (o, gen) => {\n return prng.oneOf(gen, o.shape)\n })\n .if($$null, (o, gen) => {\n return null\n })\n .if($$lambda, (o, gen) => {\n const res = random(gen, o.res)\n return () => res\n })\n .if($$any, (o, gen) => random(gen, prng.oneOf(gen, [\n $number, $string, $null, $undefined, $bigint, $boolean,\n $array($number),\n $record($union('a', 'b', 'c'), $number)\n ])))\n .if($$record, (o, gen) => {\n /**\n * @type {any}\n */\n const res = {}\n const keysN = prng.int53(gen, 0, 3)\n for (let i = 0; i < keysN; i++) {\n const key = random(gen, o.shape.keys)\n const val = random(gen, o.shape.values)\n res[key] = val\n }\n return res\n })\n .done())\n\n/**\n * @template S\n * @param {prng.PRNG} gen\n * @param {S} schema\n * @return {Unwrap<ReadSchema<S>>}\n */\nexport const random = (gen, schema) => /** @type {any} */ (_random($(schema), gen))\n", "/* eslint-env browser */\n\n/**\n * Utility module to work with the DOM.\n *\n * @module dom\n */\n\nimport * as pair from './pair.js'\nimport * as map from './map.js'\nimport * as $ from './schema.js'\n\n/* c8 ignore start */\n/**\n * @type {Document}\n */\nexport const doc = /** @type {Document} */ (typeof document !== 'undefined' ? document : {})\n\n/**\n * @param {string} name\n * @return {HTMLElement}\n */\nexport const createElement = name => doc.createElement(name)\n\n/**\n * @return {DocumentFragment}\n */\nexport const createDocumentFragment = () => doc.createDocumentFragment()\n\n/**\n * @type {$.Schema<DocumentFragment>}\n */\nexport const $fragment = $.$custom(el => el.nodeType === DOCUMENT_FRAGMENT_NODE)\n\n/**\n * @param {string} text\n * @return {Text}\n */\nexport const createTextNode = text => doc.createTextNode(text)\n\nexport const domParser = /** @type {DOMParser} */ (typeof DOMParser !== 'undefined' ? new DOMParser() : null)\n\n/**\n * @param {HTMLElement} el\n * @param {string} name\n * @param {Object} opts\n */\nexport const emitCustomEvent = (el, name, opts) => el.dispatchEvent(new CustomEvent(name, opts))\n\n/**\n * @param {Element} el\n * @param {Array<pair.Pair<string,string|boolean>>} attrs Array of key-value pairs\n * @return {Element}\n */\nexport const setAttributes = (el, attrs) => {\n pair.forEach(attrs, (key, value) => {\n if (value === false) {\n el.removeAttribute(key)\n } else if (value === true) {\n el.setAttribute(key, '')\n } else {\n // @ts-ignore\n el.setAttribute(key, value)\n }\n })\n return el\n}\n\n/**\n * @param {Element} el\n * @param {Map<string, string>} attrs Array of key-value pairs\n * @return {Element}\n */\nexport const setAttributesMap = (el, attrs) => {\n attrs.forEach((value, key) => { el.setAttribute(key, value) })\n return el\n}\n\n/**\n * @param {Array<Node>|HTMLCollection} children\n * @return {DocumentFragment}\n */\nexport const fragment = children => {\n const fragment = createDocumentFragment()\n for (let i = 0; i < children.length; i++) {\n appendChild(fragment, children[i])\n }\n return fragment\n}\n\n/**\n * @param {Element} parent\n * @param {Array<Node>} nodes\n * @return {Element}\n */\nexport const append = (parent, nodes) => {\n appendChild(parent, fragment(nodes))\n return parent\n}\n\n/**\n * @param {HTMLElement} el\n */\nexport const remove = el => el.remove()\n\n/**\n * @param {EventTarget} el\n * @param {string} name\n * @param {EventListener} f\n */\nexport const addEventListener = (el, name, f) => el.addEventListener(name, f)\n\n/**\n * @param {EventTarget} el\n * @param {string} name\n * @param {EventListener} f\n */\nexport const removeEventListener = (el, name, f) => el.removeEventListener(name, f)\n\n/**\n * @param {Node} node\n * @param {Array<pair.Pair<string,EventListener>>} listeners\n * @return {Node}\n */\nexport const addEventListeners = (node, listeners) => {\n pair.forEach(listeners, (name, f) => addEventListener(node, name, f))\n return node\n}\n\n/**\n * @param {Node} node\n * @param {Array<pair.Pair<string,EventListener>>} listeners\n * @return {Node}\n */\nexport const removeEventListeners = (node, listeners) => {\n pair.forEach(listeners, (name, f) => removeEventListener(node, name, f))\n return node\n}\n\n/**\n * @param {string} name\n * @param {Array<pair.Pair<string,string>|pair.Pair<string,boolean>>} attrs Array of key-value pairs\n * @param {Array<Node>} children\n * @return {Element}\n */\nexport const element = (name, attrs = [], children = []) =>\n append(setAttributes(createElement(name), attrs), children)\n\n/**\n * @type {$.Schema<Element>}\n */\nexport const $element = $.$custom(el => el.nodeType === ELEMENT_NODE)\n\n/**\n * @param {number} width\n * @param {number} height\n */\nexport const canvas = (width, height) => {\n const c = /** @type {HTMLCanvasElement} */ (createElement('canvas'))\n c.height = height\n c.width = width\n return c\n}\n\n/**\n * @param {string} t\n * @return {Text}\n */\nexport const text = createTextNode\n\n/**\n * @type {$.Schema<Text>}\n */\nexport const $text = $.$custom(el => el.nodeType === TEXT_NODE)\n\n/**\n * @param {pair.Pair<string,string>} pair\n */\nexport const pairToStyleString = pair => `${pair.left}:${pair.right};`\n\n/**\n * @param {Array<pair.Pair<string,string>>} pairs\n * @return {string}\n */\nexport const pairsToStyleString = pairs => pairs.map(pairToStyleString).join('')\n\n/**\n * @param {Map<string,string>} m\n * @return {string}\n */\nexport const mapToStyleString = m => map.map(m, (value, key) => `${key}:${value};`).join('')\n\n/**\n * @todo should always query on a dom element\n *\n * @param {HTMLElement|ShadowRoot} el\n * @param {string} query\n * @return {HTMLElement | null}\n */\nexport const querySelector = (el, query) => el.querySelector(query)\n\n/**\n * @param {HTMLElement|ShadowRoot} el\n * @param {string} query\n * @return {NodeListOf<HTMLElement>}\n */\nexport const querySelectorAll = (el, query) => el.querySelectorAll(query)\n\n/**\n * @param {string} id\n * @return {HTMLElement}\n */\nexport const getElementById = id => /** @type {HTMLElement} */ (doc.getElementById(id))\n\n/**\n * @param {string} html\n * @return {HTMLElement}\n */\nconst _parse = html => domParser.parseFromString(`<html><body>${html}</body></html>`, 'text/html').body\n\n/**\n * @param {string} html\n * @return {DocumentFragment}\n */\nexport const parseFragment = html => fragment(/** @type {any} */ (_parse(html).childNodes))\n\n/**\n * @param {string} html\n * @return {HTMLElement}\n */\nexport const parseElement = html => /** @type HTMLElement */ (_parse(html).firstElementChild)\n\n/**\n * @param {HTMLElement} oldEl\n * @param {HTMLElement|DocumentFragment} newEl\n */\nexport const replaceWith = (oldEl, newEl) => oldEl.replaceWith(newEl)\n\n/**\n * @param {HTMLElement} parent\n * @param {HTMLElement} el\n * @param {Node|null} ref\n * @return {HTMLElement}\n */\nexport const insertBefore = (parent, el, ref) => parent.insertBefore(el, ref)\n\n/**\n * @param {Node} parent\n * @param {Node} child\n * @return {Node}\n */\nexport const appendChild = (parent, child) => parent.appendChild(child)\n\nexport const ELEMENT_NODE = doc.ELEMENT_NODE\nexport const TEXT_NODE = doc.TEXT_NODE\nexport const CDATA_SECTION_NODE = doc.CDATA_SECTION_NODE\nexport const COMMENT_NODE = doc.COMMENT_NODE\nexport const DOCUMENT_NODE = doc.DOCUMENT_NODE\nexport const DOCUMENT_TYPE_NODE = doc.DOCUMENT_TYPE_NODE\nexport const DOCUMENT_FRAGMENT_NODE = doc.DOCUMENT_FRAGMENT_NODE\n\n/**\n * @type {$.Schema<Node>}\n */\nexport const $node = $.$custom(el => el.nodeType === DOCUMENT_NODE)\n\n/**\n * @param {any} node\n * @param {number} type\n */\nexport const checkNodeType = (node, type) => node.nodeType === type\n\n/**\n * @param {Node} parent\n * @param {HTMLElement} child\n */\nexport const isParentOf = (parent, child) => {\n let p = child.parentNode\n while (p && p !== parent) {\n p = p.parentNode\n }\n return p === parent\n}\n/* c8 ignore stop */\n", "/**\n * Utility module to work with EcmaScript Symbols.\n *\n * @module symbol\n */\n\n/**\n * Return fresh symbol.\n */\nexport const create = Symbol\n\n/**\n * @param {any} s\n * @return {boolean}\n */\nexport const isSymbol = s => typeof s === 'symbol'\n", "import * as symbol from './symbol.js'\nimport * as time from './time.js'\nimport * as env from './environment.js'\nimport * as func from './function.js'\nimport * as json from './json.js'\n\nexport const BOLD = symbol.create()\nexport const UNBOLD = symbol.create()\nexport const BLUE = symbol.create()\nexport const GREY = symbol.create()\nexport const GREEN = symbol.create()\nexport const RED = symbol.create()\nexport const PURPLE = symbol.create()\nexport const ORANGE = symbol.create()\nexport const UNCOLOR = symbol.create()\n\n/* c8 ignore start */\n/**\n * @param {Array<undefined|string|Symbol|Object|number|function():any>} args\n * @return {Array<string|object|number|undefined>}\n */\nexport const computeNoColorLoggingArgs = args => {\n if (args.length === 1 && args[0]?.constructor === Function) {\n args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]())\n }\n const strBuilder = []\n const logArgs = []\n // try with formatting until we find something unsupported\n let i = 0\n for (; i < args.length; i++) {\n const arg = args[i]\n if (arg === undefined) {\n break\n } else if (arg.constructor === String || arg.constructor === Number) {\n strBuilder.push(arg)\n } else if (arg.constructor === Object) {\n break\n }\n }\n if (i > 0) {\n // create logArgs with what we have so far\n logArgs.push(strBuilder.join(''))\n }\n // append the rest\n for (; i < args.length; i++) {\n const arg = args[i]\n if (!(arg instanceof Symbol)) {\n logArgs.push(arg)\n }\n }\n return logArgs\n}\n/* c8 ignore stop */\n\nconst loggingColors = [GREEN, PURPLE, ORANGE, BLUE]\nlet nextColor = 0\nlet lastLoggingTime = time.getUnixTime()\n\n/* c8 ignore start */\n/**\n * @param {function(...any):void} _print\n * @param {string} moduleName\n * @return {function(...any):void}\n */\nexport const createModuleLogger = (_print, moduleName) => {\n const color = loggingColors[nextColor]\n const debugRegexVar = env.getVariable('log')\n const doLogging = debugRegexVar !== null &&\n (debugRegexVar === '*' || debugRegexVar === 'true' ||\n new RegExp(debugRegexVar, 'gi').test(moduleName))\n nextColor = (nextColor + 1) % loggingColors.length\n moduleName += ': '\n return !doLogging\n ? func.nop\n : (...args) => {\n if (args.length === 1 && args[0]?.constructor === Function) {\n args = args[0]()\n }\n const timeNow = time.getUnixTime()\n const timeDiff = timeNow - lastLoggingTime\n lastLoggingTime = timeNow\n _print(\n color,\n moduleName,\n UNCOLOR,\n ...args.map((arg) => {\n if (arg != null && arg.constructor === Uint8Array) {\n arg = Array.from(arg)\n }\n const t = typeof arg\n switch (t) {\n case 'string':\n case 'symbol':\n return arg\n default: {\n return json.stringify(arg)\n }\n }\n }),\n color,\n ' +' + timeDiff + 'ms'\n )\n }\n}\n/* c8 ignore stop */\n", "/**\n * Isomorphic logging module with support for colors!\n *\n * @module logging\n */\n\nimport * as env from './environment.js'\nimport * as set from './set.js'\nimport * as pair from './pair.js'\nimport * as dom from './dom.js'\nimport * as json from './json.js'\nimport * as map from './map.js'\nimport * as eventloop from './eventloop.js'\nimport * as math from './math.js'\nimport * as common from './logging.common.js'\n\nexport { BOLD, UNBOLD, BLUE, GREY, GREEN, RED, PURPLE, ORANGE, UNCOLOR } from './logging.common.js'\n\n/**\n * @type {Object<Symbol,pair.Pair<string,string>>}\n */\nconst _browserStyleMap = {\n [common.BOLD]: pair.create('font-weight', 'bold'),\n [common.UNBOLD]: pair.create('font-weight', 'normal'),\n [common.BLUE]: pair.create('color', 'blue'),\n [common.GREEN]: pair.create('color', 'green'),\n [common.GREY]: pair.create('color', 'grey'),\n [common.RED]: pair.create('color', 'red'),\n [common.PURPLE]: pair.create('color', 'purple'),\n [common.ORANGE]: pair.create('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate\n [common.UNCOLOR]: pair.create('color', 'black')\n}\n\n/**\n * @param {Array<string|Symbol|Object|number|function():any>} args\n * @return {Array<string|object|number>}\n */\n/* c8 ignore start */\nconst computeBrowserLoggingArgs = (args) => {\n if (args.length === 1 && args[0]?.constructor === Function) {\n args = /** @type {Array<string|Symbol|Object|number>} */ (/** @type {[function]} */ (args)[0]())\n }\n const strBuilder = []\n const styles = []\n const currentStyle = map.create()\n /**\n * @type {Array<string|Object|number>}\n */\n let logArgs = []\n // try with formatting until we find something unsupported\n let i = 0\n for (; i < args.length; i++) {\n const arg = args[i]\n // @ts-ignore\n const style = _browserStyleMap[arg]\n if (style !== undefined) {\n currentStyle.set(style.left, style.right)\n } else {\n if (arg === undefined) {\n break\n }\n if (arg.constructor === String || arg.constructor === Number) {\n const style = dom.mapToStyleString(currentStyle)\n if (i > 0 || style.length > 0) {\n strBuilder.push('%c' + arg)\n styles.push(style)\n } else {\n strBuilder.push(arg)\n }\n } else {\n break\n }\n }\n }\n if (i > 0) {\n // create logArgs with what we have so far\n logArgs = styles\n logArgs.unshift(strBuilder.join(''))\n }\n // append the rest\n for (; i < args.length; i++) {\n const arg = args[i]\n if (!(arg instanceof Symbol)) {\n logArgs.push(arg)\n }\n }\n return logArgs\n}\n/* c8 ignore stop */\n\n/* c8 ignore start */\nconst computeLoggingArgs = env.supportsColor\n ? computeBrowserLoggingArgs\n : common.computeNoColorLoggingArgs\n/* c8 ignore stop */\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const print = (...args) => {\n console.log(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.print(args))\n}\n\n/* c8 ignore start */\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const warn = (...args) => {\n console.warn(...computeLoggingArgs(args))\n args.unshift(common.ORANGE)\n vconsoles.forEach((vc) => vc.print(args))\n}\n/* c8 ignore stop */\n\n/**\n * @param {Error} err\n */\n/* c8 ignore start */\nexport const printError = (err) => {\n console.error(err)\n vconsoles.forEach((vc) => vc.printError(err))\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} url image location\n * @param {number} height height of the image in pixel\n */\n/* c8 ignore start */\nexport const printImg = (url, height) => {\n if (env.isBrowser) {\n console.log(\n '%c ',\n `font-size: ${height}px; background-size: contain; background-repeat: no-repeat; background-image: url(${url})`\n )\n // console.log('%c ', `font-size: ${height}x; background: url(${url}) no-repeat;`)\n }\n vconsoles.forEach((vc) => vc.printImg(url, height))\n}\n/* c8 ignore stop */\n\n/**\n * @param {string} base64\n * @param {number} height\n */\n/* c8 ignore next 2 */\nexport const printImgBase64 = (base64, height) =>\n printImg(`data:image/gif;base64,${base64}`, height)\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const group = (...args) => {\n console.group(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.group(args))\n}\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n */\nexport const groupCollapsed = (...args) => {\n console.groupCollapsed(...computeLoggingArgs(args))\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.groupCollapsed(args))\n}\n\nexport const groupEnd = () => {\n console.groupEnd()\n /* c8 ignore next */\n vconsoles.forEach((vc) => vc.groupEnd())\n}\n\n/**\n * @param {function():Node} createNode\n */\n/* c8 ignore next 2 */\nexport const printDom = (createNode) =>\n vconsoles.forEach((vc) => vc.printDom(createNode()))\n\n/**\n * @param {HTMLCanvasElement} canvas\n * @param {number} height\n */\n/* c8 ignore next 2 */\nexport const printCanvas = (canvas, height) =>\n printImg(canvas.toDataURL(), height)\n\nexport const vconsoles = set.create()\n\n/**\n * @param {Array<string|Symbol|Object|number>} args\n * @return {Array<Element>}\n */\n/* c8 ignore start */\nconst _computeLineSpans = (args) => {\n const spans = []\n const currentStyle = new Map()\n // try with formatting until we find something unsupported\n let i = 0\n for (; i < args.length; i++) {\n let arg = args[i]\n // @ts-ignore\n const style = _browserStyleMap[arg]\n if (style !== undefined) {\n currentStyle.set(style.left, style.right)\n } else {\n if (arg === undefined) {\n arg = 'undefined '\n }\n if (arg.constructor === String || arg.constructor === Number) {\n // @ts-ignore\n const span = dom.element('span', [\n pair.create('style', dom.mapToStyleString(currentStyle))\n ], [dom.text(arg.toString())])\n if (span.innerHTML === '') {\n span.innerHTML = '&nbsp;'\n }\n spans.push(span)\n } else {\n break\n }\n }\n }\n // append the rest\n for (; i < args.length; i++) {\n let content = args[i]\n if (!(content instanceof Symbol)) {\n if (content.constructor !== String && content.constructor !== Number) {\n content = ' ' + json.stringify(content) + ' '\n }\n spans.push(\n dom.element('span', [], [dom.text(/** @type {string} */ (content))])\n )\n }\n }\n return spans\n}\n/* c8 ignore stop */\n\nconst lineStyle =\n 'font-family:monospace;border-bottom:1px solid #e2e2e2;padding:2px;'\n\n/* c8 ignore start */\nexport class VConsole {\n /**\n * @param {Element} dom\n */\n constructor (dom) {\n this.dom = dom\n /**\n * @type {Element}\n */\n this.ccontainer = this.dom\n this.depth = 0\n vconsoles.add(this)\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n * @param {boolean} collapsed\n */\n group (args, collapsed = false) {\n eventloop.enqueue(() => {\n const triangleDown = dom.element('span', [\n pair.create('hidden', collapsed),\n pair.create('style', 'color:grey;font-size:120%;')\n ], [dom.text('\u25BC')])\n const triangleRight = dom.element('span', [\n pair.create('hidden', !collapsed),\n pair.create('style', 'color:grey;font-size:125%;')\n ], [dom.text('\u25B6')])\n const content = dom.element(\n 'div',\n [pair.create(\n 'style',\n `${lineStyle};padding-left:${this.depth * 10}px`\n )],\n [triangleDown, triangleRight, dom.text(' ')].concat(\n _computeLineSpans(args)\n )\n )\n const nextContainer = dom.element('div', [\n pair.create('hidden', collapsed)\n ])\n const nextLine = dom.element('div', [], [content, nextContainer])\n dom.append(this.ccontainer, [nextLine])\n this.ccontainer = nextContainer\n this.depth++\n // when header is clicked, collapse/uncollapse container\n dom.addEventListener(content, 'click', (_event) => {\n nextContainer.toggleAttribute('hidden')\n triangleDown.toggleAttribute('hidden')\n triangleRight.toggleAttribute('hidden')\n })\n })\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n */\n groupCollapsed (args) {\n this.group(args, true)\n }\n\n groupEnd () {\n eventloop.enqueue(() => {\n if (this.depth > 0) {\n this.depth--\n // @ts-ignore\n this.ccontainer = this.ccontainer.parentElement.parentElement\n }\n })\n }\n\n /**\n * @param {Array<string|Symbol|Object|number>} args\n */\n print (args) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [\n dom.element('div', [\n pair.create(\n 'style',\n `${lineStyle};padding-left:${this.depth * 10}px`\n )\n ], _computeLineSpans(args))\n ])\n })\n }\n\n /**\n * @param {Error} err\n */\n printError (err) {\n this.print([common.RED, common.BOLD, err.toString()])\n }\n\n /**\n * @param {string} url\n * @param {number} height\n */\n printImg (url, height) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [\n dom.element('img', [\n pair.create('src', url),\n pair.create('height', `${math.round(height * 1.5)}px`)\n ])\n ])\n })\n }\n\n /**\n * @param {Node} node\n */\n printDom (node) {\n eventloop.enqueue(() => {\n dom.append(this.ccontainer, [node])\n })\n }\n\n destroy () {\n eventloop.enqueue(() => {\n vconsoles.delete(this)\n })\n }\n}\n/* c8 ignore stop */\n\n/**\n * @param {Element} dom\n */\n/* c8 ignore next */\nexport const createVConsole = (dom) => new VConsole(dom)\n\n/**\n * @param {string} moduleName\n * @return {function(...any):void}\n */\nexport const createModuleLogger = (moduleName) => common.createModuleLogger(print, moduleName)\n", "/**\n * Utility module to create and manipulate Iterators.\n *\n * @module iterator\n */\n\n/**\n * @template T,R\n * @param {Iterator<T>} iterator\n * @param {function(T):R} f\n * @return {IterableIterator<R>}\n */\nexport const mapIterator = (iterator, f) => ({\n [Symbol.iterator] () {\n return this\n },\n // @ts-ignore\n next () {\n const r = iterator.next()\n return { value: r.done ? undefined : f(r.value), done: r.done }\n }\n})\n\n/**\n * @template T\n * @param {function():IteratorResult<T>} next\n * @return {IterableIterator<T>}\n */\nexport const createIterator = next => ({\n /**\n * @return {IterableIterator<T>}\n */\n [Symbol.iterator] () {\n return this\n },\n // @ts-ignore\n next\n})\n\n/**\n * @template T\n * @param {Iterator<T>} iterator\n * @param {function(T):boolean} filter\n */\nexport const iteratorFilter = (iterator, filter) => createIterator(() => {\n let res\n do {\n res = iterator.next()\n } while (!res.done && !filter(res.value))\n return res\n})\n\n/**\n * @template T,M\n * @param {Iterator<T>} iterator\n * @param {function(T):M} fmap\n */\nexport const iteratorMap = (iterator, fmap) => createIterator(() => {\n const { done, value } = iterator.next()\n return { done, value: done ? undefined : fmap(value) }\n})\n", "import { ObservableV2 } from 'lib0/observable'\n\nimport {\n Doc // eslint-disable-line\n} from '../internals.js'\n\n/**\n * This is an abstract interface that all Connectors should implement to keep them interchangeable.\n *\n * @note This interface is experimental and it is not advised to actually inherit this class.\n * It just serves as typing information.\n *\n * @extends {ObservableV2<any>}\n */\nexport class AbstractConnector extends ObservableV2 {\n /**\n * @param {Doc} ydoc\n * @param {any} awareness\n */\n constructor (ydoc, awareness) {\n super()\n this.doc = ydoc\n this.awareness = awareness\n }\n}\n", "import {\n findIndexSS,\n getState,\n splitItem,\n iterateStructs,\n UpdateEncoderV2,\n DSDecoderV1, DSEncoderV1, DSDecoderV2, DSEncoderV2, Item, GC, StructStore, Transaction, ID // eslint-disable-line\n} from '../internals.js'\n\nimport * as array from 'lib0/array'\nimport * as math from 'lib0/math'\nimport * as map from 'lib0/map'\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\n\nexport class DeleteItem {\n /**\n * @param {number} clock\n * @param {number} len\n */\n constructor (clock, len) {\n /**\n * @type {number}\n */\n this.clock = clock\n /**\n * @type {number}\n */\n this.len = len\n }\n}\n\n/**\n * We no longer maintain a DeleteStore. DeleteSet is a temporary object that is created when needed.\n * - When created in a transaction, it must only be accessed after sorting, and merging\n * - This DeleteSet is send to other clients\n * - We do not create a DeleteSet when we send a sync message. The DeleteSet message is created directly from StructStore\n * - We read a DeleteSet as part of a sync/update message. In this case the DeleteSet is already sorted and merged.\n */\nexport class DeleteSet {\n constructor () {\n /**\n * @type {Map<number,Array<DeleteItem>>}\n */\n this.clients = new Map()\n }\n}\n\n/**\n * Iterate over all structs that the DeleteSet gc's.\n *\n * @param {Transaction} transaction\n * @param {DeleteSet} ds\n * @param {function(GC|Item):void} f\n *\n * @function\n */\nexport const iterateDeletedStructs = (transaction, ds, f) =>\n ds.clients.forEach((deletes, clientid) => {\n const structs = /** @type {Array<GC|Item>} */ (transaction.doc.store.clients.get(clientid))\n if (structs != null) {\n const lastStruct = structs[structs.length - 1]\n const clockState = lastStruct.id.clock + lastStruct.length\n for (let i = 0, del = deletes[i]; i < deletes.length && del.clock < clockState; del = deletes[++i]) {\n iterateStructs(transaction, structs, del.clock, del.len, f)\n }\n }\n })\n\n/**\n * @param {Array<DeleteItem>} dis\n * @param {number} clock\n * @return {number|null}\n *\n * @private\n * @function\n */\nexport const findIndexDS = (dis, clock) => {\n let left = 0\n let right = dis.length - 1\n while (left <= right) {\n const midindex = math.floor((left + right) / 2)\n const mid = dis[midindex]\n const midclock = mid.clock\n if (midclock <= clock) {\n if (clock < midclock + mid.len) {\n return midindex\n }\n left = midindex + 1\n } else {\n right = midindex - 1\n }\n }\n return null\n}\n\n/**\n * @param {DeleteSet} ds\n * @param {ID} id\n * @return {boolean}\n *\n * @private\n * @function\n */\nexport const isDeleted = (ds, id) => {\n const dis = ds.clients.get(id.client)\n return dis !== undefined && findIndexDS(dis, id.clock) !== null\n}\n\n/**\n * @param {DeleteSet} ds\n *\n * @private\n * @function\n */\nexport const sortAndMergeDeleteSet = ds => {\n ds.clients.forEach(dels => {\n dels.sort((a, b) => a.clock - b.clock)\n // merge items without filtering or splicing the array\n // i is the current pointer\n // j refers to the current insert position for the pointed item\n // try to merge dels[i] into dels[j-1] or set dels[j]=dels[i]\n let i, j\n for (i = 1, j = 1; i < dels.length; i++) {\n const left = dels[j - 1]\n const right = dels[i]\n if (left.clock + left.len >= right.clock) {\n dels[j - 1] = new DeleteItem(left.clock, math.max(left.len, right.clock + right.len - left.clock))\n } else {\n if (j < i) {\n dels[j] = right\n }\n j++\n }\n }\n dels.length = j\n })\n}\n\n/**\n * @param {Array<DeleteSet>} dss\n * @return {DeleteSet} A fresh DeleteSet\n */\nexport const mergeDeleteSets = dss => {\n const merged = new DeleteSet()\n for (let dssI = 0; dssI < dss.length; dssI++) {\n dss[dssI].clients.forEach((delsLeft, client) => {\n if (!merged.clients.has(client)) {\n // Write all missing keys from current ds and all following.\n // If merged already contains `client` current ds has already been added.\n /**\n * @type {Array<DeleteItem>}\n */\n const dels = delsLeft.slice()\n for (let i = dssI + 1; i < dss.length; i++) {\n array.appendTo(dels, dss[i].clients.get(client) || [])\n }\n merged.clients.set(client, dels)\n }\n })\n }\n sortAndMergeDeleteSet(merged)\n return merged\n}\n\n/**\n * @param {DeleteSet} ds\n * @param {number} client\n * @param {number} clock\n * @param {number} length\n *\n * @private\n * @function\n */\nexport const addToDeleteSet = (ds, client, clock, length) => {\n map.setIfUndefined(ds.clients, client, () => /** @type {Array<DeleteItem>} */ ([])).push(new DeleteItem(clock, length))\n}\n\nexport const createDeleteSet = () => new DeleteSet()\n\n/**\n * @param {StructStore} ss\n * @return {DeleteSet} Merged and sorted DeleteSet\n *\n * @private\n * @function\n */\nexport const createDeleteSetFromStructStore = ss => {\n const ds = createDeleteSet()\n ss.clients.forEach((structs, client) => {\n /**\n * @type {Array<DeleteItem>}\n */\n const dsitems = []\n for (let i = 0; i < structs.length; i++) {\n const struct = structs[i]\n if (struct.deleted) {\n const clock = struct.id.clock\n let len = struct.length\n if (i + 1 < structs.length) {\n for (let next = structs[i + 1]; i + 1 < structs.length && next.deleted; next = structs[++i + 1]) {\n len += next.length\n }\n }\n dsitems.push(new DeleteItem(clock, len))\n }\n }\n if (dsitems.length > 0) {\n ds.clients.set(client, dsitems)\n }\n })\n return ds\n}\n\n/**\n * @param {DSEncoderV1 | DSEncoderV2} encoder\n * @param {DeleteSet} ds\n *\n * @private\n * @function\n */\nexport const writeDeleteSet = (encoder, ds) => {\n encoding.writeVarUint(encoder.restEncoder, ds.clients.size)\n\n // Ensure that the delete set is written in a deterministic order\n array.from(ds.clients.entries())\n .sort((a, b) => b[0] - a[0])\n .forEach(([client, dsitems]) => {\n encoder.resetDsCurVal()\n encoding.writeVarUint(encoder.restEncoder, client)\n const len = dsitems.length\n encoding.writeVarUint(encoder.restEncoder, len)\n for (let i = 0; i < len; i++) {\n const item = dsitems[i]\n encoder.writeDsClock(item.clock)\n encoder.writeDsLen(item.len)\n }\n })\n}\n\n/**\n * @param {DSDecoderV1 | DSDecoderV2} decoder\n * @return {DeleteSet}\n *\n * @private\n * @function\n */\nexport const readDeleteSet = decoder => {\n const ds = new DeleteSet()\n const numClients = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < numClients; i++) {\n decoder.resetDsCurVal()\n const client = decoding.readVarUint(decoder.restDecoder)\n const numberOfDeletes = decoding.readVarUint(decoder.restDecoder)\n if (numberOfDeletes > 0) {\n const dsField = map.setIfUndefined(ds.clients, client, () => /** @type {Array<DeleteItem>} */ ([]))\n for (let i = 0; i < numberOfDeletes; i++) {\n dsField.push(new DeleteItem(decoder.readDsClock(), decoder.readDsLen()))\n }\n }\n }\n return ds\n}\n\n/**\n * @todo YDecoder also contains references to String and other Decoders. Would make sense to exchange YDecoder.toUint8Array for YDecoder.DsToUint8Array()..\n */\n\n/**\n * @param {DSDecoderV1 | DSDecoderV2} decoder\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @return {Uint8Array|null} Returns a v2 update containing all deletes that couldn't be applied yet; or null if all deletes were applied successfully.\n *\n * @private\n * @function\n */\nexport const readAndApplyDeleteSet = (decoder, transaction, store) => {\n const unappliedDS = new DeleteSet()\n const numClients = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < numClients; i++) {\n decoder.resetDsCurVal()\n const client = decoding.readVarUint(decoder.restDecoder)\n const numberOfDeletes = decoding.readVarUint(decoder.restDecoder)\n const structs = store.clients.get(client) || []\n const state = getState(store, client)\n for (let i = 0; i < numberOfDeletes; i++) {\n const clock = decoder.readDsClock()\n const clockEnd = clock + decoder.readDsLen()\n if (clock < state) {\n if (state < clockEnd) {\n addToDeleteSet(unappliedDS, client, state, clockEnd - state)\n }\n let index = findIndexSS(structs, clock)\n /**\n * We can ignore the case of GC and Delete structs, because we are going to skip them\n * @type {Item}\n */\n // @ts-ignore\n let struct = structs[index]\n // split the first item if necessary\n if (!struct.deleted && struct.id.clock < clock) {\n structs.splice(index + 1, 0, splitItem(transaction, struct, clock - struct.id.clock))\n index++ // increase we now want to use the next struct\n }\n while (index < structs.length) {\n // @ts-ignore\n struct = structs[index++]\n if (struct.id.clock < clockEnd) {\n if (!struct.deleted) {\n if (clockEnd < struct.id.clock + struct.length) {\n structs.splice(index, 0, splitItem(transaction, struct, clockEnd - struct.id.clock))\n }\n struct.delete(transaction)\n }\n } else {\n break\n }\n }\n } else {\n addToDeleteSet(unappliedDS, client, clock, clockEnd - clock)\n }\n }\n }\n if (unappliedDS.clients.size > 0) {\n const ds = new UpdateEncoderV2()\n encoding.writeVarUint(ds.restEncoder, 0) // encode 0 structs\n writeDeleteSet(ds, unappliedDS)\n return ds.toUint8Array()\n }\n return null\n}\n\n/**\n * @param {DeleteSet} ds1\n * @param {DeleteSet} ds2\n */\nexport const equalDeleteSets = (ds1, ds2) => {\n if (ds1.clients.size !== ds2.clients.size) return false\n for (const [client, deleteItems1] of ds1.clients.entries()) {\n const deleteItems2 = /** @type {Array<import('../internals.js').DeleteItem>} */ (ds2.clients.get(client))\n if (deleteItems2 === undefined || deleteItems1.length !== deleteItems2.length) return false\n for (let i = 0; i < deleteItems1.length; i++) {\n const di1 = deleteItems1[i]\n const di2 = deleteItems2[i]\n if (di1.clock !== di2.clock || di1.len !== di2.len) {\n return false\n }\n }\n }\n return true\n}\n", "/**\n * @module Y\n */\n\nimport {\n StructStore,\n AbstractType,\n YArray,\n YText,\n YMap,\n YXmlElement,\n YXmlFragment,\n transact,\n ContentDoc, Item, Transaction, YEvent // eslint-disable-line\n} from '../internals.js'\n\nimport { ObservableV2 } from 'lib0/observable'\nimport * as random from 'lib0/random'\nimport * as map from 'lib0/map'\nimport * as array from 'lib0/array'\nimport * as promise from 'lib0/promise'\n\nexport const generateNewClientId = random.uint32\n\n/**\n * @typedef {Object} DocOpts\n * @property {boolean} [DocOpts.gc=true] Disable garbage collection (default: gc=true)\n * @property {function(Item):boolean} [DocOpts.gcFilter] Will be called before an Item is garbage collected. Return false to keep the Item.\n * @property {string} [DocOpts.guid] Define a globally unique identifier for this document\n * @property {string | null} [DocOpts.collectionid] Associate this document with a collection. This only plays a role if your provider has a concept of collection.\n * @property {any} [DocOpts.meta] Any kind of meta information you want to associate with this document. If this is a subdocument, remote peers will store the meta information as well.\n * @property {boolean} [DocOpts.autoLoad] If a subdocument, automatically load document. If this is a subdocument, remote peers will load the document as well automatically.\n * @property {boolean} [DocOpts.shouldLoad] Whether the document should be synced by the provider now. This is toggled to true when you call ydoc.load()\n */\n\n/**\n * @typedef {Object} DocEvents\n * @property {function(Doc):void} DocEvents.destroy\n * @property {function(Doc):void} DocEvents.load\n * @property {function(boolean, Doc):void} DocEvents.sync\n * @property {function(Uint8Array, any, Doc, Transaction):void} DocEvents.update\n * @property {function(Uint8Array, any, Doc, Transaction):void} DocEvents.updateV2\n * @property {function(Doc):void} DocEvents.beforeAllTransactions\n * @property {function(Transaction, Doc):void} DocEvents.beforeTransaction\n * @property {function(Transaction, Doc):void} DocEvents.beforeObserverCalls\n * @property {function(Transaction, Doc):void} DocEvents.afterTransaction\n * @property {function(Transaction, Doc):void} DocEvents.afterTransactionCleanup\n * @property {function(Doc, Array<Transaction>):void} DocEvents.afterAllTransactions\n * @property {function({ loaded: Set<Doc>, added: Set<Doc>, removed: Set<Doc> }, Doc, Transaction):void} DocEvents.subdocs\n */\n\n/**\n * A Yjs instance handles the state of shared data.\n * @extends ObservableV2<DocEvents>\n */\nexport class Doc extends ObservableV2 {\n /**\n * @param {DocOpts} opts configuration\n */\n constructor ({ guid = random.uuidv4(), collectionid = null, gc = true, gcFilter = () => true, meta = null, autoLoad = false, shouldLoad = true } = {}) {\n super()\n this.gc = gc\n this.gcFilter = gcFilter\n this.clientID = generateNewClientId()\n this.guid = guid\n this.collectionid = collectionid\n /**\n * @type {Map<string, AbstractType<YEvent<any>>>}\n */\n this.share = new Map()\n this.store = new StructStore()\n /**\n * @type {Transaction | null}\n */\n this._transaction = null\n /**\n * @type {Array<Transaction>}\n */\n this._transactionCleanups = []\n /**\n * @type {Set<Doc>}\n */\n this.subdocs = new Set()\n /**\n * If this document is a subdocument - a document integrated into another document - then _item is defined.\n * @type {Item?}\n */\n this._item = null\n this.shouldLoad = shouldLoad\n this.autoLoad = autoLoad\n this.meta = meta\n /**\n * This is set to true when the persistence provider loaded the document from the database or when the `sync` event fires.\n * Note that not all providers implement this feature. Provider authors are encouraged to fire the `load` event when the doc content is loaded from the database.\n *\n * @type {boolean}\n */\n this.isLoaded = false\n /**\n * This is set to true when the connection provider has successfully synced with a backend.\n * Note that when using peer-to-peer providers this event may not provide very useful.\n * Also note that not all providers implement this feature. Provider authors are encouraged to fire\n * the `sync` event when the doc has been synced (with `true` as a parameter) or if connection is\n * lost (with false as a parameter).\n */\n this.isSynced = false\n this.isDestroyed = false\n /**\n * Promise that resolves once the document has been loaded from a persistence provider.\n */\n this.whenLoaded = promise.create(resolve => {\n this.on('load', () => {\n this.isLoaded = true\n resolve(this)\n })\n })\n const provideSyncedPromise = () => promise.create(resolve => {\n /**\n * @param {boolean} isSynced\n */\n const eventHandler = (isSynced) => {\n if (isSynced === undefined || isSynced === true) {\n this.off('sync', eventHandler)\n resolve()\n }\n }\n this.on('sync', eventHandler)\n })\n this.on('sync', isSynced => {\n if (isSynced === false && this.isSynced) {\n this.whenSynced = provideSyncedPromise()\n }\n this.isSynced = isSynced === undefined || isSynced === true\n if (this.isSynced && !this.isLoaded) {\n this.emit('load', [this])\n }\n })\n /**\n * Promise that resolves once the document has been synced with a backend.\n * This promise is recreated when the connection is lost.\n * Note the documentation about the `isSynced` property.\n */\n this.whenSynced = provideSyncedPromise()\n }\n\n /**\n * Notify the parent document that you request to load data into this subdocument (if it is a subdocument).\n *\n * `load()` might be used in the future to request any provider to load the most current data.\n *\n * It is safe to call `load()` multiple times.\n */\n load () {\n const item = this._item\n if (item !== null && !this.shouldLoad) {\n transact(/** @type {any} */ (item.parent).doc, transaction => {\n transaction.subdocsLoaded.add(this)\n }, null, true)\n }\n this.shouldLoad = true\n }\n\n getSubdocs () {\n return this.subdocs\n }\n\n getSubdocGuids () {\n return new Set(array.from(this.subdocs).map(doc => doc.guid))\n }\n\n /**\n * Changes that happen inside of a transaction are bundled. This means that\n * the observer fires _after_ the transaction is finished and that all changes\n * that happened inside of the transaction are sent as one message to the\n * other peers.\n *\n * @template T\n * @param {function(Transaction):T} f The function that should be executed as a transaction\n * @param {any} [origin] Origin of who started the transaction. Will be stored on transaction.origin\n * @return T\n *\n * @public\n */\n transact (f, origin = null) {\n return transact(this, f, origin)\n }\n\n /**\n * Define a shared data type.\n *\n * Multiple calls of `ydoc.get(name, TypeConstructor)` yield the same result\n * and do not overwrite each other. I.e.\n * `ydoc.get(name, Y.Array) === ydoc.get(name, Y.Array)`\n *\n * After this method is called, the type is also available on `ydoc.share.get(name)`.\n *\n * *Best Practices:*\n * Define all types right after the Y.Doc instance is created and store them in a separate object.\n * Also use the typed methods `getText(name)`, `getArray(name)`, ..\n *\n * @template {typeof AbstractType<any>} Type\n * @example\n * const ydoc = new Y.Doc(..)\n * const appState = {\n * document: ydoc.getText('document')\n * comments: ydoc.getArray('comments')\n * }\n *\n * @param {string} name\n * @param {Type} TypeConstructor The constructor of the type definition. E.g. Y.Text, Y.Array, Y.Map, ...\n * @return {InstanceType<Type>} The created type. Constructed with TypeConstructor\n *\n * @public\n */\n get (name, TypeConstructor = /** @type {any} */ (AbstractType)) {\n const type = map.setIfUndefined(this.share, name, () => {\n // @ts-ignore\n const t = new TypeConstructor()\n t._integrate(this, null)\n return t\n })\n const Constr = type.constructor\n if (TypeConstructor !== AbstractType && Constr !== TypeConstructor) {\n if (Constr === AbstractType) {\n // @ts-ignore\n const t = new TypeConstructor()\n t._map = type._map\n type._map.forEach(/** @param {Item?} n */ n => {\n for (; n !== null; n = n.left) {\n // @ts-ignore\n n.parent = t\n }\n })\n t._start = type._start\n for (let n = t._start; n !== null; n = n.right) {\n n.parent = t\n }\n t._length = type._length\n this.share.set(name, t)\n t._integrate(this, null)\n return /** @type {InstanceType<Type>} */ (t)\n } else {\n throw new Error(`Type with the name ${name} has already been defined with a different constructor`)\n }\n }\n return /** @type {InstanceType<Type>} */ (type)\n }\n\n /**\n * @template T\n * @param {string} [name]\n * @return {YArray<T>}\n *\n * @public\n */\n getArray (name = '') {\n return /** @type {YArray<T>} */ (this.get(name, YArray))\n }\n\n /**\n * @param {string} [name]\n * @return {YText}\n *\n * @public\n */\n getText (name = '') {\n return this.get(name, YText)\n }\n\n /**\n * @template T\n * @param {string} [name]\n * @return {YMap<T>}\n *\n * @public\n */\n getMap (name = '') {\n return /** @type {YMap<T>} */ (this.get(name, YMap))\n }\n\n /**\n * @param {string} [name]\n * @return {YXmlElement}\n *\n * @public\n */\n getXmlElement (name = '') {\n return /** @type {YXmlElement<{[key:string]:string}>} */ (this.get(name, YXmlElement))\n }\n\n /**\n * @param {string} [name]\n * @return {YXmlFragment}\n *\n * @public\n */\n getXmlFragment (name = '') {\n return this.get(name, YXmlFragment)\n }\n\n /**\n * Converts the entire document into a js object, recursively traversing each yjs type\n * Doesn't log types that have not been defined (using ydoc.getType(..)).\n *\n * @deprecated Do not use this method and rather call toJSON directly on the shared types.\n *\n * @return {Object<string, any>}\n */\n toJSON () {\n /**\n * @type {Object<string, any>}\n */\n const doc = {}\n\n this.share.forEach((value, key) => {\n doc[key] = value.toJSON()\n })\n\n return doc\n }\n\n /**\n * Emit `destroy` event and unregister all event handlers.\n */\n destroy () {\n this.isDestroyed = true\n array.from(this.subdocs).forEach(subdoc => subdoc.destroy())\n const item = this._item\n if (item !== null) {\n this._item = null\n const content = /** @type {ContentDoc} */ (item.content)\n content.doc = new Doc({ guid: this.guid, ...content.opts, shouldLoad: false })\n content.doc._item = item\n transact(/** @type {any} */ (item).parent.doc, transaction => {\n const doc = content.doc\n if (!item.deleted) {\n transaction.subdocsAdded.add(doc)\n }\n transaction.subdocsRemoved.add(this)\n }, null, true)\n }\n // @ts-ignore\n this.emit('destroyed', [true]) // DEPRECATED!\n this.emit('destroy', [this])\n super.destroy()\n }\n}\n", "import * as buffer from 'lib0/buffer'\nimport * as decoding from 'lib0/decoding'\nimport {\n ID, createID\n} from '../internals.js'\n\nexport class DSDecoderV1 {\n /**\n * @param {decoding.Decoder} decoder\n */\n constructor (decoder) {\n this.restDecoder = decoder\n }\n\n resetDsCurVal () {\n // nop\n }\n\n /**\n * @return {number}\n */\n readDsClock () {\n return decoding.readVarUint(this.restDecoder)\n }\n\n /**\n * @return {number}\n */\n readDsLen () {\n return decoding.readVarUint(this.restDecoder)\n }\n}\n\nexport class UpdateDecoderV1 extends DSDecoderV1 {\n /**\n * @return {ID}\n */\n readLeftID () {\n return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder))\n }\n\n /**\n * @return {ID}\n */\n readRightID () {\n return createID(decoding.readVarUint(this.restDecoder), decoding.readVarUint(this.restDecoder))\n }\n\n /**\n * Read the next client id.\n * Use this in favor of readID whenever possible to reduce the number of objects created.\n */\n readClient () {\n return decoding.readVarUint(this.restDecoder)\n }\n\n /**\n * @return {number} info An unsigned 8-bit integer\n */\n readInfo () {\n return decoding.readUint8(this.restDecoder)\n }\n\n /**\n * @return {string}\n */\n readString () {\n return decoding.readVarString(this.restDecoder)\n }\n\n /**\n * @return {boolean} isKey\n */\n readParentInfo () {\n return decoding.readVarUint(this.restDecoder) === 1\n }\n\n /**\n * @return {number} info An unsigned 8-bit integer\n */\n readTypeRef () {\n return decoding.readVarUint(this.restDecoder)\n }\n\n /**\n * Write len of a struct - well suited for Opt RLE encoder.\n *\n * @return {number} len\n */\n readLen () {\n return decoding.readVarUint(this.restDecoder)\n }\n\n /**\n * @return {any}\n */\n readAny () {\n return decoding.readAny(this.restDecoder)\n }\n\n /**\n * @return {Uint8Array}\n */\n readBuf () {\n return buffer.copyUint8Array(decoding.readVarUint8Array(this.restDecoder))\n }\n\n /**\n * Legacy implementation uses JSON parse. We use any-decoding in v2.\n *\n * @return {any}\n */\n readJSON () {\n return JSON.parse(decoding.readVarString(this.restDecoder))\n }\n\n /**\n * @return {string}\n */\n readKey () {\n return decoding.readVarString(this.restDecoder)\n }\n}\n\nexport class DSDecoderV2 {\n /**\n * @param {decoding.Decoder} decoder\n */\n constructor (decoder) {\n /**\n * @private\n */\n this.dsCurrVal = 0\n this.restDecoder = decoder\n }\n\n resetDsCurVal () {\n this.dsCurrVal = 0\n }\n\n /**\n * @return {number}\n */\n readDsClock () {\n this.dsCurrVal += decoding.readVarUint(this.restDecoder)\n return this.dsCurrVal\n }\n\n /**\n * @return {number}\n */\n readDsLen () {\n const diff = decoding.readVarUint(this.restDecoder) + 1\n this.dsCurrVal += diff\n return diff\n }\n}\n\nexport class UpdateDecoderV2 extends DSDecoderV2 {\n /**\n * @param {decoding.Decoder} decoder\n */\n constructor (decoder) {\n super(decoder)\n /**\n * List of cached keys. If the keys[id] does not exist, we read a new key\n * from stringEncoder and push it to keys.\n *\n * @type {Array<string>}\n */\n this.keys = []\n decoding.readVarUint(decoder) // read feature flag - currently unused\n this.keyClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))\n this.clientDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))\n this.leftClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))\n this.rightClockDecoder = new decoding.IntDiffOptRleDecoder(decoding.readVarUint8Array(decoder))\n this.infoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8)\n this.stringDecoder = new decoding.StringDecoder(decoding.readVarUint8Array(decoder))\n this.parentInfoDecoder = new decoding.RleDecoder(decoding.readVarUint8Array(decoder), decoding.readUint8)\n this.typeRefDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))\n this.lenDecoder = new decoding.UintOptRleDecoder(decoding.readVarUint8Array(decoder))\n }\n\n /**\n * @return {ID}\n */\n readLeftID () {\n return new ID(this.clientDecoder.read(), this.leftClockDecoder.read())\n }\n\n /**\n * @return {ID}\n */\n readRightID () {\n return new ID(this.clientDecoder.read(), this.rightClockDecoder.read())\n }\n\n /**\n * Read the next client id.\n * Use this in favor of readID whenever possible to reduce the number of objects created.\n */\n readClient () {\n return this.clientDecoder.read()\n }\n\n /**\n * @return {number} info An unsigned 8-bit integer\n */\n readInfo () {\n return /** @type {number} */ (this.infoDecoder.read())\n }\n\n /**\n * @return {string}\n */\n readString () {\n return this.stringDecoder.read()\n }\n\n /**\n * @return {boolean}\n */\n readParentInfo () {\n return this.parentInfoDecoder.read() === 1\n }\n\n /**\n * @return {number} An unsigned 8-bit integer\n */\n readTypeRef () {\n return this.typeRefDecoder.read()\n }\n\n /**\n * Write len of a struct - well suited for Opt RLE encoder.\n *\n * @return {number}\n */\n readLen () {\n return this.lenDecoder.read()\n }\n\n /**\n * @return {any}\n */\n readAny () {\n return decoding.readAny(this.restDecoder)\n }\n\n /**\n * @return {Uint8Array}\n */\n readBuf () {\n return decoding.readVarUint8Array(this.restDecoder)\n }\n\n /**\n * This is mainly here for legacy purposes.\n *\n * Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.\n *\n * @return {any}\n */\n readJSON () {\n return decoding.readAny(this.restDecoder)\n }\n\n /**\n * @return {string}\n */\n readKey () {\n const keyClock = this.keyClockDecoder.read()\n if (keyClock < this.keys.length) {\n return this.keys[keyClock]\n } else {\n const key = this.stringDecoder.read()\n this.keys.push(key)\n return key\n }\n }\n}\n", "import * as error from 'lib0/error'\nimport * as encoding from 'lib0/encoding'\n\nimport {\n ID // eslint-disable-line\n} from '../internals.js'\n\nexport class DSEncoderV1 {\n constructor () {\n this.restEncoder = encoding.createEncoder()\n }\n\n toUint8Array () {\n return encoding.toUint8Array(this.restEncoder)\n }\n\n resetDsCurVal () {\n // nop\n }\n\n /**\n * @param {number} clock\n */\n writeDsClock (clock) {\n encoding.writeVarUint(this.restEncoder, clock)\n }\n\n /**\n * @param {number} len\n */\n writeDsLen (len) {\n encoding.writeVarUint(this.restEncoder, len)\n }\n}\n\nexport class UpdateEncoderV1 extends DSEncoderV1 {\n /**\n * @param {ID} id\n */\n writeLeftID (id) {\n encoding.writeVarUint(this.restEncoder, id.client)\n encoding.writeVarUint(this.restEncoder, id.clock)\n }\n\n /**\n * @param {ID} id\n */\n writeRightID (id) {\n encoding.writeVarUint(this.restEncoder, id.client)\n encoding.writeVarUint(this.restEncoder, id.clock)\n }\n\n /**\n * Use writeClient and writeClock instead of writeID if possible.\n * @param {number} client\n */\n writeClient (client) {\n encoding.writeVarUint(this.restEncoder, client)\n }\n\n /**\n * @param {number} info An unsigned 8-bit integer\n */\n writeInfo (info) {\n encoding.writeUint8(this.restEncoder, info)\n }\n\n /**\n * @param {string} s\n */\n writeString (s) {\n encoding.writeVarString(this.restEncoder, s)\n }\n\n /**\n * @param {boolean} isYKey\n */\n writeParentInfo (isYKey) {\n encoding.writeVarUint(this.restEncoder, isYKey ? 1 : 0)\n }\n\n /**\n * @param {number} info An unsigned 8-bit integer\n */\n writeTypeRef (info) {\n encoding.writeVarUint(this.restEncoder, info)\n }\n\n /**\n * Write len of a struct - well suited for Opt RLE encoder.\n *\n * @param {number} len\n */\n writeLen (len) {\n encoding.writeVarUint(this.restEncoder, len)\n }\n\n /**\n * @param {any} any\n */\n writeAny (any) {\n encoding.writeAny(this.restEncoder, any)\n }\n\n /**\n * @param {Uint8Array} buf\n */\n writeBuf (buf) {\n encoding.writeVarUint8Array(this.restEncoder, buf)\n }\n\n /**\n * @param {any} embed\n */\n writeJSON (embed) {\n encoding.writeVarString(this.restEncoder, JSON.stringify(embed))\n }\n\n /**\n * @param {string} key\n */\n writeKey (key) {\n encoding.writeVarString(this.restEncoder, key)\n }\n}\n\nexport class DSEncoderV2 {\n constructor () {\n this.restEncoder = encoding.createEncoder() // encodes all the rest / non-optimized\n this.dsCurrVal = 0\n }\n\n toUint8Array () {\n return encoding.toUint8Array(this.restEncoder)\n }\n\n resetDsCurVal () {\n this.dsCurrVal = 0\n }\n\n /**\n * @param {number} clock\n */\n writeDsClock (clock) {\n const diff = clock - this.dsCurrVal\n this.dsCurrVal = clock\n encoding.writeVarUint(this.restEncoder, diff)\n }\n\n /**\n * @param {number} len\n */\n writeDsLen (len) {\n if (len === 0) {\n error.unexpectedCase()\n }\n encoding.writeVarUint(this.restEncoder, len - 1)\n this.dsCurrVal += len\n }\n}\n\nexport class UpdateEncoderV2 extends DSEncoderV2 {\n constructor () {\n super()\n /**\n * @type {Map<string,number>}\n */\n this.keyMap = new Map()\n /**\n * Refers to the next unique key-identifier to me used.\n * See writeKey method for more information.\n *\n * @type {number}\n */\n this.keyClock = 0\n this.keyClockEncoder = new encoding.IntDiffOptRleEncoder()\n this.clientEncoder = new encoding.UintOptRleEncoder()\n this.leftClockEncoder = new encoding.IntDiffOptRleEncoder()\n this.rightClockEncoder = new encoding.IntDiffOptRleEncoder()\n this.infoEncoder = new encoding.RleEncoder(encoding.writeUint8)\n this.stringEncoder = new encoding.StringEncoder()\n this.parentInfoEncoder = new encoding.RleEncoder(encoding.writeUint8)\n this.typeRefEncoder = new encoding.UintOptRleEncoder()\n this.lenEncoder = new encoding.UintOptRleEncoder()\n }\n\n toUint8Array () {\n const encoder = encoding.createEncoder()\n encoding.writeVarUint(encoder, 0) // this is a feature flag that we might use in the future\n encoding.writeVarUint8Array(encoder, this.keyClockEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, this.clientEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, this.leftClockEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, this.rightClockEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.infoEncoder))\n encoding.writeVarUint8Array(encoder, this.stringEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, encoding.toUint8Array(this.parentInfoEncoder))\n encoding.writeVarUint8Array(encoder, this.typeRefEncoder.toUint8Array())\n encoding.writeVarUint8Array(encoder, this.lenEncoder.toUint8Array())\n // @note The rest encoder is appended! (note the missing var)\n encoding.writeUint8Array(encoder, encoding.toUint8Array(this.restEncoder))\n return encoding.toUint8Array(encoder)\n }\n\n /**\n * @param {ID} id\n */\n writeLeftID (id) {\n this.clientEncoder.write(id.client)\n this.leftClockEncoder.write(id.clock)\n }\n\n /**\n * @param {ID} id\n */\n writeRightID (id) {\n this.clientEncoder.write(id.client)\n this.rightClockEncoder.write(id.clock)\n }\n\n /**\n * @param {number} client\n */\n writeClient (client) {\n this.clientEncoder.write(client)\n }\n\n /**\n * @param {number} info An unsigned 8-bit integer\n */\n writeInfo (info) {\n this.infoEncoder.write(info)\n }\n\n /**\n * @param {string} s\n */\n writeString (s) {\n this.stringEncoder.write(s)\n }\n\n /**\n * @param {boolean} isYKey\n */\n writeParentInfo (isYKey) {\n this.parentInfoEncoder.write(isYKey ? 1 : 0)\n }\n\n /**\n * @param {number} info An unsigned 8-bit integer\n */\n writeTypeRef (info) {\n this.typeRefEncoder.write(info)\n }\n\n /**\n * Write len of a struct - well suited for Opt RLE encoder.\n *\n * @param {number} len\n */\n writeLen (len) {\n this.lenEncoder.write(len)\n }\n\n /**\n * @param {any} any\n */\n writeAny (any) {\n encoding.writeAny(this.restEncoder, any)\n }\n\n /**\n * @param {Uint8Array} buf\n */\n writeBuf (buf) {\n encoding.writeVarUint8Array(this.restEncoder, buf)\n }\n\n /**\n * This is mainly here for legacy purposes.\n *\n * Initial we incoded objects using JSON. Now we use the much faster lib0/any-encoder. This method mainly exists for legacy purposes for the v1 encoder.\n *\n * @param {any} embed\n */\n writeJSON (embed) {\n encoding.writeAny(this.restEncoder, embed)\n }\n\n /**\n * Property keys are often reused. For example, in y-prosemirror the key `bold` might\n * occur very often. For a 3d application, the key `position` might occur very often.\n *\n * We cache these keys in a Map and refer to them via a unique number.\n *\n * @param {string} key\n */\n writeKey (key) {\n const clock = this.keyMap.get(key)\n if (clock === undefined) {\n /**\n * @todo uncomment to introduce this feature finally\n *\n * Background. The ContentFormat object was always encoded using writeKey, but the decoder used to use readString.\n * Furthermore, I forgot to set the keyclock. So everything was working fine.\n *\n * However, this feature here is basically useless as it is not being used (it actually only consumes extra memory).\n *\n * I don't know yet how to reintroduce this feature..\n *\n * Older clients won't be able to read updates when we reintroduce this feature. So this should probably be done using a flag.\n *\n */\n // this.keyMap.set(key, this.keyClock)\n this.keyClockEncoder.write(this.keyClock++)\n this.stringEncoder.write(key)\n } else {\n this.keyClockEncoder.write(clock)\n }\n }\n}\n", "/**\n * @module encoding\n */\n/*\n * We use the first five bits in the info flag for determining the type of the struct.\n *\n * 0: GC\n * 1: Item with Deleted content\n * 2: Item with JSON content\n * 3: Item with Binary content\n * 4: Item with String content\n * 5: Item with Embed content (for richtext content)\n * 6: Item with Format content (a formatting marker for richtext content)\n * 7: Item with Type\n */\n\nimport {\n findIndexSS,\n getState,\n createID,\n getStateVector,\n readAndApplyDeleteSet,\n writeDeleteSet,\n createDeleteSetFromStructStore,\n transact,\n readItemContent,\n UpdateDecoderV1,\n UpdateDecoderV2,\n UpdateEncoderV1,\n UpdateEncoderV2,\n DSEncoderV2,\n DSDecoderV1,\n DSEncoderV1,\n mergeUpdates,\n mergeUpdatesV2,\n Skip,\n diffUpdateV2,\n convertUpdateFormatV2ToV1,\n DSDecoderV2, Doc, Transaction, GC, Item, StructStore // eslint-disable-line\n} from '../internals.js'\n\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\nimport * as binary from 'lib0/binary'\nimport * as map from 'lib0/map'\nimport * as math from 'lib0/math'\nimport * as array from 'lib0/array'\n\n/**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {Array<GC|Item>} structs All structs by `client`\n * @param {number} client\n * @param {number} clock write structs starting with `ID(client,clock)`\n *\n * @function\n */\nconst writeStructs = (encoder, structs, client, clock) => {\n // write first id\n clock = math.max(clock, structs[0].id.clock) // make sure the first id exists\n const startNewStructs = findIndexSS(structs, clock)\n // write # encoded structs\n encoding.writeVarUint(encoder.restEncoder, structs.length - startNewStructs)\n encoder.writeClient(client)\n encoding.writeVarUint(encoder.restEncoder, clock)\n const firstStruct = structs[startNewStructs]\n // write first struct with an offset\n firstStruct.write(encoder, clock - firstStruct.id.clock)\n for (let i = startNewStructs + 1; i < structs.length; i++) {\n structs[i].write(encoder, 0)\n }\n}\n\n/**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {StructStore} store\n * @param {Map<number,number>} _sm\n *\n * @private\n * @function\n */\nexport const writeClientsStructs = (encoder, store, _sm) => {\n // we filter all valid _sm entries into sm\n const sm = new Map()\n _sm.forEach((clock, client) => {\n // only write if new structs are available\n if (getState(store, client) > clock) {\n sm.set(client, clock)\n }\n })\n getStateVector(store).forEach((_clock, client) => {\n if (!_sm.has(client)) {\n sm.set(client, 0)\n }\n })\n // write # states that were updated\n encoding.writeVarUint(encoder.restEncoder, sm.size)\n // Write items with higher client ids first\n // This heavily improves the conflict algorithm.\n array.from(sm.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {\n writeStructs(encoder, /** @type {Array<GC|Item>} */ (store.clients.get(client)), client, clock)\n })\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder The decoder object to read data from.\n * @param {Doc} doc\n * @return {Map<number, { i: number, refs: Array<Item | GC> }>}\n *\n * @private\n * @function\n */\nexport const readClientsStructRefs = (decoder, doc) => {\n /**\n * @type {Map<number, { i: number, refs: Array<Item | GC> }>}\n */\n const clientRefs = map.create()\n const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < numOfStateUpdates; i++) {\n const numberOfStructs = decoding.readVarUint(decoder.restDecoder)\n /**\n * @type {Array<GC|Item>}\n */\n const refs = new Array(numberOfStructs)\n const client = decoder.readClient()\n let clock = decoding.readVarUint(decoder.restDecoder)\n // const start = performance.now()\n clientRefs.set(client, { i: 0, refs })\n for (let i = 0; i < numberOfStructs; i++) {\n const info = decoder.readInfo()\n switch (binary.BITS5 & info) {\n case 0: { // GC\n const len = decoder.readLen()\n refs[i] = new GC(createID(client, clock), len)\n clock += len\n break\n }\n case 10: { // Skip Struct (nothing to apply)\n // @todo we could reduce the amount of checks by adding Skip struct to clientRefs so we know that something is missing.\n const len = decoding.readVarUint(decoder.restDecoder)\n refs[i] = new Skip(createID(client, clock), len)\n clock += len\n break\n }\n default: { // Item with content\n /**\n * The optimized implementation doesn't use any variables because inlining variables is faster.\n * Below a non-optimized version is shown that implements the basic algorithm with\n * a few comments\n */\n const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0\n // If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`\n // and we read the next string as parentYKey.\n // It indicates how we store/retrieve parent from `y.share`\n // @type {string|null}\n const struct = new Item(\n createID(client, clock),\n null, // left\n (info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null, // origin\n null, // right\n (info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null, // right origin\n cantCopyParentInfo ? (decoder.readParentInfo() ? doc.get(decoder.readString()) : decoder.readLeftID()) : null, // parent\n cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub\n readItemContent(decoder, info) // item content\n )\n /* A non-optimized implementation of the above algorithm:\n\n // The item that was originally to the left of this item.\n const origin = (info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null\n // The item that was originally to the right of this item.\n const rightOrigin = (info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null\n const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0\n const hasParentYKey = cantCopyParentInfo ? decoder.readParentInfo() : false\n // If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`\n // and we read the next string as parentYKey.\n // It indicates how we store/retrieve parent from `y.share`\n // @type {string|null}\n const parentYKey = cantCopyParentInfo && hasParentYKey ? decoder.readString() : null\n\n const struct = new Item(\n createID(client, clock),\n null, // left\n origin, // origin\n null, // right\n rightOrigin, // right origin\n cantCopyParentInfo && !hasParentYKey ? decoder.readLeftID() : (parentYKey !== null ? doc.get(parentYKey) : null), // parent\n cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub\n readItemContent(decoder, info) // item content\n )\n */\n refs[i] = struct\n clock += struct.length\n }\n }\n }\n // console.log('time to read: ', performance.now() - start) // @todo remove\n }\n return clientRefs\n}\n\n/**\n * Resume computing structs generated by struct readers.\n *\n * While there is something to do, we integrate structs in this order\n * 1. top element on stack, if stack is not empty\n * 2. next element from current struct reader (if empty, use next struct reader)\n *\n * If struct causally depends on another struct (ref.missing), we put next reader of\n * `ref.id.client` on top of stack.\n *\n * At some point we find a struct that has no causal dependencies,\n * then we start emptying the stack.\n *\n * It is not possible to have circles: i.e. struct1 (from client1) depends on struct2 (from client2)\n * depends on struct3 (from client1). Therefore the max stack size is equal to `structReaders.length`.\n *\n * This method is implemented in a way so that we can resume computation if this update\n * causally depends on another update.\n *\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @param {Map<number, { i: number, refs: (GC | Item)[] }>} clientsStructRefs\n * @return { null | { update: Uint8Array, missing: Map<number,number> } }\n *\n * @private\n * @function\n */\nconst integrateStructs = (transaction, store, clientsStructRefs) => {\n /**\n * @type {Array<Item | GC>}\n */\n const stack = []\n // sort them so that we take the higher id first, in case of conflicts the lower id will probably not conflict with the id from the higher user.\n let clientsStructRefsIds = array.from(clientsStructRefs.keys()).sort((a, b) => a - b)\n if (clientsStructRefsIds.length === 0) {\n return null\n }\n const getNextStructTarget = () => {\n if (clientsStructRefsIds.length === 0) {\n return null\n }\n let nextStructsTarget = /** @type {{i:number,refs:Array<GC|Item>}} */ (clientsStructRefs.get(clientsStructRefsIds[clientsStructRefsIds.length - 1]))\n while (nextStructsTarget.refs.length === nextStructsTarget.i) {\n clientsStructRefsIds.pop()\n if (clientsStructRefsIds.length > 0) {\n nextStructsTarget = /** @type {{i:number,refs:Array<GC|Item>}} */ (clientsStructRefs.get(clientsStructRefsIds[clientsStructRefsIds.length - 1]))\n } else {\n return null\n }\n }\n return nextStructsTarget\n }\n let curStructsTarget = getNextStructTarget()\n if (curStructsTarget === null) {\n return null\n }\n\n /**\n * @type {StructStore}\n */\n const restStructs = new StructStore()\n const missingSV = new Map()\n /**\n * @param {number} client\n * @param {number} clock\n */\n const updateMissingSv = (client, clock) => {\n const mclock = missingSV.get(client)\n if (mclock == null || mclock > clock) {\n missingSV.set(client, clock)\n }\n }\n /**\n * @type {GC|Item}\n */\n let stackHead = /** @type {any} */ (curStructsTarget).refs[/** @type {any} */ (curStructsTarget).i++]\n // caching the state because it is used very often\n const state = new Map()\n\n const addStackToRestSS = () => {\n for (const item of stack) {\n const client = item.id.client\n const inapplicableItems = clientsStructRefs.get(client)\n if (inapplicableItems) {\n // decrement because we weren't able to apply previous operation\n inapplicableItems.i--\n restStructs.clients.set(client, inapplicableItems.refs.slice(inapplicableItems.i))\n clientsStructRefs.delete(client)\n inapplicableItems.i = 0\n inapplicableItems.refs = []\n } else {\n // item was the last item on clientsStructRefs and the field was already cleared. Add item to restStructs and continue\n restStructs.clients.set(client, [item])\n }\n // remove client from clientsStructRefsIds to prevent users from applying the same update again\n clientsStructRefsIds = clientsStructRefsIds.filter(c => c !== client)\n }\n stack.length = 0\n }\n\n // iterate over all struct readers until we are done\n while (true) {\n if (stackHead.constructor !== Skip) {\n const localClock = map.setIfUndefined(state, stackHead.id.client, () => getState(store, stackHead.id.client))\n const offset = localClock - stackHead.id.clock\n if (offset < 0) {\n // update from the same client is missing\n stack.push(stackHead)\n updateMissingSv(stackHead.id.client, stackHead.id.clock - 1)\n // hid a dead wall, add all items from stack to restSS\n addStackToRestSS()\n } else {\n const missing = stackHead.getMissing(transaction, store)\n if (missing !== null) {\n stack.push(stackHead)\n // get the struct reader that has the missing struct\n /**\n * @type {{ refs: Array<GC|Item>, i: number }}\n */\n const structRefs = clientsStructRefs.get(/** @type {number} */ (missing)) || { refs: [], i: 0 }\n if (structRefs.refs.length === structRefs.i) {\n // This update message causally depends on another update message that doesn't exist yet\n updateMissingSv(/** @type {number} */ (missing), getState(store, missing))\n addStackToRestSS()\n } else {\n stackHead = structRefs.refs[structRefs.i++]\n continue\n }\n } else if (offset === 0 || offset < stackHead.length) {\n // all fine, apply the stackhead\n stackHead.integrate(transaction, offset)\n state.set(stackHead.id.client, stackHead.id.clock + stackHead.length)\n }\n }\n }\n // iterate to next stackHead\n if (stack.length > 0) {\n stackHead = /** @type {GC|Item} */ (stack.pop())\n } else if (curStructsTarget !== null && curStructsTarget.i < curStructsTarget.refs.length) {\n stackHead = /** @type {GC|Item} */ (curStructsTarget.refs[curStructsTarget.i++])\n } else {\n curStructsTarget = getNextStructTarget()\n if (curStructsTarget === null) {\n // we are done!\n break\n } else {\n stackHead = /** @type {GC|Item} */ (curStructsTarget.refs[curStructsTarget.i++])\n }\n }\n }\n if (restStructs.clients.size > 0) {\n const encoder = new UpdateEncoderV2()\n writeClientsStructs(encoder, restStructs, new Map())\n // write empty deleteset\n // writeDeleteSet(encoder, new DeleteSet())\n encoding.writeVarUint(encoder.restEncoder, 0) // => no need for an extra function call, just write 0 deletes\n return { missing: missingSV, update: encoder.toUint8Array() }\n }\n return null\n}\n\n/**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {Transaction} transaction\n *\n * @private\n * @function\n */\nexport const writeStructsFromTransaction = (encoder, transaction) => writeClientsStructs(encoder, transaction.doc.store, transaction.beforeState)\n\n/**\n * Read and apply a document update.\n *\n * This function has the same effect as `applyUpdate` but accepts a decoder.\n *\n * @param {decoding.Decoder} decoder\n * @param {Doc} ydoc\n * @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`\n * @param {UpdateDecoderV1 | UpdateDecoderV2} [structDecoder]\n *\n * @function\n */\nexport const readUpdateV2 = (decoder, ydoc, transactionOrigin, structDecoder = new UpdateDecoderV2(decoder)) =>\n transact(ydoc, transaction => {\n // force that transaction.local is set to non-local\n transaction.local = false\n let retry = false\n const doc = transaction.doc\n const store = doc.store\n // let start = performance.now()\n const ss = readClientsStructRefs(structDecoder, doc)\n // console.log('time to read structs: ', performance.now() - start) // @todo remove\n // start = performance.now()\n // console.log('time to merge: ', performance.now() - start) // @todo remove\n // start = performance.now()\n const restStructs = integrateStructs(transaction, store, ss)\n const pending = store.pendingStructs\n if (pending) {\n // check if we can apply something\n for (const [client, clock] of pending.missing) {\n if (clock < getState(store, client)) {\n retry = true\n break\n }\n }\n if (restStructs) {\n // merge restStructs into store.pending\n for (const [client, clock] of restStructs.missing) {\n const mclock = pending.missing.get(client)\n if (mclock == null || mclock > clock) {\n pending.missing.set(client, clock)\n }\n }\n pending.update = mergeUpdatesV2([pending.update, restStructs.update])\n }\n } else {\n store.pendingStructs = restStructs\n }\n // console.log('time to integrate: ', performance.now() - start) // @todo remove\n // start = performance.now()\n const dsRest = readAndApplyDeleteSet(structDecoder, transaction, store)\n if (store.pendingDs) {\n // @todo we could make a lower-bound state-vector check as we do above\n const pendingDSUpdate = new UpdateDecoderV2(decoding.createDecoder(store.pendingDs))\n decoding.readVarUint(pendingDSUpdate.restDecoder) // read 0 structs, because we only encode deletes in pendingdsupdate\n const dsRest2 = readAndApplyDeleteSet(pendingDSUpdate, transaction, store)\n if (dsRest && dsRest2) {\n // case 1: ds1 != null && ds2 != null\n store.pendingDs = mergeUpdatesV2([dsRest, dsRest2])\n } else {\n // case 2: ds1 != null\n // case 3: ds2 != null\n // case 4: ds1 == null && ds2 == null\n store.pendingDs = dsRest || dsRest2\n }\n } else {\n // Either dsRest == null && pendingDs == null OR dsRest != null\n store.pendingDs = dsRest\n }\n // console.log('time to cleanup: ', performance.now() - start) // @todo remove\n // start = performance.now()\n\n // console.log('time to resume delete readers: ', performance.now() - start) // @todo remove\n // start = performance.now()\n if (retry) {\n const update = /** @type {{update: Uint8Array}} */ (store.pendingStructs).update\n store.pendingStructs = null\n applyUpdateV2(transaction.doc, update)\n }\n }, transactionOrigin, false)\n\n/**\n * Read and apply a document update.\n *\n * This function has the same effect as `applyUpdate` but accepts a decoder.\n *\n * @param {decoding.Decoder} decoder\n * @param {Doc} ydoc\n * @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`\n *\n * @function\n */\nexport const readUpdate = (decoder, ydoc, transactionOrigin) => readUpdateV2(decoder, ydoc, transactionOrigin, new UpdateDecoderV1(decoder))\n\n/**\n * Apply a document update created by, for example, `y.on('update', update => ..)` or `update = encodeStateAsUpdate()`.\n *\n * This function has the same effect as `readUpdate` but accepts an Uint8Array instead of a Decoder.\n *\n * @param {Doc} ydoc\n * @param {Uint8Array} update\n * @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`\n * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]\n *\n * @function\n */\nexport const applyUpdateV2 = (ydoc, update, transactionOrigin, YDecoder = UpdateDecoderV2) => {\n const decoder = decoding.createDecoder(update)\n readUpdateV2(decoder, ydoc, transactionOrigin, new YDecoder(decoder))\n}\n\n/**\n * Apply a document update created by, for example, `y.on('update', update => ..)` or `update = encodeStateAsUpdate()`.\n *\n * This function has the same effect as `readUpdate` but accepts an Uint8Array instead of a Decoder.\n *\n * @param {Doc} ydoc\n * @param {Uint8Array} update\n * @param {any} [transactionOrigin] This will be stored on `transaction.origin` and `.on('update', (update, origin))`\n *\n * @function\n */\nexport const applyUpdate = (ydoc, update, transactionOrigin) => applyUpdateV2(ydoc, update, transactionOrigin, UpdateDecoderV1)\n\n/**\n * Write all the document as a single update message. If you specify the state of the remote client (`targetStateVector`) it will\n * only write the operations that are missing.\n *\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {Doc} doc\n * @param {Map<number,number>} [targetStateVector] The state of the target that receives the update. Leave empty to write all known structs\n *\n * @function\n */\nexport const writeStateAsUpdate = (encoder, doc, targetStateVector = new Map()) => {\n writeClientsStructs(encoder, doc.store, targetStateVector)\n writeDeleteSet(encoder, createDeleteSetFromStructStore(doc.store))\n}\n\n/**\n * Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (`targetState`) it will\n * only write the operations that are missing.\n *\n * Use `writeStateAsUpdate` instead if you are working with lib0/encoding.js#Encoder\n *\n * @param {Doc} doc\n * @param {Uint8Array} [encodedTargetStateVector] The state of the target that receives the update. Leave empty to write all known structs\n * @param {UpdateEncoderV1 | UpdateEncoderV2} [encoder]\n * @return {Uint8Array}\n *\n * @function\n */\nexport const encodeStateAsUpdateV2 = (doc, encodedTargetStateVector = new Uint8Array([0]), encoder = new UpdateEncoderV2()) => {\n const targetStateVector = decodeStateVector(encodedTargetStateVector)\n writeStateAsUpdate(encoder, doc, targetStateVector)\n const updates = [encoder.toUint8Array()]\n // also add the pending updates (if there are any)\n if (doc.store.pendingDs) {\n updates.push(doc.store.pendingDs)\n }\n if (doc.store.pendingStructs) {\n updates.push(diffUpdateV2(doc.store.pendingStructs.update, encodedTargetStateVector))\n }\n if (updates.length > 1) {\n if (encoder.constructor === UpdateEncoderV1) {\n return mergeUpdates(updates.map((update, i) => i === 0 ? update : convertUpdateFormatV2ToV1(update)))\n } else if (encoder.constructor === UpdateEncoderV2) {\n return mergeUpdatesV2(updates)\n }\n }\n return updates[0]\n}\n\n/**\n * Write all the document as a single update message that can be applied on the remote document. If you specify the state of the remote client (`targetState`) it will\n * only write the operations that are missing.\n *\n * Use `writeStateAsUpdate` instead if you are working with lib0/encoding.js#Encoder\n *\n * @param {Doc} doc\n * @param {Uint8Array} [encodedTargetStateVector] The state of the target that receives the update. Leave empty to write all known structs\n * @return {Uint8Array}\n *\n * @function\n */\nexport const encodeStateAsUpdate = (doc, encodedTargetStateVector) => encodeStateAsUpdateV2(doc, encodedTargetStateVector, new UpdateEncoderV1())\n\n/**\n * Read state vector from Decoder and return as Map\n *\n * @param {DSDecoderV1 | DSDecoderV2} decoder\n * @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.\n *\n * @function\n */\nexport const readStateVector = decoder => {\n const ss = new Map()\n const ssLength = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < ssLength; i++) {\n const client = decoding.readVarUint(decoder.restDecoder)\n const clock = decoding.readVarUint(decoder.restDecoder)\n ss.set(client, clock)\n }\n return ss\n}\n\n/**\n * Read decodedState and return State as Map.\n *\n * @param {Uint8Array} decodedState\n * @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.\n *\n * @function\n */\n// export const decodeStateVectorV2 = decodedState => readStateVector(new DSDecoderV2(decoding.createDecoder(decodedState)))\n\n/**\n * Read decodedState and return State as Map.\n *\n * @param {Uint8Array} decodedState\n * @return {Map<number,number>} Maps `client` to the number next expected `clock` from that client.\n *\n * @function\n */\nexport const decodeStateVector = decodedState => readStateVector(new DSDecoderV1(decoding.createDecoder(decodedState)))\n\n/**\n * @param {DSEncoderV1 | DSEncoderV2} encoder\n * @param {Map<number,number>} sv\n * @function\n */\nexport const writeStateVector = (encoder, sv) => {\n encoding.writeVarUint(encoder.restEncoder, sv.size)\n array.from(sv.entries()).sort((a, b) => b[0] - a[0]).forEach(([client, clock]) => {\n encoding.writeVarUint(encoder.restEncoder, client) // @todo use a special client decoder that is based on mapping\n encoding.writeVarUint(encoder.restEncoder, clock)\n })\n return encoder\n}\n\n/**\n * @param {DSEncoderV1 | DSEncoderV2} encoder\n * @param {Doc} doc\n *\n * @function\n */\nexport const writeDocumentStateVector = (encoder, doc) => writeStateVector(encoder, getStateVector(doc.store))\n\n/**\n * Encode State as Uint8Array.\n *\n * @param {Doc|Map<number,number>} doc\n * @param {DSEncoderV1 | DSEncoderV2} [encoder]\n * @return {Uint8Array}\n *\n * @function\n */\nexport const encodeStateVectorV2 = (doc, encoder = new DSEncoderV2()) => {\n if (doc instanceof Map) {\n writeStateVector(encoder, doc)\n } else {\n writeDocumentStateVector(encoder, doc)\n }\n return encoder.toUint8Array()\n}\n\n/**\n * Encode State as Uint8Array.\n *\n * @param {Doc|Map<number,number>} doc\n * @return {Uint8Array}\n *\n * @function\n */\nexport const encodeStateVector = doc => encodeStateVectorV2(doc, new DSEncoderV1())\n", "import * as f from 'lib0/function'\n\n/**\n * General event handler implementation.\n *\n * @template ARG0, ARG1\n *\n * @private\n */\nexport class EventHandler {\n constructor () {\n /**\n * @type {Array<function(ARG0, ARG1):void>}\n */\n this.l = []\n }\n}\n\n/**\n * @template ARG0,ARG1\n * @returns {EventHandler<ARG0,ARG1>}\n *\n * @private\n * @function\n */\nexport const createEventHandler = () => new EventHandler()\n\n/**\n * Adds an event listener that is called when\n * {@link EventHandler#callEventListeners} is called.\n *\n * @template ARG0,ARG1\n * @param {EventHandler<ARG0,ARG1>} eventHandler\n * @param {function(ARG0,ARG1):void} f The event handler.\n *\n * @private\n * @function\n */\nexport const addEventHandlerListener = (eventHandler, f) =>\n eventHandler.l.push(f)\n\n/**\n * Removes an event listener.\n *\n * @template ARG0,ARG1\n * @param {EventHandler<ARG0,ARG1>} eventHandler\n * @param {function(ARG0,ARG1):void} f The event handler that was added with\n * {@link EventHandler#addEventListener}\n *\n * @private\n * @function\n */\nexport const removeEventHandlerListener = (eventHandler, f) => {\n const l = eventHandler.l\n const len = l.length\n eventHandler.l = l.filter(g => f !== g)\n if (len === eventHandler.l.length) {\n console.error('[yjs] Tried to remove event handler that doesn\\'t exist.')\n }\n}\n\n/**\n * Removes all event listeners.\n * @template ARG0,ARG1\n * @param {EventHandler<ARG0,ARG1>} eventHandler\n *\n * @private\n * @function\n */\nexport const removeAllEventHandlerListeners = eventHandler => {\n eventHandler.l.length = 0\n}\n\n/**\n * Call all event listeners that were added via\n * {@link EventHandler#addEventListener}.\n *\n * @template ARG0,ARG1\n * @param {EventHandler<ARG0,ARG1>} eventHandler\n * @param {ARG0} arg0\n * @param {ARG1} arg1\n *\n * @private\n * @function\n */\nexport const callEventHandlerListeners = (eventHandler, arg0, arg1) =>\n f.callAll(eventHandler.l, [arg0, arg1])\n", "import { AbstractType } from '../internals.js' // eslint-disable-line\n\nimport * as decoding from 'lib0/decoding'\nimport * as encoding from 'lib0/encoding'\nimport * as error from 'lib0/error'\n\nexport class ID {\n /**\n * @param {number} client client id\n * @param {number} clock unique per client id, continuous number\n */\n constructor (client, clock) {\n /**\n * Client id\n * @type {number}\n */\n this.client = client\n /**\n * unique per client id, continuous number\n * @type {number}\n */\n this.clock = clock\n }\n}\n\n/**\n * @param {ID | null} a\n * @param {ID | null} b\n * @return {boolean}\n *\n * @function\n */\nexport const compareIDs = (a, b) => a === b || (a !== null && b !== null && a.client === b.client && a.clock === b.clock)\n\n/**\n * @param {number} client\n * @param {number} clock\n *\n * @private\n * @function\n */\nexport const createID = (client, clock) => new ID(client, clock)\n\n/**\n * @param {encoding.Encoder} encoder\n * @param {ID} id\n *\n * @private\n * @function\n */\nexport const writeID = (encoder, id) => {\n encoding.writeVarUint(encoder, id.client)\n encoding.writeVarUint(encoder, id.clock)\n}\n\n/**\n * Read ID.\n * * If first varUint read is 0xFFFFFF a RootID is returned.\n * * Otherwise an ID is returned\n *\n * @param {decoding.Decoder} decoder\n * @return {ID}\n *\n * @private\n * @function\n */\nexport const readID = decoder =>\n createID(decoding.readVarUint(decoder), decoding.readVarUint(decoder))\n\n/**\n * The top types are mapped from y.share.get(keyname) => type.\n * `type` does not store any information about the `keyname`.\n * This function finds the correct `keyname` for `type` and throws otherwise.\n *\n * @param {AbstractType<any>} type\n * @return {string}\n *\n * @private\n * @function\n */\nexport const findRootTypeKey = type => {\n // @ts-ignore _y must be defined, otherwise unexpected case\n for (const [key, value] of type.doc.share.entries()) {\n if (value === type) {\n return key\n }\n }\n throw error.unexpectedCase()\n}\n", "import { AbstractType, Item } from '../internals.js' // eslint-disable-line\n\n/**\n * Check if `parent` is a parent of `child`.\n *\n * @param {AbstractType<any>} parent\n * @param {Item|null} child\n * @return {Boolean} Whether `parent` is a parent of `child`.\n *\n * @private\n * @function\n */\nexport const isParentOf = (parent, child) => {\n while (child !== null) {\n if (child.parent === parent) {\n return true\n }\n child = /** @type {AbstractType<any>} */ (child.parent)._item\n }\n return false\n}\n", "import {\n AbstractType // eslint-disable-line\n} from '../internals.js'\n\n/**\n * Convenient helper to log type information.\n *\n * Do not use in productive systems as the output can be immense!\n *\n * @param {AbstractType<any>} type\n */\nexport const logType = type => {\n const res = []\n let n = type._start\n while (n) {\n res.push(n)\n n = n.right\n }\n console.log('Children: ', res)\n console.log('Children content: ', res.filter(m => !m.deleted).map(m => m.content))\n}\n", "import {\n YArray,\n YMap,\n readDeleteSet,\n writeDeleteSet,\n createDeleteSet,\n DSEncoderV1, DSDecoderV1, ID, DeleteSet, YArrayEvent, Transaction, Doc // eslint-disable-line\n} from '../internals.js'\n\nimport * as decoding from 'lib0/decoding'\n\nimport { mergeDeleteSets, isDeleted } from './DeleteSet.js'\n\nexport class PermanentUserData {\n /**\n * @param {Doc} doc\n * @param {YMap<any>} [storeType]\n */\n constructor (doc, storeType = doc.getMap('users')) {\n /**\n * @type {Map<string,DeleteSet>}\n */\n const dss = new Map()\n this.yusers = storeType\n this.doc = doc\n /**\n * Maps from clientid to userDescription\n *\n * @type {Map<number,string>}\n */\n this.clients = new Map()\n this.dss = dss\n /**\n * @param {YMap<any>} user\n * @param {string} userDescription\n */\n const initUser = (user, userDescription) => {\n /**\n * @type {YArray<Uint8Array>}\n */\n const ds = user.get('ds')\n const ids = user.get('ids')\n const addClientId = /** @param {number} clientid */ clientid => this.clients.set(clientid, userDescription)\n ds.observe(/** @param {YArrayEvent<any>} event */ event => {\n event.changes.added.forEach(item => {\n item.content.getContent().forEach(encodedDs => {\n if (encodedDs instanceof Uint8Array) {\n this.dss.set(userDescription, mergeDeleteSets([this.dss.get(userDescription) || createDeleteSet(), readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs)))]))\n }\n })\n })\n })\n this.dss.set(userDescription, mergeDeleteSets(ds.map(encodedDs => readDeleteSet(new DSDecoderV1(decoding.createDecoder(encodedDs))))))\n ids.observe(/** @param {YArrayEvent<any>} event */ event =>\n event.changes.added.forEach(item => item.content.getContent().forEach(addClientId))\n )\n ids.forEach(addClientId)\n }\n // observe users\n storeType.observe(event => {\n event.keysChanged.forEach(userDescription =>\n initUser(storeType.get(userDescription), userDescription)\n )\n })\n // add initial data\n storeType.forEach(initUser)\n }\n\n /**\n * @param {Doc} doc\n * @param {number} clientid\n * @param {string} userDescription\n * @param {Object} conf\n * @param {function(Transaction, DeleteSet):boolean} [conf.filter]\n */\n setUserMapping (doc, clientid, userDescription, { filter = () => true } = {}) {\n const users = this.yusers\n let user = users.get(userDescription)\n if (!user) {\n user = new YMap()\n user.set('ids', new YArray())\n user.set('ds', new YArray())\n users.set(userDescription, user)\n }\n user.get('ids').push([clientid])\n users.observe(_event => {\n setTimeout(() => {\n const userOverwrite = users.get(userDescription)\n if (userOverwrite !== user) {\n // user was overwritten, port all data over to the next user object\n // @todo Experiment with Y.Sets here\n user = userOverwrite\n // @todo iterate over old type\n this.clients.forEach((_userDescription, clientid) => {\n if (userDescription === _userDescription) {\n user.get('ids').push([clientid])\n }\n })\n const encoder = new DSEncoderV1()\n const ds = this.dss.get(userDescription)\n if (ds) {\n writeDeleteSet(encoder, ds)\n user.get('ds').push([encoder.toUint8Array()])\n }\n }\n }, 0)\n })\n doc.on('afterTransaction', /** @param {Transaction} transaction */ transaction => {\n setTimeout(() => {\n const yds = user.get('ds')\n const ds = transaction.deleteSet\n if (transaction.local && ds.clients.size > 0 && filter(transaction, ds)) {\n const encoder = new DSEncoderV1()\n writeDeleteSet(encoder, ds)\n yds.push([encoder.toUint8Array()])\n }\n })\n })\n }\n\n /**\n * @param {number} clientid\n * @return {any}\n */\n getUserByClientId (clientid) {\n return this.clients.get(clientid) || null\n }\n\n /**\n * @param {ID} id\n * @return {string | null}\n */\n getUserByDeletedId (id) {\n for (const [userDescription, ds] of this.dss.entries()) {\n if (isDeleted(ds, id)) {\n return userDescription\n }\n }\n return null\n }\n}\n", "import {\n writeID,\n readID,\n compareIDs,\n getState,\n findRootTypeKey,\n Item,\n createID,\n ContentType,\n followRedone,\n getItem,\n StructStore, ID, Doc, AbstractType, // eslint-disable-line\n} from '../internals.js'\n\nimport * as encoding from 'lib0/encoding'\nimport * as decoding from 'lib0/decoding'\nimport * as error from 'lib0/error'\n\n/**\n * A relative position is based on the Yjs model and is not affected by document changes.\n * E.g. If you place a relative position before a certain character, it will always point to this character.\n * If you place a relative position at the end of a type, it will always point to the end of the type.\n *\n * A numeric position is often unsuited for user selections, because it does not change when content is inserted\n * before or after.\n *\n * ```Insert(0, 'x')('a|bc') = 'xa|bc'``` Where | is the relative position.\n *\n * One of the properties must be defined.\n *\n * @example\n * // Current cursor position is at position 10\n * const relativePosition = createRelativePositionFromIndex(yText, 10)\n * // modify yText\n * yText.insert(0, 'abc')\n * yText.delete(3, 10)\n * // Compute the cursor position\n * const absolutePosition = createAbsolutePositionFromRelativePosition(y, relativePosition)\n * absolutePosition.type === yText // => true\n * console.log('cursor location is ' + absolutePosition.index) // => cursor location is 3\n *\n */\nexport class RelativePosition {\n /**\n * @param {ID|null} type\n * @param {string|null} tname\n * @param {ID|null} item\n * @param {number} assoc\n */\n constructor (type, tname, item, assoc = 0) {\n /**\n * @type {ID|null}\n */\n this.type = type\n /**\n * @type {string|null}\n */\n this.tname = tname\n /**\n * @type {ID | null}\n */\n this.item = item\n /**\n * A relative position is associated to a specific character. By default\n * assoc >= 0, the relative position is associated to the character\n * after the meant position.\n * I.e. position 1 in 'ab' is associated to character 'b'.\n *\n * If assoc < 0, then the relative position is associated to the character\n * before the meant position.\n *\n * @type {number}\n */\n this.assoc = assoc\n }\n}\n\n/**\n * @param {RelativePosition} rpos\n * @return {any}\n */\nexport const relativePositionToJSON = rpos => {\n const json = {}\n if (rpos.type) {\n json.type = rpos.type\n }\n if (rpos.tname) {\n json.tname = rpos.tname\n }\n if (rpos.item) {\n json.item = rpos.item\n }\n if (rpos.assoc != null) {\n json.assoc = rpos.assoc\n }\n return json\n}\n\n/**\n * @param {any} json\n * @return {RelativePosition}\n *\n * @function\n */\nexport const createRelativePositionFromJSON = json => new RelativePosition(json.type == null ? null : createID(json.type.client, json.type.clock), json.tname ?? null, json.item == null ? null : createID(json.item.client, json.item.clock), json.assoc == null ? 0 : json.assoc)\n\nexport class AbsolutePosition {\n /**\n * @param {AbstractType<any>} type\n * @param {number} index\n * @param {number} [assoc]\n */\n constructor (type, index, assoc = 0) {\n /**\n * @type {AbstractType<any>}\n */\n this.type = type\n /**\n * @type {number}\n */\n this.index = index\n this.assoc = assoc\n }\n}\n\n/**\n * @param {AbstractType<any>} type\n * @param {number} index\n * @param {number} [assoc]\n *\n * @function\n */\nexport const createAbsolutePosition = (type, index, assoc = 0) => new AbsolutePosition(type, index, assoc)\n\n/**\n * @param {AbstractType<any>} type\n * @param {ID|null} item\n * @param {number} [assoc]\n *\n * @function\n */\nexport const createRelativePosition = (type, item, assoc) => {\n let typeid = null\n let tname = null\n if (type._item === null) {\n tname = findRootTypeKey(type)\n } else {\n typeid = createID(type._item.id.client, type._item.id.clock)\n }\n return new RelativePosition(typeid, tname, item, assoc)\n}\n\n/**\n * Create a relativePosition based on a absolute position.\n *\n * @param {AbstractType<any>} type The base type (e.g. YText or YArray).\n * @param {number} index The absolute position.\n * @param {number} [assoc]\n * @return {RelativePosition}\n *\n * @function\n */\nexport const createRelativePositionFromTypeIndex = (type, index, assoc = 0) => {\n let t = type._start\n if (assoc < 0) {\n // associated to the left character or the beginning of a type, increment index if possible.\n if (index === 0) {\n return createRelativePosition(type, null, assoc)\n }\n index--\n }\n while (t !== null) {\n if (!t.deleted && t.countable) {\n if (t.length > index) {\n // case 1: found position somewhere in the linked list\n return createRelativePosition(type, createID(t.id.client, t.id.clock + index), assoc)\n }\n index -= t.length\n }\n if (t.right === null && assoc < 0) {\n // left-associated position, return last available id\n return createRelativePosition(type, t.lastId, assoc)\n }\n t = t.right\n }\n return createRelativePosition(type, null, assoc)\n}\n\n/**\n * @param {encoding.Encoder} encoder\n * @param {RelativePosition} rpos\n *\n * @function\n */\nexport const writeRelativePosition = (encoder, rpos) => {\n const { type, tname, item, assoc } = rpos\n if (item !== null) {\n encoding.writeVarUint(encoder, 0)\n writeID(encoder, item)\n } else if (tname !== null) {\n // case 2: found position at the end of the list and type is stored in y.share\n encoding.writeUint8(encoder, 1)\n encoding.writeVarString(encoder, tname)\n } else if (type !== null) {\n // case 3: found position at the end of the list and type is attached to an item\n encoding.writeUint8(encoder, 2)\n writeID(encoder, type)\n } else {\n throw error.unexpectedCase()\n }\n encoding.writeVarInt(encoder, assoc)\n return encoder\n}\n\n/**\n * @param {RelativePosition} rpos\n * @return {Uint8Array}\n */\nexport const encodeRelativePosition = rpos => {\n const encoder = encoding.createEncoder()\n writeRelativePosition(encoder, rpos)\n return encoding.toUint8Array(encoder)\n}\n\n/**\n * @param {decoding.Decoder} decoder\n * @return {RelativePosition}\n *\n * @function\n */\nexport const readRelativePosition = decoder => {\n let type = null\n let tname = null\n let itemID = null\n switch (decoding.readVarUint(decoder)) {\n case 0:\n // case 1: found position somewhere in the linked list\n itemID = readID(decoder)\n break\n case 1:\n // case 2: found position at the end of the list and type is stored in y.share\n tname = decoding.readVarString(decoder)\n break\n case 2: {\n // case 3: found position at the end of the list and type is attached to an item\n type = readID(decoder)\n }\n }\n const assoc = decoding.hasContent(decoder) ? decoding.readVarInt(decoder) : 0\n return new RelativePosition(type, tname, itemID, assoc)\n}\n\n/**\n * @param {Uint8Array} uint8Array\n * @return {RelativePosition}\n */\nexport const decodeRelativePosition = uint8Array => readRelativePosition(decoding.createDecoder(uint8Array))\n\n/**\n * @param {StructStore} store\n * @param {ID} id\n */\nconst getItemWithOffset = (store, id) => {\n const item = getItem(store, id)\n const diff = id.clock - item.id.clock\n return {\n item, diff\n }\n}\n\n/**\n * Transform a relative position to an absolute position.\n *\n * If you want to share the relative position with other users, you should set\n * `followUndoneDeletions` to false to get consistent results across all clients.\n *\n * When calculating the absolute position, we try to follow the \"undone deletions\". This yields\n * better results for the user who performed undo. However, only the user who performed the undo\n * will get the better results, the other users don't know which operations recreated a deleted\n * range of content. There is more information in this ticket: https://github.com/yjs/yjs/issues/638\n *\n * @param {RelativePosition} rpos\n * @param {Doc} doc\n * @param {boolean} followUndoneDeletions - whether to follow undone deletions - see https://github.com/yjs/yjs/issues/638\n * @return {AbsolutePosition|null}\n *\n * @function\n */\nexport const createAbsolutePositionFromRelativePosition = (rpos, doc, followUndoneDeletions = true) => {\n const store = doc.store\n const rightID = rpos.item\n const typeID = rpos.type\n const tname = rpos.tname\n const assoc = rpos.assoc\n let type = null\n let index = 0\n if (rightID !== null) {\n if (getState(store, rightID.client) <= rightID.clock) {\n return null\n }\n const res = followUndoneDeletions ? followRedone(store, rightID) : getItemWithOffset(store, rightID)\n const right = res.item\n if (!(right instanceof Item)) {\n return null\n }\n type = /** @type {AbstractType<any>} */ (right.parent)\n if (type._item === null || !type._item.deleted) {\n index = (right.deleted || !right.countable) ? 0 : (res.diff + (assoc >= 0 ? 0 : 1)) // adjust position based on left association if necessary\n let n = right.left\n while (n !== null) {\n if (!n.deleted && n.countable) {\n index += n.length\n }\n n = n.left\n }\n }\n } else {\n if (tname !== null) {\n type = doc.get(tname)\n } else if (typeID !== null) {\n if (getState(store, typeID.client) <= typeID.clock) {\n // type does not exist yet\n return null\n }\n const { item } = followUndoneDeletions ? followRedone(store, typeID) : { item: getItem(store, typeID) }\n if (item instanceof Item && item.content instanceof ContentType) {\n type = item.content.type\n } else {\n // struct is garbage collected\n return null\n }\n } else {\n throw error.unexpectedCase()\n }\n if (assoc >= 0) {\n index = type._length\n } else {\n index = 0\n }\n }\n return createAbsolutePosition(type, index, rpos.assoc)\n}\n\n/**\n * @param {RelativePosition|null} a\n * @param {RelativePosition|null} b\n * @return {boolean}\n *\n * @function\n */\nexport const compareRelativePositions = (a, b) => a === b || (\n a !== null && b !== null && a.tname === b.tname && compareIDs(a.item, b.item) && compareIDs(a.type, b.type) && a.assoc === b.assoc\n)\n", "import {\n isDeleted,\n createDeleteSetFromStructStore,\n getStateVector,\n getItemCleanStart,\n iterateDeletedStructs,\n writeDeleteSet,\n writeStateVector,\n readDeleteSet,\n readStateVector,\n createDeleteSet,\n createID,\n getState,\n findIndexSS,\n UpdateEncoderV2,\n applyUpdateV2,\n LazyStructReader,\n equalDeleteSets,\n UpdateDecoderV1, UpdateDecoderV2, DSEncoderV1, DSEncoderV2, DSDecoderV1, DSDecoderV2, Transaction, Doc, DeleteSet, Item, // eslint-disable-line\n mergeDeleteSets\n} from '../internals.js'\n\nimport * as map from 'lib0/map'\nimport * as set from 'lib0/set'\nimport * as decoding from 'lib0/decoding'\nimport * as encoding from 'lib0/encoding'\n\nexport class Snapshot {\n /**\n * @param {DeleteSet} ds\n * @param {Map<number,number>} sv state map\n */\n constructor (ds, sv) {\n /**\n * @type {DeleteSet}\n */\n this.ds = ds\n /**\n * State Map\n * @type {Map<number,number>}\n */\n this.sv = sv\n }\n}\n\n/**\n * @param {Snapshot} snap1\n * @param {Snapshot} snap2\n * @return {boolean}\n */\nexport const equalSnapshots = (snap1, snap2) => {\n const ds1 = snap1.ds.clients\n const ds2 = snap2.ds.clients\n const sv1 = snap1.sv\n const sv2 = snap2.sv\n if (sv1.size !== sv2.size || ds1.size !== ds2.size) {\n return false\n }\n for (const [key, value] of sv1.entries()) {\n if (sv2.get(key) !== value) {\n return false\n }\n }\n for (const [client, dsitems1] of ds1.entries()) {\n const dsitems2 = ds2.get(client) || []\n if (dsitems1.length !== dsitems2.length) {\n return false\n }\n for (let i = 0; i < dsitems1.length; i++) {\n const dsitem1 = dsitems1[i]\n const dsitem2 = dsitems2[i]\n if (dsitem1.clock !== dsitem2.clock || dsitem1.len !== dsitem2.len) {\n return false\n }\n }\n }\n return true\n}\n\n/**\n * @param {Snapshot} snapshot\n * @param {DSEncoderV1 | DSEncoderV2} [encoder]\n * @return {Uint8Array}\n */\nexport const encodeSnapshotV2 = (snapshot, encoder = new DSEncoderV2()) => {\n writeDeleteSet(encoder, snapshot.ds)\n writeStateVector(encoder, snapshot.sv)\n return encoder.toUint8Array()\n}\n\n/**\n * @param {Snapshot} snapshot\n * @return {Uint8Array}\n */\nexport const encodeSnapshot = snapshot => encodeSnapshotV2(snapshot, new DSEncoderV1())\n\n/**\n * @param {Uint8Array} buf\n * @param {DSDecoderV1 | DSDecoderV2} [decoder]\n * @return {Snapshot}\n */\nexport const decodeSnapshotV2 = (buf, decoder = new DSDecoderV2(decoding.createDecoder(buf))) => {\n return new Snapshot(readDeleteSet(decoder), readStateVector(decoder))\n}\n\n/**\n * @param {Uint8Array} buf\n * @return {Snapshot}\n */\nexport const decodeSnapshot = buf => decodeSnapshotV2(buf, new DSDecoderV1(decoding.createDecoder(buf)))\n\n/**\n * @param {DeleteSet} ds\n * @param {Map<number,number>} sm\n * @return {Snapshot}\n */\nexport const createSnapshot = (ds, sm) => new Snapshot(ds, sm)\n\nexport const emptySnapshot = createSnapshot(createDeleteSet(), new Map())\n\n/**\n * @param {Doc} doc\n * @return {Snapshot}\n */\nexport const snapshot = doc => createSnapshot(createDeleteSetFromStructStore(doc.store), getStateVector(doc.store))\n\n/**\n * @param {Item} item\n * @param {Snapshot|undefined} snapshot\n *\n * @protected\n * @function\n */\nexport const isVisible = (item, snapshot) => snapshot === undefined\n ? !item.deleted\n : snapshot.sv.has(item.id.client) && (snapshot.sv.get(item.id.client) || 0) > item.id.clock && !isDeleted(snapshot.ds, item.id)\n\n/**\n * @param {Transaction} transaction\n * @param {Snapshot} snapshot\n */\nexport const splitSnapshotAffectedStructs = (transaction, snapshot) => {\n const meta = map.setIfUndefined(transaction.meta, splitSnapshotAffectedStructs, set.create)\n const store = transaction.doc.store\n // check if we already split for this snapshot\n if (!meta.has(snapshot)) {\n snapshot.sv.forEach((clock, client) => {\n if (clock < getState(store, client)) {\n getItemCleanStart(transaction, createID(client, clock))\n }\n })\n iterateDeletedStructs(transaction, snapshot.ds, _item => {})\n meta.add(snapshot)\n }\n}\n\n/**\n * @example\n * const ydoc = new Y.Doc({ gc: false })\n * ydoc.getText().insert(0, 'world!')\n * const snapshot = Y.snapshot(ydoc)\n * ydoc.getText().insert(0, 'hello ')\n * const restored = Y.createDocFromSnapshot(ydoc, snapshot)\n * assert(restored.getText().toString() === 'world!')\n *\n * @param {Doc} originDoc\n * @param {Snapshot} snapshot\n * @param {Doc} [newDoc] Optionally, you may define the Yjs document that receives the data from originDoc\n * @return {Doc}\n */\nexport const createDocFromSnapshot = (originDoc, snapshot, newDoc = new Doc()) => {\n if (originDoc.gc) {\n // we should not try to restore a GC-ed document, because some of the restored items might have their content deleted\n throw new Error('Garbage-collection must be disabled in `originDoc`!')\n }\n const { sv, ds } = snapshot\n\n const encoder = new UpdateEncoderV2()\n originDoc.transact(transaction => {\n let size = 0\n sv.forEach(clock => {\n if (clock > 0) {\n size++\n }\n })\n encoding.writeVarUint(encoder.restEncoder, size)\n // splitting the structs before writing them to the encoder\n for (const [client, clock] of sv) {\n if (clock === 0) {\n continue\n }\n if (clock < getState(originDoc.store, client)) {\n getItemCleanStart(transaction, createID(client, clock))\n }\n const structs = originDoc.store.clients.get(client) || []\n const lastStructIndex = findIndexSS(structs, clock - 1)\n // write # encoded structs\n encoding.writeVarUint(encoder.restEncoder, lastStructIndex + 1)\n encoder.writeClient(client)\n // first clock written is 0\n encoding.writeVarUint(encoder.restEncoder, 0)\n for (let i = 0; i <= lastStructIndex; i++) {\n structs[i].write(encoder, 0)\n }\n }\n writeDeleteSet(encoder, ds)\n })\n\n applyUpdateV2(newDoc, encoder.toUint8Array(), 'snapshot')\n return newDoc\n}\n\n/**\n * @param {Snapshot} snapshot\n * @param {Uint8Array} update\n * @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]\n */\nexport const snapshotContainsUpdateV2 = (snapshot, update, YDecoder = UpdateDecoderV2) => {\n const structs = []\n const updateDecoder = new YDecoder(decoding.createDecoder(update))\n const lazyDecoder = new LazyStructReader(updateDecoder, false)\n for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) {\n structs.push(curr)\n if ((snapshot.sv.get(curr.id.client) || 0) < curr.id.clock + curr.length) {\n return false\n }\n }\n const mergedDS = mergeDeleteSets([snapshot.ds, readDeleteSet(updateDecoder)])\n return equalDeleteSets(snapshot.ds, mergedDS)\n}\n\n/**\n * @param {Snapshot} snapshot\n * @param {Uint8Array} update\n */\nexport const snapshotContainsUpdate = (snapshot, update) => snapshotContainsUpdateV2(snapshot, update, UpdateDecoderV1)\n", "import {\n GC,\n splitItem,\n Transaction, ID, Item, DSDecoderV2 // eslint-disable-line\n} from '../internals.js'\n\nimport * as math from 'lib0/math'\nimport * as error from 'lib0/error'\n\nexport class StructStore {\n constructor () {\n /**\n * @type {Map<number,Array<GC|Item>>}\n */\n this.clients = new Map()\n /**\n * @type {null | { missing: Map<number, number>, update: Uint8Array }}\n */\n this.pendingStructs = null\n /**\n * @type {null | Uint8Array}\n */\n this.pendingDs = null\n }\n}\n\n/**\n * Return the states as a Map<client,clock>.\n * Note that clock refers to the next expected clock id.\n *\n * @param {StructStore} store\n * @return {Map<number,number>}\n *\n * @public\n * @function\n */\nexport const getStateVector = store => {\n const sm = new Map()\n store.clients.forEach((structs, client) => {\n const struct = structs[structs.length - 1]\n sm.set(client, struct.id.clock + struct.length)\n })\n return sm\n}\n\n/**\n * @param {StructStore} store\n * @param {number} client\n * @return {number}\n *\n * @public\n * @function\n */\nexport const getState = (store, client) => {\n const structs = store.clients.get(client)\n if (structs === undefined) {\n return 0\n }\n const lastStruct = structs[structs.length - 1]\n return lastStruct.id.clock + lastStruct.length\n}\n\n/**\n * @param {StructStore} store\n *\n * @private\n * @function\n */\nexport const integrityCheck = store => {\n store.clients.forEach(structs => {\n for (let i = 1; i < structs.length; i++) {\n const l = structs[i - 1]\n const r = structs[i]\n if (l.id.clock + l.length !== r.id.clock) {\n throw new Error('StructStore failed integrity check')\n }\n }\n })\n}\n\n/**\n * @param {StructStore} store\n * @param {GC|Item} struct\n *\n * @private\n * @function\n */\nexport const addStruct = (store, struct) => {\n let structs = store.clients.get(struct.id.client)\n if (structs === undefined) {\n structs = []\n store.clients.set(struct.id.client, structs)\n } else {\n const lastStruct = structs[structs.length - 1]\n if (lastStruct.id.clock + lastStruct.length !== struct.id.clock) {\n throw error.unexpectedCase()\n }\n }\n structs.push(struct)\n}\n\n/**\n * Perform a binary search on a sorted array\n * @param {Array<Item|GC>} structs\n * @param {number} clock\n * @return {number}\n *\n * @private\n * @function\n */\nexport const findIndexSS = (structs, clock) => {\n let left = 0\n let right = structs.length - 1\n let mid = structs[right]\n let midclock = mid.id.clock\n if (midclock === clock) {\n return right\n }\n // @todo does it even make sense to pivot the search?\n // If a good split misses, it might actually increase the time to find the correct item.\n // Currently, the only advantage is that search with pivoting might find the item on the first try.\n let midindex = math.floor((clock / (midclock + mid.length - 1)) * right) // pivoting the search\n while (left <= right) {\n mid = structs[midindex]\n midclock = mid.id.clock\n if (midclock <= clock) {\n if (clock < midclock + mid.length) {\n return midindex\n }\n left = midindex + 1\n } else {\n right = midindex - 1\n }\n midindex = math.floor((left + right) / 2)\n }\n // Always check state before looking for a struct in StructStore\n // Therefore the case of not finding a struct is unexpected\n throw error.unexpectedCase()\n}\n\n/**\n * Expects that id is actually in store. This function throws or is an infinite loop otherwise.\n *\n * @param {StructStore} store\n * @param {ID} id\n * @return {GC|Item}\n *\n * @private\n * @function\n */\nexport const find = (store, id) => {\n /**\n * @type {Array<GC|Item>}\n */\n // @ts-ignore\n const structs = store.clients.get(id.client)\n return structs[findIndexSS(structs, id.clock)]\n}\n\n/**\n * Expects that id is actually in store. This function throws or is an infinite loop otherwise.\n * @private\n * @function\n */\nexport const getItem = /** @type {function(StructStore,ID):Item} */ (find)\n\n/**\n * @param {Transaction} transaction\n * @param {Array<Item|GC>} structs\n * @param {number} clock\n */\nexport const findIndexCleanStart = (transaction, structs, clock) => {\n const index = findIndexSS(structs, clock)\n const struct = structs[index]\n if (struct.id.clock < clock && struct instanceof Item) {\n structs.splice(index + 1, 0, splitItem(transaction, struct, clock - struct.id.clock))\n return index + 1\n }\n return index\n}\n\n/**\n * Expects that id is actually in store. This function throws or is an infinite loop otherwise.\n *\n * @param {Transaction} transaction\n * @param {ID} id\n * @return {Item}\n *\n * @private\n * @function\n */\nexport const getItemCleanStart = (transaction, id) => {\n const structs = /** @type {Array<Item>} */ (transaction.doc.store.clients.get(id.client))\n return structs[findIndexCleanStart(transaction, structs, id.clock)]\n}\n\n/**\n * Expects that id is actually in store. This function throws or is an infinite loop otherwise.\n *\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @param {ID} id\n * @return {Item}\n *\n * @private\n * @function\n */\nexport const getItemCleanEnd = (transaction, store, id) => {\n /**\n * @type {Array<Item>}\n */\n // @ts-ignore\n const structs = store.clients.get(id.client)\n const index = findIndexSS(structs, id.clock)\n const struct = structs[index]\n if (id.clock !== struct.id.clock + struct.length - 1 && struct.constructor !== GC) {\n structs.splice(index + 1, 0, splitItem(transaction, struct, id.clock - struct.id.clock + 1))\n }\n return struct\n}\n\n/**\n * Replace `item` with `newitem` in store\n * @param {StructStore} store\n * @param {GC|Item} struct\n * @param {GC|Item} newStruct\n *\n * @private\n * @function\n */\nexport const replaceStruct = (store, struct, newStruct) => {\n const structs = /** @type {Array<GC|Item>} */ (store.clients.get(struct.id.client))\n structs[findIndexSS(structs, struct.id.clock)] = newStruct\n}\n\n/**\n * Iterate over a range of structs\n *\n * @param {Transaction} transaction\n * @param {Array<Item|GC>} structs\n * @param {number} clockStart Inclusive start\n * @param {number} len\n * @param {function(GC|Item):void} f\n *\n * @function\n */\nexport const iterateStructs = (transaction, structs, clockStart, len, f) => {\n if (len === 0) {\n return\n }\n const clockEnd = clockStart + len\n let index = findIndexCleanStart(transaction, structs, clockStart)\n let struct\n do {\n struct = structs[index++]\n if (clockEnd < struct.id.clock + struct.length) {\n findIndexCleanStart(transaction, structs, clockEnd)\n }\n f(struct)\n } while (index < structs.length && structs[index].id.clock < clockEnd)\n}\n", "import {\n getState,\n writeStructsFromTransaction,\n writeDeleteSet,\n DeleteSet,\n sortAndMergeDeleteSet,\n getStateVector,\n findIndexSS,\n callEventHandlerListeners,\n Item,\n generateNewClientId,\n createID,\n cleanupYTextAfterTransaction,\n UpdateEncoderV1, UpdateEncoderV2, GC, StructStore, AbstractType, AbstractStruct, YEvent, Doc // eslint-disable-line\n} from '../internals.js'\n\nimport * as map from 'lib0/map'\nimport * as math from 'lib0/math'\nimport * as set from 'lib0/set'\nimport * as logging from 'lib0/logging'\nimport { callAll } from 'lib0/function'\n\n/**\n * A transaction is created for every change on the Yjs model. It is possible\n * to bundle changes on the Yjs model in a single transaction to\n * minimize the number on messages sent and the number of observer calls.\n * If possible the user of this library should bundle as many changes as\n * possible. Here is an example to illustrate the advantages of bundling:\n *\n * @example\n * const ydoc = new Y.Doc()\n * const map = ydoc.getMap('map')\n * // Log content when change is triggered\n * map.observe(() => {\n * console.log('change triggered')\n * })\n * // Each change on the map type triggers a log message:\n * map.set('a', 0) // => \"change triggered\"\n * map.set('b', 0) // => \"change triggered\"\n * // When put in a transaction, it will trigger the log after the transaction:\n * ydoc.transact(() => {\n * map.set('a', 1)\n * map.set('b', 1)\n * }) // => \"change triggered\"\n *\n * @public\n */\nexport class Transaction {\n /**\n * @param {Doc} doc\n * @param {any} origin\n * @param {boolean} local\n */\n constructor (doc, origin, local) {\n /**\n * The Yjs instance.\n * @type {Doc}\n */\n this.doc = doc\n /**\n * Describes the set of deleted items by ids\n * @type {DeleteSet}\n */\n this.deleteSet = new DeleteSet()\n /**\n * Holds the state before the transaction started.\n * @type {Map<Number,Number>}\n */\n this.beforeState = getStateVector(doc.store)\n /**\n * Holds the state after the transaction.\n * @type {Map<Number,Number>}\n */\n this.afterState = new Map()\n /**\n * All types that were directly modified (property added or child\n * inserted/deleted). New types are not included in this Set.\n * Maps from type to parentSubs (`item.parentSub = null` for YArray)\n * @type {Map<AbstractType<YEvent<any>>,Set<String|null>>}\n */\n this.changed = new Map()\n /**\n * Stores the events for the types that observe also child elements.\n * It is mainly used by `observeDeep`.\n * @type {Map<AbstractType<YEvent<any>>,Array<YEvent<any>>>}\n */\n this.changedParentTypes = new Map()\n /**\n * @type {Array<AbstractStruct>}\n */\n this._mergeStructs = []\n /**\n * @type {any}\n */\n this.origin = origin\n /**\n * Stores meta information on the transaction\n * @type {Map<any,any>}\n */\n this.meta = new Map()\n /**\n * Whether this change originates from this doc.\n * @type {boolean}\n */\n this.local = local\n /**\n * @type {Set<Doc>}\n */\n this.subdocsAdded = new Set()\n /**\n * @type {Set<Doc>}\n */\n this.subdocsRemoved = new Set()\n /**\n * @type {Set<Doc>}\n */\n this.subdocsLoaded = new Set()\n /**\n * @type {boolean}\n */\n this._needFormattingCleanup = false\n }\n}\n\n/**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {Transaction} transaction\n * @return {boolean} Whether data was written.\n */\nexport const writeUpdateMessageFromTransaction = (encoder, transaction) => {\n if (transaction.deleteSet.clients.size === 0 && !map.any(transaction.afterState, (clock, client) => transaction.beforeState.get(client) !== clock)) {\n return false\n }\n sortAndMergeDeleteSet(transaction.deleteSet)\n writeStructsFromTransaction(encoder, transaction)\n writeDeleteSet(encoder, transaction.deleteSet)\n return true\n}\n\n/**\n * @param {Transaction} transaction\n *\n * @private\n * @function\n */\nexport const nextID = transaction => {\n const y = transaction.doc\n return createID(y.clientID, getState(y.store, y.clientID))\n}\n\n/**\n * If `type.parent` was added in current transaction, `type` technically\n * did not change, it was just added and we should not fire events for `type`.\n *\n * @param {Transaction} transaction\n * @param {AbstractType<YEvent<any>>} type\n * @param {string|null} parentSub\n */\nexport const addChangedTypeToTransaction = (transaction, type, parentSub) => {\n const item = type._item\n if (item === null || (item.id.clock < (transaction.beforeState.get(item.id.client) || 0) && !item.deleted)) {\n map.setIfUndefined(transaction.changed, type, set.create).add(parentSub)\n }\n}\n\n/**\n * @param {Array<AbstractStruct>} structs\n * @param {number} pos\n * @return {number} # of merged structs\n */\nconst tryToMergeWithLefts = (structs, pos) => {\n let right = structs[pos]\n let left = structs[pos - 1]\n let i = pos\n for (; i > 0; right = left, left = structs[--i - 1]) {\n if (left.deleted === right.deleted && left.constructor === right.constructor) {\n if (left.mergeWith(right)) {\n if (right instanceof Item && right.parentSub !== null && /** @type {AbstractType<any>} */ (right.parent)._map.get(right.parentSub) === right) {\n /** @type {AbstractType<any>} */ (right.parent)._map.set(right.parentSub, /** @type {Item} */ (left))\n }\n continue\n }\n }\n break\n }\n const merged = pos - i\n if (merged) {\n // remove all merged structs from the array\n structs.splice(pos + 1 - merged, merged)\n }\n return merged\n}\n\n/**\n * @param {DeleteSet} ds\n * @param {StructStore} store\n * @param {function(Item):boolean} gcFilter\n */\nconst tryGcDeleteSet = (ds, store, gcFilter) => {\n for (const [client, deleteItems] of ds.clients.entries()) {\n const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client))\n for (let di = deleteItems.length - 1; di >= 0; di--) {\n const deleteItem = deleteItems[di]\n const endDeleteItemClock = deleteItem.clock + deleteItem.len\n for (\n let si = findIndexSS(structs, deleteItem.clock), struct = structs[si];\n si < structs.length && struct.id.clock < endDeleteItemClock;\n struct = structs[++si]\n ) {\n const struct = structs[si]\n if (deleteItem.clock + deleteItem.len <= struct.id.clock) {\n break\n }\n if (struct instanceof Item && struct.deleted && !struct.keep && gcFilter(struct)) {\n struct.gc(store, false)\n }\n }\n }\n }\n}\n\n/**\n * @param {DeleteSet} ds\n * @param {StructStore} store\n */\nconst tryMergeDeleteSet = (ds, store) => {\n // try to merge deleted / gc'd items\n // merge from right to left for better efficiency and so we don't miss any merge targets\n ds.clients.forEach((deleteItems, client) => {\n const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client))\n for (let di = deleteItems.length - 1; di >= 0; di--) {\n const deleteItem = deleteItems[di]\n // start with merging the item next to the last deleted item\n const mostRightIndexToCheck = math.min(structs.length - 1, 1 + findIndexSS(structs, deleteItem.clock + deleteItem.len - 1))\n for (\n let si = mostRightIndexToCheck, struct = structs[si];\n si > 0 && struct.id.clock >= deleteItem.clock;\n struct = structs[si]\n ) {\n si -= 1 + tryToMergeWithLefts(structs, si)\n }\n }\n })\n}\n\n/**\n * @param {DeleteSet} ds\n * @param {StructStore} store\n * @param {function(Item):boolean} gcFilter\n */\nexport const tryGc = (ds, store, gcFilter) => {\n tryGcDeleteSet(ds, store, gcFilter)\n tryMergeDeleteSet(ds, store)\n}\n\n/**\n * @param {Array<Transaction>} transactionCleanups\n * @param {number} i\n */\nconst cleanupTransactions = (transactionCleanups, i) => {\n if (i < transactionCleanups.length) {\n const transaction = transactionCleanups[i]\n const doc = transaction.doc\n const store = doc.store\n const ds = transaction.deleteSet\n const mergeStructs = transaction._mergeStructs\n try {\n sortAndMergeDeleteSet(ds)\n transaction.afterState = getStateVector(transaction.doc.store)\n doc.emit('beforeObserverCalls', [transaction, doc])\n /**\n * An array of event callbacks.\n *\n * Each callback is called even if the other ones throw errors.\n *\n * @type {Array<function():void>}\n */\n const fs = []\n // observe events on changed types\n transaction.changed.forEach((subs, itemtype) =>\n fs.push(() => {\n if (itemtype._item === null || !itemtype._item.deleted) {\n itemtype._callObserver(transaction, subs)\n }\n })\n )\n fs.push(() => {\n // deep observe events\n transaction.changedParentTypes.forEach((events, type) => {\n // We need to think about the possibility that the user transforms the\n // Y.Doc in the event.\n if (type._dEH.l.length > 0 && (type._item === null || !type._item.deleted)) {\n events = events\n .filter(event =>\n event.target._item === null || !event.target._item.deleted\n )\n events\n .forEach(event => {\n event.currentTarget = type\n // path is relative to the current target\n event._path = null\n })\n // sort events by path length so that top-level events are fired first.\n events\n .sort((event1, event2) => event1.path.length - event2.path.length)\n fs.push(() => {\n // We don't need to check for events.length\n // because we know it has at least one element\n callEventHandlerListeners(type._dEH, events, transaction)\n })\n }\n })\n fs.push(() => doc.emit('afterTransaction', [transaction, doc]))\n fs.push(() => {\n if (transaction._needFormattingCleanup) {\n cleanupYTextAfterTransaction(transaction)\n }\n })\n })\n callAll(fs, [])\n } finally {\n // Replace deleted items with ItemDeleted / GC.\n // This is where content is actually remove from the Yjs Doc.\n if (doc.gc) {\n tryGcDeleteSet(ds, store, doc.gcFilter)\n }\n tryMergeDeleteSet(ds, store)\n\n // on all affected store.clients props, try to merge\n transaction.afterState.forEach((clock, client) => {\n const beforeClock = transaction.beforeState.get(client) || 0\n if (beforeClock !== clock) {\n const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client))\n // we iterate from right to left so we can safely remove entries\n const firstChangePos = math.max(findIndexSS(structs, beforeClock), 1)\n for (let i = structs.length - 1; i >= firstChangePos;) {\n i -= 1 + tryToMergeWithLefts(structs, i)\n }\n }\n })\n // try to merge mergeStructs\n // @todo: it makes more sense to transform mergeStructs to a DS, sort it, and merge from right to left\n // but at the moment DS does not handle duplicates\n for (let i = mergeStructs.length - 1; i >= 0; i--) {\n const { client, clock } = mergeStructs[i].id\n const structs = /** @type {Array<GC|Item>} */ (store.clients.get(client))\n const replacedStructPos = findIndexSS(structs, clock)\n if (replacedStructPos + 1 < structs.length) {\n if (tryToMergeWithLefts(structs, replacedStructPos + 1) > 1) {\n continue // no need to perform next check, both are already merged\n }\n }\n if (replacedStructPos > 0) {\n tryToMergeWithLefts(structs, replacedStructPos)\n }\n }\n if (!transaction.local && transaction.afterState.get(doc.clientID) !== transaction.beforeState.get(doc.clientID)) {\n logging.print(logging.ORANGE, logging.BOLD, '[yjs] ', logging.UNBOLD, logging.RED, 'Changed the client-id because another client seems to be using it.')\n doc.clientID = generateNewClientId()\n }\n // @todo Merge all the transactions into one and provide send the data as a single update message\n doc.emit('afterTransactionCleanup', [transaction, doc])\n if (doc._observers.has('update')) {\n const encoder = new UpdateEncoderV1()\n const hasContent = writeUpdateMessageFromTransaction(encoder, transaction)\n if (hasContent) {\n doc.emit('update', [encoder.toUint8Array(), transaction.origin, doc, transaction])\n }\n }\n if (doc._observers.has('updateV2')) {\n const encoder = new UpdateEncoderV2()\n const hasContent = writeUpdateMessageFromTransaction(encoder, transaction)\n if (hasContent) {\n doc.emit('updateV2', [encoder.toUint8Array(), transaction.origin, doc, transaction])\n }\n }\n const { subdocsAdded, subdocsLoaded, subdocsRemoved } = transaction\n if (subdocsAdded.size > 0 || subdocsRemoved.size > 0 || subdocsLoaded.size > 0) {\n subdocsAdded.forEach(subdoc => {\n subdoc.clientID = doc.clientID\n if (subdoc.collectionid == null) {\n subdoc.collectionid = doc.collectionid\n }\n doc.subdocs.add(subdoc)\n })\n subdocsRemoved.forEach(subdoc => doc.subdocs.delete(subdoc))\n doc.emit('subdocs', [{ loaded: subdocsLoaded, added: subdocsAdded, removed: subdocsRemoved }, doc, transaction])\n subdocsRemoved.forEach(subdoc => subdoc.destroy())\n }\n\n if (transactionCleanups.length <= i + 1) {\n doc._transactionCleanups = []\n doc.emit('afterAllTransactions', [doc, transactionCleanups])\n } else {\n cleanupTransactions(transactionCleanups, i + 1)\n }\n }\n }\n}\n\n/**\n * Implements the functionality of `y.transact(()=>{..})`\n *\n * @template T\n * @param {Doc} doc\n * @param {function(Transaction):T} f\n * @param {any} [origin=true]\n * @return {T}\n *\n * @function\n */\nexport const transact = (doc, f, origin = null, local = true) => {\n const transactionCleanups = doc._transactionCleanups\n let initialCall = false\n /**\n * @type {any}\n */\n let result = null\n if (doc._transaction === null) {\n initialCall = true\n doc._transaction = new Transaction(doc, origin, local)\n transactionCleanups.push(doc._transaction)\n if (transactionCleanups.length === 1) {\n doc.emit('beforeAllTransactions', [doc])\n }\n doc.emit('beforeTransaction', [doc._transaction, doc])\n }\n try {\n result = f(doc._transaction)\n } finally {\n if (initialCall) {\n const finishCleanup = doc._transaction === transactionCleanups[0]\n doc._transaction = null\n if (finishCleanup) {\n // The first transaction ended, now process observer calls.\n // Observer call may create new transactions for which we need to call the observers and do cleanup.\n // We don't want to nest these calls, so we execute these calls one after\n // another.\n // Also we need to ensure that all cleanups are called, even if the\n // observes throw errors.\n // This file is full of hacky try {} finally {} blocks to ensure that an\n // event can throw errors and also that the cleanup is called.\n cleanupTransactions(transactionCleanups, 0)\n }\n }\n }\n return result\n}\n", "import {\n mergeDeleteSets,\n iterateDeletedStructs,\n keepItem,\n transact,\n createID,\n redoItem,\n isParentOf,\n followRedone,\n getItemCleanStart,\n isDeleted,\n addToDeleteSet,\n YEvent, Transaction, Doc, Item, GC, DeleteSet, AbstractType // eslint-disable-line\n} from '../internals.js'\n\nimport * as time from 'lib0/time'\nimport * as array from 'lib0/array'\nimport * as logging from 'lib0/logging'\nimport { ObservableV2 } from 'lib0/observable'\n\nexport class StackItem {\n /**\n * @param {DeleteSet} deletions\n * @param {DeleteSet} insertions\n */\n constructor (deletions, insertions) {\n this.insertions = insertions\n this.deletions = deletions\n /**\n * Use this to save and restore metadata like selection range\n */\n this.meta = new Map()\n }\n}\n/**\n * @param {Transaction} tr\n * @param {UndoManager} um\n * @param {StackItem} stackItem\n */\nconst clearUndoManagerStackItem = (tr, um, stackItem) => {\n iterateDeletedStructs(tr, stackItem.deletions, item => {\n if (item instanceof Item && um.scope.some(type => type === tr.doc || isParentOf(/** @type {AbstractType<any>} */ (type), item))) {\n keepItem(item, false)\n }\n })\n}\n\n/**\n * @param {UndoManager} undoManager\n * @param {Array<StackItem>} stack\n * @param {'undo'|'redo'} eventType\n * @return {StackItem?}\n */\nconst popStackItem = (undoManager, stack, eventType) => {\n /**\n * Keep a reference to the transaction so we can fire the event with the changedParentTypes\n * @type {any}\n */\n let _tr = null\n const doc = undoManager.doc\n const scope = undoManager.scope\n transact(doc, transaction => {\n while (stack.length > 0 && undoManager.currStackItem === null) {\n const store = doc.store\n const stackItem = /** @type {StackItem} */ (stack.pop())\n /**\n * @type {Set<Item>}\n */\n const itemsToRedo = new Set()\n /**\n * @type {Array<Item>}\n */\n const itemsToDelete = []\n let performedChange = false\n iterateDeletedStructs(transaction, stackItem.insertions, struct => {\n if (struct instanceof Item) {\n if (struct.redone !== null) {\n let { item, diff } = followRedone(store, struct.id)\n if (diff > 0) {\n item = getItemCleanStart(transaction, createID(item.id.client, item.id.clock + diff))\n }\n struct = item\n }\n if (!struct.deleted && scope.some(type => type === transaction.doc || isParentOf(/** @type {AbstractType<any>} */ (type), /** @type {Item} */ (struct)))) {\n itemsToDelete.push(struct)\n }\n }\n })\n iterateDeletedStructs(transaction, stackItem.deletions, struct => {\n if (\n struct instanceof Item &&\n scope.some(type => type === transaction.doc || isParentOf(/** @type {AbstractType<any>} */ (type), struct)) &&\n // Never redo structs in stackItem.insertions because they were created and deleted in the same capture interval.\n !isDeleted(stackItem.insertions, struct.id)\n ) {\n itemsToRedo.add(struct)\n }\n })\n itemsToRedo.forEach(struct => {\n performedChange = redoItem(transaction, struct, itemsToRedo, stackItem.insertions, undoManager.ignoreRemoteMapChanges, undoManager) !== null || performedChange\n })\n // We want to delete in reverse order so that children are deleted before\n // parents, so we have more information available when items are filtered.\n for (let i = itemsToDelete.length - 1; i >= 0; i--) {\n const item = itemsToDelete[i]\n if (undoManager.deleteFilter(item)) {\n item.delete(transaction)\n performedChange = true\n }\n }\n undoManager.currStackItem = performedChange ? stackItem : null\n }\n transaction.changed.forEach((subProps, type) => {\n // destroy search marker if necessary\n if (subProps.has(null) && type._searchMarker) {\n type._searchMarker.length = 0\n }\n })\n _tr = transaction\n }, undoManager)\n const res = undoManager.currStackItem\n if (res != null) {\n const changedParentTypes = _tr.changedParentTypes\n undoManager.emit('stack-item-popped', [{ stackItem: res, type: eventType, changedParentTypes, origin: undoManager }, undoManager])\n undoManager.currStackItem = null\n }\n return res\n}\n\n/**\n * @typedef {Object} UndoManagerOptions\n * @property {number} [UndoManagerOptions.captureTimeout=500]\n * @property {function(Transaction):boolean} [UndoManagerOptions.captureTransaction] Do not capture changes of a Transaction if result false.\n * @property {function(Item):boolean} [UndoManagerOptions.deleteFilter=()=>true] Sometimes\n * it is necessary to filter what an Undo/Redo operation can delete. If this\n * filter returns false, the type/item won't be deleted even it is in the\n * undo/redo scope.\n * @property {Set<any>} [UndoManagerOptions.trackedOrigins=new Set([null])]\n * @property {boolean} [ignoreRemoteMapChanges] Experimental. By default, the UndoManager will never overwrite remote changes. Enable this property to enable overwriting remote changes on key-value changes (Y.Map, properties on Y.Xml, etc..).\n * @property {Doc} [doc] The document that this UndoManager operates on. Only needed if typeScope is empty.\n */\n\n/**\n * @typedef {Object} StackItemEvent\n * @property {StackItem} StackItemEvent.stackItem\n * @property {any} StackItemEvent.origin\n * @property {'undo'|'redo'} StackItemEvent.type\n * @property {Map<AbstractType<YEvent<any>>,Array<YEvent<any>>>} StackItemEvent.changedParentTypes\n */\n\n/**\n * Fires 'stack-item-added' event when a stack item was added to either the undo- or\n * the redo-stack. You may store additional stack information via the\n * metadata property on `event.stackItem.meta` (it is a `Map` of metadata properties).\n * Fires 'stack-item-popped' event when a stack item was popped from either the\n * undo- or the redo-stack. You may restore the saved stack information from `event.stackItem.meta`.\n *\n * @extends {ObservableV2<{'stack-item-added':function(StackItemEvent, UndoManager):void, 'stack-item-popped': function(StackItemEvent, UndoManager):void, 'stack-cleared': function({ undoStackCleared: boolean, redoStackCleared: boolean }):void, 'stack-item-updated': function(StackItemEvent, UndoManager):void }>}\n */\nexport class UndoManager extends ObservableV2 {\n /**\n * @param {Doc|AbstractType<any>|Array<AbstractType<any>>} typeScope Limits the scope of the UndoManager. If this is set to a ydoc instance, all changes on that ydoc will be undone. If set to a specific type, only changes on that type or its children will be undone. Also accepts an array of types.\n * @param {UndoManagerOptions} options\n */\n constructor (typeScope, {\n captureTimeout = 500,\n captureTransaction = _tr => true,\n deleteFilter = () => true,\n trackedOrigins = new Set([null]),\n ignoreRemoteMapChanges = false,\n doc = /** @type {Doc} */ (array.isArray(typeScope) ? typeScope[0].doc : typeScope instanceof Doc ? typeScope : typeScope.doc)\n } = {}) {\n super()\n /**\n * @type {Array<AbstractType<any> | Doc>}\n */\n this.scope = []\n this.doc = doc\n this.addToScope(typeScope)\n this.deleteFilter = deleteFilter\n trackedOrigins.add(this)\n this.trackedOrigins = trackedOrigins\n this.captureTransaction = captureTransaction\n /**\n * @type {Array<StackItem>}\n */\n this.undoStack = []\n /**\n * @type {Array<StackItem>}\n */\n this.redoStack = []\n /**\n * Whether the client is currently undoing (calling UndoManager.undo)\n *\n * @type {boolean}\n */\n this.undoing = false\n this.redoing = false\n /**\n * The currently popped stack item if UndoManager.undoing or UndoManager.redoing\n *\n * @type {StackItem|null}\n */\n this.currStackItem = null\n this.lastChange = 0\n this.ignoreRemoteMapChanges = ignoreRemoteMapChanges\n this.captureTimeout = captureTimeout\n /**\n * @param {Transaction} transaction\n */\n this.afterTransactionHandler = transaction => {\n // Only track certain transactions\n if (\n !this.captureTransaction(transaction) ||\n !this.scope.some(type => transaction.changedParentTypes.has(/** @type {AbstractType<any>} */ (type)) || type === this.doc) ||\n (!this.trackedOrigins.has(transaction.origin) && (!transaction.origin || !this.trackedOrigins.has(transaction.origin.constructor)))\n ) {\n return\n }\n const undoing = this.undoing\n const redoing = this.redoing\n const stack = undoing ? this.redoStack : this.undoStack\n if (undoing) {\n this.stopCapturing() // next undo should not be appended to last stack item\n } else if (!redoing) {\n // neither undoing nor redoing: delete redoStack\n this.clear(false, true)\n }\n const insertions = new DeleteSet()\n transaction.afterState.forEach((endClock, client) => {\n const startClock = transaction.beforeState.get(client) || 0\n const len = endClock - startClock\n if (len > 0) {\n addToDeleteSet(insertions, client, startClock, len)\n }\n })\n const now = time.getUnixTime()\n let didAdd = false\n if (this.lastChange > 0 && now - this.lastChange < this.captureTimeout && stack.length > 0 && !undoing && !redoing) {\n // append change to last stack op\n const lastOp = stack[stack.length - 1]\n lastOp.deletions = mergeDeleteSets([lastOp.deletions, transaction.deleteSet])\n lastOp.insertions = mergeDeleteSets([lastOp.insertions, insertions])\n } else {\n // create a new stack op\n stack.push(new StackItem(transaction.deleteSet, insertions))\n didAdd = true\n }\n if (!undoing && !redoing) {\n this.lastChange = now\n }\n // make sure that deleted structs are not gc'd\n iterateDeletedStructs(transaction, transaction.deleteSet, /** @param {Item|GC} item */ item => {\n if (item instanceof Item && this.scope.some(type => type === transaction.doc || isParentOf(/** @type {AbstractType<any>} */ (type), item))) {\n keepItem(item, true)\n }\n })\n /**\n * @type {[StackItemEvent, UndoManager]}\n */\n const changeEvent = [{ stackItem: stack[stack.length - 1], origin: transaction.origin, type: undoing ? 'redo' : 'undo', changedParentTypes: transaction.changedParentTypes }, this]\n if (didAdd) {\n this.emit('stack-item-added', changeEvent)\n } else {\n this.emit('stack-item-updated', changeEvent)\n }\n }\n this.destroy = this.destroy.bind(this)\n this.doc.on('afterTransaction', this.afterTransactionHandler)\n this.doc.on('destroy', this.destroy)\n }\n\n /**\n * Extend the scope.\n *\n * @param {Array<AbstractType<any> | Doc> | AbstractType<any> | Doc} ytypes\n */\n addToScope (ytypes) {\n const tmpSet = new Set(this.scope)\n ytypes = array.isArray(ytypes) ? ytypes : [ytypes]\n ytypes.forEach(ytype => {\n if (!tmpSet.has(ytype)) {\n tmpSet.add(ytype)\n if (ytype instanceof AbstractType ? ytype.doc !== this.doc : ytype !== this.doc) logging.warn('[yjs#509] Not same Y.Doc') // use MultiDocUndoManager instead. also see https://github.com/yjs/yjs/issues/509\n this.scope.push(ytype)\n }\n })\n }\n\n /**\n * @param {any} origin\n */\n addTrackedOrigin (origin) {\n this.trackedOrigins.add(origin)\n }\n\n /**\n * @param {any} origin\n */\n removeTrackedOrigin (origin) {\n this.trackedOrigins.delete(origin)\n }\n\n clear (clearUndoStack = true, clearRedoStack = true) {\n if ((clearUndoStack && this.canUndo()) || (clearRedoStack && this.canRedo())) {\n this.doc.transact(tr => {\n if (clearUndoStack) {\n this.undoStack.forEach(item => clearUndoManagerStackItem(tr, this, item))\n this.undoStack = []\n }\n if (clearRedoStack) {\n this.redoStack.forEach(item => clearUndoManagerStackItem(tr, this, item))\n this.redoStack = []\n }\n this.emit('stack-cleared', [{ undoStackCleared: clearUndoStack, redoStackCleared: clearRedoStack }])\n })\n }\n }\n\n /**\n * UndoManager merges Undo-StackItem if they are created within time-gap\n * smaller than `options.captureTimeout`. Call `um.stopCapturing()` so that the next\n * StackItem won't be merged.\n *\n *\n * @example\n * // without stopCapturing\n * ytext.insert(0, 'a')\n * ytext.insert(1, 'b')\n * um.undo()\n * ytext.toString() // => '' (note that 'ab' was removed)\n * // with stopCapturing\n * ytext.insert(0, 'a')\n * um.stopCapturing()\n * ytext.insert(0, 'b')\n * um.undo()\n * ytext.toString() // => 'a' (note that only 'b' was removed)\n *\n */\n stopCapturing () {\n this.lastChange = 0\n }\n\n /**\n * Undo last changes on type.\n *\n * @return {StackItem?} Returns StackItem if a change was applied\n */\n undo () {\n this.undoing = true\n let res\n try {\n res = popStackItem(this, this.undoStack, 'undo')\n } finally {\n this.undoing = false\n }\n return res\n }\n\n /**\n * Redo last undo operation.\n *\n * @return {StackItem?} Returns StackItem if a change was applied\n */\n redo () {\n this.redoing = true\n let res\n try {\n res = popStackItem(this, this.redoStack, 'redo')\n } finally {\n this.redoing = false\n }\n return res\n }\n\n /**\n * Are undo steps available?\n *\n * @return {boolean} `true` if undo is possible\n */\n canUndo () {\n return this.undoStack.length > 0\n }\n\n /**\n * Are redo steps available?\n *\n * @return {boolean} `true` if redo is possible\n */\n canRedo () {\n return this.redoStack.length > 0\n }\n\n destroy () {\n this.trackedOrigins.delete(this)\n this.doc.off('afterTransaction', this.afterTransactionHandler)\n this.doc.off('destroy', this.destroy)\n super.destroy()\n }\n}\n", "import * as binary from 'lib0/binary'\nimport * as decoding from 'lib0/decoding'\nimport * as encoding from 'lib0/encoding'\nimport * as error from 'lib0/error'\nimport * as f from 'lib0/function'\nimport * as logging from 'lib0/logging'\nimport * as map from 'lib0/map'\nimport * as math from 'lib0/math'\nimport * as string from 'lib0/string'\n\nimport {\n ContentAny,\n ContentBinary,\n ContentDeleted,\n ContentDoc,\n ContentEmbed,\n ContentFormat,\n ContentJSON,\n ContentString,\n ContentType,\n createID,\n decodeStateVector,\n DSEncoderV1,\n DSEncoderV2,\n GC,\n Item,\n mergeDeleteSets,\n readDeleteSet,\n readItemContent,\n Skip,\n UpdateDecoderV1,\n UpdateDecoderV2,\n UpdateEncoderV1,\n UpdateEncoderV2,\n writeDeleteSet,\n YXmlElement,\n YXmlHook\n} from '../internals.js'\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n */\nfunction * lazyStructReaderGenerator (decoder) {\n const numOfStateUpdates = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < numOfStateUpdates; i++) {\n const numberOfStructs = decoding.readVarUint(decoder.restDecoder)\n const client = decoder.readClient()\n let clock = decoding.readVarUint(decoder.restDecoder)\n for (let i = 0; i < numberOfStructs; i++) {\n const info = decoder.readInfo()\n // @todo use switch instead of ifs\n if (info === 10) {\n const len = decoding.readVarUint(decoder.restDecoder)\n yield new Skip(createID(client, clock), len)\n clock += len\n } else if ((binary.BITS5 & info) !== 0) {\n const cantCopyParentInfo = (info & (binary.BIT7 | binary.BIT8)) === 0\n // If parent = null and neither left nor right are defined, then we know that `parent` is child of `y`\n // and we read the next string as parentYKey.\n // It indicates how we store/retrieve parent from `y.share`\n // @type {string|null}\n const struct = new Item(\n createID(client, clock),\n null, // left\n (info & binary.BIT8) === binary.BIT8 ? decoder.readLeftID() : null, // origin\n null, // right\n (info & binary.BIT7) === binary.BIT7 ? decoder.readRightID() : null, // right origin\n // @ts-ignore Force writing a string here.\n cantCopyParentInfo ? (decoder.readParentInfo() ? decoder.readString() : decoder.readLeftID()) : null, // parent\n cantCopyParentInfo && (info & binary.BIT6) === binary.BIT6 ? decoder.readString() : null, // parentSub\n readItemContent(decoder, info) // item content\n )\n yield struct\n clock += struct.length\n } else {\n const len = decoder.readLen()\n yield new GC(createID(client, clock), len)\n clock += len\n }\n }\n }\n}\n\nexport class LazyStructReader {\n /**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @param {boolean} filterSkips\n */\n constructor (decoder, filterSkips) {\n this.gen = lazyStructReaderGenerator(decoder)\n /**\n * @type {null | Item | Skip | GC}\n */\n this.curr = null\n this.done = false\n this.filterSkips = filterSkips\n this.next()\n }\n\n /**\n * @return {Item | GC | Skip |null}\n */\n next () {\n // ignore \"Skip\" structs\n do {\n this.curr = this.gen.next().value || null\n } while (this.filterSkips && this.curr !== null && this.curr.constructor === Skip)\n return this.curr\n }\n}\n\n/**\n * @param {Uint8Array} update\n *\n */\nexport const logUpdate = update => logUpdateV2(update, UpdateDecoderV1)\n\n/**\n * @param {Uint8Array} update\n * @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]\n *\n */\nexport const logUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {\n const structs = []\n const updateDecoder = new YDecoder(decoding.createDecoder(update))\n const lazyDecoder = new LazyStructReader(updateDecoder, false)\n for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) {\n structs.push(curr)\n }\n logging.print('Structs: ', structs)\n const ds = readDeleteSet(updateDecoder)\n logging.print('DeleteSet: ', ds)\n}\n\n/**\n * @param {Uint8Array} update\n *\n */\nexport const decodeUpdate = (update) => decodeUpdateV2(update, UpdateDecoderV1)\n\n/**\n * @param {Uint8Array} update\n * @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} [YDecoder]\n *\n */\nexport const decodeUpdateV2 = (update, YDecoder = UpdateDecoderV2) => {\n const structs = []\n const updateDecoder = new YDecoder(decoding.createDecoder(update))\n const lazyDecoder = new LazyStructReader(updateDecoder, false)\n for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) {\n structs.push(curr)\n }\n return {\n structs,\n ds: readDeleteSet(updateDecoder)\n }\n}\n\nexport class LazyStructWriter {\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n */\n constructor (encoder) {\n this.currClient = 0\n this.startClock = 0\n this.written = 0\n this.encoder = encoder\n /**\n * We want to write operations lazily, but also we need to know beforehand how many operations we want to write for each client.\n *\n * This kind of meta-information (#clients, #structs-per-client-written) is written to the restEncoder.\n *\n * We fragment the restEncoder and store a slice of it per-client until we know how many clients there are.\n * When we flush (toUint8Array) we write the restEncoder using the fragments and the meta-information.\n *\n * @type {Array<{ written: number, restEncoder: Uint8Array }>}\n */\n this.clientStructs = []\n }\n}\n\n/**\n * @param {Array<Uint8Array>} updates\n * @return {Uint8Array}\n */\nexport const mergeUpdates = updates => mergeUpdatesV2(updates, UpdateDecoderV1, UpdateEncoderV1)\n\n/**\n * @param {Uint8Array} update\n * @param {typeof DSEncoderV1 | typeof DSEncoderV2} YEncoder\n * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} YDecoder\n * @return {Uint8Array}\n */\nexport const encodeStateVectorFromUpdateV2 = (update, YEncoder = DSEncoderV2, YDecoder = UpdateDecoderV2) => {\n const encoder = new YEncoder()\n const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false)\n let curr = updateDecoder.curr\n if (curr !== null) {\n let size = 0\n let currClient = curr.id.client\n let stopCounting = curr.id.clock !== 0 // must start at 0\n let currClock = stopCounting ? 0 : curr.id.clock + curr.length\n for (; curr !== null; curr = updateDecoder.next()) {\n if (currClient !== curr.id.client) {\n if (currClock !== 0) {\n size++\n // We found a new client\n // write what we have to the encoder\n encoding.writeVarUint(encoder.restEncoder, currClient)\n encoding.writeVarUint(encoder.restEncoder, currClock)\n }\n currClient = curr.id.client\n currClock = 0\n stopCounting = curr.id.clock !== 0\n }\n // we ignore skips\n if (curr.constructor === Skip) {\n stopCounting = true\n }\n if (!stopCounting) {\n currClock = curr.id.clock + curr.length\n }\n }\n // write what we have\n if (currClock !== 0) {\n size++\n encoding.writeVarUint(encoder.restEncoder, currClient)\n encoding.writeVarUint(encoder.restEncoder, currClock)\n }\n // prepend the size of the state vector\n const enc = encoding.createEncoder()\n encoding.writeVarUint(enc, size)\n encoding.writeBinaryEncoder(enc, encoder.restEncoder)\n encoder.restEncoder = enc\n return encoder.toUint8Array()\n } else {\n encoding.writeVarUint(encoder.restEncoder, 0)\n return encoder.toUint8Array()\n }\n}\n\n/**\n * @param {Uint8Array} update\n * @return {Uint8Array}\n */\nexport const encodeStateVectorFromUpdate = update => encodeStateVectorFromUpdateV2(update, DSEncoderV1, UpdateDecoderV1)\n\n/**\n * @param {Uint8Array} update\n * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} YDecoder\n * @return {{ from: Map<number,number>, to: Map<number,number> }}\n */\nexport const parseUpdateMetaV2 = (update, YDecoder = UpdateDecoderV2) => {\n /**\n * @type {Map<number, number>}\n */\n const from = new Map()\n /**\n * @type {Map<number, number>}\n */\n const to = new Map()\n const updateDecoder = new LazyStructReader(new YDecoder(decoding.createDecoder(update)), false)\n let curr = updateDecoder.curr\n if (curr !== null) {\n let currClient = curr.id.client\n let currClock = curr.id.clock\n // write the beginning to `from`\n from.set(currClient, currClock)\n for (; curr !== null; curr = updateDecoder.next()) {\n if (currClient !== curr.id.client) {\n // We found a new client\n // write the end to `to`\n to.set(currClient, currClock)\n // write the beginning to `from`\n from.set(curr.id.client, curr.id.clock)\n // update currClient\n currClient = curr.id.client\n }\n currClock = curr.id.clock + curr.length\n }\n // write the end to `to`\n to.set(currClient, currClock)\n }\n return { from, to }\n}\n\n/**\n * @param {Uint8Array} update\n * @return {{ from: Map<number,number>, to: Map<number,number> }}\n */\nexport const parseUpdateMeta = update => parseUpdateMetaV2(update, UpdateDecoderV1)\n\n/**\n * This method is intended to slice any kind of struct and retrieve the right part.\n * It does not handle side-effects, so it should only be used by the lazy-encoder.\n *\n * @param {Item | GC | Skip} left\n * @param {number} diff\n * @return {Item | GC}\n */\nconst sliceStruct = (left, diff) => {\n if (left.constructor === GC) {\n const { client, clock } = left.id\n return new GC(createID(client, clock + diff), left.length - diff)\n } else if (left.constructor === Skip) {\n const { client, clock } = left.id\n return new Skip(createID(client, clock + diff), left.length - diff)\n } else {\n const leftItem = /** @type {Item} */ (left)\n const { client, clock } = leftItem.id\n return new Item(\n createID(client, clock + diff),\n null,\n createID(client, clock + diff - 1),\n null,\n leftItem.rightOrigin,\n leftItem.parent,\n leftItem.parentSub,\n leftItem.content.splice(diff)\n )\n }\n}\n\n/**\n *\n * This function works similarly to `readUpdateV2`.\n *\n * @param {Array<Uint8Array>} updates\n * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]\n * @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]\n * @return {Uint8Array}\n */\nexport const mergeUpdatesV2 = (updates, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {\n if (updates.length === 1) {\n return updates[0]\n }\n const updateDecoders = updates.map(update => new YDecoder(decoding.createDecoder(update)))\n let lazyStructDecoders = updateDecoders.map(decoder => new LazyStructReader(decoder, true))\n\n /**\n * @todo we don't need offset because we always slice before\n * @type {null | { struct: Item | GC | Skip, offset: number }}\n */\n let currWrite = null\n\n const updateEncoder = new YEncoder()\n // write structs lazily\n const lazyStructEncoder = new LazyStructWriter(updateEncoder)\n\n // Note: We need to ensure that all lazyStructDecoders are fully consumed\n // Note: Should merge document updates whenever possible - even from different updates\n // Note: Should handle that some operations cannot be applied yet ()\n\n while (true) {\n // Write higher clients first ⇒ sort by clientID & clock and remove decoders without content\n lazyStructDecoders = lazyStructDecoders.filter(dec => dec.curr !== null)\n lazyStructDecoders.sort(\n /** @type {function(any,any):number} */ (dec1, dec2) => {\n if (dec1.curr.id.client === dec2.curr.id.client) {\n const clockDiff = dec1.curr.id.clock - dec2.curr.id.clock\n if (clockDiff === 0) {\n // @todo remove references to skip since the structDecoders must filter Skips.\n return dec1.curr.constructor === dec2.curr.constructor\n ? 0\n : dec1.curr.constructor === Skip ? 1 : -1 // we are filtering skips anyway.\n } else {\n return clockDiff\n }\n } else {\n return dec2.curr.id.client - dec1.curr.id.client\n }\n }\n )\n if (lazyStructDecoders.length === 0) {\n break\n }\n const currDecoder = lazyStructDecoders[0]\n // write from currDecoder until the next operation is from another client or if filler-struct\n // then we need to reorder the decoders and find the next operation to write\n const firstClient = /** @type {Item | GC} */ (currDecoder.curr).id.client\n\n if (currWrite !== null) {\n let curr = /** @type {Item | GC | null} */ (currDecoder.curr)\n let iterated = false\n\n // iterate until we find something that we haven't written already\n // remember: first the high client-ids are written\n while (curr !== null && curr.id.clock + curr.length <= currWrite.struct.id.clock + currWrite.struct.length && curr.id.client >= currWrite.struct.id.client) {\n curr = currDecoder.next()\n iterated = true\n }\n if (\n curr === null || // current decoder is empty\n curr.id.client !== firstClient || // check whether there is another decoder that has has updates from `firstClient`\n (iterated && curr.id.clock > currWrite.struct.id.clock + currWrite.struct.length) // the above while loop was used and we are potentially missing updates\n ) {\n continue\n }\n\n if (firstClient !== currWrite.struct.id.client) {\n writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)\n currWrite = { struct: curr, offset: 0 }\n currDecoder.next()\n } else {\n if (currWrite.struct.id.clock + currWrite.struct.length < curr.id.clock) {\n // @todo write currStruct & set currStruct = Skip(clock = currStruct.id.clock + currStruct.length, length = curr.id.clock - self.clock)\n if (currWrite.struct.constructor === Skip) {\n // extend existing skip\n currWrite.struct.length = curr.id.clock + curr.length - currWrite.struct.id.clock\n } else {\n writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)\n const diff = curr.id.clock - currWrite.struct.id.clock - currWrite.struct.length\n /**\n * @type {Skip}\n */\n const struct = new Skip(createID(firstClient, currWrite.struct.id.clock + currWrite.struct.length), diff)\n currWrite = { struct, offset: 0 }\n }\n } else { // if (currWrite.struct.id.clock + currWrite.struct.length >= curr.id.clock) {\n const diff = currWrite.struct.id.clock + currWrite.struct.length - curr.id.clock\n if (diff > 0) {\n if (currWrite.struct.constructor === Skip) {\n // prefer to slice Skip because the other struct might contain more information\n currWrite.struct.length -= diff\n } else {\n curr = sliceStruct(curr, diff)\n }\n }\n if (!currWrite.struct.mergeWith(/** @type {any} */ (curr))) {\n writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)\n currWrite = { struct: curr, offset: 0 }\n currDecoder.next()\n }\n }\n }\n } else {\n currWrite = { struct: /** @type {Item | GC} */ (currDecoder.curr), offset: 0 }\n currDecoder.next()\n }\n for (\n let next = currDecoder.curr;\n next !== null && next.id.client === firstClient && next.id.clock === currWrite.struct.id.clock + currWrite.struct.length && next.constructor !== Skip;\n next = currDecoder.next()\n ) {\n writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)\n currWrite = { struct: next, offset: 0 }\n }\n }\n if (currWrite !== null) {\n writeStructToLazyStructWriter(lazyStructEncoder, currWrite.struct, currWrite.offset)\n currWrite = null\n }\n finishLazyStructWriting(lazyStructEncoder)\n\n const dss = updateDecoders.map(decoder => readDeleteSet(decoder))\n const ds = mergeDeleteSets(dss)\n writeDeleteSet(updateEncoder, ds)\n return updateEncoder.toUint8Array()\n}\n\n/**\n * @param {Uint8Array} update\n * @param {Uint8Array} sv\n * @param {typeof UpdateDecoderV1 | typeof UpdateDecoderV2} [YDecoder]\n * @param {typeof UpdateEncoderV1 | typeof UpdateEncoderV2} [YEncoder]\n */\nexport const diffUpdateV2 = (update, sv, YDecoder = UpdateDecoderV2, YEncoder = UpdateEncoderV2) => {\n const state = decodeStateVector(sv)\n const encoder = new YEncoder()\n const lazyStructWriter = new LazyStructWriter(encoder)\n const decoder = new YDecoder(decoding.createDecoder(update))\n const reader = new LazyStructReader(decoder, false)\n while (reader.curr) {\n const curr = reader.curr\n const currClient = curr.id.client\n const svClock = state.get(currClient) || 0\n if (reader.curr.constructor === Skip) {\n // the first written struct shouldn't be a skip\n reader.next()\n continue\n }\n if (curr.id.clock + curr.length > svClock) {\n writeStructToLazyStructWriter(lazyStructWriter, curr, math.max(svClock - curr.id.clock, 0))\n reader.next()\n while (reader.curr && reader.curr.id.client === currClient) {\n writeStructToLazyStructWriter(lazyStructWriter, reader.curr, 0)\n reader.next()\n }\n } else {\n // read until something new comes up\n while (reader.curr && reader.curr.id.client === currClient && reader.curr.id.clock + reader.curr.length <= svClock) {\n reader.next()\n }\n }\n }\n finishLazyStructWriting(lazyStructWriter)\n // write ds\n const ds = readDeleteSet(decoder)\n writeDeleteSet(encoder, ds)\n return encoder.toUint8Array()\n}\n\n/**\n * @param {Uint8Array} update\n * @param {Uint8Array} sv\n */\nexport const diffUpdate = (update, sv) => diffUpdateV2(update, sv, UpdateDecoderV1, UpdateEncoderV1)\n\n/**\n * @param {LazyStructWriter} lazyWriter\n */\nconst flushLazyStructWriter = lazyWriter => {\n if (lazyWriter.written > 0) {\n lazyWriter.clientStructs.push({ written: lazyWriter.written, restEncoder: encoding.toUint8Array(lazyWriter.encoder.restEncoder) })\n lazyWriter.encoder.restEncoder = encoding.createEncoder()\n lazyWriter.written = 0\n }\n}\n\n/**\n * @param {LazyStructWriter} lazyWriter\n * @param {Item | GC} struct\n * @param {number} offset\n */\nconst writeStructToLazyStructWriter = (lazyWriter, struct, offset) => {\n // flush curr if we start another client\n if (lazyWriter.written > 0 && lazyWriter.currClient !== struct.id.client) {\n flushLazyStructWriter(lazyWriter)\n }\n if (lazyWriter.written === 0) {\n lazyWriter.currClient = struct.id.client\n // write next client\n lazyWriter.encoder.writeClient(struct.id.client)\n // write startClock\n encoding.writeVarUint(lazyWriter.encoder.restEncoder, struct.id.clock + offset)\n }\n struct.write(lazyWriter.encoder, offset)\n lazyWriter.written++\n}\n/**\n * Call this function when we collected all parts and want to\n * put all the parts together. After calling this method,\n * you can continue using the UpdateEncoder.\n *\n * @param {LazyStructWriter} lazyWriter\n */\nconst finishLazyStructWriting = (lazyWriter) => {\n flushLazyStructWriter(lazyWriter)\n\n // this is a fresh encoder because we called flushCurr\n const restEncoder = lazyWriter.encoder.restEncoder\n\n /**\n * Now we put all the fragments together.\n * This works similarly to `writeClientsStructs`\n */\n\n // write # states that were updated - i.e. the clients\n encoding.writeVarUint(restEncoder, lazyWriter.clientStructs.length)\n\n for (let i = 0; i < lazyWriter.clientStructs.length; i++) {\n const partStructs = lazyWriter.clientStructs[i]\n /**\n * Works similarly to `writeStructs`\n */\n // write # encoded structs\n encoding.writeVarUint(restEncoder, partStructs.written)\n // write the rest of the fragment\n encoding.writeUint8Array(restEncoder, partStructs.restEncoder)\n }\n}\n\n/**\n * @param {Uint8Array} update\n * @param {function(Item|GC|Skip):Item|GC|Skip} blockTransformer\n * @param {typeof UpdateDecoderV2 | typeof UpdateDecoderV1} YDecoder\n * @param {typeof UpdateEncoderV2 | typeof UpdateEncoderV1 } YEncoder\n */\nexport const convertUpdateFormat = (update, blockTransformer, YDecoder, YEncoder) => {\n const updateDecoder = new YDecoder(decoding.createDecoder(update))\n const lazyDecoder = new LazyStructReader(updateDecoder, false)\n const updateEncoder = new YEncoder()\n const lazyWriter = new LazyStructWriter(updateEncoder)\n for (let curr = lazyDecoder.curr; curr !== null; curr = lazyDecoder.next()) {\n writeStructToLazyStructWriter(lazyWriter, blockTransformer(curr), 0)\n }\n finishLazyStructWriting(lazyWriter)\n const ds = readDeleteSet(updateDecoder)\n writeDeleteSet(updateEncoder, ds)\n return updateEncoder.toUint8Array()\n}\n\n/**\n * @typedef {Object} ObfuscatorOptions\n * @property {boolean} [ObfuscatorOptions.formatting=true]\n * @property {boolean} [ObfuscatorOptions.subdocs=true]\n * @property {boolean} [ObfuscatorOptions.yxml=true] Whether to obfuscate nodeName / hookName\n */\n\n/**\n * @param {ObfuscatorOptions} obfuscator\n */\nconst createObfuscator = ({ formatting = true, subdocs = true, yxml = true } = {}) => {\n let i = 0\n const mapKeyCache = map.create()\n const nodeNameCache = map.create()\n const formattingKeyCache = map.create()\n const formattingValueCache = map.create()\n formattingValueCache.set(null, null) // end of a formatting range should always be the end of a formatting range\n /**\n * @param {Item|GC|Skip} block\n * @return {Item|GC|Skip}\n */\n return block => {\n switch (block.constructor) {\n case GC:\n case Skip:\n return block\n case Item: {\n const item = /** @type {Item} */ (block)\n const content = item.content\n switch (content.constructor) {\n case ContentDeleted:\n break\n case ContentType: {\n if (yxml) {\n const type = /** @type {ContentType} */ (content).type\n if (type instanceof YXmlElement) {\n type.nodeName = map.setIfUndefined(nodeNameCache, type.nodeName, () => 'node-' + i)\n }\n if (type instanceof YXmlHook) {\n type.hookName = map.setIfUndefined(nodeNameCache, type.hookName, () => 'hook-' + i)\n }\n }\n break\n }\n case ContentAny: {\n const c = /** @type {ContentAny} */ (content)\n c.arr = c.arr.map(() => i)\n break\n }\n case ContentBinary: {\n const c = /** @type {ContentBinary} */ (content)\n c.content = new Uint8Array([i])\n break\n }\n case ContentDoc: {\n const c = /** @type {ContentDoc} */ (content)\n if (subdocs) {\n c.opts = {}\n c.doc.guid = i + ''\n }\n break\n }\n case ContentEmbed: {\n const c = /** @type {ContentEmbed} */ (content)\n c.embed = {}\n break\n }\n case ContentFormat: {\n const c = /** @type {ContentFormat} */ (content)\n if (formatting) {\n c.key = map.setIfUndefined(formattingKeyCache, c.key, () => i + '')\n c.value = map.setIfUndefined(formattingValueCache, c.value, () => ({ i }))\n }\n break\n }\n case ContentJSON: {\n const c = /** @type {ContentJSON} */ (content)\n c.arr = c.arr.map(() => i)\n break\n }\n case ContentString: {\n const c = /** @type {ContentString} */ (content)\n c.str = string.repeat((i % 10) + '', c.str.length)\n break\n }\n default:\n // unknown content type\n error.unexpectedCase()\n }\n if (item.parentSub) {\n item.parentSub = map.setIfUndefined(mapKeyCache, item.parentSub, () => i + '')\n }\n i++\n return block\n }\n default:\n // unknown block-type\n error.unexpectedCase()\n }\n }\n}\n\n/**\n * This function obfuscates the content of a Yjs update. This is useful to share\n * buggy Yjs documents while significantly limiting the possibility that a\n * developer can on the user. Note that it might still be possible to deduce\n * some information by analyzing the \"structure\" of the document or by analyzing\n * the typing behavior using the CRDT-related metadata that is still kept fully\n * intact.\n *\n * @param {Uint8Array} update\n * @param {ObfuscatorOptions} [opts]\n */\nexport const obfuscateUpdate = (update, opts) => convertUpdateFormat(update, createObfuscator(opts), UpdateDecoderV1, UpdateEncoderV1)\n\n/**\n * @param {Uint8Array} update\n * @param {ObfuscatorOptions} [opts]\n */\nexport const obfuscateUpdateV2 = (update, opts) => convertUpdateFormat(update, createObfuscator(opts), UpdateDecoderV2, UpdateEncoderV2)\n\n/**\n * @param {Uint8Array} update\n */\nexport const convertUpdateFormatV1ToV2 = update => convertUpdateFormat(update, f.id, UpdateDecoderV1, UpdateEncoderV2)\n\n/**\n * @param {Uint8Array} update\n */\nexport const convertUpdateFormatV2ToV1 = update => convertUpdateFormat(update, f.id, UpdateDecoderV2, UpdateEncoderV1)\n", "import {\n isDeleted,\n Item, AbstractType, Transaction, AbstractStruct // eslint-disable-line\n} from '../internals.js'\n\nimport * as set from 'lib0/set'\nimport * as array from 'lib0/array'\nimport * as error from 'lib0/error'\n\nconst errorComputeChanges = 'You must not compute changes after the event-handler fired.'\n\n/**\n * @template {AbstractType<any>} T\n * YEvent describes the changes on a YType.\n */\nexport class YEvent {\n /**\n * @param {T} target The changed type.\n * @param {Transaction} transaction\n */\n constructor (target, transaction) {\n /**\n * The type on which this event was created on.\n * @type {T}\n */\n this.target = target\n /**\n * The current target on which the observe callback is called.\n * @type {AbstractType<any>}\n */\n this.currentTarget = target\n /**\n * The transaction that triggered this event.\n * @type {Transaction}\n */\n this.transaction = transaction\n /**\n * @type {Object|null}\n */\n this._changes = null\n /**\n * @type {null | Map<string, { action: 'add' | 'update' | 'delete', oldValue: any }>}\n */\n this._keys = null\n /**\n * @type {null | Array<{ insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any> }>}\n */\n this._delta = null\n /**\n * @type {Array<string|number>|null}\n */\n this._path = null\n }\n\n /**\n * Computes the path from `y` to the changed type.\n *\n * @todo v14 should standardize on path: Array<{parent, index}> because that is easier to work with.\n *\n * The following property holds:\n * @example\n * let type = y\n * event.path.forEach(dir => {\n * type = type.get(dir)\n * })\n * type === event.target // => true\n */\n get path () {\n return this._path || (this._path = getPathTo(this.currentTarget, this.target))\n }\n\n /**\n * Check if a struct is deleted by this event.\n *\n * In contrast to change.deleted, this method also returns true if the struct was added and then deleted.\n *\n * @param {AbstractStruct} struct\n * @return {boolean}\n */\n deletes (struct) {\n return isDeleted(this.transaction.deleteSet, struct.id)\n }\n\n /**\n * @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any }>}\n */\n get keys () {\n if (this._keys === null) {\n if (this.transaction.doc._transactionCleanups.length === 0) {\n throw error.create(errorComputeChanges)\n }\n const keys = new Map()\n const target = this.target\n const changed = /** @type Set<string|null> */ (this.transaction.changed.get(target))\n changed.forEach(key => {\n if (key !== null) {\n const item = /** @type {Item} */ (target._map.get(key))\n /**\n * @type {'delete' | 'add' | 'update'}\n */\n let action\n let oldValue\n if (this.adds(item)) {\n let prev = item.left\n while (prev !== null && this.adds(prev)) {\n prev = prev.left\n }\n if (this.deletes(item)) {\n if (prev !== null && this.deletes(prev)) {\n action = 'delete'\n oldValue = array.last(prev.content.getContent())\n } else {\n return\n }\n } else {\n if (prev !== null && this.deletes(prev)) {\n action = 'update'\n oldValue = array.last(prev.content.getContent())\n } else {\n action = 'add'\n oldValue = undefined\n }\n }\n } else {\n if (this.deletes(item)) {\n action = 'delete'\n oldValue = array.last(/** @type {Item} */ item.content.getContent())\n } else {\n return // nop\n }\n }\n keys.set(key, { action, oldValue })\n }\n })\n this._keys = keys\n }\n return this._keys\n }\n\n /**\n * This is a computed property. Note that this can only be safely computed during the\n * event call. Computing this property after other changes happened might result in\n * unexpected behavior (incorrect computation of deltas). A safe way to collect changes\n * is to store the `changes` or the `delta` object. Avoid storing the `transaction` object.\n *\n * @type {Array<{insert?: string | Array<any> | object | AbstractType<any>, retain?: number, delete?: number, attributes?: Object<string, any>}>}\n */\n get delta () {\n return this.changes.delta\n }\n\n /**\n * Check if a struct is added by this event.\n *\n * In contrast to change.deleted, this method also returns true if the struct was added and then deleted.\n *\n * @param {AbstractStruct} struct\n * @return {boolean}\n */\n adds (struct) {\n return struct.id.clock >= (this.transaction.beforeState.get(struct.id.client) || 0)\n }\n\n /**\n * This is a computed property. Note that this can only be safely computed during the\n * event call. Computing this property after other changes happened might result in\n * unexpected behavior (incorrect computation of deltas). A safe way to collect changes\n * is to store the `changes` or the `delta` object. Avoid storing the `transaction` object.\n *\n * @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string, delete?:number, retain?:number}>}}\n */\n get changes () {\n let changes = this._changes\n if (changes === null) {\n if (this.transaction.doc._transactionCleanups.length === 0) {\n throw error.create(errorComputeChanges)\n }\n const target = this.target\n const added = set.create()\n const deleted = set.create()\n /**\n * @type {Array<{insert:Array<any>}|{delete:number}|{retain:number}>}\n */\n const delta = []\n changes = {\n added,\n deleted,\n delta,\n keys: this.keys\n }\n const changed = /** @type Set<string|null> */ (this.transaction.changed.get(target))\n if (changed.has(null)) {\n /**\n * @type {any}\n */\n let lastOp = null\n const packOp = () => {\n if (lastOp) {\n delta.push(lastOp)\n }\n }\n for (let item = target._start; item !== null; item = item.right) {\n if (item.deleted) {\n if (this.deletes(item) && !this.adds(item)) {\n if (lastOp === null || lastOp.delete === undefined) {\n packOp()\n lastOp = { delete: 0 }\n }\n lastOp.delete += item.length\n deleted.add(item)\n } // else nop\n } else {\n if (this.adds(item)) {\n if (lastOp === null || lastOp.insert === undefined) {\n packOp()\n lastOp = { insert: [] }\n }\n lastOp.insert = lastOp.insert.concat(item.content.getContent())\n added.add(item)\n } else {\n if (lastOp === null || lastOp.retain === undefined) {\n packOp()\n lastOp = { retain: 0 }\n }\n lastOp.retain += item.length\n }\n }\n }\n if (lastOp !== null && lastOp.retain === undefined) {\n packOp()\n }\n }\n this._changes = changes\n }\n return /** @type {any} */ (changes)\n }\n}\n\n/**\n * Compute the path from this type to the specified target.\n *\n * @example\n * // `child` should be accessible via `type.get(path[0]).get(path[1])..`\n * const path = type.getPathTo(child)\n * // assuming `type instanceof YArray`\n * console.log(path) // might look like => [2, 'key1']\n * child === type.get(path[0]).get(path[1])\n *\n * @param {AbstractType<any>} parent\n * @param {AbstractType<any>} child target\n * @return {Array<string|number>} Path to the target\n *\n * @private\n * @function\n */\nconst getPathTo = (parent, child) => {\n const path = []\n while (child._item !== null && child !== parent) {\n if (child._item.parentSub !== null) {\n // parent is map-ish\n path.unshift(child._item.parentSub)\n } else {\n // parent is array-ish\n let i = 0\n let c = /** @type {AbstractType<any>} */ (child._item.parent)._start\n while (c !== child._item && c !== null) {\n if (!c.deleted && c.countable) {\n i += c.length\n }\n c = c.right\n }\n path.unshift(i)\n }\n child = /** @type {AbstractType<any>} */ (child._item.parent)\n }\n return path\n}\n", "import {\n removeEventHandlerListener,\n callEventHandlerListeners,\n addEventHandlerListener,\n createEventHandler,\n getState,\n isVisible,\n ContentType,\n createID,\n ContentAny,\n ContentBinary,\n getItemCleanStart,\n ContentDoc, YText, YArray, UpdateEncoderV1, UpdateEncoderV2, Doc, Snapshot, Transaction, EventHandler, YEvent, Item, // eslint-disable-line\n} from '../internals.js'\n\nimport * as map from 'lib0/map'\nimport * as iterator from 'lib0/iterator'\nimport * as error from 'lib0/error'\nimport * as math from 'lib0/math'\nimport * as log from 'lib0/logging'\n\n/**\n * https://docs.yjs.dev/getting-started/working-with-shared-types#caveats\n */\nexport const warnPrematureAccess = () => { log.warn('Invalid access: Add Yjs type to a document before reading data.') }\n\nconst maxSearchMarker = 80\n\n/**\n * A unique timestamp that identifies each marker.\n *\n * Time is relative,.. this is more like an ever-increasing clock.\n *\n * @type {number}\n */\nlet globalSearchMarkerTimestamp = 0\n\nexport class ArraySearchMarker {\n /**\n * @param {Item} p\n * @param {number} index\n */\n constructor (p, index) {\n p.marker = true\n this.p = p\n this.index = index\n this.timestamp = globalSearchMarkerTimestamp++\n }\n}\n\n/**\n * @param {ArraySearchMarker} marker\n */\nconst refreshMarkerTimestamp = marker => { marker.timestamp = globalSearchMarkerTimestamp++ }\n\n/**\n * This is rather complex so this function is the only thing that should overwrite a marker\n *\n * @param {ArraySearchMarker} marker\n * @param {Item} p\n * @param {number} index\n */\nconst overwriteMarker = (marker, p, index) => {\n marker.p.marker = false\n marker.p = p\n p.marker = true\n marker.index = index\n marker.timestamp = globalSearchMarkerTimestamp++\n}\n\n/**\n * @param {Array<ArraySearchMarker>} searchMarker\n * @param {Item} p\n * @param {number} index\n */\nconst markPosition = (searchMarker, p, index) => {\n if (searchMarker.length >= maxSearchMarker) {\n // override oldest marker (we don't want to create more objects)\n const marker = searchMarker.reduce((a, b) => a.timestamp < b.timestamp ? a : b)\n overwriteMarker(marker, p, index)\n return marker\n } else {\n // create new marker\n const pm = new ArraySearchMarker(p, index)\n searchMarker.push(pm)\n return pm\n }\n}\n\n/**\n * Search marker help us to find positions in the associative array faster.\n *\n * They speed up the process of finding a position without much bookkeeping.\n *\n * A maximum of `maxSearchMarker` objects are created.\n *\n * This function always returns a refreshed marker (updated timestamp)\n *\n * @param {AbstractType<any>} yarray\n * @param {number} index\n */\nexport const findMarker = (yarray, index) => {\n if (yarray._start === null || index === 0 || yarray._searchMarker === null) {\n return null\n }\n const marker = yarray._searchMarker.length === 0 ? null : yarray._searchMarker.reduce((a, b) => math.abs(index - a.index) < math.abs(index - b.index) ? a : b)\n let p = yarray._start\n let pindex = 0\n if (marker !== null) {\n p = marker.p\n pindex = marker.index\n refreshMarkerTimestamp(marker) // we used it, we might need to use it again\n }\n // iterate to right if possible\n while (p.right !== null && pindex < index) {\n if (!p.deleted && p.countable) {\n if (index < pindex + p.length) {\n break\n }\n pindex += p.length\n }\n p = p.right\n }\n // iterate to left if necessary (might be that pindex > index)\n while (p.left !== null && pindex > index) {\n p = p.left\n if (!p.deleted && p.countable) {\n pindex -= p.length\n }\n }\n // we want to make sure that p can't be merged with left, because that would screw up everything\n // in that cas just return what we have (it is most likely the best marker anyway)\n // iterate to left until p can't be merged with left\n while (p.left !== null && p.left.id.client === p.id.client && p.left.id.clock + p.left.length === p.id.clock) {\n p = p.left\n if (!p.deleted && p.countable) {\n pindex -= p.length\n }\n }\n\n // @todo remove!\n // assure position\n // {\n // let start = yarray._start\n // let pos = 0\n // while (start !== p) {\n // if (!start.deleted && start.countable) {\n // pos += start.length\n // }\n // start = /** @type {Item} */ (start.right)\n // }\n // if (pos !== pindex) {\n // debugger\n // throw new Error('Gotcha position fail!')\n // }\n // }\n // if (marker) {\n // if (window.lengths == null) {\n // window.lengths = []\n // window.getLengths = () => window.lengths.sort((a, b) => a - b)\n // }\n // window.lengths.push(marker.index - pindex)\n // console.log('distance', marker.index - pindex, 'len', p && p.parent.length)\n // }\n if (marker !== null && math.abs(marker.index - pindex) < /** @type {YText|YArray<any>} */ (p.parent).length / maxSearchMarker) {\n // adjust existing marker\n overwriteMarker(marker, p, pindex)\n return marker\n } else {\n // create new marker\n return markPosition(yarray._searchMarker, p, pindex)\n }\n}\n\n/**\n * Update markers when a change happened.\n *\n * This should be called before doing a deletion!\n *\n * @param {Array<ArraySearchMarker>} searchMarker\n * @param {number} index\n * @param {number} len If insertion, len is positive. If deletion, len is negative.\n */\nexport const updateMarkerChanges = (searchMarker, index, len) => {\n for (let i = searchMarker.length - 1; i >= 0; i--) {\n const m = searchMarker[i]\n if (len > 0) {\n /**\n * @type {Item|null}\n */\n let p = m.p\n p.marker = false\n // Ideally we just want to do a simple position comparison, but this will only work if\n // search markers don't point to deleted items for formats.\n // Iterate marker to prev undeleted countable position so we know what to do when updating a position\n while (p && (p.deleted || !p.countable)) {\n p = p.left\n if (p && !p.deleted && p.countable) {\n // adjust position. the loop should break now\n m.index -= p.length\n }\n }\n if (p === null || p.marker === true) {\n // remove search marker if updated position is null or if position is already marked\n searchMarker.splice(i, 1)\n continue\n }\n m.p = p\n p.marker = true\n }\n if (index < m.index || (len > 0 && index === m.index)) { // a simple index <= m.index check would actually suffice\n m.index = math.max(index, m.index + len)\n }\n }\n}\n\n/**\n * Accumulate all (list) children of a type and return them as an Array.\n *\n * @param {AbstractType<any>} t\n * @return {Array<Item>}\n */\nexport const getTypeChildren = t => {\n t.doc ?? warnPrematureAccess()\n let s = t._start\n const arr = []\n while (s) {\n arr.push(s)\n s = s.right\n }\n return arr\n}\n\n/**\n * Call event listeners with an event. This will also add an event to all\n * parents (for `.observeDeep` handlers).\n *\n * @template EventType\n * @param {AbstractType<EventType>} type\n * @param {Transaction} transaction\n * @param {EventType} event\n */\nexport const callTypeObservers = (type, transaction, event) => {\n const changedType = type\n const changedParentTypes = transaction.changedParentTypes\n while (true) {\n // @ts-ignore\n map.setIfUndefined(changedParentTypes, type, () => []).push(event)\n if (type._item === null) {\n break\n }\n type = /** @type {AbstractType<any>} */ (type._item.parent)\n }\n callEventHandlerListeners(changedType._eH, event, transaction)\n}\n\n/**\n * @template EventType\n * Abstract Yjs Type class\n */\nexport class AbstractType {\n constructor () {\n /**\n * @type {Item|null}\n */\n this._item = null\n /**\n * @type {Map<string,Item>}\n */\n this._map = new Map()\n /**\n * @type {Item|null}\n */\n this._start = null\n /**\n * @type {Doc|null}\n */\n this.doc = null\n this._length = 0\n /**\n * Event handlers\n * @type {EventHandler<EventType,Transaction>}\n */\n this._eH = createEventHandler()\n /**\n * Deep event handlers\n * @type {EventHandler<Array<YEvent<any>>,Transaction>}\n */\n this._dEH = createEventHandler()\n /**\n * @type {null | Array<ArraySearchMarker>}\n */\n this._searchMarker = null\n }\n\n /**\n * @return {AbstractType<any>|null}\n */\n get parent () {\n return this._item ? /** @type {AbstractType<any>} */ (this._item.parent) : null\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Doc} y The Yjs instance\n * @param {Item|null} item\n */\n _integrate (y, item) {\n this.doc = y\n this._item = item\n }\n\n /**\n * @return {AbstractType<EventType>}\n */\n _copy () {\n throw error.methodUnimplemented()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {AbstractType<EventType>}\n */\n clone () {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder\n */\n _write (_encoder) { }\n\n /**\n * The first non-deleted item\n */\n get _first () {\n let n = this._start\n while (n !== null && n.deleted) {\n n = n.right\n }\n return n\n }\n\n /**\n * Creates YEvent and calls all type observers.\n * Must be implemented by each type.\n *\n * @param {Transaction} transaction\n * @param {Set<null|string>} _parentSubs Keys changed on this type. `null` if list was modified.\n */\n _callObserver (transaction, _parentSubs) {\n if (!transaction.local && this._searchMarker) {\n this._searchMarker.length = 0\n }\n }\n\n /**\n * Observe all events that are created on this type.\n *\n * @param {function(EventType, Transaction):void} f Observer function\n */\n observe (f) {\n addEventHandlerListener(this._eH, f)\n }\n\n /**\n * Observe all events that are created by this type and its children.\n *\n * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function\n */\n observeDeep (f) {\n addEventHandlerListener(this._dEH, f)\n }\n\n /**\n * Unregister an observer function.\n *\n * @param {function(EventType,Transaction):void} f Observer function\n */\n unobserve (f) {\n removeEventHandlerListener(this._eH, f)\n }\n\n /**\n * Unregister an observer function.\n *\n * @param {function(Array<YEvent<any>>,Transaction):void} f Observer function\n */\n unobserveDeep (f) {\n removeEventHandlerListener(this._dEH, f)\n }\n\n /**\n * @abstract\n * @return {any}\n */\n toJSON () {}\n}\n\n/**\n * @param {AbstractType<any>} type\n * @param {number} start\n * @param {number} end\n * @return {Array<any>}\n *\n * @private\n * @function\n */\nexport const typeListSlice = (type, start, end) => {\n type.doc ?? warnPrematureAccess()\n if (start < 0) {\n start = type._length + start\n }\n if (end < 0) {\n end = type._length + end\n }\n let len = end - start\n const cs = []\n let n = type._start\n while (n !== null && len > 0) {\n if (n.countable && !n.deleted) {\n const c = n.content.getContent()\n if (c.length <= start) {\n start -= c.length\n } else {\n for (let i = start; i < c.length && len > 0; i++) {\n cs.push(c[i])\n len--\n }\n start = 0\n }\n }\n n = n.right\n }\n return cs\n}\n\n/**\n * @param {AbstractType<any>} type\n * @return {Array<any>}\n *\n * @private\n * @function\n */\nexport const typeListToArray = type => {\n type.doc ?? warnPrematureAccess()\n const cs = []\n let n = type._start\n while (n !== null) {\n if (n.countable && !n.deleted) {\n const c = n.content.getContent()\n for (let i = 0; i < c.length; i++) {\n cs.push(c[i])\n }\n }\n n = n.right\n }\n return cs\n}\n\n/**\n * @param {AbstractType<any>} type\n * @param {Snapshot} snapshot\n * @return {Array<any>}\n *\n * @private\n * @function\n */\nexport const typeListToArraySnapshot = (type, snapshot) => {\n const cs = []\n let n = type._start\n while (n !== null) {\n if (n.countable && isVisible(n, snapshot)) {\n const c = n.content.getContent()\n for (let i = 0; i < c.length; i++) {\n cs.push(c[i])\n }\n }\n n = n.right\n }\n return cs\n}\n\n/**\n * Executes a provided function on once on every element of this YArray.\n *\n * @param {AbstractType<any>} type\n * @param {function(any,number,any):void} f A function to execute on every element of this YArray.\n *\n * @private\n * @function\n */\nexport const typeListForEach = (type, f) => {\n let index = 0\n let n = type._start\n type.doc ?? warnPrematureAccess()\n while (n !== null) {\n if (n.countable && !n.deleted) {\n const c = n.content.getContent()\n for (let i = 0; i < c.length; i++) {\n f(c[i], index++, type)\n }\n }\n n = n.right\n }\n}\n\n/**\n * @template C,R\n * @param {AbstractType<any>} type\n * @param {function(C,number,AbstractType<any>):R} f\n * @return {Array<R>}\n *\n * @private\n * @function\n */\nexport const typeListMap = (type, f) => {\n /**\n * @type {Array<any>}\n */\n const result = []\n typeListForEach(type, (c, i) => {\n result.push(f(c, i, type))\n })\n return result\n}\n\n/**\n * @param {AbstractType<any>} type\n * @return {IterableIterator<any>}\n *\n * @private\n * @function\n */\nexport const typeListCreateIterator = type => {\n let n = type._start\n /**\n * @type {Array<any>|null}\n */\n let currentContent = null\n let currentContentIndex = 0\n return {\n [Symbol.iterator] () {\n return this\n },\n next: () => {\n // find some content\n if (currentContent === null) {\n while (n !== null && n.deleted) {\n n = n.right\n }\n // check if we reached the end, no need to check currentContent, because it does not exist\n if (n === null) {\n return {\n done: true,\n value: undefined\n }\n }\n // we found n, so we can set currentContent\n currentContent = n.content.getContent()\n currentContentIndex = 0\n n = n.right // we used the content of n, now iterate to next\n }\n const value = currentContent[currentContentIndex++]\n // check if we need to empty currentContent\n if (currentContent.length <= currentContentIndex) {\n currentContent = null\n }\n return {\n done: false,\n value\n }\n }\n }\n}\n\n/**\n * Executes a provided function on once on every element of this YArray.\n * Operates on a snapshotted state of the document.\n *\n * @param {AbstractType<any>} type\n * @param {function(any,number,AbstractType<any>):void} f A function to execute on every element of this YArray.\n * @param {Snapshot} snapshot\n *\n * @private\n * @function\n */\nexport const typeListForEachSnapshot = (type, f, snapshot) => {\n let index = 0\n let n = type._start\n while (n !== null) {\n if (n.countable && isVisible(n, snapshot)) {\n const c = n.content.getContent()\n for (let i = 0; i < c.length; i++) {\n f(c[i], index++, type)\n }\n }\n n = n.right\n }\n}\n\n/**\n * @param {AbstractType<any>} type\n * @param {number} index\n * @return {any}\n *\n * @private\n * @function\n */\nexport const typeListGet = (type, index) => {\n type.doc ?? warnPrematureAccess()\n const marker = findMarker(type, index)\n let n = type._start\n if (marker !== null) {\n n = marker.p\n index -= marker.index\n }\n for (; n !== null; n = n.right) {\n if (!n.deleted && n.countable) {\n if (index < n.length) {\n return n.content.getContent()[index]\n }\n index -= n.length\n }\n }\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {Item?} referenceItem\n * @param {Array<Object<string,any>|Array<any>|boolean|number|null|string|Uint8Array>} content\n *\n * @private\n * @function\n */\nexport const typeListInsertGenericsAfter = (transaction, parent, referenceItem, content) => {\n let left = referenceItem\n const doc = transaction.doc\n const ownClientId = doc.clientID\n const store = doc.store\n const right = referenceItem === null ? parent._start : referenceItem.right\n /**\n * @type {Array<Object|Array<any>|number|null>}\n */\n let jsonContent = []\n const packJsonContent = () => {\n if (jsonContent.length > 0) {\n left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentAny(jsonContent))\n left.integrate(transaction, 0)\n jsonContent = []\n }\n }\n content.forEach(c => {\n if (c === null) {\n jsonContent.push(c)\n } else {\n switch (c.constructor) {\n case Number:\n case Object:\n case Boolean:\n case Array:\n case String:\n jsonContent.push(c)\n break\n default:\n packJsonContent()\n switch (c.constructor) {\n case Uint8Array:\n case ArrayBuffer:\n left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentBinary(new Uint8Array(/** @type {Uint8Array} */ (c))))\n left.integrate(transaction, 0)\n break\n case Doc:\n left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentDoc(/** @type {Doc} */ (c)))\n left.integrate(transaction, 0)\n break\n default:\n if (c instanceof AbstractType) {\n left = new Item(createID(ownClientId, getState(store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentType(c))\n left.integrate(transaction, 0)\n } else {\n throw new Error('Unexpected content type in insert operation')\n }\n }\n }\n }\n })\n packJsonContent()\n}\n\nconst lengthExceeded = () => error.create('Length exceeded!')\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {number} index\n * @param {Array<Object<string,any>|Array<any>|number|null|string|Uint8Array>} content\n *\n * @private\n * @function\n */\nexport const typeListInsertGenerics = (transaction, parent, index, content) => {\n if (index > parent._length) {\n throw lengthExceeded()\n }\n if (index === 0) {\n if (parent._searchMarker) {\n updateMarkerChanges(parent._searchMarker, index, content.length)\n }\n return typeListInsertGenericsAfter(transaction, parent, null, content)\n }\n const startIndex = index\n const marker = findMarker(parent, index)\n let n = parent._start\n if (marker !== null) {\n n = marker.p\n index -= marker.index\n // we need to iterate one to the left so that the algorithm works\n if (index === 0) {\n // @todo refactor this as it actually doesn't consider formats\n n = n.prev // important! get the left undeleted item so that we can actually decrease index\n index += (n && n.countable && !n.deleted) ? n.length : 0\n }\n }\n for (; n !== null; n = n.right) {\n if (!n.deleted && n.countable) {\n if (index <= n.length) {\n if (index < n.length) {\n // insert in-between\n getItemCleanStart(transaction, createID(n.id.client, n.id.clock + index))\n }\n break\n }\n index -= n.length\n }\n }\n if (parent._searchMarker) {\n updateMarkerChanges(parent._searchMarker, startIndex, content.length)\n }\n return typeListInsertGenericsAfter(transaction, parent, n, content)\n}\n\n/**\n * Pushing content is special as we generally want to push after the last item. So we don't have to update\n * the search marker.\n *\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {Array<Object<string,any>|Array<any>|number|null|string|Uint8Array>} content\n *\n * @private\n * @function\n */\nexport const typeListPushGenerics = (transaction, parent, content) => {\n // Use the marker with the highest index and iterate to the right.\n const marker = (parent._searchMarker || []).reduce((maxMarker, currMarker) => currMarker.index > maxMarker.index ? currMarker : maxMarker, { index: 0, p: parent._start })\n let n = marker.p\n if (n) {\n while (n.right) {\n n = n.right\n }\n }\n return typeListInsertGenericsAfter(transaction, parent, n, content)\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {number} index\n * @param {number} length\n *\n * @private\n * @function\n */\nexport const typeListDelete = (transaction, parent, index, length) => {\n if (length === 0) { return }\n const startIndex = index\n const startLength = length\n const marker = findMarker(parent, index)\n let n = parent._start\n if (marker !== null) {\n n = marker.p\n index -= marker.index\n }\n // compute the first item to be deleted\n for (; n !== null && index > 0; n = n.right) {\n if (!n.deleted && n.countable) {\n if (index < n.length) {\n getItemCleanStart(transaction, createID(n.id.client, n.id.clock + index))\n }\n index -= n.length\n }\n }\n // delete all items until done\n while (length > 0 && n !== null) {\n if (!n.deleted) {\n if (length < n.length) {\n getItemCleanStart(transaction, createID(n.id.client, n.id.clock + length))\n }\n n.delete(transaction)\n length -= n.length\n }\n n = n.right\n }\n if (length > 0) {\n throw lengthExceeded()\n }\n if (parent._searchMarker) {\n updateMarkerChanges(parent._searchMarker, startIndex, -startLength + length /* in case we remove the above exception */)\n }\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {string} key\n *\n * @private\n * @function\n */\nexport const typeMapDelete = (transaction, parent, key) => {\n const c = parent._map.get(key)\n if (c !== undefined) {\n c.delete(transaction)\n }\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {string} key\n * @param {Object|number|null|Array<any>|string|Uint8Array|AbstractType<any>} value\n *\n * @private\n * @function\n */\nexport const typeMapSet = (transaction, parent, key, value) => {\n const left = parent._map.get(key) || null\n const doc = transaction.doc\n const ownClientId = doc.clientID\n let content\n if (value == null) {\n content = new ContentAny([value])\n } else {\n switch (value.constructor) {\n case Number:\n case Object:\n case Boolean:\n case Array:\n case String:\n case Date:\n case BigInt:\n content = new ContentAny([value])\n break\n case Uint8Array:\n content = new ContentBinary(/** @type {Uint8Array} */ (value))\n break\n case Doc:\n content = new ContentDoc(/** @type {Doc} */ (value))\n break\n default:\n if (value instanceof AbstractType) {\n content = new ContentType(value)\n } else {\n throw new Error('Unexpected content type')\n }\n }\n }\n new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, null, null, parent, key, content).integrate(transaction, 0)\n}\n\n/**\n * @param {AbstractType<any>} parent\n * @param {string} key\n * @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}\n *\n * @private\n * @function\n */\nexport const typeMapGet = (parent, key) => {\n parent.doc ?? warnPrematureAccess()\n const val = parent._map.get(key)\n return val !== undefined && !val.deleted ? val.content.getContent()[val.length - 1] : undefined\n}\n\n/**\n * @param {AbstractType<any>} parent\n * @return {Object<string,Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}\n *\n * @private\n * @function\n */\nexport const typeMapGetAll = (parent) => {\n /**\n * @type {Object<string,any>}\n */\n const res = {}\n parent.doc ?? warnPrematureAccess()\n parent._map.forEach((value, key) => {\n if (!value.deleted) {\n res[key] = value.content.getContent()[value.length - 1]\n }\n })\n return res\n}\n\n/**\n * @param {AbstractType<any>} parent\n * @param {string} key\n * @return {boolean}\n *\n * @private\n * @function\n */\nexport const typeMapHas = (parent, key) => {\n parent.doc ?? warnPrematureAccess()\n const val = parent._map.get(key)\n return val !== undefined && !val.deleted\n}\n\n/**\n * @param {AbstractType<any>} parent\n * @param {string} key\n * @param {Snapshot} snapshot\n * @return {Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined}\n *\n * @private\n * @function\n */\nexport const typeMapGetSnapshot = (parent, key, snapshot) => {\n let v = parent._map.get(key) || null\n while (v !== null && (!snapshot.sv.has(v.id.client) || v.id.clock >= (snapshot.sv.get(v.id.client) || 0))) {\n v = v.left\n }\n return v !== null && isVisible(v, snapshot) ? v.content.getContent()[v.length - 1] : undefined\n}\n\n/**\n * @param {AbstractType<any>} parent\n * @param {Snapshot} snapshot\n * @return {Object<string,Object<string,any>|number|null|Array<any>|string|Uint8Array|AbstractType<any>|undefined>}\n *\n * @private\n * @function\n */\nexport const typeMapGetAllSnapshot = (parent, snapshot) => {\n /**\n * @type {Object<string,any>}\n */\n const res = {}\n parent._map.forEach((value, key) => {\n /**\n * @type {Item|null}\n */\n let v = value\n while (v !== null && (!snapshot.sv.has(v.id.client) || v.id.clock >= (snapshot.sv.get(v.id.client) || 0))) {\n v = v.left\n }\n if (v !== null && isVisible(v, snapshot)) {\n res[key] = v.content.getContent()[v.length - 1]\n }\n })\n return res\n}\n\n/**\n * @param {AbstractType<any> & { _map: Map<string, Item> }} type\n * @return {IterableIterator<Array<any>>}\n *\n * @private\n * @function\n */\nexport const createMapIterator = type => {\n type.doc ?? warnPrematureAccess()\n return iterator.iteratorFilter(type._map.entries(), /** @param {any} entry */ entry => !entry[1].deleted)\n}\n", "/**\n * @module YArray\n */\n\nimport {\n YEvent,\n AbstractType,\n typeListGet,\n typeListToArray,\n typeListForEach,\n typeListCreateIterator,\n typeListInsertGenerics,\n typeListPushGenerics,\n typeListDelete,\n typeListMap,\n YArrayRefID,\n callTypeObservers,\n transact,\n warnPrematureAccess,\n ArraySearchMarker, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Doc, Transaction, Item // eslint-disable-line\n} from '../internals.js'\nimport { typeListSlice } from './AbstractType.js'\n\n/**\n * Event that describes the changes on a YArray\n * @template T\n * @extends YEvent<YArray<T>>\n */\nexport class YArrayEvent extends YEvent {}\n\n/**\n * A shared Array implementation.\n * @template T\n * @extends AbstractType<YArrayEvent<T>>\n * @implements {Iterable<T>}\n */\nexport class YArray extends AbstractType {\n constructor () {\n super()\n /**\n * @type {Array<any>?}\n * @private\n */\n this._prelimContent = []\n /**\n * @type {Array<ArraySearchMarker>}\n */\n this._searchMarker = []\n }\n\n /**\n * Construct a new YArray containing the specified items.\n * @template {Object<string,any>|Array<any>|number|null|string|Uint8Array} T\n * @param {Array<T>} items\n * @return {YArray<T>}\n */\n static from (items) {\n /**\n * @type {YArray<T>}\n */\n const a = new YArray()\n a.push(items)\n return a\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Doc} y The Yjs instance\n * @param {Item} item\n */\n _integrate (y, item) {\n super._integrate(y, item)\n this.insert(0, /** @type {Array<any>} */ (this._prelimContent))\n this._prelimContent = null\n }\n\n /**\n * @return {YArray<T>}\n */\n _copy () {\n return new YArray()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YArray<T>}\n */\n clone () {\n /**\n * @type {YArray<T>}\n */\n const arr = new YArray()\n arr.insert(0, this.toArray().map(el =>\n el instanceof AbstractType ? /** @type {typeof el} */ (el.clone()) : el\n ))\n return arr\n }\n\n get length () {\n this.doc ?? warnPrematureAccess()\n return this._length\n }\n\n /**\n * Creates YArrayEvent and calls observers.\n *\n * @param {Transaction} transaction\n * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.\n */\n _callObserver (transaction, parentSubs) {\n super._callObserver(transaction, parentSubs)\n callTypeObservers(this, transaction, new YArrayEvent(this, transaction))\n }\n\n /**\n * Inserts new content at an index.\n *\n * Important: This function expects an array of content. Not just a content\n * object. The reason for this \"weirdness\" is that inserting several elements\n * is very efficient when it is done as a single operation.\n *\n * @example\n * // Insert character 'a' at position 0\n * yarray.insert(0, ['a'])\n * // Insert numbers 1, 2 at position 1\n * yarray.insert(1, [1, 2])\n *\n * @param {number} index The index to insert content at.\n * @param {Array<T>} content The array of content\n */\n insert (index, content) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeListInsertGenerics(transaction, this, index, /** @type {any} */ (content))\n })\n } else {\n /** @type {Array<any>} */ (this._prelimContent).splice(index, 0, ...content)\n }\n }\n\n /**\n * Appends content to this YArray.\n *\n * @param {Array<T>} content Array of content to append.\n *\n * @todo Use the following implementation in all types.\n */\n push (content) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeListPushGenerics(transaction, this, /** @type {any} */ (content))\n })\n } else {\n /** @type {Array<any>} */ (this._prelimContent).push(...content)\n }\n }\n\n /**\n * Prepends content to this YArray.\n *\n * @param {Array<T>} content Array of content to prepend.\n */\n unshift (content) {\n this.insert(0, content)\n }\n\n /**\n * Deletes elements starting from an index.\n *\n * @param {number} index Index at which to start deleting elements\n * @param {number} length The number of elements to remove. Defaults to 1.\n */\n delete (index, length = 1) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeListDelete(transaction, this, index, length)\n })\n } else {\n /** @type {Array<any>} */ (this._prelimContent).splice(index, length)\n }\n }\n\n /**\n * Returns the i-th element from a YArray.\n *\n * @param {number} index The index of the element to return from the YArray\n * @return {T}\n */\n get (index) {\n return typeListGet(this, index)\n }\n\n /**\n * Transforms this YArray to a JavaScript Array.\n *\n * @return {Array<T>}\n */\n toArray () {\n return typeListToArray(this)\n }\n\n /**\n * Returns a portion of this YArray into a JavaScript Array selected\n * from start to end (end not included).\n *\n * @param {number} [start]\n * @param {number} [end]\n * @return {Array<T>}\n */\n slice (start = 0, end = this.length) {\n return typeListSlice(this, start, end)\n }\n\n /**\n * Transforms this Shared Type to a JSON object.\n *\n * @return {Array<any>}\n */\n toJSON () {\n return this.map(c => c instanceof AbstractType ? c.toJSON() : c)\n }\n\n /**\n * Returns an Array with the result of calling a provided function on every\n * element of this YArray.\n *\n * @template M\n * @param {function(T,number,YArray<T>):M} f Function that produces an element of the new Array\n * @return {Array<M>} A new array with each element being the result of the\n * callback function\n */\n map (f) {\n return typeListMap(this, /** @type {any} */ (f))\n }\n\n /**\n * Executes a provided function once on every element of this YArray.\n *\n * @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.\n */\n forEach (f) {\n typeListForEach(this, f)\n }\n\n /**\n * @return {IterableIterator<T>}\n */\n [Symbol.iterator] () {\n return typeListCreateIterator(this)\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n */\n _write (encoder) {\n encoder.writeTypeRef(YArrayRefID)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder\n *\n * @private\n * @function\n */\nexport const readYArray = _decoder => new YArray()\n", "/**\n * @module YMap\n */\n\nimport {\n YEvent,\n AbstractType,\n typeMapDelete,\n typeMapSet,\n typeMapGet,\n typeMapHas,\n createMapIterator,\n YMapRefID,\n callTypeObservers,\n transact,\n warnPrematureAccess,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Doc, Transaction, Item // eslint-disable-line\n} from '../internals.js'\n\nimport * as iterator from 'lib0/iterator'\n\n/**\n * @template T\n * @extends YEvent<YMap<T>>\n * Event that describes the changes on a YMap.\n */\nexport class YMapEvent extends YEvent {\n /**\n * @param {YMap<T>} ymap The YArray that changed.\n * @param {Transaction} transaction\n * @param {Set<any>} subs The keys that changed.\n */\n constructor (ymap, transaction, subs) {\n super(ymap, transaction)\n this.keysChanged = subs\n }\n}\n\n/**\n * @template MapType\n * A shared Map implementation.\n *\n * @extends AbstractType<YMapEvent<MapType>>\n * @implements {Iterable<[string, MapType]>}\n */\nexport class YMap extends AbstractType {\n /**\n *\n * @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap\n */\n constructor (entries) {\n super()\n /**\n * @type {Map<string,any>?}\n * @private\n */\n this._prelimContent = null\n\n if (entries === undefined) {\n this._prelimContent = new Map()\n } else {\n this._prelimContent = new Map(entries)\n }\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Doc} y The Yjs instance\n * @param {Item} item\n */\n _integrate (y, item) {\n super._integrate(y, item)\n ;/** @type {Map<string, any>} */ (this._prelimContent).forEach((value, key) => {\n this.set(key, value)\n })\n this._prelimContent = null\n }\n\n /**\n * @return {YMap<MapType>}\n */\n _copy () {\n return new YMap()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YMap<MapType>}\n */\n clone () {\n /**\n * @type {YMap<MapType>}\n */\n const map = new YMap()\n this.forEach((value, key) => {\n map.set(key, value instanceof AbstractType ? /** @type {typeof value} */ (value.clone()) : value)\n })\n return map\n }\n\n /**\n * Creates YMapEvent and calls observers.\n *\n * @param {Transaction} transaction\n * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.\n */\n _callObserver (transaction, parentSubs) {\n callTypeObservers(this, transaction, new YMapEvent(this, transaction, parentSubs))\n }\n\n /**\n * Transforms this Shared Type to a JSON object.\n *\n * @return {Object<string,any>}\n */\n toJSON () {\n this.doc ?? warnPrematureAccess()\n /**\n * @type {Object<string,MapType>}\n */\n const map = {}\n this._map.forEach((item, key) => {\n if (!item.deleted) {\n const v = item.content.getContent()[item.length - 1]\n map[key] = v instanceof AbstractType ? v.toJSON() : v\n }\n })\n return map\n }\n\n /**\n * Returns the size of the YMap (count of key/value pairs)\n *\n * @return {number}\n */\n get size () {\n return [...createMapIterator(this)].length\n }\n\n /**\n * Returns the keys for each element in the YMap Type.\n *\n * @return {IterableIterator<string>}\n */\n keys () {\n return iterator.iteratorMap(createMapIterator(this), /** @param {any} v */ v => v[0])\n }\n\n /**\n * Returns the values for each element in the YMap Type.\n *\n * @return {IterableIterator<MapType>}\n */\n values () {\n return iterator.iteratorMap(createMapIterator(this), /** @param {any} v */ v => v[1].content.getContent()[v[1].length - 1])\n }\n\n /**\n * Returns an Iterator of [key, value] pairs\n *\n * @return {IterableIterator<[string, MapType]>}\n */\n entries () {\n return iterator.iteratorMap(createMapIterator(this), /** @param {any} v */ v => /** @type {any} */ ([v[0], v[1].content.getContent()[v[1].length - 1]]))\n }\n\n /**\n * Executes a provided function on once on every key-value pair.\n *\n * @param {function(MapType,string,YMap<MapType>):void} f A function to execute on every element of this YArray.\n */\n forEach (f) {\n this.doc ?? warnPrematureAccess()\n this._map.forEach((item, key) => {\n if (!item.deleted) {\n f(item.content.getContent()[item.length - 1], key, this)\n }\n })\n }\n\n /**\n * Returns an Iterator of [key, value] pairs\n *\n * @return {IterableIterator<[string, MapType]>}\n */\n [Symbol.iterator] () {\n return this.entries()\n }\n\n /**\n * Remove a specified element from this YMap.\n *\n * @param {string} key The key of the element to remove.\n */\n delete (key) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapDelete(transaction, this, key)\n })\n } else {\n /** @type {Map<string, any>} */ (this._prelimContent).delete(key)\n }\n }\n\n /**\n * Adds or updates an element with a specified key and value.\n * @template {MapType} VAL\n *\n * @param {string} key The key of the element to add to this YMap\n * @param {VAL} value The value of the element to add\n * @return {VAL}\n */\n set (key, value) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapSet(transaction, this, key, /** @type {any} */ (value))\n })\n } else {\n /** @type {Map<string, any>} */ (this._prelimContent).set(key, value)\n }\n return value\n }\n\n /**\n * Returns a specified element from this YMap.\n *\n * @param {string} key\n * @return {MapType|undefined}\n */\n get (key) {\n return /** @type {any} */ (typeMapGet(this, key))\n }\n\n /**\n * Returns a boolean indicating whether the specified key exists or not.\n *\n * @param {string} key The key to test.\n * @return {boolean}\n */\n has (key) {\n return typeMapHas(this, key)\n }\n\n /**\n * Removes all elements from this YMap.\n */\n clear () {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n this.forEach(function (_value, key, map) {\n typeMapDelete(transaction, map, key)\n })\n })\n } else {\n /** @type {Map<string, any>} */ (this._prelimContent).clear()\n }\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n */\n _write (encoder) {\n encoder.writeTypeRef(YMapRefID)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder\n *\n * @private\n * @function\n */\nexport const readYMap = _decoder => new YMap()\n", "/**\n * @module YText\n */\n\nimport {\n YEvent,\n AbstractType,\n getItemCleanStart,\n getState,\n isVisible,\n createID,\n YTextRefID,\n callTypeObservers,\n transact,\n ContentEmbed,\n GC,\n ContentFormat,\n ContentString,\n splitSnapshotAffectedStructs,\n iterateDeletedStructs,\n iterateStructs,\n findMarker,\n typeMapDelete,\n typeMapSet,\n typeMapGet,\n typeMapGetAll,\n updateMarkerChanges,\n ContentType,\n warnPrematureAccess,\n ArraySearchMarker, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ID, Doc, Item, Snapshot, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as object from 'lib0/object'\nimport * as map from 'lib0/map'\nimport * as error from 'lib0/error'\n\n/**\n * @param {any} a\n * @param {any} b\n * @return {boolean}\n */\nconst equalAttrs = (a, b) => a === b || (typeof a === 'object' && typeof b === 'object' && a && b && object.equalFlat(a, b))\n\nexport class ItemTextListPosition {\n /**\n * @param {Item|null} left\n * @param {Item|null} right\n * @param {number} index\n * @param {Map<string,any>} currentAttributes\n */\n constructor (left, right, index, currentAttributes) {\n this.left = left\n this.right = right\n this.index = index\n this.currentAttributes = currentAttributes\n }\n\n /**\n * Only call this if you know that this.right is defined\n */\n forward () {\n if (this.right === null) {\n error.unexpectedCase()\n }\n switch (this.right.content.constructor) {\n case ContentFormat:\n if (!this.right.deleted) {\n updateCurrentAttributes(this.currentAttributes, /** @type {ContentFormat} */ (this.right.content))\n }\n break\n default:\n if (!this.right.deleted) {\n this.index += this.right.length\n }\n break\n }\n this.left = this.right\n this.right = this.right.right\n }\n}\n\n/**\n * @param {Transaction} transaction\n * @param {ItemTextListPosition} pos\n * @param {number} count steps to move forward\n * @return {ItemTextListPosition}\n *\n * @private\n * @function\n */\nconst findNextPosition = (transaction, pos, count) => {\n while (pos.right !== null && count > 0) {\n switch (pos.right.content.constructor) {\n case ContentFormat:\n if (!pos.right.deleted) {\n updateCurrentAttributes(pos.currentAttributes, /** @type {ContentFormat} */ (pos.right.content))\n }\n break\n default:\n if (!pos.right.deleted) {\n if (count < pos.right.length) {\n // split right\n getItemCleanStart(transaction, createID(pos.right.id.client, pos.right.id.clock + count))\n }\n pos.index += pos.right.length\n count -= pos.right.length\n }\n break\n }\n pos.left = pos.right\n pos.right = pos.right.right\n // pos.forward() - we don't forward because that would halve the performance because we already do the checks above\n }\n return pos\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {number} index\n * @param {boolean} useSearchMarker\n * @return {ItemTextListPosition}\n *\n * @private\n * @function\n */\nconst findPosition = (transaction, parent, index, useSearchMarker) => {\n const currentAttributes = new Map()\n const marker = useSearchMarker ? findMarker(parent, index) : null\n if (marker) {\n const pos = new ItemTextListPosition(marker.p.left, marker.p, marker.index, currentAttributes)\n return findNextPosition(transaction, pos, index - marker.index)\n } else {\n const pos = new ItemTextListPosition(null, parent._start, 0, currentAttributes)\n return findNextPosition(transaction, pos, index)\n }\n}\n\n/**\n * Negate applied formats\n *\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {ItemTextListPosition} currPos\n * @param {Map<string,any>} negatedAttributes\n *\n * @private\n * @function\n */\nconst insertNegatedAttributes = (transaction, parent, currPos, negatedAttributes) => {\n // check if we really need to remove attributes\n while (\n currPos.right !== null && (\n currPos.right.deleted === true || (\n currPos.right.content.constructor === ContentFormat &&\n equalAttrs(negatedAttributes.get(/** @type {ContentFormat} */ (currPos.right.content).key), /** @type {ContentFormat} */ (currPos.right.content).value)\n )\n )\n ) {\n if (!currPos.right.deleted) {\n negatedAttributes.delete(/** @type {ContentFormat} */ (currPos.right.content).key)\n }\n currPos.forward()\n }\n const doc = transaction.doc\n const ownClientId = doc.clientID\n negatedAttributes.forEach((val, key) => {\n const left = currPos.left\n const right = currPos.right\n const nextFormat = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))\n nextFormat.integrate(transaction, 0)\n currPos.right = nextFormat\n currPos.forward()\n })\n}\n\n/**\n * @param {Map<string,any>} currentAttributes\n * @param {ContentFormat} format\n *\n * @private\n * @function\n */\nconst updateCurrentAttributes = (currentAttributes, format) => {\n const { key, value } = format\n if (value === null) {\n currentAttributes.delete(key)\n } else {\n currentAttributes.set(key, value)\n }\n}\n\n/**\n * @param {ItemTextListPosition} currPos\n * @param {Object<string,any>} attributes\n *\n * @private\n * @function\n */\nconst minimizeAttributeChanges = (currPos, attributes) => {\n // go right while attributes[right.key] === right.value (or right is deleted)\n while (true) {\n if (currPos.right === null) {\n break\n } else if (currPos.right.deleted || (currPos.right.content.constructor === ContentFormat && equalAttrs(attributes[(/** @type {ContentFormat} */ (currPos.right.content)).key] ?? null, /** @type {ContentFormat} */ (currPos.right.content).value))) {\n //\n } else {\n break\n }\n currPos.forward()\n }\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {ItemTextListPosition} currPos\n * @param {Object<string,any>} attributes\n * @return {Map<string,any>}\n *\n * @private\n * @function\n **/\nconst insertAttributes = (transaction, parent, currPos, attributes) => {\n const doc = transaction.doc\n const ownClientId = doc.clientID\n const negatedAttributes = new Map()\n // insert format-start items\n for (const key in attributes) {\n const val = attributes[key]\n const currentVal = currPos.currentAttributes.get(key) ?? null\n if (!equalAttrs(currentVal, val)) {\n // save negated attribute (set null if currentVal undefined)\n negatedAttributes.set(key, currentVal)\n const { left, right } = currPos\n currPos.right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, new ContentFormat(key, val))\n currPos.right.integrate(transaction, 0)\n currPos.forward()\n }\n }\n return negatedAttributes\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {ItemTextListPosition} currPos\n * @param {string|object|AbstractType<any>} text\n * @param {Object<string,any>} attributes\n *\n * @private\n * @function\n **/\nconst insertText = (transaction, parent, currPos, text, attributes) => {\n currPos.currentAttributes.forEach((_val, key) => {\n if (attributes[key] === undefined) {\n attributes[key] = null\n }\n })\n const doc = transaction.doc\n const ownClientId = doc.clientID\n minimizeAttributeChanges(currPos, attributes)\n const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes)\n // insert content\n const content = text.constructor === String ? new ContentString(/** @type {string} */ (text)) : (text instanceof AbstractType ? new ContentType(text) : new ContentEmbed(text))\n let { left, right, index } = currPos\n if (parent._searchMarker) {\n updateMarkerChanges(parent._searchMarker, currPos.index, content.getLength())\n }\n right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), left, left && left.lastId, right, right && right.id, parent, null, content)\n right.integrate(transaction, 0)\n currPos.right = right\n currPos.index = index\n currPos.forward()\n insertNegatedAttributes(transaction, parent, currPos, negatedAttributes)\n}\n\n/**\n * @param {Transaction} transaction\n * @param {AbstractType<any>} parent\n * @param {ItemTextListPosition} currPos\n * @param {number} length\n * @param {Object<string,any>} attributes\n *\n * @private\n * @function\n */\nconst formatText = (transaction, parent, currPos, length, attributes) => {\n const doc = transaction.doc\n const ownClientId = doc.clientID\n minimizeAttributeChanges(currPos, attributes)\n const negatedAttributes = insertAttributes(transaction, parent, currPos, attributes)\n // iterate until first non-format or null is found\n // delete all formats with attributes[format.key] != null\n // also check the attributes after the first non-format as we do not want to insert redundant negated attributes there\n // eslint-disable-next-line no-labels\n iterationLoop: while (\n currPos.right !== null &&\n (length > 0 ||\n (\n negatedAttributes.size > 0 &&\n (currPos.right.deleted || currPos.right.content.constructor === ContentFormat)\n )\n )\n ) {\n if (!currPos.right.deleted) {\n switch (currPos.right.content.constructor) {\n case ContentFormat: {\n const { key, value } = /** @type {ContentFormat} */ (currPos.right.content)\n const attr = attributes[key]\n if (attr !== undefined) {\n if (equalAttrs(attr, value)) {\n negatedAttributes.delete(key)\n } else {\n if (length === 0) {\n // no need to further extend negatedAttributes\n // eslint-disable-next-line no-labels\n break iterationLoop\n }\n negatedAttributes.set(key, value)\n }\n currPos.right.delete(transaction)\n } else {\n currPos.currentAttributes.set(key, value)\n }\n break\n }\n default:\n if (length < currPos.right.length) {\n getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length))\n }\n length -= currPos.right.length\n break\n }\n }\n currPos.forward()\n }\n // Quill just assumes that the editor starts with a newline and that it always\n // ends with a newline. We only insert that newline when a new newline is\n // inserted - i.e when length is bigger than type.length\n if (length > 0) {\n let newlines = ''\n for (; length > 0; length--) {\n newlines += '\\n'\n }\n currPos.right = new Item(createID(ownClientId, getState(doc.store, ownClientId)), currPos.left, currPos.left && currPos.left.lastId, currPos.right, currPos.right && currPos.right.id, parent, null, new ContentString(newlines))\n currPos.right.integrate(transaction, 0)\n currPos.forward()\n }\n insertNegatedAttributes(transaction, parent, currPos, negatedAttributes)\n}\n\n/**\n * Call this function after string content has been deleted in order to\n * clean up formatting Items.\n *\n * @param {Transaction} transaction\n * @param {Item} start\n * @param {Item|null} curr exclusive end, automatically iterates to the next Content Item\n * @param {Map<string,any>} startAttributes\n * @param {Map<string,any>} currAttributes\n * @return {number} The amount of formatting Items deleted.\n *\n * @function\n */\nconst cleanupFormattingGap = (transaction, start, curr, startAttributes, currAttributes) => {\n /**\n * @type {Item|null}\n */\n let end = start\n /**\n * @type {Map<string,ContentFormat>}\n */\n const endFormats = map.create()\n while (end && (!end.countable || end.deleted)) {\n if (!end.deleted && end.content.constructor === ContentFormat) {\n const cf = /** @type {ContentFormat} */ (end.content)\n endFormats.set(cf.key, cf)\n }\n end = end.right\n }\n let cleanups = 0\n let reachedCurr = false\n while (start !== end) {\n if (curr === start) {\n reachedCurr = true\n }\n if (!start.deleted) {\n const content = start.content\n switch (content.constructor) {\n case ContentFormat: {\n const { key, value } = /** @type {ContentFormat} */ (content)\n const startAttrValue = startAttributes.get(key) ?? null\n if (endFormats.get(key) !== content || startAttrValue === value) {\n // Either this format is overwritten or it is not necessary because the attribute already existed.\n start.delete(transaction)\n cleanups++\n if (!reachedCurr && (currAttributes.get(key) ?? null) === value && startAttrValue !== value) {\n if (startAttrValue === null) {\n currAttributes.delete(key)\n } else {\n currAttributes.set(key, startAttrValue)\n }\n }\n }\n if (!reachedCurr && !start.deleted) {\n updateCurrentAttributes(currAttributes, /** @type {ContentFormat} */ (content))\n }\n break\n }\n }\n }\n start = /** @type {Item} */ (start.right)\n }\n return cleanups\n}\n\n/**\n * @param {Transaction} transaction\n * @param {Item | null} item\n */\nconst cleanupContextlessFormattingGap = (transaction, item) => {\n // iterate until item.right is null or content\n while (item && item.right && (item.right.deleted || !item.right.countable)) {\n item = item.right\n }\n const attrs = new Set()\n // iterate back until a content item is found\n while (item && (item.deleted || !item.countable)) {\n if (!item.deleted && item.content.constructor === ContentFormat) {\n const key = /** @type {ContentFormat} */ (item.content).key\n if (attrs.has(key)) {\n item.delete(transaction)\n } else {\n attrs.add(key)\n }\n }\n item = item.left\n }\n}\n\n/**\n * This function is experimental and subject to change / be removed.\n *\n * Ideally, we don't need this function at all. Formatting attributes should be cleaned up\n * automatically after each change. This function iterates twice over the complete YText type\n * and removes unnecessary formatting attributes. This is also helpful for testing.\n *\n * This function won't be exported anymore as soon as there is confidence that the YText type works as intended.\n *\n * @param {YText} type\n * @return {number} How many formatting attributes have been cleaned up.\n */\nexport const cleanupYTextFormatting = type => {\n let res = 0\n transact(/** @type {Doc} */ (type.doc), transaction => {\n let start = /** @type {Item} */ (type._start)\n let end = type._start\n let startAttributes = map.create()\n const currentAttributes = map.copy(startAttributes)\n while (end) {\n if (end.deleted === false) {\n switch (end.content.constructor) {\n case ContentFormat:\n updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ (end.content))\n break\n default:\n res += cleanupFormattingGap(transaction, start, end, startAttributes, currentAttributes)\n startAttributes = map.copy(currentAttributes)\n start = end\n break\n }\n }\n end = end.right\n }\n })\n return res\n}\n\n/**\n * This will be called by the transaction once the event handlers are called to potentially cleanup\n * formatting attributes.\n *\n * @param {Transaction} transaction\n */\nexport const cleanupYTextAfterTransaction = transaction => {\n /**\n * @type {Set<YText>}\n */\n const needFullCleanup = new Set()\n // check if another formatting item was inserted\n const doc = transaction.doc\n for (const [client, afterClock] of transaction.afterState.entries()) {\n const clock = transaction.beforeState.get(client) || 0\n if (afterClock === clock) {\n continue\n }\n iterateStructs(transaction, /** @type {Array<Item|GC>} */ (doc.store.clients.get(client)), clock, afterClock, item => {\n if (\n !item.deleted && /** @type {Item} */ (item).content.constructor === ContentFormat && item.constructor !== GC\n ) {\n needFullCleanup.add(/** @type {any} */ (item).parent)\n }\n })\n }\n // cleanup in a new transaction\n transact(doc, (t) => {\n iterateDeletedStructs(transaction, transaction.deleteSet, item => {\n if (item instanceof GC || !(/** @type {YText} */ (item.parent)._hasFormatting) || needFullCleanup.has(/** @type {YText} */ (item.parent))) {\n return\n }\n const parent = /** @type {YText} */ (item.parent)\n if (item.content.constructor === ContentFormat) {\n needFullCleanup.add(parent)\n } else {\n // If no formatting attribute was inserted or deleted, we can make due with contextless\n // formatting cleanups.\n // Contextless: it is not necessary to compute currentAttributes for the affected position.\n cleanupContextlessFormattingGap(t, item)\n }\n })\n // If a formatting item was inserted, we simply clean the whole type.\n // We need to compute currentAttributes for the current position anyway.\n for (const yText of needFullCleanup) {\n cleanupYTextFormatting(yText)\n }\n })\n}\n\n/**\n * @param {Transaction} transaction\n * @param {ItemTextListPosition} currPos\n * @param {number} length\n * @return {ItemTextListPosition}\n *\n * @private\n * @function\n */\nconst deleteText = (transaction, currPos, length) => {\n const startLength = length\n const startAttrs = map.copy(currPos.currentAttributes)\n const start = currPos.right\n while (length > 0 && currPos.right !== null) {\n if (currPos.right.deleted === false) {\n switch (currPos.right.content.constructor) {\n case ContentType:\n case ContentEmbed:\n case ContentString:\n if (length < currPos.right.length) {\n getItemCleanStart(transaction, createID(currPos.right.id.client, currPos.right.id.clock + length))\n }\n length -= currPos.right.length\n currPos.right.delete(transaction)\n break\n }\n }\n currPos.forward()\n }\n if (start) {\n cleanupFormattingGap(transaction, start, currPos.right, startAttrs, currPos.currentAttributes)\n }\n const parent = /** @type {AbstractType<any>} */ (/** @type {Item} */ (currPos.left || currPos.right).parent)\n if (parent._searchMarker) {\n updateMarkerChanges(parent._searchMarker, currPos.index, -startLength + length)\n }\n return currPos\n}\n\n/**\n * The Quill Delta format represents changes on a text document with\n * formatting information. For more information visit {@link https://quilljs.com/docs/delta/|Quill Delta}\n *\n * @example\n * {\n * ops: [\n * { insert: 'Gandalf', attributes: { bold: true } },\n * { insert: ' the ' },\n * { insert: 'Grey', attributes: { color: '#cccccc' } }\n * ]\n * }\n *\n */\n\n/**\n * Attributes that can be assigned to a selection of text.\n *\n * @example\n * {\n * bold: true,\n * font-size: '40px'\n * }\n *\n * @typedef {Object} TextAttributes\n */\n\n/**\n * @extends YEvent<YText>\n * Event that describes the changes on a YText type.\n */\nexport class YTextEvent extends YEvent {\n /**\n * @param {YText} ytext\n * @param {Transaction} transaction\n * @param {Set<any>} subs The keys that changed\n */\n constructor (ytext, transaction, subs) {\n super(ytext, transaction)\n /**\n * Whether the children changed.\n * @type {Boolean}\n * @private\n */\n this.childListChanged = false\n /**\n * Set of all changed attributes.\n * @type {Set<string>}\n */\n this.keysChanged = new Set()\n subs.forEach((sub) => {\n if (sub === null) {\n this.childListChanged = true\n } else {\n this.keysChanged.add(sub)\n }\n })\n }\n\n /**\n * @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string, delete?:number, retain?:number}>}}\n */\n get changes () {\n if (this._changes === null) {\n /**\n * @type {{added:Set<Item>,deleted:Set<Item>,keys:Map<string,{action:'add'|'update'|'delete',oldValue:any}>,delta:Array<{insert?:Array<any>|string|AbstractType<any>|object, delete?:number, retain?:number}>}}\n */\n const changes = {\n keys: this.keys,\n delta: this.delta,\n added: new Set(),\n deleted: new Set()\n }\n this._changes = changes\n }\n return /** @type {any} */ (this._changes)\n }\n\n /**\n * Compute the changes in the delta format.\n * A {@link https://quilljs.com/docs/delta/|Quill Delta}) that represents the changes on the document.\n *\n * @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}\n *\n * @public\n */\n get delta () {\n if (this._delta === null) {\n const y = /** @type {Doc} */ (this.target.doc)\n /**\n * @type {Array<{insert?:string|object|AbstractType<any>, delete?:number, retain?:number, attributes?: Object<string,any>}>}\n */\n const delta = []\n transact(y, transaction => {\n const currentAttributes = new Map() // saves all current attributes for insert\n const oldAttributes = new Map()\n let item = this.target._start\n /**\n * @type {string?}\n */\n let action = null\n /**\n * @type {Object<string,any>}\n */\n const attributes = {} // counts added or removed new attributes for retain\n /**\n * @type {string|object}\n */\n let insert = ''\n let retain = 0\n let deleteLen = 0\n const addOp = () => {\n if (action !== null) {\n /**\n * @type {any}\n */\n let op = null\n switch (action) {\n case 'delete':\n if (deleteLen > 0) {\n op = { delete: deleteLen }\n }\n deleteLen = 0\n break\n case 'insert':\n if (typeof insert === 'object' || insert.length > 0) {\n op = { insert }\n if (currentAttributes.size > 0) {\n op.attributes = {}\n currentAttributes.forEach((value, key) => {\n if (value !== null) {\n op.attributes[key] = value\n }\n })\n }\n }\n insert = ''\n break\n case 'retain':\n if (retain > 0) {\n op = { retain }\n if (!object.isEmpty(attributes)) {\n op.attributes = object.assign({}, attributes)\n }\n }\n retain = 0\n break\n }\n if (op) delta.push(op)\n action = null\n }\n }\n while (item !== null) {\n switch (item.content.constructor) {\n case ContentType:\n case ContentEmbed:\n if (this.adds(item)) {\n if (!this.deletes(item)) {\n addOp()\n action = 'insert'\n insert = item.content.getContent()[0]\n addOp()\n }\n } else if (this.deletes(item)) {\n if (action !== 'delete') {\n addOp()\n action = 'delete'\n }\n deleteLen += 1\n } else if (!item.deleted) {\n if (action !== 'retain') {\n addOp()\n action = 'retain'\n }\n retain += 1\n }\n break\n case ContentString:\n if (this.adds(item)) {\n if (!this.deletes(item)) {\n if (action !== 'insert') {\n addOp()\n action = 'insert'\n }\n insert += /** @type {ContentString} */ (item.content).str\n }\n } else if (this.deletes(item)) {\n if (action !== 'delete') {\n addOp()\n action = 'delete'\n }\n deleteLen += item.length\n } else if (!item.deleted) {\n if (action !== 'retain') {\n addOp()\n action = 'retain'\n }\n retain += item.length\n }\n break\n case ContentFormat: {\n const { key, value } = /** @type {ContentFormat} */ (item.content)\n if (this.adds(item)) {\n if (!this.deletes(item)) {\n const curVal = currentAttributes.get(key) ?? null\n if (!equalAttrs(curVal, value)) {\n if (action === 'retain') {\n addOp()\n }\n if (equalAttrs(value, (oldAttributes.get(key) ?? null))) {\n delete attributes[key]\n } else {\n attributes[key] = value\n }\n } else if (value !== null) {\n item.delete(transaction)\n }\n }\n } else if (this.deletes(item)) {\n oldAttributes.set(key, value)\n const curVal = currentAttributes.get(key) ?? null\n if (!equalAttrs(curVal, value)) {\n if (action === 'retain') {\n addOp()\n }\n attributes[key] = curVal\n }\n } else if (!item.deleted) {\n oldAttributes.set(key, value)\n const attr = attributes[key]\n if (attr !== undefined) {\n if (!equalAttrs(attr, value)) {\n if (action === 'retain') {\n addOp()\n }\n if (value === null) {\n delete attributes[key]\n } else {\n attributes[key] = value\n }\n } else if (attr !== null) { // this will be cleaned up automatically by the contextless cleanup function\n item.delete(transaction)\n }\n }\n }\n if (!item.deleted) {\n if (action === 'insert') {\n addOp()\n }\n updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ (item.content))\n }\n break\n }\n }\n item = item.right\n }\n addOp()\n while (delta.length > 0) {\n const lastOp = delta[delta.length - 1]\n if (lastOp.retain !== undefined && lastOp.attributes === undefined) {\n // retain delta's if they don't assign attributes\n delta.pop()\n } else {\n break\n }\n }\n })\n this._delta = delta\n }\n return /** @type {any} */ (this._delta)\n }\n}\n\n/**\n * Type that represents text with formatting information.\n *\n * This type replaces y-richtext as this implementation is able to handle\n * block formats (format information on a paragraph), embeds (complex elements\n * like pictures and videos), and text formats (**bold**, *italic*).\n *\n * @extends AbstractType<YTextEvent>\n */\nexport class YText extends AbstractType {\n /**\n * @param {String} [string] The initial value of the YText.\n */\n constructor (string) {\n super()\n /**\n * Array of pending operations on this type\n * @type {Array<function():void>?}\n */\n this._pending = string !== undefined ? [() => this.insert(0, string)] : []\n /**\n * @type {Array<ArraySearchMarker>|null}\n */\n this._searchMarker = []\n /**\n * Whether this YText contains formatting attributes.\n * This flag is updated when a formatting item is integrated (see ContentFormat.integrate)\n */\n this._hasFormatting = false\n }\n\n /**\n * Number of characters of this text type.\n *\n * @type {number}\n */\n get length () {\n this.doc ?? warnPrematureAccess()\n return this._length\n }\n\n /**\n * @param {Doc} y\n * @param {Item} item\n */\n _integrate (y, item) {\n super._integrate(y, item)\n try {\n /** @type {Array<function>} */ (this._pending).forEach(f => f())\n } catch (e) {\n console.error(e)\n }\n this._pending = null\n }\n\n _copy () {\n return new YText()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YText}\n */\n clone () {\n const text = new YText()\n text.applyDelta(this.toDelta())\n return text\n }\n\n /**\n * Creates YTextEvent and calls observers.\n *\n * @param {Transaction} transaction\n * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.\n */\n _callObserver (transaction, parentSubs) {\n super._callObserver(transaction, parentSubs)\n const event = new YTextEvent(this, transaction, parentSubs)\n callTypeObservers(this, transaction, event)\n // If a remote change happened, we try to cleanup potential formatting duplicates.\n if (!transaction.local && this._hasFormatting) {\n transaction._needFormattingCleanup = true\n }\n }\n\n /**\n * Returns the unformatted string representation of this YText type.\n *\n * @public\n */\n toString () {\n this.doc ?? warnPrematureAccess()\n let str = ''\n /**\n * @type {Item|null}\n */\n let n = this._start\n while (n !== null) {\n if (!n.deleted && n.countable && n.content.constructor === ContentString) {\n str += /** @type {ContentString} */ (n.content).str\n }\n n = n.right\n }\n return str\n }\n\n /**\n * Returns the unformatted string representation of this YText type.\n *\n * @return {string}\n * @public\n */\n toJSON () {\n return this.toString()\n }\n\n /**\n * Apply a {@link Delta} on this shared YText type.\n *\n * @param {Array<any>} delta The changes to apply on this element.\n * @param {object} opts\n * @param {boolean} [opts.sanitize] Sanitize input delta. Removes ending newlines if set to true.\n *\n *\n * @public\n */\n applyDelta (delta, { sanitize = true } = {}) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n const currPos = new ItemTextListPosition(null, this._start, 0, new Map())\n for (let i = 0; i < delta.length; i++) {\n const op = delta[i]\n if (op.insert !== undefined) {\n // Quill assumes that the content starts with an empty paragraph.\n // Yjs/Y.Text assumes that it starts empty. We always hide that\n // there is a newline at the end of the content.\n // If we omit this step, clients will see a different number of\n // paragraphs, but nothing bad will happen.\n const ins = (!sanitize && typeof op.insert === 'string' && i === delta.length - 1 && currPos.right === null && op.insert.slice(-1) === '\\n') ? op.insert.slice(0, -1) : op.insert\n if (typeof ins !== 'string' || ins.length > 0) {\n insertText(transaction, this, currPos, ins, op.attributes || {})\n }\n } else if (op.retain !== undefined) {\n formatText(transaction, this, currPos, op.retain, op.attributes || {})\n } else if (op.delete !== undefined) {\n deleteText(transaction, currPos, op.delete)\n }\n }\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.applyDelta(delta))\n }\n }\n\n /**\n * Returns the Delta representation of this YText type.\n *\n * @param {Snapshot} [snapshot]\n * @param {Snapshot} [prevSnapshot]\n * @param {function('removed' | 'added', ID):any} [computeYChange]\n * @return {any} The Delta representation of this type.\n *\n * @public\n */\n toDelta (snapshot, prevSnapshot, computeYChange) {\n this.doc ?? warnPrematureAccess()\n /**\n * @type{Array<any>}\n */\n const ops = []\n const currentAttributes = new Map()\n const doc = /** @type {Doc} */ (this.doc)\n let str = ''\n let n = this._start\n function packStr () {\n if (str.length > 0) {\n // pack str with attributes to ops\n /**\n * @type {Object<string,any>}\n */\n const attributes = {}\n let addAttributes = false\n currentAttributes.forEach((value, key) => {\n addAttributes = true\n attributes[key] = value\n })\n /**\n * @type {Object<string,any>}\n */\n const op = { insert: str }\n if (addAttributes) {\n op.attributes = attributes\n }\n ops.push(op)\n str = ''\n }\n }\n const computeDelta = () => {\n while (n !== null) {\n if (isVisible(n, snapshot) || (prevSnapshot !== undefined && isVisible(n, prevSnapshot))) {\n switch (n.content.constructor) {\n case ContentString: {\n const cur = currentAttributes.get('ychange')\n if (snapshot !== undefined && !isVisible(n, snapshot)) {\n if (cur === undefined || cur.user !== n.id.client || cur.type !== 'removed') {\n packStr()\n currentAttributes.set('ychange', computeYChange ? computeYChange('removed', n.id) : { type: 'removed' })\n }\n } else if (prevSnapshot !== undefined && !isVisible(n, prevSnapshot)) {\n if (cur === undefined || cur.user !== n.id.client || cur.type !== 'added') {\n packStr()\n currentAttributes.set('ychange', computeYChange ? computeYChange('added', n.id) : { type: 'added' })\n }\n } else if (cur !== undefined) {\n packStr()\n currentAttributes.delete('ychange')\n }\n str += /** @type {ContentString} */ (n.content).str\n break\n }\n case ContentType:\n case ContentEmbed: {\n packStr()\n /**\n * @type {Object<string,any>}\n */\n const op = {\n insert: n.content.getContent()[0]\n }\n if (currentAttributes.size > 0) {\n const attrs = /** @type {Object<string,any>} */ ({})\n op.attributes = attrs\n currentAttributes.forEach((value, key) => {\n attrs[key] = value\n })\n }\n ops.push(op)\n break\n }\n case ContentFormat:\n if (isVisible(n, snapshot)) {\n packStr()\n updateCurrentAttributes(currentAttributes, /** @type {ContentFormat} */ (n.content))\n }\n break\n }\n }\n n = n.right\n }\n packStr()\n }\n if (snapshot || prevSnapshot) {\n // snapshots are merged again after the transaction, so we need to keep the\n // transaction alive until we are done\n transact(doc, transaction => {\n if (snapshot) {\n splitSnapshotAffectedStructs(transaction, snapshot)\n }\n if (prevSnapshot) {\n splitSnapshotAffectedStructs(transaction, prevSnapshot)\n }\n computeDelta()\n }, 'cleanup')\n } else {\n computeDelta()\n }\n return ops\n }\n\n /**\n * Insert text at a given index.\n *\n * @param {number} index The index at which to start inserting.\n * @param {String} text The text to insert at the specified position.\n * @param {TextAttributes} [attributes] Optionally define some formatting\n * information to apply on the inserted\n * Text.\n * @public\n */\n insert (index, text, attributes) {\n if (text.length <= 0) {\n return\n }\n const y = this.doc\n if (y !== null) {\n transact(y, transaction => {\n const pos = findPosition(transaction, this, index, !attributes)\n if (!attributes) {\n attributes = {}\n // @ts-ignore\n pos.currentAttributes.forEach((v, k) => { attributes[k] = v })\n }\n insertText(transaction, this, pos, text, attributes)\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.insert(index, text, attributes))\n }\n }\n\n /**\n * Inserts an embed at a index.\n *\n * @param {number} index The index to insert the embed at.\n * @param {Object | AbstractType<any>} embed The Object that represents the embed.\n * @param {TextAttributes} [attributes] Attribute information to apply on the\n * embed\n *\n * @public\n */\n insertEmbed (index, embed, attributes) {\n const y = this.doc\n if (y !== null) {\n transact(y, transaction => {\n const pos = findPosition(transaction, this, index, !attributes)\n insertText(transaction, this, pos, embed, attributes || {})\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.insertEmbed(index, embed, attributes || {}))\n }\n }\n\n /**\n * Deletes text starting from an index.\n *\n * @param {number} index Index at which to start deleting.\n * @param {number} length The number of characters to remove. Defaults to 1.\n *\n * @public\n */\n delete (index, length) {\n if (length === 0) {\n return\n }\n const y = this.doc\n if (y !== null) {\n transact(y, transaction => {\n deleteText(transaction, findPosition(transaction, this, index, true), length)\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.delete(index, length))\n }\n }\n\n /**\n * Assigns properties to a range of text.\n *\n * @param {number} index The position where to start formatting.\n * @param {number} length The amount of characters to assign properties to.\n * @param {TextAttributes} attributes Attribute information to apply on the\n * text.\n *\n * @public\n */\n format (index, length, attributes) {\n if (length === 0) {\n return\n }\n const y = this.doc\n if (y !== null) {\n transact(y, transaction => {\n const pos = findPosition(transaction, this, index, false)\n if (pos.right === null) {\n return\n }\n formatText(transaction, this, pos, length, attributes)\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.format(index, length, attributes))\n }\n }\n\n /**\n * Removes an attribute.\n *\n * @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.\n *\n * @param {String} attributeName The attribute name that is to be removed.\n *\n * @public\n */\n removeAttribute (attributeName) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapDelete(transaction, this, attributeName)\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.removeAttribute(attributeName))\n }\n }\n\n /**\n * Sets or updates an attribute.\n *\n * @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.\n *\n * @param {String} attributeName The attribute name that is to be set.\n * @param {any} attributeValue The attribute value that is to be set.\n *\n * @public\n */\n setAttribute (attributeName, attributeValue) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapSet(transaction, this, attributeName, attributeValue)\n })\n } else {\n /** @type {Array<function>} */ (this._pending).push(() => this.setAttribute(attributeName, attributeValue))\n }\n }\n\n /**\n * Returns an attribute value that belongs to the attribute name.\n *\n * @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.\n *\n * @param {String} attributeName The attribute name that identifies the\n * queried value.\n * @return {any} The queried attribute value.\n *\n * @public\n */\n getAttribute (attributeName) {\n return /** @type {any} */ (typeMapGet(this, attributeName))\n }\n\n /**\n * Returns all attribute name/value pairs in a JSON Object.\n *\n * @note Xml-Text nodes don't have attributes. You can use this feature to assign properties to complete text-blocks.\n *\n * @return {Object<string, any>} A JSON Object that describes the attributes.\n *\n * @public\n */\n getAttributes () {\n return typeMapGetAll(this)\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n */\n _write (encoder) {\n encoder.writeTypeRef(YTextRefID)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder\n * @return {YText}\n *\n * @private\n * @function\n */\nexport const readYText = _decoder => new YText()\n", "/**\n * @module YXml\n */\n\nimport {\n YXmlEvent,\n YXmlElement,\n AbstractType,\n typeListMap,\n typeListForEach,\n typeListInsertGenerics,\n typeListInsertGenericsAfter,\n typeListDelete,\n typeListToArray,\n YXmlFragmentRefID,\n callTypeObservers,\n transact,\n typeListGet,\n typeListSlice,\n warnPrematureAccess,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Doc, ContentType, Transaction, Item, YXmlText, YXmlHook // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\nimport * as array from 'lib0/array'\n\n/**\n * Define the elements to which a set of CSS queries apply.\n * {@link https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors|CSS_Selectors}\n *\n * @example\n * query = '.classSelector'\n * query = 'nodeSelector'\n * query = '#idSelector'\n *\n * @typedef {string} CSS_Selector\n */\n\n/**\n * Dom filter function.\n *\n * @callback domFilter\n * @param {string} nodeName The nodeName of the element\n * @param {Map} attributes The map of attributes.\n * @return {boolean} Whether to include the Dom node in the YXmlElement.\n */\n\n/**\n * Represents a subset of the nodes of a YXmlElement / YXmlFragment and a\n * position within them.\n *\n * Can be created with {@link YXmlFragment#createTreeWalker}\n *\n * @public\n * @implements {Iterable<YXmlElement|YXmlText|YXmlElement|YXmlHook>}\n */\nexport class YXmlTreeWalker {\n /**\n * @param {YXmlFragment | YXmlElement} root\n * @param {function(AbstractType<any>):boolean} [f]\n */\n constructor (root, f = () => true) {\n this._filter = f\n this._root = root\n /**\n * @type {Item}\n */\n this._currentNode = /** @type {Item} */ (root._start)\n this._firstCall = true\n root.doc ?? warnPrematureAccess()\n }\n\n [Symbol.iterator] () {\n return this\n }\n\n /**\n * Get the next node.\n *\n * @return {IteratorResult<YXmlElement|YXmlText|YXmlHook>} The next node.\n *\n * @public\n */\n next () {\n /**\n * @type {Item|null}\n */\n let n = this._currentNode\n let type = n && n.content && /** @type {any} */ (n.content).type\n if (n !== null && (!this._firstCall || n.deleted || !this._filter(type))) { // if first call, we check if we can use the first item\n do {\n type = /** @type {any} */ (n.content).type\n if (!n.deleted && (type.constructor === YXmlElement || type.constructor === YXmlFragment) && type._start !== null) {\n // walk down in the tree\n n = type._start\n } else {\n // walk right or up in the tree\n while (n !== null) {\n /**\n * @type {Item | null}\n */\n const nxt = n.next\n if (nxt !== null) {\n n = nxt\n break\n } else if (n.parent === this._root) {\n n = null\n } else {\n n = /** @type {AbstractType<any>} */ (n.parent)._item\n }\n }\n }\n } while (n !== null && (n.deleted || !this._filter(/** @type {ContentType} */ (n.content).type)))\n }\n this._firstCall = false\n if (n === null) {\n // @ts-ignore\n return { value: undefined, done: true }\n }\n this._currentNode = n\n return { value: /** @type {any} */ (n.content).type, done: false }\n }\n}\n\n/**\n * Represents a list of {@link YXmlElement}.and {@link YXmlText} types.\n * A YxmlFragment is similar to a {@link YXmlElement}, but it does not have a\n * nodeName and it does not have attributes. Though it can be bound to a DOM\n * element - in this case the attributes and the nodeName are not shared.\n *\n * @public\n * @extends AbstractType<YXmlEvent>\n */\nexport class YXmlFragment extends AbstractType {\n constructor () {\n super()\n /**\n * @type {Array<any>|null}\n */\n this._prelimContent = []\n }\n\n /**\n * @type {YXmlElement|YXmlText|null}\n */\n get firstChild () {\n const first = this._first\n return first ? first.content.getContent()[0] : null\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Doc} y The Yjs instance\n * @param {Item} item\n */\n _integrate (y, item) {\n super._integrate(y, item)\n this.insert(0, /** @type {Array<any>} */ (this._prelimContent))\n this._prelimContent = null\n }\n\n _copy () {\n return new YXmlFragment()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YXmlFragment}\n */\n clone () {\n const el = new YXmlFragment()\n // @ts-ignore\n el.insert(0, this.toArray().map(item => item instanceof AbstractType ? item.clone() : item))\n return el\n }\n\n get length () {\n this.doc ?? warnPrematureAccess()\n return this._prelimContent === null ? this._length : this._prelimContent.length\n }\n\n /**\n * Create a subtree of childNodes.\n *\n * @example\n * const walker = elem.createTreeWalker(dom => dom.nodeName === 'div')\n * for (let node in walker) {\n * // `node` is a div node\n * nop(node)\n * }\n *\n * @param {function(AbstractType<any>):boolean} filter Function that is called on each child element and\n * returns a Boolean indicating whether the child\n * is to be included in the subtree.\n * @return {YXmlTreeWalker} A subtree and a position within it.\n *\n * @public\n */\n createTreeWalker (filter) {\n return new YXmlTreeWalker(this, filter)\n }\n\n /**\n * Returns the first YXmlElement that matches the query.\n * Similar to DOM's {@link querySelector}.\n *\n * Query support:\n * - tagname\n * TODO:\n * - id\n * - attribute\n *\n * @param {CSS_Selector} query The query on the children.\n * @return {YXmlElement|YXmlText|YXmlHook|null} The first element that matches the query or null.\n *\n * @public\n */\n querySelector (query) {\n query = query.toUpperCase()\n // @ts-ignore\n const iterator = new YXmlTreeWalker(this, element => element.nodeName && element.nodeName.toUpperCase() === query)\n const next = iterator.next()\n if (next.done) {\n return null\n } else {\n return next.value\n }\n }\n\n /**\n * Returns all YXmlElements that match the query.\n * Similar to Dom's {@link querySelectorAll}.\n *\n * @todo Does not yet support all queries. Currently only query by tagName.\n *\n * @param {CSS_Selector} query The query on the children\n * @return {Array<YXmlElement|YXmlText|YXmlHook|null>} The elements that match this query.\n *\n * @public\n */\n querySelectorAll (query) {\n query = query.toUpperCase()\n // @ts-ignore\n return array.from(new YXmlTreeWalker(this, element => element.nodeName && element.nodeName.toUpperCase() === query))\n }\n\n /**\n * Creates YXmlEvent and calls observers.\n *\n * @param {Transaction} transaction\n * @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.\n */\n _callObserver (transaction, parentSubs) {\n callTypeObservers(this, transaction, new YXmlEvent(this, parentSubs, transaction))\n }\n\n /**\n * Get the string representation of all the children of this YXmlFragment.\n *\n * @return {string} The string representation of all children.\n */\n toString () {\n return typeListMap(this, xml => xml.toString()).join('')\n }\n\n /**\n * @return {string}\n */\n toJSON () {\n return this.toString()\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<string, any>} [hooks={}] Optional property to customize how hooks\n * are presented in the DOM\n * @param {any} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type.\n * @return {Node} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDOM (_document = document, hooks = {}, binding) {\n const fragment = _document.createDocumentFragment()\n if (binding !== undefined) {\n binding._createAssociation(fragment, this)\n }\n typeListForEach(this, xmlType => {\n fragment.insertBefore(xmlType.toDOM(_document, hooks, binding), null)\n })\n return fragment\n }\n\n /**\n * Inserts new content at an index.\n *\n * @example\n * // Insert character 'a' at position 0\n * xml.insert(0, [new Y.XmlText('text')])\n *\n * @param {number} index The index to insert content at\n * @param {Array<YXmlElement|YXmlText>} content The array of content\n */\n insert (index, content) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeListInsertGenerics(transaction, this, index, content)\n })\n } else {\n // @ts-ignore _prelimContent is defined because this is not yet integrated\n this._prelimContent.splice(index, 0, ...content)\n }\n }\n\n /**\n * Inserts new content at an index.\n *\n * @example\n * // Insert character 'a' at position 0\n * xml.insert(0, [new Y.XmlText('text')])\n *\n * @param {null|Item|YXmlElement|YXmlText} ref The index to insert content at\n * @param {Array<YXmlElement|YXmlText>} content The array of content\n */\n insertAfter (ref, content) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n const refItem = (ref && ref instanceof AbstractType) ? ref._item : ref\n typeListInsertGenericsAfter(transaction, this, refItem, content)\n })\n } else {\n const pc = /** @type {Array<any>} */ (this._prelimContent)\n const index = ref === null ? 0 : pc.findIndex(el => el === ref) + 1\n if (index === 0 && ref !== null) {\n throw error.create('Reference item not found')\n }\n pc.splice(index, 0, ...content)\n }\n }\n\n /**\n * Deletes elements starting from an index.\n *\n * @param {number} index Index at which to start deleting elements\n * @param {number} [length=1] The number of elements to remove. Defaults to 1.\n */\n delete (index, length = 1) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeListDelete(transaction, this, index, length)\n })\n } else {\n // @ts-ignore _prelimContent is defined because this is not yet integrated\n this._prelimContent.splice(index, length)\n }\n }\n\n /**\n * Transforms this YArray to a JavaScript Array.\n *\n * @return {Array<YXmlElement|YXmlText|YXmlHook>}\n */\n toArray () {\n return typeListToArray(this)\n }\n\n /**\n * Appends content to this YArray.\n *\n * @param {Array<YXmlElement|YXmlText>} content Array of content to append.\n */\n push (content) {\n this.insert(this.length, content)\n }\n\n /**\n * Prepends content to this YArray.\n *\n * @param {Array<YXmlElement|YXmlText>} content Array of content to prepend.\n */\n unshift (content) {\n this.insert(0, content)\n }\n\n /**\n * Returns the i-th element from a YArray.\n *\n * @param {number} index The index of the element to return from the YArray\n * @return {YXmlElement|YXmlText}\n */\n get (index) {\n return typeListGet(this, index)\n }\n\n /**\n * Returns a portion of this YXmlFragment into a JavaScript Array selected\n * from start to end (end not included).\n *\n * @param {number} [start]\n * @param {number} [end]\n * @return {Array<YXmlElement|YXmlText>}\n */\n slice (start = 0, end = this.length) {\n return typeListSlice(this, start, end)\n }\n\n /**\n * Executes a provided function on once on every child element.\n *\n * @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.\n */\n forEach (f) {\n typeListForEach(this, f)\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.\n */\n _write (encoder) {\n encoder.writeTypeRef(YXmlFragmentRefID)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} _decoder\n * @return {YXmlFragment}\n *\n * @private\n * @function\n */\nexport const readYXmlFragment = _decoder => new YXmlFragment()\n", "import * as object from 'lib0/object'\n\nimport {\n YXmlFragment,\n transact,\n typeMapDelete,\n typeMapHas,\n typeMapSet,\n typeMapGet,\n typeMapGetAll,\n typeMapGetAllSnapshot,\n typeListForEach,\n YXmlElementRefID,\n Snapshot, YXmlText, ContentType, AbstractType, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Doc, Item // eslint-disable-line\n} from '../internals.js'\n\n/**\n * @typedef {Object|number|null|Array<any>|string|Uint8Array|AbstractType<any>} ValueTypes\n */\n\n/**\n * An YXmlElement imitates the behavior of a\n * https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element\n *\n * * An YXmlElement has attributes (key value pairs)\n * * An YXmlElement has childElements that must inherit from YXmlElement\n *\n * @template {{ [key: string]: ValueTypes }} [KV={ [key: string]: string }]\n */\nexport class YXmlElement extends YXmlFragment {\n constructor (nodeName = 'UNDEFINED') {\n super()\n this.nodeName = nodeName\n /**\n * @type {Map<string, any>|null}\n */\n this._prelimAttrs = new Map()\n }\n\n /**\n * @type {YXmlElement|YXmlText|null}\n */\n get nextSibling () {\n const n = this._item ? this._item.next : null\n return n ? /** @type {YXmlElement|YXmlText} */ (/** @type {ContentType} */ (n.content).type) : null\n }\n\n /**\n * @type {YXmlElement|YXmlText|null}\n */\n get prevSibling () {\n const n = this._item ? this._item.prev : null\n return n ? /** @type {YXmlElement|YXmlText} */ (/** @type {ContentType} */ (n.content).type) : null\n }\n\n /**\n * Integrate this type into the Yjs instance.\n *\n * * Save this struct in the os\n * * This type is sent to other client\n * * Observer functions are fired\n *\n * @param {Doc} y The Yjs instance\n * @param {Item} item\n */\n _integrate (y, item) {\n super._integrate(y, item)\n ;(/** @type {Map<string, any>} */ (this._prelimAttrs)).forEach((value, key) => {\n this.setAttribute(key, value)\n })\n this._prelimAttrs = null\n }\n\n /**\n * Creates an Item with the same effect as this Item (without position effect)\n *\n * @return {YXmlElement}\n */\n _copy () {\n return new YXmlElement(this.nodeName)\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YXmlElement<KV>}\n */\n clone () {\n /**\n * @type {YXmlElement<KV>}\n */\n const el = new YXmlElement(this.nodeName)\n const attrs = this.getAttributes()\n object.forEach(attrs, (value, key) => {\n el.setAttribute(key, /** @type {any} */ (value))\n })\n // @ts-ignore\n el.insert(0, this.toArray().map(v => v instanceof AbstractType ? v.clone() : v))\n return el\n }\n\n /**\n * Returns the XML serialization of this YXmlElement.\n * The attributes are ordered by attribute-name, so you can easily use this\n * method to compare YXmlElements\n *\n * @return {string} The string representation of this type.\n *\n * @public\n */\n toString () {\n const attrs = this.getAttributes()\n const stringBuilder = []\n const keys = []\n for (const key in attrs) {\n keys.push(key)\n }\n keys.sort()\n const keysLen = keys.length\n for (let i = 0; i < keysLen; i++) {\n const key = keys[i]\n stringBuilder.push(key + '=\"' + attrs[key] + '\"')\n }\n const nodeName = this.nodeName.toLocaleLowerCase()\n const attrsString = stringBuilder.length > 0 ? ' ' + stringBuilder.join(' ') : ''\n return `<${nodeName}${attrsString}>${super.toString()}</${nodeName}>`\n }\n\n /**\n * Removes an attribute from this YXmlElement.\n *\n * @param {string} attributeName The attribute name that is to be removed.\n *\n * @public\n */\n removeAttribute (attributeName) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapDelete(transaction, this, attributeName)\n })\n } else {\n /** @type {Map<string,any>} */ (this._prelimAttrs).delete(attributeName)\n }\n }\n\n /**\n * Sets or updates an attribute.\n *\n * @template {keyof KV & string} KEY\n *\n * @param {KEY} attributeName The attribute name that is to be set.\n * @param {KV[KEY]} attributeValue The attribute value that is to be set.\n *\n * @public\n */\n setAttribute (attributeName, attributeValue) {\n if (this.doc !== null) {\n transact(this.doc, transaction => {\n typeMapSet(transaction, this, attributeName, attributeValue)\n })\n } else {\n /** @type {Map<string, any>} */ (this._prelimAttrs).set(attributeName, attributeValue)\n }\n }\n\n /**\n * Returns an attribute value that belongs to the attribute name.\n *\n * @template {keyof KV & string} KEY\n *\n * @param {KEY} attributeName The attribute name that identifies the\n * queried value.\n * @return {KV[KEY]|undefined} The queried attribute value.\n *\n * @public\n */\n getAttribute (attributeName) {\n return /** @type {any} */ (typeMapGet(this, attributeName))\n }\n\n /**\n * Returns whether an attribute exists\n *\n * @param {string} attributeName The attribute name to check for existence.\n * @return {boolean} whether the attribute exists.\n *\n * @public\n */\n hasAttribute (attributeName) {\n return /** @type {any} */ (typeMapHas(this, attributeName))\n }\n\n /**\n * Returns all attribute name/value pairs in a JSON Object.\n *\n * @param {Snapshot} [snapshot]\n * @return {{ [Key in Extract<keyof KV,string>]?: KV[Key]}} A JSON Object that describes the attributes.\n *\n * @public\n */\n getAttributes (snapshot) {\n return /** @type {any} */ (snapshot ? typeMapGetAllSnapshot(this, snapshot) : typeMapGetAll(this))\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<string, any>} [hooks={}] Optional property to customize how hooks\n * are presented in the DOM\n * @param {any} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type.\n * @return {Node} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDOM (_document = document, hooks = {}, binding) {\n const dom = _document.createElement(this.nodeName)\n const attrs = this.getAttributes()\n for (const key in attrs) {\n const value = attrs[key]\n if (typeof value === 'string') {\n dom.setAttribute(key, value)\n }\n }\n typeListForEach(this, yxml => {\n dom.appendChild(yxml.toDOM(_document, hooks, binding))\n })\n if (binding !== undefined) {\n binding._createAssociation(dom, this)\n }\n return dom\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.\n */\n _write (encoder) {\n encoder.writeTypeRef(YXmlElementRefID)\n encoder.writeKey(this.nodeName)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {YXmlElement}\n *\n * @function\n */\nexport const readYXmlElement = decoder => new YXmlElement(decoder.readKey())\n", "import {\n YEvent,\n YXmlText, YXmlElement, YXmlFragment, Transaction // eslint-disable-line\n} from '../internals.js'\n\n/**\n * @extends YEvent<YXmlElement|YXmlText|YXmlFragment>\n * An Event that describes changes on a YXml Element or Yxml Fragment\n */\nexport class YXmlEvent extends YEvent {\n /**\n * @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.\n * @param {Set<string|null>} subs The set of changed attributes. `null` is included if the\n * child list changed.\n * @param {Transaction} transaction The transaction instance with which the\n * change was created.\n */\n constructor (target, subs, transaction) {\n super(target, transaction)\n /**\n * Whether the children changed.\n * @type {Boolean}\n * @private\n */\n this.childListChanged = false\n /**\n * Set of all changed attributes.\n * @type {Set<string>}\n */\n this.attributesChanged = new Set()\n subs.forEach((sub) => {\n if (sub === null) {\n this.childListChanged = true\n } else {\n this.attributesChanged.add(sub)\n }\n })\n }\n}\n", "import {\n YMap,\n YXmlHookRefID,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2 // eslint-disable-line\n} from '../internals.js'\n\n/**\n * You can manage binding to a custom type with YXmlHook.\n *\n * @extends {YMap<any>}\n */\nexport class YXmlHook extends YMap {\n /**\n * @param {string} hookName nodeName of the Dom Node.\n */\n constructor (hookName) {\n super()\n /**\n * @type {string}\n */\n this.hookName = hookName\n }\n\n /**\n * Creates an Item with the same effect as this Item (without position effect)\n */\n _copy () {\n return new YXmlHook(this.hookName)\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YXmlHook}\n */\n clone () {\n const el = new YXmlHook(this.hookName)\n this.forEach((value, key) => {\n el.set(key, value)\n })\n return el\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlElement.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object.<string, any>} [hooks] Optional property to customize how hooks\n * are presented in the DOM\n * @param {any} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type\n * @return {Element} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDOM (_document = document, hooks = {}, binding) {\n const hook = hooks[this.hookName]\n let dom\n if (hook !== undefined) {\n dom = hook.createDom(this)\n } else {\n dom = document.createElement(this.hookName)\n }\n dom.setAttribute('data-yjs-hook', this.hookName)\n if (binding !== undefined) {\n binding._createAssociation(dom, this)\n }\n return dom\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.\n */\n _write (encoder) {\n encoder.writeTypeRef(YXmlHookRefID)\n encoder.writeKey(this.hookName)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {YXmlHook}\n *\n * @private\n * @function\n */\nexport const readYXmlHook = decoder =>\n new YXmlHook(decoder.readKey())\n", "import {\n YText,\n YXmlTextRefID,\n ContentType, YXmlElement, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, // eslint-disable-line\n} from '../internals.js'\n\n/**\n * Represents text in a Dom Element. In the future this type will also handle\n * simple formatting information like bold and italic.\n */\nexport class YXmlText extends YText {\n /**\n * @type {YXmlElement|YXmlText|null}\n */\n get nextSibling () {\n const n = this._item ? this._item.next : null\n return n ? /** @type {YXmlElement|YXmlText} */ (/** @type {ContentType} */ (n.content).type) : null\n }\n\n /**\n * @type {YXmlElement|YXmlText|null}\n */\n get prevSibling () {\n const n = this._item ? this._item.prev : null\n return n ? /** @type {YXmlElement|YXmlText} */ (/** @type {ContentType} */ (n.content).type) : null\n }\n\n _copy () {\n return new YXmlText()\n }\n\n /**\n * Makes a copy of this data type that can be included somewhere else.\n *\n * Note that the content is only readable _after_ it has been included somewhere in the Ydoc.\n *\n * @return {YXmlText}\n */\n clone () {\n const text = new YXmlText()\n text.applyDelta(this.toDelta())\n return text\n }\n\n /**\n * Creates a Dom Element that mirrors this YXmlText.\n *\n * @param {Document} [_document=document] The document object (you must define\n * this when calling this method in\n * nodejs)\n * @param {Object<string, any>} [hooks] Optional property to customize how hooks\n * are presented in the DOM\n * @param {any} [binding] You should not set this property. This is\n * used if DomBinding wants to create a\n * association to the created DOM type.\n * @return {Text} The {@link https://developer.mozilla.org/en-US/docs/Web/API/Element|Dom Element}\n *\n * @public\n */\n toDOM (_document = document, hooks, binding) {\n const dom = _document.createTextNode(this.toString())\n if (binding !== undefined) {\n binding._createAssociation(dom, this)\n }\n return dom\n }\n\n toString () {\n // @ts-ignore\n return this.toDelta().map(delta => {\n const nestedNodes = []\n for (const nodeName in delta.attributes) {\n const attrs = []\n for (const key in delta.attributes[nodeName]) {\n attrs.push({ key, value: delta.attributes[nodeName][key] })\n }\n // sort attributes to get a unique order\n attrs.sort((a, b) => a.key < b.key ? -1 : 1)\n nestedNodes.push({ nodeName, attrs })\n }\n // sort node order to get a unique order\n nestedNodes.sort((a, b) => a.nodeName < b.nodeName ? -1 : 1)\n // now convert to dom string\n let str = ''\n for (let i = 0; i < nestedNodes.length; i++) {\n const node = nestedNodes[i]\n str += `<${node.nodeName}`\n for (let j = 0; j < node.attrs.length; j++) {\n const attr = node.attrs[j]\n str += ` ${attr.key}=\"${attr.value}\"`\n }\n str += '>'\n }\n str += delta.insert\n for (let i = nestedNodes.length - 1; i >= 0; i--) {\n str += `</${nestedNodes[i].nodeName}>`\n }\n return str\n }).join('')\n }\n\n /**\n * @return {string}\n */\n toJSON () {\n return this.toString()\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n */\n _write (encoder) {\n encoder.writeTypeRef(YXmlTextRefID)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {YXmlText}\n *\n * @private\n * @function\n */\nexport const readYXmlText = decoder => new YXmlText()\n", "import {\n UpdateEncoderV1, UpdateEncoderV2, ID, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\nexport class AbstractStruct {\n /**\n * @param {ID} id\n * @param {number} length\n */\n constructor (id, length) {\n this.id = id\n this.length = length\n }\n\n /**\n * @type {boolean}\n */\n get deleted () {\n throw error.methodUnimplemented()\n }\n\n /**\n * Merge this struct with the item to the right.\n * This method is already assuming that `this.id.clock + this.length === this.id.clock`.\n * Also this method does *not* remove right from StructStore!\n * @param {AbstractStruct} right\n * @return {boolean} whether this merged with right\n */\n mergeWith (right) {\n return false\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.\n * @param {number} offset\n * @param {number} encodingRef\n */\n write (encoder, offset, encodingRef) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {Transaction} transaction\n * @param {number} offset\n */\n integrate (transaction, offset) {\n throw error.methodUnimplemented()\n }\n}\n", "import {\n AbstractStruct,\n addStruct,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction, ID // eslint-disable-line\n} from '../internals.js'\n\nexport const structGCRefNumber = 0\n\n/**\n * @private\n */\nexport class GC extends AbstractStruct {\n get deleted () {\n return true\n }\n\n delete () {}\n\n /**\n * @param {GC} right\n * @return {boolean}\n */\n mergeWith (right) {\n if (this.constructor !== right.constructor) {\n return false\n }\n this.length += right.length\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {number} offset\n */\n integrate (transaction, offset) {\n if (offset > 0) {\n this.id.clock += offset\n this.length -= offset\n }\n addStruct(transaction.doc.store, this)\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeInfo(structGCRefNumber)\n encoder.writeLen(this.length - offset)\n }\n\n /**\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @return {null | number}\n */\n getMissing (transaction, store) {\n return null\n }\n}\n", "import {\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\nexport class ContentBinary {\n /**\n * @param {Uint8Array} content\n */\n constructor (content) {\n this.content = content\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return 1\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return [this.content]\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentBinary}\n */\n copy () {\n return new ContentBinary(this.content)\n }\n\n /**\n * @param {number} offset\n * @return {ContentBinary}\n */\n splice (offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {ContentBinary} right\n * @return {boolean}\n */\n mergeWith (right) {\n return false\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {}\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeBuf(this.content)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 3\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder\n * @return {ContentBinary}\n */\nexport const readContentBinary = decoder => new ContentBinary(decoder.readBuf())\n", "import {\n addToDeleteSet,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line\n} from '../internals.js'\n\nexport class ContentDeleted {\n /**\n * @param {number} len\n */\n constructor (len) {\n this.len = len\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return this.len\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return []\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return false\n }\n\n /**\n * @return {ContentDeleted}\n */\n copy () {\n return new ContentDeleted(this.len)\n }\n\n /**\n * @param {number} offset\n * @return {ContentDeleted}\n */\n splice (offset) {\n const right = new ContentDeleted(this.len - offset)\n this.len = offset\n return right\n }\n\n /**\n * @param {ContentDeleted} right\n * @return {boolean}\n */\n mergeWith (right) {\n this.len += right.len\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {\n addToDeleteSet(transaction.deleteSet, item.id.client, item.id.clock, this.len)\n item.markDeleted()\n }\n\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeLen(this.len - offset)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 1\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2 } decoder\n * @return {ContentDeleted}\n */\nexport const readContentDeleted = decoder => new ContentDeleted(decoder.readLen())\n", "import {\n Doc, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction, Item // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\n/**\n * @param {string} guid\n * @param {Object<string, any>} opts\n */\nconst createDocFromOpts = (guid, opts) => new Doc({ guid, ...opts, shouldLoad: opts.shouldLoad || opts.autoLoad || false })\n\n/**\n * @private\n */\nexport class ContentDoc {\n /**\n * @param {Doc} doc\n */\n constructor (doc) {\n if (doc._item) {\n console.error('This document was already integrated as a sub-document. You should create a second instance instead with the same guid.')\n }\n /**\n * @type {Doc}\n */\n this.doc = doc\n /**\n * @type {any}\n */\n const opts = {}\n this.opts = opts\n if (!doc.gc) {\n opts.gc = false\n }\n if (doc.autoLoad) {\n opts.autoLoad = true\n }\n if (doc.meta !== null) {\n opts.meta = doc.meta\n }\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return 1\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return [this.doc]\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentDoc}\n */\n copy () {\n return new ContentDoc(createDocFromOpts(this.doc.guid, this.opts))\n }\n\n /**\n * @param {number} offset\n * @return {ContentDoc}\n */\n splice (offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {ContentDoc} right\n * @return {boolean}\n */\n mergeWith (right) {\n return false\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {\n // this needs to be reflected in doc.destroy as well\n this.doc._item = item\n transaction.subdocsAdded.add(this.doc)\n if (this.doc.shouldLoad) {\n transaction.subdocsLoaded.add(this.doc)\n }\n }\n\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {\n if (transaction.subdocsAdded.has(this.doc)) {\n transaction.subdocsAdded.delete(this.doc)\n } else {\n transaction.subdocsRemoved.add(this.doc)\n }\n }\n\n /**\n * @param {StructStore} store\n */\n gc (store) { }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeString(this.doc.guid)\n encoder.writeAny(this.opts)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 9\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentDoc}\n */\nexport const readContentDoc = decoder => new ContentDoc(createDocFromOpts(decoder.readString(), decoder.readAny()))\n", "import {\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Item, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\n/**\n * @private\n */\nexport class ContentEmbed {\n /**\n * @param {Object} embed\n */\n constructor (embed) {\n this.embed = embed\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return 1\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return [this.embed]\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentEmbed}\n */\n copy () {\n return new ContentEmbed(this.embed)\n }\n\n /**\n * @param {number} offset\n * @return {ContentEmbed}\n */\n splice (offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {ContentEmbed} right\n * @return {boolean}\n */\n mergeWith (right) {\n return false\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {}\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeJSON(this.embed)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 5\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentEmbed}\n */\nexport const readContentEmbed = decoder => new ContentEmbed(decoder.readJSON())\n", "import {\n YText, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Item, StructStore, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\n/**\n * @private\n */\nexport class ContentFormat {\n /**\n * @param {string} key\n * @param {Object} value\n */\n constructor (key, value) {\n this.key = key\n this.value = value\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return 1\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return []\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return false\n }\n\n /**\n * @return {ContentFormat}\n */\n copy () {\n return new ContentFormat(this.key, this.value)\n }\n\n /**\n * @param {number} _offset\n * @return {ContentFormat}\n */\n splice (_offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {ContentFormat} _right\n * @return {boolean}\n */\n mergeWith (_right) {\n return false\n }\n\n /**\n * @param {Transaction} _transaction\n * @param {Item} item\n */\n integrate (_transaction, item) {\n // @todo searchmarker are currently unsupported for rich text documents\n const p = /** @type {YText} */ (item.parent)\n p._searchMarker = null\n p._hasFormatting = true\n }\n\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeKey(this.key)\n encoder.writeJSON(this.value)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 6\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentFormat}\n */\nexport const readContentFormat = decoder => new ContentFormat(decoder.readKey(), decoder.readJSON())\n", "import {\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Transaction, Item, StructStore // eslint-disable-line\n} from '../internals.js'\n\n/**\n * @private\n */\nexport class ContentJSON {\n /**\n * @param {Array<any>} arr\n */\n constructor (arr) {\n /**\n * @type {Array<any>}\n */\n this.arr = arr\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return this.arr.length\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return this.arr\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentJSON}\n */\n copy () {\n return new ContentJSON(this.arr)\n }\n\n /**\n * @param {number} offset\n * @return {ContentJSON}\n */\n splice (offset) {\n const right = new ContentJSON(this.arr.slice(offset))\n this.arr = this.arr.slice(0, offset)\n return right\n }\n\n /**\n * @param {ContentJSON} right\n * @return {boolean}\n */\n mergeWith (right) {\n this.arr = this.arr.concat(right.arr)\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {}\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n const len = this.arr.length\n encoder.writeLen(len - offset)\n for (let i = offset; i < len; i++) {\n const c = this.arr[i]\n encoder.writeString(c === undefined ? 'undefined' : JSON.stringify(c))\n }\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 2\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentJSON}\n */\nexport const readContentJSON = decoder => {\n const len = decoder.readLen()\n const cs = []\n for (let i = 0; i < len; i++) {\n const c = decoder.readString()\n if (c === 'undefined') {\n cs.push(undefined)\n } else {\n cs.push(JSON.parse(c))\n }\n }\n return new ContentJSON(cs)\n}\n", "import {\n UpdateEncoderV1, UpdateEncoderV2, UpdateDecoderV1, UpdateDecoderV2, Transaction, Item, StructStore // eslint-disable-line\n} from '../internals.js'\n\nimport * as env from 'lib0/environment'\nimport * as object from 'lib0/object'\n\nconst isDevMode = env.getVariable('node_env') === 'development'\n\nexport class ContentAny {\n /**\n * @param {Array<any>} arr\n */\n constructor (arr) {\n /**\n * @type {Array<any>}\n */\n this.arr = arr\n isDevMode && object.deepFreeze(arr)\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return this.arr.length\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return this.arr\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentAny}\n */\n copy () {\n return new ContentAny(this.arr)\n }\n\n /**\n * @param {number} offset\n * @return {ContentAny}\n */\n splice (offset) {\n const right = new ContentAny(this.arr.slice(offset))\n this.arr = this.arr.slice(0, offset)\n return right\n }\n\n /**\n * @param {ContentAny} right\n * @return {boolean}\n */\n mergeWith (right) {\n this.arr = this.arr.concat(right.arr)\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {}\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n const len = this.arr.length\n encoder.writeLen(len - offset)\n for (let i = offset; i < len; i++) {\n const c = this.arr[i]\n encoder.writeAny(c)\n }\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 8\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentAny}\n */\nexport const readContentAny = decoder => {\n const len = decoder.readLen()\n const cs = []\n for (let i = 0; i < len; i++) {\n cs.push(decoder.readAny())\n }\n return new ContentAny(cs)\n}\n", "import {\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, Transaction, Item, StructStore // eslint-disable-line\n} from '../internals.js'\n\n/**\n * @private\n */\nexport class ContentString {\n /**\n * @param {string} str\n */\n constructor (str) {\n /**\n * @type {string}\n */\n this.str = str\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return this.str.length\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return this.str.split('')\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentString}\n */\n copy () {\n return new ContentString(this.str)\n }\n\n /**\n * @param {number} offset\n * @return {ContentString}\n */\n splice (offset) {\n const right = new ContentString(this.str.slice(offset))\n this.str = this.str.slice(0, offset)\n\n // Prevent encoding invalid documents because of splitting of surrogate pairs: https://github.com/yjs/yjs/issues/248\n const firstCharCode = this.str.charCodeAt(offset - 1)\n if (firstCharCode >= 0xD800 && firstCharCode <= 0xDBFF) {\n // Last character of the left split is the start of a surrogate utf16/ucs2 pair.\n // We don't support splitting of surrogate pairs because this may lead to invalid documents.\n // Replace the invalid character with a unicode replacement character (� / U+FFFD)\n this.str = this.str.slice(0, offset - 1) + '�'\n // replace right as well\n right.str = '�' + right.str.slice(1)\n }\n return right\n }\n\n /**\n * @param {ContentString} right\n * @return {boolean}\n */\n mergeWith (right) {\n this.str += right.str\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {}\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {}\n /**\n * @param {StructStore} store\n */\n gc (store) {}\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeString(offset === 0 ? this.str : this.str.slice(offset))\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 4\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentString}\n */\nexport const readContentString = decoder => new ContentString(decoder.readString())\n", "import {\n readYArray,\n readYMap,\n readYText,\n readYXmlElement,\n readYXmlFragment,\n readYXmlHook,\n readYXmlText,\n UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction, Item, YEvent, AbstractType // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\n\n/**\n * @type {Array<function(UpdateDecoderV1 | UpdateDecoderV2):AbstractType<any>>}\n * @private\n */\nexport const typeRefs = [\n readYArray,\n readYMap,\n readYText,\n readYXmlElement,\n readYXmlFragment,\n readYXmlHook,\n readYXmlText\n]\n\nexport const YArrayRefID = 0\nexport const YMapRefID = 1\nexport const YTextRefID = 2\nexport const YXmlElementRefID = 3\nexport const YXmlFragmentRefID = 4\nexport const YXmlHookRefID = 5\nexport const YXmlTextRefID = 6\n\n/**\n * @private\n */\nexport class ContentType {\n /**\n * @param {AbstractType<any>} type\n */\n constructor (type) {\n /**\n * @type {AbstractType<any>}\n */\n this.type = type\n }\n\n /**\n * @return {number}\n */\n getLength () {\n return 1\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n return [this.type]\n }\n\n /**\n * @return {boolean}\n */\n isCountable () {\n return true\n }\n\n /**\n * @return {ContentType}\n */\n copy () {\n return new ContentType(this.type._copy())\n }\n\n /**\n * @param {number} offset\n * @return {ContentType}\n */\n splice (offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {ContentType} right\n * @return {boolean}\n */\n mergeWith (right) {\n return false\n }\n\n /**\n * @param {Transaction} transaction\n * @param {Item} item\n */\n integrate (transaction, item) {\n this.type._integrate(transaction.doc, item)\n }\n\n /**\n * @param {Transaction} transaction\n */\n delete (transaction) {\n let item = this.type._start\n while (item !== null) {\n if (!item.deleted) {\n item.delete(transaction)\n } else if (item.id.clock < (transaction.beforeState.get(item.id.client) || 0)) {\n // This will be gc'd later and we want to merge it if possible\n // We try to merge all deleted items after each transaction,\n // but we have no knowledge about that this needs to be merged\n // since it is not in transaction.ds. Hence we add it to transaction._mergeStructs\n transaction._mergeStructs.push(item)\n }\n item = item.right\n }\n this.type._map.forEach(item => {\n if (!item.deleted) {\n item.delete(transaction)\n } else if (item.id.clock < (transaction.beforeState.get(item.id.client) || 0)) {\n // same as above\n transaction._mergeStructs.push(item)\n }\n })\n transaction.changed.delete(this.type)\n }\n\n /**\n * @param {StructStore} store\n */\n gc (store) {\n let item = this.type._start\n while (item !== null) {\n item.gc(store, true)\n item = item.right\n }\n this.type._start = null\n this.type._map.forEach(/** @param {Item | null} item */ (item) => {\n while (item !== null) {\n item.gc(store, true)\n item = item.left\n }\n })\n this.type._map = new Map()\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n this.type._write(encoder)\n }\n\n /**\n * @return {number}\n */\n getRef () {\n return 7\n }\n}\n\n/**\n * @private\n *\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @return {ContentType}\n */\nexport const readContentType = decoder => new ContentType(typeRefs[decoder.readTypeRef()](decoder))\n", "import {\n GC,\n getState,\n AbstractStruct,\n replaceStruct,\n addStruct,\n addToDeleteSet,\n findRootTypeKey,\n compareIDs,\n getItem,\n getItemCleanEnd,\n getItemCleanStart,\n readContentDeleted,\n readContentBinary,\n readContentJSON,\n readContentAny,\n readContentString,\n readContentEmbed,\n readContentDoc,\n createID,\n readContentFormat,\n readContentType,\n addChangedTypeToTransaction,\n isDeleted,\n StackItem, DeleteSet, UpdateDecoderV1, UpdateDecoderV2, UpdateEncoderV1, UpdateEncoderV2, ContentType, ContentDeleted, StructStore, ID, AbstractType, Transaction // eslint-disable-line\n} from '../internals.js'\n\nimport * as error from 'lib0/error'\nimport * as binary from 'lib0/binary'\nimport * as array from 'lib0/array'\n\n/**\n * @todo This should return several items\n *\n * @param {StructStore} store\n * @param {ID} id\n * @return {{item:Item, diff:number}}\n */\nexport const followRedone = (store, id) => {\n /**\n * @type {ID|null}\n */\n let nextID = id\n let diff = 0\n let item\n do {\n if (diff > 0) {\n nextID = createID(nextID.client, nextID.clock + diff)\n }\n item = getItem(store, nextID)\n diff = nextID.clock - item.id.clock\n nextID = item.redone\n } while (nextID !== null && item instanceof Item)\n return {\n item, diff\n }\n}\n\n/**\n * Make sure that neither item nor any of its parents is ever deleted.\n *\n * This property does not persist when storing it into a database or when\n * sending it to other peers\n *\n * @param {Item|null} item\n * @param {boolean} keep\n */\nexport const keepItem = (item, keep) => {\n while (item !== null && item.keep !== keep) {\n item.keep = keep\n item = /** @type {AbstractType<any>} */ (item.parent)._item\n }\n}\n\n/**\n * Split leftItem into two items\n * @param {Transaction} transaction\n * @param {Item} leftItem\n * @param {number} diff\n * @return {Item}\n *\n * @function\n * @private\n */\nexport const splitItem = (transaction, leftItem, diff) => {\n // create rightItem\n const { client, clock } = leftItem.id\n const rightItem = new Item(\n createID(client, clock + diff),\n leftItem,\n createID(client, clock + diff - 1),\n leftItem.right,\n leftItem.rightOrigin,\n leftItem.parent,\n leftItem.parentSub,\n leftItem.content.splice(diff)\n )\n if (leftItem.deleted) {\n rightItem.markDeleted()\n }\n if (leftItem.keep) {\n rightItem.keep = true\n }\n if (leftItem.redone !== null) {\n rightItem.redone = createID(leftItem.redone.client, leftItem.redone.clock + diff)\n }\n // update left (do not set leftItem.rightOrigin as it will lead to problems when syncing)\n leftItem.right = rightItem\n // update right\n if (rightItem.right !== null) {\n rightItem.right.left = rightItem\n }\n // right is more specific.\n transaction._mergeStructs.push(rightItem)\n // update parent._map\n if (rightItem.parentSub !== null && rightItem.right === null) {\n /** @type {AbstractType<any>} */ (rightItem.parent)._map.set(rightItem.parentSub, rightItem)\n }\n leftItem.length = diff\n return rightItem\n}\n\n/**\n * @param {Array<StackItem>} stack\n * @param {ID} id\n */\nconst isDeletedByUndoStack = (stack, id) => array.some(stack, /** @param {StackItem} s */ s => isDeleted(s.deletions, id))\n\n/**\n * Redoes the effect of this operation.\n *\n * @param {Transaction} transaction The Yjs instance.\n * @param {Item} item\n * @param {Set<Item>} redoitems\n * @param {DeleteSet} itemsToDelete\n * @param {boolean} ignoreRemoteMapChanges\n * @param {import('../utils/UndoManager.js').UndoManager} um\n *\n * @return {Item|null}\n *\n * @private\n */\nexport const redoItem = (transaction, item, redoitems, itemsToDelete, ignoreRemoteMapChanges, um) => {\n const doc = transaction.doc\n const store = doc.store\n const ownClientID = doc.clientID\n const redone = item.redone\n if (redone !== null) {\n return getItemCleanStart(transaction, redone)\n }\n let parentItem = /** @type {AbstractType<any>} */ (item.parent)._item\n /**\n * @type {Item|null}\n */\n let left = null\n /**\n * @type {Item|null}\n */\n let right\n // make sure that parent is redone\n if (parentItem !== null && parentItem.deleted === true) {\n // try to undo parent if it will be undone anyway\n if (parentItem.redone === null && (!redoitems.has(parentItem) || redoItem(transaction, parentItem, redoitems, itemsToDelete, ignoreRemoteMapChanges, um) === null)) {\n return null\n }\n while (parentItem.redone !== null) {\n parentItem = getItemCleanStart(transaction, parentItem.redone)\n }\n }\n const parentType = parentItem === null ? /** @type {AbstractType<any>} */ (item.parent) : /** @type {ContentType} */ (parentItem.content).type\n\n if (item.parentSub === null) {\n // Is an array item. Insert at the old position\n left = item.left\n right = item\n // find next cloned_redo items\n while (left !== null) {\n /**\n * @type {Item|null}\n */\n let leftTrace = left\n // trace redone until parent matches\n while (leftTrace !== null && /** @type {AbstractType<any>} */ (leftTrace.parent)._item !== parentItem) {\n leftTrace = leftTrace.redone === null ? null : getItemCleanStart(transaction, leftTrace.redone)\n }\n if (leftTrace !== null && /** @type {AbstractType<any>} */ (leftTrace.parent)._item === parentItem) {\n left = leftTrace\n break\n }\n left = left.left\n }\n while (right !== null) {\n /**\n * @type {Item|null}\n */\n let rightTrace = right\n // trace redone until parent matches\n while (rightTrace !== null && /** @type {AbstractType<any>} */ (rightTrace.parent)._item !== parentItem) {\n rightTrace = rightTrace.redone === null ? null : getItemCleanStart(transaction, rightTrace.redone)\n }\n if (rightTrace !== null && /** @type {AbstractType<any>} */ (rightTrace.parent)._item === parentItem) {\n right = rightTrace\n break\n }\n right = right.right\n }\n } else {\n right = null\n if (item.right && !ignoreRemoteMapChanges) {\n left = item\n // Iterate right while right is in itemsToDelete\n // If it is intended to delete right while item is redone, we can expect that item should replace right.\n while (left !== null && left.right !== null && (left.right.redone || isDeleted(itemsToDelete, left.right.id) || isDeletedByUndoStack(um.undoStack, left.right.id) || isDeletedByUndoStack(um.redoStack, left.right.id))) {\n left = left.right\n // follow redone\n while (left.redone) left = getItemCleanStart(transaction, left.redone)\n }\n if (left && left.right !== null) {\n // It is not possible to redo this item because it conflicts with a\n // change from another client\n return null\n }\n } else {\n left = parentType._map.get(item.parentSub) || null\n }\n // drop cross-parent left so origin doesn't mislead the remote (#757)\n if (left !== null && /** @type {AbstractType<any>} */ (left.parent)._item !== parentItem) {\n left = parentType._map.get(item.parentSub) || null\n }\n }\n const nextClock = getState(store, ownClientID)\n const nextId = createID(ownClientID, nextClock)\n const redoneItem = new Item(\n nextId,\n left, left && left.lastId,\n right, right && right.id,\n parentType,\n item.parentSub,\n item.content.copy()\n )\n item.redone = nextId\n keepItem(redoneItem, true)\n redoneItem.integrate(transaction, 0)\n return redoneItem\n}\n\n/**\n * Abstract class that represents any content.\n */\nexport class Item extends AbstractStruct {\n /**\n * @param {ID} id\n * @param {Item | null} left\n * @param {ID | null} origin\n * @param {Item | null} right\n * @param {ID | null} rightOrigin\n * @param {AbstractType<any>|ID|null} parent Is a type if integrated, is null if it is possible to copy parent from left or right, is ID before integration to search for it.\n * @param {string | null} parentSub\n * @param {AbstractContent} content\n */\n constructor (id, left, origin, right, rightOrigin, parent, parentSub, content) {\n super(id, content.getLength())\n /**\n * The item that was originally to the left of this item.\n * @type {ID | null}\n */\n this.origin = origin\n /**\n * The item that is currently to the left of this item.\n * @type {Item | null}\n */\n this.left = left\n /**\n * The item that is currently to the right of this item.\n * @type {Item | null}\n */\n this.right = right\n /**\n * The item that was originally to the right of this item.\n * @type {ID | null}\n */\n this.rightOrigin = rightOrigin\n /**\n * @type {AbstractType<any>|ID|null}\n */\n this.parent = parent\n /**\n * If the parent refers to this item with some kind of key (e.g. YMap, the\n * key is specified here. The key is then used to refer to the list in which\n * to insert this item. If `parentSub = null` type._start is the list in\n * which to insert to. Otherwise it is `parent._map`.\n * @type {String | null}\n */\n this.parentSub = parentSub\n /**\n * If this type's effect is redone this type refers to the type that undid\n * this operation.\n * @type {ID | null}\n */\n this.redone = null\n /**\n * @type {AbstractContent}\n */\n this.content = content\n /**\n * bit1: keep\n * bit2: countable\n * bit3: deleted\n * bit4: mark - mark node as fast-search-marker\n * @type {number} byte\n */\n this.info = this.content.isCountable() ? binary.BIT2 : 0\n }\n\n /**\n * This is used to mark the item as an indexed fast-search marker\n *\n * @type {boolean}\n */\n set marker (isMarked) {\n if (((this.info & binary.BIT4) > 0) !== isMarked) {\n this.info ^= binary.BIT4\n }\n }\n\n get marker () {\n return (this.info & binary.BIT4) > 0\n }\n\n /**\n * If true, do not garbage collect this Item.\n */\n get keep () {\n return (this.info & binary.BIT1) > 0\n }\n\n set keep (doKeep) {\n if (this.keep !== doKeep) {\n this.info ^= binary.BIT1\n }\n }\n\n get countable () {\n return (this.info & binary.BIT2) > 0\n }\n\n /**\n * Whether this item was deleted or not.\n * @type {Boolean}\n */\n get deleted () {\n return (this.info & binary.BIT3) > 0\n }\n\n set deleted (doDelete) {\n if (this.deleted !== doDelete) {\n this.info ^= binary.BIT3\n }\n }\n\n markDeleted () {\n this.info |= binary.BIT3\n }\n\n /**\n * Return the creator clientID of the missing op or define missing items and return null.\n *\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @return {null | number}\n */\n getMissing (transaction, store) {\n if (this.origin && this.origin.client !== this.id.client && this.origin.clock >= getState(store, this.origin.client)) {\n return this.origin.client\n }\n if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= getState(store, this.rightOrigin.client)) {\n return this.rightOrigin.client\n }\n if (this.parent && this.parent.constructor === ID && this.id.client !== this.parent.client && this.parent.clock >= getState(store, this.parent.client)) {\n return this.parent.client\n }\n\n // We have all missing ids, now find the items\n\n if (this.origin) {\n this.left = getItemCleanEnd(transaction, store, this.origin)\n this.origin = this.left.lastId\n }\n if (this.rightOrigin) {\n this.right = getItemCleanStart(transaction, this.rightOrigin)\n this.rightOrigin = this.right.id\n }\n if ((this.left && this.left.constructor === GC) || (this.right && this.right.constructor === GC)) {\n this.parent = null\n } else if (!this.parent) {\n // only set parent if this shouldn't be garbage collected\n if (this.left && this.left.constructor === Item) {\n this.parent = this.left.parent\n this.parentSub = this.left.parentSub\n } else if (this.right && this.right.constructor === Item) {\n this.parent = this.right.parent\n this.parentSub = this.right.parentSub\n }\n } else if (this.parent.constructor === ID) {\n const parentItem = getItem(store, this.parent)\n if (parentItem.constructor === GC) {\n this.parent = null\n } else {\n this.parent = /** @type {ContentType} */ (parentItem.content).type\n }\n }\n return null\n }\n\n /**\n * @param {Transaction} transaction\n * @param {number} offset\n */\n integrate (transaction, offset) {\n if (offset > 0) {\n this.id.clock += offset\n this.left = getItemCleanEnd(transaction, transaction.doc.store, createID(this.id.client, this.id.clock - 1))\n this.origin = this.left.lastId\n this.content = this.content.splice(offset)\n this.length -= offset\n }\n\n if (this.parent) {\n if ((!this.left && (!this.right || this.right.left !== null)) || (this.left && this.left.right !== this.right)) {\n /**\n * @type {Item|null}\n */\n let left = this.left\n\n /**\n * @type {Item|null}\n */\n let o\n // set o to the first conflicting item\n if (left !== null) {\n o = left.right\n } else if (this.parentSub !== null) {\n o = /** @type {AbstractType<any>} */ (this.parent)._map.get(this.parentSub) || null\n while (o !== null && o.left !== null) {\n o = o.left\n }\n } else {\n o = /** @type {AbstractType<any>} */ (this.parent)._start\n }\n // TODO: use something like DeleteSet here (a tree implementation would be best)\n // @todo use global set definitions\n /**\n * @type {Set<Item>}\n */\n const conflictingItems = new Set()\n /**\n * @type {Set<Item>}\n */\n const itemsBeforeOrigin = new Set()\n // Let c in conflictingItems, b in itemsBeforeOrigin\n // ***{origin}bbbb{this}{c,b}{c,b}{o}***\n // Note that conflictingItems is a subset of itemsBeforeOrigin\n while (o !== null && o !== this.right) {\n itemsBeforeOrigin.add(o)\n conflictingItems.add(o)\n if (compareIDs(this.origin, o.origin)) {\n // case 1\n if (o.id.client < this.id.client) {\n left = o\n conflictingItems.clear()\n } else if (compareIDs(this.rightOrigin, o.rightOrigin)) {\n // this and o are conflicting and point to the same integration points. The id decides which item comes first.\n // Since this is to the left of o, we can break here\n break\n } // else, o might be integrated before an item that this conflicts with. If so, we will find it in the next iterations\n } else if (o.origin !== null && itemsBeforeOrigin.has(getItem(transaction.doc.store, o.origin))) { // use getItem instead of getItemCleanEnd because we don't want / need to split items.\n // case 2\n if (!conflictingItems.has(getItem(transaction.doc.store, o.origin))) {\n left = o\n conflictingItems.clear()\n }\n } else {\n break\n }\n o = o.right\n }\n this.left = left\n }\n // reconnect left/right + update parent map/start if necessary\n if (this.left !== null) {\n const right = this.left.right\n this.right = right\n this.left.right = this\n } else {\n let r\n if (this.parentSub !== null) {\n r = /** @type {AbstractType<any>} */ (this.parent)._map.get(this.parentSub) || null\n while (r !== null && r.left !== null) {\n r = r.left\n }\n } else {\n r = /** @type {AbstractType<any>} */ (this.parent)._start\n ;/** @type {AbstractType<any>} */ (this.parent)._start = this\n }\n this.right = r\n }\n if (this.right !== null) {\n this.right.left = this\n } else if (this.parentSub !== null) {\n // set as current parent value if right === null and this is parentSub\n /** @type {AbstractType<any>} */ (this.parent)._map.set(this.parentSub, this)\n if (this.left !== null) {\n // this is the current attribute value of parent. delete right\n this.left.delete(transaction)\n }\n }\n // adjust length of parent\n if (this.parentSub === null && this.countable && !this.deleted) {\n /** @type {AbstractType<any>} */ (this.parent)._length += this.length\n }\n addStruct(transaction.doc.store, this)\n this.content.integrate(transaction, this)\n // add parent to transaction.changed\n addChangedTypeToTransaction(transaction, /** @type {AbstractType<any>} */ (this.parent), this.parentSub)\n if ((/** @type {AbstractType<any>} */ (this.parent)._item !== null && /** @type {AbstractType<any>} */ (this.parent)._item.deleted) || (this.parentSub !== null && this.right !== null)) {\n // delete if parent is deleted or if this is not the current attribute value of parent\n this.delete(transaction)\n }\n } else {\n // parent is not defined. Integrate GC struct instead\n new GC(this.id, this.length).integrate(transaction, 0)\n }\n }\n\n /**\n * Returns the next non-deleted item\n */\n get next () {\n let n = this.right\n while (n !== null && n.deleted) {\n n = n.right\n }\n return n\n }\n\n /**\n * Returns the previous non-deleted item\n */\n get prev () {\n let n = this.left\n while (n !== null && n.deleted) {\n n = n.left\n }\n return n\n }\n\n /**\n * Computes the last content address of this Item.\n */\n get lastId () {\n // allocating ids is pretty costly because of the amount of ids created, so we try to reuse whenever possible\n return this.length === 1 ? this.id : createID(this.id.client, this.id.clock + this.length - 1)\n }\n\n /**\n * Try to merge two items\n *\n * @param {Item} right\n * @return {boolean}\n */\n mergeWith (right) {\n if (\n this.constructor === right.constructor &&\n compareIDs(right.origin, this.lastId) &&\n this.right === right &&\n compareIDs(this.rightOrigin, right.rightOrigin) &&\n this.id.client === right.id.client &&\n this.id.clock + this.length === right.id.clock &&\n this.deleted === right.deleted &&\n this.redone === null &&\n right.redone === null &&\n this.content.constructor === right.content.constructor &&\n this.content.mergeWith(right.content)\n ) {\n const searchMarker = /** @type {AbstractType<any>} */ (this.parent)._searchMarker\n if (searchMarker) {\n searchMarker.forEach(marker => {\n if (marker.p === right) {\n // right is going to be \"forgotten\" so we need to update the marker\n marker.p = this\n // adjust marker index\n if (!this.deleted && this.countable) {\n marker.index -= this.length\n }\n }\n })\n }\n if (right.keep) {\n this.keep = true\n }\n this.right = right.right\n if (this.right !== null) {\n this.right.left = this\n }\n this.length += right.length\n return true\n }\n return false\n }\n\n /**\n * Mark this Item as deleted.\n *\n * @param {Transaction} transaction\n */\n delete (transaction) {\n if (!this.deleted) {\n const parent = /** @type {AbstractType<any>} */ (this.parent)\n // adjust the length of parent\n if (this.countable && this.parentSub === null) {\n parent._length -= this.length\n }\n this.markDeleted()\n addToDeleteSet(transaction.deleteSet, this.id.client, this.id.clock, this.length)\n addChangedTypeToTransaction(transaction, parent, this.parentSub)\n this.content.delete(transaction)\n }\n }\n\n /**\n * @param {StructStore} store\n * @param {boolean} parentGCd\n */\n gc (store, parentGCd) {\n if (!this.deleted) {\n throw error.unexpectedCase()\n }\n this.content.gc(store)\n if (parentGCd) {\n replaceStruct(store, this, new GC(this.id, this.length))\n } else {\n this.content = new ContentDeleted(this.length)\n }\n }\n\n /**\n * Transform the properties of this type to binary and write it to an\n * BinaryEncoder.\n *\n * This is called when this Item is sent to a remote peer.\n *\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.\n * @param {number} offset\n */\n write (encoder, offset) {\n const origin = offset > 0 ? createID(this.id.client, this.id.clock + offset - 1) : this.origin\n const rightOrigin = this.rightOrigin\n const parentSub = this.parentSub\n const info = (this.content.getRef() & binary.BITS5) |\n (origin === null ? 0 : binary.BIT8) | // origin is defined\n (rightOrigin === null ? 0 : binary.BIT7) | // right origin is defined\n (parentSub === null ? 0 : binary.BIT6) // parentSub is non-null\n encoder.writeInfo(info)\n if (origin !== null) {\n encoder.writeLeftID(origin)\n }\n if (rightOrigin !== null) {\n encoder.writeRightID(rightOrigin)\n }\n if (origin === null && rightOrigin === null) {\n const parent = /** @type {AbstractType<any>} */ (this.parent)\n if (parent._item !== undefined) {\n const parentItem = parent._item\n if (parentItem === null) {\n // parent type on y._map\n // find the correct key\n const ykey = findRootTypeKey(parent)\n encoder.writeParentInfo(true) // write parentYKey\n encoder.writeString(ykey)\n } else {\n encoder.writeParentInfo(false) // write parent id\n encoder.writeLeftID(parentItem.id)\n }\n } else if (parent.constructor === String) { // this edge case was added by differential updates\n encoder.writeParentInfo(true) // write parentYKey\n encoder.writeString(parent)\n } else if (parent.constructor === ID) {\n encoder.writeParentInfo(false) // write parent id\n encoder.writeLeftID(parent)\n } else {\n error.unexpectedCase()\n }\n if (parentSub !== null) {\n encoder.writeString(parentSub)\n }\n }\n this.content.write(encoder, offset)\n }\n}\n\n/**\n * @param {UpdateDecoderV1 | UpdateDecoderV2} decoder\n * @param {number} info\n */\nexport const readItemContent = (decoder, info) => contentRefs[info & binary.BITS5](decoder)\n\n/**\n * A lookup map for reading Item content.\n *\n * @type {Array<function(UpdateDecoderV1 | UpdateDecoderV2):AbstractContent>}\n */\nexport const contentRefs = [\n () => { error.unexpectedCase() }, // GC is not ItemContent\n readContentDeleted, // 1\n readContentJSON, // 2\n readContentBinary, // 3\n readContentString, // 4\n readContentEmbed, // 5\n readContentFormat, // 6\n readContentType, // 7\n readContentAny, // 8\n readContentDoc, // 9\n () => { error.unexpectedCase() } // 10 - Skip is not ItemContent\n]\n\n/**\n * Do not implement this class!\n */\nexport class AbstractContent {\n /**\n * @return {number}\n */\n getLength () {\n throw error.methodUnimplemented()\n }\n\n /**\n * @return {Array<any>}\n */\n getContent () {\n throw error.methodUnimplemented()\n }\n\n /**\n * Should return false if this Item is some kind of meta information\n * (e.g. format information).\n *\n * * Whether this Item should be addressable via `yarray.get(i)`\n * * Whether this Item should be counted when computing yarray.length\n *\n * @return {boolean}\n */\n isCountable () {\n throw error.methodUnimplemented()\n }\n\n /**\n * @return {AbstractContent}\n */\n copy () {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {number} _offset\n * @return {AbstractContent}\n */\n splice (_offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {AbstractContent} _right\n * @return {boolean}\n */\n mergeWith (_right) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {Transaction} _transaction\n * @param {Item} _item\n */\n integrate (_transaction, _item) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {Transaction} _transaction\n */\n delete (_transaction) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {StructStore} _store\n */\n gc (_store) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder\n * @param {number} _offset\n */\n write (_encoder, _offset) {\n throw error.methodUnimplemented()\n }\n\n /**\n * @return {number}\n */\n getRef () {\n throw error.methodUnimplemented()\n }\n}\n", "import {\n AbstractStruct,\n UpdateEncoderV1, UpdateEncoderV2, StructStore, Transaction, ID // eslint-disable-line\n} from '../internals.js'\nimport * as error from 'lib0/error'\nimport * as encoding from 'lib0/encoding'\n\nexport const structSkipRefNumber = 10\n\n/**\n * @private\n */\nexport class Skip extends AbstractStruct {\n get deleted () {\n return true\n }\n\n delete () {}\n\n /**\n * @param {Skip} right\n * @return {boolean}\n */\n mergeWith (right) {\n if (this.constructor !== right.constructor) {\n return false\n }\n this.length += right.length\n return true\n }\n\n /**\n * @param {Transaction} transaction\n * @param {number} offset\n */\n integrate (transaction, offset) {\n // skip structs cannot be integrated\n error.unexpectedCase()\n }\n\n /**\n * @param {UpdateEncoderV1 | UpdateEncoderV2} encoder\n * @param {number} offset\n */\n write (encoder, offset) {\n encoder.writeInfo(structSkipRefNumber)\n // write as VarUint because Skips can't make use of predictable length-encoding\n encoding.writeVarUint(encoder.restEncoder, this.length - offset)\n }\n\n /**\n * @param {Transaction} transaction\n * @param {StructStore} store\n * @return {null | number}\n */\n getMissing (transaction, store) {\n return null\n }\n}\n", "/** eslint-env browser */\n\nexport {\n Doc,\n Transaction,\n YArray as Array,\n YMap as Map,\n YText as Text,\n YXmlText as XmlText,\n YXmlHook as XmlHook,\n YXmlElement as XmlElement,\n YXmlFragment as XmlFragment,\n YXmlEvent,\n YMapEvent,\n YArrayEvent,\n YTextEvent,\n YEvent,\n Item,\n AbstractStruct,\n GC,\n Skip,\n ContentBinary,\n ContentDeleted,\n ContentDoc,\n ContentEmbed,\n ContentFormat,\n ContentJSON,\n ContentAny,\n ContentString,\n ContentType,\n AbstractType,\n getTypeChildren,\n createRelativePositionFromTypeIndex,\n createRelativePositionFromJSON,\n createAbsolutePositionFromRelativePosition,\n compareRelativePositions,\n AbsolutePosition,\n RelativePosition,\n ID,\n createID,\n compareIDs,\n getState,\n Snapshot,\n createSnapshot,\n createDeleteSet,\n createDeleteSetFromStructStore,\n cleanupYTextFormatting,\n snapshot,\n emptySnapshot,\n findRootTypeKey,\n findIndexSS,\n getItem,\n getItemCleanStart,\n getItemCleanEnd,\n typeListToArraySnapshot,\n typeMapGetSnapshot,\n typeMapGetAllSnapshot,\n createDocFromSnapshot,\n iterateDeletedStructs,\n applyUpdate,\n applyUpdateV2,\n readUpdate,\n readUpdateV2,\n encodeStateAsUpdate,\n encodeStateAsUpdateV2,\n encodeStateVector,\n UndoManager,\n decodeSnapshot,\n encodeSnapshot,\n decodeSnapshotV2,\n encodeSnapshotV2,\n decodeStateVector,\n logUpdate,\n logUpdateV2,\n decodeUpdate,\n decodeUpdateV2,\n relativePositionToJSON,\n isDeleted,\n isParentOf,\n equalSnapshots,\n PermanentUserData, // @TODO experimental\n tryGc,\n transact,\n AbstractConnector,\n logType,\n mergeUpdates,\n mergeUpdatesV2,\n parseUpdateMeta,\n parseUpdateMetaV2,\n encodeStateVectorFromUpdate,\n encodeStateVectorFromUpdateV2,\n encodeRelativePosition,\n decodeRelativePosition,\n diffUpdate,\n diffUpdateV2,\n convertUpdateFormatV1ToV2,\n convertUpdateFormatV2ToV1,\n obfuscateUpdate,\n obfuscateUpdateV2,\n UpdateEncoderV1,\n UpdateEncoderV2,\n UpdateDecoderV1,\n UpdateDecoderV2,\n equalDeleteSets,\n mergeDeleteSets,\n snapshotContainsUpdate\n} from './internals.js'\n\nconst glo = /** @type {any} */ (typeof globalThis !== 'undefined'\n ? globalThis\n : typeof window !== 'undefined'\n ? window\n // @ts-ignore\n : typeof global !== 'undefined' ? global : {})\n\nconst importIdentifier = '__ $YJS$ __'\n\nif (glo[importIdentifier] === true) {\n /**\n * Dear reader of this message. Please take this seriously.\n *\n * If you see this message, make sure that you only import one version of Yjs. In many cases,\n * your package manager installs two versions of Yjs that are used by different packages within your project.\n * Another reason for this message is that some parts of your project use the commonjs version of Yjs\n * and others use the EcmaScript version of Yjs.\n *\n * This often leads to issues that are hard to debug. We often need to perform constructor checks,\n * e.g. `struct instanceof GC`. If you imported different versions of Yjs, it is impossible for us to\n * do the constructor checks anymore - which might break the CRDT algorithm.\n *\n * https://github.com/yjs/yjs/issues/438\n */\n console.error('Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438')\n}\nglo[importIdentifier] = true\n", "// A live document's shell, and the serializer that draws its content.\n//\n// Two halves with different jobs, which is why they look different. The shell\n// is ordinary kit markup, written as JSX like every other component here.\n// `documentHtml` is not: the binding renders by replacing the container's\n// innerHTML, so what it needs is a string, and a JSX tree would only be turned\n// back into one.\n//\n// Both live in the kit rather than beside the CRDT binding for the reason\n// tools/ui-audit.ts gives for the whole suite \u2014 markup is written under\n// packages/ketsuite/src/ui/ and nowhere else, and an island is not an\n// exception to it.\n\nimport type { TemplateResult } from '@ketvietlab/ketjs-view'\nimport type { Delta } from './live-doc-blocks.ts'\n\n/** One block as the serializer needs it: what kind, and the text it holds. */\nexport type LiveDocBlock = { type: string; checked?: boolean; delta: Delta }\n\n/** Somebody else in the document, and which block their caret is in. */\nexport type LiveDocViewer = { id: string; name: string; index: number }\n\ntype Labels = (typeof LABELS)['vi']\n\nconst LABELS = {\n vi: {\n toolbar: '\u0110\u1ECBnh d\u1EA1ng',\n editor: 'M\u00F4 t\u1EA3 c\u00F4ng vi\u1EC7c',\n blockType: 'Ki\u1EC3u kh\u1ED1i',\n p: '\u0110o\u1EA1n v\u0103n',\n h1: 'Ti\u00EAu \u0111\u1EC1 1',\n h2: 'Ti\u00EAu \u0111\u1EC1 2',\n h3: 'Ti\u00EAu \u0111\u1EC1 3',\n quote: 'Tr\u00EDch d\u1EABn',\n code: 'Kh\u1ED1i m\u00E3',\n bullet: 'Danh s\u00E1ch',\n ordered: 'Danh s\u00E1ch \u0111\u00E1nh s\u1ED1',\n check: 'Danh s\u00E1ch vi\u1EC7c c\u1EA7n l\u00E0m',\n bold: 'Ch\u1EEF \u0111\u1EADm',\n italic: 'Ch\u1EEF nghi\u00EAng',\n strike: 'G\u1EA1ch ngang',\n inlineCode: 'M\u00E3',\n link: 'Li\u00EAn k\u1EBFt',\n linkTitle: 'Th\u00EAm li\u00EAn k\u1EBFt',\n linkUrl: '\u0110\u1ECBa ch\u1EC9',\n linkApply: '\u00C1p d\u1EE5ng',\n linkRemove: 'B\u1ECF li\u00EAn k\u1EBFt',\n linkCancel: 'Hu\u1EF7',\n alsoHere: '\u0110ang xem:',\n },\n en: {\n toolbar: 'Formatting',\n editor: 'Issue description',\n blockType: 'Block type',\n p: 'Paragraph',\n h1: 'Heading 1',\n h2: 'Heading 2',\n h3: 'Heading 3',\n quote: 'Quote',\n code: 'Code block',\n bullet: 'Bullet list',\n ordered: 'Numbered list',\n check: 'Checklist',\n bold: 'Bold',\n italic: 'Italic',\n strike: 'Strikethrough',\n inlineCode: 'Code',\n link: 'Link',\n linkTitle: 'Add a link',\n linkUrl: 'Address',\n linkApply: 'Apply',\n linkRemove: 'Remove link',\n linkCancel: 'Cancel',\n alsoHere: 'Also here:',\n },\n}\n\nexport const labelsOf = (lang?: string | null): Labels =>\n LABELS[String(lang ?? '').slice(0, 2) as keyof typeof LABELS] ?? LABELS.vi\n\n/** The block vocabulary. The first six are what the type control offers. */\n\n/** Which block types are list items, and so share one wrapper across a run. */\nconst LIST_WRAPPER: Record<string, string> = { bullet: 'ul', ordered: 'ol', check: 'ul' }\n\nconst BLOCK_TAG: Record<string, string> = {\n p: 'p',\n h1: 'h1',\n h2: 'h2',\n h3: 'h3',\n quote: 'blockquote',\n code: 'pre',\n bullet: 'li',\n ordered: 'li',\n check: 'li',\n}\n\nconst escapeHtml = (text: unknown): string =>\n String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')\n\nconst escapeAttr = (text: unknown): string => escapeHtml(text).replace(/\"/g, '&quot;')\n\n/**\n * Only http/https/mailto survive.\n *\n * A link's address comes from whoever typed it, and the editor writes it\n * straight into an `href` \u2014 `javascript:` there is a script the *next* reader\n * runs, on a page that already holds their session. Anything else renders as\n * an inert `#`, which is still visibly a link, rather than silently dropping\n * text somebody typed.\n */\nconst safeHref = (href: unknown): string => {\n const value = String(href ?? '').trim()\n return /^(https?:|mailto:)/i.test(value) ? value : '#'\n}\n\n/** A line break is a newline in the model and a <br> on screen. */\nconst withBreaks = (text: string): string => escapeHtml(text).replace(/\\n/g, '<br>')\n\nconst plainOf = (delta?: Delta): string => (delta ?? []).map((op) => op.insert).join('')\n\n/**\n * A block whose text ends in a newline needs one more `<br>` than it has\n * newlines.\n *\n * The last one is a placeholder, not a character: without it the browser gives\n * the empty final line no line box, the caret has nowhere to sit, and the\n * binding \u2014 which drops one trailing `<br>` when it reads a block back \u2014\n * concluded the newline was never there. Pressing Enter at the end of a code\n * block and typing put the next line straight onto the end of the previous\n * one.\n */\nconst trailingBreak = (text: string): string => (text.endsWith('\\n') ? '<br>' : '')\n\n/**\n * One delta run's marks, wrapped innermost-first so the nesting is stable\n * across renders: selection restore walks text nodes, and a run whose wrappers\n * reorder between two renders moves the caret for no reason.\n */\nconst inlineHtml = (delta?: Delta): string =>\n (delta ?? [])\n .map((op) => {\n const attributes = op.attributes ?? {}\n let out = withBreaks(op.insert)\n if (attributes.code) out = `<code data-ui=\"flow-editor-code\">${out}</code>`\n if (attributes.bold) out = `<b>${out}</b>`\n if (attributes.italic) out = `<i>${out}</i>`\n if (attributes.strike) out = `<s>${out}</s>`\n if (attributes.link)\n out = `<a data-ui=\"flow-editor-link\" href=\"${escapeAttr(safeHref(attributes.link))}\" rel=\"noreferrer noopener\">${out}</a>`\n return out\n })\n .join('')\n\n/**\n * An empty block still needs a line box, or contenteditable gives it zero\n * height and there is nowhere left to put the caret.\n */\nconst blockBody = (block: LiveDocBlock): string => {\n const inner = inlineHtml(block.delta)\n return inner ? `${inner}${trailingBreak(plainOf(block.delta))}` : '<br>'\n}\n\n/**\n * A stable colour per person, from their name.\n *\n * Assigning colours in arrival order would give the same person a different\n * colour in every tab, and the colour is the whole point of the marker \u2014 it is\n * what lets you match the initials by the paragraph to the chip in the row\n * without reading either.\n */\nconst hueOf = (key: unknown): number => {\n let hash = 0\n for (let i = 0; i < String(key).length; i++) hash = (hash * 31 + String(key).charCodeAt(i)) % 360\n return hash\n}\n\n/** Two letters, because that is what fits and what people recognise. */\nconst initialsOf = (name: unknown): string => {\n const words = String(name ?? '')\n .trim()\n .split(/\\s+/)\n .filter(Boolean)\n if (!words.length) return '?'\n const first = words[0][0] ?? ''\n const last = words.length > 1 ? (words[words.length - 1][0] ?? '') : ''\n return (first + last).toUpperCase()\n}\n\n/** The people in a block, marked inside it so you can see whose paragraph it is. */\nconst viewerMarks = (people: LiveDocViewer[]): string =>\n people\n .map(\n (person) =>\n `<span data-ui=\"flow-editor-viewer\" contenteditable=\"false\" style=\"--flow-viewer-hue:${hueOf(person.name)}\" title=\"${escapeAttr(person.name)}\" aria-hidden=\"true\">${escapeHtml(initialsOf(person.name))}</span>`,\n )\n .join('')\n\n/**\n * Who else has this description open.\n *\n * Rendered into its own container rather than into the document, so a\n * heartbeat never touches the element somebody is typing into.\n */\nexport function presenceHtml(people: LiveDocViewer[] | undefined, lang?: string | null): string {\n const labels = labelsOf(lang)\n if (!people?.length) return ''\n return `<span data-ui=\"flow-editor-presence-label\">${escapeHtml(labels.alsoHere)}</span>${people\n .map(\n (person) =>\n `<span data-ui=\"flow-editor-viewer\" data-size=\"chip\" style=\"--flow-viewer-hue:${hueOf(person.name)}\" title=\"${escapeAttr(person.name)}\">${escapeHtml(initialsOf(person.name))}</span>`,\n )\n .join('')}`\n}\n\nconst checkMark = (block: LiveDocBlock, labels: Labels): string =>\n `<span data-ui=\"flow-editor-check\" contenteditable=\"false\" role=\"checkbox\" aria-checked=\"${block.checked ? 'true' : 'false'}\" aria-label=\"${escapeAttr(labels.check)}\" tabindex=\"-1\"></span>`\n\nconst blockHtml = (block: LiveDocBlock, index: number, labels: Labels, people: LiveDocViewer[]): string => {\n const type = BLOCK_TAG[block.type] ? block.type : 'p'\n const tag = BLOCK_TAG[type]\n const checked = type === 'check' ? ` data-checked=\"${block.checked ? 'true' : 'false'}\"` : ''\n // A code block carries no inline marks: the whole point of it is that what\n // sits inside is characters rather than formatting.\n const code = type === 'code' ? plainOf(block.delta) : ''\n const body =\n type === 'code'\n ? code\n ? `${withBreaks(code)}${trailingBreak(code)}`\n : '<br>'\n : type === 'check'\n ? `${checkMark(block, labels)}<span data-ui=\"flow-editor-line\">${blockBody(block)}</span>`\n : blockBody(block)\n return `<${tag} data-block=\"${type}\" data-index=\"${index}\"${checked}>${body}${viewerMarks(people)}</${tag}>`\n}\n\n/**\n * The whole document as one HTML string, runs of list items wrapped.\n *\n * Consecutive items share one `<ul>`/`<ol>` rather than each getting its own:\n * a screen reader announces \"list, three items\" from the wrapper, and an\n * ordered list numbers from it. `data-index` rather than child position is how\n * the binding finds a block again afterwards, precisely because these wrappers\n * mean a block is not always a direct child of the container.\n */\nexport function documentHtml(\n blocks: LiveDocBlock[] | undefined,\n lang?: string | null,\n presence?: LiveDocViewer[],\n): string {\n const labels = labelsOf(lang)\n const here = new Map<number, LiveDocViewer[]>()\n for (const person of presence ?? []) {\n const at = here.get(person.index)\n if (at) at.push(person)\n else here.set(person.index, [person])\n }\n const parts: string[] = []\n let openList = ''\n let openKind = ''\n const closeList = () => {\n if (openList) parts.push(`</${openList}>`)\n openList = ''\n openKind = ''\n }\n const list = blocks ?? []\n for (let index = 0; index < list.length; index++) {\n const block = list[index]\n const wrapper = LIST_WRAPPER[block.type]\n if (!wrapper) closeList()\n else if (openKind !== block.type) {\n closeList()\n openList = wrapper\n openKind = block.type\n parts.push(`<${wrapper} data-ui=\"flow-editor-list\" data-kind=\"${block.type}\">`)\n }\n parts.push(blockHtml(block, index, labels, here.get(index) ?? []))\n }\n closeList()\n return parts.join('')\n}\n\n/**\n * `containerId` is how the client entry finds the contenteditable element to\n * mount on: `IslandController` has no \"mounted\" hook, so the binding looks the\n * node up by id once the view has rendered.\n */\n\n/**\n * `containerId` is how the client entry finds the contenteditable element to\n * mount on: `IslandController` has no \"mounted\" hook, so the binding looks the\n * node up by id once the view has rendered.\n */\nexport function liveDocShell(o: { containerId: string; lang?: string | null }): TemplateResult {\n const labels = labelsOf(o.lang)\n const mark = (key: string, glyph: string, label: string) => (\n <button\n data-ui=\"flow-editor-mark\"\n data-flow-editor-mark={key}\n data-control=\"action\"\n data-variant=\"secondary\"\n data-size=\"compact\"\n type=\"button\"\n aria-label={label}\n title={label}\n >\n {glyph}\n </button>\n )\n const blockOption = (value: 'p' | 'h1' | 'h2' | 'h3' | 'quote' | 'code') => (\n <option value={value}>{labels[value]}</option>\n )\n return (\n <section data-ui=\"flow-editor\">\n <div data-ui=\"flow-editor-toolbar\" role=\"toolbar\" aria-label={labels.toolbar}>\n <select\n data-ui=\"form-control\"\n data-flow-editor-block\n data-size=\"compact\"\n aria-label={labels.blockType}\n title={labels.blockType}\n >\n {blockOption('p')}\n {blockOption('h1')}\n {blockOption('h2')}\n {blockOption('h3')}\n {blockOption('quote')}\n {blockOption('code')}\n </select>\n {mark('bullet', '\\u2022', labels.bullet)}\n {mark('ordered', '1.', labels.ordered)}\n {mark('check', '\\u2611', labels.check)}\n <span data-ui=\"flow-editor-divider\" aria-hidden=\"true\" />\n {mark('bold', 'B', labels.bold)}\n {mark('italic', 'I', labels.italic)}\n {mark('strike', 'S', labels.strike)}\n {mark('code', '</>', labels.inlineCode)}\n {mark('link', '\\u{1F517}', labels.link)}\n </div>\n <div data-ui=\"flow-editor-presence\" data-flow-editor-presence role=\"status\" aria-live=\"polite\" />\n {/* biome-ignore lint/a11y/useFocusableInteractive: `contenteditable` makes this natively focusable and tab-reachable, which the rule does not model; the explicit tabindex is there so it reads that way too. */}\n <div\n data-ui=\"flow-editor-content\"\n id={o.containerId}\n contenteditable=\"true\"\n role=\"textbox\"\n tabindex=\"0\"\n aria-multiline=\"true\"\n aria-label={labels.editor}\n />\n <dialog data-ui=\"flow-editor-link-dialog\" data-flow-editor-link-dialog aria-label={labels.linkTitle}>\n <div data-ui=\"flow-editor-link-body\">\n <label data-ui=\"flow-editor-link-label\">\n <span>{labels.linkUrl}</span>\n <input\n data-ui=\"form-control\"\n data-flow-editor-link-input\n type=\"url\"\n name=\"href\"\n placeholder=\"https://\"\n autocomplete=\"off\"\n />\n </label>\n <div data-ui=\"flow-editor-link-actions\">\n <button\n data-control=\"action\"\n data-variant=\"secondary\"\n data-size=\"compact\"\n type=\"button\"\n data-flow-editor-link-cancel\n >\n {labels.linkCancel}\n </button>\n <button\n data-control=\"action\"\n data-variant=\"destructive\"\n data-size=\"compact\"\n type=\"button\"\n data-flow-editor-link-remove\n >\n {labels.linkRemove}\n </button>\n <button\n data-control=\"action\"\n data-variant=\"primary\"\n data-size=\"compact\"\n type=\"button\"\n data-flow-editor-link-apply\n >\n {labels.linkApply}\n </button>\n </div>\n </div>\n </dialog>\n </section>\n )\n}\n", "// The editor's block vocabulary, shared by the binding and the Markdown\n// reader.\n//\n// Its own file because both of them need the same list and neither owns it:\n// `live-doc-markdown.ts` produces blocks and `live-doc-view.tsx` consumes\n// them, so putting the union in either one makes the other import from a\n// module it has no business depending on.\n\nexport type BlockType = 'p' | 'h1' | 'h2' | 'h3' | 'quote' | 'code' | 'bullet' | 'ordered' | 'check'\n\nexport const BLOCK_TYPES: readonly BlockType[] = [\n 'p',\n 'h1',\n 'h2',\n 'h3',\n 'quote',\n 'code',\n 'bullet',\n 'ordered',\n 'check',\n]\n\n/** The list kinds, which share a wrapper when rendered and continue on Enter. */\nexport const LIST_TYPES: readonly BlockType[] = ['bullet', 'ordered', 'check']\n\n/** Pressing Enter at the end of one of these starts another of the same kind. */\nexport const CONTINUES = new Set<BlockType>(['p', 'bullet', 'ordered', 'check'])\n\nexport type MarkName = 'bold' | 'italic' | 'strike' | 'code'\n\nexport type Attributes = {\n bold?: boolean\n italic?: boolean\n strike?: boolean\n code?: boolean\n link?: string | null\n}\n\nexport type Delta = Array<{ insert: string; attributes?: Attributes }>\n", "// Markdown in, blocks out.\n//\n// The editor's vocabulary and Markdown's overlap almost exactly, which is the\n// whole reason this is worth having: people already write `## ` and `**bold**`\n// out of habit, and they paste from README files, chat and issue trackers that\n// speak it. What arrives on the clipboard is the source, and the source is\n// what somebody meant.\n//\n// A deliberately small subset \u2014 the blocks the editor has and the marks it can\n// carry, and nothing else. There is no table, no image, no footnote, no\n// reference link, because there is nowhere to put them: a parser that produced\n// a node the renderer cannot draw would lose it silently, which is worse than\n// leaving the characters alone. Anything unrecognised stays literal text.\n//\n// Pure and DOM-free on purpose, so it can be tested without a browser \u2014 which\n// is most of why the paste path is worth trusting.\nimport type { Attributes, BlockType, Delta } from './live-doc-blocks.ts'\n\nexport type MarkdownBlock = { type: BlockType; checked: boolean; delta: Delta }\n\n/**\n * Emphasis, innermost text first.\n *\n * No inner text may contain its own delimiter, and it may not begin or end\n * with a space: the second half stops `2 * 3 * 4` turning half a sum italic,\n * and the first stops the italic rule opening on the first `*` of a bold pair\n * and eating the second as content. Inline code does not recurse \u2014 what is\n * inside it is characters.\n *\n * `word` marks the two rules that may not open or close inside a word, which\n * is CommonMark's own asymmetry between `_` and `*` and exists for exactly one\n * reason: `snake_case_name` is a name, not a sentence with a slant in it.\n */\nconst EMPHASIS: Array<{ pattern: RegExp; mark: Attributes; word?: false }> = [\n { pattern: /^\\*\\*([^*\\s](?:[^*]*[^*\\s])?)\\*\\*/, mark: { bold: true } },\n { pattern: /^__([^_\\s](?:[^_]*[^_\\s])?)__/, mark: { bold: true }, word: false },\n { pattern: /^~~([^~\\s](?:[^~]*[^~\\s])?)~~/, mark: { strike: true } },\n { pattern: /^\\*([^*\\s](?:[^*]*[^*\\s])?)\\*/, mark: { italic: true } },\n { pattern: /^_([^_\\s](?:[^_]*[^_\\s])?)_/, mark: { italic: true }, word: false },\n]\n\nconst WORD = /[\\p{L}\\p{N}_]/u\n\nconst CODE_SPAN = /^`([^`]+)`/\nconst LINK = /^\\[([^\\]]+)\\]\\(([^)\\s]+)\\)/\nconst ESCAPED = /^\\\\([\\\\`*_~[\\]()])/\n\nconst merge = (delta: Delta, mark: Attributes): Delta =>\n delta.map((op) => ({ ...op, attributes: { ...mark, ...(op.attributes ?? {}) } }))\n\n/** Runs of the same marks are one op, so a paste and a keystroke produce the same shape. */\nconst compact = (delta: Delta): Delta => {\n const out: Delta = []\n for (const op of delta) {\n const last = out[out.length - 1]\n const same = last && JSON.stringify(last.attributes ?? null) === JSON.stringify(op.attributes ?? null)\n if (same && last) last.insert += op.insert\n else out.push({ ...op })\n }\n return out.filter((op) => op.insert.length > 0)\n}\n\n/** One line of Markdown as marked-up text. */\nexport function inlineDelta(source: string): Delta {\n const out: Delta = []\n let rest = source\n let plain = ''\n let previous = ''\n const flush = () => {\n if (plain) out.push({ insert: plain })\n plain = ''\n }\n const take = (count: number) => {\n previous = rest[count - 1] as string\n rest = rest.slice(count)\n }\n while (rest) {\n const escaped = ESCAPED.exec(rest)\n if (escaped) {\n plain += escaped[1]\n take(escaped[0].length)\n continue\n }\n const link = LINK.exec(rest)\n if (link) {\n flush()\n out.push(...merge(inlineDelta(link[1] as string), { link: link[2] as string }))\n take(link[0].length)\n continue\n }\n const code = CODE_SPAN.exec(rest)\n if (code) {\n flush()\n out.push({ insert: code[1] as string, attributes: { code: true } })\n take(code[0].length)\n continue\n }\n const emphasis = EMPHASIS.map((rule) => ({ rule, match: rule.pattern.exec(rest) })).find(\n (found) =>\n found.match &&\n // A word-boundary rule has to be at one on both sides: opening after a\n // letter, or closing before one, is somebody's identifier.\n (found.rule.word !== false ||\n (!WORD.test(previous) && !WORD.test(rest[found.match[0].length] ?? ''))),\n )\n if (emphasis?.match) {\n flush()\n out.push(...merge(inlineDelta(emphasis.match[1] as string), emphasis.rule.mark))\n take(emphasis.match[0].length)\n continue\n }\n plain += rest[0]\n take(1)\n }\n flush()\n return compact(out)\n}\n\nconst FENCE = /^\\s{0,3}```/\nconst HEADING = /^(#{1,3}) +(.*)$/\nconst QUOTE = /^ {0,3}> ?(.*)$/\nconst CHECK = /^ {0,3}[-*+] +\\[([ xX])\\] +(.*)$/\nconst BULLET = /^ {0,3}[-*+] +(.*)$/\nconst ORDERED = /^ {0,3}\\d+[.)] +(.*)$/\n\nconst block = (type: BlockType, delta: Delta, checked = false): MarkdownBlock => ({\n type,\n checked,\n delta,\n})\n\n/**\n * A Markdown document as the editor's blocks.\n *\n * Consecutive plain lines join into one paragraph and a blank line ends it,\n * which is Markdown's own rule and the reason pasting a soft-wrapped README\n * does not arrive as forty one-line paragraphs. Anything with its own marker \u2014\n * a heading, a list item, a quote \u2014 is its own block regardless.\n */\nexport function parseMarkdown(source: string): MarkdownBlock[] {\n const lines = String(source ?? '').split(/\\r\\n|\\r|\\n/)\n const blocks: MarkdownBlock[] = []\n let paragraph: string[] = []\n const closeParagraph = () => {\n if (paragraph.length) blocks.push(block('p', inlineDelta(paragraph.join(' '))))\n paragraph = []\n }\n\n for (let index = 0; index < lines.length; index++) {\n const line = lines[index] as string\n\n if (FENCE.test(line)) {\n closeParagraph()\n const body: string[] = []\n index++\n while (index < lines.length && !FENCE.test(lines[index] as string)) {\n body.push(lines[index] as string)\n index++\n }\n // An unclosed fence still becomes a code block: the alternative is\n // deciding, on somebody's behalf, that they meant none of it.\n blocks.push(block('code', body.length ? [{ insert: body.join('\\n') }] : []))\n continue\n }\n\n if (!line.trim()) {\n closeParagraph()\n continue\n }\n\n const heading = HEADING.exec(line)\n if (heading) {\n closeParagraph()\n const level = (heading[1] as string).length\n blocks.push(block(`h${level}` as BlockType, inlineDelta(heading[2] as string)))\n continue\n }\n\n const check = CHECK.exec(line)\n if (check) {\n closeParagraph()\n blocks.push(block('check', inlineDelta(check[2] as string), (check[1] as string).toLowerCase() === 'x'))\n continue\n }\n\n const bullet = BULLET.exec(line)\n if (bullet) {\n closeParagraph()\n blocks.push(block('bullet', inlineDelta(bullet[1] as string)))\n continue\n }\n\n const ordered = ORDERED.exec(line)\n if (ordered) {\n closeParagraph()\n blocks.push(block('ordered', inlineDelta(ordered[1] as string)))\n continue\n }\n\n const quote = QUOTE.exec(line)\n if (quote) {\n closeParagraph()\n blocks.push(block('quote', inlineDelta(quote[1] as string)))\n continue\n }\n\n paragraph.push(line)\n }\n closeParagraph()\n return blocks\n}\n", "// The collaborative editor's DOM<->Yjs binding.\n//\n// The first version of this file was one flat rich-text run with bold and\n// italic \u2014 deliberately narrow, to prove the CRDT binding and IME handling\n// before spending anything on vocabulary. This is that vocabulary: paragraphs,\n// three heading levels, quote, code block, bullet/numbered/checklist items,\n// and the marks bold/italic/strikethrough/code/link.\n//\n// The document is a flat list of blocks, not a tree. Each block is a\n// `Y.XmlElement('block')` carrying a `type` attribute and one `Y.XmlText`\n// child; nesting exists only in the rendered HTML, where consecutive list\n// items share a `<ul>`. A tree would buy indented sub-lists and cost a\n// position model that no longer maps to `(blockIndex, offset)` \u2014 the pair\n// every operation below is written in terms of. Sub-lists are the thing given\n// up for that, stated rather than pretended away.\n//\n// Runtime-agnostic on purpose: `html` comes from the caller so the same code\n// renders server-side (flow_backend/islands.ts, importing @ketvietlab/ketjs-view\n// directly) and client-side (editor-client.mjs, importing the framework's\n// browser-served /_ket/view/index.js) \u2014 the same split mail_backend's own\n// chatter view uses.\nimport * as Y from 'yjs'\nimport type { IslandController, IslandProps, TemplateResult } from '@ketvietlab/ketjs-view'\n// The shell's markup and the document serializer, which belong to the kit and\n// not to a module \u2014 see the header of that file, and tools/ui-audit.ts for the\n// rule it answers.\nimport { documentHtml, liveDocShell, presenceHtml } from './live-doc-shell.tsx'\nimport { BLOCK_TYPES, CONTINUES, LIST_TYPES } from './live-doc-blocks.ts'\nimport type { BlockType, Delta, MarkName } from './live-doc-blocks.ts'\nimport { parseMarkdown } from './live-doc-markdown.ts'\nimport type { MarkdownBlock } from './live-doc-markdown.ts'\n\nexport type LiveDocProps = {\n /** The record this document belongs to. */\n docId: string\n /**\n * The collection its endpoints hang off \u2014 `/admin/flow/issues`, matching the\n * base the owner passed `documentRoutes`. Handed in rather than built here so\n * one editor serves an issue, a project description and a page alike.\n */\n base: string\n lang?: string\n}\n\ntype Block = { node: Y.XmlElement | Y.XmlText; text: Y.XmlText; type: BlockType; checked: boolean }\ntype Point = { index: number; offset: number }\ntype Span = { start: Point; end: Point }\ntype Viewer = { id: string; name: string; index: number; seenAt: number }\n\n/**\n * Typing a prefix turns the block into what the prefix means, the way every\n * editor people already use behaves. Each pattern matches the block's *whole*\n * text, so a rule only fires on a line that is still nothing but its prefix \u2014\n * `1. ` mid-sentence is a numbered reference, not a list.\n */\nconst INPUT_RULES: Array<[RegExp, BlockType]> = [\n [/^# $/, 'h1'],\n [/^## $/, 'h2'],\n [/^### $/, 'h3'],\n [/^> $/, 'quote'],\n [/^[-*] $/, 'bullet'],\n [/^\\d+\\. $/, 'ordered'],\n [/^\\[[ xX]?\\] $/, 'check'],\n [/^```$/, 'code'],\n]\n\n/**\n * Markdown that completes as you type it.\n *\n * Each pattern is anchored to the caret, so a rule fires on the keystroke that\n * closes it and never reaches back through text somebody finished with \u2014 the\n * closing delimiter is the gesture.\n *\n * No inner text may contain its own delimiter, and it may not begin or end\n * with a space. The second half keeps `2 * 3 * 4` a sum. The first half is\n * what makes `**now**` bold: while the inner text was merely \"not a space\",\n * the italic rule could open on the first `*` of a bold pair and swallow the\n * second one as content, so finishing `**now**` produced italic `now`.\n */\nconst INLINE_RULES: Array<{ pattern: RegExp; open: number; mark: MarkName }> = [\n { pattern: /\\*\\*([^*\\s](?:[^*]*[^*\\s])?)\\*\\*$/, open: 2, mark: 'bold' },\n { pattern: /__([^_\\s](?:[^_]*[^_\\s])?)__$/, open: 2, mark: 'bold' },\n { pattern: /~~([^~\\s](?:[^~]*[^~\\s])?)~~$/, open: 2, mark: 'strike' },\n { pattern: /(?<![*\\w])\\*([^*\\s](?:[^*]*[^*\\s])?)\\*$/, open: 1, mark: 'italic' },\n { pattern: /(?<![_\\w])_([^_\\s](?:[^_]*[^_\\s])?)_$/, open: 1, mark: 'italic' },\n { pattern: /`([^`]+)`$/, open: 1, mark: 'code' },\n]\n\nconst LINK_RULE = /\\[([^\\]]+)\\]\\(([^)\\s]+)\\)$/\n\n/**\n * How long a viewer stays listed without saying anything.\n *\n * Three heartbeats' worth, so one dropped frame does not make somebody blink\n * out of the room and back.\n */\nconst VIEWER_TTL = 90_000\nconst HEARTBEAT_MS = 30_000\n/** A caret moving between blocks is worth announcing; a caret moving is not. */\nconst ANNOUNCE_EVERY_MS = 1_000\n\nconst REMOTE = Symbol('remote-origin')\n/**\n * Typing's own transact() is tagged so the update listener can skip its\n * render() \u2014 the DOM the user is actively typing into already reflects\n * their keystroke, so replacing its innerHTML from Yjs on every single\n * character is churn a re-render doesn't need to do (it avoids fighting the\n * browser's own cursor and IME state for no reason). Every structural change\n * still wants the normal render, and says where the caret lands.\n */\nconst LOCAL_TYPING = Symbol('local-typing-origin')\n\n/**\n * `Y.XmlText.prototype.toString()` is NOT plain text \u2014 it renders each\n * attribute key as a wrapping XML tag name (e.g. `bold: true` becomes\n * `<bold>...</bold>`), which is what XmlText is for structurally, but it\n * silently broke every diff in this file: comparing that against the DOM's\n * real plain text made two unrelated strings, so `diffRange` computed a\n * delete-everything-insert-everything range and every mark on the run was\n * gone the moment anything was typed nearby. This is the actual plain-text\n * projection to diff against instead.\n */\nconst plainTextOf = (text: Y.XmlText): string => (text.toDelta() as Delta).map((op) => op.insert).join('')\n\nconst plainLength = (delta: Delta): number => delta.reduce((total, op) => total + op.insert.length, 0)\n\nconst sliceDelta = (delta: Delta, from: number, to = Number.POSITIVE_INFINITY): Delta => {\n const out: Delta = []\n let cursor = 0\n for (const op of delta) {\n const end = cursor + op.insert.length\n const start = Math.max(from, cursor)\n const stop = Math.min(to, end)\n if (stop > start)\n out.push({\n insert: op.insert.slice(start - cursor, stop - cursor),\n ...(op.attributes ? { attributes: op.attributes } : {}),\n })\n cursor = end\n }\n return out\n}\n\n/** Everything a run can carry, so every one of them can be turned off by name. */\nconst MARK_KEYS = ['bold', 'italic', 'strike', 'code', 'link'] as const\n\n/**\n * The marks new text inherits: the ones it is landing *inside* of.\n *\n * A mark does not reach past its own end. Typing in the middle of a bold word\n * keeps it bold, which is what anyone expects; typing immediately after one\n * does not, which is the half that has to be said out loud, because word\n * processors do the opposite.\n *\n * Here the closing delimiter is usually the gesture that made the mark \u2014\n * somebody types `**now**`, and the two asterisks they finished with mean\n * exactly \"stop\". Extending anyway turned the rest of the sentence bold, then\n * the rest of that into code, then dropped all of it inside a link. The\n * failure is silent in the direction that matters, too: unwanted formatting is\n * invisible until you look at it, while missing formatting is visible at once\n * and one click away.\n *\n * Every mark is named on every insert, `null` for the ones that do not apply,\n * because leaving them out is not the same statement. `Y.Text.insert` with no\n * attributes means *inherit whatever is at this position* \u2014 so the answer to\n * \"no marks here\" is an explicit no, not silence. That distinction is why the\n * paragraph above was true of the code and false of the running editor.\n */\nfunction attributesAt(text: Y.XmlText, offset: number): Record<string, unknown> {\n const clear: Record<string, unknown> = {}\n for (const key of MARK_KEYS) clear[key] = null\n if (offset === 0) return clear\n const delta = text.toDelta() as Delta\n let cursor = 0\n for (const op of delta) {\n const end = cursor + op.insert.length\n // `toDelta` merges neighbouring runs carrying the same marks, so the end of\n // an op is always the end of the run it belongs to.\n if (offset <= end) {\n if (offset === end || !op.attributes) return clear\n const carried: Record<string, unknown> = { ...clear }\n for (const key of MARK_KEYS) {\n const value = (op.attributes as Record<string, unknown>)[key]\n if (value != null) carried[key] = value\n }\n return carried\n }\n cursor = end\n }\n return clear\n}\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n let binary = ''\n for (let i = 0; i < bytes.length; i++) binary += String.fromCharCode(bytes[i] as number)\n return btoa(binary)\n}\n\nconst base64ToBytes = (base64: string): Uint8Array => {\n const binary = atob(base64)\n const bytes = new Uint8Array(binary.length)\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)\n return bytes\n}\n\n/** Common-prefix/suffix text diff \u2014 small enough edits to keep formatting on either side intact. */\nfunction diffRange(\n before: string,\n after: string,\n): { start: number; deletedLength: number; inserted: string } {\n let start = 0\n const maxStart = Math.min(before.length, after.length)\n while (start < maxStart && before[start] === after[start]) start++\n let endBefore = before.length\n let endAfter = after.length\n while (endBefore > start && endAfter > start && before[endBefore - 1] === after[endAfter - 1]) {\n endBefore--\n endAfter--\n }\n return { start, deletedLength: endBefore - start, inserted: after.slice(start, endAfter) }\n}\n\n/** A selection point given as an element must be resolved down to a text node first. */\nfunction descend(node: Node, offset: number): { node: Node; offset: number } {\n let current = node\n let at = offset\n while (current.nodeType === Node.ELEMENT_NODE) {\n const children = current.childNodes\n if (!children.length) return { node: current, offset: 0 }\n if (at >= children.length) {\n const last = children[children.length - 1] as Node\n current = last\n at = last.nodeType === Node.TEXT_NODE ? (last.textContent ?? '').length : last.childNodes.length\n } else {\n current = children[at] as Node\n at = 0\n }\n }\n return { node: current, offset: at }\n}\n\nexport function createLiveDocView(props: LiveDocProps) {\n const docId = props.docId\n const base = `${props.base}/${encodeURIComponent(docId)}`\n const containerId = `flow-editor-${docId}`\n const doc = new Y.Doc()\n let container: HTMLElement | null = null\n let shell: HTMLElement | null = null\n let composing = false\n /**\n * Where a composition began, and whether a re-render is owed to it.\n *\n * Replacing the container's innerHTML while an IME is mid-word detaches the\n * text node it is composing into, and the half-typed word goes with it \u2014\n * reproduced with two tabs: one composing `ti\u00EA`, the other typing anything,\n * and the first reader's word was gone. Telex and VNI make this ordinary\n * rather than rare: a Vietnamese word is several keystrokes long and the\n * accents rewrite letters already on screen, so the window in which a\n * collaborator can destroy one is most of the time spent typing.\n */\n let composedAt: Point | null = null\n let renderOwed: Span | null | undefined\n let source: EventSource | null = null\n /**\n * Where the caret goes after the next render, set by whichever structural\n * edit is about to run.\n *\n * A structural edit changes how many blocks there are, so reading the\n * selection out of the DOM at render time \u2014 which is the old DOM, still\n * showing the old block count \u2014 yields indices that no longer exist and a\n * caret that silently vanishes. The operation knows where the caret lands\n * before it runs; this is where it says so.\n */\n let pending: Span | null = null\n /** The selection the link dialog was opened over, since focusing its input destroys it. */\n let linkSpan: Span | null = null\n /**\n * Everyone else with this description open, by user id.\n *\n * Kept only here. Presence is who is here *now*, so the moment it were\n * stored anywhere it would outlive the person \u2014 a viewer is remembered\n * until they stop saying otherwise, and no longer.\n */\n const viewers = new Map<string, Viewer>()\n let selfId = ''\n let announcedAt = 0\n let announcedIndex = -1\n let heartbeat: ReturnType<typeof setInterval> | null = null\n\n const fragment = doc.getXmlFragment('content')\n\n // ---- document model -----------------------------------------------------\n\n const typeOf = (element: Y.XmlElement): BlockType => {\n const value = element.getAttribute('type') as BlockType | undefined\n return value && BLOCK_TYPES.includes(value) ? value : 'p'\n }\n\n /**\n * The blocks, in order.\n *\n * A bare `Y.XmlText` at the top level is what the first version of this\n * editor wrote, and documents written by it are still stored. It is read as\n * a paragraph rather than migrated on load: a migration is a write, two tabs\n * opening the same old issue would each perform it, and the result is the\n * paragraph twice. It converts to a real block the first time somebody\n * changes its type, which is a deliberate act by one client.\n */\n const blocksOf = (): Block[] =>\n fragment.toArray().flatMap((node): Block[] => {\n if (node instanceof Y.XmlText) return [{ node, text: node, type: 'p', checked: false }]\n if (!(node instanceof Y.XmlElement)) return []\n const first = node.get(0)\n if (!(first instanceof Y.XmlText)) return []\n return [{ node, text: first, type: typeOf(node), checked: node.getAttribute('checked') === 'true' }]\n })\n\n /** Inserts a new empty block and answers its text run. Call inside a transaction. */\n function insertBlock(index: number, type: BlockType, checked = false): Y.XmlText {\n const element = new Y.XmlElement('block')\n element.setAttribute('type', type)\n if (checked) element.setAttribute('checked', 'true')\n fragment.insert(index, [element])\n const text = new Y.XmlText()\n element.insert(0, [text])\n return text\n }\n\n const ensureBlocks = () => {\n if (fragment.length === 0) doc.transact(() => void insertBlock(0, 'p'))\n }\n\n const modelOf = () =>\n blocksOf().map((block) => ({\n type: block.type,\n checked: block.checked,\n delta: block.text.toDelta() as Delta,\n }))\n\n // ---- DOM <-> model positions --------------------------------------------\n\n const elementAt = (index: number): HTMLElement | null =>\n container?.querySelector(`[data-index=\"${index}\"]`) ?? null\n\n /**\n * The element a block's characters actually live in.\n *\n * For most blocks that is the block itself. A checklist item also holds a\n * tick box, so its text sits in its own span \u2014 and the difference matters at\n * exactly one moment: an empty item has no text node to put the caret in, so\n * `pointIn`'s fallback has to name an element instead. Naming the `<li>` put\n * the caret *before* the tick box, and the first character typed into a\n * fresh checklist item landed outside the line, ahead of its own checkbox.\n *\n * Only that fallback uses this. Reading a block's text still walks the whole\n * block, so a character that does end up outside the line \u2014 a click landing\n * in the item's padding, say \u2014 is still read into the model and moved back\n * where it belongs by the next render, rather than quietly discarded.\n */\n const lineOf = (block: HTMLElement): HTMLElement =>\n (block.querySelector('[data-ui=\"flow-editor-line\"]') as HTMLElement | null) ?? block\n\n /**\n * The editable nodes of one block, in order.\n *\n * `contenteditable=\"false\"` subtrees are rejected outright \u2014 a checklist's\n * own tick box is chrome, not a character, and counting it shifted every\n * offset in the line by one. A trailing `<br>` is dropped for the same kind\n * of reason: it is the placeholder that gives an empty block a line box, not\n * something anybody typed.\n */\n function blockNodes(block: HTMLElement): Node[] {\n const walker = document.createTreeWalker(block, NodeFilter.SHOW_TEXT | NodeFilter.SHOW_ELEMENT, {\n acceptNode: (node: Node) => {\n if (node.nodeType !== Node.ELEMENT_NODE) return NodeFilter.FILTER_ACCEPT\n const element = node as HTMLElement\n if (element.getAttribute('contenteditable') === 'false') return NodeFilter.FILTER_REJECT\n return element.tagName === 'BR' ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n },\n })\n const nodes: Node[] = []\n let current = walker.nextNode()\n while (current) {\n nodes.push(current)\n current = walker.nextNode()\n }\n // Exactly one, never more: the last `<br>` is the placeholder the renderer\n // adds so an empty line has somewhere to put the caret, and every one\n // before it is a newline somebody typed. Dropping them all read\n // `\"cd build\\n\"` back as `\"cd build\"`, so the next character typed landed\n // on the end of the previous line.\n if (nodes.length && (nodes[nodes.length - 1] as HTMLElement).tagName === 'BR') nodes.pop()\n return nodes\n }\n\n const lengthOfNode = (node: Node): number =>\n node.nodeType === Node.TEXT_NODE ? (node.textContent ?? '').length : 1\n\n /**\n * A block's text as the model would spell it.\n *\n * The U+00A0 replacement is not cosmetic. contenteditable writes a\n * non-breaking space wherever a normal one would collapse -- a trailing\n * space above all -- so what the model read back after typing \"# \" was \"#\"\n * followed by U+00A0, which matches no input rule and is not the character\n * anybody typed. It reached the stored description and the search index\n * that way too. `white-space: pre-wrap` on the container (flow-editor.css)\n * is the other half: it lets a real space survive the round trip, so the\n * browser has no reason to reach for the substitute in the first place.\n */\n const domTextOf = (block: HTMLElement): string =>\n blockNodes(block)\n .map((node) => (node.nodeType === Node.TEXT_NODE ? (node.textContent ?? '') : '\\n'))\n .join('')\n .replace(/\\u00a0/g, ' ')\n\n function offsetIn(block: HTMLElement, node: Node, nodeOffset: number): number {\n let offset = 0\n for (const current of blockNodes(block)) {\n if (current === node) return offset + nodeOffset\n offset += lengthOfNode(current)\n }\n return offset\n }\n\n /** Where in the DOM a `<br>` sits, as a (parent, childIndex) point. */\n const beside = (node: Node, after: boolean): { node: Node; offset: number } => {\n const parent = node.parentNode as Node\n const at = Array.prototype.indexOf.call(parent.childNodes, node) as number\n return { node: parent, offset: at + (after ? 1 : 0) }\n }\n\n function pointIn(block: HTMLElement, offset: number): { node: Node; offset: number } {\n let remaining = offset\n let last: Node | null = null\n for (const current of blockNodes(block)) {\n const length = lengthOfNode(current)\n if (current.nodeType === Node.TEXT_NODE) {\n if (remaining <= length) return { node: current, offset: remaining }\n } else if (remaining === 0) return beside(current, false)\n remaining -= length\n last = current\n }\n if (last?.nodeType === Node.TEXT_NODE) return { node: last, offset: (last.textContent ?? '').length }\n // Past the last newline is the empty line after it, which is a position\n // between two `<br>`s rather than anywhere inside a text node.\n if (last) return beside(last, true)\n return { node: lineOf(block), offset: 0 }\n }\n\n function pointFrom(node: Node | null, offset: number): Point | null {\n if (!container || !node || !container.contains(node)) return null\n const resolved = descend(node, offset)\n const host =\n resolved.node.nodeType === Node.ELEMENT_NODE\n ? (resolved.node as HTMLElement)\n : resolved.node.parentElement\n const block = host?.closest('[data-index]') as HTMLElement | null\n if (!block) return null\n return {\n index: Number(block.getAttribute('data-index')),\n offset: offsetIn(block, resolved.node, resolved.offset),\n }\n }\n\n /** The current selection as model positions, always in document order. */\n function selectionSpan(): Span | null {\n const selection = document.getSelection()\n if (!selection?.rangeCount) return null\n const range = selection.getRangeAt(0)\n const start = pointFrom(range.startContainer, range.startOffset)\n const end = pointFrom(range.endContainer, range.endOffset)\n return start && end ? { start, end } : null\n }\n\n const isCollapsed = (span: Span) =>\n span.start.index === span.end.index && span.start.offset === span.end.offset\n\n const caretAt = (point: Point): Span => ({ start: point, end: point })\n\n function restoreSelection(span: Span) {\n const startBlock = elementAt(span.start.index)\n const endBlock = elementAt(span.end.index)\n if (!startBlock || !endBlock) return\n const from = pointIn(startBlock, span.start.offset)\n const to = pointIn(endBlock, span.end.offset)\n const range = document.createRange()\n range.setStart(from.node, from.offset)\n range.setEnd(to.node, to.offset)\n const selection = document.getSelection()\n selection?.removeAllRanges()\n selection?.addRange(range)\n }\n\n // ---- rendering ----------------------------------------------------------\n\n function render(keep?: Span | null) {\n if (!container) return\n const span = keep === undefined ? selectionSpan() : keep\n container.innerHTML = documentHtml(modelOf(), props.lang, others())\n if (span) restoreSelection(span)\n syncToolbar()\n renderPresence()\n }\n\n /**\n * The toolbar reports the block under the caret and which marks it carries.\n *\n * Without it the type control keeps showing whatever was last chosen and the\n * mark buttons never look pressed, so the toolbar describes the past rather\n * than the selection \u2014 which is worse than having no toolbar state at all,\n * because it reads as authoritative.\n */\n function syncToolbar() {\n if (!shell) return\n const span = selectionSpan()\n const block = span ? blocksOf()[span.start.index] : undefined\n const select = shell.querySelector('[data-flow-editor-block]') as HTMLSelectElement | null\n if (select && block) select.value = LIST_TYPES.includes(block.type) ? 'p' : block.type\n for (const button of Array.from(shell.querySelectorAll('[data-flow-editor-mark]')) as HTMLElement[]) {\n const name = button.getAttribute('data-flow-editor-mark') ?? ''\n const active = LIST_TYPES.includes(name as BlockType)\n ? block?.type === name\n : span && !isCollapsed(span) && spanHasMark(span, name as MarkName)\n button.setAttribute('aria-pressed', String(active === true))\n }\n }\n\n // ---- presence -----------------------------------------------------------\n\n /** Everyone but you, and only while they are still saying they are here. */\n function others(): Array<{ id: string; name: string; index: number }> {\n const now = Date.now()\n for (const [id, viewer] of viewers) if (now - viewer.seenAt > VIEWER_TTL) viewers.delete(id)\n return [...viewers.values()]\n .filter((viewer) => viewer.id !== selfId)\n .map(({ id, name, index }) => ({ id, name, index }))\n }\n\n /** What the room looks like, so a frame that changes nothing costs nothing. */\n const roomSignature = (): string =>\n others()\n .map((viewer) => `${viewer.id}@${viewer.index}`)\n .sort()\n .join(',')\n\n function renderPresence() {\n const slot = shell?.querySelector('[data-flow-editor-presence]')\n if (slot) slot.innerHTML = presenceHtml(others(), props.lang)\n }\n\n /**\n * Says where this client's caret is \u2014 or, with `gone`, that it is leaving.\n *\n * The name is not sent. The route stamps it from the session, because a\n * frame goes to everyone else in the document and a client that could name\n * itself could sit in the room under somebody else's name.\n */\n async function announce(index: number, gone = false) {\n announcedAt = Date.now()\n announcedIndex = gone ? -1 : index\n const answer = await fetch(`${base}/presence`, {\n method: 'POST',\n credentials: 'same-origin',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ index, gone }),\n })\n .then((response) => (response.ok ? (response.json() as Promise<{ id?: string }>) : null))\n .catch(() => null)\n if (answer?.id) selfId = answer.id\n }\n\n /**\n * Announce when the caret changes block, and no more often than that.\n *\n * A caret moving inside a paragraph tells nobody anything the marker on that\n * paragraph did not already say, and these frames ride the same topic as the\n * edits \u2014 which is bounded by how often the document flattens, not by how\n * often anybody types.\n */\n function announceCaret() {\n const span = selectionSpan()\n if (!span) return\n const index = span.start.index\n if (index === announcedIndex && Date.now() - announcedAt < HEARTBEAT_MS) return\n if (Date.now() - announcedAt < ANNOUNCE_EVERY_MS) return\n void announce(index)\n }\n\n function receivePresence(frame: { id?: string; name?: string; index?: number; gone?: boolean }) {\n if (!frame.id) return\n const before = roomSignature()\n const known = viewers.has(frame.id)\n if (frame.gone) viewers.delete(frame.id)\n else\n viewers.set(frame.id, {\n id: frame.id,\n name: String(frame.name ?? frame.id),\n index: Number(frame.index) || 0,\n // Stamped on arrival rather than taken from the frame: freshness is\n // measured against this clock, and the sender's is a different one.\n seenAt: Date.now(),\n })\n // Somebody new only learns who is already here when they next speak, and\n // an idle room is silent. Answering a stranger is what makes the room\n // visible to a joiner within a beat instead of within a heartbeat.\n if (!known && !frame.gone && frame.id !== selfId && Date.now() - announcedAt > ANNOUNCE_EVERY_MS)\n void announce(selectionSpan()?.start.index ?? 0)\n if (roomSignature() !== before) render()\n }\n\n // ---- structural edits ---------------------------------------------------\n\n /** Every structural edit runs through here, so none of them can forget the caret. */\n function structural(caret: Span, run: () => void) {\n pending = caret\n doc.transact(run)\n }\n\n function setBlockType(index: number, type: BlockType) {\n const block = blocksOf()[index]\n if (!block || block.type === type) return\n if (block.node instanceof Y.XmlText) {\n // A legacy top-level run has nowhere to put an attribute, so it is\n // replaced by a real block carrying the same content.\n const delta = block.text.toDelta() as Delta\n fragment.delete(index, 1)\n const text = insertBlock(index, type)\n if (delta.length) text.applyDelta(delta as unknown[])\n return\n }\n block.node.setAttribute('type', type)\n if (type !== 'check') block.node.removeAttribute('checked')\n }\n\n function applyBlockType(type: BlockType) {\n const span = selectionSpan()\n if (!span) return\n const blocks = blocksOf()\n // Asking for the type a block already has means asking to leave it \u2014 the\n // way the same button both makes a list and unmakes one.\n const all = blocks.slice(span.start.index, span.end.index + 1).every((block) => block.type === type)\n const target = all ? 'p' : type\n structural(span, () => {\n for (let index = span.end.index; index >= span.start.index; index--) setBlockType(index, target)\n })\n }\n\n function splitBlock(at: Point) {\n const blocks = blocksOf()\n const block = blocks[at.index]\n if (!block) return\n const delta = block.text.toDelta() as Delta\n const length = plainLength(delta)\n // Enter on an empty list item leaves the list rather than extending it \u2014\n // otherwise there is no way out of one except deleting it.\n if (LIST_TYPES.includes(block.type) && length === 0) {\n structural(caretAt({ index: at.index, offset: 0 }), () => setBlockType(at.index, 'p'))\n return\n }\n const tail = sliceDelta(delta, at.offset)\n const nextType = CONTINUES.has(block.type) ? block.type : 'p'\n structural(caretAt({ index: at.index + 1, offset: 0 }), () => {\n if (at.offset < length) block.text.delete(at.offset, length - at.offset)\n const text = insertBlock(at.index + 1, nextType)\n if (tail.length) text.applyDelta(tail as unknown[])\n })\n }\n\n function mergeBackward(index: number) {\n if (index <= 0) return\n const blocks = blocksOf()\n const previous = blocks[index - 1]\n const current = blocks[index]\n if (!previous || !current) return\n const at = plainLength(previous.text.toDelta() as Delta)\n const tail = current.text.toDelta() as Delta\n structural(caretAt({ index: index - 1, offset: at }), () => {\n if (tail.length) previous.text.applyDelta([{ retain: at }, ...tail] as unknown[])\n fragment.delete(index, 1)\n })\n }\n\n function mergeForward(index: number) {\n const blocks = blocksOf()\n if (index + 1 >= blocks.length) return\n mergeBackward(index + 1)\n }\n\n /** Removes everything between the two ends and answers where the caret lands. */\n function deleteSpan(span: Span): Point {\n const blocks = blocksOf()\n const first = blocks[span.start.index]\n if (!first) return span.start\n const caret = { index: span.start.index, offset: span.start.offset }\n if (span.start.index === span.end.index) {\n structural(caretAt(caret), () =>\n first.text.delete(span.start.offset, span.end.offset - span.start.offset),\n )\n return caret\n }\n const last = blocks[span.end.index]\n const tail = last ? sliceDelta(last.text.toDelta() as Delta, span.end.offset) : []\n const length = plainLength(first.text.toDelta() as Delta)\n structural(caretAt(caret), () => {\n if (span.start.offset < length) first.text.delete(span.start.offset, length - span.start.offset)\n if (tail.length) first.text.applyDelta([{ retain: span.start.offset }, ...tail] as unknown[])\n fragment.delete(span.start.index + 1, span.end.index - span.start.index)\n })\n return caret\n }\n\n function insertTextAt(at: Point, value: string) {\n const block = blocksOf()[at.index]\n if (!block || !value) return\n const caret = { index: at.index, offset: at.offset + value.length }\n structural(caretAt(caret), () => block.text.insert(at.offset, value, attributesAt(block.text, at.offset)))\n }\n\n /** Sets a checklist item's tick without regard to what it was. Call inside a transaction. */\n function checkedOn(index: number, checked: boolean) {\n const block = blocksOf()[index]\n if (!block || block.node instanceof Y.XmlText) return\n if (checked) block.node.setAttribute('checked', 'true')\n else block.node.removeAttribute('checked')\n }\n\n function toggleChecked(index: number) {\n const block = blocksOf()[index]\n if (!block || block.node instanceof Y.XmlText || block.type !== 'check') return\n const next = block.checked ? null : 'true'\n structural(selectionSpan() ?? caretAt({ index, offset: 0 }), () => {\n if (next) (block.node as Y.XmlElement).setAttribute('checked', next)\n else (block.node as Y.XmlElement).removeAttribute('checked')\n })\n }\n\n // ---- marks --------------------------------------------------------------\n\n /** Runs `visit` over each block's slice of the selection. */\n function overSpan(span: Span, visit: (text: Y.XmlText, from: number, to: number) => void) {\n const blocks = blocksOf()\n for (let index = span.start.index; index <= span.end.index; index++) {\n const block = blocks[index]\n if (!block) continue\n const length = plainLength(block.text.toDelta() as Delta)\n const from = index === span.start.index ? span.start.offset : 0\n const to = index === span.end.index ? Math.min(span.end.offset, length) : length\n if (to > from) visit(block.text, from, to)\n }\n }\n\n function spanHasMark(span: Span, name: MarkName): boolean {\n let seen = false\n let all = true\n overSpan(span, (text, from, to) => {\n let cursor = 0\n for (const op of text.toDelta() as Delta) {\n const end = cursor + op.insert.length\n if (end > from && cursor < to) {\n seen = true\n if (!op.attributes?.[name]) all = false\n }\n cursor = end\n }\n })\n return seen && all\n }\n\n function toggleMark(name: MarkName) {\n const span = selectionSpan()\n if (!span || isCollapsed(span)) return\n const on = spanHasMark(span, name)\n pending = span\n doc.transact(() => {\n overSpan(span, (text, from, to) => text.format(from, to - from, { [name]: on ? null : true }))\n })\n }\n\n function applyLink(href: string | null) {\n const span = linkSpan\n if (!span || isCollapsed(span)) return\n pending = span\n doc.transact(() => {\n overSpan(span, (text, from, to) => text.format(from, to - from, { link: href }))\n })\n }\n\n // ---- input --------------------------------------------------------------\n\n function applyInputRule(index: number): boolean {\n const block = blocksOf()[index]\n if (!block || block.type === 'code') return false\n const text = plainTextOf(block.text)\n const rule = INPUT_RULES.find(([pattern]) => pattern.test(text))\n if (!rule) return false\n structural(caretAt({ index, offset: 0 }), () => {\n block.text.delete(0, text.length)\n setBlockType(index, rule[1])\n })\n return true\n }\n\n /**\n * Turns a completed Markdown span into the mark it spells.\n *\n * The delimiters are removed from the end first, so the offsets computed\n * against the original text still hold when the opening one goes. What is\n * left keeps whatever marks it already carried \u2014 writing `**` around a word\n * that is already a link should bold the link, not replace it.\n */\n function applyInlineRule(index: number, caret: number): boolean {\n const block = blocksOf()[index]\n // Not in a code block: the delimiters there are characters.\n if (!block || block.type === 'code') return false\n const upToCaret = plainTextOf(block.text).slice(0, caret)\n\n const link = LINK_RULE.exec(upToCaret)\n if (link) {\n const whole = link[0] as string\n const label = link[1] as string\n const href = link[2] as string\n const start = caret - whole.length\n structural(caretAt({ index, offset: start + label.length }), () => {\n block.text.delete(start + 1 + label.length, whole.length - 1 - label.length)\n block.text.delete(start, 1)\n block.text.format(start, label.length, { link: href })\n })\n return true\n }\n\n for (const rule of INLINE_RULES) {\n const match = rule.pattern.exec(upToCaret)\n if (!match) continue\n const whole = match[0] as string\n const inner = match[1] as string\n const start = caret - whole.length\n structural(caretAt({ index, offset: start + inner.length }), () => {\n block.text.delete(start + rule.open + inner.length, rule.open)\n block.text.delete(start, rule.open)\n block.text.format(start, inner.length, { [rule.mark]: true })\n })\n return true\n }\n return false\n }\n\n /**\n * Within-block typing, diffed rather than intercepted.\n *\n * Everything structural is handled in `onBeforeInput` before the browser\n * touches the DOM; what reaches here is a character landing inside one\n * block, which is exactly the case where letting contenteditable do its own\n * work is what keeps an IME's composition intact. If the DOM has more or\n * fewer blocks than the model, the browser did something structural anyway\n * and the model wins \u2014 re-rendering discards it rather than trying to\n * reverse-engineer it.\n */\n function applyLocalTextChange() {\n if (!container || composing) return\n const blocks = blocksOf()\n if (container.querySelectorAll('[data-index]').length !== blocks.length) {\n render(null)\n return\n }\n const span = selectionSpan()\n if (!span) return\n const element = elementAt(span.start.index)\n const block = blocks[span.start.index]\n if (!element || !block) {\n render(null)\n return\n }\n const before = plainTextOf(block.text)\n const after = domTextOf(element)\n if (before === after) return\n const { start, deletedLength, inserted } = diffRange(before, after)\n doc.transact(() => {\n if (deletedLength) block.text.delete(start, deletedLength)\n if (inserted) block.text.insert(start, inserted, attributesAt(block.text, start))\n }, LOCAL_TYPING)\n // Block rules win: they only fire on a line that is still nothing but its\n // prefix, so the two can never both be right about the same keystroke.\n if (!applyInputRule(span.start.index)) applyInlineRule(span.start.index, start + inserted.length)\n }\n\n function onBeforeInput(event: InputEvent) {\n if (composing || !container) return\n const span = selectionSpan()\n if (!span) return\n const type = event.inputType\n const collapsed = isCollapsed(span)\n const multi = span.start.index !== span.end.index\n\n if (type === 'insertParagraph' || type === 'insertLineBreak') {\n event.preventDefault()\n const at = collapsed ? span.start : deleteSpan(span)\n const block = blocksOf()[at.index]\n // A code block is where a newline is a character rather than a new\n // block \u2014 that is most of what makes it a code block. Which leaves the\n // question of how anyone gets out of one, since Enter no longer means\n // \"next block\" and a code block at the end of the document has nothing\n // after it to click into. Enter on an already-blank last line is the\n // way out, the same gesture every editor uses for the same problem.\n if (block?.type === 'code') {\n const length = plainLength(block.text.toDelta() as Delta)\n if (at.offset === length && plainTextOf(block.text).endsWith('\\n'))\n structural(caretAt({ index: at.index + 1, offset: 0 }), () => {\n block.text.delete(length - 1, 1)\n insertBlock(at.index + 1, 'p')\n })\n else insertTextAt(at, '\\n')\n } else splitBlock(at)\n return\n }\n\n if (type.startsWith('delete')) {\n if (!collapsed) {\n event.preventDefault()\n deleteSpan(span)\n return\n }\n const block = blocksOf()[span.start.index]\n if (!block) return\n const length = plainLength(block.text.toDelta() as Delta)\n if (type.includes('Backward') && span.start.offset === 0) {\n event.preventDefault()\n // Backspace at the head of a heading or a list item removes the *kind*\n // first and joins the line above only on a second press. Joining\n // straight away is how a heading silently disappears into the\n // paragraph before it.\n if (block.type !== 'p')\n structural(caretAt({ index: span.start.index, offset: 0 }), () =>\n setBlockType(span.start.index, 'p'),\n )\n else mergeBackward(span.start.index)\n return\n }\n if (type.includes('Forward') && span.start.offset === length) {\n event.preventDefault()\n mergeForward(span.start.index)\n }\n return\n }\n\n if (!multi) return\n // Anything else spanning two blocks would leave contenteditable to do its\n // own structural surgery, which the model cannot read back. The selection\n // is removed here and the typed character, if there is one, re-inserted.\n event.preventDefault()\n const at = deleteSpan(span)\n if (type === 'insertText' && typeof event.data === 'string') insertTextAt(at, event.data)\n }\n\n /**\n * Paste arrives as plain text and lands as blocks.\n *\n * Keeping the source's own HTML would mean trusting markup from wherever the\n * clipboard came from, which is a different and much larger problem than\n * this editor has; every line becomes a block of the current kind instead,\n * so pasting a list into a list stays a list.\n */\n function onPaste(event: ClipboardEvent) {\n event.preventDefault()\n const value = event.clipboardData?.getData('text/plain') ?? ''\n const span = selectionSpan()\n if (!value || !span) return\n const at = isCollapsed(span) ? span.start : deleteSpan(span)\n const block = blocksOf()[at.index]\n if (!block) return\n // Into a code block the clipboard is characters, delimiters and all \u2014\n // pasting a snippet is the one time nobody wants it read as Markdown.\n if (block.type === 'code') {\n insertTextAt(at, value)\n return\n }\n const parsed = parseMarkdown(value)\n if (!parsed.length) return\n\n const delta = block.text.toDelta() as Delta\n const length = plainLength(delta)\n const tail = sliceDelta(delta, at.offset)\n const first = parsed[0] as MarkdownBlock\n // An empty block takes the shape of what lands in it \u2014 pasting a heading\n // into a blank line should give a heading, not a heading's words. A block\n // with something in it keeps its own kind and takes only the words.\n const adopt = length === 0 && first.type !== 'p'\n const lastBlock = parsed[parsed.length - 1] as MarkdownBlock\n const caret = {\n index: at.index + parsed.length - 1,\n offset: parsed.length === 1 ? at.offset + plainLength(first.delta) : plainLength(lastBlock.delta),\n }\n\n structural(caretAt(caret), () => {\n if (at.offset < length) block.text.delete(at.offset, length - at.offset)\n if (first.delta.length) block.text.applyDelta([{ retain: at.offset }, ...first.delta] as unknown[])\n if (adopt) {\n setBlockType(at.index, first.type)\n if (first.checked) checkedOn(at.index, true)\n }\n for (let index = 1; index < parsed.length; index++) {\n const source = parsed[index] as MarkdownBlock\n const text = insertBlock(at.index + index, source.type, source.checked)\n if (source.delta.length) text.applyDelta(source.delta as unknown[])\n if (index === parsed.length - 1 && tail.length)\n text.applyDelta([{ retain: plainLength(source.delta) }, ...tail] as unknown[])\n }\n // One block in, so the text after the caret never left its own block.\n if (parsed.length === 1 && tail.length)\n block.text.applyDelta([{ retain: at.offset + plainLength(first.delta) }, ...tail] as unknown[])\n })\n }\n\n // ---- transport ----------------------------------------------------------\n\n async function pushLocalUpdate(update: Uint8Array) {\n await fetch(`${base}/push`, {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify({ update: bytesToBase64(update) }),\n }).catch(() => {})\n }\n\n /**\n * A topic is scoped to one flatten generation (see sync.ts's rollGeneration) \u2014\n * once it rolls over, the old topic 404s forever, and EventSource's native\n * reconnect just retries the same dead URL. Re-fetching /content gets both\n * the current topic and a snapshot to catch up on anything missed while\n * disconnected; re-applying already-known updates through it is a no-op,\n * Yjs merges are idempotent.\n */\n async function resync() {\n const response = await fetch(`${base}/content`).catch(() => null)\n if (!response?.ok) return\n const { snapshot, topic, viewerId } = (await response.json()) as {\n snapshot: string\n topic: string\n viewerId?: string | null\n }\n if (viewerId) selfId = viewerId\n Y.applyUpdate(doc, base64ToBytes(snapshot), REMOTE)\n connectLive(topic)\n }\n\n function connectLive(topic: string) {\n source?.close()\n const es = new EventSource(`${base}/live?topic=${encodeURIComponent(topic)}`)\n es.onmessage = (event) => {\n try {\n const payload = JSON.parse(event.data) as {\n update?: string\n presence?: Record<string, unknown>\n }\n if (payload.presence) receivePresence(payload.presence)\n else if (payload.update) Y.applyUpdate(doc, base64ToBytes(payload.update), REMOTE)\n } catch {\n // A malformed frame is skipped rather than tearing down the\n // connection \u2014 the CRDT stays correct either way.\n }\n }\n es.onerror = () => {\n if (es.readyState === EventSource.CLOSED) setTimeout(() => void resync(), 500)\n }\n source = es\n }\n\n // ---- mount --------------------------------------------------------------\n\n const onSelectionChange = () => {\n syncToolbar()\n announceCaret()\n }\n\n function wireToolbar(root: HTMLElement) {\n for (const button of Array.from(root.querySelectorAll('[data-flow-editor-mark]')) as HTMLElement[]) {\n const name = button.getAttribute('data-flow-editor-mark') ?? ''\n button.addEventListener('mousedown', (event) => event.preventDefault())\n button.addEventListener('click', () => {\n if (LIST_TYPES.includes(name as BlockType)) applyBlockType(name as BlockType)\n else if (name === 'link') openLinkDialog()\n else toggleMark(name as MarkName)\n })\n }\n const select = root.querySelector('[data-flow-editor-block]') as HTMLSelectElement | null\n select?.addEventListener('change', () => {\n const value = select.value as BlockType\n const span = selectionSpan()\n if (!span) return\n structural(span, () => {\n for (let index = span.end.index; index >= span.start.index; index--) setBlockType(index, value)\n })\n })\n }\n\n const linkDialog = () => shell?.querySelector('[data-flow-editor-link-dialog]') as HTMLDialogElement | null\n\n function openLinkDialog() {\n const span = selectionSpan()\n if (!span || isCollapsed(span)) return\n linkSpan = span\n const dialog = linkDialog()\n const input = shell?.querySelector('[data-flow-editor-link-input]') as HTMLInputElement | null\n const block = blocksOf()[span.start.index]\n const existing = block\n ? (sliceDelta(block.text.toDelta() as Delta, span.start.offset)[0]?.attributes?.link ?? '')\n : ''\n if (input) input.value = existing\n dialog?.showModal()\n input?.focus()\n }\n\n function wireLinkDialog(root: HTMLElement) {\n const dialog = root.querySelector('[data-flow-editor-link-dialog]') as HTMLDialogElement | null\n const input = root.querySelector('[data-flow-editor-link-input]') as HTMLInputElement | null\n root.querySelector('[data-flow-editor-link-cancel]')?.addEventListener('click', () => {\n dialog?.close()\n })\n root.querySelector('[data-flow-editor-link-remove]')?.addEventListener('click', () => {\n applyLink(null)\n dialog?.close()\n })\n root.querySelector('[data-flow-editor-link-apply]')?.addEventListener('click', () => {\n applyLink(input?.value?.trim() || null)\n dialog?.close()\n })\n }\n\n async function mount(el: HTMLElement) {\n container = el\n shell = (el.closest('[data-ui=\"flow-editor\"]') as HTMLElement | null) ?? el.parentElement\n el.addEventListener('compositionstart', () => {\n composing = true\n composedAt = selectionSpan()?.start ?? null\n })\n el.addEventListener('compositionend', (event) => {\n composing = false\n const owed = renderOwed\n renderOwed = undefined\n const composed = (event as CompositionEvent).data ?? ''\n if (owed === undefined) {\n // Nothing arrived while they typed, so the DOM is still the truth and\n // the ordinary diff reads it.\n applyLocalTextChange()\n composedAt = null\n return\n }\n // Something did arrive, and the DOM has been holding a stale copy of the\n // document ever since. Diffing it now would read the remote edit as a\n // deletion, so the word is taken from the event that carries it and put\n // back where the composition began, and the document is redrawn from the\n // model rather than the other way round.\n const block = composedAt ? blocksOf()[composedAt.index] : undefined\n if (block && composed) {\n const offset = Math.min(composedAt!.offset, plainLength(block.text.toDelta() as Delta))\n const caret = { index: composedAt!.index, offset: offset + composed.length }\n structural(caretAt(caret), () =>\n block.text.insert(offset, composed, attributesAt(block.text, offset)),\n )\n } else render(owed ?? undefined)\n composedAt = null\n })\n el.addEventListener('beforeinput', (event) => onBeforeInput(event as InputEvent))\n el.addEventListener('input', () => {\n if (!composing) applyLocalTextChange()\n })\n el.addEventListener('paste', (event) => onPaste(event as ClipboardEvent))\n el.addEventListener('click', (event) => {\n const target = event.target as HTMLElement | null\n const box = target?.closest('[data-ui=\"flow-editor-check\"]')\n const block = box?.closest('[data-index]')\n if (block) toggleChecked(Number(block.getAttribute('data-index')))\n })\n document.addEventListener('selectionchange', onSelectionChange)\n if (shell) {\n wireToolbar(shell)\n wireLinkDialog(shell)\n }\n\n doc.on('update', (update: Uint8Array, origin: unknown) => {\n // The incremental update Yjs already computed for this change, not a\n // fresh Y.encodeStateAsUpdate(doc) full re-encode \u2014 sending the whole\n // document's state on every keystroke was the actual source of an early\n // formatting-loss bug: applying a full-state update on top of the\n // server's own incrementally-built state doesn't round-trip marks the\n // same way normal incremental merges do.\n if (origin !== REMOTE) void pushLocalUpdate(update)\n if (origin !== LOCAL_TYPING) {\n const keep = pending\n pending = null\n // Not while somebody is mid-word. The change is already in the\n // document; drawing it can wait the second it takes them to finish.\n if (composing) renderOwed = keep\n else render(keep ?? undefined)\n }\n })\n\n const response = await fetch(`${base}/content`)\n const { snapshot, topic, viewerId } = (await response.json()) as {\n snapshot: string\n topic: string\n viewerId?: string | null\n }\n if (viewerId) selfId = viewerId\n Y.applyUpdate(doc, base64ToBytes(snapshot), REMOTE)\n ensureBlocks()\n render(null)\n connectLive(topic)\n\n void announce(0)\n // Only while the tab is actually being looked at: a background tab that\n // kept announcing would hold its author in the room for as long as the\n // browser stayed open, and would keep writing frames onto a topic that\n // only a flatten ever ends.\n heartbeat = setInterval(() => {\n if (document.visibilityState === 'visible') void announce(selectionSpan()?.start.index ?? 0)\n }, HEARTBEAT_MS)\n\n window.addEventListener('pagehide', () => {\n navigator.sendBeacon?.(`${base}/leave`)\n // A Blob, because sendBeacon posts text/plain otherwise and the route\n // reads JSON. Beacons survive the page going away; a fetch does not.\n navigator.sendBeacon?.(\n `${base}/presence`,\n new Blob([JSON.stringify({ index: 0, gone: true })], { type: 'application/json' }),\n )\n })\n }\n\n return {\n view: () => liveDocShell({ containerId, lang: props.lang }) as TemplateResult,\n dispose() {\n source?.close()\n if (heartbeat) clearInterval(heartbeat)\n if (typeof document !== 'undefined') document.removeEventListener('selectionchange', onSelectionChange)\n },\n mount,\n containerId,\n }\n}\n\n/**\n * The island the shell is mounted as.\n *\n * A separate browser-only entry file used to hold these six lines, because the\n * view runtime resolves to a URL rather than a package and a `.ts` file could\n * not say so without failing the zero-dep audit. It is imported as a type-only\n * runtime here instead, which is what `relation-select-view.tsx` next door\n * already does \u2014 so the entry, and the `client-src` directory it lived in, are\n * gone.\n *\n * `IslandController` has no \"mounted\" hook, so the DOM mount is queued for\n * after the view has rendered and finds its container by id.\n */\nexport const liveDoc = (props: IslandProps): IslandController => {\n const controller = createLiveDocView(props as unknown as LiveDocProps)\n queueMicrotask(() => {\n const el = document.getElementById(controller.containerId)\n if (el) void controller.mount(el)\n })\n return { view: controller.view, dispose: controller.dispose }\n}\n"],
5
+ "mappings": ";AAoBO,IAAMA,EAAS,IAAM,IAAI,IAUnBC,GAAOC,GAAK,CACvB,IAAMC,EAAIH,EAAO,EACjB,OAAAE,EAAE,QAAQ,CAACE,EAAGC,IAAM,CAAEF,EAAE,IAAIE,EAAGD,CAAC,CAAE,CAAC,EAC5BD,CACT,EAkBaG,GAAiB,CAACC,EAAKC,EAAKC,IAAY,CACnD,IAAIC,EAAMH,EAAI,IAAIC,CAAG,EACrB,OAAIE,IAAQ,QACVH,EAAI,IAAIC,EAAKE,EAAMD,EAAQ,CAAC,EAEvBC,CACT,EAaaH,GAAM,CAACL,EAAGS,IAAM,CAC3B,IAAMC,EAAM,CAAC,EACb,OAAW,CAACJ,EAAKK,CAAK,IAAKX,EACzBU,EAAI,KAAKD,EAAEE,EAAOL,CAAG,CAAC,EAExB,OAAOI,CACT,EAcaE,GAAM,CAACZ,EAAGS,IAAM,CAC3B,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5B,EAAc,GAAG,MAAM,OAAS,CAAC,CAC7F,EAAG9F,EAAY,EAEf,OAAO,iBAAiB,WAAY,IAAM,CACxC,UAAU,aAAa,GAAG8C,CAAI,QAAQ,EAGtC,UAAU,aACR,GAAGA,CAAI,YACP,IAAI,KAAK,CAAC,KAAK,UAAU,CAAE,MAAO,EAAG,KAAM,EAAK,CAAC,CAAC,EAAG,CAAE,KAAM,kBAAmB,CAAC,CACnF,CACF,CAAC,CACH,CAEA,MAAO,CACL,KAAM,IAAM6J,GAAa,CAAE,YAAA5J,EAAa,KAAMH,EAAM,IAAK,CAAC,EAC1D,SAAU,CACRW,GAAQ,MAAM,EACVO,IAAW,cAAcA,EAAS,EAClC,OAAO,SAAa,KAAa,SAAS,oBAAoB,kBAAmB+H,EAAiB,CACxG,EACA,MAAAS,GACA,YAAAvJ,CACF,CACF,CAeO,IAAM6J,GAAWhK,GAAyC,CAC/D,IAAMiK,EAAalK,GAAkBC,CAAgC,EACrE,sBAAe,IAAM,CACnB,IAAM2J,EAAK,SAAS,eAAeM,EAAW,WAAW,EACrDN,GAASM,EAAW,MAAMN,CAAE,CAClC,CAAC,EACM,CAAE,KAAMM,EAAW,KAAM,QAASA,EAAW,OAAQ,CAC9D",
6
+ "names": ["create", "copy", "m", "r", "v", "k", "setIfUndefined", "map", "key", "createT", "set", "f", "res", "value", "any", "create", "last", "arr", "appendTo", "dest", "src", "i", "from", "every", "arr", "f", "some", "unfold", "len", "f", "array", "i", "isArray", "ObservableV2", "create", "name", "f", "setIfUndefined", "_f", "args", "observers", "from", "floor", "abs", "min", "a", "b", "max", "isNaN", "isNegativeZero", "n", "MAX_SAFE_INTEGER", "MIN_SAFE_INTEGER", "LOWEST_INT32", "isInteger", "num", "floor", "isNaN", "parseInt", "fromCharCode", "fromCodePoint", "MAX_UTF16_CHARACTER", "toLowerCase", "s", "trimLeftRegex", "trimLeft", "fromCamelCaseRegex", "fromCamelCase", "separator", "match", "_encodeUtf8Polyfill", "str", "encodedString", "len", "buf", "i", "utf8TextEncoder", "_encodeUtf8Native", "encodeUtf8", "utf8TextDecoder", "repeat", "source", "n", "unfold", "Encoder", "createEncoder", "length", "encoder", "len", "i", "toUint8Array", "encoder", "uint8arr", "length", "curPos", "i", "d", "verifyLen", "len", "bufferLen", "max", "write", "num", "writeUint8", "write", "writeVarUint", "encoder", "num", "write", "floor", "writeVarInt", "isNegative", "isNegativeZero", "_strBuffer", "_maxStrBSize", "_writeVarStringNative", "str", "written", "utf8TextEncoder", "i", "writeVarUint8Array", "encodeUtf8", "_writeVarStringPolyfill", "encodedString", "len", "writeVarString", "writeUint8Array", "encoder", "uint8Array", "bufferLen", "cpos", "leftCopyLen", "min", "rightCopyLen", "max", "writeVarUint8Array", "writeVarUint", "writeOnDataView", "len", "verifyLen", "dview", "writeFloat32", "num", "writeFloat64", "writeBigInt64", "floatTestBed", "isFloat32", "num", "writeAny", "encoder", "data", "write", "writeVarString", "isInteger", "abs", "writeVarInt", "writeFloat32", "writeFloat64", "writeBigInt64", "isArray", "writeVarUint", "i", "writeVarUint8Array", "keys", "key", "RleEncoder", "Encoder", "writer", "v", "flushUintOptRleEncoder", "encoder", "writeVarInt", "writeVarUint", "UintOptRleEncoder", "Encoder", "v", "toUint8Array", "flushIntDiffOptRleEncoder", "encoder", "encodedDiff", "writeVarInt", "writeVarUint", "IntDiffOptRleEncoder", "Encoder", "v", "toUint8Array", "StringEncoder", "UintOptRleEncoder", "string", "writeVarString", "writeUint8Array", "create", "s", "methodUnimplemented", "unexpectedCase", "errorUnexpectedEndOfArray", "create", "errorIntegerOutOfRange", "Decoder", "uint8Array", "createDecoder", "hasContent", "decoder", "readUint8Array", "decoder", "len", "view", "readVarUint8Array", "readVarUint", "readUint8", "decoder", "readVarUint", "decoder", "num", "mult", "len", "r", "MAX_SAFE_INTEGER", "errorIntegerOutOfRange", "errorUnexpectedEndOfArray", "readVarInt", "sign", "_readVarStringPolyfill", "decoder", "remainingLen", "readVarUint", "encodedString", "readUint8", "nextLen", "bytes", "_readVarStringNative", "utf8TextDecoder", "readVarUint8Array", "readVarString", "readFromDataView", "decoder", "len", "dv", "readFloat32", "readFloat64", "readBigInt64", "readAnyLookupTable", "decoder", "readVarInt", "readFloat32", "readFloat64", "readBigInt64", "readVarString", "len", "readVarUint", "obj", "i", "key", "readAny", "arr", "readVarUint8Array", "readUint8", "RleDecoder", "Decoder", "uint8Array", "reader", "hasContent", "UintOptRleDecoder", "Decoder", "uint8Array", "readVarInt", "isNegative", "isNegativeZero", "readVarUint", "IntDiffOptRleDecoder", "Decoder", "uint8Array", "diff", "readVarInt", "hasCount", "floor", "readVarUint", "StringDecoder", "UintOptRleDecoder", "readVarString", "end", "res", "subtle", "getRandomValues", "uint32", "getRandomValues", "uuidv4Template", "uuidv4", "c", "uint32", "getUnixTime", "create", "f", "all", "undefinedToNull", "v", "VarStoragePolyfill", "key", "newValue", "_localStorage", "usePolyfill", "varStorage", "EqualityTraitSymbol", "equals", "a", "b", "isObject", "o", "assign", "keys", "forEach", "obj", "f", "key", "size", "obj", "keys", "isEmpty", "obj", "_k", "every", "f", "key", "hasProperty", "equalFlat", "a", "b", "size", "val", "equals", "freeze", "deepFreeze", "o", "c", "callAll", "fs", "args", "i", "equalityDeep", "a", "b", "EqualityTraitSymbol", "i", "value", "key", "size", "hasProperty", "isOneOf", "options", "isNode", "isMac", "params", "args", "computeParams", "isNode", "create", "pargs", "currParamName", "i", "parg", "kv", "key", "value", "fromCamelCase", "hasParam", "name", "getVariable", "name", "isNode", "undefinedToNull", "varStorage", "hasConf", "name", "hasParam", "getVariable", "production", "forceColor", "isNode", "isOneOf", "supportsColor", "createUint8ArrayFromLen", "len", "copyUint8Array", "uint8Array", "newBuf", "createUint8ArrayFromLen", "Pair", "left", "right", "create", "bool", "gen", "int53", "min", "max", "floor", "int32", "gen", "min", "max", "floor", "int31", "gen", "min", "max", "int32", "letter", "gen", "fromCharCode", "int31", "word", "minLen", "maxLen", "len", "str", "i", "oneOf", "gen", "array", "int31", "schemaSymbol", "ValidationError", "path", "expected", "has", "message", "s", "i", "repeat", "shapeExtends", "a", "b", "EqualityTraitSymbol", "equals", "isArray", "every", "aitem", "some", "bitem", "isObject", "akey", "Schema", "other", "equalityDeep", "o", "_o", "_err", "methodUnimplemented", "$union", "$null", "$Optional", "assert", "$ConstructedBy", "c", "check", "err", "$constructedBy", "$$constructedBy", "$Custom", "$custom", "$$custom", "$Literal", "literals", "$literal", "$$literal", "_regexEscape", "str", "_schemaStringTemplateToRegex", "$string", "v", "$$number", "$$string", "$$union", "unexpectedCase", "$StringTemplate", "shape", "opts", "$$stringTemplate", "$constructedBy", "$StringTemplate", "isOptionalSymbol", "$Optional", "Schema", "shape", "o", "err", "c", "$$optional", "$Never", "_o", "$never", "$$never", "$Object", "_$Object", "partial", "every", "vv", "vk", "hasProperty", "$object", "def", "$$object", "$objectAny", "$custom", "$Record", "keys", "values", "ck", "$record", "$$record", "$Tuple", "$tuple", "$$tuple", "$Array", "v", "$Union", "isArray", "oi", "$array", "$$array", "$arrayAny", "$InstanceOf", "constructor", "check", "$instanceOf", "$$instanceOf", "$$schema", "$Lambda", "args", "f", "$$lambda", "$constructedBy", "$Lambda", "$function", "$custom", "o", "$Intersection", "Schema", "v", "err", "c", "every", "check", "$$intersect", "$constructedBy", "$Intersection", "o", "$Union", "Schema", "v", "err", "c", "some", "vv", "$union", "schemas", "$s", "$$union", "$", "_t", "$any", "$custom", "$$any", "$Custom", "$bigint", "$$bigint", "$symbol", "$$symbol", "$number", "$$number", "$string", "$$string", "$boolean", "$$boolean", "$undefined", "$literal", "$$undefined", "$Literal", "$void", "$null", "$literal", "$$null", "$constructedBy", "$Literal", "o", "$uint8Array", "$$uint8Array", "$ConstructedBy", "$primitive", "$union", "$number", "$string", "$undefined", "$bigint", "$boolean", "$symbol", "$json", "$jsonArr", "$array", "$any", "$jsonRecord", "$record", "$", "$$schema", "$objectAny", "o2", "k", "$object", "$arrayAny", "$function", "unexpectedCase", "assert", "production", "schema", "err", "ValidationError", "create", "PatternMatcher", "$state", "pattern", "handler", "h", "s", "i", "p", "match", "state", "_random", "$$number", "_o", "gen", "int53", "MIN_SAFE_INTEGER", "MAX_SAFE_INTEGER", "$$string", "word", "$$boolean", "bool", "$$bigint", "$$union", "random", "oneOf", "$$object", "res", "prop", "$$optional", "$$array", "arr", "n", "int32", "$$literal", "$$lambda", "$$any", "$$record", "keysN", "key", "val", "doc", "$fragment", "$custom", "el", "DOCUMENT_FRAGMENT_NODE", "domParser", "$element", "$custom", "el", "ELEMENT_NODE", "$text", "$custom", "el", "TEXT_NODE", "mapToStyleString", "m", "map", "value", "key", "ELEMENT_NODE", "doc", "TEXT_NODE", "CDATA_SECTION_NODE", "COMMENT_NODE", "DOCUMENT_NODE", "DOCUMENT_TYPE_NODE", "DOCUMENT_FRAGMENT_NODE", "$node", "$custom", "el", "create", "BOLD", "create", "UNBOLD", "BLUE", "GREY", "GREEN", "RED", "PURPLE", "ORANGE", "UNCOLOR", "computeNoColorLoggingArgs", "args", "strBuilder", "logArgs", "i", "arg", "lastLoggingTime", "getUnixTime", "_browserStyleMap", "BOLD", "create", "UNBOLD", "BLUE", "GREEN", "GREY", "RED", "PURPLE", "ORANGE", "UNCOLOR", "computeBrowserLoggingArgs", "args", "strBuilder", "styles", "currentStyle", "logArgs", "i", "arg", "style", "mapToStyleString", "computeLoggingArgs", "supportsColor", "computeNoColorLoggingArgs", "print", "vconsoles", "vc", "warn", "vconsoles", "create", "createIterator", "next", "iteratorFilter", "iterator", "filter", "res", "iteratorMap", "fmap", "done", "value", "DeleteItem", "clock", "len", "DeleteSet", "iterateDeletedStructs", "transaction", "ds", "f", "deletes", "clientid", "structs", "lastStruct", "clockState", "i", "del", "iterateStructs", "findIndexDS", "dis", "left", "right", "midindex", "floor", "mid", "midclock", "isDeleted", "id", "sortAndMergeDeleteSet", "dels", "a", "b", "j", "max", "mergeDeleteSets", "dss", "merged", "dssI", "delsLeft", "client", "appendTo", "addToDeleteSet", "length", "setIfUndefined", "createDeleteSet", "writeDeleteSet", "encoder", "ds", "writeVarUint", "from", "a", "b", "client", "dsitems", "len", "i", "item", "readDeleteSet", "decoder", "DeleteSet", "numClients", "readVarUint", "numberOfDeletes", "dsField", "setIfUndefined", "DeleteItem", "readAndApplyDeleteSet", "transaction", "store", "unappliedDS", "structs", "state", "getState", "clock", "clockEnd", "addToDeleteSet", "index", "findIndexSS", "struct", "splitItem", "UpdateEncoderV2", "generateNewClientId", "uint32", "Doc", "_Doc", "ObservableV2", "guid", "uuidv4", "collectionid", "gc", "gcFilter", "meta", "autoLoad", "shouldLoad", "StructStore", "create", "resolve", "provideSyncedPromise", "eventHandler", "isSynced", "item", "transact", "transaction", "from", "doc", "f", "origin", "name", "TypeConstructor", "AbstractType", "type", "setIfUndefined", "t", "Constr", "n", "YArray", "YText", "YMap", "YXmlElement", "YXmlFragment", "value", "key", "subdoc", "content", "DSDecoderV1", "decoder", "readVarUint", "UpdateDecoderV1", "createID", "readUint8", "readVarString", "readAny", "copyUint8Array", "readVarUint8Array", "DSDecoderV2", "diff", "UpdateDecoderV2", "IntDiffOptRleDecoder", "UintOptRleDecoder", "RleDecoder", "StringDecoder", "ID", "keyClock", "DSEncoderV1", "createEncoder", "toUint8Array", "clock", "writeVarUint", "len", "UpdateEncoderV1", "id", "client", "info", "writeUint8", "s", "writeVarString", "isYKey", "any", "writeAny", "buf", "writeVarUint8Array", "embed", "DSEncoderV2", "unexpectedCase", "UpdateEncoderV2", "IntDiffOptRleEncoder", "UintOptRleEncoder", "RleEncoder", "StringEncoder", "encoder", "writeUint8Array", "writeStructs", "structs", "max", "startNewStructs", "findIndexSS", "firstStruct", "writeClientsStructs", "store", "_sm", "sm", "getState", "getStateVector", "_clock", "a", "b", "readClientsStructRefs", "clientRefs", "numOfStateUpdates", "i", "numberOfStructs", "refs", "GC", "Skip", "cantCopyParentInfo", "struct", "Item", "readItemContent", "integrateStructs", "clientsStructRefs", "stack", "clientsStructRefsIds", "getNextStructTarget", "nextStructsTarget", "curStructsTarget", "restStructs", "missingSV", "updateMissingSv", "mclock", "stackHead", "state", "addStackToRestSS", "inapplicableItems", "c", "offset", "missing", "structRefs", "writeStructsFromTransaction", "readUpdateV2", "ydoc", "transactionOrigin", "structDecoder", "retry", "ss", "pending", "mergeUpdatesV2", "dsRest", "readAndApplyDeleteSet", "pendingDSUpdate", "createDecoder", "dsRest2", "update", "applyUpdateV2", "applyUpdateV2", "ydoc", "update", "transactionOrigin", "YDecoder", "UpdateDecoderV2", "decoder", "createDecoder", "readUpdateV2", "applyUpdate", "UpdateDecoderV1", "EventHandler", "createEventHandler", "addEventHandlerListener", "eventHandler", "f", "removeEventHandlerListener", "l", "len", "g", "callEventHandlerListeners", "arg0", "arg1", "callAll", "ID", "client", "clock", "compareIDs", "a", "b", "createID", "findRootTypeKey", "type", "key", "value", "unexpectedCase", "Snapshot", "ds", "sv", "createSnapshot", "ds", "sm", "Snapshot", "emptySnapshot", "createDeleteSet", "isVisible", "item", "snapshot", "isDeleted", "splitSnapshotAffectedStructs", "transaction", "meta", "setIfUndefined", "create", "store", "clock", "client", "getState", "getItemCleanStart", "createID", "iterateDeletedStructs", "_item", "StructStore", "getStateVector", "store", "sm", "structs", "client", "struct", "getState", "lastStruct", "addStruct", "unexpectedCase", "findIndexSS", "clock", "left", "right", "mid", "midclock", "midindex", "floor", "find", "id", "getItem", "findIndexCleanStart", "transaction", "index", "Item", "splitItem", "getItemCleanStart", "getItemCleanEnd", "GC", "replaceStruct", "newStruct", "iterateStructs", "clockStart", "len", "f", "clockEnd", "Transaction", "doc", "origin", "local", "DeleteSet", "writeUpdateMessageFromTransaction", "encoder", "any", "sortAndMergeDeleteSet", "writeStructsFromTransaction", "writeDeleteSet", "addChangedTypeToTransaction", "type", "parentSub", "item", "setIfUndefined", "create", "tryToMergeWithLefts", "pos", "i", "merged", "tryGcDeleteSet", "ds", "gcFilter", "deleteItems", "di", "deleteItem", "endDeleteItemClock", "si", "tryMergeDeleteSet", "mostRightIndexToCheck", "min", "cleanupTransactions", "transactionCleanups", "i", "transaction", "doc", "store", "ds", "mergeStructs", "sortAndMergeDeleteSet", "getStateVector", "fs", "subs", "itemtype", "events", "type", "event", "event1", "event2", "callEventHandlerListeners", "cleanupYTextAfterTransaction", "callAll", "tryGcDeleteSet", "tryMergeDeleteSet", "clock", "client", "beforeClock", "structs", "firstChangePos", "max", "findIndexSS", "tryToMergeWithLefts", "replacedStructPos", "print", "ORANGE", "BOLD", "UNBOLD", "RED", "generateNewClientId", "encoder", "UpdateEncoderV1", "writeUpdateMessageFromTransaction", "UpdateEncoderV2", "subdocsAdded", "subdocsLoaded", "subdocsRemoved", "subdoc", "transact", "f", "origin", "local", "initialCall", "result", "Transaction", "finishCleanup", "lazyStructReaderGenerator", "decoder", "numOfStateUpdates", "readVarUint", "i", "numberOfStructs", "client", "clock", "info", "len", "Skip", "createID", "cantCopyParentInfo", "struct", "Item", "readItemContent", "GC", "LazyStructReader", "filterSkips", "LazyStructWriter", "encoder", "sliceStruct", "left", "diff", "GC", "client", "clock", "createID", "Skip", "leftItem", "Item", "mergeUpdatesV2", "updates", "YDecoder", "UpdateDecoderV2", "YEncoder", "UpdateEncoderV2", "updateDecoders", "update", "createDecoder", "lazyStructDecoders", "decoder", "LazyStructReader", "currWrite", "updateEncoder", "lazyStructEncoder", "LazyStructWriter", "dec", "dec1", "dec2", "clockDiff", "currDecoder", "firstClient", "curr", "iterated", "writeStructToLazyStructWriter", "next", "finishLazyStructWriting", "dss", "readDeleteSet", "ds", "mergeDeleteSets", "writeDeleteSet", "flushLazyStructWriter", "lazyWriter", "toUint8Array", "createEncoder", "writeStructToLazyStructWriter", "struct", "offset", "writeVarUint", "finishLazyStructWriting", "restEncoder", "i", "partStructs", "writeUint8Array", "errorComputeChanges", "YEvent", "target", "transaction", "getPathTo", "struct", "isDeleted", "create", "keys", "key", "item", "action", "oldValue", "prev", "last", "changes", "added", "deleted", "delta", "lastOp", "packOp", "parent", "child", "path", "i", "c", "warnPrematureAccess", "warn", "maxSearchMarker", "globalSearchMarkerTimestamp", "ArraySearchMarker", "p", "index", "refreshMarkerTimestamp", "marker", "overwriteMarker", "markPosition", "searchMarker", "a", "b", "pm", "findMarker", "yarray", "abs", "pindex", "updateMarkerChanges", "len", "m", "max", "callTypeObservers", "type", "transaction", "event", "changedType", "changedParentTypes", "setIfUndefined", "callEventHandlerListeners", "AbstractType", "createEventHandler", "y", "item", "methodUnimplemented", "_encoder", "n", "_parentSubs", "f", "addEventHandlerListener", "removeEventHandlerListener", "typeListSlice", "start", "end", "warnPrematureAccess", "len", "cs", "c", "i", "typeListToArray", "typeListForEach", "type", "f", "index", "n", "warnPrematureAccess", "c", "i", "typeListMap", "result", "typeListCreateIterator", "currentContent", "currentContentIndex", "value", "typeListGet", "marker", "findMarker", "typeListInsertGenericsAfter", "transaction", "parent", "referenceItem", "content", "left", "doc", "ownClientId", "store", "right", "jsonContent", "packJsonContent", "Item", "createID", "getState", "ContentAny", "ContentBinary", "Doc", "ContentDoc", "AbstractType", "ContentType", "lengthExceeded", "create", "typeListInsertGenerics", "updateMarkerChanges", "startIndex", "getItemCleanStart", "typeListPushGenerics", "maxMarker", "currMarker", "typeListDelete", "length", "startLength", "typeMapDelete", "key", "typeMapSet", "typeMapGet", "val", "typeMapGetAll", "res", "typeMapHas", "typeMapGetAllSnapshot", "parent", "snapshot", "res", "value", "key", "v", "isVisible", "createMapIterator", "type", "warnPrematureAccess", "iteratorFilter", "entry", "YArrayEvent", "YEvent", "YArray", "_YArray", "AbstractType", "items", "a", "y", "item", "arr", "el", "transaction", "parentSubs", "callTypeObservers", "index", "content", "transact", "typeListInsertGenerics", "typeListPushGenerics", "length", "typeListDelete", "typeListGet", "typeListToArray", "start", "end", "typeListSlice", "c", "f", "typeListMap", "typeListForEach", "typeListCreateIterator", "encoder", "YArrayRefID", "readYArray", "_decoder", "YMapEvent", "ymap", "subs", "YMap", "_YMap", "entries", "map", "iteratorMap", "typeMapDelete", "typeMapSet", "typeMapGet", "typeMapHas", "_value", "YMapRefID", "readYMap", "equalAttrs", "b", "equalFlat", "ItemTextListPosition", "left", "right", "currentAttributes", "unexpectedCase", "ContentFormat", "updateCurrentAttributes", "findNextPosition", "pos", "count", "getItemCleanStart", "createID", "findPosition", "useSearchMarker", "marker", "findMarker", "insertNegatedAttributes", "currPos", "negatedAttributes", "doc", "ownClientId", "val", "nextFormat", "Item", "getState", "format", "minimizeAttributeChanges", "attributes", "insertAttributes", "currentVal", "insertText", "text", "_val", "ContentString", "ContentType", "ContentEmbed", "updateMarkerChanges", "formatText", "iterationLoop", "attr", "newlines", "cleanupFormattingGap", "curr", "startAttributes", "currAttributes", "endFormats", "create", "cf", "cleanups", "reachedCurr", "startAttrValue", "cleanupContextlessFormattingGap", "attrs", "cleanupYTextFormatting", "copy", "cleanupYTextAfterTransaction", "needFullCleanup", "client", "afterClock", "clock", "iterateStructs", "GC", "t", "iterateDeletedStructs", "yText", "deleteText", "startLength", "startAttrs", "YTextEvent", "ytext", "sub", "changes", "delta", "oldAttributes", "action", "insert", "retain", "deleteLen", "addOp", "op", "isEmpty", "assign", "curVal", "lastOp", "YText", "_YText", "string", "e", "event", "str", "sanitize", "i", "ins", "prevSnapshot", "computeYChange", "ops", "n", "packStr", "addAttributes", "computeDelta", "cur", "splitSnapshotAffectedStructs", "k", "embed", "attributeName", "attributeValue", "typeMapGetAll", "YTextRefID", "readYText", "YXmlTreeWalker", "root", "YXmlElement", "YXmlFragment", "nxt", "_YXmlFragment", "first", "filter", "query", "next", "element", "from", "YXmlEvent", "xml", "_document", "hooks", "binding", "fragment", "xmlType", "ref", "refItem", "typeListInsertGenericsAfter", "pc", "YXmlFragmentRefID", "readYXmlFragment", "_YXmlElement", "nodeName", "forEach", "stringBuilder", "keys", "keysLen", "attrsString", "dom", "yxml", "YXmlElementRefID", "readYXmlElement", "decoder", "target", "YXmlHook", "_YXmlHook", "hookName", "hook", "YXmlHookRefID", "readYXmlHook", "YXmlText", "_YXmlText", "nestedNodes", "node", "j", "YXmlTextRefID", "readYXmlText", "AbstractStruct", "id", "methodUnimplemented", "offset", "encodingRef", "structGCRefNumber", "addStruct", "store", "ContentBinary", "_ContentBinary", "readContentBinary", "ContentDeleted", "_ContentDeleted", "len", "addToDeleteSet", "readContentDeleted", "createDocFromOpts", "guid", "opts", "Doc", "ContentDoc", "_ContentDoc", "readContentDoc", "_ContentEmbed", "readContentEmbed", "_ContentFormat", "_offset", "_right", "_transaction", "p", "readContentFormat", "ContentJSON", "_ContentJSON", "readContentJSON", "cs", "isDevMode", "getVariable", "ContentAny", "_ContentAny", "deepFreeze", "readContentAny", "_ContentString", "firstCharCode", "readContentString", "typeRefs", "_ContentType", "readContentType", "splitItem", "transaction", "leftItem", "diff", "client", "clock", "rightItem", "Item", "createID", "Item", "_Item", "AbstractStruct", "id", "left", "origin", "right", "rightOrigin", "parent", "parentSub", "content", "isMarked", "doKeep", "doDelete", "transaction", "store", "getState", "ID", "getItemCleanEnd", "getItemCleanStart", "GC", "parentItem", "getItem", "offset", "createID", "o", "conflictingItems", "itemsBeforeOrigin", "compareIDs", "addStruct", "addChangedTypeToTransaction", "n", "searchMarker", "marker", "addToDeleteSet", "parentGCd", "unexpectedCase", "replaceStruct", "ContentDeleted", "encoder", "info", "ykey", "findRootTypeKey", "readItemContent", "decoder", "contentRefs", "readContentDeleted", "readContentJSON", "readContentBinary", "readContentString", "readContentEmbed", "readContentFormat", "readContentType", "readContentAny", "readContentDoc", "structSkipRefNumber", "Skip", "writeVarUint", "glo", "importIdentifier", "jsx", "jsxs", "LABELS", "labelsOf", "lang", "LIST_WRAPPER", "BLOCK_TAG", "escapeHtml", "text", "escapeAttr", "safeHref", "href", "value", "withBreaks", "plainOf", "delta", "op", "trailingBreak", "inlineHtml", "attributes", "out", "blockBody", "block", "inner", "hueOf", "key", "hash", "i", "initialsOf", "name", "words", "first", "last", "viewerMarks", "people", "person", "presenceHtml", "labels", "checkMark", "blockHtml", "index", "type", "tag", "checked", "code", "body", "documentHtml", "blocks", "presence", "here", "at", "parts", "openList", "openKind", "closeList", "list", "wrapper", "liveDocShell", "o", "mark", "glyph", "label", "blockOption", "BLOCK_TYPES", "LIST_TYPES", "CONTINUES", "EMPHASIS", "WORD", "CODE_SPAN", "LINK", "ESCAPED", "merge", "delta", "mark", "op", "compact", "out", "last", "inlineDelta", "source", "rest", "plain", "previous", "flush", "take", "count", "escaped", "link", "code", "emphasis", "rule", "found", "FENCE", "HEADING", "QUOTE", "CHECK", "BULLET", "ORDERED", "block", "type", "checked", "parseMarkdown", "lines", "blocks", "paragraph", "closeParagraph", "index", "line", "body", "heading", "level", "check", "bullet", "ordered", "quote", "INPUT_RULES", "INLINE_RULES", "LINK_RULE", "VIEWER_TTL", "HEARTBEAT_MS", "ANNOUNCE_EVERY_MS", "REMOTE", "LOCAL_TYPING", "plainTextOf", "text", "op", "plainLength", "delta", "total", "sliceDelta", "from", "to", "out", "cursor", "end", "start", "stop", "MARK_KEYS", "attributesAt", "offset", "clear", "key", "carried", "value", "bytesToBase64", "bytes", "binary", "i", "base64ToBytes", "base64", "diffRange", "before", "after", "maxStart", "endBefore", "endAfter", "descend", "node", "current", "at", "children", "last", "createLiveDocView", "props", "docId", "base", "containerId", "doc", "Doc", "container", "shell", "composing", "composedAt", "renderOwed", "source", "pending", "linkSpan", "viewers", "selfId", "announcedAt", "announcedIndex", "heartbeat", "fragment", "typeOf", "element", "BLOCK_TYPES", "blocksOf", "YXmlText", "YXmlElement", "first", "insertBlock", "index", "type", "checked", "ensureBlocks", "modelOf", "block", "elementAt", "lineOf", "blockNodes", "walker", "nodes", "lengthOfNode", "domTextOf", "offsetIn", "nodeOffset", "beside", "parent", "pointIn", "remaining", "length", "pointFrom", "resolved", "selectionSpan", "selection", "range", "isCollapsed", "span", "caretAt", "point", "restoreSelection", "startBlock", "endBlock", "render", "keep", "documentHtml", "others", "syncToolbar", "renderPresence", "select", "LIST_TYPES", "button", "name", "active", "spanHasMark", "now", "id", "viewer", "roomSignature", "slot", "presenceHtml", "announce", "gone", "answer", "response", "announceCaret", "receivePresence", "frame", "known", "structural", "caret", "run", "setBlockType", "applyBlockType", "target", "splitBlock", "tail", "nextType", "CONTINUES", "mergeBackward", "blocks", "previous", "mergeForward", "deleteSpan", "insertTextAt", "checkedOn", "toggleChecked", "next", "overSpan", "visit", "seen", "all", "toggleMark", "on", "applyLink", "href", "applyInputRule", "rule", "pattern", "applyInlineRule", "upToCaret", "link", "whole", "label", "match", "inner", "applyLocalTextChange", "deletedLength", "inserted", "onBeforeInput", "event", "collapsed", "multi", "onPaste", "parsed", "parseMarkdown", "adopt", "lastBlock", "pushLocalUpdate", "update", "resync", "snapshot", "topic", "viewerId", "applyUpdate", "connectLive", "es", "payload", "onSelectionChange", "wireToolbar", "root", "openLinkDialog", "linkDialog", "dialog", "input", "existing", "wireLinkDialog", "mount", "el", "owed", "composed", "origin", "liveDocShell", "liveDoc", "controller"]
7
+ }