spragkit 0.1.0__py3-none-any.whl

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 (293) hide show
  1. sprag/__init__.py +169 -0
  2. sprag/__main__.py +7 -0
  3. sprag/assets/RAGOT_LICENSE +203 -0
  4. sprag/assets/RAGOT_NOTICE +5 -0
  5. sprag/assets/ragot.esm.min.js +16 -0
  6. sprag/dev/__init__.py +1 -0
  7. sprag/dev/__main__.py +5 -0
  8. sprag/dev/build.py +502 -0
  9. sprag/dev/cli.py +983 -0
  10. sprag/dev/codegen/__init__.py +49 -0
  11. sprag/dev/codegen/components.py +795 -0
  12. sprag/dev/codegen/dependencies.py +147 -0
  13. sprag/dev/codegen/diagnostics.py +620 -0
  14. sprag/dev/codegen/emit.py +459 -0
  15. sprag/dev/codegen/expressions.py +621 -0
  16. sprag/dev/codegen/imports.py +88 -0
  17. sprag/dev/codegen/mappings.py +205 -0
  18. sprag/dev/codegen/modules.py +846 -0
  19. sprag/dev/codegen/source_maps.py +115 -0
  20. sprag/dev/codegen/statements.py +596 -0
  21. sprag/dev/codegen/stores_scan.py +109 -0
  22. sprag/dev/pack.py +915 -0
  23. sprag/dev/package.py +287 -0
  24. sprag/dev/scaffold.py +348 -0
  25. sprag/dev/templates/_content/article/__init__.py.tmpl +1 -0
  26. sprag/dev/templates/_content/article/components.py.tmpl +39 -0
  27. sprag/dev/templates/_content/article/page.py.tmpl +19 -0
  28. sprag/dev/templates/_content/article/server.py.tmpl +21 -0
  29. sprag/dev/templates/_content/article/web.py.tmpl +8 -0
  30. sprag/dev/templates/_content/index/__init__.py.tmpl +1 -0
  31. sprag/dev/templates/_content/index/components.py.tmpl +30 -0
  32. sprag/dev/templates/_content/index/page.py.tmpl +13 -0
  33. sprag/dev/templates/_content/index/server.py.tmpl +20 -0
  34. sprag/dev/templates/_content/index/web.py.tmpl +8 -0
  35. sprag/dev/templates/_content/starter/getting-started.md.tmpl +19 -0
  36. sprag/dev/templates/_content/support/content_support.py.tmpl +36 -0
  37. sprag/dev/templates/_mount/__init__.py.tmpl +1 -0
  38. sprag/dev/templates/_mount/modules.py.tmpl +73 -0
  39. sprag/dev/templates/_mount/mount.py.tmpl +14 -0
  40. sprag/dev/templates/_mount/server.py.tmpl +13 -0
  41. sprag/dev/templates/_mount/web.py.tmpl +88 -0
  42. sprag/dev/templates/_route/document/__init__.py.tmpl +1 -0
  43. sprag/dev/templates/_route/document/components.py.tmpl +11 -0
  44. sprag/dev/templates/_route/document/page.py.tmpl +13 -0
  45. sprag/dev/templates/_route/document/server.py.tmpl +11 -0
  46. sprag/dev/templates/_route/document/web.py.tmpl +12 -0
  47. sprag/dev/templates/_route/hybrid/__init__.py.tmpl +1 -0
  48. sprag/dev/templates/_route/hybrid/components.py.tmpl +14 -0
  49. sprag/dev/templates/_route/hybrid/modules.py.tmpl +18 -0
  50. sprag/dev/templates/_route/hybrid/page.py.tmpl +13 -0
  51. sprag/dev/templates/_route/hybrid/server.py.tmpl +12 -0
  52. sprag/dev/templates/_route/hybrid/web.py.tmpl +12 -0
  53. sprag/dev/templates/bare/README.md.tmpl +35 -0
  54. sprag/dev/templates/bare/app/__init__.py.tmpl +4 -0
  55. sprag/dev/templates/bare/app/routes/__init__.py.tmpl +1 -0
  56. sprag/dev/templates/bare/requirements.txt.tmpl +1 -0
  57. sprag/dev/templates/default/README.md.tmpl +119 -0
  58. sprag/dev/templates/default/app/__init__.py.tmpl +7 -0
  59. sprag/dev/templates/default/app/routes/__init__.py.tmpl +1 -0
  60. sprag/dev/templates/default/app/routes/about/__init__.py.tmpl +1 -0
  61. sprag/dev/templates/default/app/routes/about/components.py.tmpl +48 -0
  62. sprag/dev/templates/default/app/routes/about/page.py.tmpl +13 -0
  63. sprag/dev/templates/default/app/routes/about/server.py.tmpl +10 -0
  64. sprag/dev/templates/default/app/routes/about/web.py.tmpl +8 -0
  65. sprag/dev/templates/default/app/routes/counter/__init__.py.tmpl +1 -0
  66. sprag/dev/templates/default/app/routes/counter/components.py.tmpl +19 -0
  67. sprag/dev/templates/default/app/routes/counter/modules.py.tmpl +34 -0
  68. sprag/dev/templates/default/app/routes/counter/page.py.tmpl +13 -0
  69. sprag/dev/templates/default/app/routes/counter/server.py.tmpl +16 -0
  70. sprag/dev/templates/default/app/routes/counter/web.py.tmpl +24 -0
  71. sprag/dev/templates/default/app/routes/home/__init__.py.tmpl +1 -0
  72. sprag/dev/templates/default/app/routes/home/components.py.tmpl +42 -0
  73. sprag/dev/templates/default/app/routes/home/page.py.tmpl +13 -0
  74. sprag/dev/templates/default/app/routes/home/server.py.tmpl +17 -0
  75. sprag/dev/templates/default/app/routes/home/web.py.tmpl +13 -0
  76. sprag/dev/templates/default/app/shell.css.tmpl +125 -0
  77. sprag/dev/templates/default/app/shell.html.tmpl +21 -0
  78. sprag/dev/templates/default/app/stores.py.tmpl +19 -0
  79. sprag/dev/templates/default/requirements.txt.tmpl +1 -0
  80. sprag/dev/templates/docs/README.md.tmpl +40 -0
  81. sprag/dev/templates/docs/app/__init__.py.tmpl +10 -0
  82. sprag/dev/templates/docs/app/content/blog/file-based-routing.md.tmpl +28 -0
  83. sprag/dev/templates/docs/app/content/blog/launching-static-docs.md.tmpl +27 -0
  84. sprag/dev/templates/docs/app/content/docs/getting-started.md.tmpl +46 -0
  85. sprag/dev/templates/docs/app/content/docs/guides/static-deployment.md.tmpl +31 -0
  86. sprag/dev/templates/docs/app/content.py.tmpl +46 -0
  87. sprag/dev/templates/docs/app/routes/__init__.py.tmpl +1 -0
  88. sprag/dev/templates/docs/app/routes/blog/[slug]/__init__.py.tmpl +1 -0
  89. sprag/dev/templates/docs/app/routes/blog/[slug]/components.py.tmpl +29 -0
  90. sprag/dev/templates/docs/app/routes/blog/[slug]/page.py.tmpl +15 -0
  91. sprag/dev/templates/docs/app/routes/blog/[slug]/server.py.tmpl +17 -0
  92. sprag/dev/templates/docs/app/routes/blog/[slug]/web.py.tmpl +8 -0
  93. sprag/dev/templates/docs/app/routes/blog/__init__.py.tmpl +1 -0
  94. sprag/dev/templates/docs/app/routes/blog/components.py.tmpl +46 -0
  95. sprag/dev/templates/docs/app/routes/blog/page.py.tmpl +13 -0
  96. sprag/dev/templates/docs/app/routes/blog/server.py.tmpl +18 -0
  97. sprag/dev/templates/docs/app/routes/blog/web.py.tmpl +8 -0
  98. sprag/dev/templates/docs/app/routes/docs/[...segments]/__init__.py.tmpl +1 -0
  99. sprag/dev/templates/docs/app/routes/docs/[...segments]/components.py.tmpl +29 -0
  100. sprag/dev/templates/docs/app/routes/docs/[...segments]/page.py.tmpl +15 -0
  101. sprag/dev/templates/docs/app/routes/docs/[...segments]/server.py.tmpl +18 -0
  102. sprag/dev/templates/docs/app/routes/docs/[...segments]/web.py.tmpl +8 -0
  103. sprag/dev/templates/docs/app/routes/docs/__init__.py.tmpl +1 -0
  104. sprag/dev/templates/docs/app/routes/docs/components.py.tmpl +37 -0
  105. sprag/dev/templates/docs/app/routes/docs/page.py.tmpl +13 -0
  106. sprag/dev/templates/docs/app/routes/docs/server.py.tmpl +19 -0
  107. sprag/dev/templates/docs/app/routes/docs/web.py.tmpl +8 -0
  108. sprag/dev/templates/docs/app/routes/home/__init__.py.tmpl +1 -0
  109. sprag/dev/templates/docs/app/routes/home/components.py.tmpl +78 -0
  110. sprag/dev/templates/docs/app/routes/home/page.py.tmpl +13 -0
  111. sprag/dev/templates/docs/app/routes/home/server.py.tmpl +23 -0
  112. sprag/dev/templates/docs/app/routes/home/web.py.tmpl +8 -0
  113. sprag/dev/templates/docs/app/routes/playground/__init__.py.tmpl +1 -0
  114. sprag/dev/templates/docs/app/routes/playground/components.py.tmpl +64 -0
  115. sprag/dev/templates/docs/app/routes/playground/modules.py.tmpl +45 -0
  116. sprag/dev/templates/docs/app/routes/playground/page.py.tmpl +13 -0
  117. sprag/dev/templates/docs/app/routes/playground/server.py.tmpl +13 -0
  118. sprag/dev/templates/docs/app/routes/playground/web.py.tmpl +13 -0
  119. sprag/dev/templates/docs/app/shell.css.tmpl +462 -0
  120. sprag/dev/templates/docs/app/shell.html.tmpl +18 -0
  121. sprag/dev/templates/docs/app/site.py.tmpl +45 -0
  122. sprag/dev/templates/docs/requirements.txt.tmpl +1 -0
  123. sprag/dev/templates/labs/README.md.tmpl +68 -0
  124. sprag/dev/templates/labs/app/__init__.py.tmpl +21 -0
  125. sprag/dev/templates/labs/app/mounts/__init__.py.tmpl +1 -0
  126. sprag/dev/templates/labs/app/mounts/lifecycle_demo/__init__.py.tmpl +1 -0
  127. sprag/dev/templates/labs/app/mounts/lifecycle_demo/lifecycle.css.tmpl +99 -0
  128. sprag/dev/templates/labs/app/mounts/lifecycle_demo/modules.py.tmpl +89 -0
  129. sprag/dev/templates/labs/app/mounts/lifecycle_demo/mount.py.tmpl +15 -0
  130. sprag/dev/templates/labs/app/mounts/lifecycle_demo/server.py.tmpl +11 -0
  131. sprag/dev/templates/labs/app/mounts/lifecycle_demo/web.py.tmpl +168 -0
  132. sprag/dev/templates/labs/app/routes/__init__.py.tmpl +1 -0
  133. sprag/dev/templates/labs/app/routes/animation_demo/__init__.py.tmpl +1 -0
  134. sprag/dev/templates/labs/app/routes/animation_demo/components.py.tmpl +25 -0
  135. sprag/dev/templates/labs/app/routes/animation_demo/modules.py.tmpl +31 -0
  136. sprag/dev/templates/labs/app/routes/animation_demo/page.py.tmpl +13 -0
  137. sprag/dev/templates/labs/app/routes/animation_demo/server.py.tmpl +11 -0
  138. sprag/dev/templates/labs/app/routes/animation_demo/web.py.tmpl +13 -0
  139. sprag/dev/templates/labs/app/routes/auth_demo/__init__.py.tmpl +1 -0
  140. sprag/dev/templates/labs/app/routes/auth_demo/protected/__init__.py.tmpl +1 -0
  141. sprag/dev/templates/labs/app/routes/auth_demo/protected/components.py.tmpl +76 -0
  142. sprag/dev/templates/labs/app/routes/auth_demo/protected/modules.py.tmpl +102 -0
  143. sprag/dev/templates/labs/app/routes/auth_demo/protected/page.py.tmpl +13 -0
  144. sprag/dev/templates/labs/app/routes/auth_demo/protected/server.py.tmpl +58 -0
  145. sprag/dev/templates/labs/app/routes/auth_demo/protected/web.py.tmpl +22 -0
  146. sprag/dev/templates/labs/app/routes/counter/__init__.py.tmpl +1 -0
  147. sprag/dev/templates/labs/app/routes/counter/components.py.tmpl +19 -0
  148. sprag/dev/templates/labs/app/routes/counter/modules.py.tmpl +23 -0
  149. sprag/dev/templates/labs/app/routes/counter/page.py.tmpl +13 -0
  150. sprag/dev/templates/labs/app/routes/counter/server.py.tmpl +16 -0
  151. sprag/dev/templates/labs/app/routes/counter/web.py.tmpl +12 -0
  152. sprag/dev/templates/labs/app/routes/cross_wired_demo/__init__.py.tmpl +1 -0
  153. sprag/dev/templates/labs/app/routes/cross_wired_demo/components.py.tmpl +50 -0
  154. sprag/dev/templates/labs/app/routes/cross_wired_demo/modules.py.tmpl +42 -0
  155. sprag/dev/templates/labs/app/routes/cross_wired_demo/page.py.tmpl +12 -0
  156. sprag/dev/templates/labs/app/routes/cross_wired_demo/server.py.tmpl +20 -0
  157. sprag/dev/templates/labs/app/routes/cross_wired_demo/web.py.tmpl +26 -0
  158. sprag/dev/templates/labs/app/routes/defer_demo/__init__.py.tmpl +0 -0
  159. sprag/dev/templates/labs/app/routes/defer_demo/components.py.tmpl +47 -0
  160. sprag/dev/templates/labs/app/routes/defer_demo/modules.py.tmpl +62 -0
  161. sprag/dev/templates/labs/app/routes/defer_demo/page.py.tmpl +13 -0
  162. sprag/dev/templates/labs/app/routes/defer_demo/server.py.tmpl +35 -0
  163. sprag/dev/templates/labs/app/routes/defer_demo/web.py.tmpl +13 -0
  164. sprag/dev/templates/labs/app/routes/form_demo/__init__.py.tmpl +1 -0
  165. sprag/dev/templates/labs/app/routes/form_demo/components.py.tmpl +142 -0
  166. sprag/dev/templates/labs/app/routes/form_demo/modules.py.tmpl +193 -0
  167. sprag/dev/templates/labs/app/routes/form_demo/page.py.tmpl +13 -0
  168. sprag/dev/templates/labs/app/routes/form_demo/server.py.tmpl +114 -0
  169. sprag/dev/templates/labs/app/routes/form_demo/web.py.tmpl +13 -0
  170. sprag/dev/templates/labs/app/routes/form_success/__init__.py.tmpl +1 -0
  171. sprag/dev/templates/labs/app/routes/form_success/components.py.tmpl +22 -0
  172. sprag/dev/templates/labs/app/routes/form_success/page.py.tmpl +13 -0
  173. sprag/dev/templates/labs/app/routes/form_success/server.py.tmpl +13 -0
  174. sprag/dev/templates/labs/app/routes/form_success/web.py.tmpl +8 -0
  175. sprag/dev/templates/labs/app/routes/home/__init__.py.tmpl +1 -0
  176. sprag/dev/templates/labs/app/routes/home/components.py.tmpl +212 -0
  177. sprag/dev/templates/labs/app/routes/home/page.py.tmpl +13 -0
  178. sprag/dev/templates/labs/app/routes/home/server.py.tmpl +15 -0
  179. sprag/dev/templates/labs/app/routes/home/web.py.tmpl +8 -0
  180. sprag/dev/templates/labs/app/routes/js_global_demo/__init__.py.tmpl +1 -0
  181. sprag/dev/templates/labs/app/routes/js_global_demo/components.py.tmpl +16 -0
  182. sprag/dev/templates/labs/app/routes/js_global_demo/modules.py.tmpl +12 -0
  183. sprag/dev/templates/labs/app/routes/js_global_demo/page.py.tmpl +14 -0
  184. sprag/dev/templates/labs/app/routes/js_global_demo/server.py.tmpl +8 -0
  185. sprag/dev/templates/labs/app/routes/js_global_demo/web.py.tmpl +11 -0
  186. sprag/dev/templates/labs/app/routes/js_module_demo/__init__.py.tmpl +1 -0
  187. sprag/dev/templates/labs/app/routes/js_module_demo/components.py.tmpl +18 -0
  188. sprag/dev/templates/labs/app/routes/js_module_demo/modules.py.tmpl +15 -0
  189. sprag/dev/templates/labs/app/routes/js_module_demo/page.py.tmpl +14 -0
  190. sprag/dev/templates/labs/app/routes/js_module_demo/server.py.tmpl +8 -0
  191. sprag/dev/templates/labs/app/routes/js_module_demo/web.py.tmpl +12 -0
  192. sprag/dev/templates/labs/app/routes/login/__init__.py.tmpl +1 -0
  193. sprag/dev/templates/labs/app/routes/login/components.py.tmpl +84 -0
  194. sprag/dev/templates/labs/app/routes/login/modules.py.tmpl +70 -0
  195. sprag/dev/templates/labs/app/routes/login/page.py.tmpl +13 -0
  196. sprag/dev/templates/labs/app/routes/login/server.py.tmpl +55 -0
  197. sprag/dev/templates/labs/app/routes/login/web.py.tmpl +22 -0
  198. sprag/dev/templates/labs/app/routes/metadata_demo/__init__.py.tmpl +1 -0
  199. sprag/dev/templates/labs/app/routes/metadata_demo/components.py.tmpl +106 -0
  200. sprag/dev/templates/labs/app/routes/metadata_demo/modules.py.tmpl +60 -0
  201. sprag/dev/templates/labs/app/routes/metadata_demo/page.py.tmpl +13 -0
  202. sprag/dev/templates/labs/app/routes/metadata_demo/server.py.tmpl +27 -0
  203. sprag/dev/templates/labs/app/routes/metadata_demo/web.py.tmpl +13 -0
  204. sprag/dev/templates/labs/app/routes/nested_store_demo/__init__.py.tmpl +1 -0
  205. sprag/dev/templates/labs/app/routes/nested_store_demo/components.py.tmpl +44 -0
  206. sprag/dev/templates/labs/app/routes/nested_store_demo/modules.py.tmpl +94 -0
  207. sprag/dev/templates/labs/app/routes/nested_store_demo/page.py.tmpl +13 -0
  208. sprag/dev/templates/labs/app/routes/nested_store_demo/server.py.tmpl +58 -0
  209. sprag/dev/templates/labs/app/routes/nested_store_demo/web.py.tmpl +36 -0
  210. sprag/dev/templates/labs/app/routes/operation_demo/__init__.py.tmpl +1 -0
  211. sprag/dev/templates/labs/app/routes/operation_demo/components.py.tmpl +34 -0
  212. sprag/dev/templates/labs/app/routes/operation_demo/modules.py.tmpl +58 -0
  213. sprag/dev/templates/labs/app/routes/operation_demo/page.py.tmpl +13 -0
  214. sprag/dev/templates/labs/app/routes/operation_demo/server.py.tmpl +34 -0
  215. sprag/dev/templates/labs/app/routes/operation_demo/web.py.tmpl +13 -0
  216. sprag/dev/templates/labs/app/routes/queue_demo/__init__.py.tmpl +1 -0
  217. sprag/dev/templates/labs/app/routes/queue_demo/components.py.tmpl +67 -0
  218. sprag/dev/templates/labs/app/routes/queue_demo/modules.py.tmpl +53 -0
  219. sprag/dev/templates/labs/app/routes/queue_demo/page.py.tmpl +13 -0
  220. sprag/dev/templates/labs/app/routes/queue_demo/server.py.tmpl +29 -0
  221. sprag/dev/templates/labs/app/routes/queue_demo/web.py.tmpl +13 -0
  222. sprag/dev/templates/labs/app/routes/socket_demo/__init__.py.tmpl +1 -0
  223. sprag/dev/templates/labs/app/routes/socket_demo/components.py.tmpl +44 -0
  224. sprag/dev/templates/labs/app/routes/socket_demo/modules.py.tmpl +85 -0
  225. sprag/dev/templates/labs/app/routes/socket_demo/page.py.tmpl +13 -0
  226. sprag/dev/templates/labs/app/routes/socket_demo/server.py.tmpl +53 -0
  227. sprag/dev/templates/labs/app/routes/socket_demo/web.py.tmpl +13 -0
  228. sprag/dev/templates/labs/app/routes/store_demo/__init__.py.tmpl +1 -0
  229. sprag/dev/templates/labs/app/routes/store_demo/components.py.tmpl +20 -0
  230. sprag/dev/templates/labs/app/routes/store_demo/modules.py.tmpl +23 -0
  231. sprag/dev/templates/labs/app/routes/store_demo/page.py.tmpl +13 -0
  232. sprag/dev/templates/labs/app/routes/store_demo/server.py.tmpl +24 -0
  233. sprag/dev/templates/labs/app/routes/store_demo/web.py.tmpl +28 -0
  234. sprag/dev/templates/labs/app/routes/upload_demo/__init__.py.tmpl +1 -0
  235. sprag/dev/templates/labs/app/routes/upload_demo/components.py.tmpl +198 -0
  236. sprag/dev/templates/labs/app/routes/upload_demo/modules.py.tmpl +126 -0
  237. sprag/dev/templates/labs/app/routes/upload_demo/page.py.tmpl +12 -0
  238. sprag/dev/templates/labs/app/routes/upload_demo/server.py.tmpl +142 -0
  239. sprag/dev/templates/labs/app/routes/upload_demo/web.py.tmpl +13 -0
  240. sprag/dev/templates/labs/app/routes/virtual_scroll/__init__.py.tmpl +1 -0
  241. sprag/dev/templates/labs/app/routes/virtual_scroll/components.py.tmpl +59 -0
  242. sprag/dev/templates/labs/app/routes/virtual_scroll/page.py.tmpl +13 -0
  243. sprag/dev/templates/labs/app/routes/virtual_scroll/server.py.tmpl +10 -0
  244. sprag/dev/templates/labs/app/routes/virtual_scroll/web.py.tmpl +25 -0
  245. sprag/dev/templates/labs/app/routes/watcher_demo/__init__.py.tmpl +1 -0
  246. sprag/dev/templates/labs/app/routes/watcher_demo/components.py.tmpl +26 -0
  247. sprag/dev/templates/labs/app/routes/watcher_demo/modules.py.tmpl +19 -0
  248. sprag/dev/templates/labs/app/routes/watcher_demo/page.py.tmpl +13 -0
  249. sprag/dev/templates/labs/app/routes/watcher_demo/server.py.tmpl +9 -0
  250. sprag/dev/templates/labs/app/routes/watcher_demo/web.py.tmpl +13 -0
  251. sprag/dev/templates/labs/app/services/__init__.py.tmpl +1 -0
  252. sprag/dev/templates/labs/app/services/auth.py.tmpl +184 -0
  253. sprag/dev/templates/labs/app/services/job_queue.py.tmpl +163 -0
  254. sprag/dev/templates/labs/app/services/pulse.py.tmpl +57 -0
  255. sprag/dev/templates/labs/app/shell.css.tmpl +259 -0
  256. sprag/dev/templates/labs/app/shell.html.tmpl +28 -0
  257. sprag/dev/templates/labs/app/static/vendor/create-pulse.mjs.tmpl +23 -0
  258. sprag/dev/templates/labs/app/static/vendor/spark-widget.js.tmpl +27 -0
  259. sprag/dev/templates/labs/app/stores.py.tmpl +55 -0
  260. sprag/dev/templates/labs/requirements.txt.tmpl +2 -0
  261. sprag/runtime/__init__.py +13 -0
  262. sprag/runtime/app.py +249 -0
  263. sprag/runtime/assets.py +360 -0
  264. sprag/runtime/attrs.py +25 -0
  265. sprag/runtime/browser.py +623 -0
  266. sprag/runtime/content.py +245 -0
  267. sprag/runtime/discovery.py +230 -0
  268. sprag/runtime/dom.py +157 -0
  269. sprag/runtime/env.py +146 -0
  270. sprag/runtime/http/__init__.py +10 -0
  271. sprag/runtime/http/wsgi.py +1262 -0
  272. sprag/runtime/loader.py +49 -0
  273. sprag/runtime/mount.py +68 -0
  274. sprag/runtime/observability.py +87 -0
  275. sprag/runtime/page.py +63 -0
  276. sprag/runtime/rendering/__init__.py +36 -0
  277. sprag/runtime/rendering/page.py +684 -0
  278. sprag/runtime/rendering/tree.py +229 -0
  279. sprag/runtime/request.py +74 -0
  280. sprag/runtime/routing.py +228 -0
  281. sprag/runtime/server.py +1481 -0
  282. sprag/runtime/session.py +530 -0
  283. sprag/runtime/shell.py +187 -0
  284. sprag/runtime/socket_bridge.py +420 -0
  285. sprag/runtime/stores.py +252 -0
  286. sprag/runtime/ui.py +161 -0
  287. sprag/runtime/uploads.py +221 -0
  288. spragkit-0.1.0.dist-info/METADATA +681 -0
  289. spragkit-0.1.0.dist-info/RECORD +293 -0
  290. spragkit-0.1.0.dist-info/WHEEL +5 -0
  291. spragkit-0.1.0.dist-info/entry_points.txt +2 -0
  292. spragkit-0.1.0.dist-info/licenses/LICENSE +201 -0
  293. spragkit-0.1.0.dist-info/top_level.txt +1 -0
