studiograph 1.3.3 → 1.3.4

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 (290) hide show
  1. package/dist/agent/orchestrator.d.ts +10 -0
  2. package/dist/agent/orchestrator.js +26 -7
  3. package/dist/agent/orchestrator.js.map +1 -1
  4. package/dist/agent/skills/sync-configuration.md +4 -29
  5. package/dist/agent/skills/sync-setup.md +2 -4
  6. package/dist/agent/tools/graph-tools.d.ts +5 -1
  7. package/dist/agent/tools/graph-tools.js +161 -9
  8. package/dist/agent/tools/graph-tools.js.map +1 -1
  9. package/dist/agent/tools/ops-tools.js +15 -126
  10. package/dist/agent/tools/ops-tools.js.map +1 -1
  11. package/dist/agent/tools/permission-tools.d.ts +15 -14
  12. package/dist/agent/tools/permission-tools.js +65 -128
  13. package/dist/agent/tools/permission-tools.js.map +1 -1
  14. package/dist/agent/tools/sync-tools.d.ts +7 -6
  15. package/dist/agent/tools/sync-tools.js +205 -178
  16. package/dist/agent/tools/sync-tools.js.map +1 -1
  17. package/dist/cli/commands/about.d.ts +13 -0
  18. package/dist/cli/commands/about.js +97 -0
  19. package/dist/cli/commands/about.js.map +1 -0
  20. package/dist/cli/commands/clone.d.ts +5 -2
  21. package/dist/cli/commands/clone.js +131 -62
  22. package/dist/cli/commands/clone.js.map +1 -1
  23. package/dist/cli/commands/connector.d.ts +2 -16
  24. package/dist/cli/commands/connector.js +32 -109
  25. package/dist/cli/commands/connector.js.map +1 -1
  26. package/dist/cli/commands/deploy.d.ts +0 -1
  27. package/dist/cli/commands/deploy.js +13 -103
  28. package/dist/cli/commands/deploy.js.map +1 -1
  29. package/dist/cli/commands/init.js +6 -93
  30. package/dist/cli/commands/init.js.map +1 -1
  31. package/dist/cli/commands/join.d.ts +3 -2
  32. package/dist/cli/commands/join.js +142 -97
  33. package/dist/cli/commands/join.js.map +1 -1
  34. package/dist/cli/commands/redeploy.js +1 -2
  35. package/dist/cli/commands/redeploy.js.map +1 -1
  36. package/dist/cli/commands/serve.d.ts +1 -3
  37. package/dist/cli/commands/serve.js +29 -109
  38. package/dist/cli/commands/serve.js.map +1 -1
  39. package/dist/cli/commands/start.js +1 -1
  40. package/dist/cli/commands/start.js.map +1 -1
  41. package/dist/cli/commands/sync-collection.d.ts +14 -0
  42. package/dist/cli/commands/sync-collection.js +366 -0
  43. package/dist/cli/commands/sync-collection.js.map +1 -0
  44. package/dist/cli/commands/sync.d.ts +4 -2
  45. package/dist/cli/commands/sync.js +529 -94
  46. package/dist/cli/commands/sync.js.map +1 -1
  47. package/dist/cli/index.js +15 -30
  48. package/dist/cli/index.js.map +1 -1
  49. package/dist/cli/setup-wizard.d.ts +0 -13
  50. package/dist/cli/setup-wizard.js +6 -81
  51. package/dist/cli/setup-wizard.js.map +1 -1
  52. package/dist/core/graph.d.ts +8 -2
  53. package/dist/core/graph.js +11 -7
  54. package/dist/core/graph.js.map +1 -1
  55. package/dist/core/types.d.ts +149 -21
  56. package/dist/core/types.js +16 -4
  57. package/dist/core/types.js.map +1 -1
  58. package/dist/core/workspace-manager.js +1 -5
  59. package/dist/core/workspace-manager.js.map +1 -1
  60. package/dist/core/workspace.d.ts +11 -4
  61. package/dist/core/workspace.js +61 -26
  62. package/dist/core/workspace.js.map +1 -1
  63. package/dist/integrations/asana.d.ts +26 -0
  64. package/dist/integrations/asana.js +77 -0
  65. package/dist/integrations/asana.js.map +1 -0
  66. package/dist/integrations/figma-local.d.ts +16 -0
  67. package/dist/integrations/figma-local.js +10 -0
  68. package/dist/integrations/figma-local.js.map +1 -0
  69. package/dist/integrations/figma.d.ts +17 -0
  70. package/dist/integrations/figma.js +16 -0
  71. package/dist/integrations/figma.js.map +1 -0
  72. package/dist/integrations/granola.d.ts +24 -0
  73. package/dist/integrations/granola.js +59 -0
  74. package/dist/integrations/granola.js.map +1 -0
  75. package/dist/integrations/linear.d.ts +14 -0
  76. package/dist/integrations/linear.js +70 -0
  77. package/dist/integrations/linear.js.map +1 -0
  78. package/dist/integrations/paper-local.d.ts +14 -0
  79. package/dist/integrations/paper-local.js +10 -0
  80. package/dist/integrations/paper-local.js.map +1 -0
  81. package/dist/integrations/paper.d.ts +2 -0
  82. package/dist/integrations/paper.js +10 -0
  83. package/dist/integrations/paper.js.map +1 -0
  84. package/dist/integrations/pipedrive.d.ts +26 -0
  85. package/dist/integrations/pipedrive.js +97 -0
  86. package/dist/integrations/pipedrive.js.map +1 -0
  87. package/dist/integrations/registry.d.ts +15 -0
  88. package/dist/integrations/registry.js +27 -0
  89. package/dist/integrations/registry.js.map +1 -0
  90. package/dist/integrations/types.d.ts +34 -0
  91. package/dist/integrations/types.js +9 -0
  92. package/dist/integrations/types.js.map +1 -0
  93. package/dist/mcp/connector-manager.d.ts +45 -31
  94. package/dist/mcp/connector-manager.js +164 -116
  95. package/dist/mcp/connector-manager.js.map +1 -1
  96. package/dist/mcp/server-oauth-provider.d.ts +56 -0
  97. package/dist/mcp/server-oauth-provider.js +138 -0
  98. package/dist/mcp/server-oauth-provider.js.map +1 -0
  99. package/dist/server/chrome/chrome.css +142 -28
  100. package/dist/server/chrome/chrome.js +46 -220
  101. package/dist/server/collab-authority.d.ts +70 -0
  102. package/dist/server/collab-authority.js +218 -0
  103. package/dist/server/collab-authority.js.map +1 -0
  104. package/dist/server/collab.d.ts +29 -0
  105. package/dist/server/collab.js +195 -0
  106. package/dist/server/collab.js.map +1 -0
  107. package/dist/server/commit-scheduler.d.ts +39 -0
  108. package/dist/server/commit-scheduler.js +113 -0
  109. package/dist/server/commit-scheduler.js.map +1 -0
  110. package/dist/server/index.d.ts +0 -2
  111. package/dist/server/index.js +166 -55
  112. package/dist/server/index.js.map +1 -1
  113. package/dist/server/routes/auth-api.d.ts +6 -0
  114. package/dist/server/routes/auth-api.js +78 -0
  115. package/dist/server/routes/auth-api.js.map +1 -1
  116. package/dist/server/routes/chat.js +4 -0
  117. package/dist/server/routes/chat.js.map +1 -1
  118. package/dist/server/routes/collab.d.ts +6 -0
  119. package/dist/server/routes/collab.js +10 -0
  120. package/dist/server/routes/collab.js.map +1 -0
  121. package/dist/server/routes/git-http.d.ts +23 -0
  122. package/dist/server/routes/git-http.js +251 -0
  123. package/dist/server/routes/git-http.js.map +1 -0
  124. package/dist/server/routes/graph-api.d.ts +6 -2
  125. package/dist/server/routes/graph-api.js +266 -82
  126. package/dist/server/routes/graph-api.js.map +1 -1
  127. package/dist/server/routes/mcp.d.ts +12 -0
  128. package/dist/server/routes/mcp.js +35 -0
  129. package/dist/server/routes/mcp.js.map +1 -0
  130. package/dist/server/routes/permissions-api.d.ts +6 -4
  131. package/dist/server/routes/permissions-api.js +53 -167
  132. package/dist/server/routes/permissions-api.js.map +1 -1
  133. package/dist/server/routes/sync-api.d.ts +26 -0
  134. package/dist/server/routes/sync-api.js +757 -0
  135. package/dist/server/routes/sync-api.js.map +1 -0
  136. package/dist/server/routes/ws.d.ts +9 -0
  137. package/dist/server/routes/ws.js +131 -0
  138. package/dist/server/routes/ws.js.map +1 -0
  139. package/dist/server/session-manager.d.ts +40 -0
  140. package/dist/server/session-manager.js +132 -0
  141. package/dist/server/session-manager.js.map +1 -0
  142. package/dist/server/ws-hub.d.ts +130 -0
  143. package/dist/server/ws-hub.js +250 -0
  144. package/dist/server/ws-hub.js.map +1 -0
  145. package/dist/server/yjs-manager.d.ts +59 -0
  146. package/dist/server/yjs-manager.js +194 -0
  147. package/dist/server/yjs-manager.js.map +1 -0
  148. package/dist/services/auth-service.d.ts +74 -0
  149. package/dist/services/auth-service.js +286 -6
  150. package/dist/services/auth-service.js.map +1 -1
  151. package/dist/services/git.d.ts +6 -0
  152. package/dist/services/git.js +32 -2
  153. package/dist/services/git.js.map +1 -1
  154. package/dist/services/sync/collection-sync.d.ts +73 -0
  155. package/dist/services/sync/collection-sync.js +726 -0
  156. package/dist/services/sync/collection-sync.js.map +1 -0
  157. package/dist/services/sync/commit.js +5 -20
  158. package/dist/services/sync/commit.js.map +1 -1
  159. package/dist/services/sync/data-fetcher.d.ts +31 -0
  160. package/dist/services/sync/data-fetcher.js +12 -0
  161. package/dist/services/sync/data-fetcher.js.map +1 -0
  162. package/dist/services/sync/entity-refresh.d.ts +30 -0
  163. package/dist/services/sync/entity-refresh.js +275 -0
  164. package/dist/services/sync/entity-refresh.js.map +1 -0
  165. package/dist/services/sync/frontmatter-extractor.d.ts +2 -2
  166. package/dist/services/sync/frontmatter-extractor.js +1 -2
  167. package/dist/services/sync/frontmatter-extractor.js.map +1 -1
  168. package/dist/services/sync/graph-match.js +1 -1
  169. package/dist/services/sync/graph-match.js.map +1 -1
  170. package/dist/services/sync/mcp-client.d.ts +16 -4
  171. package/dist/services/sync/mcp-client.js +34 -20
  172. package/dist/services/sync/mcp-client.js.map +1 -1
  173. package/dist/services/sync/prompts.js +1 -1
  174. package/dist/services/sync/reconciler.js +1 -2
  175. package/dist/services/sync/reconciler.js.map +1 -1
  176. package/dist/services/sync/rest-client.d.ts +40 -0
  177. package/dist/services/sync/rest-client.js +100 -0
  178. package/dist/services/sync/rest-client.js.map +1 -0
  179. package/dist/services/sync/source-config.d.ts +23 -1
  180. package/dist/services/sync/source-config.js +112 -16
  181. package/dist/services/sync/source-config.js.map +1 -1
  182. package/dist/services/sync/source-definitions/asana.d.ts +3 -4
  183. package/dist/services/sync/source-definitions/asana.js +7 -13
  184. package/dist/services/sync/source-definitions/asana.js.map +1 -1
  185. package/dist/services/sync/source-definitions/definitions.d.ts +5 -18
  186. package/dist/services/sync/source-definitions/definitions.js +4 -22
  187. package/dist/services/sync/source-definitions/definitions.js.map +1 -1
  188. package/dist/services/sync/source-definitions/granola.d.ts +1 -1
  189. package/dist/services/sync/source-definitions/granola.js +11 -18
  190. package/dist/services/sync/source-definitions/granola.js.map +1 -1
  191. package/dist/services/sync/source-definitions/linear.d.ts +1 -1
  192. package/dist/services/sync/source-definitions/linear.js +17 -15
  193. package/dist/services/sync/source-definitions/linear.js.map +1 -1
  194. package/dist/services/sync/source-definitions/pipedrive.d.ts +1 -1
  195. package/dist/services/sync/source-definitions/pipedrive.js +6 -15
  196. package/dist/services/sync/source-definitions/pipedrive.js.map +1 -1
  197. package/dist/services/sync/staging.js +1 -2
  198. package/dist/services/sync/staging.js.map +1 -1
  199. package/dist/services/sync/structured-extractor.d.ts +8 -2
  200. package/dist/services/sync/structured-extractor.js +243 -35
  201. package/dist/services/sync/structured-extractor.js.map +1 -1
  202. package/dist/services/sync/types.d.ts +192 -23
  203. package/dist/services/sync/unstructured-extractor.d.ts +1 -3
  204. package/dist/services/sync/unstructured-extractor.js +2 -14
  205. package/dist/services/sync/unstructured-extractor.js.map +1 -1
  206. package/dist/utils/git.d.ts +33 -20
  207. package/dist/utils/git.js +119 -62
  208. package/dist/utils/git.js.map +1 -1
  209. package/dist/utils/preflight.d.ts +1 -15
  210. package/dist/utils/preflight.js +1 -35
  211. package/dist/utils/preflight.js.map +1 -1
  212. package/dist/web/_app/immutable/assets/0.CupILLQs.css +1 -0
  213. package/dist/web/_app/immutable/assets/3.CtJi4Cy9.css +1 -0
  214. package/dist/web/_app/immutable/assets/5.CydFyZSu.css +1 -0
  215. package/dist/web/_app/immutable/assets/6.kqeOo0OW.css +1 -0
  216. package/dist/web/_app/immutable/assets/7.CseIx7qQ.css +1 -0
  217. package/dist/web/_app/immutable/assets/8.BYpFDZHK.css +1 -0
  218. package/dist/web/_app/immutable/assets/AppShell.Ch_ef9hJ.css +1 -0
  219. package/dist/web/_app/immutable/assets/ChatPanel.CP-_8txt.css +1 -0
  220. package/dist/web/_app/immutable/chunks/0oxpWEgM.js +1 -0
  221. package/dist/web/_app/immutable/chunks/B1y7Wy5O.js +18 -0
  222. package/dist/web/_app/immutable/chunks/B7eduG_j.js +64 -0
  223. package/dist/web/_app/immutable/chunks/BBLgaWN8.js +1 -0
  224. package/dist/web/_app/immutable/chunks/BCB5cYCz.js +2 -0
  225. package/dist/web/_app/immutable/chunks/{aosHekRC.js → BPUy9_sS.js} +1 -1
  226. package/dist/web/_app/immutable/chunks/BVBRzmeQ.js +7 -0
  227. package/dist/web/_app/immutable/chunks/{CUzqHQY_.js → BXuvR8Ks.js} +2 -1
  228. package/dist/web/_app/immutable/chunks/BeBar3OL.js +1 -0
  229. package/dist/web/_app/immutable/chunks/BuOTIbJu.js +1 -0
  230. package/dist/web/_app/immutable/chunks/CLFba8FK.js +5 -0
  231. package/dist/web/_app/immutable/chunks/CQCkXCml.js +1 -0
  232. package/dist/web/_app/immutable/chunks/CXuhHL4d.js +1 -0
  233. package/dist/web/_app/immutable/chunks/Cg9NOuOl.js +27 -0
  234. package/dist/web/_app/immutable/chunks/Cs5oz2oJ.js +5 -0
  235. package/dist/web/_app/immutable/chunks/Cs_ROD7H.js +2 -0
  236. package/dist/web/_app/immutable/chunks/D2aTbzFm.js +3 -0
  237. package/dist/web/_app/immutable/chunks/D4FXhiC2.js +1 -0
  238. package/dist/web/_app/immutable/chunks/D4VHRYeB.js +1 -0
  239. package/dist/web/_app/immutable/chunks/DCGSm8Hl.js +1 -0
  240. package/dist/web/_app/immutable/chunks/DP09rP34.js +2 -0
  241. package/dist/web/_app/immutable/chunks/DiP47fAp.js +1 -0
  242. package/dist/web/_app/immutable/chunks/DptGlK8O.js +1 -0
  243. package/dist/web/_app/immutable/chunks/O0fx2ss6.js +1 -0
  244. package/dist/web/_app/immutable/chunks/xBRYfpah.js +1 -0
  245. package/dist/web/_app/immutable/entry/app.FgnywZP_.js +2 -0
  246. package/dist/web/_app/immutable/entry/start.Bsa-zlPf.js +1 -0
  247. package/dist/web/_app/immutable/nodes/0.D3SW-LMc.js +10 -0
  248. package/dist/web/_app/immutable/nodes/1.y0c5TQTP.js +1 -0
  249. package/dist/web/_app/immutable/nodes/2.BQfSep9-.js +1 -0
  250. package/dist/web/_app/immutable/nodes/3.CC4Y-xMM.js +11 -0
  251. package/dist/web/_app/immutable/nodes/{5.BBpmYkAu.js → 4.Dp0Z-oPW.js} +2 -2
  252. package/dist/web/_app/immutable/nodes/5.gjZ03DON.js +2 -0
  253. package/dist/web/_app/immutable/nodes/6.dRNIwcJQ.js +1 -0
  254. package/dist/web/_app/immutable/nodes/7.I4Gjes3o.js +2 -0
  255. package/dist/web/_app/immutable/nodes/8.Dj14D7uH.js +1 -0
  256. package/dist/web/_app/version.json +1 -1
  257. package/dist/web/index.html +10 -12
  258. package/package.json +12 -2
  259. package/dist/web/_app/immutable/assets/0.CDbX4Cwz.css +0 -1
  260. package/dist/web/_app/immutable/assets/3.BJy7pVXi.css +0 -1
  261. package/dist/web/_app/immutable/assets/4.Ad16uh9o.css +0 -1
  262. package/dist/web/_app/immutable/assets/6.Bm2i7O0j.css +0 -1
  263. package/dist/web/_app/immutable/assets/AppShell.D0rmbdqF.css +0 -1
  264. package/dist/web/_app/immutable/assets/ChatPanel.RFD5GGYI.css +0 -1
  265. package/dist/web/_app/immutable/assets/editor.CPAf2SRV.css +0 -1
  266. package/dist/web/_app/immutable/chunks/479TgXB4.js +0 -1
  267. package/dist/web/_app/immutable/chunks/4QY4j-jX.js +0 -1
  268. package/dist/web/_app/immutable/chunks/BFb0g4TQ.js +0 -64
  269. package/dist/web/_app/immutable/chunks/Bopa-Ask.js +0 -1
  270. package/dist/web/_app/immutable/chunks/COwytaCP.js +0 -1
  271. package/dist/web/_app/immutable/chunks/DEJSHbC3.js +0 -1
  272. package/dist/web/_app/immutable/chunks/DNywhIex.js +0 -23
  273. package/dist/web/_app/immutable/chunks/DTUXhwEY.js +0 -1
  274. package/dist/web/_app/immutable/chunks/DThXpa0U.js +0 -6
  275. package/dist/web/_app/immutable/chunks/Dh_H7Owr.js +0 -18
  276. package/dist/web/_app/immutable/chunks/Dml-u95b.js +0 -2
  277. package/dist/web/_app/immutable/chunks/DnlgZ_Tk.js +0 -5
  278. package/dist/web/_app/immutable/chunks/DtVH--hH.js +0 -6
  279. package/dist/web/_app/immutable/chunks/DvKVaE7M.js +0 -1
  280. package/dist/web/_app/immutable/chunks/MbiSz-iW.js +0 -2
  281. package/dist/web/_app/immutable/chunks/bSAC733J.js +0 -1
  282. package/dist/web/_app/immutable/entry/app.BvodXQQ0.js +0 -2
  283. package/dist/web/_app/immutable/entry/start.Bkui3Kyw.js +0 -1
  284. package/dist/web/_app/immutable/nodes/0.DfbCOBhn.js +0 -2
  285. package/dist/web/_app/immutable/nodes/1.vtxUGpe6.js +0 -1
  286. package/dist/web/_app/immutable/nodes/2.Cq29oW4h.js +0 -1
  287. package/dist/web/_app/immutable/nodes/3.SquslPZy.js +0 -1
  288. package/dist/web/_app/immutable/nodes/4.COV8FR8b.js +0 -16
  289. package/dist/web/_app/immutable/nodes/6.BBbh6z9I.js +0 -2
  290. /package/dist/web/_app/immutable/assets/{5.BhKgiXd2.css → 4.BhKgiXd2.css} +0 -0