sprag/__init__.py ADDED
@@ -0,0 +1,169 @@
1
+ """Public SPRAG framework surface."""
2
+
3
+ __version__ = "0.1.0"
4
+
5
+ from .runtime import dom
6
+ from .runtime.app import App
7
+ from .runtime.assets import ModuleImport, Script, module, script
8
+ from .runtime.content import ContentDocument, load_markdown_document, load_markdown_tree, slugify
9
+ from .runtime.env import env, public_env
10
+ from .runtime.mount import Mount, mount
11
+ from .runtime.page import Page, page
12
+ from .runtime.request import Request, UploadedFile
13
+ from .runtime.session import AnonymousAuthService, InMemorySessionStore, SessionPolicy
14
+ from .runtime.shell import Shell, shell
15
+ from .runtime.server import (
16
+ Redirect,
17
+ redirect,
18
+ socket_target,
19
+ action,
20
+ requires_auth,
21
+ # Core (already exposed)
22
+ Controller,
23
+ Field,
24
+ Outcome,
25
+ Schema,
26
+ Service,
27
+ registry,
28
+ # HTTP / routing
29
+ HTTPError,
30
+ Router,
31
+ expect_json,
32
+ json_endpoint,
33
+ require_fields,
34
+ route,
35
+ # Operations
36
+ Operation,
37
+ OperationError,
38
+ # State
39
+ Cache,
40
+ Model,
41
+ Store,
42
+ create_cache,
43
+ create_model,
44
+ create_store,
45
+ # Communication
46
+ bus,
47
+ # Workers
48
+ QueueService,
49
+ # Realtime
50
+ Handler,
51
+ SocketIngress,
52
+ # System
53
+ ManagedProcess,
54
+ Watcher,
55
+ WatcherError,
56
+ start_process,
57
+ # Orchestration
58
+ ServiceManager,
59
+ boot,
60
+ )
61
+ from .runtime.stores import StoreBridge, declared_stores, store
62
+ from .runtime.ui import ui
63
+ from .runtime.browser import (
64
+ Component,
65
+ Module,
66
+ Screen,
67
+ animate,
68
+ browser,
69
+ debounce,
70
+ hydrate,
71
+ infinite_scroll,
72
+ imports,
73
+ ref,
74
+ ssr,
75
+ throttle,
76
+ virtual_scroll,
77
+ )
78
+
79
+ __all__ = [
80
+ "__version__",
81
+ # App
82
+ "App",
83
+ "ContentDocument",
84
+ "Mount",
85
+ "Page",
86
+ "Request",
87
+ "Redirect",
88
+ "Shell",
89
+ "UploadedFile",
90
+ "AnonymousAuthService",
91
+ "InMemorySessionStore",
92
+ "SessionPolicy",
93
+ "action",
94
+ "mount",
95
+ "load_markdown_document",
96
+ "load_markdown_tree",
97
+ "page",
98
+ "redirect",
99
+ "socket_target",
100
+ "requires_auth",
101
+ "env",
102
+ "public_env",
103
+ # Web authoring
104
+ "Component",
105
+ "Module",
106
+ "Screen",
107
+ "dom",
108
+ "hydrate",
109
+ "ssr",
110
+ "ui",
111
+ # State bridge (one declaration, two runtimes)
112
+ "StoreBridge",
113
+ "declared_stores",
114
+ "store",
115
+ "ModuleImport",
116
+ "Script",
117
+ "module",
118
+ "script",
119
+ "slugify",
120
+ # Client-side decorators (justified — see sprag/browser.py)
121
+ "animate",
122
+ "browser",
123
+ "debounce",
124
+ "infinite_scroll",
125
+ "imports",
126
+ "ref",
127
+ "throttle",
128
+ "virtual_scroll",
129
+ # Core server
130
+ "Controller",
131
+ "Field",
132
+ "Outcome",
133
+ "Schema",
134
+ "Service",
135
+ "registry",
136
+ # HTTP / routing
137
+ "HTTPError",
138
+ "Router",
139
+ "expect_json",
140
+ "json_endpoint",
141
+ "require_fields",
142
+ "route",
143
+ "shell",
144
+ # Operations
145
+ "Operation",
146
+ "OperationError",
147
+ # State
148
+ "Cache",
149
+ "Model",
150
+ "Store",
151
+ "create_cache",
152
+ "create_model",
153
+ "create_store",
154
+ # Communication
155
+ "bus",
156
+ # Workers
157
+ "QueueService",
158
+ # Realtime
159
+ "Handler",
160
+ "SocketIngress",
161
+ # System
162
+ "ManagedProcess",
163
+ "Watcher",
164
+ "WatcherError",
165
+ "start_process",
166
+ # Orchestration
167
+ "ServiceManager",
168
+ "boot",
169
+ ]
sprag/__main__.py ADDED
@@ -0,0 +1,7 @@
1
+ """Top-level package entrypoint for ``python -m sprag``."""
2
+
3
+ from .dev.cli import main
4
+
5
+
6
+ if __name__ == "__main__":
7
+ main()
@@ -0,0 +1,203 @@
1
+ Copyright 2026 BleedingXIko
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ RAGOT
2
+ Copyright 2026 BleedingXIko
3
+
4
+ This product is licensed under the Apache License, Version 2.0.
5
+ You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
@@ -0,0 +1,16 @@
1
+ /*!
2
+ * RAGOT
3
+ * Browser bundle generated from index.js
4
+ * Licensed under Apache-2.0
5
+ */
6
+ var oe=(s,e=document)=>e.querySelector(s),ae=(s,e=document)=>Array.from(e.querySelectorAll(s));var Ae=class{constructor(){this.events=new Map}on(e,t){return this.events.has(e)||this.events.set(e,new Set),this.events.get(e).add(t),()=>this.off(e,t)}off(e,t){this.events.has(e)&&(this.events.get(e).delete(t),this.events.get(e).size===0&&this.events.delete(e))}emit(e,t){if(this.events.has(e))for(let n of this.events.get(e))try{n(t)}catch(r){console.error(`[EventBus] Error in listener for ${e}:`,r)}}once(e,t){let n=r=>{this.off(e,n),t(r)};return this.on(e,n)}clear(e){e?this.events.delete(e):this.events.clear()}},ee=new Ae;function Je(){try{return typeof window!="undefined"&&window.__RAGOT_WARN_MISSING_TARGET__===!0}catch(s){return!1}}function Pe(){return typeof window!="undefined"&&window.__RAGOT_ALLOW_DIRECT_MUTATION__===!0}var Me=class{constructor(){this._entries=new Map,this._waiters=new Map}provide(e,t,n=null,r={}){let i=this._normalizeKey(e,"provide"),{replace:a=!1}=r;if(this._entries.get(i)&&!a)throw new Error(`[RAGOTRegistry] "${i}" is already provided`);let c=Symbol(`ragot:${i}`);if(this._entries.set(i,{value:t,token:c}),n)if(typeof n.addCleanup=="function")n.addCleanup(()=>{this.unregister(i,c)});else throw new Error(`[RAGOTRegistry] owner for "${i}" must expose addCleanup()`);return this._resolveWaiters(i,t),t}unregister(e,t=null){let n=this._normalizeKey(e,"unregister"),r=this._entries.get(n);return!r||t&&r.token!==t?!1:this._entries.delete(n)}resolve(e){var n;let t=this._normalizeKey(e,"resolve");return(n=this._entries.get(t))==null?void 0:n.value}require(e){var r;let t=this._normalizeKey(e,"require"),n=(r=this._entries.get(t))==null?void 0:r.value;if(n===void 0)throw new Error(`[RAGOTRegistry] "${t}" is not provided`);return n}has(e){let t=this._normalizeKey(e,"has");return this._entries.has(t)}list(){return Array.from(this._entries.keys())}clear(){this._entries.clear(),this._rejectAllWaiters(new Error("[RAGOTRegistry] registry was cleared"))}waitFor(e,t={}){var a;let n=this._normalizeKey(e,"waitFor"),r=(a=this._entries.get(n))==null?void 0:a.value;if(r!==void 0)return Promise.resolve(r);let{timeoutMs:i=0}=t;return new Promise((l,c)=>{let f={resolve:l,reject:c,timerId:null};this._waiters.has(n)||this._waiters.set(n,new Set),this._waiters.get(n).add(f),i>0&&(f.timerId=setTimeout(()=>{this._removeWaiter(n,f),c(new Error(`[RAGOTRegistry] waitFor("${n}") timed out after ${i}ms`))},i))})}waitForCancellable(e,t={}){var u;let n=this._normalizeKey(e,"waitForCancellable"),r=(u=this._entries.get(n))==null?void 0:u.value;if(r!==void 0)return{promise:Promise.resolve(r),cancel:()=>{}};let{timeoutMs:i=0}=t,a=null,l=!1;return{promise:new Promise((h,d)=>{a={resolve:h,reject:d,timerId:null},this._waiters.has(n)||this._waiters.set(n,new Set),this._waiters.get(n).add(a),i>0&&(a.timerId=setTimeout(()=>{this._removeWaiter(n,a),d(new Error(`[RAGOTRegistry] waitForCancellable("${n}") timed out after ${i}ms`))},i))}),cancel:()=>{l||!a||(l=!0,a.timerId&&clearTimeout(a.timerId),this._removeWaiter(n,a),a.reject(new Error(`[RAGOTRegistry] waitForCancellable("${n}") was cancelled`)))}}}_resolveWaiters(e,t){let n=this._waiters.get(e);if(!(!n||n.size===0)){for(let r of n)r.timerId&&clearTimeout(r.timerId),r.resolve(t);this._waiters.delete(e)}}_removeWaiter(e,t){let n=this._waiters.get(e);n&&(n.delete(t),n.size===0&&this._waiters.delete(e))}_rejectAllWaiters(e){for(let[t,n]of this._waiters.entries()){for(let r of n)r.timerId&&clearTimeout(r.timerId),r.reject(e);this._waiters.delete(t)}}_normalizeKey(e,t){if(typeof e!="string"||e.trim()==="")throw new Error(`[RAGOTRegistry] ${t}() requires a non-empty string key`);return e.trim()}},G=new Me,_e=new Proxy({},{get(s,e){if(typeof e=="string")return G.resolve(e)},set(s,e,t){if(!Pe())throw new Error("[RAGOTRegistry] Direct mutation of ragotModules is disabled. Use ragotRegistry.provide().");return typeof e!="string"?!1:(G.provide(e,t,null,{replace:!0}),!0)},deleteProperty(s,e){if(!Pe())throw new Error("[RAGOTRegistry] Direct deletion from ragotModules is disabled. Use ragotRegistry.unregister().");return typeof e!="string"?!1:(G.unregister(e),!0)},has(s,e){return typeof e!="string"?!1:G.has(e)},ownKeys(){return G.list()},getOwnPropertyDescriptor(s,e){if(!(typeof e!="string"||!G.has(e)))return{enumerable:!0,configurable:!0,value:G.resolve(e)}}});if(typeof window!="undefined"){let s=window.ragotModules;if(window.ragotRegistry=G,Object.defineProperty(window,"ragotModules",{configurable:!0,enumerable:!0,get(){return _e},set(e){if(!Pe())throw new Error("[RAGOTRegistry] window.ragotModules is read-only. Use ragotRegistry.provide().");if(G.clear(),!(!e||typeof e!="object"))for(let[t,n]of Object.entries(e))G.provide(t,n,null,{replace:!0})}}),s&&typeof s=="object")for(let[e,t]of Object.entries(s))G.provide(e,t,null,{replace:!0})}function pe(s){return!s||typeof s!="object"?!1:Array.isArray(s)||s instanceof Map||s instanceof Set?!0:Object.getPrototypeOf(s)===Object.prototype}function et(s){return Array.isArray(s)?s.map(String).filter(Boolean):typeof s=="string"?s.split(".").map(e=>e.trim()).filter(Boolean):[]}function te(s,e){if(!Array.isArray(s)||s.some(r=>typeof r!="function"))throw new Error("[RAGOT] createSelector(inputSelectors, resultFunc): inputSelectors must be an array of functions");if(typeof e!="function")throw new Error("[RAGOT] createSelector(inputSelectors, resultFunc): resultFunc must be a function");let t=[],n=null;return r=>{let i=s.map(l=>l(r));return(i.some((l,c)=>!Object.is(l,t[c]))||t.length===0)&&(t=i,n=e(...i)),n}}function Re(s={},e={}){let t=e.name||"store",n=pe(s)?s:{},r=new Set,i=new WeakMap,a=Object.create(null),l=0,c=0,f=[],u=null,h=!1;function d(b=null){if(f.length===0)return;let y=f;f=[],h=!1,l+=1,u=y.length===1?{...y[0],version:l,store:t,timestamp:Date.now()}:{type:"batch",changes:y,version:l,store:t,timestamp:Date.now(),meta:b?{...b}:{source:"microtask"}};for(let k of r)try{if(!k.selector){k.listener(M,u,O);continue}let v=k.selector(M);if(k.equals(v,k.selected))continue;let g=k.selected;k.selected=v,k.listener(v,u,O,g)}catch(v){console.warn(`[RAGOT:StateStore:${t}] subscriber error:`,v)}}function p(b){f.push(b),!(c>0||h)&&(h=!0,typeof queueMicrotask=="function"?queueMicrotask(d):Promise.resolve().then(d))}function A(b={}){f.length!==0&&(h||d(b))}function R(b,y=[]){if(!pe(b))return b;let k=i.get(b);if(k)return k;let v=null;return b instanceof Map?(v=new Proxy(b,{get(g,o,S){if(o==="set")return(w,E)=>{let $=g.has(w),J=g.get(w);return g.set(w,E),p({type:$?"map:set":"map:add",path:y.concat(String(w)),value:E,prevValue:J,meta:{source:"proxy.map.set"}}),S};if(o==="delete")return w=>{if(!g.has(w))return!1;let E=g.get(w),$=g.delete(w);return p({type:"map:delete",path:y.concat(String(w)),prevValue:E,meta:{source:"proxy.map.delete"}}),$};if(o==="clear")return()=>{g.size!==0&&(g.clear(),p({type:"map:clear",path:[...y],meta:{source:"proxy.map.clear"}}))};let m=Reflect.get(g,o,g);return typeof m=="function"?m.bind(g):m}}),i.set(b,v),v):b instanceof Set?(v=new Proxy(b,{get(g,o,S){if(o==="add")return w=>{let E=g.has(w);return g.add(w),E||p({type:"set:add",path:y.concat(String(w)),value:w,meta:{source:"proxy.set.add"}}),S};if(o==="delete")return w=>{let E=g.has(w),$=g.delete(w);return E&&p({type:"set:delete",path:y.concat(String(w)),value:w,meta:{source:"proxy.set.delete"}}),$};if(o==="clear")return()=>{g.size!==0&&(g.clear(),p({type:"set:clear",path:[...y],meta:{source:"proxy.set.clear"}}))};let m=Reflect.get(g,o,g);return typeof m=="function"?m.bind(g):m}}),i.set(b,v),v):(v=new Proxy(b,{get(g,o,S){let m=Reflect.get(g,o,S);return pe(m)?R(m,y.concat(String(o))):m},set(g,o,S,m){let w=Reflect.get(g,o,m),E=Reflect.set(g,o,S,m);return Object.is(w,S)||p({type:"set",path:y.concat(String(o)),value:S,prevValue:w,meta:{source:"proxy.set"}}),E},deleteProperty(g,o){if(!Object.prototype.hasOwnProperty.call(g,o))return!0;let S=g[o],m=Reflect.deleteProperty(g,o);return m&&p({type:"delete",path:y.concat(String(o)),prevValue:S,meta:{source:"proxy.delete"}}),m}}),i.set(b,v),v)}let M=R(n,[]);function P(){return M}function D(b,y=void 0){let k=et(b);if(k.length===0)return M;let v=M;for(let g of k){if(v==null)return y;v=v[g]}return v===void 0?y:v}function j(b,y,k={}){let v=et(b);if(v.length===0)return y;let g=v[v.length-1],o=n;for(let m=0;m<v.length-1;m+=1){let w=v[m],E=o[w];if(E instanceof Map||E instanceof Set)return console.warn(`[RAGOT:StateStore:${t}] store.set() path "${v.join(".")}" passes through a Map or Set at key "${w}". Use map.set() / set.add() directly instead.`),y;pe(E)||(o[w]={}),o=o[w]}let S=o[g];return Object.is(S,y)||(o[g]=y,p({type:"set:path",path:v,value:y,prevValue:S,meta:{source:k.source||"store.set",...k}})),y}function W(b,y={}){let k=typeof b=="function"?b(M,O):b;if(!k||typeof k!="object")return M;c+=1;try{for(let[v,g]of Object.entries(k))j([v],g,{source:y.source||"store.patch",...y})}finally{c-=1,c===0&&A({source:y.source||"store.patch",...y})}return M}function B(b,y={}){if(typeof b!="function")return M;c+=1;try{b(M,O)}finally{c-=1,c===0&&A({source:y.source||"store.batch",...y})}return M}function N(b,y,k,v={}){let g=D(b);return Object.is(g,y)?(j(b,k,{source:v.source||"store.compareAndSet",...v}),!0):!1}function X(b,y={}){if(typeof b!="function")return()=>{};let k=typeof y.selector=="function"?y.selector:null,v=typeof y.equals=="function"?y.equals:Object.is,g={listener:b,selector:k,equals:v,selected:k?k(M):null};if(r.add(g),y.immediate)try{let o=k?g.selected:M;b(o,{type:"init",version:l,store:t,timestamp:Date.now()},O)}catch(o){console.warn(`[RAGOT:StateStore:${t}] immediate subscriber error:`,o)}return()=>{r.delete(g)}}function K(b){let y=typeof b=="function"?b(O):b;if(!y||typeof y!="object")throw new Error(`[RAGOT:StateStore:${t}] registerActions() expects an object or function returning an object`);for(let[k,v]of Object.entries(y)){if(typeof v!="function")throw new Error(`[RAGOT:StateStore:${t}] action "${k}" must be a function`);a[k]=(...g)=>v(O,...g)}return a}function Z(b,...y){let k=a[b];if(typeof k!="function")throw new Error(`[RAGOT:StateStore:${t}] action "${b}" is not registered`);return k(...y)}function re(){return Object.keys(a)}function U(b,y){return te(b,y)}let O={name:t,getState:P,get:D,set:j,setState:W,patch:W,batch:B,compareAndSet:N,subscribe:X,createSelector:U,registerActions:K,dispatch:Z,actions:a,listActions:re,getVersion:()=>l,getLastChange:()=>u};return O}var Te={};function q(s,e={},...t){let n=s.startsWith("svg:")||["svg","path","circle","rect","line","polygon","polyline","ellipse","g","defs","marker","mask","pattern","stop","linearGradient","radialGradient","text","tspan"].includes(s),r=s;s.startsWith("svg:")&&(r=s.split(":")[1]);let i=n?document.createElementNS("http://www.w3.org/2000/svg",r):document.createElement(r);if(e)for(let[c,f]of Object.entries(e))if(c==="className"||c==="class"){let u=Array.isArray(f)?f:typeof f=="string"?f.split(" "):[];i.classList.add(...u.map(h=>typeof h=="string"?h.trim():"").filter(Boolean))}else if(c==="style"&&typeof f=="object")Object.assign(i.style,f);else if(c==="dataset"&&typeof f=="object")for(let[u,h]of Object.entries(f))h!=null&&(i.dataset[u]=h);else if(c==="ref"&&typeof f=="function")f(i),i._ragotRefCallbacks||(i._ragotRefCallbacks=[]),i._ragotRefCallbacks.push(f);else if(c==="events"&&typeof f=="object")for(let[u,h]of Object.entries(f))typeof h=="function"&&(i.addEventListener(u,h),i._ragotHandlers||(i._ragotHandlers={}),i._ragotHandlers[u]=h);else if(c.startsWith("on")&&typeof f=="function"){let u=c.toLowerCase().substring(2);i._ragotHandlers||(i._ragotHandlers={}),i._ragotHandlers[u]!==f&&(i._ragotHandlers[u]&&i.removeEventListener(u,i._ragotHandlers[u]),i.addEventListener(u,f),i._ragotHandlers[u]=f)}else["value","checked","selected","disabled","loading","src","alt","type","id"].includes(c)&&!n?(i[c]=f,f!==!1&&f!==null&&f!==void 0&&i.setAttribute(c,f===!0?"":f)):f!=null&&f!==!1&&(f===!0?i.setAttribute(c,""):i.setAttribute(c,f));let a=[];e&&e.children&&a.push(e.children),a.push(...t);let l=document.createDocumentFragment();return a.flat(1/0).forEach(c=>{c==null||typeof c=="boolean"||(c instanceof Node?l.appendChild(c):l.appendChild(document.createTextNode(String(c))))}),e&&e.innerHTML!==void 0?i.innerHTML=e.innerHTML:e&&e.textContent!==void 0&&(i.textContent=e.textContent),l.childNodes.length>0&&i.appendChild(l),i}function Oe(s,e){return new Promise(t=>{requestAnimationFrame(()=>{let n=document.createDocumentFragment();(Array.isArray(e)?e:[e]).forEach(i=>{i instanceof Node&&n.appendChild(i)}),s&&s.appendChild(n),t()})})}function Ie(s,...e){if(!s)return s;let t=document.createDocumentFragment();return e.flat(1/0).forEach(n=>{n==null||n===!1||t.appendChild(n instanceof Node?n:document.createTextNode(String(n)))}),s.appendChild(t),s}function De(s,...e){if(!s)return s;let t=document.createDocumentFragment();return e.flat(1/0).forEach(n=>{n==null||n===!1||t.appendChild(n instanceof Node?n:document.createTextNode(String(n)))}),s.insertBefore(t,s.firstChild),s}function ze(s,e,t){return!s||!e||s.insertBefore(e,t),e}function $e(s){return s&&s.parentNode&&s.parentNode.removeChild(s),s}var nt=new Set(["ragot-lazy-loading","ragot-lazy-loaded","ragot-lazy-error"]);function rt(){try{if(typeof Te!="undefined"&&Te.env&&Te.env.PROD)return!1}catch(s){}try{let s=typeof globalThis!="undefined"?globalThis.process:void 0;if((s&&s.env?s.env.NODE_ENV:void 0)==="production")return!1}catch(s){}return!0}function Ee(s,e){if(!s.attributes||!e.attributes)return;let t=s.attributes,n=e.attributes,r=s.tagName==="IMG"&&(e.hasAttribute("data-src")||e.hasAttribute("data-srcset")||e.classList.contains("lazy-load")),i=r&&s.src&&s.src.length>5&&!s.src.startsWith("data:");for(let a=t.length-1;a>=0;a--){let l=t[a].name;if(!l.startsWith("on")&&!e.hasAttribute(l)){if(r&&i&&(l==="src"||l==="srcset"))continue;s.removeAttribute(l)}}for(let a=0;a<n.length;a++){let l=n[a].name,c=n[a].value;if(!l.startsWith("on")){if(r&&i&&(l==="src"||l==="srcset")){let f=s.getAttribute(l);if((!c||c===""||c.length<100&&c.startsWith("data:image"))&&f&&f.length>5)continue}if(l==="class"&&r&&i){let f=Array.from(s.classList).filter(u=>nt.has(u));if(f.length>0){let u=new Set([...c.split(" ").filter(Boolean),...f]);c=Array.from(u).join(" ")}}s.getAttribute(l)!==c&&s.setAttribute(l,c)}}}function Le(s,e){let t=s._ragotHandlers||{},n=e._ragotHandlers||{};for(let[r,i]of Object.entries(t))n[r]!==i&&(s.removeEventListener(r,i),n[r]&&s.addEventListener(r,n[r]));for(let[r,i]of Object.entries(n))t[r]||s.addEventListener(r,i);s._ragotHandlers={...n}}function V(s,e){var c;if(!s)return e;if(!e)return s;if(s.nodeType!==e.nodeType||s.tagName!==e.tagName)return s.replaceWith(e),e;if(s.nodeType===Node.ELEMENT_NODE&&s.hasAttribute("data-ragot-ignore")){if(Ee(s,e),Le(s,e),e._ragotRefCallbacks){s._ragotRefCallbacks=e._ragotRefCallbacks;for(let f of s._ragotRefCallbacks)f(s)}return s}if(s.nodeType===Node.TEXT_NODE)return s.nodeValue!==e.nodeValue&&(s.nodeValue=e.nodeValue),s;if(s.tagName==="VIDEO")return s;if(s.tagName==="IMG"){let f=e.getAttribute("src"),u=s.getAttribute("src"),h=e.getAttribute("data-src"),d=s.getAttribute("data-src");if(f===u&&h===d){if(Ee(s,e),Le(s,e),e._ragotRefCallbacks){s._ragotRefCallbacks=e._ragotRefCallbacks;for(let p of s._ragotRefCallbacks)p(s)}return s}}if(Ee(s,e),Le(s,e),e._ragotRefCallbacks){s._ragotRefCallbacks=e._ragotRefCallbacks;for(let f of s._ragotRefCallbacks)f(s)}["INPUT","TEXTAREA","SELECT","OPTION"].includes(s.tagName)&&(s.value!==e.value&&(s.value=e.value),s.checked!==e.checked&&(s.checked=e.checked),s.selected!==e.selected&&(s.selected=e.selected),s.disabled!==e.disabled&&(s.disabled=e.disabled));let t=Array.from(s.childNodes),n=Array.from(e.childNodes),r=s.scrollLeft||0,i=s.scrollTop||0,a=r>0||i>0,l=n.some(f=>f.nodeType===Node.ELEMENT_NODE&&f.dataset&&f.dataset.ragotKey!==void 0);if(l){let f=n.filter(d=>d.nodeType===Node.ELEMENT_NODE),u=f.filter(d=>d.dataset&&d.dataset.ragotKey!==void 0).length,h=f.length-u;if(u>0&&h>0){let d=`[RAGOT] morphDOM: mixed keyed and unkeyed element siblings detected in <${(c=s.tagName)==null?void 0:c.toLowerCase()}>.
7
+ Keyed: ${u}, Unkeyed: ${h}.
8
+ Either key all siblings (add data-ragot-key) or key none of them.`;if(rt())throw new Error(d);console.warn(d)}}if(l){let f=new Map;for(let u of t)u.nodeType===Node.ELEMENT_NODE&&u.dataset&&u.dataset.ragotKey!==void 0&&f.set(u.dataset.ragotKey,u);for(let u of n){if(u.nodeType!==Node.ELEMENT_NODE||!u.dataset||u.dataset.ragotKey===void 0){s.appendChild(u);continue}let h=u.dataset.ragotKey,d=f.get(h);d?(f.delete(h),V(d,u),s.appendChild(d)):s.appendChild(u)}for(let u of f.values())s.removeChild(u)}else{let f=Math.max(t.length,n.length);for(let u=0;u<f;u++)t[u]?n[u]?V(t[u],n[u]):s.removeChild(t[u]):s.appendChild(n[u])}return a&&(s.scrollLeft!==r&&(s.scrollLeft=r),s.scrollTop!==i&&(s.scrollTop=i)),s}function Ge(s){if(s)for(;s.firstChild;)s.removeChild(s.firstChild)}function le(s,e,t,n){let r=typeof s=="string"?oe(s):s;if(!r)return()=>{};let i=function(a){let l=a.target;for(;l&&l!==r;){if(l.matches(t))return n.call(l,a,l);l=l.parentNode}};return r.addEventListener(e,i),()=>r.removeEventListener(e,i)}function He(s,e){return!s||!e||Object.assign(s.style,e),s}function ce(s,e,{additive:t=!1}={}){if(!s||!e)return s;for(let[n,r]of Object.entries(e))if(n.startsWith("on")){let i=n.toLowerCase().substring(2),a=s._ragotHandlers?s._ragotHandlers[i]:null;if(typeof r=="function"&&a===r)continue;a&&!t&&(s.removeEventListener(i,a),delete s._ragotHandlers[i]),typeof r=="function"&&(s.addEventListener(i,r),s._ragotHandlers||(s._ragotHandlers={}),s._ragotHandlers[i]=r)}else r==null||r===!1?s.removeAttribute(n):r===!0?s.setAttribute(n,""):s.setAttribute(n,r);return s}function je(s,e="icon"){let t=document.createElement("span");return e&&(t.className=e),t.innerHTML=s,t}function Be(s){return s&&s.classList.remove("hidden"),s}function Fe(s){return s&&s.classList.add("hidden"),s}function We(s,e){return s&&(e!==void 0?s.classList.toggle("hidden",!e):s.classList.toggle("hidden")),s}function Ne(s,e="is-visible"){s&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.classList.add(e)})})}function Ve(s,e="is-visible",t=!1){return s?new Promise(n=>{let r=!1,i=()=>{r||(r=!0,l.disconnect(),t&&s.parentNode&&s.parentNode.removeChild(s),n())},a=s.parentNode,l=new MutationObserver(()=>{s.isConnected||i()});a&&l.observe(a,{childList:!0}),s.classList.remove(e),s.addEventListener("transitionend",i,{once:!0}),setTimeout(i,350)}):Promise.resolve()}var me=class{constructor(){this._listeners=[],this._timers=new Set,this._intervals=new Set,this._cleanups=[]}on(e,t,n,r){if(!e)return Je()&&console.warn(`[RAGOT] Skipped listener for "${t}": target is null or undefined.`),this;if(this._listeners.some(l=>l.target===e&&l.type===t&&l.handler===n))return this;let a=n;return r&&r.once&&(a=(...l)=>{this._listeners=this._listeners.filter(c=>!(c.target===e&&c.type===t&&c.handler===n)),n(...l)}),e.addEventListener(t,a,r),this._listeners.push({target:e,type:t,handler:n,_registeredHandler:a,options:r}),this}off(e,t,n){if(!e)return this;let r=this._listeners.find(i=>i.target===e&&i.type===t&&i.handler===n);try{r&&e.removeEventListener(t,r._registeredHandler,r.options)}catch(i){console.warn(`[RAGOT] Failed to remove listener for "${t}":`,i)}return this._listeners=this._listeners.filter(i=>!(i.target===e&&i.type===t&&i.handler===n)),this}listen(e,t){let n=ee.on(e,t);return this._listeners.push({_busUnsub:n}),this}emit(e,t){return ee.emit(e,t),this}timeout(e,t){let n=setTimeout(()=>{this._timers.delete(n),e()},t);return this._timers.add(n),n}interval(e,t){let n=setInterval(e,t);return this._intervals.add(n),n}clearTimeout(e){return clearTimeout(e),this._timers.delete(e),this}clearInterval(e){return clearInterval(e),this._intervals.delete(e),this}clearTimers(){for(let e of this._timers)clearTimeout(e);for(let e of this._intervals)clearInterval(e);return this._timers.clear(),this._intervals.clear(),this}addCleanup(e){if(typeof e!="function")return()=>!1;let t=!0,n=()=>{t&&(t=!1,e())};return this._cleanups.push(n),()=>{if(!t)return!1;t=!1;let r=this._cleanups.indexOf(n);return r===-1?!1:(this._cleanups.splice(r,1),!0)}}delegate(e,t,n,r){let i=le(e,t,n,r);return this._cleanups.push(i),this}adopt(e,t={}){if(!e)return this;let{startMethod:n="start",stopMethod:r="stop",startArgs:i=[]}=t;return r==="stop"&&typeof e.unmount=="function"&&typeof e.mount=="function"&&typeof e.stop!="function"&&console.warn(`[RAGOT] adopt() called on a Component-like object without { stopMethod: 'unmount' }.
9
+ Components use unmount(), not stop(). Use adoptComponent() or pass { startMethod: 'mount', stopMethod: 'unmount' }.`),typeof e[n]=="function"&&e[n](...i),this.addCleanup(()=>{typeof e[r]=="function"&&e[r]()}),this}createSelector(e,t){return te(e,t)}teardown(e=""){var t;for(let n of this._listeners)try{n._busUnsub?n._busUnsub():n.target&&n.target.removeEventListener(n.type,(t=n._registeredHandler)!=null?t:n.handler,n.options)}catch(r){console.warn(`[RAGOT${e}] Failed to cleanup listener for "${n.type}":`,r)}this._listeners=[];for(let n of this._timers)clearTimeout(n);for(let n of this._intervals)clearInterval(n);for(this._timers.clear(),this._intervals.clear();this._cleanups.length>0;){let n=this._cleanups.shift();try{typeof n=="function"&&n()}catch(r){console.warn(`[RAGOT${e}] Failed to run cleanup callback:`,r)}}}},ue=class{constructor(e={}){this.state=e,this._isMounted=!1,this._lc=new me,this._socketHandlers=[],this._subscribers=new Set,this._batchDepth=0,this._notifyQueued=!1}onStart(){}onStop(){}setState(e){this.state={...this.state,...e},this._scheduleNotify()}batchState(e){this._batchDepth++;try{e(this.state)}finally{this._batchDepth--,this._batchDepth===0&&this._notifyAll()}return this}_scheduleNotify(){this._batchDepth>0||this._notifyQueued||(this._notifyQueued=!0,typeof queueMicrotask=="function"?queueMicrotask(()=>this._notifyAll()):Promise.resolve().then(()=>this._notifyAll()))}_notifyAll(){this._notifyQueued=!1;let e=this.state;for(let t of this._subscribers)try{if(t.selector){let n=t.selector(e);if(Object.is(n,t._lastSelected))continue;t._lastSelected=n,t.fn(n,e,this)}else t.fn(e,this)}catch(n){console.warn("[RAGOT] Error in Module state subscriber:",n)}}subscribe(e,t={}){if(typeof e=="string")throw new TypeError(`[RAGOT] subscribe() received a string as its first argument.
10
+ To filter by field, use the selector option:
11
+ module.subscribe((value) => { ... }, { selector: (s) => s.${e} })`);if(typeof e!="function")return()=>{};let{selector:n=null,immediate:r=!1,owner:i=null}=t,a={fn:e,selector:n,_lastSelected:n?n(this.state):void 0};this._subscribers.add(a);let l=()=>this._subscribers.delete(a);if(i&&typeof i.addCleanup=="function"&&i.addCleanup(l),r)try{n?e(a._lastSelected,this.state,this):e(this.state,this)}catch(c){console.warn("[RAGOT] Error in Module subscriber (immediate):",c)}return l}watchState(e,t={}){if(typeof e!="function")throw new TypeError(`[RAGOT] watchState() requires a function as its first argument — received ${typeof e}.
12
+ To watch a specific field, use the selector option:
13
+ this.watchState((value) => { ... }, { selector: (s) => s.fieldName })`);let{immediate:n=!0}=t;return this.subscribe(e,{owner:this,immediate:n})}start(){return this._isMounted?this:(this._isMounted=!0,this.onStart(),this)}stop(){var e,t;if(!this._isMounted)return this;try{this.onStop()}catch(n){console.error("[RAGOT] Error in Module.onStop:",n)}this._lc.teardown(" Module");for(let n of this._socketHandlers)try{(t=(e=n.socket)==null?void 0:e.off)==null||t.call(e,n.event,n.handler)}catch(r){console.warn(`[RAGOT] Failed to cleanup socket listener for "${n.event}":`,r)}return this._socketHandlers=[],this._subscribers.clear(),this._notifyQueued=!1,this._batchDepth=0,this._isMounted=!1,this}on(e,t,n,r){return this._lc.on(e,t,n,r),this}off(e,t,n){return this._lc.off(e,t,n),this}listen(e,t){return this._lc.listen(e,t),this}emit(e,t){return this._lc.emit(e,t),this}timeout(e,t){return this._lc.timeout(e,t)}interval(e,t){return this._lc.interval(e,t)}clearTimeout(e){return this._lc.clearTimeout(e),this}clearInterval(e){return this._lc.clearInterval(e),this}clearTimers(){return this._lc.clearTimers(),this}addCleanup(e){return this._lc.addCleanup(e),this}delegate(e,t,n,r){return this._lc.delegate(e,t,n,r),this}adopt(e,t={}){return this._lc.adopt(e,t),this}createSelector(e,t){return this._lc.createSelector(e,t)}onSocket(e,t,n){return e?typeof e.on!="function"||typeof e.off!="function"?(console.warn(`[RAGOT] onSocket("${t}"): first argument does not look like a socket.io socket (missing .on/.off).
14
+ Did you accidentally pass an event name or a non-socket object?`),this):this._socketHandlers.some(i=>i.socket===e&&i.event===t&&i.handler===n)?this:(e.on(t,n),this._socketHandlers.push({socket:e,event:t,handler:n}),this):(console.warn(`[RAGOT] onSocket("${t}"): socket is null or undefined — handler not registered.`),this)}offSocket(e,t,n){return!e||typeof e.off!="function"?this:(e.off(t,n),this._socketHandlers=this._socketHandlers.filter(r=>!(r.socket===e&&r.event===t&&r.handler===n)),this)}adoptComponent(e,t={}){let{sync:n=null,startMethod:r="mount",stopMethod:i="unmount",startArgs:a=[]}=t;return this.adopt(e,{startMethod:r,stopMethod:i,startArgs:a}),typeof n=="function"&&this.watchState((l,c)=>n(e,l,c)),this}},Y=class{constructor(e={}){this.state=e,this.element=null,this._isMounted=!1,this._pendingState=null,this._renderQueued=!1,this._renderRafId=null,this._lc=new me,this.refs={}}onStart(){}onStop(){}render(){return document.createElement("div")}setState(e){this._pendingState={...this.state,...this._pendingState,...e},this._renderQueued||(this._renderQueued=!0,this._renderRafId=requestAnimationFrame(()=>this._performUpdate()))}setStateSync(e){if(this._renderRafId!==null&&(cancelAnimationFrame(this._renderRafId),this._renderRafId=null),this._renderQueued=!1,this._pendingState=null,this.state={...this.state,...e},this.element&&this._isMounted){let t=this.render();t instanceof Node&&(this.element=V(this.element,t))}}_performUpdate(){if(this._renderRafId=null,this._renderQueued=!1,this._pendingState&&(this.state={...this.state,...this._pendingState},this._pendingState=null,this.element&&this._isMounted)){let e=this.render();e instanceof Node&&(this.element=V(this.element,e))}}ref(e){return t=>{this.refs[e]=t,t&&t.setAttribute&&t.setAttribute("data-ragot-ref",e)}}mount(e){return this._isMounted||!e?this.element:(typeof document!="undefined"&&!document.contains(e)&&console.warn(`[RAGOT] Component.mount() called with a container that is not yet in the document.
15
+ onStart() runs after mount — any DOM measurements or observers will fail silently.
16
+ Ensure the container is attached before calling mount().`),this.element=this.render(),this.element&&(this.element.__ragotComponent=this,e.appendChild(this.element),this._isMounted=!0,this.onStart()),this.element)}mountBefore(e){return this._isMounted||!e?this.element:(this.element=this.render(),this.element&&e.parentNode&&(this.element.__ragotComponent=this,e.parentNode.insertBefore(this.element,e),this._isMounted=!0,this.onStart()),this.element)}unmount(){if(this._isMounted){try{this.onStop()}catch(e){console.error("[RAGOT] Error in onStop:",e)}this._renderRafId!==null&&(cancelAnimationFrame(this._renderRafId),this._renderRafId=null),this._renderQueued=!1,this._pendingState=null,this._lc.teardown(" Component"),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this._isMounted=!1,this.refs={},this.element=null}}on(e,t,n,r){return this._lc.on(e,t,n,r),this}off(e,t,n){return this._lc.off(e,t,n),this}listen(e,t){return this._lc.listen(e,t),this}emit(e,t){return this._lc.emit(e,t),this}timeout(e,t){return this._lc.timeout(e,t)}interval(e,t){return this._lc.interval(e,t)}clearTimeout(e){return this._lc.clearTimeout(e),this}clearInterval(e){return this._lc.clearInterval(e),this}clearTimers(){return this._lc.clearTimers(),this}addCleanup(e){return this._lc.addCleanup(e),this}delegate(e,t,n,r){return this._lc.delegate(e,t,n,r),this}adopt(e,t={}){return this._lc.adopt(e,t),this}createSelector(e,t){return this._lc.createSelector(e,t)}};var ne=new Map,st=50;function ge(s,e,t,n,r,i={}){if(!s)return;let{poolKey:a=null}=i,l=new Map;for(let h of Array.from(s.children)){let d=h.dataset._listKey;d!==void 0&&l.set(d,h)}let c=new Set,f=[];for(let h of e){let d=String(t(h));if(c.add(d),l.has(d)){let p=l.get(d);r&&r(p,h),f.push(p)}else{let p=null;if(a){let A=ne.get(a);if(A&&A.length>0)if(p=A.pop(),r)r(p,h);else{let R=n(h);p=V(p,R)||p}}p||(p=n(h)),p&&(p.dataset._listKey=d,a&&(p.dataset._poolKey=a),f.push(p))}}for(let[h,d]of l)if(!c.has(h)){let p=d.dataset._poolKey||a;if(p){ne.has(p)||ne.set(p,[]);let A=ne.get(p);A.length<st&&A.push(d)}d.remove()}let u=null;for(let h of f){let d=u?u.nextSibling:s.firstChild;for(;d&&d!==h&&d.dataset._listKey===void 0;)d=d.nextSibling;d!==h&&s.insertBefore(h,d||null),u=h}}function qe(s,e,t,n,r,i={}){if(!s)return;let{columns:a,columnWidth:l,gap:c,applyGridStyles:f=!0,...u}=i;f&&(s.style.display="grid",l?s.style.gridTemplateColumns=`repeat(auto-fill, minmax(${l}, 1fr))`:a&&(s.style.gridTemplateColumns=`repeat(${a}, 1fr)`),c!==void 0&&(s.style.gap=c)),ge(s,e,t,n,r,u)}function Ke(s){s?ne.delete(s):ne.clear()}function fe(s,e={}){let{sentinel:t,topSentinel:n,onLoadMore:r,onEvictChunk:i,onLoadDirection:a=null,seekToViewport:l=null,visibleChunks:c,totalItems:f,getChunkEl:u=null,chunkSize:h=30,maxChunks:d=5,rootMargin:p="1200px 0px",root:A=null,axis:R="auto"}=e;if(!t||!n)return console.warn("[RAGOT] createInfiniteScroll: sentinel and topSentinel are required."),Ue();if(typeof r!="function"||typeof i!="function")return console.warn("[RAGOT] createInfiniteScroll: onLoadMore and onEvictChunk must be functions."),Ue();if(typeof c!="function"||typeof f!="function")return console.warn("[RAGOT] createInfiniteScroll: visibleChunks and totalItems must be functions."),Ue();let M=!1,P=!1,D=!1,j=null,W=null,B=null,N=null,X=!1,K=!1;function Z(){return Math.ceil(f()/h)}function re(){if(!u)return;let _=c();if(_.size===0)return;let C=1/0,x=-1/0;for(let T of _)T<C&&(C=T),T>x&&(x=T);let L=u(C),z=u(x);if(L&&L.parentNode&&n.nextSibling!==L&&L.parentNode.insertBefore(n,L),z&&z.parentNode){let T=z.nextSibling;T!==t&&(T?z.parentNode.insertBefore(t,T):z.parentNode.appendChild(t))}}function U(_){let C=1/0;for(let x of _)x<C&&(C=x);return C===1/0?-1:C}function O(_){let C=-1/0;for(let x of _)x>C&&(C=x);return C===-1/0?-1:C}function b(_){return _==="forward"?"bottom":"top"}function y(_){return _==="forward"?"backward":"forward"}function k(_){return _==="forward"?M:P}function v(_,C){if(_==="forward"){M=C;return}P=C}function g(_,C,x,L){let z=Math.max(1,L.size),T=Math.max(1,x.end-C.start),F=Math.max(1,T/z);return Math.max(1,Math.min(d,Math.ceil(_/F)))}function o(){return A||window}function S(){if(R==="horizontal"||R==="vertical")return R;let _=o();if(!_||_===window)return"vertical";let C=Math.max(0,(_.scrollWidth||0)-(_.clientWidth||0)),x=Math.max(0,(_.scrollHeight||0)-(_.clientHeight||0));return C>x?"horizontal":"vertical"}function m(_,C){var L;if(!_)return null;if(_===window)return C==="horizontal"?{start:0,end:window.innerWidth||0}:{start:0,end:window.innerHeight||0};let x=(L=_.getBoundingClientRect)==null?void 0:L.call(_);return x?C==="horizontal"?!Number.isFinite(x.left)||!Number.isFinite(x.right)||x.right<=x.left?null:{start:x.left,end:x.right}:!Number.isFinite(x.top)||!Number.isFinite(x.bottom)||x.bottom<=x.top?null:{start:x.top,end:x.bottom}:null}function w(){D||B!==null||!u||(B=requestAnimationFrame(()=>{B=null,ve()}))}function E(_,C){return!_||typeof _.finally!="function"?null:(_.catch(x=>{console.warn(`[RAGOT] createInfiniteScroll: onLoadMore (${b(C)}) rejected:`,x)}),_)}function $(_,C,x,L){if(typeof a=="function")return a({direction:_,batchCount:L,firstTarget:C,step:x});let z=[],T=Math.max(1,L);for(let I=0;I<T;I++){let H=C+I*x;if(_==="forward"&&H>=Z()||_==="backward"&&H<0)break;z.push(r(H))}let F=z.map(I=>E(I,_)).filter(Boolean);return F.length===1?F[0]:F.length>1?Promise.allSettled(F):null}function J(){if(D||k("forward")||k("backward")||!u)return null;let _=c();if(_.size===0)return null;let C=U(_),x=O(_),L=u(C),z=u(x);if(!L||!z)return null;let T=S(),F=o(),I=m(F,T),H=m(L,T),ie=m(z,T);if(!I||!H||!ie)return null;if(ie.end<I.start){let xe=I.start-ie.end;return{direction:"forward",batchCount:g(xe,H,ie,_)}}if(H.start>I.end){let xe=H.start-I.end;return{direction:"backward",batchCount:g(xe,H,ie,_)}}return null}function ve(){let _=J();_&&de({..._,allowSeek:!0})}function Se(){return!(!(t!=null&&t.isConnected)||!(n!=null&&n.isConnected)||A&&!A.isConnected)}function Ce(){se.observe(t),se.observe(n)}function ke(){D||W!==null||(W=requestAnimationFrame(()=>{if(W=null,!D){if(Se()){Ce();return}ke()}}))}function tt(_){let C=c();for(;C.size>d;)i(_==="forward"?U(C):O(C))}function Ye(_,C){if(v(_,!1),tt(_),C){w();return}ve()}function de({direction:_,batchCount:C=1,allowSeek:x=!1}){if(D||k(_)||k(y(_)))return;let L=c(),z=_==="forward"?O(L):U(L),T=_==="forward"?1:-1,F=z+T;if(!(_==="forward"&&F>=Z())&&!(_==="backward"&&F<0)){if(_==="forward"&&L.size>=d&&X&&U(L)===0){K=!0;return}if(_==="forward"&&(K=!1),x&&typeof l=="function"&&l(_)){w();return}v(_,!0);try{let I=$(_,F,T,C),H=E(I,_)||I;H&&typeof H.finally=="function"?H.finally(()=>{Promise.resolve().then(()=>{D||Ye(_,!0)})}):requestAnimationFrame(()=>{Ye(_,!1)})}catch(I){v(_,!1),console.warn(`[RAGOT] createInfiniteScroll: onLoadMore (${b(_)}) threw synchronously:`,I)}}}let se=new IntersectionObserver(_=>{for(let C of _){if(C.target===n){let x=X;if(X=C.isIntersecting,!C.isIntersecting){x&&K&&(K=!1,de({direction:"forward"}));continue}de({direction:"backward"});continue}if(C.target===t){if(!C.isIntersecting)continue;de({direction:"forward"})}}},{root:A,rootMargin:p,threshold:0});Se()?Ce():ke();function Ze(){w()}let Q=o();Q!=null&&Q.addEventListener&&Q.addEventListener("scroll",Ze,{passive:!0});let we={reset(){D||j===null&&(j=requestAnimationFrame(()=>{j=null,!D&&(re(),se.unobserve(t),se.unobserve(n),Se()?Ce():ke(),ve())}))},destroy(){D||(D=!0,typeof N=="function"&&(N(),N=null),j!==null&&(cancelAnimationFrame(j),j=null),W!==null&&(cancelAnimationFrame(W),W=null),B!==null&&(cancelAnimationFrame(B),B=null),Q!=null&&Q.removeEventListener&&Q.removeEventListener("scroll",Ze),se.disconnect())}};return s!=null&&s._lc&&typeof s._lc.addCleanup=="function"?N=s._lc.addCleanup(()=>we.destroy()):s&&typeof s.addCleanup=="function"&&s.addCleanup(()=>we.destroy()),we}function Ue(){return{reset(){},destroy(){}}}var he=class s extends Y{constructor(e={}){super({}),this._options=e,this._visibleChunks=new Set,this._chunkSizes=new Map,this._scrollController=null,this._avgChunkSize=0,this._measuredCount=0,this._childScrollers=new Map,this._childPool=[],this._elementPool=[],this._renderEpoch=0,this._loadTokenSeq=0,this._chunkLoadTokens=new Map,this._activeChunks=new Map}_emitDebug(e,t={}){var r,i,a,l,c;let n=(i=(r=this._options)==null?void 0:r.debugHooks)==null?void 0:i.onEvent;if(typeof n=="function")try{let f=((l=(a=this._options)==null?void 0:a.debugHooks)==null?void 0:l.includeSnapshot)===!0;n({event:e,scroller:((c=this._options)==null?void 0:c.debugLabel)||"vs",visibleSize:this._visibleChunks.size,...f?this._buildDebugSnapshot():null,...t})}catch(f){}}render(){let{containerClass:e=""}=this._options,t=["vs-container",e].filter(Boolean).join(" ");return q("div",{className:t},q("div",{ref:this.ref("topSentinel"),className:"vs-sentinel vs-sentinel-top"}),q("div",{ref:this.ref("bottomSentinel"),className:"vs-sentinel vs-sentinel-bottom"}))}onStart(){this._initialize()}_initialize(e={},t=null){Object.assign(this._options,e),this._restoreSentinelsToContainer(),this.element&&t&&t.appendChild(this.element);let{totalItems:n,chunkSize:r,maxChunks:i=5,root:a=null,rootMargin:l="1200px 0px",initialChunks:c=1,axis:f="auto"}=this._options;this._scrollController=fe(this,{sentinel:this.refs.bottomSentinel,topSentinel:this.refs.topSentinel,root:a,axis:f,rootMargin:l,chunkSize:r,maxChunks:i,totalItems:n,visibleChunks:()=>this._visibleChunks,getChunkEl:h=>this._getChunkOrPlaceholder(h),onLoadDirection:({direction:h,batchCount:d,firstTarget:p,step:A})=>this._loadDirectionBatch(h,d,p,A),seekToViewport:h=>this.seekToViewport(h),onLoadMore:h=>this._loadChunk(h),onEvictChunk:h=>{this._evictChunk(h)}});let u=this._chunkParent();if(u)for(let h of this._visibleChunks){let d=this._activeChunks.get(h);d&&d.parentNode!==u&&u.appendChild(d)}for(let h=0;h<c;h++)this._loadChunk(h)}onStop(){for(let[,t]of this._childScrollers)for(let n of t)try{n.unmount()}catch(r){}this._childScrollers.clear();for(let t of this._childPool)try{t.unmount()}catch(n){}this._childPool.length=0,this._elementPool.length=0;let e=this._chunkParent();if(e){let t=[];for(let n of e.children){let r=this._chunkIndex(n);Number.isNaN(r)||t.push(n)}for(let n of t)n.parentNode.removeChild(n)}this._scrollController=null,this._renderEpoch++,this._visibleChunks.clear(),this._chunkSizes.clear(),this._chunkLoadTokens.clear()}reset(){this._scrollController&&this._scrollController.reset()}jumpToIndex(e){if(!Number.isInteger(e))return!1;let t=Array.from(this._visibleChunks).reduce((i,a)=>i+a,0)/(this._visibleChunks.size||1),n=e>=t?"forward":"backward",r=this._jumpWindowToIndex(e,n);return r&&this._scheduleReset(),r}getVisibleChunks(){return new Set(this._visibleChunks)}getChunkElement(e){return this._getChunkOrPlaceholder(e)}seekToViewport(e="forward"){var a;if(e!=="forward"&&e!=="backward")return!1;let t=this._chunkParent();if(!t||this._visibleChunks.size===0)return!1;let n=this._resolveViewportAxis(),r=this._getViewportBounds(((a=this._options)==null?void 0:a.root)||window,n);if(!r)return!1;let i=this._findSeekTargetIndex(t,e,r,n);return Number.isInteger(i)?this._jumpWindowToIndex(i,e):!1}refreshChunkMeasurement(e){var r;if(!this._visibleChunks.has(e))return 0;let t=this.getChunkElement(e);if(!t||((r=t.dataset)==null?void 0:r.vsPlaceholder)!==void 0)return 0;let n=this._measure(t,e);return n>0&&(this._chunkSizes.set(e,n),this._scheduleReset()),n}getDebugState(){var n,r,i,a,l,c,f;let e=((n=this._options)==null?void 0:n.root)||null,t=((r=this._options)==null?void 0:r.axis)||"auto";return{label:((i=this._options)==null?void 0:i.debugLabel)||"vs",axis:t,visibleChunks:Array.from(this._visibleChunks).sort((u,h)=>u-h),rootConnected:!!(e!=null&&e.isConnected),rootScrollTop:e?e.scrollTop||0:null,rootScrollLeft:e?e.scrollLeft||0:null,clientHeight:e?e.clientHeight||0:null,clientWidth:e?e.clientWidth||0:null,scrollHeight:e?e.scrollHeight||0:null,scrollWidth:e?e.scrollWidth||0:null,topSentinelConnected:!!((l=(a=this.refs)==null?void 0:a.topSentinel)!=null&&l.isConnected),bottomSentinelConnected:!!((f=(c=this.refs)==null?void 0:c.bottomSentinel)!=null&&f.isConnected),...this._buildDebugSnapshot()}}acquireChild(e,t,n){var l,c,f,u,h;let r,i=this._options.childPoolSize||0;if(this._childPool.length?(r=this._childPool.pop(),r.rebind(t,n),this._emitDebug("child_rebind",{chunkIndex:e,childLabel:((l=r==null?void 0:r._options)==null?void 0:l.debugLabel)||(t==null?void 0:t.debugLabel)||"child"})):(r=new s(t),r.mount(n),this._emitDebug("child_mount",{chunkIndex:e,childLabel:((c=r==null?void 0:r._options)==null?void 0:c.debugLabel)||(t==null?void 0:t.debugLabel)||"child"})),!this._visibleChunks.has(e)){if(i>0&&this._childPool.length<i){try{r.recycle()}catch(d){}this._childPool.push(r),this._emitDebug("child_repool",{chunkIndex:e,childLabel:((f=r==null?void 0:r._options)==null?void 0:f.debugLabel)||(t==null?void 0:t.debugLabel)||"child"})}else try{r.unmount()}catch(d){}return this._emitDebug("child_pruned",{chunkIndex:e,childLabel:((u=r==null?void 0:r._options)==null?void 0:u.debugLabel)||(t==null?void 0:t.debugLabel)||"child"}),r}let a=this._childScrollers.get(e);return a?a.push(r):this._childScrollers.set(e,[r]),this._emitDebug("child_register",{chunkIndex:e,childCount:(this._childScrollers.get(e)||[]).length,childLabel:((h=r==null?void 0:r._options)==null?void 0:h.debugLabel)||(t==null?void 0:t.debugLabel)||"child"}),r}recycle(){this._scrollController&&(this._scrollController.destroy(),this._scrollController=null);let e=this._options.childPoolSize||0;if(this._childScrollers.size>0){for(let[,n]of this._childScrollers)for(let r of n)if(e>0&&this._childPool.length<e){try{r.recycle()}catch(i){}this._childPool.push(r)}else try{r.unmount()}catch(i){}this._childScrollers.clear()}if(e<=0&&this._childPool.length>0){for(let n of this._childPool)try{n.unmount()}catch(r){}this._childPool.length=0}let t=this._chunkParent();if(t){let n=[];for(let r of t.children){let i=this._chunkIndex(r);!Number.isNaN(i)&&Number.isFinite(i)&&n.push(r)}for(let r of n)r.remove()}this._restoreSentinelsToContainer(),this._visibleChunks.clear(),this._activeChunks.clear(),this._chunkSizes.clear(),this._avgChunkSize=0,this._measuredCount=0,this._elementPool.length=0,this._renderEpoch++,this._chunkLoadTokens.clear(),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}rebind(e,t){this._initialize(e,t)}_chunkParent(){return this._options.chunkContainer||this.element}_restoreSentinelsToContainer(){var n,r;if(!this.element)return;let e=(n=this.refs)==null?void 0:n.topSentinel,t=(r=this.refs)==null?void 0:r.bottomSentinel;!e||!t||(e.parentNode!==this.element&&this.element.appendChild(e),t.parentNode!==this.element&&this.element.appendChild(t),e.nextSibling!==t&&this.element.insertBefore(e,t))}_loadChunk(e){if(this._visibleChunks.has(e))return;let t=this._chunkParent();if(!t)return;let{totalItems:n,chunkSize:r,renderChunk:i,onRecycle:a}=this._options;if(e*r>=n())return;let l=this._renderEpoch,c=++this._loadTokenSeq;this._chunkLoadTokens.set(e,c);let f={token:c,isCurrent:()=>this._isCurrentLoad(e,c,l)};if(this._visibleChunks.add(e),this._emitDebug("load_start",{chunkIndex:e,token:c}),this._elementPool.length>0){let h=this._elementPool.shift();typeof a=="function"&&a(h,e),h.dataset.vsChunk=String(e),this._activeChunks.set(e,h),this._insertChunkEl(h,e,t),this._scheduleReset(),this._emitDebug("load_pool_reuse",{chunkIndex:e,token:c});return}let u=i(e,f);if(u&&typeof u.then=="function"){let h=this._buildLoadingPlaceholder(e);return this._insertChunkEl(h,e,t),u.then(d=>{if(!d){this._isCurrentLoad(e,c,l)&&(this._visibleChunks.delete(e),this._chunkLoadTokens.delete(e),this._evictChildScrollers(e),this._removeChunkShell(e,t),this._scheduleReset(),this._emitDebug("load_null",{chunkIndex:e,token:c}));return}if(!this._isCurrentLoad(e,c,l)){this._evictChildScrollers(e),this._emitDebug("load_stale",{chunkIndex:e,token:c});return}d.dataset.vsChunk=String(e),this._activeChunks.set(e,d);let p=this._measure(d,e);p>0&&(this._chunkSizes.set(e,p),this._measuredCount++,this._avgChunkSize+=(p-this._avgChunkSize)/this._measuredCount),this._insertChunkEl(d,e,t),this._scheduleReset(),this._emitDebug("load_commit",{chunkIndex:e,token:c,async:!0})}).catch(d=>{console.error(`[VirtualScroller] renderChunk(${e}) failed:`,d),this._isCurrentLoad(e,c,l)&&(this._visibleChunks.delete(e),this._chunkLoadTokens.delete(e),this._evictChildScrollers(e),this._removeChunkShell(e,t),this._scheduleReset(),this._emitDebug("load_error",{chunkIndex:e,token:c,message:String((d==null?void 0:d.message)||d)}))})}else{let h=u;if(!h){this._visibleChunks.delete(e),this._chunkLoadTokens.delete(e),this._emitDebug("load_null",{chunkIndex:e,token:c});return}if(!this._isCurrentLoad(e,c,l)){this._evictChildScrollers(e),this._emitDebug("load_stale",{chunkIndex:e,token:c});return}h.dataset.vsChunk=String(e),this._activeChunks.set(e,h);let d=this._measure(h,e);d>0&&(this._chunkSizes.set(e,d),this._measuredCount++,this._avgChunkSize+=(d-this._avgChunkSize)/this._measuredCount),this._insertChunkEl(h,e,t),this._scheduleReset(),this._emitDebug("load_commit",{chunkIndex:e,token:c,async:!1})}}_insertChunkEl(e,t,n){let r=this._findManagedDirectChild(n,a=>{var l;return((l=a.dataset)==null?void 0:l.vsChunk)===String(t)});if(r&&r!==e){r.parentNode.replaceChild(e,r);return}let i=this._findManagedDirectChild(n,a=>{let l=this._getPlaceholderBounds(a);return(l==null?void 0:l.start)===t&&(l==null?void 0:l.end)===t});if(i){i.parentNode.insertBefore(e,i),i.parentNode.removeChild(i);return}else{let a=!1;for(let l of n.children){let c=this._chunkIndex(l);if(!Number.isNaN(c)&&c>t){n.insertBefore(e,l),a=!0;break}}a||n.appendChild(e)}}_evictChunk(e){if(!this._visibleChunks.has(e))return;let t=this._chunkParent();if(!t)return;this._chunkLoadTokens.delete(e);let n=this._findManagedDirectChild(t,c=>{var f;return((f=c.dataset)==null?void 0:f.vsChunk)===String(e)});if(!n){this._visibleChunks.delete(e),this._activeChunks.delete(e),this._emitDebug("evict_missing",{chunkIndex:e});return}let r=this._measure(n,e);r>0&&(this._chunkSizes.set(e,r),this._measuredCount++,this._avgChunkSize+=(r-this._avgChunkSize)/this._measuredCount),typeof this._options.onChunkEvicted=="function"&&this._options.onChunkEvicted(e),this._evictChildScrollers(e);let i=this._chunkSizes.get(e)||r||Math.round(this._avgChunkSize)||0,a=this._buildPlaceholder(e,i);n.parentNode.insertBefore(a,n),n.parentNode.removeChild(n);let l=this._options.poolSize||0;l>0&&this._elementPool.length<l&&this._elementPool.push(n),this._visibleChunks.delete(e),this._activeChunks.delete(e),this._scheduleReset(),this._emitDebug("evict",{chunkIndex:e,pooled:l>0&&this._elementPool.includes(n)})}_evictChildScrollers(e){var r,i;let t=this._childScrollers.get(e);if(!t)return;let n=this._options.childPoolSize||0;for(let a of t)if(n>0&&this._childPool.length<n){try{a.recycle()}catch(l){}this._childPool.push(a),this._emitDebug("child_recycle",{chunkIndex:e,childLabel:((r=a==null?void 0:a._options)==null?void 0:r.debugLabel)||"child"})}else{try{a.unmount()}catch(l){}this._emitDebug("child_unmount",{chunkIndex:e,childLabel:((i=a==null?void 0:a._options)==null?void 0:i.debugLabel)||"child"})}this._childScrollers.delete(e)}_measure(e,t){let{measureChunk:n}=this._options;return typeof n=="function"?n(e,t)||0:e.offsetHeight||this._chunkSizes.get(t)||0}_buildPlaceholder(e,t){let{buildPlaceholder:n}=this._options;if(typeof n=="function"){let r=n(e,t);return r.dataset.vsPlaceholder=String(e),r}return q("div",{className:"vs-placeholder",dataset:{vsPlaceholder:String(e)},style:`height:${t}px`})}_buildPlaceholderRange(e,t,n){let r=this._buildPlaceholder(e,n);return r.dataset.vsPlaceholder=String(e),r.dataset.vsPlaceholderStart=String(e),r.dataset.vsPlaceholderEnd=String(t),r.dataset.vsPlaceholderPx=String(n),r}_buildLoadingPlaceholder(e){var a;let n=this._chunkSizes.get(e)||Math.round(this._avgChunkSize)||0,r=((a=this._options)==null?void 0:a.axis)||"vertical",i={};return n>0?r==="horizontal"?i={flex:"0 0 auto",minWidth:`${n}px`,height:"1px"}:i={minHeight:`${n}px`}:r==="horizontal"&&(i={flex:"0 0 auto",minWidth:"24px",height:"1px"}),q("div",{className:"vs-chunk-loading",dataset:{vsChunk:String(e)},style:i})}_getChunkOrPlaceholder(e){let t=this._chunkParent();return t?this._findManagedDirectChild(t,n=>{var i;if(((i=n.dataset)==null?void 0:i.vsChunk)===String(e))return!0;let r=this._getPlaceholderBounds(n);return r?r.start<=e&&e<=r.end:!1}):null}_removeChunkShell(e,t){if(!t)return;let n=this._findManagedDirectChild(t,r=>{var i;return((i=r.dataset)==null?void 0:i.vsChunk)===String(e)});n!=null&&n.parentNode&&n.parentNode.removeChild(n)}_chunkIndex(e){let t=e.dataset.vsChunk;if(t!==void 0&&t!=="")return parseInt(t,10);let n=e.dataset.vsPlaceholderStart;if(n!==void 0&&n!=="")return parseInt(n,10);let r=e.dataset.vsPlaceholder;return r!==void 0&&r!==""?parseInt(r,10):e.classList.contains("vs-sentinel-bottom")?1/0:e.classList.contains("vs-sentinel-top")?-1/0:NaN}_scheduleReset(){this._scrollController&&this._scrollController.reset()}_loadDirectionBatch(e,t,n,r){let i=[],a=Math.max(1,t);for(let l=0;l<a;l++){let c=n+l*r;if(e==="forward"&&c<n||e==="backward"&&c>n)break;let f=this._loadChunk(c);f&&typeof f.finally=="function"&&i.push(f)}return i.length>0?Promise.allSettled(i):null}_resolveViewportAxis(){var n,r;let e=((n=this._options)==null?void 0:n.axis)||"auto";if(e==="horizontal"||e==="vertical")return e;let t=((r=this._options)==null?void 0:r.root)||null;if(t&&t!==window){let i=Math.max(0,(t.scrollWidth||0)-(t.clientWidth||0)),a=Math.max(0,(t.scrollHeight||0)-(t.clientHeight||0));return i>a?"horizontal":"vertical"}return"vertical"}_getViewportBounds(e,t){var r;if(!e)return null;if(e===window)return t==="horizontal"?{start:0,end:window.innerWidth||0}:{start:0,end:window.innerHeight||0};let n=(r=e.getBoundingClientRect)==null?void 0:r.call(e);return n?t==="horizontal"?!Number.isFinite(n.left)||!Number.isFinite(n.right)||n.right<=n.left?null:{start:n.left,end:n.right}:!Number.isFinite(n.top)||!Number.isFinite(n.bottom)||n.bottom<=n.top?null:{start:n.top,end:n.bottom}:null}_findSeekTargetIndex(e,t,n,r){var c,f;let i=Math.min(...this._visibleChunks),a=Math.max(...this._visibleChunks),l=Array.from(e.children);if(t==="forward"){for(let u of l){let h=this._chunkIndex(u);if(Number.isNaN(h)||!Number.isFinite(h)||h<=a)continue;let d=this._getViewportBounds(u,r);if(!d||d.end<n.start)continue;let p=this._getPlaceholderBounds(u);if(p)return p.start;if(((c=u.dataset)==null?void 0:c.vsChunk)!==void 0)return h}return null}for(let u=l.length-1;u>=0;u--){let h=l[u],d=this._chunkIndex(h);if(Number.isNaN(d)||!Number.isFinite(d)||d>=i)continue;let p=this._getViewportBounds(h,r);if(!p||p.start>n.end)continue;let A=this._getPlaceholderBounds(h);if(A)return A.end;if(((f=h.dataset)==null?void 0:f.vsChunk)!==void 0)return d}return null}_jumpWindowToIndex(e,t){let{totalItems:n,chunkSize:r,maxChunks:i=5}=this._options,a=Math.ceil(n()/r);if(!Number.isFinite(a)||a<=0)return!1;let l=Math.max(1,i),c=t==="forward"?e:e-l+1;c=Math.max(0,Math.min(c,Math.max(0,a-l)));let f=Math.min(a-1,c+l-1),u=new Set;for(let p=c;p<=f;p++)u.add(p);let h=!1;for(let p=c;p<=f;p++)this._visibleChunks.has(p)||(this._loadChunk(p),h=!0);let d=Array.from(this._visibleChunks).sort((p,A)=>p-A);for(let p of d)u.has(p)||(this._evictChunk(p),h=!0);return h}_buildDebugSnapshot(){var i,a,l,c,f,u,h,d;let e=this._chunkParent(),t=Array.from(this._visibleChunks).sort((p,A)=>p-A);if(!e)return{visibleWindow:t.join(","),placeholders:"",domWindow:"",topPrev:"",topNext:"",bottomPrev:"",bottomNext:""};let n=[],r=[];for(let p of e.children){let A=this._describeManagedNode(p);A&&(n.push(A),A.startsWith("P")&&r.push(A.slice(1)))}return{visibleWindow:t.join(","),placeholders:r.join("|"),domWindow:n.join(">"),topPrev:this._describeManagedNode((a=(i=this.refs)==null?void 0:i.topSentinel)==null?void 0:a.previousElementSibling),topNext:this._describeManagedNode((c=(l=this.refs)==null?void 0:l.topSentinel)==null?void 0:c.nextElementSibling),bottomPrev:this._describeManagedNode((u=(f=this.refs)==null?void 0:f.bottomSentinel)==null?void 0:u.previousElementSibling),bottomNext:this._describeManagedNode((d=(h=this.refs)==null?void 0:h.bottomSentinel)==null?void 0:d.nextElementSibling)}}_describeManagedNode(e){var r,i,a;if(!e)return"";if(e===((r=this.refs)==null?void 0:r.topSentinel))return"T";if(e===((i=this.refs)==null?void 0:i.bottomSentinel))return"B";let t=(a=e.dataset)==null?void 0:a.vsChunk;if(t!==void 0&&t!=="")return`C${t}`;let n=this._getPlaceholderBounds(e);return n?n.start===n.end?`P${n.start}`:`P${n.start}-${n.end}`:""}_getSentinelAnchor(e,t,n){return t||null}_isCurrentLoad(e,t,n){return this._renderEpoch===n&&this._chunkLoadTokens.get(e)===t&&this._visibleChunks.has(e)}_getPlaceholderElForIndex(e,t){for(let n of t.children){let r=this._getPlaceholderBounds(n);if(r&&r.start<=e&&e<=r.end)return n}return null}_findManagedDirectChild(e,t){if(!e)return null;for(let n of e.children)if(t(n))return n;return null}_getPlaceholderBounds(e){var r;if(!(e!=null&&e.dataset))return null;let t=e.dataset.vsPlaceholderStart;if(t!==void 0&&t!==""){let i=parseInt(t,10),a=(r=e.dataset.vsPlaceholderEnd)!=null?r:t,l=parseInt(a,10);return Number.isNaN(i)||Number.isNaN(l)?null:{start:i,end:l}}let n=e.dataset.vsPlaceholder;if(n!==void 0&&n!==""){let i=parseInt(n,10);return Number.isNaN(i)?null:{start:i,end:i}}return null}_getPlaceholderPx(e){var r,i;let t=parseFloat((i=(r=e==null?void 0:e.dataset)==null?void 0:r.vsPlaceholderPx)!=null?i:"");if(Number.isFinite(t))return t;let n=this._getPlaceholderBounds(e);return n?this._sumChunkSizes(n.start,n.end):0}_sumChunkSizes(e,t){let n=0;for(let r=e;r<=t;r++)n+=this._chunkSizes.get(r)||0;return n}_mergeAdjacentPlaceholders(e){let t=e,n=this._findAdjacentPlaceholder(t,"previousElementSibling");for(;n;)t=this._mergePlaceholderPair(n,t),n=this._findAdjacentPlaceholder(t,"previousElementSibling");let r=this._findAdjacentPlaceholder(t,"nextElementSibling");for(;r;)t=this._mergePlaceholderPair(t,r),r=this._findAdjacentPlaceholder(t,"nextElementSibling");return t}_findAdjacentPlaceholder(e,t){let n=(e==null?void 0:e[t])||null;for(;n;){if(this._getPlaceholderBounds(n))return n;let i=this._chunkIndex(n);if(!Number.isNaN(i))return null;n=n[t]||null}return null}_mergePlaceholderPair(e,t){let n=this._getPlaceholderBounds(e),r=this._getPlaceholderBounds(t);if(!n||!r)return t||e;if(n.end+1<r.start)return t;let i=this._buildPlaceholderRange(Math.min(n.start,r.start),Math.max(n.end,r.end),this._getPlaceholderPx(e)+this._getPlaceholderPx(t)),a=e.parentNode;return a.replaceChild(i,e),t.parentNode===a&&a.removeChild(t),i}};var be={pending:"ragot-lazy-loading",loaded:"ragot-lazy-loaded",error:"ragot-lazy-error"};function ye(s,e=null){if(!s||(s.classList.remove(be.pending,be.loaded,be.error),!e))return;let t=be[e];t&&s.classList.add(t)}function Qe(s,e={}){let{selector:t="[data-src]",root:n=null,rootMargin:r="1000px",concurrency:i=6,retry:a=null,onStateChange:l=null,onLoad:c=null,onError:f=null}=e,u=new Set,h=[],d=new WeakSet,p=new WeakMap,A=0,R=null,M=!1,P=a===!0?{}:a||null,D=Number.isFinite(P==null?void 0:P.maxAttempts)?P.maxAttempts:2,j=Number.isFinite(P==null?void 0:P.baseDelayMs)?P.baseDelayMs:1e3,W=Number.isFinite(P==null?void 0:P.backoffFactor)?P.backoffFactor:2;function B(o,S,m={}){if(typeof l=="function")try{l(o,S,m)}catch(w){}}function N(o){o&&(ye(o,"pending"),B(o,"pending"))}function X(o){o&&(ye(o,"loaded"),B(o,"loaded"))}function K(o){o&&(ye(o,"error"),B(o,"error"))}function Z(o){var m;return{attempt:(p.get(o)||0)+1,currentSrc:((m=o.dataset)==null?void 0:m.src)||o.src||""}}function re(o,S){let m=typeof(P==null?void 0:P.schedule)=="function"?P.schedule:(E,$)=>setTimeout(E,$),w=j*Math.pow(W,S.attempt-1);m(()=>{var $;if(M||!o||!o.isConnected)return;let E=(($=o.dataset)==null?void 0:$.src)||o.src||"";if(typeof(P==null?void 0:P.getNextSrc)=="function"){let J=P.getNextSrc(o,S.attempt,E,S);J&&(o.dataset.src=J)}N(o),h.push(o),b()},w)}function U(o,S){return!P||S.attempt>D?!1:typeof P.shouldRetry=="function"?P.shouldRetry(o,S)===!0:!0}function O(o,{front:S=!1}={}){var m;return M||!o||u.has(o)||!((m=o.dataset)!=null&&m.src)?!1:(u.add(o),S?h.unshift(o):h.push(o),b(),!0)}function b(){if(!M)for(;A<i&&h.length>0;){let o=h.shift();if(!o||!o.isConnected||!o.dataset.src)continue;A++;let S=!1,m=()=>{S||(S=!0,A=Math.max(0,A-1),b())};ce(o,{onLoad:()=>{p.delete(o),X(o),c&&c(o),m()},onError:()=>{ye(o,null);let w=Z(o);if(U(o,w)){p.set(o,w.attempt),typeof(P==null?void 0:P.onRetry)=="function"&&P.onRetry(o,w),re(o,w),m();return}p.delete(o),K(o),f&&f(o,w),m()}}),o.decoding="async",o.src=o.dataset.src,o.complete&&setTimeout(()=>{S||(o.naturalWidth>0||o.naturalHeight>0?o.dispatchEvent(new Event("load")):o.dispatchEvent(new Event("error")))},10),setTimeout(()=>{!M&&!S&&!o.isConnected&&m()},500)}}function y(){R&&R.disconnect(),R=new IntersectionObserver(o=>{o.forEach(S=>{if(S.isIntersecting){let m=S.target;R.unobserve(m),O(m)}})},{root:n,rootMargin:r,threshold:0})}function k(o,S=0){var m;if(M||!o||!((m=o.dataset)!=null&&m.src)){o&&d.delete(o);return}if(o.isConnected){d.delete(o),R?R.observe(o):O(o);return}if(S>=10){d.delete(o);return}requestAnimationFrame(()=>k(o,S+1))}function v(){if(M||document.visibilityState!=="visible")return;for(let m of u)m.isConnected||(u.delete(m),R.unobserve(m));ae(t,n||document).filter(m=>!u.has(m)).forEach(m=>{R.observe(m)})}y(),s&&typeof s.on=="function"&&(s.on(document,"visibilitychange",v),s.on(window,"focus",v),s.on(window,"pageshow",v));let g={observe(o){var S;if(!(M||!o||!((S=o.dataset)!=null&&S.src))){if(u.has(o)){let m=(o.src||"").split("?")[0],w=o.dataset.src.split("?")[0],E=!!(m&&w&&m!==w),$=!o.classList.contains("loaded")&&!(o.complete&&o.naturalWidth>0);if(E||$)u.delete(o);else return}if(N(o),!o.isConnected){if(d.has(o))return;d.add(o),k(o);return}R?R.observe(o):O(o)}},reset(o){M||!o||(u.delete(o),p.delete(o),R&&R.unobserve(o),N(o))},prime(o,S={}){var m;if(!(M||!o||u.has(o)||!((m=o.dataset)!=null&&m.src))){if(S.fetchPriority&&(o.fetchPriority=S.fetchPriority),N(o),!o.isConnected){if(d.has(o))return;d.add(o),k(o);return}R&&R.unobserve(o),O(o,{front:!0})}},refresh(){v()},destroy(){M||(M=!0,R&&R.disconnect(),h.length=0,u.clear())}};return s&&typeof s.addCleanup=="function"&&s.addCleanup(()=>g.destroy()),g}function Xe(s,e,t={},n){let r=typeof e=="string"?document.querySelector(e):e;if(!r)return console.error(`[RAGOT] createApp: container not found — "${e}"`),null;let i=new s(t);return i.mount(r),n&&(window[n]=i),i}var it={$:oe,$$:ae,bus:ee,ragotRegistry:G,ragotModules:_e,createStateStore:Re,createSelector:te,createElement:q,batchAppend:Oe,append:Ie,prepend:De,insertBefore:ze,remove:$e,morphDOM:V,Module:ue,Component:Y,clear:Ge,delegateEvent:le,css:He,attr:ce,createIcon:je,show:Be,hide:Fe,toggle:We,renderList:ge,renderGrid:qe,clearPool:Ke,createInfiniteScroll:fe,VirtualScroller:he,createLazyLoader:Qe,animateIn:Ne,animateOut:Ve,createApp:Xe},ot=it;export{oe as $,ae as $$,Y as Component,ue as Module,he as VirtualScroller,Ne as animateIn,Ve as animateOut,Ie as append,ce as attr,Oe as batchAppend,ee as bus,Ge as clear,Ke as clearPool,Xe as createApp,q as createElement,je as createIcon,fe as createInfiniteScroll,Qe as createLazyLoader,te as createSelector,Re as createStateStore,He as css,ot as default,le as delegateEvent,Fe as hide,ze as insertBefore,V as morphDOM,De as prepend,_e as ragotModules,G as ragotRegistry,$e as remove,qe as renderGrid,ge as renderList,Be as show,We as toggle};
sprag/dev/__init__.py ADDED
@@ -0,0 +1 @@
1
+ """Development-only SPRAG helpers."""
sprag/dev/__main__.py ADDED
@@ -0,0 +1,5 @@
1
+ from .cli import main
2
+
3
+
4
+ if __name__ == "__main__":
5
+ main()