@@ -0,0 +1,5 @@
1
+ const T=()=>new Map,en=e=>{const t=T();return e.forEach((n,s)=>{t.set(s,n)}),t},R=(e,t,n)=>{let s=e.get(t);return s===void 0&&e.set(t,s=n()),s},Pr=(e,t)=>{const n=[];for(const[s,r]of e)n.push(t(r,s));return n},Zr=(e,t)=>{for(const[n,s]of e)if(t(s,n))return!0;return!1},Et=()=>new Set,He=e=>e[e.length-1],Qr=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},st=Array.from,fn=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},gn=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1},ti=(e,t)=>{const n=new Array(e);for(let s=0;s<e;s++)n[s]=t(s,n);return n},Mt=Array.isArray;class pn{constructor(){this._observers=T()}on(t,n){return R(this._observers,t,Et).add(n),n}once(t,n){const s=(...r)=>{this.off(t,s),n(...r)};this.on(t,s)}off(t,n){const s=this._observers.get(t);s!==void 0&&(s.delete(n),s.size===0&&this._observers.delete(t))}emit(t,n){return st((this._observers.get(t)||T()).values()).forEach(s=>s(...n))}destroy(){this._observers=T()}}class Ol{constructor(){this._observers=T()}on(t,n){R(this._observers,t,Et).add(n)}once(t,n){const s=(...r)=>{this.off(t,s),n(...r)};this.on(t,s)}off(t,n){const s=this._observers.get(t);s!==void 0&&(s.delete(n),s.size===0&&this._observers.delete(t))}emit(t,n){return st((this._observers.get(t)||T()).values()).forEach(s=>s(...n))}destroy(){this._observers=T()}}const q=Math.floor,ge=Math.abs,ks=(e,t)=>e<t?e:t,Tt=(e,t)=>e>t?e:t,ys=e=>e!==0?e<0:1/e<0,Jn=1,Hn=2,Ye=4,Xe=8,Ht=32,et=64,j=128,Ie=31,nn=63,kt=127,ei=2147483647,ye=Number.MAX_SAFE_INTEGER,Yn=Number.MIN_SAFE_INTEGER,ni=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&q(e)===e),si=String.fromCharCode,ri=e=>e.toLowerCase(),ii=/^\s*/g,oi=e=>e.replace(ii,""),ci=/([A-Z])/g,Xn=(e,t)=>oi(e.replace(ci,n=>`${t}${ri(n)}`)),li=e=>{const t=unescape(encodeURIComponent(e)),n=t.length,s=new Uint8Array(n);for(let r=0;r<n;r++)s[r]=t.codePointAt(r);return s},Yt=typeof TextEncoder<"u"?new TextEncoder:null,hi=e=>Yt.encode(e),ai=Yt?hi:li;let Jt=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});Jt&&Jt.decode(new Uint8Array).length===1&&(Jt=null);const _s=(e,t)=>ti(t,()=>e).join("");class oe{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const jt=()=>new oe,ui=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},z=e=>{const t=new Uint8Array(ui(e));let n=0;for(let s=0;s<e.bufs.length;s++){const r=e.bufs[s];t.set(r,n),n+=r.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},di=(e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(Tt(n,t)*2),e.cpos=0)},I=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t},Xt=I,p=(e,t)=>{for(;t>kt;)I(e,j|kt&t),t=q(t/128);I(e,kt&t)},Te=(e,t)=>{const n=ys(t);for(n&&(t=-t),I(e,(t>nn?j:0)|(n?et:0)|nn&t),t=q(t/64);t>0;)I(e,(t>kt?j:0)|kt&t),t=q(t/128)},sn=new Uint8Array(3e4),fi=sn.length/3,gi=(e,t)=>{if(t.length<fi){const n=Yt.encodeInto(t,sn).written||0;p(e,n);for(let s=0;s<n;s++)I(e,sn[s])}else V(e,ai(t))},pi=(e,t)=>{const n=unescape(encodeURIComponent(t)),s=n.length;p(e,s);for(let r=0;r<s;r++)I(e,n.codePointAt(r))},yt=Yt&&Yt.encodeInto?gi:pi,wi=(e,t)=>ce(e,z(t)),ce=(e,t)=>{const n=e.cbuf.length,s=e.cpos,r=ks(n-s,t.length),i=t.length-r;e.cbuf.set(t.subarray(0,r),s),e.cpos+=r,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(Tt(n*2,i)),e.cbuf.set(t.subarray(r)),e.cpos=i)},V=(e,t)=>{p(e,t.byteLength),ce(e,t)},wn=(e,t)=>{di(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},mi=(e,t)=>wn(e,4).setFloat32(0,t,!1),ki=(e,t)=>wn(e,8).setFloat64(0,t,!1),yi=(e,t)=>wn(e,8).setBigInt64(0,t,!1),Kn=new DataView(new ArrayBuffer(4)),_i=e=>(Kn.setFloat32(0,e),Kn.getFloat32(0)===e),Kt=(e,t)=>{switch(typeof t){case"string":I(e,119),yt(e,t);break;case"number":ni(t)&&ge(t)<=ei?(I(e,125),Te(e,t)):_i(t)?(I(e,124),mi(e,t)):(I(e,123),ki(e,t));break;case"bigint":I(e,122),yi(e,t);break;case"object":if(t===null)I(e,126);else if(Mt(t)){I(e,117),p(e,t.length);for(let n=0;n<t.length;n++)Kt(e,t[n])}else if(t instanceof Uint8Array)I(e,116),V(e,t);else{I(e,118);const n=Object.keys(t);p(e,n.length);for(let s=0;s<n.length;s++){const r=n[s];yt(e,r),Kt(e,t[r])}}break;case"boolean":I(e,t?120:121);break;default:I(e,127)}};class Wn extends oe{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&p(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}const qn=e=>{e.count>0&&(Te(e.encoder,e.count===1?e.s:-e.s),e.count>1&&p(e.encoder,e.count-2))};class pe{constructor(){this.encoder=new oe,this.s=0,this.count=0}write(t){this.s===t?this.count++:(qn(this),this.count=1,this.s=t)}toUint8Array(){return qn(this),z(this.encoder)}}const Pn=e=>{if(e.count>0){const t=e.diff*2+(e.count===1?0:1);Te(e.encoder,t),e.count>1&&p(e.encoder,e.count-2)}};class Ke{constructor(){this.encoder=new oe,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(Pn(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return Pn(this),z(this.encoder)}}class bi{constructor(){this.sarr=[],this.s="",this.lensE=new pe}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){const t=new oe;return this.sarr.push(this.s),this.s="",yt(t,this.sarr.join("")),ce(t,this.lensE.toUint8Array()),z(t)}}const P=e=>new Error(e),X=()=>{throw P("Method unimplemented")},v=()=>{throw P("Unexpected case")},bs=P("Unexpected end of array"),Ss=P("Integer out of Range");class xe{constructor(t){this.arr=t,this.pos=0}}const L=e=>new xe(e),Es=e=>e.pos!==e.arr.length,Si=(e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n},F=e=>Si(e,k(e)),Nt=e=>e.arr[e.pos++],k=e=>{let t=0,n=1;const s=e.arr.length;for(;e.pos<s;){const r=e.arr[e.pos++];if(t=t+(r&kt)*n,n*=128,r<j)return t;if(t>ye)throw Ss}throw bs},Oe=e=>{let t=e.arr[e.pos++],n=t&nn,s=64;const r=(t&et)>0?-1:1;if((t&j)===0)return r*n;const i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&kt)*s,s*=128,t<j)return r*n;if(n>ye)throw Ss}throw bs},Ei=e=>{let t=k(e);if(t===0)return"";{let n=String.fromCodePoint(Nt(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(Nt(e));else for(;t>0;){const s=t<1e4?t:1e4,r=e.arr.subarray(e.pos,e.pos+s);e.pos+=s,n+=String.fromCodePoint.apply(null,r),t-=s}return decodeURIComponent(escape(n))}},Ci=e=>Jt.decode(F(e)),_t=Jt?Ci:Ei,mn=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},Di=e=>mn(e,4).getFloat32(0,!1),Ai=e=>mn(e,8).getFloat64(0,!1),Ii=e=>mn(e,8).getBigInt64(0,!1),Ti=[e=>{},e=>null,Oe,Di,Ai,Ii,e=>!1,e=>!0,_t,e=>{const t=k(e),n={};for(let s=0;s<t;s++){const r=_t(e);n[r]=Wt(e)}return n},e=>{const t=k(e),n=[];for(let s=0;s<t;s++)n.push(Wt(e));return n},F],Wt=e=>Ti[127-Nt(e)](e);class Zn extends xe{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Es(this)?this.count=k(this)+1:this.count=-1),this.count--,this.s}}class we extends xe{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=Oe(this);const t=ys(this.s);this.count=1,t&&(this.s=-this.s,this.count=k(this)+2)}return this.count--,this.s}}class We extends xe{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const t=Oe(this),n=t&1;this.diff=q(t/2),this.count=1,n&&(this.count=k(this)+2)}return this.s+=this.diff,this.count--,this.s}}class xi{constructor(t){this.decoder=new we(t),this.str=_t(this.decoder),this.spos=0}read(){const t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}}const Oi=crypto.getRandomValues.bind(crypto),Cs=()=>Oi(new Uint32Array(1))[0],Ui="10000000-1000-4000-8000"+-1e11,vi=()=>Ui.replace(/[018]/g,e=>(e^Cs()&15>>e/4).toString(16)),Li=Date.now,Qn=e=>new Promise(e);Promise.all.bind(Promise);const ts=e=>e===void 0?null:e;class Mi{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}}let Ds=new Mi,Ni=!0;try{typeof localStorage<"u"&&localStorage&&(Ds=localStorage,Ni=!1)}catch{}const Ri=Ds,qt=Symbol("Equality"),As=(e,t)=>e===t||!!e?.[qt]?.(t)||!1,$i=e=>typeof e=="object",Vi=Object.assign,Fi=Object.keys,ji=(e,t)=>{for(const n in e)t(e[n],n)},_e=e=>Fi(e).length,Bi=e=>{for(const t in e)return!1;return!0},le=(e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0},kn=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),zi=(e,t)=>e===t||_e(e)===_e(t)&&le(e,(n,s)=>(n!==void 0||kn(t,s))&&As(t[s],n)),Gi=Object.freeze,Is=e=>{for(const t in e){const n=e[t];(typeof n=="object"||typeof n=="function")&&Is(e[t])}return Gi(e)},yn=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&yn(e,t,n+1)}},Ts=e=>e,me=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[qt]!=null)return e[qt](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!me(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(_e(e)!==_e(t))return!1;for(const n in e)if(!kn(e,n)||!me(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!me(e[n],t[n]))return!1;break;default:return!1}return!0},Ji=(e,t)=>t.includes(e);var xs={};const Pt=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]";let W;const Hi=()=>{if(W===void 0)if(Pt){W=T();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const s=e[n];s[0]==="-"?(t!==null&&W.set(t,""),t=s):t!==null&&(W.set(t,s),t=null)}t!==null&&W.set(t,"")}else typeof location=="object"?(W=T(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){const[t,n]=e.split("=");W.set(`--${Xn(t,"-")}`,n),W.set(`-${Xn(t,"-")}`,n)}})):W=T();return W},rn=e=>Hi().has(e),be=e=>ts(Pt?xs[e.toUpperCase().replaceAll("-","_")]:Ri.getItem(e)),Os=e=>rn("--"+e)||be(e)!==null,Yi=Os("production"),Xi=Pt&&Ji(xs.FORCE_COLOR,["true","1","2"]),Ki=Xi||!rn("--no-colors")&&!Os("no-color")&&(!Pt||process.stdout.isTTY)&&(!Pt||rn("--color")||be("COLORTERM")!==null||(be("TERM")||"").includes("color")),Wi=e=>new Uint8Array(e),qi=e=>{const t=Wi(e.byteLength);return t.set(e),t};class Pi{constructor(t,n){this.left=t,this.right=n}}const tt=(e,t)=>new Pi(e,t),Zi=(e,t)=>e.forEach(n=>t(n.left,n.right)),es=e=>e.next()>=.5,qe=(e,t,n)=>q(e.next()*(n+1-t)+t),Us=(e,t,n)=>q(e.next()*(n+1-t)+t),_n=(e,t,n)=>Us(e,t,n),Qi=e=>si(_n(e,97,122)),to=(e,t=0,n=20)=>{const s=_n(e,t,n);let r="";for(let i=0;i<s;i++)r+=Qi(e);return r},Pe=(e,t)=>t[_n(e,0,t.length-1)],eo=Symbol("0schema");class no{constructor(){this._rerrs=[]}extend(t,n,s,r=null){this._rerrs.push({path:t,expected:n,has:s,message:r})}toString(){const t=[];for(let n=this._rerrs.length-1;n>0;n--){const s=this._rerrs[n];t.push(_s(" ",(this._rerrs.length-n)*2)+`${s.path!=null?`[${s.path}] `:""}${s.has} doesn't match ${s.expected}. ${s.message}`)}return t.join(`
2
+ `)}}const on=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[qt]?As(e,t):Mt(e)?fn(e,n=>gn(t,s=>on(n,s))):$i(e)?le(e,(n,s)=>on(n,t[s])):!1;class N{static _dilutes=!1;extends(t){let[n,s]=[this.shape,t.shape];return this.constructor._dilutes&&([s,n]=[n,s]),on(n,s)}equals(t){return this.constructor===t.constructor&&me(this.shape,t.shape)}[eo](){return!0}[qt](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){X()}get nullable(){return Bt(this,Ne)}get optional(){return new Ms(this)}cast(t){return ns(t,this),t}expect(t){return ns(t,this),t}}class bn extends N{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){const s=t?.constructor===this.shape&&(this._c==null||this._c(t));return!s&&n?.extend(null,this.shape.name,t?.constructor.name,t?.constructor!==this.shape?"Constructor match failed":"Check failed"),s}}const D=(e,t=null)=>new bn(e,t);D(bn);class Sn extends N{constructor(t){super(),this.shape=t}check(t,n){const s=this.shape(t);return!s&&n?.extend(null,"custom prop",t?.constructor.name,"failed to check custom prop"),s}}const x=e=>new Sn(e);D(Sn);class Ue extends N{constructor(t){super(),this.shape=t}check(t,n){const s=this.shape.some(r=>r===t);return!s&&n?.extend(null,this.shape.join(" | "),t.toString()),s}}const ve=(...e)=>new Ue(e),vs=D(Ue),so=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Ls=e=>{if(Rt.check(e))return[so(e)];if(vs.check(e))return e.shape.map(t=>t+"");if(Gs.check(e))return["[+-]?\\d+.?\\d*"];if(Js.check(e))return[".*"];if(Se.check(e))return e.shape.map(Ls).flat(1);v()};class ro extends N{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(Ls).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){const s=this._r.exec(t)!=null;return!s&&n?.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),s}}D(ro);const io=Symbol("optional");class Ms extends N{constructor(t){super(),this.shape=t}check(t,n){const s=t===void 0||this.shape.check(t);return!s&&n?.extend(null,"undefined (optional)","()"),s}get[io](){return!0}}const oo=D(Ms);class co extends N{check(t,n){return n?.extend(null,"never",typeof t),!1}}D(co);class Le extends N{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}static _dilutes=!0;get partial(){return new Le(this.shape,!0)}check(t,n){return t==null?(n?.extend(null,"object","null"),!1):le(this.shape,(s,r)=>{const i=this._isPartial&&!kn(t,r)||s.check(t[r],n);return!i&&n?.extend(r.toString(),s.toString(),typeof t[r],"Object property does not match"),i})}}const lo=e=>new Le(e),ho=D(Le),ao=x(e=>e!=null&&(e.constructor===Object||e.constructor==null));class Ns extends N{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&le(t,(s,r)=>{const i=this.shape.keys.check(r,n);return!i&&n?.extend(r+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value"),i&&this.shape.values.check(s,n)})}}const Rs=(e,t)=>new Ns(e,t),uo=D(Ns);class $s extends N{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&le(this.shape,(s,r)=>{const i=s.check(t[r],n);return!i&&n?.extend(r.toString(),"Tuple",typeof s),i})}}const fo=(...e)=>new $s(e);D($s);class Vs extends N{constructor(t){super(),this.shape=t.length===1?t[0]:new En(t)}check(t,n){const s=Mt(t)&&fn(t,r=>this.shape.check(r));return!s&&n?.extend(null,"Array",""),s}}const Fs=(...e)=>new Vs(e),go=D(Vs),po=x(e=>Mt(e));class js extends N{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){const s=t instanceof this.shape&&(this._c==null||this._c(t));return!s&&n?.extend(null,this.shape.name,t?.constructor.name),s}}const wo=(e,t=null)=>new js(e,t);D(js);const mo=wo(N);class ko extends N{constructor(t){super(),this.len=t.length-1,this.args=fo(...t.slice(-1)),this.res=t[this.len]}check(t,n){const s=t.constructor===Function&&t.length<=this.len;return!s&&n?.extend(null,"function",typeof t),s}}const yo=D(ko),_o=x(e=>typeof e=="function");class bo extends N{constructor(t){super(),this.shape=t}check(t,n){const s=fn(this.shape,r=>r.check(t,n));return!s&&n?.extend(null,"Intersectinon",typeof t),s}}D(bo,e=>e.shape.length>0);class En extends N{static _dilutes=!0;constructor(t){super(),this.shape=t}check(t,n){const s=gn(this.shape,r=>r.check(t,n));return n?.extend(null,"Union",typeof t),s}}const Bt=(...e)=>e.findIndex(t=>Se.check(t))>=0?Bt(...e.map(t=>Zt(t)).map(t=>Se.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new En(e),Se=D(En),Bs=()=>!0,Ee=x(Bs),So=D(Sn,e=>e.shape===Bs),Cn=x(e=>typeof e=="bigint"),Eo=x(e=>e===Cn),zs=x(e=>typeof e=="symbol");x(e=>e===zs);const Lt=x(e=>typeof e=="number"),Gs=x(e=>e===Lt),Rt=x(e=>typeof e=="string"),Js=x(e=>e===Rt),Me=x(e=>typeof e=="boolean"),Co=x(e=>e===Me),Hs=ve(void 0);D(Ue,e=>e.shape.length===1&&e.shape[0]===void 0);ve(void 0);const Ne=ve(null),Do=D(Ue,e=>e.shape.length===1&&e.shape[0]===null);D(Uint8Array);D(bn,e=>e.shape===Uint8Array);const Ao=Bt(Lt,Rt,Ne,Hs,Cn,Me,zs);(()=>{const e=Fs(Ee),t=Rs(Rt,Ee),n=Bt(Lt,Rt,Ne,Me,e,t);return e.shape=n,t.shape.values=n,n})();const Zt=e=>{if(mo.check(e))return e;if(ao.check(e)){const t={};for(const n in e)t[n]=Zt(e[n]);return lo(t)}else{if(po.check(e))return Bt(...e.map(Zt));if(Ao.check(e))return ve(e);if(_o.check(e))return D(e)}v()},ns=Yi?()=>{}:(e,t)=>{const n=new no;if(!t.check(e,n))throw P(`Expected value to be of type ${t.constructor.name}.
3
+ ${n.toString()}`)};class Io{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Zt(t),h:n}),this}else(t){return this.if(Ee,t)}done(){return(t,n)=>{for(let s=0;s<this.patterns.length;s++){const r=this.patterns[s];if(r.if.check(t))return r.h(t,n)}throw P("Unhandled pattern")}}}const To=e=>new Io(e),Ys=To(Ee).if(Gs,(e,t)=>qe(t,Yn,ye)).if(Js,(e,t)=>to(t)).if(Co,(e,t)=>es(t)).if(Eo,(e,t)=>BigInt(qe(t,Yn,ye))).if(Se,(e,t)=>vt(t,Pe(t,e.shape))).if(ho,(e,t)=>{const n={};for(const s in e.shape){let r=e.shape[s];if(oo.check(r)){if(es(t))continue;r=r.shape}n[s]=Ys(r,t)}return n}).if(go,(e,t)=>{const n=[],s=Us(t,0,42);for(let r=0;r<s;r++)n.push(vt(t,e.shape));return n}).if(vs,(e,t)=>Pe(t,e.shape)).if(Do,(e,t)=>null).if(yo,(e,t)=>{const n=vt(t,e.res);return()=>n}).if(So,(e,t)=>vt(t,Pe(t,[Lt,Rt,Ne,Hs,Cn,Me,Fs(Lt),Rs(Bt("a","b","c"),Lt)]))).if(uo,(e,t)=>{const n={},s=qe(t,0,3);for(let r=0;r<s;r++){const i=vt(t,e.shape.keys),o=vt(t,e.shape.values);n[i]=o}return n}).done(),vt=(e,t)=>Ys(Zt(t),e),Q=typeof document<"u"?document:{},xo=e=>Q.createElement(e),Oo=()=>Q.createDocumentFragment();x(e=>e.nodeType===Fo);const Uo=e=>Q.createTextNode(e);typeof DOMParser<"u"&&new DOMParser;const vo=(e,t)=>(Zi(t,(n,s)=>{s===!1?e.removeAttribute(n):s===!0?e.setAttribute(n,""):e.setAttribute(n,s)}),e),Lo=e=>{const t=Oo();for(let n=0;n<e.length;n++)Xs(t,e[n]);return t},Mo=(e,t)=>(Xs(e,Lo(t)),e),Ul=(e,t=[],n=[])=>Mo(vo(xo(e),t),n);x(e=>e.nodeType===Ro);const vl=Uo;x(e=>e.nodeType===$o);const No=e=>Pr(e,(t,n)=>`${n}:${t};`).join(""),Xs=(e,t)=>e.appendChild(t),Ro=Q.ELEMENT_NODE,$o=Q.TEXT_NODE;Q.CDATA_SECTION_NODE;Q.COMMENT_NODE;const Vo=Q.DOCUMENT_NODE;Q.DOCUMENT_TYPE_NODE;const Fo=Q.DOCUMENT_FRAGMENT_NODE;x(e=>e.nodeType===Vo);const ot=Symbol,Ks=ot(),Ws=ot(),jo=ot(),Bo=ot(),zo=ot(),qs=ot(),Go=ot(),Dn=ot(),Jo=ot(),Ho=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[];let s=0;for(;s<e.length;s++){const r=e[s];if(r===void 0)break;if(r.constructor===String||r.constructor===Number)t.push(r);else if(r.constructor===Object)break}for(s>0&&n.push(t.join(""));s<e.length;s++){const r=e[s];r instanceof Symbol||n.push(r)}return n},Yo={[Ks]:tt("font-weight","bold"),[Ws]:tt("font-weight","normal"),[jo]:tt("color","blue"),[zo]:tt("color","green"),[Bo]:tt("color","grey"),[qs]:tt("color","red"),[Go]:tt("color","purple"),[Dn]:tt("color","orange"),[Jo]:tt("color","black")},Xo=e=>{e.length===1&&e[0]?.constructor===Function&&(e=e[0]());const t=[],n=[],s=T();let r=[],i=0;for(;i<e.length;i++){const o=e[i],c=Yo[o];if(c!==void 0)s.set(c.left,c.right);else{if(o===void 0)break;if(o.constructor===String||o.constructor===Number){const l=No(s);i>0||l.length>0?(t.push("%c"+o),n.push(l)):t.push(o)}else break}}for(i>0&&(r=n,r.unshift(t.join("")));i<e.length;i++){const o=e[i];o instanceof Symbol||r.push(o)}return r},Ps=Ki?Xo:Ho,cn=(...e)=>{console.log(...Ps(e)),Qs.forEach(t=>t.print(e))},Zs=(...e)=>{console.warn(...Ps(e)),e.unshift(Dn),Qs.forEach(t=>t.print(e))},Qs=Et(),tr=e=>({[Symbol.iterator](){return this},next:e}),Ko=(e,t)=>tr(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Ze=(e,t)=>tr(()=>{const{done:n,value:s}=e.next();return{done:n,value:n?void 0:t(s)}});class Wo extends pn{constructor(t,n){super(),this.doc=t,this.awareness=n}}class Re{constructor(t,n){this.clock=t,this.len=n}}class zt{constructor(){this.clients=new Map}}const Ct=(e,t,n)=>t.clients.forEach((s,r)=>{const i=e.doc.store.clients.get(r);if(i!=null){const o=i[i.length-1],c=o.id.clock+o.length;for(let l=0,a=s[l];l<s.length&&a.clock<c;a=s[++l])dr(e,i,a.clock,a.len,n)}}),qo=(e,t)=>{let n=0,s=e.length-1;for(;n<=s;){const r=q((n+s)/2),i=e[r],o=i.clock;if(o<=t){if(t<o+i.len)return r;n=r+1}else s=r-1}return null},xt=(e,t)=>{const n=e.clients.get(t.client);return n!==void 0&&qo(n,t.clock)!==null},An=e=>{e.clients.forEach(t=>{t.sort((r,i)=>r.clock-i.clock);let n,s;for(n=1,s=1;n<t.length;n++){const r=t[s-1],i=t[n];r.clock+r.len>=i.clock?t[s-1]=new Re(r.clock,Tt(r.len,i.clock+i.len-r.clock)):(s<n&&(t[s]=i),s++)}t.length=s})},Dt=e=>{const t=new zt;for(let n=0;n<e.length;n++)e[n].clients.forEach((s,r)=>{if(!t.clients.has(r)){const i=s.slice();for(let o=n+1;o<e.length;o++)Qr(i,e[o].clients.get(r)||[]);t.clients.set(r,i)}});return An(t),t},Qt=(e,t,n,s)=>{R(e.clients,t,()=>[]).push(new Re(n,s))},$e=()=>new zt,In=e=>{const t=$e();return e.clients.forEach((n,s)=>{const r=[];for(let i=0;i<n.length;i++){const o=n[i];if(o.deleted){const c=o.id.clock;let l=o.length;if(i+1<n.length)for(let a=n[i+1];i+1<n.length&&a.deleted;a=n[++i+1])l+=a.length;r.push(new Re(c,l))}}r.length>0&&t.clients.set(s,r)}),t},Z=(e,t)=>{p(e.restEncoder,t.clients.size),st(t.clients.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{e.resetDsCurVal(),p(e.restEncoder,n);const r=s.length;p(e.restEncoder,r);for(let i=0;i<r;i++){const o=s[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},rt=e=>{const t=new zt,n=k(e.restDecoder);for(let s=0;s<n;s++){e.resetDsCurVal();const r=k(e.restDecoder),i=k(e.restDecoder);if(i>0){const o=R(t.clients,r,()=>[]);for(let c=0;c<i;c++)o.push(new Re(e.readDsClock(),e.readDsLen()))}}return t},ss=(e,t,n)=>{const s=new zt,r=k(e.restDecoder);for(let i=0;i<r;i++){e.resetDsCurVal();const o=k(e.restDecoder),c=k(e.restDecoder),l=n.clients.get(o)||[],a=E(n,o);for(let h=0;h<c;h++){const u=e.readDsClock(),d=u+e.readDsLen();if(u<a){a<d&&Qt(s,o,a,d-a);let f=G(l,u),g=l[f];for(!g.deleted&&g.id.clock<u&&(l.splice(f+1,0,Ae(t,g,u-g.id.clock)),f++);f<l.length&&(g=l[f++],g.id.clock<d);)g.deleted||(d<g.id.clock+g.length&&l.splice(f,0,Ae(t,g,d-g.id.clock)),g.delete(t))}else Qt(s,o,u,d-u)}}if(s.clients.size>0){const i=new K;return p(i.restEncoder,0),Z(i,s),i.toUint8Array()}return null},er=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(const[n,s]of e.clients.entries()){const r=t.clients.get(n);if(r===void 0||s.length!==r.length)return!1;for(let i=0;i<s.length;i++){const o=s[i],c=r[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},nr=Cs;class gt extends pn{constructor({guid:t=vi(),collectionid:n=null,gc:s=!0,gcFilter:r=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=s,this.gcFilter=r,this.clientID=nr(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new ar,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=Qn(a=>{this.on("load",()=>{this.isLoaded=!0,a(this)})});const l=()=>Qn(a=>{const h=u=>{(u===void 0||u===!0)&&(this.off("sync",h),a())};this.on("sync",h)});this.on("sync",a=>{a===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=a===void 0||a===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const t=this._item;t!==null&&!this.shouldLoad&&_(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(st(this.subdocs).map(t=>t.guid))}transact(t,n=null){return _(this,t,n)}get(t,n=A){const s=R(this.share,t,()=>{const i=new n;return i._integrate(this,null),i}),r=s.constructor;if(n!==A&&r!==n)if(r===A){const i=new n;i._map=s._map,s._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=s._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=s._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return s}getArray(t=""){return this.get(t,nt)}getText(t=""){return this.get(t,At)}getMap(t=""){return this.get(t,ut)}getXmlElement(t=""){return this.get(t,ft)}getXmlFragment(t=""){return this.get(t,dt)}toJSON(){const t={};return this.share.forEach((n,s)=>{t[s]=n.toJSON()}),t}destroy(){this.isDestroyed=!0,st(this.subdocs).forEach(n=>n.destroy());const t=this._item;if(t!==null){this._item=null;const n=t.content;n.doc=new gt({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,_(t.parent.doc,s=>{const r=n.doc;t.deleted||s.subdocsAdded.add(r),s.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class te{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return k(this.restDecoder)}readDsLen(){return k(this.restDecoder)}}class H extends te{readLeftID(){return w(k(this.restDecoder),k(this.restDecoder))}readRightID(){return w(k(this.restDecoder),k(this.restDecoder))}readClient(){return k(this.restDecoder)}readInfo(){return Nt(this.restDecoder)}readString(){return _t(this.restDecoder)}readParentInfo(){return k(this.restDecoder)===1}readTypeRef(){return k(this.restDecoder)}readLen(){return k(this.restDecoder)}readAny(){return Wt(this.restDecoder)}readBuf(){return qi(F(this.restDecoder))}readJSON(){return JSON.parse(_t(this.restDecoder))}readKey(){return _t(this.restDecoder)}}class sr{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=k(this.restDecoder),this.dsCurrVal}readDsLen(){const t=k(this.restDecoder)+1;return this.dsCurrVal+=t,t}}class B extends sr{constructor(t){super(t),this.keys=[],k(t),this.keyClockDecoder=new We(F(t)),this.clientDecoder=new we(F(t)),this.leftClockDecoder=new We(F(t)),this.rightClockDecoder=new We(F(t)),this.infoDecoder=new Zn(F(t),Nt),this.stringDecoder=new xi(F(t)),this.parentInfoDecoder=new Zn(F(t),Nt),this.typeRefDecoder=new we(F(t)),this.lenDecoder=new we(F(t))}readLeftID(){return new bt(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new bt(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Wt(this.restDecoder)}readBuf(){return F(this.restDecoder)}readJSON(){return Wt(this.restDecoder)}readKey(){const t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class $t{constructor(){this.restEncoder=jt()}toUint8Array(){return z(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){p(this.restEncoder,t)}writeDsLen(t){p(this.restEncoder,t)}}class pt extends $t{writeLeftID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeRightID(t){p(this.restEncoder,t.client),p(this.restEncoder,t.clock)}writeClient(t){p(this.restEncoder,t)}writeInfo(t){Xt(this.restEncoder,t)}writeString(t){yt(this.restEncoder,t)}writeParentInfo(t){p(this.restEncoder,t?1:0)}writeTypeRef(t){p(this.restEncoder,t)}writeLen(t){p(this.restEncoder,t)}writeAny(t){Kt(this.restEncoder,t)}writeBuf(t){V(this.restEncoder,t)}writeJSON(t){yt(this.restEncoder,JSON.stringify(t))}writeKey(t){yt(this.restEncoder,t)}}class Ve{constructor(){this.restEncoder=jt(),this.dsCurrVal=0}toUint8Array(){return z(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){const n=t-this.dsCurrVal;this.dsCurrVal=t,p(this.restEncoder,n)}writeDsLen(t){t===0&&v(),p(this.restEncoder,t-1),this.dsCurrVal+=t}}class K extends Ve{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ke,this.clientEncoder=new pe,this.leftClockEncoder=new Ke,this.rightClockEncoder=new Ke,this.infoEncoder=new Wn(Xt),this.stringEncoder=new bi,this.parentInfoEncoder=new Wn(Xt),this.typeRefEncoder=new pe,this.lenEncoder=new pe}toUint8Array(){const t=jt();return p(t,0),V(t,this.keyClockEncoder.toUint8Array()),V(t,this.clientEncoder.toUint8Array()),V(t,this.leftClockEncoder.toUint8Array()),V(t,this.rightClockEncoder.toUint8Array()),V(t,z(this.infoEncoder)),V(t,this.stringEncoder.toUint8Array()),V(t,z(this.parentInfoEncoder)),V(t,this.typeRefEncoder.toUint8Array()),V(t,this.lenEncoder.toUint8Array()),ce(t,z(this.restEncoder)),z(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){Kt(this.restEncoder,t)}writeBuf(t){V(this.restEncoder,t)}writeJSON(t){Kt(this.restEncoder,t)}writeKey(t){const n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}}const Po=(e,t,n,s)=>{s=Tt(s,t[0].id.clock);const r=G(t,s);p(e.restEncoder,t.length-r),e.writeClient(n),p(e.restEncoder,s);const i=t[r];i.write(e,s-i.id.clock);for(let o=r+1;o<t.length;o++)t[o].write(e,0)},Tn=(e,t,n)=>{const s=new Map;n.forEach((r,i)=>{E(t,i)>r&&s.set(i,r)}),he(t).forEach((r,i)=>{n.has(i)||s.set(i,0)}),p(e.restEncoder,s.size),st(s.entries()).sort((r,i)=>i[0]-r[0]).forEach(([r,i])=>{Po(e,t.clients.get(r),r,i)})},Zo=(e,t)=>{const n=T(),s=k(e.restDecoder);for(let r=0;r<s;r++){const i=k(e.restDecoder),o=new Array(i),c=e.readClient();let l=k(e.restDecoder);n.set(c,{i:0,refs:o});for(let a=0;a<i;a++){const h=e.readInfo();switch(Ie&h){case 0:{const u=e.readLen();o[a]=new $(w(c,l),u),l+=u;break}case 10:{const u=k(e.restDecoder);o[a]=new M(w(c,l),u),l+=u;break}default:{const u=(h&(et|j))===0,d=new y(w(c,l),null,(h&j)===j?e.readLeftID():null,null,(h&et)===et?e.readRightID():null,u?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,u&&(h&Ht)===Ht?e.readString():null,Kr(e,h));o[a]=d,l+=d.length}}}}return n},Qo=(e,t,n)=>{const s=[];let r=st(n.keys()).sort((f,g)=>f-g);if(r.length===0)return null;const i=()=>{if(r.length===0)return null;let f=n.get(r[r.length-1]);for(;f.refs.length===f.i;)if(r.pop(),r.length>0)f=n.get(r[r.length-1]);else return null;return f};let o=i();if(o===null)return null;const c=new ar,l=new Map,a=(f,g)=>{const m=l.get(f);(m==null||m>g)&&l.set(f,g)};let h=o.refs[o.i++];const u=new Map,d=()=>{for(const f of s){const g=f.id.client,m=n.get(g);m?(m.i--,c.clients.set(g,m.refs.slice(m.i)),n.delete(g),m.i=0,m.refs=[]):c.clients.set(g,[f]),r=r.filter(b=>b!==g)}s.length=0};for(;;){if(h.constructor!==M){const g=R(u,h.id.client,()=>E(t,h.id.client))-h.id.clock;if(g<0)s.push(h),a(h.id.client,h.id.clock-1),d();else{const m=h.getMissing(e,t);if(m!==null){s.push(h);const b=n.get(m)||{refs:[],i:0};if(b.refs.length===b.i)a(m,E(t,m)),d();else{h=b.refs[b.i++];continue}}else(g===0||g<h.length)&&(h.integrate(e,g),u.set(h.id.client,h.id.clock+h.length))}}if(s.length>0)h=s.pop();else if(o!==null&&o.i<o.refs.length)h=o.refs[o.i++];else{if(o=i(),o===null)break;h=o.refs[o.i++]}}if(c.clients.size>0){const f=new K;return Tn(f,c,new Map),p(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},tc=(e,t)=>Tn(e,t.doc.store,t.beforeState),xn=(e,t,n,s=new B(e))=>_(t,r=>{r.local=!1;let i=!1;const o=r.doc,c=o.store,l=Zo(s,o),a=Qo(r,c,l),h=c.pendingStructs;if(h){for(const[d,f]of h.missing)if(f<E(c,d)){i=!0;break}if(a){for(const[d,f]of a.missing){const g=h.missing.get(d);(g==null||g>f)&&h.missing.set(d,f)}h.update=ne([h.update,a.update])}}else c.pendingStructs=a;const u=ss(s,r,c);if(c.pendingDs){const d=new B(L(c.pendingDs));k(d.restDecoder);const f=ss(d,r,c);u&&f?c.pendingDs=ne([u,f]):c.pendingDs=u||f}else c.pendingDs=u;if(i){const d=c.pendingStructs.update;c.pendingStructs=null,Fe(r.doc,d)}},n,!1),ec=(e,t,n)=>xn(e,t,n,new H(e)),Fe=(e,t,n,s=B)=>{const r=L(t);xn(r,e,n,new s(r))},nc=(e,t,n)=>Fe(e,t,n,H),sc=(e,t,n=new Map)=>{Tn(e,t.store,n),Z(e,In(t.store))},rr=(e,t=new Uint8Array([0]),n=new K)=>{const s=On(t);sc(n,e,s);const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(Rn(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===pt)return yr(r.map((i,o)=>o===0?i:Cr(i)));if(n.constructor===K)return ne(r)}return r[0]},rc=(e,t)=>rr(e,t,new pt),ir=e=>{const t=new Map,n=k(e.restDecoder);for(let s=0;s<n;s++){const r=k(e.restDecoder),i=k(e.restDecoder);t.set(r,i)}return t},On=e=>ir(new te(L(e))),Un=(e,t)=>(p(e.restEncoder,t.size),st(t.entries()).sort((n,s)=>s[0]-n[0]).forEach(([n,s])=>{p(e.restEncoder,n),p(e.restEncoder,s)}),e),ic=(e,t)=>Un(e,he(t.store)),oc=(e,t=new Ve)=>(e instanceof Map?Un(t,e):ic(t,e),t.toUint8Array()),cc=e=>oc(e,new $t);class lc{constructor(){this.l=[]}}const rs=()=>new lc,is=(e,t)=>e.l.push(t),os=(e,t)=>{const n=e.l,s=n.length;e.l=n.filter(r=>t!==r),s===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},or=(e,t,n)=>yn(e.l,[t,n]);class bt{constructor(t,n){this.client=t,this.clock=n}}const mt=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,w=(e,t)=>new bt(e,t),cs=(e,t)=>{p(e,t.client),p(e,t.clock)},ls=e=>w(k(e),k(e)),vn=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw v()},ee=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},hc=e=>{const t=[];let n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(s=>!s.deleted).map(s=>s.content))};class ac{constructor(t,n=t.getMap("users")){const s=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=s;const r=(i,o)=>{const c=i.get("ds"),l=i.get("ids"),a=h=>this.clients.set(h,o);c.observe(h=>{h.changes.added.forEach(u=>{u.content.getContent().forEach(d=>{d instanceof Uint8Array&&this.dss.set(o,Dt([this.dss.get(o)||$e(),rt(new te(L(d)))]))})})}),this.dss.set(o,Dt(c.map(h=>rt(new te(L(h)))))),l.observe(h=>h.changes.added.forEach(u=>u.content.getContent().forEach(a))),l.forEach(a)};n.observe(i=>{i.keysChanged.forEach(o=>r(n.get(o),o))}),n.forEach(r)}setUserMapping(t,n,s,{filter:r=()=>!0}={}){const i=this.yusers;let o=i.get(s);o||(o=new ut,o.set("ids",new nt),o.set("ds",new nt),i.set(s,o)),o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{const l=i.get(s);if(l!==o){o=l,this.clients.forEach((u,d)=>{s===u&&o.get("ids").push([d])});const a=new $t,h=this.dss.get(s);h&&(Z(a,h),o.get("ds").push([a.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{const l=o.get("ds"),a=c.deleteSet;if(c.local&&a.clients.size>0&&r(c,a)){const h=new $t;Z(h,a),l.push([h.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(const[n,s]of this.dss.entries())if(xt(s,t))return n;return null}}class je{constructor(t,n,s,r=0){this.type=t,this.tname=n,this.item=s,this.assoc=r}}const uc=e=>{const t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},dc=e=>new je(e.type==null?null:w(e.type.client,e.type.clock),e.tname??null,e.item==null?null:w(e.item.client,e.item.clock),e.assoc==null?0:e.assoc);class cr{constructor(t,n,s=0){this.type=t,this.index=n,this.assoc=s}}const fc=(e,t,n=0)=>new cr(e,t,n),ue=(e,t,n)=>{let s=null,r=null;return e._item===null?r=vn(e):s=w(e._item.id.client,e._item.id.clock),new je(s,r,t,n)},gc=(e,t,n=0)=>{let s=e._start;if(n<0){if(t===0)return ue(e,null,n);t--}for(;s!==null;){if(!s.deleted&&s.countable){if(s.length>t)return ue(e,w(s.id.client,s.id.clock+t),n);t-=s.length}if(s.right===null&&n<0)return ue(e,s.lastId,n);s=s.right}return ue(e,null,n)},pc=(e,t)=>{const{type:n,tname:s,item:r,assoc:i}=t;if(r!==null)p(e,0),cs(e,r);else if(s!==null)Xt(e,1),yt(e,s);else if(n!==null)Xt(e,2),cs(e,n);else throw v();return Te(e,i),e},wc=e=>{const t=jt();return pc(t,e),z(t)},mc=e=>{let t=null,n=null,s=null;switch(k(e)){case 0:s=ls(e);break;case 1:n=_t(e);break;case 2:t=ls(e)}const r=Es(e)?Oe(e):0;return new je(t,n,s,r)},kc=e=>mc(L(e)),yc=(e,t)=>{const n=St(e,t),s=t.clock-n.id.clock;return{item:n,diff:s}},_c=(e,t,n=!0)=>{const s=t.store,r=e.item,i=e.type,o=e.tname,c=e.assoc;let l=null,a=0;if(r!==null){if(E(s,r.client)<=r.clock)return null;const h=n?dn(s,r):yc(s,r),u=h.item;if(!(u instanceof y))return null;if(l=u.parent,l._item===null||!l._item.deleted){a=u.deleted||!u.countable?0:h.diff+(c>=0?0:1);let d=u.left;for(;d!==null;)!d.deleted&&d.countable&&(a+=d.length),d=d.left}}else{if(o!==null)l=t.get(o);else if(i!==null){if(E(s,i.client)<=i.clock)return null;const{item:h}=n?dn(s,i):{item:St(s,i)};if(h instanceof y&&h.content instanceof Y)l=h.content.type;else return null}else throw v();c>=0?a=l._length:a=0}return fc(l,a,e.assoc)},bc=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&mt(e.item,t.item)&&mt(e.type,t.type)&&e.assoc===t.assoc;class Ln{constructor(t,n){this.ds=t,this.sv=n}}const Sc=(e,t)=>{const n=e.ds.clients,s=t.ds.clients,r=e.sv,i=t.sv;if(r.size!==i.size||n.size!==s.size)return!1;for(const[o,c]of r.entries())if(i.get(o)!==c)return!1;for(const[o,c]of n.entries()){const l=s.get(o)||[];if(c.length!==l.length)return!1;for(let a=0;a<c.length;a++){const h=c[a],u=l[a];if(h.clock!==u.clock||h.len!==u.len)return!1}}return!0},lr=(e,t=new Ve)=>(Z(t,e.ds),Un(t,e.sv),t.toUint8Array()),Ec=e=>lr(e,new $t),hr=(e,t=new sr(L(e)))=>new Ln(rt(t),ir(t)),Cc=e=>hr(e,new te(L(e))),Mn=(e,t)=>new Ln(e,t),Dc=Mn($e(),new Map),Ac=e=>Mn(In(e.store),he(e.store)),lt=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!xt(t.ds,e.id),ln=(e,t)=>{const n=R(e.meta,ln,Et),s=e.doc.store;n.has(t)||(t.sv.forEach((r,i)=>{r<E(s,i)&&U(e,w(i,r))}),Ct(e,t.ds,r=>{}),n.add(t))},Ic=(e,t,n=new gt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");const{sv:s,ds:r}=t,i=new K;return e.transact(o=>{let c=0;s.forEach(l=>{l>0&&c++}),p(i.restEncoder,c);for(const[l,a]of s){if(a===0)continue;a<E(e.store,l)&&U(o,w(l,a));const h=e.store.clients.get(l)||[],u=G(h,a-1);p(i.restEncoder,u+1),i.writeClient(l),p(i.restEncoder,0);for(let d=0;d<=u;d++)h[d].write(i,0)}Z(i,r)}),Fe(n,i.toUint8Array(),"snapshot"),n},Tc=(e,t,n=B)=>{const s=new n(L(t)),r=new wt(s,!1);for(let o=r.curr;o!==null;o=r.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;const i=Dt([e.ds,rt(s)]);return er(e.ds,i)},xc=(e,t)=>Tc(e,t,H);class ar{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const he=e=>{const t=new Map;return e.clients.forEach((n,s)=>{const r=n[n.length-1];t.set(s,r.id.clock+r.length)}),t},E=(e,t)=>{const n=e.clients.get(t);if(n===void 0)return 0;const s=n[n.length-1];return s.id.clock+s.length},ur=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{const s=n[n.length-1];if(s.id.clock+s.length!==t.id.clock)throw v()}n.push(t)},G=(e,t)=>{let n=0,s=e.length-1,r=e[s],i=r.id.clock;if(i===t)return s;let o=q(t/(i+r.length-1)*s);for(;n<=s;){if(r=e[o],i=r.id.clock,i<=t){if(t<i+r.length)return o;n=o+1}else s=o-1;o=q((n+s)/2)}throw v()},Oc=(e,t)=>{const n=e.clients.get(t.client);return n[G(n,t.clock)]},St=Oc,hn=(e,t,n)=>{const s=G(t,n),r=t[s];return r.id.clock<n&&r instanceof y?(t.splice(s+1,0,Ae(e,r,n-r.id.clock)),s+1):s},U=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[hn(e,n,t.clock)]},an=(e,t,n)=>{const s=t.clients.get(n.client),r=G(s,n.clock),i=s[r];return n.clock!==i.id.clock+i.length-1&&i.constructor!==$&&s.splice(r+1,0,Ae(e,i,n.clock-i.id.clock+1)),i},Uc=(e,t,n)=>{const s=e.clients.get(t.id.client);s[G(s,t.id.clock)]=n},dr=(e,t,n,s,r)=>{if(s===0)return;const i=n+s;let o=hn(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&hn(e,t,i),r(c);while(o<t.length&&t[o].id.clock<i)};class fr{constructor(t,n,s){this.doc=t,this.deleteSet=new zt,this.beforeState=he(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=s,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const hs=(e,t)=>t.deleteSet.clients.size===0&&!Zr(t.afterState,(n,s)=>t.beforeState.get(s)!==n)?!1:(An(t.deleteSet),tc(e,t),Z(e,t.deleteSet),!0),as=(e,t,n)=>{const s=t._item;(s===null||s.id.clock<(e.beforeState.get(s.id.client)||0)&&!s.deleted)&&R(e.changed,t,Et).add(n)},ke=(e,t)=>{let n=e[t],s=e[t-1],r=t;for(;r>0;n=s,s=e[--r-1]){if(s.deleted===n.deleted&&s.constructor===n.constructor&&s.mergeWith(n)){n instanceof y&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,s);continue}break}const i=t-r;return i&&e.splice(t+1-i,i),i},gr=(e,t,n)=>{for(const[s,r]of e.clients.entries()){const i=t.clients.get(s);for(let o=r.length-1;o>=0;o--){const c=r[o],l=c.clock+c.len;for(let a=G(i,c.clock),h=i[a];a<i.length&&h.id.clock<l;h=i[++a]){const u=i[a];if(c.clock+c.len<=u.id.clock)break;u instanceof y&&u.deleted&&!u.keep&&n(u)&&u.gc(t,!1)}}}},pr=(e,t)=>{e.clients.forEach((n,s)=>{const r=t.clients.get(s);for(let i=n.length-1;i>=0;i--){const o=n[i],c=ks(r.length-1,1+G(r,o.clock+o.len-1));for(let l=c,a=r[l];l>0&&a.id.clock>=o.clock;a=r[l])l-=1+ke(r,l)}})},vc=(e,t,n)=>{gr(e,t,n),pr(e,t)},wr=(e,t)=>{if(t<e.length){const n=e[t],s=n.doc,r=s.store,i=n.deleteSet,o=n._mergeStructs;try{An(i),n.afterState=he(n.doc.store),s.emit("beforeObserverCalls",[n,s]);const c=[];n.changed.forEach((l,a)=>c.push(()=>{(a._item===null||!a._item.deleted)&&a._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,a)=>{a._dEH.l.length>0&&(a._item===null||!a._item.deleted)&&(l=l.filter(h=>h.target._item===null||!h.target._item.deleted),l.forEach(h=>{h.currentTarget=a,h._path=null}),l.sort((h,u)=>h.path.length-u.path.length),c.push(()=>{or(a._dEH,l,n)}))}),c.push(()=>s.emit("afterTransaction",[n,s])),c.push(()=>{n._needFormattingCleanup&&sl(n)})}),yn(c,[])}finally{s.gc&&gr(i,r,s.gcFilter),pr(i,r),n.afterState.forEach((h,u)=>{const d=n.beforeState.get(u)||0;if(d!==h){const f=r.clients.get(u),g=Tt(G(f,d),1);for(let m=f.length-1;m>=g;)m-=1+ke(f,m)}});for(let h=o.length-1;h>=0;h--){const{client:u,clock:d}=o[h].id,f=r.clients.get(u),g=G(f,d);g+1<f.length&&ke(f,g+1)>1||g>0&&ke(f,g)}if(!n.local&&n.afterState.get(s.clientID)!==n.beforeState.get(s.clientID)&&(cn(Dn,Ks,"[yjs] ",Ws,qs,"Changed the client-id because another client seems to be using it."),s.clientID=nr()),s.emit("afterTransactionCleanup",[n,s]),s._observers.has("update")){const h=new pt;hs(h,n)&&s.emit("update",[h.toUint8Array(),n.origin,s,n])}if(s._observers.has("updateV2")){const h=new K;hs(h,n)&&s.emit("updateV2",[h.toUint8Array(),n.origin,s,n])}const{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:a}=n;(c.size>0||a.size>0||l.size>0)&&(c.forEach(h=>{h.clientID=s.clientID,h.collectionid==null&&(h.collectionid=s.collectionid),s.subdocs.add(h)}),a.forEach(h=>s.subdocs.delete(h)),s.emit("subdocs",[{loaded:l,added:c,removed:a},s,n]),a.forEach(h=>h.destroy())),e.length<=t+1?(s._transactionCleanups=[],s.emit("afterAllTransactions",[s,e])):wr(e,t+1)}}},_=(e,t,n=null,s=!0)=>{const r=e._transactionCleanups;let i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new fr(e,n,s),r.push(e._transaction),r.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){const c=e._transaction===r[0];e._transaction=null,c&&wr(r,0)}}return o};class Lc{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}}const us=(e,t,n)=>{Ct(e,n.deletions,s=>{s instanceof y&&t.scope.some(r=>r===e.doc||ee(r,s))&&Bn(s,!1)})},ds=(e,t,n)=>{let s=null;const r=e.doc,i=e.scope;_(r,c=>{for(;t.length>0&&e.currStackItem===null;){const l=r.store,a=t.pop(),h=new Set,u=[];let d=!1;Ct(c,a.insertions,f=>{if(f instanceof y){if(f.redone!==null){let{item:g,diff:m}=dn(l,f.id);m>0&&(g=U(c,w(g.id.client,g.id.clock+m))),f=g}!f.deleted&&i.some(g=>g===c.doc||ee(g,f))&&u.push(f)}}),Ct(c,a.deletions,f=>{f instanceof y&&i.some(g=>g===c.doc||ee(g,f))&&!xt(a.insertions,f.id)&&h.add(f)}),h.forEach(f=>{d=Xr(c,f,h,a.insertions,e.ignoreRemoteMapChanges,e)!==null||d});for(let f=u.length-1;f>=0;f--){const g=u[f];e.deleteFilter(g)&&(g.delete(c),d=!0)}e.currStackItem=d?a:null}c.changed.forEach((l,a)=>{l.has(null)&&a._searchMarker&&(a._searchMarker.length=0)}),s=c},e);const o=e.currStackItem;if(o!=null){const c=s.changedParentTypes;e.emit("stack-item-popped",[{stackItem:o,type:n,changedParentTypes:c,origin:e},e]),e.currStackItem=null}return o};class Mc extends pn{constructor(t,{captureTimeout:n=500,captureTransaction:s=l=>!0,deleteFilter:r=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=Mt(t)?t[0].doc:t instanceof gt?t:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=r,i.add(this),this.trackedOrigins=i,this.captureTransaction=s,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(b=>l.changedParentTypes.has(b)||b===this.doc)||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const a=this.undoing,h=this.redoing,u=a?this.redoStack:this.undoStack;a?this.stopCapturing():h||this.clear(!1,!0);const d=new zt;l.afterState.forEach((b,S)=>{const zn=l.beforeState.get(S)||0,Gn=b-zn;Gn>0&&Qt(d,S,zn,Gn)});const f=Li();let g=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&u.length>0&&!a&&!h){const b=u[u.length-1];b.deletions=Dt([b.deletions,l.deleteSet]),b.insertions=Dt([b.insertions,d])}else u.push(new Lc(l.deleteSet,d)),g=!0;!a&&!h&&(this.lastChange=f),Ct(l,l.deleteSet,b=>{b instanceof y&&this.scope.some(S=>S===l.doc||ee(S,b))&&Bn(b,!0)});const m=[{stackItem:u[u.length-1],origin:l.origin,type:a?"redo":"undo",changedParentTypes:l.changedParentTypes},this];g?this.emit("stack-item-added",m):this.emit("stack-item-updated",m)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){const n=new Set(this.scope);t=Mt(t)?t:[t],t.forEach(s=>{n.has(s)||(n.add(s),(s instanceof A?s.doc!==this.doc:s!==this.doc)&&Zs("[yjs#509] Not same Y.Doc"),this.scope.push(s))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(s=>{t&&(this.undoStack.forEach(r=>us(s,this,r)),this.undoStack=[]),n&&(this.redoStack.forEach(r=>us(s,this,r)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=ds(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=ds(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*Nc(e){const t=k(e.restDecoder);for(let n=0;n<t;n++){const s=k(e.restDecoder),r=e.readClient();let i=k(e.restDecoder);for(let o=0;o<s;o++){const c=e.readInfo();if(c===10){const l=k(e.restDecoder);yield new M(w(r,i),l),i+=l}else if((Ie&c)!==0){const l=(c&(et|j))===0,a=new y(w(r,i),null,(c&j)===j?e.readLeftID():null,null,(c&et)===et?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&Ht)===Ht?e.readString():null,Kr(e,c));yield a,i+=a.length}else{const l=e.readLen();yield new $(w(r,i),l),i+=l}}}}class wt{constructor(t,n){this.gen=Nc(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===M);return this.curr}}const Rc=e=>mr(e,H),mr=(e,t=B)=>{const n=[],s=new t(L(e)),r=new wt(s,!1);for(let o=r.curr;o!==null;o=r.next())n.push(o);cn("Structs: ",n);const i=rt(s);cn("DeleteSet: ",i)},$c=e=>kr(e,H),kr=(e,t=B)=>{const n=[],s=new t(L(e)),r=new wt(s,!1);for(let i=r.curr;i!==null;i=r.next())n.push(i);return{structs:n,ds:rt(s)}};class Nn{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}}const yr=e=>ne(e,H,pt),_r=(e,t=Ve,n=B)=>{const s=new t,r=new wt(new n(L(e)),!1);let i=r.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,a=l?0:i.id.clock+i.length;for(;i!==null;i=r.next())c!==i.id.client&&(a!==0&&(o++,p(s.restEncoder,c),p(s.restEncoder,a)),c=i.id.client,a=0,l=i.id.clock!==0),i.constructor===M&&(l=!0),l||(a=i.id.clock+i.length);a!==0&&(o++,p(s.restEncoder,c),p(s.restEncoder,a));const h=jt();return p(h,o),wi(h,s.restEncoder),s.restEncoder=h,s.toUint8Array()}else return p(s.restEncoder,0),s.toUint8Array()},Vc=e=>_r(e,$t,H),br=(e,t=B)=>{const n=new Map,s=new Map,r=new wt(new t(L(e)),!1);let i=r.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=r.next())o!==i.id.client&&(s.set(o,c),n.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;s.set(o,c)}return{from:n,to:s}},Fc=e=>br(e,H),jc=(e,t)=>{if(e.constructor===$){const{client:n,clock:s}=e.id;return new $(w(n,s+t),e.length-t)}else if(e.constructor===M){const{client:n,clock:s}=e.id;return new M(w(n,s+t),e.length-t)}else{const n=e,{client:s,clock:r}=n.id;return new y(w(s,r+t),null,w(s,r+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},ne=(e,t=B,n=K)=>{if(e.length===1)return e[0];const s=e.map(h=>new t(L(h)));let r=s.map(h=>new wt(h,!0)),i=null;const o=new n,c=new Nn(o);for(;r=r.filter(d=>d.curr!==null),r.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){const g=d.curr.id.clock-f.curr.id.clock;return g===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===M?1:-1:g}else return f.curr.id.client-d.curr.id.client}),r.length!==0;){const h=r[0],u=h.curr.id.client;if(i!==null){let d=h.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=h.next(),f=!0;if(d===null||d.id.client!==u||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(u!==i.struct.id.client)ht(c,i.struct,i.offset),i={struct:d,offset:0},h.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===M)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{ht(c,i.struct,i.offset);const g=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new M(w(u,i.struct.id.clock+i.struct.length),g),offset:0}}else{const g=i.struct.id.clock+i.struct.length-d.id.clock;g>0&&(i.struct.constructor===M?i.struct.length-=g:d=jc(d,g)),i.struct.mergeWith(d)||(ht(c,i.struct,i.offset),i={struct:d,offset:0},h.next())}}else i={struct:h.curr,offset:0},h.next();for(let d=h.curr;d!==null&&d.id.client===u&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==M;d=h.next())ht(c,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(ht(c,i.struct,i.offset),i=null),$n(c);const l=s.map(h=>rt(h)),a=Dt(l);return Z(o,a),o.toUint8Array()},Rn=(e,t,n=B,s=K)=>{const r=On(t),i=new s,o=new Nn(i),c=new n(L(e)),l=new wt(c,!1);for(;l.curr;){const h=l.curr,u=h.id.client,d=r.get(u)||0;if(l.curr.constructor===M){l.next();continue}if(h.id.clock+h.length>d)for(ht(o,h,Tt(d-h.id.clock,0)),l.next();l.curr&&l.curr.id.client===u;)ht(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===u&&l.curr.id.clock+l.curr.length<=d;)l.next()}$n(o);const a=rt(c);return Z(i,a),i.toUint8Array()},Bc=(e,t)=>Rn(e,t,H,pt),Sr=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:z(e.encoder.restEncoder)}),e.encoder.restEncoder=jt(),e.written=0)},ht=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Sr(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),p(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},$n=e=>{Sr(e);const t=e.encoder.restEncoder;p(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const s=e.clientStructs[n];p(t,s.written),ce(t,s.restEncoder)}},Be=(e,t,n,s)=>{const r=new n(L(e)),i=new wt(r,!1),o=new s,c=new Nn(o);for(let a=i.curr;a!==null;a=i.next())ht(c,t(a),0);$n(c);const l=rt(r);return Z(o,l),o.toUint8Array()},Er=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let s=0;const r=T(),i=T(),o=T(),c=T();return c.set(null,null),l=>{switch(l.constructor){case $:case M:return l;case y:{const a=l,h=a.content;switch(h.constructor){case It:break;case Y:{if(n){const u=h.type;u instanceof ft&&(u.nodeName=R(i,u.nodeName,()=>"node-"+s)),u instanceof Vt&&(u.hookName=R(i,u.hookName,()=>"hook-"+s))}break}case it:{const u=h;u.arr=u.arr.map(()=>s);break}case Ot:{const u=h;u.content=new Uint8Array([s]);break}case Ut:{const u=h;t&&(u.opts={},u.doc.guid=s+"");break}case ct:{const u=h;u.embed={};break}case C:{const u=h;e&&(u.key=R(o,u.key,()=>s+""),u.value=R(c,u.value,()=>({i:s})));break}case Ft:{const u=h;u.arr=u.arr.map(()=>s);break}case J:{const u=h;u.str=_s(s%10+"",u.str.length);break}default:v()}return a.parentSub&&(a.parentSub=R(r,a.parentSub,()=>s+"")),s++,l}default:v()}}},zc=(e,t)=>Be(e,Er(t),H,pt),Gc=(e,t)=>Be(e,Er(t),B,K),Jc=e=>Be(e,Ts,H,K),Cr=e=>Be(e,Ts,B,pt),fs="You must not compute changes after the event-handler fired.";class ae{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=Hc(this.currentTarget,this.target))}deletes(t){return xt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw P(fs);const t=new Map,n=this.target;this.transaction.changed.get(n).forEach(r=>{if(r!==null){const i=n._map.get(r);let o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=He(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=He(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=He(i.content.getContent());else return;t.set(r,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw P(fs);const n=this.target,s=Et(),r=Et(),i=[];if(t={added:s,deleted:r,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null;const l=()=>{c&&i.push(c)};for(let a=n._start;a!==null;a=a.right)a.deleted?this.deletes(a)&&!this.adds(a)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=a.length,r.add(a)):this.adds(a)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(a.content.getContent()),s.add(a)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=a.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}}const Hc=(e,t)=>{const n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let s=0,r=t._item.parent._start;for(;r!==t._item&&r!==null;)!r.deleted&&r.countable&&(s+=r.length),r=r.right;n.unshift(s)}t=t._item.parent}return n},O=()=>{Zs("Invalid access: Add Yjs type to a document before reading data.")},Dr=80;let Vn=0;class Yc{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Vn++}}const Xc=e=>{e.timestamp=Vn++},Ar=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Vn++},Kc=(e,t,n)=>{if(e.length>=Dr){const s=e.reduce((r,i)=>r.timestamp<i.timestamp?r:i);return Ar(s,t,n),s}else{const s=new Yc(t,n);return e.push(s),s}},ze=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;const n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>ge(t-i.index)<ge(t-o.index)?i:o);let s=e._start,r=0;for(n!==null&&(s=n.p,r=n.index,Xc(n));s.right!==null&&r<t;){if(!s.deleted&&s.countable){if(t<r+s.length)break;r+=s.length}s=s.right}for(;s.left!==null&&r>t;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);for(;s.left!==null&&s.left.id.client===s.id.client&&s.left.id.clock+s.left.length===s.id.clock;)s=s.left,!s.deleted&&s.countable&&(r-=s.length);return n!==null&&ge(n.index-r)<s.parent.length/Dr?(Ar(n,s,r),n):Kc(e._searchMarker,s,r)},se=(e,t,n)=>{for(let s=e.length-1;s>=0;s--){const r=e[s];if(n>0){let i=r.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(r.index-=i.length);if(i===null||i.marker===!0){e.splice(s,1);continue}r.p=i,i.marker=!0}(t<r.index||n>0&&t===r.index)&&(r.index=Tt(t,r.index+n))}},Wc=e=>{e.doc??O();let t=e._start;const n=[];for(;t;)n.push(t),t=t.right;return n},Ge=(e,t,n)=>{const s=e,r=t.changedParentTypes;for(;R(r,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;or(s._eH,n,t)};class A{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=rs(),this._dEH=rs(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw X()}clone(){throw X()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){is(this._eH,t)}observeDeep(t){is(this._dEH,t)}unobserve(t){os(this._eH,t)}unobserveDeep(t){os(this._dEH,t)}toJSON(){}}const Ir=(e,t,n)=>{e.doc??O(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let s=n-t;const r=[];let i=e._start;for(;i!==null&&s>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&s>0;c++)r.push(o[c]),s--;t=0}}i=i.right}return r},Tr=e=>{e.doc??O();const t=[];let n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){const s=n.content.getContent();for(let r=0;r<s.length;r++)t.push(s[r])}n=n.right}return t},qc=(e,t)=>{const n=[];let s=e._start;for(;s!==null;){if(s.countable&&lt(s,t)){const r=s.content.getContent();for(let i=0;i<r.length;i++)n.push(r[i])}s=s.right}return n},re=(e,t)=>{let n=0,s=e._start;for(e.doc??O();s!==null;){if(s.countable&&!s.deleted){const r=s.content.getContent();for(let i=0;i<r.length;i++)t(r[i],n++,e)}s=s.right}},xr=(e,t)=>{const n=[];return re(e,(s,r)=>{n.push(t(s,r,e))}),n},Pc=e=>{let t=e._start,n=null,s=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),s=0,t=t.right}const r=n[s++];return n.length<=s&&(n=null),{done:!1,value:r}}}},Or=(e,t)=>{e.doc??O();const n=ze(e,t);let s=e._start;for(n!==null&&(s=n.p,t-=n.index);s!==null;s=s.right)if(!s.deleted&&s.countable){if(t<s.length)return s.content.getContent()[t];t-=s.length}},Ce=(e,t,n,s)=>{let r=n;const i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right;let a=[];const h=()=>{a.length>0&&(r=new y(w(o,E(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new it(a)),r.integrate(e,0),a=[])};s.forEach(u=>{if(u===null)a.push(u);else switch(u.constructor){case Number:case Object:case Boolean:case Array:case String:a.push(u);break;default:switch(h(),u.constructor){case Uint8Array:case ArrayBuffer:r=new y(w(o,E(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new Ot(new Uint8Array(u))),r.integrate(e,0);break;case gt:r=new y(w(o,E(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new Ut(u)),r.integrate(e,0);break;default:if(u instanceof A)r=new y(w(o,E(c,o)),r,r&&r.lastId,l,l&&l.id,t,null,new Y(u)),r.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),h()},Ur=()=>P("Length exceeded!"),vr=(e,t,n,s)=>{if(n>t._length)throw Ur();if(n===0)return t._searchMarker&&se(t._searchMarker,n,s.length),Ce(e,t,null,s);const r=n,i=ze(t,n);let o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&U(e,w(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&se(t._searchMarker,r,s.length),Ce(e,t,o,s)},Zc=(e,t,n)=>{let r=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;return Ce(e,t,r,n)},Lr=(e,t,n,s)=>{if(s===0)return;const r=n,i=s,o=ze(t,n);let c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&U(e,w(c.id.client,c.id.clock+n)),n-=c.length);for(;s>0&&c!==null;)c.deleted||(s<c.length&&U(e,w(c.id.client,c.id.clock+s)),c.delete(e),s-=c.length),c=c.right;if(s>0)throw Ur();t._searchMarker&&se(t._searchMarker,r,-i+s)},De=(e,t,n)=>{const s=t._map.get(n);s!==void 0&&s.delete(e)},Fn=(e,t,n,s)=>{const r=t._map.get(n)||null,i=e.doc,o=i.clientID;let c;if(s==null)c=new it([s]);else switch(s.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:c=new it([s]);break;case Uint8Array:c=new Ot(s);break;case gt:c=new Ut(s);break;default:if(s instanceof A)c=new Y(s);else throw new Error("Unexpected content type")}new y(w(o,E(i.store,o)),r,r&&r.lastId,null,null,t,n,c).integrate(e,0)},jn=(e,t)=>{e.doc??O();const n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},Mr=e=>{const t={};return e.doc??O(),e._map.forEach((n,s)=>{n.deleted||(t[s]=n.content.getContent()[n.length-1])}),t},Nr=(e,t)=>{e.doc??O();const n=e._map.get(t);return n!==void 0&&!n.deleted},Qc=(e,t,n)=>{let s=e._map.get(t)||null;for(;s!==null&&(!n.sv.has(s.id.client)||s.id.clock>=(n.sv.get(s.id.client)||0));)s=s.left;return s!==null&&lt(s,n)?s.content.getContent()[s.length-1]:void 0},Rr=(e,t)=>{const n={};return e._map.forEach((s,r)=>{let i=s;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&lt(i,t)&&(n[r]=i.content.getContent()[i.length-1])}),n},de=e=>(e.doc??O(),Ko(e._map.entries(),t=>!t[1].deleted));class $r extends ae{}class nt extends A{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){const n=new nt;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new nt}clone(){const t=new nt;return t.insert(0,this.toArray().map(n=>n instanceof A?n.clone():n)),t}get length(){return this.doc??O(),this._length}_callObserver(t,n){super._callObserver(t,n),Ge(this,t,new $r(this,t))}insert(t,n){this.doc!==null?_(this.doc,s=>{vr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?_(this.doc,n=>{Zc(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?_(this.doc,s=>{Lr(s,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Or(this,t)}toArray(){return Tr(this)}slice(t=0,n=this.length){return Ir(this,t,n)}toJSON(){return this.map(t=>t instanceof A?t.toJSON():t)}map(t){return xr(this,t)}forEach(t){re(this,t)}[Symbol.iterator](){return Pc(this)}_write(t){t.writeTypeRef(_l)}}const tl=e=>new nt;class Vr extends ae{constructor(t,n,s){super(t,n),this.keysChanged=s}}class ut extends A{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((s,r)=>{this.set(r,s)}),this._prelimContent=null}_copy(){return new ut}clone(){const t=new ut;return this.forEach((n,s)=>{t.set(s,n instanceof A?n.clone():n)}),t}_callObserver(t,n){Ge(this,t,new Vr(this,t,n))}toJSON(){this.doc??O();const t={};return this._map.forEach((n,s)=>{if(!n.deleted){const r=n.content.getContent()[n.length-1];t[s]=r instanceof A?r.toJSON():r}}),t}get size(){return[...de(this)].length}keys(){return Ze(de(this),t=>t[0])}values(){return Ze(de(this),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Ze(de(this),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this.doc??O(),this._map.forEach((n,s)=>{n.deleted||t(n.content.getContent()[n.length-1],s,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?_(this.doc,n=>{De(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?_(this.doc,s=>{Fn(s,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return jn(this,t)}has(t){return Nr(this,t)}clear(){this.doc!==null?_(this.doc,t=>{this.forEach(function(n,s,r){De(t,r,s)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(bl)}}const el=e=>new ut,at=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&zi(e,t);class un{constructor(t,n,s,r){this.left=t,this.right=n,this.index=s,this.currentAttributes=r}forward(){this.right===null&&v(),this.right.content.constructor===C?this.right.deleted||Gt(this.currentAttributes,this.right.content):this.right.deleted||(this.index+=this.right.length),this.left=this.right,this.right=this.right.right}}const gs=(e,t,n)=>{for(;t.right!==null&&n>0;)t.right.content.constructor===C?t.right.deleted||Gt(t.currentAttributes,t.right.content):t.right.deleted||(n<t.right.length&&U(e,w(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length),t.left=t.right,t.right=t.right.right;return t},fe=(e,t,n,s)=>{const r=new Map,i=s?ze(t,n):null;if(i){const o=new un(i.p.left,i.p,i.index,r);return gs(e,o,n-i.index)}else{const o=new un(null,t._start,0,r);return gs(e,o,n)}},Fr=(e,t,n,s)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===C&&at(s.get(n.right.content.key),n.right.content.value));)n.right.deleted||s.delete(n.right.content.key),n.forward();const r=e.doc,i=r.clientID;s.forEach((o,c)=>{const l=n.left,a=n.right,h=new y(w(i,E(r.store,i)),l,l&&l.lastId,a,a&&a.id,t,null,new C(c,o));h.integrate(e,0),n.right=h,n.forward()})},Gt=(e,t)=>{const{key:n,value:s}=t;s===null?e.delete(n):e.set(n,s)},jr=(e,t)=>{for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===C&&at(t[e.right.content.key]??null,e.right.content.value)))break;e.forward()}},Br=(e,t,n,s)=>{const r=e.doc,i=r.clientID,o=new Map;for(const c in s){const l=s[c],a=n.currentAttributes.get(c)??null;if(!at(a,l)){o.set(c,a);const{left:h,right:u}=n;n.right=new y(w(i,E(r.store,i)),h,h&&h.lastId,u,u&&u.id,t,null,new C(c,l)),n.right.integrate(e,0),n.forward()}}return o},Qe=(e,t,n,s,r)=>{n.currentAttributes.forEach((d,f)=>{r[f]===void 0&&(r[f]=null)});const i=e.doc,o=i.clientID;jr(n,r);const c=Br(e,t,n,r),l=s.constructor===String?new J(s):s instanceof A?new Y(s):new ct(s);let{left:a,right:h,index:u}=n;t._searchMarker&&se(t._searchMarker,n.index,l.getLength()),h=new y(w(o,E(i.store,o)),a,a&&a.lastId,h,h&&h.id,t,null,l),h.integrate(e,0),n.right=h,n.index=u,n.forward(),Fr(e,t,n,c)},ps=(e,t,n,s,r)=>{const i=e.doc,o=i.clientID;jr(n,r);const c=Br(e,t,n,r);t:for(;n.right!==null&&(s>0||c.size>0&&(n.right.deleted||n.right.content.constructor===C));){if(!n.right.deleted)switch(n.right.content.constructor){case C:{const{key:l,value:a}=n.right.content,h=r[l];if(h!==void 0){if(at(h,a))c.delete(l);else{if(s===0)break t;c.set(l,a)}n.right.delete(e)}else n.currentAttributes.set(l,a);break}default:s<n.right.length&&U(e,w(n.right.id.client,n.right.id.clock+s)),s-=n.right.length;break}n.forward()}if(s>0){let l="";for(;s>0;s--)l+=`
4
+ `;n.right=new y(w(o,E(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new J(l)),n.right.integrate(e,0),n.forward()}Fr(e,t,n,c)},zr=(e,t,n,s,r)=>{let i=t;const o=T();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===C){const a=i.content;o.set(a.key,a)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){const a=t.content;if(a.constructor===C){const{key:h,value:u}=a,d=s.get(h)??null;(o.get(h)!==a||d===u)&&(t.delete(e),c++,!l&&(r.get(h)??null)===u&&d!==u&&(d===null?r.delete(h):r.set(h,d))),!l&&!t.deleted&&Gt(r,a)}}t=t.right}return c},nl=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===C){const s=t.content.key;n.has(s)?t.delete(e):n.add(s)}t=t.left}},Gr=e=>{let t=0;return _(e.doc,n=>{let s=e._start,r=e._start,i=T();const o=en(i);for(;r;)r.deleted===!1&&(r.content.constructor===C?Gt(o,r.content):(t+=zr(n,s,r,i,o),i=en(o),s=r)),r=r.right}),t},sl=e=>{const t=new Set,n=e.doc;for(const[s,r]of e.afterState.entries()){const i=e.beforeState.get(s)||0;r!==i&&dr(e,n.store.clients.get(s),i,r,o=>{!o.deleted&&o.content.constructor===C&&o.constructor!==$&&t.add(o.parent)})}_(n,s=>{Ct(e,e.deleteSet,r=>{if(r instanceof $||!r.parent._hasFormatting||t.has(r.parent))return;const i=r.parent;r.content.constructor===C?t.add(i):nl(s,r)});for(const r of t)Gr(r)})},ws=(e,t,n)=>{const s=n,r=en(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case Y:case ct:case J:n<t.right.length&&U(e,w(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&zr(e,i,t.right,r,t.currentAttributes);const o=(t.left||t.right).parent;return o._searchMarker&&se(o._searchMarker,t.index,-s+n),t};class Jr extends ae{constructor(t,n,s){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,s.forEach(r=>{r===null?this.childListChanged=!0:this.keysChanged.add(r)})}get changes(){if(this._changes===null){const t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){const t=this.target.doc,n=[];_(t,s=>{const r=new Map,i=new Map;let o=this.target._start,c=null;const l={};let a="",h=0,u=0;const d=()=>{if(c!==null){let f=null;switch(c){case"delete":u>0&&(f={delete:u}),u=0;break;case"insert":(typeof a=="object"||a.length>0)&&(f={insert:a},r.size>0&&(f.attributes={},r.forEach((g,m)=>{g!==null&&(f.attributes[m]=g)}))),a="";break;case"retain":h>0&&(f={retain:h},Bi(l)||(f.attributes=Vi({},l))),h=0;break}f&&n.push(f),c=null}};for(;o!==null;){switch(o.content.constructor){case Y:case ct:this.adds(o)?this.deletes(o)||(d(),c="insert",a=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=1);break;case J:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),a+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),u+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),h+=o.length);break;case C:{const{key:f,value:g}=o.content;if(this.adds(o)){if(!this.deletes(o)){const m=r.get(f)??null;at(m,g)?g!==null&&o.delete(s):(c==="retain"&&d(),at(g,i.get(f)??null)?delete l[f]:l[f]=g)}}else if(this.deletes(o)){i.set(f,g);const m=r.get(f)??null;at(m,g)||(c==="retain"&&d(),l[f]=m)}else if(!o.deleted){i.set(f,g);const m=l[f];m!==void 0&&(at(m,g)?m!==null&&o.delete(s):(c==="retain"&&d(),g===null?delete l[f]:l[f]=g))}o.deleted||(c==="insert"&&d(),Gt(r,o.content));break}}o=o.right}for(d();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class At extends A{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??O(),this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(s=>s())}catch(s){console.error(s)}this._pending=null}_copy(){return new At}clone(){const t=new At;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);const s=new Jr(this,t,n);Ge(this,t,s),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){this.doc??O();let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===J&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?_(this.doc,s=>{const r=new un(null,this._start,0,new Map);for(let i=0;i<t.length;i++){const o=t[i];if(o.insert!==void 0){const c=!n&&typeof o.insert=="string"&&i===t.length-1&&r.right===null&&o.insert.slice(-1)===`
5
+ `?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Qe(s,this,r,c,o.attributes||{})}else o.retain!==void 0?ps(s,this,r,o.retain,o.attributes||{}):o.delete!==void 0&&ws(s,r,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,s){this.doc??O();const r=[],i=new Map,o=this.doc;let c="",l=this._start;function a(){if(c.length>0){const u={};let d=!1;i.forEach((g,m)=>{d=!0,u[m]=g});const f={insert:c};d&&(f.attributes=u),r.push(f),c=""}}const h=()=>{for(;l!==null;){if(lt(l,t)||n!==void 0&&lt(l,n))switch(l.content.constructor){case J:{const u=i.get("ychange");t!==void 0&&!lt(l,t)?(u===void 0||u.user!==l.id.client||u.type!=="removed")&&(a(),i.set("ychange",s?s("removed",l.id):{type:"removed"})):n!==void 0&&!lt(l,n)?(u===void 0||u.user!==l.id.client||u.type!=="added")&&(a(),i.set("ychange",s?s("added",l.id):{type:"added"})):u!==void 0&&(a(),i.delete("ychange")),c+=l.content.str;break}case Y:case ct:{a();const u={insert:l.content.getContent()[0]};if(i.size>0){const d={};u.attributes=d,i.forEach((f,g)=>{d[g]=f})}r.push(u);break}case C:lt(l,t)&&(a(),Gt(i,l.content));break}l=l.right}a()};return t||n?_(o,u=>{t&&ln(u,t),n&&ln(u,n),h()},"cleanup"):h(),r}insert(t,n,s){if(n.length<=0)return;const r=this.doc;r!==null?_(r,i=>{const o=fe(i,this,t,!s);s||(s={},o.currentAttributes.forEach((c,l)=>{s[l]=c})),Qe(i,this,o,n,s)}):this._pending.push(()=>this.insert(t,n,s))}insertEmbed(t,n,s){const r=this.doc;r!==null?_(r,i=>{const o=fe(i,this,t,!s);Qe(i,this,o,n,s||{})}):this._pending.push(()=>this.insertEmbed(t,n,s||{}))}delete(t,n){if(n===0)return;const s=this.doc;s!==null?_(s,r=>{ws(r,fe(r,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,s){if(n===0)return;const r=this.doc;r!==null?_(r,i=>{const o=fe(i,this,t,!1);o.right!==null&&ps(i,this,o,n,s)}):this._pending.push(()=>this.format(t,n,s))}removeAttribute(t){this.doc!==null?_(this.doc,n=>{De(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?_(this.doc,s=>{Fn(s,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return jn(this,t)}getAttributes(){return Mr(this)}_write(t){t.writeTypeRef(Sl)}}const rl=e=>new At;class tn{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0,t.doc??O()}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===ft||n.constructor===dt)&&n._start!==null)t=n._start;else for(;t!==null;){const s=t.next;if(s!==null){t=s;break}else t.parent===this._root?t=null:t=t.parent._item}while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}}class dt extends A{constructor(){super(),this._prelimContent=[]}get firstChild(){const t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new dt}clone(){const t=new dt;return t.insert(0,this.toArray().map(n=>n instanceof A?n.clone():n)),t}get length(){return this.doc??O(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new tn(this,t)}querySelector(t){t=t.toUpperCase();const s=new tn(this,r=>r.nodeName&&r.nodeName.toUpperCase()===t).next();return s.done?null:s.value}querySelectorAll(t){return t=t.toUpperCase(),st(new tn(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){Ge(this,t,new Hr(this,n,t))}toString(){return xr(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},s){const r=t.createDocumentFragment();return s!==void 0&&s._createAssociation(r,this),re(this,i=>{r.insertBefore(i.toDOM(t,n,s),null)}),r}insert(t,n){this.doc!==null?_(this.doc,s=>{vr(s,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)_(this.doc,s=>{const r=t&&t instanceof A?t._item:t;Ce(s,this,r,n)});else{const s=this._prelimContent,r=t===null?0:s.findIndex(i=>i===t)+1;if(r===0&&t!==null)throw P("Reference item not found");s.splice(r,0,...n)}}delete(t,n=1){this.doc!==null?_(this.doc,s=>{Lr(s,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Tr(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Or(this,t)}slice(t=0,n=this.length){return Ir(this,t,n)}forEach(t){re(this,t)}_write(t){t.writeTypeRef(Cl)}}const il=e=>new dt;class ft extends dt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((s,r)=>{this.setAttribute(r,s)}),this._prelimAttrs=null}_copy(){return new ft(this.nodeName)}clone(){const t=new ft(this.nodeName),n=this.getAttributes();return ji(n,(s,r)=>{t.setAttribute(r,s)}),t.insert(0,this.toArray().map(s=>s instanceof A?s.clone():s)),t}toString(){const t=this.getAttributes(),n=[],s=[];for(const c in t)s.push(c);s.sort();const r=s.length;for(let c=0;c<r;c++){const l=s[c];n.push(l+'="'+t[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?_(this.doc,n=>{De(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?_(this.doc,s=>{Fn(s,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return jn(this,t)}hasAttribute(t){return Nr(this,t)}getAttributes(t){return t?Rr(this,t):Mr(this)}toDOM(t=document,n={},s){const r=t.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const c=i[o];typeof c=="string"&&r.setAttribute(o,c)}return re(this,o=>{r.appendChild(o.toDOM(t,n,s))}),s!==void 0&&s._createAssociation(r,this),r}_write(t){t.writeTypeRef(El),t.writeKey(this.nodeName)}}const ol=e=>new ft(e.readKey());class Hr extends ae{constructor(t,n,s){super(t,s),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(r=>{r===null?this.childListChanged=!0:this.attributesChanged.add(r)})}}class Vt extends ut{constructor(t){super(),this.hookName=t}_copy(){return new Vt(this.hookName)}clone(){const t=new Vt(this.hookName);return this.forEach((n,s)=>{t.set(s,n)}),t}toDOM(t=document,n={},s){const r=n[this.hookName];let i;return r!==void 0?i=r.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),s!==void 0&&s._createAssociation(i,this),i}_write(t){t.writeTypeRef(Dl),t.writeKey(this.hookName)}}const cl=e=>new Vt(e.readKey());class ie extends At{get nextSibling(){const t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){const t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new ie}clone(){const t=new ie;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,s){const r=t.createTextNode(this.toString());return s!==void 0&&s._createAssociation(r,this),r}toString(){return this.toDelta().map(t=>{const n=[];for(const r in t.attributes){const i=[];for(const o in t.attributes[r])i.push({key:o,value:t.attributes[r][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:r,attrs:i})}n.sort((r,i)=>r.nodeName<i.nodeName?-1:1);let s="";for(let r=0;r<n.length;r++){const i=n[r];s+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const c=i.attrs[o];s+=` ${c.key}="${c.value}"`}s+=">"}s+=t.insert;for(let r=n.length-1;r>=0;r--)s+=`</${n[r].nodeName}>`;return s}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Al)}}const ll=e=>new ie;class Je{constructor(t,n){this.id=t,this.length=n}get deleted(){throw X()}mergeWith(t){return!1}write(t,n,s){throw X()}integrate(t,n){throw X()}}const hl=0;class $ extends Je{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),ur(t.doc.store,this)}write(t,n){t.writeInfo(hl),t.writeLen(this.length-n)}getMissing(t,n){return null}}class Ot{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Ot(this.content)}splice(t){throw X()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}}const al=e=>new Ot(e.readBuf());class It{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new It(this.len)}splice(t){const n=new It(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Qt(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}}const ul=e=>new It(e.readLen()),Yr=(e,t)=>new gt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class Ut{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;const n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Ut(Yr(this.doc.guid,this.opts))}splice(t){throw X()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}}const dl=e=>new Ut(Yr(e.readString(),e.readAny()));class ct{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new ct(this.embed)}splice(t){throw X()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}}const fl=e=>new ct(e.readJSON());class C{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new C(this.key,this.value)}splice(t){throw X()}mergeWith(t){return!1}integrate(t,n){const s=n.parent;s._searchMarker=null,s._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}}const gl=e=>new C(e.readKey(),e.readJSON());class Ft{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Ft(this.arr)}splice(t){const n=new Ft(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const pl=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++){const r=e.readString();r==="undefined"?n.push(void 0):n.push(JSON.parse(r))}return new Ft(n)},wl=be("node_env")==="development";class it{constructor(t){this.arr=t,wl&&Is(t)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new it(this.arr)}splice(t){const n=new it(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){const s=this.arr.length;t.writeLen(s-n);for(let r=n;r<s;r++){const i=this.arr[r];t.writeAny(i)}}getRef(){return 8}}const ml=e=>{const t=e.readLen(),n=[];for(let s=0;s<t;s++)n.push(e.readAny());return new it(n)};class J{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new J(this.str)}splice(t){const n=new J(this.str.slice(t));this.str=this.str.slice(0,t);const s=this.str.charCodeAt(t-1);return s>=55296&&s<=56319&&(this.str=this.str.slice(0,t-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const kl=e=>new J(e.readString()),yl=[tl,el,rl,ol,il,cl,ll],_l=0,bl=1,Sl=2,El=3,Cl=4,Dl=5,Al=6;class Y{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Y(this.type._copy())}splice(t){throw X()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(s=>{s.deleted?s.id.clock<(t.beforeState.get(s.id.client)||0)&&t._mergeStructs.push(s):s.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(s=>{for(;s!==null;)s.gc(t,!0),s=s.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}}const Il=e=>new Y(yl[e.readTypeRef()](e)),dn=(e,t)=>{let n=t,s=0,r;do s>0&&(n=w(n.client,n.clock+s)),r=St(e,n),s=n.clock-r.id.clock,n=r.redone;while(n!==null&&r instanceof y);return{item:r,diff:s}},Bn=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},Ae=(e,t,n)=>{const{client:s,clock:r}=t.id,i=new y(w(s,r+n),t,w(s,r+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=w(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},ms=(e,t)=>gn(e,n=>xt(n.deletions,t)),Xr=(e,t,n,s,r,i)=>{const o=e.doc,c=o.store,l=o.clientID,a=t.redone;if(a!==null)return U(e,a);let h=t.parent._item,u=null,d;if(h!==null&&h.deleted===!0){if(h.redone===null&&(!n.has(h)||Xr(e,h,n,s,r,i)===null))return null;for(;h.redone!==null;)h=U(e,h.redone)}const f=h===null?t.parent:h.content.type;if(t.parentSub===null){for(u=t.left,d=t;u!==null;){let S=u;for(;S!==null&&S.parent._item!==h;)S=S.redone===null?null:U(e,S.redone);if(S!==null&&S.parent._item===h){u=S;break}u=u.left}for(;d!==null;){let S=d;for(;S!==null&&S.parent._item!==h;)S=S.redone===null?null:U(e,S.redone);if(S!==null&&S.parent._item===h){d=S;break}d=d.right}}else if(d=null,t.right&&!r){for(u=t;u!==null&&u.right!==null&&(u.right.redone||xt(s,u.right.id)||ms(i.undoStack,u.right.id)||ms(i.redoStack,u.right.id));)for(u=u.right;u.redone;)u=U(e,u.redone);if(u&&u.right!==null)return null}else u=f._map.get(t.parentSub)||null;const g=E(c,l),m=w(l,g),b=new y(m,u,u&&u.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=m,Bn(b,!0),b.integrate(e,0),b};class y extends Je{constructor(t,n,s,r,i,o,c,l){super(t,l.getLength()),this.origin=s,this.left=n,this.right=r,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?Hn:0}set marker(t){(this.info&Xe)>0!==t&&(this.info^=Xe)}get marker(){return(this.info&Xe)>0}get keep(){return(this.info&Jn)>0}set keep(t){this.keep!==t&&(this.info^=Jn)}get countable(){return(this.info&Hn)>0}get deleted(){return(this.info&Ye)>0}set deleted(t){this.deleted!==t&&(this.info^=Ye)}markDeleted(){this.info|=Ye}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=E(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=E(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===bt&&this.id.client!==this.parent.client&&this.parent.clock>=E(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=an(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=U(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===$||this.right&&this.right.constructor===$)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===y?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===y&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===bt){const s=St(n,this.parent);s.constructor===$?this.parent=null:this.parent=s.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=an(t,t.doc.store,w(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let s=this.left,r;if(s!==null)r=s.right;else if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start;const i=new Set,o=new Set;for(;r!==null&&r!==this.right;){if(o.add(r),i.add(r),mt(this.origin,r.origin)){if(r.id.client<this.id.client)s=r,i.clear();else if(mt(this.rightOrigin,r.rightOrigin))break}else if(r.origin!==null&&o.has(St(t.doc.store,r.origin)))i.has(St(t.doc.store,r.origin))||(s=r,i.clear());else break;r=r.right}this.left=s}if(this.left!==null){const s=this.left.right;this.right=s,this.left.right=this}else{let s;if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start,this.parent._start=this;this.right=s}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ur(t.doc.store,this),this.content.integrate(t,this),as(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new $(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:w(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&mt(t.origin,this.lastId)&&this.right===t&&mt(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){const n=this.parent._searchMarker;return n&&n.forEach(s=>{s.p===t&&(s.p=this,!this.deleted&&this.countable&&(s.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Qt(t.deleteSet,this.id.client,this.id.clock,this.length),as(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw v();this.content.gc(t),n?Uc(t,this,new $(this.id,this.length)):this.content=new It(this.length)}write(t,n){const s=n>0?w(this.id.client,this.id.clock+n-1):this.origin,r=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Ie|(s===null?0:j)|(r===null?0:et)|(i===null?0:Ht);if(t.writeInfo(o),s!==null&&t.writeLeftID(s),r!==null&&t.writeRightID(r),s===null&&r===null){const c=this.parent;if(c._item!==void 0){const l=c._item;if(l===null){const a=vn(c);t.writeParentInfo(!0),t.writeString(a)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===bt?(t.writeParentInfo(!1),t.writeLeftID(c)):v();i!==null&&t.writeString(i)}this.content.write(t,n)}}const Kr=(e,t)=>Tl[t&Ie](e),Tl=[()=>{v()},ul,pl,al,kl,fl,gl,Il,ml,dl,()=>{v()}],xl=10;class M extends Je{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){v()}write(t,n){t.writeInfo(xl),p(t.restEncoder,this.length-n)}getMissing(t,n){return null}}const Wr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},qr="__ $YJS$ __";Wr[qr]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Wr[qr]=!0;const Ll=Object.freeze(Object.defineProperty({__proto__:null,AbsolutePosition:cr,AbstractConnector:Wo,AbstractStruct:Je,AbstractType:A,Array:nt,ContentAny:it,ContentBinary:Ot,ContentDeleted:It,ContentDoc:Ut,ContentEmbed:ct,ContentFormat:C,ContentJSON:Ft,ContentString:J,ContentType:Y,Doc:gt,GC:$,ID:bt,Item:y,Map:ut,PermanentUserData:ac,RelativePosition:je,Skip:M,Snapshot:Ln,Text:At,Transaction:fr,UndoManager:Mc,UpdateDecoderV1:H,UpdateDecoderV2:B,UpdateEncoderV1:pt,UpdateEncoderV2:K,XmlElement:ft,XmlFragment:dt,XmlHook:Vt,XmlText:ie,YArrayEvent:$r,YEvent:ae,YMapEvent:Vr,YTextEvent:Jr,YXmlEvent:Hr,applyUpdate:nc,applyUpdateV2:Fe,cleanupYTextFormatting:Gr,compareIDs:mt,compareRelativePositions:bc,convertUpdateFormatV1ToV2:Jc,convertUpdateFormatV2ToV1:Cr,createAbsolutePositionFromRelativePosition:_c,createDeleteSet:$e,createDeleteSetFromStructStore:In,createDocFromSnapshot:Ic,createID:w,createRelativePositionFromJSON:dc,createRelativePositionFromTypeIndex:gc,createSnapshot:Mn,decodeRelativePosition:kc,decodeSnapshot:Cc,decodeSnapshotV2:hr,decodeStateVector:On,decodeUpdate:$c,decodeUpdateV2:kr,diffUpdate:Bc,diffUpdateV2:Rn,emptySnapshot:Dc,encodeRelativePosition:wc,encodeSnapshot:Ec,encodeSnapshotV2:lr,encodeStateAsUpdate:rc,encodeStateAsUpdateV2:rr,encodeStateVector:cc,encodeStateVectorFromUpdate:Vc,encodeStateVectorFromUpdateV2:_r,equalDeleteSets:er,equalSnapshots:Sc,findIndexSS:G,findRootTypeKey:vn,getItem:St,getItemCleanEnd:an,getItemCleanStart:U,getState:E,getTypeChildren:Wc,isDeleted:xt,isParentOf:ee,iterateDeletedStructs:Ct,logType:hc,logUpdate:Rc,logUpdateV2:mr,mergeDeleteSets:Dt,mergeUpdates:yr,mergeUpdatesV2:ne,obfuscateUpdate:zc,obfuscateUpdateV2:Gc,parseUpdateMeta:Fc,parseUpdateMetaV2:br,readUpdate:ec,readUpdateV2:xn,relativePositionToJSON:uc,snapshot:Ac,snapshotContainsUpdate:xc,transact:_,tryGc:vc,typeListToArraySnapshot:qc,typeMapGetAllSnapshot:Rr,typeMapGetSnapshot:Qc},Symbol.toStringTag,{value:"Module"}));export{Ll as A,gt as D,Ol as O,Mc as U,yt as a,_t as b,jt as c,L as d,me as e,q as f,Li as g,V as h,cc as i,nc as j,F as k,rc as l,ui as m,uc as n,dc as o,gc as p,_c as q,k as r,bc as s,z as t,ks as u,Tt as v,p as w,Ul as x,vl as y,tt as z};
@@ -0,0 +1 @@
1
+ import{p as a}from"./BeBar3OL.js";a();
@@ -0,0 +1 @@
1
+ import{q as G,b as fe,m as p,al as te,Y as we,X as K,am as be,_ as Ie,af as $e,an as Ae,ai as ne,ao as xe,ap as Ce,Q as Ne,h as w,c as F,x as de,a as Q,aq as Oe,ar as ee,r as ke,a0 as He,s as se,d as z,e as R,C as Re,as as De,at as N,U as he,W as pe,au as X,av as Me,aw as Pe,V as Be,a2 as Fe,w as Ue,ax as ge,ay as Le,az as Ve,E as ze,aA as We,aB as qe,a9 as Ge,aC as Ye,K as d,L as b,a7 as re,k as ie,T as Je}from"./BeBar3OL.js";import{b as Xe,i as Ke}from"./Cs_ROD7H.js";import{B as Qe}from"./xBRYfpah.js";import{i as Ze}from"./D4FXhiC2.js";import{b as oe,u as ae,w as C,a as je}from"./DP09rP34.js";function Ct(e,t){return t}function et(e,t,n){for(var s=[],i=t.length,a,o=t.length,c=0;c<i;c++){let T=t[c];pe(T,()=>{if(a){if(a.pending.delete(T),a.done.add(T),a.pending.size===0){var h=e.outrogroups;Z(ee(a.done)),h.delete(a),h.size===0&&(e.outrogroups=null)}}else o-=1},!1)}if(o===0){var u=s.length===0&&n!==null;if(u){var E=n,l=E.parentNode;Pe(l),l.append(E),e.items.clear()}Z(t,!u)}else a={pending:new Set(t),done:new Set},(e.outrogroups??=new Set).add(a)}function Z(e,t=!0){for(var n=0;n<e.length;n++)Be(e[n],t)}var le;function Nt(e,t,n,s,i,a=null){var o=e,c=new Map,u=(t&ge)!==0;if(u){var E=e;o=w?F(de(E)):E.appendChild(G())}w&&Q();var l=null,T=$e(()=>{var f=n();return Oe(f)?f:f==null?[]:ee(f)}),h,g=!0;function m(){r.fallback=l,tt(r,h,o,t,s),l!==null&&(h.length===0?(l.f&N)===0?he(l):(l.f^=N,V(l,null,o)):pe(l,()=>{l=null}))}var y=fe(()=>{h=p(T);var f=h.length;let x=!1;if(w){var M=ke(o)===He;M!==(f===0)&&(o=se(),F(o),z(!1),x=!0)}for(var $=new Set,k=we,P=Ie(),I=0;I<f;I+=1){w&&R.nodeType===Re&&R.data===De&&(o=R,x=!0,z(!1));var H=h[I],B=s(H,I),v=g?null:c.get(B);v?(v.v&&te(v.v,H),v.i&&te(v.i,I),P&&k.unskip_effect(v.e)):(v=nt(c,g?o:le??=G(),H,B,I,i,t,n),g||(v.e.f|=N),c.set(B,v)),$.add(B)}if(f===0&&a&&!l&&(g?l=K(()=>a(o)):(l=K(()=>a(le??=G())),l.f|=N)),f>$.size&&be(),w&&f>0&&F(se()),!g)if(P){for(const[Se,ve]of c)$.has(Se)||k.skip_effect(ve.e);k.oncommit(m),k.ondiscard(()=>{})}else m();x&&z(!0),p(T)}),r={effect:y,items:c,outrogroups:null,fallback:l};g=!1,w&&(o=R)}function U(e){for(;e!==null&&(e.f&Me)===0;)e=e.next;return e}function tt(e,t,n,s,i){var a=(s&Le)!==0,o=t.length,c=e.items,u=U(e.effect.first),E,l=null,T,h=[],g=[],m,y,r,f;if(a)for(f=0;f<o;f+=1)m=t[f],y=i(m,f),r=c.get(y).e,(r.f&N)===0&&(r.nodes?.a?.measure(),(T??=new Set).add(r));for(f=0;f<o;f+=1){if(m=t[f],y=i(m,f),r=c.get(y).e,e.outrogroups!==null)for(const v of e.outrogroups)v.pending.delete(r),v.done.delete(r);if((r.f&N)!==0)if(r.f^=N,r===u)V(r,null,n);else{var x=l?l.next:u;r===e.effect.last&&(e.effect.last=r.prev),r.prev&&(r.prev.next=r.next),r.next&&(r.next.prev=r.prev),O(e,l,r),O(e,r,x),V(r,x,n),l=r,h=[],g=[],u=U(l.next);continue}if((r.f&X)!==0&&(he(r),a&&(r.nodes?.a?.unfix(),(T??=new Set).delete(r))),r!==u){if(E!==void 0&&E.has(r)){if(h.length<g.length){var M=g[0],$;l=M.prev;var k=h[0],P=h[h.length-1];for($=0;$<h.length;$+=1)V(h[$],M,n);for($=0;$<g.length;$+=1)E.delete(g[$]);O(e,k.prev,P.next),O(e,l,k),O(e,P,M),u=M,l=P,f-=1,h=[],g=[]}else E.delete(r),V(r,u,n),O(e,r.prev,r.next),O(e,r,l===null?e.effect.first:l.next),O(e,l,r),l=r;continue}for(h=[],g=[];u!==null&&u!==r;)(E??=new Set).add(u),g.push(u),u=U(u.next);if(u===null)continue}(r.f&N)===0&&h.push(r),l=r,u=U(r.next)}if(e.outrogroups!==null){for(const v of e.outrogroups)v.pending.size===0&&(Z(ee(v.done)),e.outrogroups?.delete(v));e.outrogroups.size===0&&(e.outrogroups=null)}if(u!==null||E!==void 0){var I=[];if(E!==void 0)for(r of E)(r.f&X)===0&&I.push(r);for(;u!==null;)(u.f&X)===0&&u!==e.fallback&&I.push(u),u=U(u.next);var H=I.length;if(H>0){var B=(s&ge)!==0&&o===0?n:null;if(a){for(f=0;f<H;f+=1)I[f].nodes?.a?.measure();for(f=0;f<H;f+=1)I[f].nodes?.a?.fix()}et(e,I,B)}}a&&Fe(()=>{if(T!==void 0)for(r of T)r.nodes?.a?.apply()})}function nt(e,t,n,s,i,a,o,c){var u=(o&xe)!==0?(o&Ce)===0?Ne(n,!1,!1):ne(n):null,E=(o&Ae)!==0?ne(i):null;return{v:u,i:E,e:K(()=>(a(t,u??n,E??i,c),()=>{e.delete(s)}))}}function V(e,t,n){if(e.nodes)for(var s=e.nodes.start,i=e.nodes.end,a=t&&(t.f&N)===0?t.nodes.start:n;s!==null;){var o=Ue(s);if(a.before(s),s===i)return;s=o}}function O(e,t,n){t===null?e.effect.first=n:t.next=n,n===null?e.effect.last=t:n.prev=t}function Ot(e,t,n,s,i,a){let o=w;w&&Q();var c=null;w&&R.nodeType===Ve&&(c=R,Q());var u=w?R:e,E=new Qe(u,!1);fe(()=>{const l=t()||null;var T=n||l==="svg"?qe:void 0;if(l===null){E.ensure(null,null);return}return E.ensure(l,h=>{if(l){if(c=w?c:We(l,T),Xe(c,c),s){w&&Ke(l)&&c.append(document.createComment(""));var g=w?de(c):c.appendChild(G());w&&(g===null?z(!1):F(g)),s(c,g)}Ge.nodes.end=c,h.before(c)}w&&F(h)}),()=>{}},ze),Ye(()=>{}),o&&(z(!0),F(u))}function st(){let e=b(null),t=b(null),n=b(null),s=b(null),i=b("entity"),a=b(null),o=b("general");function c(m,y){p(e)&&(p(e)!==m||p(n)!==y)&&oe(p(e)).catch(()=>{})}function u(m,y,r,f){c(m,r),d(e,m,!0),d(t,y,!0),d(n,r,!0),d(s,f??null,!0)}function E(){d(i,"entity")}function l(){d(i,"graph")}function T(){d(i,"settings")}function h(m,y,r){p(n)===r&&p(e)===m?(d(e,null),d(t,null),d(n,null)):(d(e,m,!0),d(t,y,!0),d(n,r,!0)),d(s,null)}function g(){p(e)&&oe(p(e)).catch(()=>{}),d(e,null),d(t,null),d(n,null),d(s,null)}return{get selectedRepo(){return p(e)},get selectedType(){return p(t)},get selectedId(){return p(n)},get selectedSubPath(){return p(s)},get activeView(){return p(i)},get entityPath(){return p(e)&&p(t)&&p(n)?`/${p(e)}/${p(t)}/${p(n)}`:null},get hoveredEntityId(){return p(a)},set hoveredEntityId(m){d(a,m,!0)},get settingsTab(){return p(o)},set settingsTab(m){d(o,m,!0)},select:u,deselect:g,selectOnGraph:h,showEntity:E,showGraph:l,showSettings:T}}const L=st();function kt(...e){return e.filter(Boolean).join(" ")}const rt=typeof document<"u";let ue=0;class it{#e=b(re([]));get toasts(){return p(this.#e)}set toasts(t){d(this.#e,t,!0)}#t=b(re([]));get heights(){return p(this.#t)}set heights(t){d(this.#t,t,!0)}#n=t=>{const n=this.toasts.findIndex(s=>s.id===t);return n===-1?null:n};addToast=t=>{rt&&this.toasts.unshift(t)};updateToast=({id:t,data:n,type:s,message:i})=>{const a=this.toasts.findIndex(c=>c.id===t),o=this.toasts[a];this.toasts[a]={...o,...n,id:t,title:i,type:s,updated:!0}};create=t=>{const{message:n,...s}=t,i=typeof t?.id=="number"||t.id&&t.id?.length>0?t.id:ue++,a=t.dismissible!==void 0?t.dismissible:t.dismissable!==void 0?t.dismissable:!0,o=t.type===void 0?"default":t.type;return ie(()=>{this.toasts.find(u=>u.id===i)?this.updateToast({id:i,data:t,type:o,message:n,dismissible:a}):this.addToast({...s,id:i,title:n,dismissible:a,type:o})}),i};dismiss=t=>(ie(()=>{if(t===void 0){this.toasts=this.toasts.map(s=>({...s,dismiss:!0}));return}const n=this.toasts.findIndex(s=>s.id===t);this.toasts[n]&&(this.toasts[n]={...this.toasts[n],dismiss:!0})}),t);remove=t=>{if(t===void 0){this.toasts=[];return}const n=this.#n(t);if(n!==null)return this.toasts.splice(n,1),t};message=(t,n)=>this.create({...n,type:"default",message:t});error=(t,n)=>this.create({...n,type:"error",message:t});success=(t,n)=>this.create({...n,type:"success",message:t});info=(t,n)=>this.create({...n,type:"info",message:t});warning=(t,n)=>this.create({...n,type:"warning",message:t});loading=(t,n)=>this.create({...n,type:"loading",message:t});promise=(t,n)=>{if(!n)return;let s;n.loading!==void 0&&(s=this.create({...n,promise:t,type:"loading",message:typeof n.loading=="string"?n.loading:n.loading()}));const i=t instanceof Promise?t:t();let a=s!==void 0;return i.then(o=>{if(typeof o=="object"&&o&&"ok"in o&&typeof o.ok=="boolean"&&!o.ok){a=!1;const c=ot(o);this.create({id:s,type:"error",message:c})}else if(n.success!==void 0){a=!1;const c=typeof n.success=="function"?n.success(o):n.success;this.create({id:s,type:"success",message:c})}}).catch(o=>{if(n.error!==void 0){a=!1;const c=typeof n.error=="function"?n.error(o):n.error;this.create({id:s,type:"error",message:c})}}).finally(()=>{a&&(this.dismiss(s),s=void 0),n.finally?.()}),s};custom=(t,n)=>{const s=n?.id||ue++;return this.create({component:t,id:s,...n}),s};removeHeight=t=>{this.heights=this.heights.filter(n=>n.toastId!==t)};setHeight=t=>{const n=this.#n(t.toastId);if(n===null){this.heights.push(t);return}this.heights[n]=t};reset=()=>{this.toasts=[],this.heights=[]}}function ot(e){return e&&typeof e=="object"&&"status"in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}const A=new it;function at(e,t){return A.create({message:e,...t})}class Ht{#e=Je(()=>A.toasts.filter(t=>!t.dismiss));get toasts(){return p(this.#e)}}const lt=at,S=Object.assign(lt,{success:A.success,info:A.info,warning:A.warning,error:A.error,custom:A.custom,message:A.message,promise:A.promise,dismiss:A.dismiss,loading:A.loading,getActiveToasts:()=>A.toasts.filter(e=>!e.dismiss)}),ut=800;function ct(){let e=b(!1),t=b(null),n=b(null),s=null,i=null,a=!1;function o(h,g,m,y){s&&s.repo===h&&s.type===g&&s.id===m?(y.data!==void 0&&(s.payload.data=y.data),y.content!==void 0&&(s.payload.content=y.content)):s={repo:h,type:g,id:m,payload:{...y}},c()}function c(){i&&clearTimeout(i),i=setTimeout(u,ut)}async function u(){if(i=null,!a&&s){const{repo:h,type:g,id:m,payload:y}=s;s=null,a=!0,d(e,!0),d(n,null);try{if(await ae(h,g,m,y),d(t,new Date,!0),y.data?.name){const f=C.repos.find(x=>x.name===h)?.entities.find(x=>x.id===m);f&&(f.title=y.data.name)}}catch(r){d(n,r.message??"Save failed",!0);const f=r.status??r.statusCode;(!f||f>=500)&&(s={repo:h,type:g,id:m,payload:y})}finally{d(e,!1),a=!1,s&&u()}}}function E(){i&&(clearTimeout(i),i=null),s&&u()}async function l(h,g,m,y){d(e,!0),d(n,null);try{const r=await ae(h,g,m,y);return d(t,new Date,!0),r}catch(r){return d(n,r.message??"Save failed",!0),null}finally{d(e,!1)}}function T(){d(n,null),d(t,null),s=null,i&&(clearTimeout(i),i=null)}return{get saving(){return p(e)},get lastSaved(){return p(t)},get error(){return p(n)},get hasPending(){return!!(s||a)},scheduleAutoSave:o,flush:E,saveEntity:l,reset:T}}const ft=ct();let _=null,me=null,ye=null,Ee=[],Y=null,q=1e3,J=b(!1),Te=b(null);const D=new Map,W={},j={};function ce(e,t){D.delete(e);const n=t.entities.length,s=n===1?`${e} updated ${t.entities[0]}`:`${e} updated ${n} entities`;S(s)}function dt(e){for(const[t,n]of D)n.repo===e&&(clearTimeout(n.timer),D.delete(t))}function ht(e){const t=je.user?.displayName;if(e.type==="sync_progress"){const n=W[e.repo];if(n){const s=e.message.trim(),i=s.match(/^Syncing from source:\s*(.+)$/i);i&&(j[e.repo]=`Syncing ${i[1].trim()}…`);const a=j[e.repo]??`Syncing ${e.repo}…`;S.loading(a,{id:n,description:s,duration:36e5})}return}if(e.type==="entity_change"){if(t&&e.actor===t&&e.source==="api"){C.refreshEntities(e.repo);return}if(C.refreshEntities(e.repo),L.selectedRepo===e.repo&&L.selectedType===e.entityType&&L.selectedId===e.entityId){ft.hasPending?S(`${e.actor} also saved changes to this entity`):Ze();return}const s=D.get(e.actor);if(s)clearTimeout(s.timer),s.entities.includes(e.entityId)||s.entities.push(e.entityId),s.timer=setTimeout(()=>ce(e.actor,s),1e4);else{const i={entities:[e.entityId],repo:e.repo,timer:setTimeout(()=>ce(e.actor,i),1e4)};D.set(e.actor,i)}return}if(e.type==="session_commit"){if(t&&e.actor===t){d(Te,e.timestamp,!0);return}const n=e.entities.length,s=n===1?`${e.actor} saved changes to ${e.entities[0]}`:`${e.actor} saved ${n} changes in ${e.repo}`;S(s),C.refreshEntities(e.repo);return}if(e.type==="sync_complete"){if(dt(e.repo),!W[e.repo]){const n=e.created+e.updated+e.deleted,s=n===0?`Sync complete · no changes in ${e.repo}`:`Sync complete · ${n} ${n===1?"entity":"entities"} from ${e.source}`;S.success(s)}C.refreshEntities(e.repo);return}if(e.type==="collection_created"){S(`${e.actor} created collection ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="collection_deleted"){S(`${e.actor} deleted collection ${e.repo}`);return}if(e.type==="repo_sync"){S(`${e.actor} pushed to ${e.repo}`),C.refreshEntities(e.repo);return}if(e.type==="presence"){me?.(e);return}if(e.type==="online"){ye?.(e);return}if(e.type==="access_granted"||e.type==="access_revoked"){e.type==="access_revoked"&&L.selectedRepo===e.repo&&L.deselect(),C.load();return}}function _e(){if(typeof window>"u"||_&&(_.readyState===WebSocket.OPEN||_.readyState===WebSocket.CONNECTING))return;const t=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;_=new WebSocket(t),_.binaryType="arraybuffer",_.onopen=()=>{d(J,!0),q=1e3,C.refreshAll();for(const n of Ee)n()},_.onmessage=n=>{if(!(n.data instanceof ArrayBuffer))try{const s=JSON.parse(n.data);if(s?.type==="ping"){_?.send(JSON.stringify({type:"pong"}));return}const i=s;i.type&&i.type!=="toast"&&ht(i)}catch{}},_.onclose=()=>{d(J,!1),_=null,Y=setTimeout(()=>{q=Math.min(q*2,1e4),_e()},q)},_.onerror=()=>{}}function pt(){Y&&(clearTimeout(Y),Y=null),_&&(_.close(),_=null),d(J,!1);for(const[,e]of D)clearTimeout(e.timer);D.clear()}function gt(e,t=4e3){S(e,{duration:t})}function mt(e,t){const n=crypto.randomUUID();return t?.loading?S.loading(e,{id:n,duration:36e5}):S(e,{id:n}),n}function yt(e,t,n){if(n?.loading){S.loading(t,{id:e});return}/failed|error/i.test(t)?S.error(t,{id:e,duration:n?.duration??6e3}):S.success(t,{id:e,duration:n?.duration??4e3})}function Et(e){const t=crypto.randomUUID();W[e]=t,S.loading(`Syncing ${e}…`,{id:t,duration:36e5})}function Tt(e,t,n){const s=W[e];s&&(delete W[e],delete j[e],n?S.error(t,{id:s,duration:6e3}):S.success(t,{id:s,duration:4e3}))}function _t(e){me=e}function St(e){ye=e}function vt(e){Ee.push(e)}function wt(e){_?.readyState===WebSocket.OPEN&&_.send(JSON.stringify(e))}const Rt={get connected(){return p(J)},get lastAutoSaved(){return p(Te)},get ws(){return _},connect:_e,disconnect:pt,showToast:gt,showPersistentToast:mt,updateToast:yt,startSyncToast:Et,finishSyncToast:Tt,send:wt,setPresenceHandler:_t,setOnlineHandler:St,addConnectHandler:vt};export{Ht as S,ft as a,Ot as b,kt as c,Nt as e,Ct as i,L as n,Rt as r,A as t};