mayu-live 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. checksums.yaml +7 -0
  2. data/COPYING +661 -0
  3. data/README.md +598 -0
  4. data/exe/mayu +33 -0
  5. data/lib/mayu/app_metrics.rb +93 -0
  6. data/lib/mayu/banner.rb +12 -0
  7. data/lib/mayu/client/README.md +17 -0
  8. data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js +1 -0
  9. data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.br +0 -0
  10. data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.map +1 -0
  11. data/lib/mayu/client/dist/DecompressionStreamPolyfill-3ceba43e.js.map.br +0 -0
  12. data/lib/mayu/client/dist/custom-elements/mayu-alert-cd7ad2a4.js +1 -0
  13. data/lib/mayu/client/dist/custom-elements/mayu-alert-cd7ad2a4.js.map +1 -0
  14. data/lib/mayu/client/dist/custom-elements/mayu-disconnected-9f349f46.js +1 -0
  15. data/lib/mayu/client/dist/custom-elements/mayu-disconnected-9f349f46.js.map +1 -0
  16. data/lib/mayu/client/dist/custom-elements/mayu-exception-63df4e8c.js +1 -0
  17. data/lib/mayu/client/dist/custom-elements/mayu-exception-63df4e8c.js.map +1 -0
  18. data/lib/mayu/client/dist/custom-elements/mayu-ping-c498c2a6.js +1 -0
  19. data/lib/mayu/client/dist/custom-elements/mayu-ping-c498c2a6.js.map +1 -0
  20. data/lib/mayu/client/dist/custom-elements/mayu-progress-bar-eb3e1ac8.js +1 -0
  21. data/lib/mayu/client/dist/custom-elements/mayu-progress-bar-eb3e1ac8.js.map +1 -0
  22. data/lib/mayu/client/dist/entries.json +3 -0
  23. data/lib/mayu/client/dist/main-4b49dbc4.js +1 -0
  24. data/lib/mayu/client/dist/main-4b49dbc4.js.br +0 -0
  25. data/lib/mayu/client/dist/main-4b49dbc4.js.map +1 -0
  26. data/lib/mayu/client/dist/main-4b49dbc4.js.map.br +0 -0
  27. data/lib/mayu/client/package.json +39 -0
  28. data/lib/mayu/client/rollup.config.js +81 -0
  29. data/lib/mayu/client/src/DecompressionStream.ts +15 -0
  30. data/lib/mayu/client/src/DecompressionStreamPolyfill.ts +43 -0
  31. data/lib/mayu/client/src/MimeTypes.ts +4 -0
  32. data/lib/mayu/client/src/NodeTree.ts +445 -0
  33. data/lib/mayu/client/src/custom-elements/mayu-alert.html +137 -0
  34. data/lib/mayu/client/src/custom-elements/mayu-alert.ts +62 -0
  35. data/lib/mayu/client/src/custom-elements/mayu-disconnected.html +134 -0
  36. data/lib/mayu/client/src/custom-elements/mayu-disconnected.ts +51 -0
  37. data/lib/mayu/client/src/custom-elements/mayu-exception.html +79 -0
  38. data/lib/mayu/client/src/custom-elements/mayu-exception.ts +28 -0
  39. data/lib/mayu/client/src/custom-elements/mayu-log.html +70 -0
  40. data/lib/mayu/client/src/custom-elements/mayu-log.ts +42 -0
  41. data/lib/mayu/client/src/custom-elements/mayu-ping.html +36 -0
  42. data/lib/mayu/client/src/custom-elements/mayu-ping.ts +53 -0
  43. data/lib/mayu/client/src/custom-elements/mayu-progress-bar.html +44 -0
  44. data/lib/mayu/client/src/custom-elements/mayu-progress-bar.ts +40 -0
  45. data/lib/mayu/client/src/custom-elements/types.d.ts +4 -0
  46. data/lib/mayu/client/src/global.d.ts +26 -0
  47. data/lib/mayu/client/src/h.ts +27 -0
  48. data/lib/mayu/client/src/logger.ts +56 -0
  49. data/lib/mayu/client/src/main.ts +271 -0
  50. data/lib/mayu/client/src/serializeEvent.ts +90 -0
  51. data/lib/mayu/client/src/stream.ts +175 -0
  52. data/lib/mayu/client/src/types.ts +1 -0
  53. data/lib/mayu/client/src/utils.ts +71 -0
  54. data/lib/mayu/client/tsconfig.json +18 -0
  55. data/lib/mayu/colors.rb +34 -0
  56. data/lib/mayu/commands/base.rb +22 -0
  57. data/lib/mayu/commands/build.rb +82 -0
  58. data/lib/mayu/commands.rb +53 -0
  59. data/lib/mayu/component/base.rb +177 -0
  60. data/lib/mayu/component/handler_ref.rb +99 -0
  61. data/lib/mayu/component/helpers.rb +93 -0
  62. data/lib/mayu/component/interface.rb +18 -0
  63. data/lib/mayu/component/wrapper.rb +165 -0
  64. data/lib/mayu/component.rb +54 -0
  65. data/lib/mayu/configuration.rb +195 -0
  66. data/lib/mayu/disable_sorbet.rb +23 -0
  67. data/lib/mayu/environment.rb +151 -0
  68. data/lib/mayu/event_stream.rb +158 -0
  69. data/lib/mayu/fetch.rb +88 -0
  70. data/lib/mayu/html.rb +53 -0
  71. data/lib/mayu/html.yaml +767 -0
  72. data/lib/mayu/message_cipher.rb +172 -0
  73. data/lib/mayu/message_cipher.test.rb +16 -0
  74. data/lib/mayu/metrics/collector.rb +161 -0
  75. data/lib/mayu/metrics/exporter.rb +47 -0
  76. data/lib/mayu/metrics/reporter.rb +187 -0
  77. data/lib/mayu/metrics.rb +82 -0
  78. data/lib/mayu/ref_counter.rb +57 -0
  79. data/lib/mayu/resources/README.md +14 -0
  80. data/lib/mayu/resources/asset.rb +71 -0
  81. data/lib/mayu/resources/assets.rb +76 -0
  82. data/lib/mayu/resources/dependency_graph.rb +306 -0
  83. data/lib/mayu/resources/dot_exporter.rb +167 -0
  84. data/lib/mayu/resources/generators/base.rb +18 -0
  85. data/lib/mayu/resources/generators/copy_file.rb +26 -0
  86. data/lib/mayu/resources/generators/image.rb +106 -0
  87. data/lib/mayu/resources/generators/write_file.rb +39 -0
  88. data/lib/mayu/resources/hot_swap/file_watcher.rb +69 -0
  89. data/lib/mayu/resources/hot_swap.rb +46 -0
  90. data/lib/mayu/resources/mermaid_exporter.rb +210 -0
  91. data/lib/mayu/resources/registry.rb +190 -0
  92. data/lib/mayu/resources/resolver/base.rb +32 -0
  93. data/lib/mayu/resources/resolver/filesystem.rb +94 -0
  94. data/lib/mayu/resources/resolver/static.rb +27 -0
  95. data/lib/mayu/resources/resolver.rb +13 -0
  96. data/lib/mayu/resources/resource.rb +150 -0
  97. data/lib/mayu/resources/transformers/__test__/css/adjacent_selectors.in.css +3 -0
  98. data/lib/mayu/resources/transformers/__test__/css/adjacent_selectors.out.css +6 -0
  99. data/lib/mayu/resources/transformers/__test__/css/attributes.in.css +3 -0
  100. data/lib/mayu/resources/transformers/__test__/css/attributes.out.css +6 -0
  101. data/lib/mayu/resources/transformers/__test__/css/composes.in.css +6 -0
  102. data/lib/mayu/resources/transformers/__test__/css/composes.out.css +10 -0
  103. data/lib/mayu/resources/transformers/__test__/css/element_selectors.in.css +3 -0
  104. data/lib/mayu/resources/transformers/__test__/css/element_selectors.out.css +6 -0
  105. data/lib/mayu/resources/transformers/__test__/css/has.in.css +7 -0
  106. data/lib/mayu/resources/transformers/__test__/css/has.out.css +10 -0
  107. data/lib/mayu/resources/transformers/__test__/css/media_queries.in.css +8 -0
  108. data/lib/mayu/resources/transformers/__test__/css/media_queries.out.css +12 -0
  109. data/lib/mayu/resources/transformers/__test__/css/pseudo_classes.in.css +5 -0
  110. data/lib/mayu/resources/transformers/__test__/css/pseudo_classes.out.css +6 -0
  111. data/lib/mayu/resources/transformers/__test__/haml/README.md +10 -0
  112. data/lib/mayu/resources/transformers/__test__/haml/case.haml +8 -0
  113. data/lib/mayu/resources/transformers/__test__/haml/case.rb +15 -0
  114. data/lib/mayu/resources/transformers/__test__/haml/class_names.haml +13 -0
  115. data/lib/mayu/resources/transformers/__test__/haml/class_names.rb +26 -0
  116. data/lib/mayu/resources/transformers/__test__/haml/comments.haml +5 -0
  117. data/lib/mayu/resources/transformers/__test__/haml/comments.rb +5 -0
  118. data/lib/mayu/resources/transformers/__test__/haml/css.haml +3 -0
  119. data/lib/mayu/resources/transformers/__test__/haml/css.rb +11 -0
  120. data/lib/mayu/resources/transformers/__test__/haml/dashes.haml +3 -0
  121. data/lib/mayu/resources/transformers/__test__/haml/dashes.rb +11 -0
  122. data/lib/mayu/resources/transformers/__test__/haml/early_return.haml +4 -0
  123. data/lib/mayu/resources/transformers/__test__/haml/early_return.rb +9 -0
  124. data/lib/mayu/resources/transformers/__test__/haml/early_return2.haml +3 -0
  125. data/lib/mayu/resources/transformers/__test__/haml/early_return2.rb +6 -0
  126. data/lib/mayu/resources/transformers/__test__/haml/handlers.haml +6 -0
  127. data/lib/mayu/resources/transformers/__test__/haml/handlers.rb +12 -0
  128. data/lib/mayu/resources/transformers/__test__/haml/if_else.haml +6 -0
  129. data/lib/mayu/resources/transformers/__test__/haml/if_else.rb +12 -0
  130. data/lib/mayu/resources/transformers/__test__/haml/interpolation.haml +8 -0
  131. data/lib/mayu/resources/transformers/__test__/haml/interpolation.rb +11 -0
  132. data/lib/mayu/resources/transformers/__test__/haml/object_ref_as_key.haml +1 -0
  133. data/lib/mayu/resources/transformers/__test__/haml/object_ref_as_key.rb +5 -0
  134. data/lib/mayu/resources/transformers/__test__/haml/props.haml +4 -0
  135. data/lib/mayu/resources/transformers/__test__/haml/props.rb +11 -0
  136. data/lib/mayu/resources/transformers/__test__/haml/slots.haml +5 -0
  137. data/lib/mayu/resources/transformers/__test__/haml/slots.rb +9 -0
  138. data/lib/mayu/resources/transformers/__test__/haml/slots_dynamic.haml +3 -0
  139. data/lib/mayu/resources/transformers/__test__/haml/slots_dynamic.rb +9 -0
  140. data/lib/mayu/resources/transformers/__test__/haml/slots_fallback.haml +3 -0
  141. data/lib/mayu/resources/transformers/__test__/haml/slots_fallback.rb +5 -0
  142. data/lib/mayu/resources/transformers/__test__/haml/spacing.haml +5 -0
  143. data/lib/mayu/resources/transformers/__test__/haml/spacing.rb +14 -0
  144. data/lib/mayu/resources/transformers/__test__/haml/spacing2.haml +10 -0
  145. data/lib/mayu/resources/transformers/__test__/haml/spacing2.rb +11 -0
  146. data/lib/mayu/resources/transformers/__test__/haml/spacing3.haml +3 -0
  147. data/lib/mayu/resources/transformers/__test__/haml/spacing3.rb +10 -0
  148. data/lib/mayu/resources/transformers/css/rouge_lexer.rb +841 -0
  149. data/lib/mayu/resources/transformers/css.rb +100 -0
  150. data/lib/mayu/resources/transformers/css.test.rb +87 -0
  151. data/lib/mayu/resources/transformers/haml.rb +984 -0
  152. data/lib/mayu/resources/transformers/haml.test.rb +114 -0
  153. data/lib/mayu/resources/types/README.md +36 -0
  154. data/lib/mayu/resources/types/base.rb +35 -0
  155. data/lib/mayu/resources/types/component.rb +198 -0
  156. data/lib/mayu/resources/types/image.rb +169 -0
  157. data/lib/mayu/resources/types/javascript.rb +50 -0
  158. data/lib/mayu/resources/types/nil.rb +23 -0
  159. data/lib/mayu/resources/types/stylesheet.rb +119 -0
  160. data/lib/mayu/resources/types/svg.rb +69 -0
  161. data/lib/mayu/resources/types.rb +37 -0
  162. data/lib/mayu/routes.rb +170 -0
  163. data/lib/mayu/routing/builder.rb +108 -0
  164. data/lib/mayu/routing/matcher.rb +58 -0
  165. data/lib/mayu/routing/routes.rb +85 -0
  166. data/lib/mayu/routing.rb +17 -0
  167. data/lib/mayu/server/app.rb +494 -0
  168. data/lib/mayu/server/controller.rb +152 -0
  169. data/lib/mayu/server/errors.rb +110 -0
  170. data/lib/mayu/server/file_server.rb +140 -0
  171. data/lib/mayu/server.rb +63 -0
  172. data/lib/mayu/session.rb +358 -0
  173. data/lib/mayu/state/README.md +6 -0
  174. data/lib/mayu/state/action_creator.rb +191 -0
  175. data/lib/mayu/state/action_wrapper.rb +30 -0
  176. data/lib/mayu/state/loader.rb +220 -0
  177. data/lib/mayu/state/store.rb +82 -0
  178. data/lib/mayu/state.rb +8 -0
  179. data/lib/mayu/state.test.rb +97 -0
  180. data/lib/mayu/utils.rb +114 -0
  181. data/lib/mayu/vdom/children.rb +117 -0
  182. data/lib/mayu/vdom/component_marshaler.rb +53 -0
  183. data/lib/mayu/vdom/css_attributes.rb +131 -0
  184. data/lib/mayu/vdom/descriptor.rb +151 -0
  185. data/lib/mayu/vdom/descriptor.test.rb +26 -0
  186. data/lib/mayu/vdom/dom.rb +239 -0
  187. data/lib/mayu/vdom/h.rb +22 -0
  188. data/lib/mayu/vdom/id_generator.rb +55 -0
  189. data/lib/mayu/vdom/interfaces.rb +186 -0
  190. data/lib/mayu/vdom/marshalling.rb +78 -0
  191. data/lib/mayu/vdom/reconciliation.rb +205 -0
  192. data/lib/mayu/vdom/reconciliation.test.rb +56 -0
  193. data/lib/mayu/vdom/special_elements.rb +108 -0
  194. data/lib/mayu/vdom/update_context.rb +180 -0
  195. data/lib/mayu/vdom/vdom.perf.test.rb +146 -0
  196. data/lib/mayu/vdom/vnode.rb +266 -0
  197. data/lib/mayu/vdom/vtree.rb +672 -0
  198. data/lib/mayu/vdom/vtree.test.rb +68 -0
  199. data/lib/mayu/vdom.rb +8 -0
  200. data/lib/mayu/vdom.test.rb +73 -0
  201. data/lib/mayu/version.rb +6 -0
  202. data/lib/mayu.rb +8 -0
  203. data/mayu-live.gemspec +70 -0
  204. metadata +612 -0
@@ -0,0 +1,93 @@
1
+ # typed: strict
2
+
3
+ module Mayu
4
+ class AppMetrics < T::Struct
5
+ extend T::Sig
6
+
7
+ const :error_count, Prometheus::Client::Counter
8
+ const :session_init_count, Prometheus::Client::Counter
9
+ const :session_timeout_count, Prometheus::Client::Counter
10
+ const :session_ping_count, Prometheus::Client::Counter
11
+ const :session_callback_count, Prometheus::Client::Counter
12
+ const :session_navigate_count, Prometheus::Client::Counter
13
+ const :session_count, Prometheus::Client::Gauge
14
+ const :vnode_patch_times, Prometheus::Client::Summary
15
+
16
+ sig do
17
+ params(
18
+ registry: Prometheus::Client::Registry,
19
+ preset_labels: String
20
+ ).returns(T.attached_class)
21
+ end
22
+ def self.setup(registry, **preset_labels)
23
+ store_settings =
24
+ if Prometheus::Client.config.data_store.is_a?(
25
+ Prometheus::Client::DataStores::Synchronized
26
+ )
27
+ {}
28
+ else
29
+ { aggregation: :sum }
30
+ end
31
+
32
+ new(
33
+ session_init_count:
34
+ registry.counter(
35
+ :mayu_session_init_count,
36
+ docstring: "Total number of inits",
37
+ labels: [*preset_labels.keys],
38
+ preset_labels:
39
+ ),
40
+ session_ping_count:
41
+ registry.counter(
42
+ :mayu_session_ping_count,
43
+ docstring: "Total number of pings",
44
+ labels: [*preset_labels.keys],
45
+ preset_labels:
46
+ ),
47
+ session_callback_count:
48
+ registry.counter(
49
+ :mayu_session_callback_count,
50
+ docstring: "Total number of callbacks",
51
+ labels: [*preset_labels.keys],
52
+ preset_labels:
53
+ ),
54
+ session_navigate_count:
55
+ registry.counter(
56
+ :mayu_session_navigate_count,
57
+ docstring: "Total number of navigates",
58
+ labels: [*preset_labels.keys],
59
+ preset_labels:
60
+ ),
61
+ session_timeout_count:
62
+ registry.counter(
63
+ :mayu_session_timeout_count,
64
+ docstring: "Total number of timeouts",
65
+ labels: [*preset_labels.keys],
66
+ preset_labels:
67
+ ),
68
+ error_count:
69
+ registry.counter(
70
+ :mayu_error_count,
71
+ docstring: "Total number errors",
72
+ labels: [*preset_labels.keys],
73
+ preset_labels:
74
+ ),
75
+ session_count:
76
+ registry.gauge(
77
+ :mayu_session_count,
78
+ docstring: "Number of active sessions",
79
+ labels: [*preset_labels.keys],
80
+ preset_labels:,
81
+ store_settings:
82
+ ),
83
+ vnode_patch_times:
84
+ registry.summary(
85
+ :mayu_vnode_patch_times,
86
+ docstring: "VNode patch times",
87
+ labels: [:vnode_type, *preset_labels.keys],
88
+ preset_labels:
89
+ )
90
+ )
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,12 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ module Mayu
5
+ BANNER = T.let(<<~EOF.chomp.freeze, String)
6
+ • ▌ ▄ ·. ▄▄▄· ▄· ▄▌▄• ▄▌ ▄▄▌ ▪ ▌ ▐·▄▄▄ .
7
+ ·██ ▐███▪▐█ ▀█ ▐█▪██▌█▪██▌ ██• ██ ▪█·█▌▀▄.▀·
8
+ ▐█ ▌▐▌▐█·▄█▀▀█ ▐█▌▐█▪█▌▐█▌ ██▪ ▐█·▐█▐█•▐▀▀▪▄
9
+ ██ ██▌▐█▌▐█ ▪▐▌ ▐█▀·.▐█▄█▌ ▐█▌▐▌▐█▌ ███ ▐█▄▄▌
10
+ ▀▀ █▪▀▀▀ ▀ ▀ ▀ • ▀▀▀ .▀▀▀ ▀▀▀. ▀ ▀▀▀
11
+ EOF
12
+ end
@@ -0,0 +1,17 @@
1
+ # `client/`
2
+
3
+ ## Description
4
+
5
+ This entire thing is a mess.
6
+ Things have just been added without any sort of plan, and things
7
+ have changed without anything being renamed.
8
+
9
+ ## Building
10
+
11
+ Development:
12
+
13
+ npm run watch
14
+
15
+ Production:
16
+
17
+ npm run build:production
@@ -0,0 +1 @@
1
+ var r={},e=Uint8Array,n=Uint16Array,t=Uint32Array,a=new e([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new e([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),o=new e([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),f=function(r,e){for(var a=new n(31),i=0;i<31;++i)a[i]=e+=1<<r[i-1];var o=new t(a[30]);for(i=1;i<30;++i)for(var f=a[i];f<a[i+1];++f)o[f]=f-a[i]<<5|i;return[a,o]},s=f(a,2),u=s[0],c=s[1];u[28]=258,c[258]=28;for(var l=f(i,0)[0],v=new n(32768),h=0;h<32768;++h){var d=(43690&h)>>>1|(21845&h)<<1;d=(61680&(d=(52428&d)>>>2|(13107&d)<<2))>>>4|(3855&d)<<4,v[h]=((65280&d)>>>8|(255&d)<<8)>>>1}var p=function(r,e,t){for(var a=r.length,i=0,o=new n(e);i<a;++i)r[i]&&++o[r[i]-1];var f,s=new n(e);for(i=0;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;if(t){f=new n(1<<e);var u=15-e;for(i=0;i<a;++i)if(r[i])for(var c=i<<4|r[i],l=e-r[i],h=s[r[i]-1]++<<l,d=h|(1<<l)-1;h<=d;++h)f[v[h]>>>u]=c}else for(f=new n(a),i=0;i<a;++i)r[i]&&(f[i]=v[s[r[i]-1]++]>>>15-r[i]);return f},w=new e(288);for(h=0;h<144;++h)w[h]=8;for(h=144;h<256;++h)w[h]=9;for(h=256;h<280;++h)w[h]=7;for(h=280;h<288;++h)w[h]=8;var g=new e(32);for(h=0;h<32;++h)g[h]=5;var b=p(w,9,1),m=p(g,5,1),y=function(r){for(var e=r[0],n=1;n<r.length;++n)r[n]>e&&(e=r[n]);return e},E=function(r,e,n){var t=e/8|0;return(r[t]|r[t+1]<<8)>>(7&e)&n},k=function(r,e){var n=e/8|0;return(r[n]|r[n+1]<<8|r[n+2]<<16)>>(7&e)},x=function(r){return(r+7)/8|0},S=function(r,a,i){(null==a||a<0)&&(a=0),(null==i||i>r.length)&&(i=r.length);var o=new(2==r.BYTES_PER_ELEMENT?n:4==r.BYTES_PER_ELEMENT?t:e)(i-a);return o.set(r.subarray(a,i)),o},T=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],M=function(r,e,n){var t=new Error(e||T[r]);if(t.code=r,Error.captureStackTrace&&Error.captureStackTrace(t,M),!n)throw t;return t},O=function(r,n,t){var f=r.length;if(!f||t&&t.f&&!t.l)return n||new e(0);var s=!n||t,c=!t||t.i;t||(t={}),n||(n=new e(3*f));var v=function(r){var t=n.length;if(r>t){var a=new e(Math.max(2*t,r));a.set(n),n=a}},h=t.f||0,d=t.p||0,w=t.b||0,g=t.l,T=t.d,O=t.m,U=t.n,L=8*f;do{if(!g){h=E(r,d,1);var $=E(r,d+1,3);if(d+=3,!$){var A=r[(q=x(d)+4)-4]|r[q-3]<<8,R=q+A;if(R>f){c&&M(0);break}s&&v(w+A),n.set(r.subarray(q,R),w),t.b=w+=A,t.p=d=8*R,t.f=h;continue}if(1==$)g=b,T=m,O=9,U=5;else if(2==$){var _=E(r,d,31)+257,z=E(r,d+10,15)+4,B=_+E(r,d+5,31)+1;d+=14;for(var D=new e(B),P=new e(19),j=0;j<z;++j)P[o[j]]=E(r,d+3*j,7);d+=3*z;var F=y(P),N=(1<<F)-1,Y=p(P,F,1);for(j=0;j<B;){var q,I=Y[E(r,d,N)];if(d+=15&I,(q=I>>>4)<16)D[j++]=q;else{var W=0,C=0;for(16==q?(C=3+E(r,d,3),d+=2,W=D[j-1]):17==q?(C=3+E(r,d,7),d+=3):18==q&&(C=11+E(r,d,127),d+=7);C--;)D[j++]=W}}var G=D.subarray(0,_),H=D.subarray(_);O=y(G),U=y(H),g=p(G,O,1),T=p(H,U,1)}else M(1);if(d>L){c&&M(0);break}}s&&v(w+131072);for(var J=(1<<O)-1,K=(1<<U)-1,Q=d;;Q=d){var V=(W=g[k(r,d)&J])>>>4;if((d+=15&W)>L){c&&M(0);break}if(W||M(2),V<256)n[w++]=V;else{if(256==V){Q=d,g=null;break}var X=V-254;if(V>264){var Z=a[j=V-257];X=E(r,d,(1<<Z)-1)+u[j],d+=Z}var rr=T[k(r,d)&K],er=rr>>>4;rr||M(3),d+=15&rr;H=l[er];if(er>3){Z=i[er];H+=k(r,d)&(1<<Z)-1,d+=Z}if(d>L){c&&M(0);break}s&&v(w+131072);for(var nr=w+X;w<nr;w+=4)n[w]=n[w-H],n[w+1]=n[w+1-H],n[w+2]=n[w+2-H],n[w+3]=n[w+3-H];w=nr}}t.l=g,t.p=Q,t.b=w,t.f=h,g&&(h=1,t.m=O,t.d=T,t.n=U)}while(!h);return w==n.length?n:S(n,0,w)},U=new e(0),L=function(r,e,n){for(var t=r(),a=r.toString(),i=a.slice(a.indexOf("[")+1,a.lastIndexOf("]")).replace(/\s+/g,"").split(","),o=0;o<t.length;++o){var f=t[o],s=i[o];if("function"==typeof f){e+=";"+s+"=";var u=f.toString();if(f.prototype)if(-1!=u.indexOf("[native code]")){var c=u.indexOf(" ",8)+1;e+=u.slice(c,u.indexOf("(",c))}else for(var l in e+=u,f.prototype)e+=";"+s+".prototype."+l+"="+f.prototype[l].toString();else e+=u}else n[s]=f}return[e,n]},$=[],A=function(e,n,t,a){var i;if(!$[t]){for(var o="",f={},s=e.length-1,u=0;u<s;++u)o=(i=L(e[u],o,f))[0],f=i[1];$[t]=L(e[s],o,f)}var c=function(r,e){var n={};for(var t in r)n[t]=r[t];for(var t in e)n[t]=e[t];return n}({},$[t][1]);return function(e,n,t,a,i){var o=new Worker(r[n]||(r[n]=URL.createObjectURL(new Blob([e+';addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'],{type:"text/javascript"}))));return o.onmessage=function(r){var e=r.data,n=e.$e$;if(n){var t=new Error(n[0]);t.code=n[1],t.stack=n[2],i(t,null)}else i(null,e)},o.postMessage(t,a),o}($[t][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+n.toString()+"}",t,c,function(r){var e=[];for(var n in r)r[n].buffer&&e.push((r[n]=new r[n].constructor(r[n])).buffer);return e}(c),a)},R=function(){return[e,n,t,a,i,o,u,l,b,m,v,T,p,y,E,k,x,S,M,O,j,_,z]},_=function(r){return postMessage(r,[r.buffer])},z=function(r){return r&&r.size&&new e(r.size)},B=function(r){return r.ondata=function(r,e){return postMessage([r,e],[r.buffer])},function(e){return r.push(e.data[0],e.data[1])}},D=function(){function r(r){this.s={},this.p=new e(0),this.ondata=r}return r.prototype.e=function(r){this.ondata||M(5),this.d&&M(4);var n=this.p.length,t=new e(n+r.length);t.set(this.p),t.set(r,n),this.p=t},r.prototype.c=function(r){this.d=this.s.i=r||!1;var e=this.s.b,n=O(this.p,this.o,this.s);this.ondata(S(n,e,this.s.b),this.d),this.o=S(n,this.s.b-32768),this.s.b=this.o.length,this.p=S(this.p,this.s.p/8|0),this.s.p&=7},r.prototype.push=function(r,e){this.e(r),this.c(e)},r}(),P=function(){return function(r){var e,n,t,a;this.ondata=r,e=this,n=0,a=A([R,function(){return[B,D]}],(function(){var r=new D;onmessage=B(r)}),7,(function(r,n){r?(a.terminate(),e.ondata.call(e,r)):(n[1]&&a.terminate(),e.ondata.call(e,r,n[0],n[1]))})),a.postMessage(n),e.push=function(r,n){e.ondata||M(5),t&&e.ondata(M(4,0,1),null,!!n),a.postMessage([r,t=n],[r.buffer])},e.terminate=function(){a.terminate()}}}();function j(r,e){return O(r,e)}var F="undefined"!=typeof TextDecoder&&new TextDecoder;try{F.decode(U,{stream:!0}),1}catch(r){}class N extends TransformStream{constructor(r){let e;super({start(r){e=new P,e.ondata=(e,n,t)=>{e?r.error(e):t?r.terminate():r.enqueue(n)}},transform(r,n){try{e.push(r,!1)}catch(r){n.error(new Error(`DecompressionStreamPolyfill inflation failure: ${r}`))}},flush(){e.push(new Uint8Array,!0)}})}}export{N as default};//# sourceMappingURL=DecompressionStreamPolyfill-3ceba43e.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DecompressionStreamPolyfill-3ceba43e.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const t=document.createElement("template");t.innerHTML='<style>@keyframes show-dialog{0%{opacity:0;scale:0}90%{scale:1.1}100%{opacity:1;scale:1}}@keyframes hide-dialog{from{scale:1}to{scale:0}}@keyframes show-backdrop{0%{opacity:0}100%{opacity:1}}@keyframes hide-backdrop{0%{opacity:1}100%{opacity:0}}dialog{all:initial;display:flex;flex-direction:column;gap:1em;border:3px solid #ccc;border-bottom-left-radius:3px;border-bottom-right-radius:3px;border-top:0;position:fixed;top:0;left:50%;translate:-50% 0;margin:0;padding:1em;min-width:10em;background:#fff;font-size:1rem;box-shadow:#0000003f 0 54px 55px,#0000001e 0 -12px 30px,#0000001e 0 4px 6px,#0000002b 0 12px 13px,#00000016 0 -3px 5px}dialog[open]{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:show-dialog;animation-play-state:running;animation-timing-function:ease}dialog:not([open]){animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:hide-dialog;animation-play-state:running;animation-timing-function:ease}dialog::backdrop{backdrop-filter:brightness(50%) blur(5px)}dialog[open]::backdrop{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:show-backdrop;animation-play-state:running;animation-timing-function:ease}dialog:not([open])::backdrop{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:hide-backdrop;animation-play-state:running;animation-timing-function:ease}h1{all:initial;display:block;font-family:system-ui;font-size:1.2em;margin:0}p{all:initial;display:block;font-family:system-ui;font-size:1em;margin:0;white-space:pre-wrap;font-size:.9em;user-select:contain}button{user-select:none;flex:0;padding:.5em 1em}.button-wrap{display:flex;justify-content:flex-end}</style><dialog><h1>Alert</h1><p id="message"></p><div class="button-wrap"><button onclick="this.getRootNode().host.remove()" autofocus>Ok</button></div></dialog>';class a extends HTMLElement{#t;#a;#i;static observedAttributes=["message"];constructor(){super(),this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(t.content.cloneNode(!0)),this.#t=this.shadowRoot.querySelector("dialog"),this.#i=this.shadowRoot.querySelector("button"),this.#a=this.shadowRoot.getElementById("message"),this.#t.addEventListener("close",(()=>this.remove()))}connectedCallback(){this.#t.showModal(),this.#a.textContent=this.getAttribute("message"),this.#i.focus()}attributeChangedCallback(t,a,i){if("message"===t)this.#a.textContent=String(i)}disconnectedCallback(){this.#t.close()}}window.customElements.define("mayu-alert",a);export{a as default};//# sourceMappingURL=mayu-alert-cd7ad2a4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mayu-alert-cd7ad2a4.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const a=document.createElement("template");a.innerHTML='<style>@keyframes show-dialog{0%{opacity:0;scale:0}90%{scale:1.1}100%{opacity:1;scale:1}}@keyframes hide-dialog{from{scale:1}to{scale:0}}@keyframes show-backdrop{0%{opacity:0}100%{opacity:1}}@keyframes hide-backdrop{0%{opacity:1}100%{opacity:0}}dialog{all:initial;display:block;border:3px solid #c00;border-radius:3px;position:fixed;top:50%;left:50%;translate:-50% -50%;margin:0;background:#fff;font-size:1rem;box-shadow:#0000003f 0 54px 55px,#0000001e 0 -12px 30px,#0000001e 0 4px 6px,#0000002b 0 12px 13px,#00000016 0 -3px 5px;user-select:none}dialog[open]{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:show-dialog;animation-play-state:running;animation-timing-function:ease}dialog:not([open]){animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:hide-dialog;animation-play-state:running;animation-timing-function:ease}dialog::backdrop{backdrop-filter:brightness(50%) blur(5px)}dialog[open]::backdrop{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:show-backdrop;animation-play-state:running;animation-timing-function:ease}dialog:not([open])::backdrop{animation-delay:0s;animation-duration:.3s;animation-iteration-count:1;animation-name:hide-backdrop;animation-play-state:running;animation-timing-function:ease}h1{all:initial;display:block;font-family:system-ui;font-size:1.5em;margin:1rem}p{all:initial;display:block;font-family:system-ui;font-size:1em;margin:1rem}a{all:revert}#reason:empty{display:none}#reason::before{content:"Reason: ";font-weight:700}</style><dialog><h1>Connection lost</h1><p id="reason"></p><p>Please check your internet connection.</p><p><a href="javascript:document.location.reload()" autofocus>Reload the page</a></p></dialog>';class n extends HTMLElement{dialog;reason;static observedAttributes=["reason"];constructor(){super(),this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(a.content.cloneNode(!0)),this.dialog=this.shadowRoot.querySelector("dialog"),this.reason=this.shadowRoot.getElementById("reason")}connectedCallback(){this.dialog.showModal()}attributeChangedCallback(a,n,i){switch(a){case"reason":if(!this.reason)break;this.reason.textContent=String(i)}}disconnectedCallback(){this.dialog?.close()}}window.customElements.define("mayu-disconnected",n);export{n as default};//# sourceMappingURL=mayu-disconnected-9f349f46.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mayu-disconnected-9f349f46.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const e=document.createElement("template");e.innerHTML='<style>dialog{position:fixed;width:80vw;top:50%;left:50%;transform:translate(-50%,-50%);z-index:10001;background:#fff;border:5px solid #c00;border-radius:3px;font-family:monospace;overflow:hidden;font-size:.9rem;display:flex;flex-direction:column;margin:0;padding:0;box-shadow:#0000003f 0 54px 55px,#0000001e 0 -12px 30px,#0000001e 0 4px 6px,#0000002b 0 12px 13px,#00000016 0 -3px 5px}dialog::backdrop{backdrop-filter:brightness(30%) blur(5px)}header{display:flex;align-items:center;background:#c00;color:#fff;text-shadow:0 0 15px #fff,0 0 2px #000;padding-bottom:5px}header>button{flex:0;background:0 0;font-size:2em;font-weight:700;opacity:.5;border:0;cursor:pointer}header>button:hover{opacity:1}h1{font-size:1.2em;margin:0;padding:0;flex:1}main{overflow-y:scroll;flex:1}pre{white-space:pre-wrap;margin:1rem;flex:1;overflow:hidden}</style><dialog><header><h1><slot name="title"></slot></h1><button onclick="console.log(this.getRootNode().host.remove())">⨉</button></header><main><pre><slot name="backtrace"></slot></pre></main></dialog>';class o extends HTMLElement{dialog;connectedCallback(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(e.content.cloneNode(!0)),this.dialog=this.shadowRoot.querySelector("dialog"),this.dialog.showModal()}disconnectedCallback(){this.dialog?.close()}}window.customElements.define("mayu-exception",o);export{o as default};//# sourceMappingURL=mayu-exception-63df4e8c.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mayu-exception-63df4e8c.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const t=document.createElement("template");t.innerHTML='<style>.mayu-ping{position:fixed;bottom:0;left:0;z-index:10000;background:#0003;border:0 solid #0003;border-width:1px 1px 0 0;font-size:.9em;padding:.2em .5em;border-top-right-radius:3px;pointer-events:none;text-shadow:0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000,0 0 2px #000;color:#fff;font-weight:700;font-family:monospace;transition:background .5s 0s ease-in-out}.status-disconnected{background:#d0060699}.status-connected{background:#44f70899}.status-transferring{background:#0866f799}</style><div class="mayu-ping">Ping: <span class="ping">N/A</span> (<span class="region">N/A</span>)</div>';class e extends HTMLElement{div;ping;region;static observedAttributes=["ping","region","status"];connectedCallback(){this.shadowRoot||this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(t.content.cloneNode(!0)),this.div=this.shadowRoot.querySelector(".mayu-ping"),this.ping=this.shadowRoot.querySelector(".ping"),this.region=this.shadowRoot.querySelector(".region")}attributeChangedCallback(t,e,s){switch(t){case"ping":if(!this.ping)break;this.ping.textContent=s;break;case"region":if(!this.region)break;this.region.textContent=s;break;case"status":if(!this.div)break;e&&e!==s&&this.div.classList.remove(`status-${e}`),s&&this.div.classList.add(`status-${s}`)}}}window.customElements.define("mayu-ping",e);export{e as default};//# sourceMappingURL=mayu-ping-c498c2a6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mayu-ping-c498c2a6.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ const e=document.createElement("template");e.innerHTML='<style>@keyframes indeterminateAnimation{0%{transform:translateX(0) scaleX(0)}40%{transform:translateX(0) scaleX(.6)}100%{transform:translateX(100%) scaleX(.3)}}.progress{position:fixed;top:0;left:0;right:0;width:100%;height:5px;display:block;z-index:10000;background:0 0;border:0;pointer-events:none}.progress[hidden]{display:none}.value{height:100%;width:100%;background:#0866f7;box-shadow:0 0 3px #000;border-radius:2px;animation:indeterminateAnimation 1.5s infinite linear;transform-origin:0% 50%}</style><div class="progress" hidden><div class="value"></div></div>';class t extends HTMLElement{progress=null;static observedAttributes=["progress"];connectedCallback(){const t=this.attachShadow({mode:"open"});t.appendChild(e.content.cloneNode(!0)),this.progress=t.querySelector(".progress")}attributeChangedCallback(e,t,s){if("progress"===e)switch(Number(s)){case 0:default:this.progress.removeAttribute("hidden");break;case 100:this.progress.setAttribute("hidden","")}}}window.customElements.define("mayu-progress-bar",t);export{t as default};//# sourceMappingURL=mayu-progress-bar-eb3e1ac8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mayu-progress-bar-eb3e1ac8.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ {
2
+ "main": "main-4b49dbc4.js"
3
+ }
@@ -0,0 +1 @@
1
+ var e,t,n,r=4294967295;function o(e,t){return 4294967296*e.getInt32(t)+e.getUint32(t+4)}var i=("undefined"==typeof process||"never"!==(null===(e=null===process||void 0===process?void 0:process.env)||void 0===e?void 0:e.TEXT_ENCODING))&&"undefined"!=typeof TextEncoder&&"undefined"!=typeof TextDecoder,s=i?new TextEncoder:void 0;i&&"undefined"!=typeof process&&(null===(t=null===process||void 0===process?void 0:process.env)||void 0===t||t.TEXT_ENCODING),null==s||s.encodeInto;function a(e,t,n){for(var r=t,o=r+n,i=[],s="";r<o;){var a=e[r++];if(0==(128&a))i.push(a);else if(192==(224&a)){var c=63&e[r++];i.push((31&a)<<6|c)}else if(224==(240&a)){c=63&e[r++];var u=63&e[r++];i.push((31&a)<<12|c<<6|u)}else if(240==(248&a)){var h=(7&a)<<18|(c=63&e[r++])<<12|(u=63&e[r++])<<6|63&e[r++];h>65535&&(h-=65536,i.push(h>>>10&1023|55296),h=56320|1023&h),i.push(h)}else i.push(a);i.length>=4096&&(s+=String.fromCharCode.apply(String,i),i.length=0)}return i.length>0&&(s+=String.fromCharCode.apply(String,i)),s}var c=i?new TextDecoder:null,u=i?"undefined"!=typeof process&&"force"!==(null===(n=null===process||void 0===process?void 0:process.env)||void 0===n?void 0:n.TEXT_DECODER)?200:0:r;var h,d=function(e,t){this.type=e,this.data=t},l=(h=function(e,t){return h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},h(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}h(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),f=function(e){function t(n){var r=e.call(this,n)||this,o=Object.create(t.prototype);return Object.setPrototypeOf(r,o),Object.defineProperty(r,"name",{configurable:!0,enumerable:!1,value:t.name}),r}return l(t,e),t}(Error);function p(e){var t=e.sec,n=e.nsec;if(t>=0&&n>=0&&t<=17179869183){if(0===n&&t<=4294967295){var r=new Uint8Array(4);return(s=new DataView(r.buffer)).setUint32(0,t),r}var o=t/4294967296,i=4294967295&t;r=new Uint8Array(8);return(s=new DataView(r.buffer)).setUint32(0,n<<2|3&o),s.setUint32(4,i),r}var s;r=new Uint8Array(12);return(s=new DataView(r.buffer)).setUint32(0,n),function(e,t,n){var r=Math.floor(n/4294967296),o=n;e.setUint32(t,r),e.setUint32(t+4,o)}(s,4,t),r}var y={type:-1,encode:function(e){var t,n,r,o;return e instanceof Date?p((t=e.getTime(),n=Math.floor(t/1e3),r=1e6*(t-1e3*n),o=Math.floor(r/1e9),{sec:n+o,nsec:r-1e9*o})):null},decode:function(e){var t=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength);switch(e.byteLength){case 4:return{sec:t.getUint32(0),nsec:0};case 8:var n=t.getUint32(0);return{sec:4294967296*(3&n)+t.getUint32(4),nsec:n>>>2};case 12:return{sec:o(t,4),nsec:t.getUint32(0)};default:throw new f("Unrecognized data size for timestamp (expected 4, 8, or 12): ".concat(e.length))}}(e);return new Date(1e3*t.sec+t.nsec/1e6)}},m=function(){function e(){this.builtInEncoders=[],this.builtInDecoders=[],this.encoders=[],this.decoders=[],this.register(y)}return e.prototype.register=function(e){var t=e.type,n=e.encode,r=e.decode;if(t>=0)this.encoders[t]=n,this.decoders[t]=r;else{var o=1+t;this.builtInEncoders[o]=n,this.builtInDecoders[o]=r}},e.prototype.tryToEncode=function(e,t){for(var n=0;n<this.builtInEncoders.length;n++){if(null!=(r=this.builtInEncoders[n]))if(null!=(o=r(e,t)))return new d(-1-n,o)}for(n=0;n<this.encoders.length;n++){var r,o;if(null!=(r=this.encoders[n]))if(null!=(o=r(e,t)))return new d(n,o)}return e instanceof d?e:null},e.prototype.decode=function(e,t,n){var r=t<0?this.builtInDecoders[-1-t]:this.decoders[t];return r?r(e,t,n):new d(t,e)},e.defaultCodec=new e,e}();function g(e){return e instanceof Uint8Array?e:ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer?new Uint8Array(e):Uint8Array.from(e)}function v(e){return"".concat(e<0?"-":"","0x").concat(Math.abs(e).toString(16).padStart(2,"0"))}var b,w=function(){function e(e,t){void 0===e&&(e=16),void 0===t&&(t=16),this.maxKeyLength=e,this.maxLengthPerKey=t,this.hit=0,this.miss=0,this.caches=[];for(var n=0;n<this.maxKeyLength;n++)this.caches.push([])}return e.prototype.canBeCached=function(e){return e>0&&e<=this.maxKeyLength},e.prototype.find=function(e,t,n){e:for(var r=0,o=this.caches[n-1];r<o.length;r++){for(var i=o[r],s=i.bytes,a=0;a<n;a++)if(s[a]!==e[t+a])continue e;return i.str}return null},e.prototype.store=function(e,t){var n=this.caches[e.length-1],r={bytes:e,str:t};n.length>=this.maxLengthPerKey?n[Math.random()*n.length|0]=r:n.push(r)},e.prototype.decode=function(e,t,n){var r=this.find(e,t,n);if(null!=r)return this.hit++,r;this.miss++;var o=a(e,t,n),i=Uint8Array.prototype.slice.call(e,t,t+n);return this.store(i,o),o},e}(),x=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))},E=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},S=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},T=function(e){return this instanceof T?(this.v=e,this):new T(e)},U=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof T?Promise.resolve(n.value.v).then(c,u):h(i[0][2],n)}catch(e){h(i[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}},k=new DataView(new ArrayBuffer(0)),A=new Uint8Array(k.buffer),I=function(){try{k.getInt8(0)}catch(e){return e.constructor}throw new Error("never reached")}(),_=new I("Insufficient data"),L=new w,M=function(){function e(e,t,n,o,i,s,a,c){void 0===e&&(e=m.defaultCodec),void 0===t&&(t=void 0),void 0===n&&(n=r),void 0===o&&(o=r),void 0===i&&(i=r),void 0===s&&(s=r),void 0===a&&(a=r),void 0===c&&(c=L),this.extensionCodec=e,this.context=t,this.maxStrLength=n,this.maxBinLength=o,this.maxArrayLength=i,this.maxMapLength=s,this.maxExtLength=a,this.keyDecoder=c,this.totalPos=0,this.pos=0,this.view=k,this.bytes=A,this.headByte=-1,this.stack=[]}return e.prototype.reinitializeState=function(){this.totalPos=0,this.headByte=-1,this.stack.length=0},e.prototype.setBuffer=function(e){this.bytes=g(e),this.view=function(e){if(e instanceof ArrayBuffer)return new DataView(e);var t=g(e);return new DataView(t.buffer,t.byteOffset,t.byteLength)}(this.bytes),this.pos=0},e.prototype.appendBuffer=function(e){if(-1!==this.headByte||this.hasRemaining(1)){var t=this.bytes.subarray(this.pos),n=g(e),r=new Uint8Array(t.length+n.length);r.set(t),r.set(n,t.length),this.setBuffer(r)}else this.setBuffer(e)},e.prototype.hasRemaining=function(e){return this.view.byteLength-this.pos>=e},e.prototype.createExtraByteError=function(e){var t=this.view,n=this.pos;return new RangeError("Extra ".concat(t.byteLength-n," of ").concat(t.byteLength," byte(s) found at buffer[").concat(e,"]"))},e.prototype.decode=function(e){this.reinitializeState(),this.setBuffer(e);var t=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return t},e.prototype.decodeMulti=function(e){return E(this,(function(t){switch(t.label){case 0:this.reinitializeState(),this.setBuffer(e),t.label=1;case 1:return this.hasRemaining(1)?[4,this.doDecodeSync()]:[3,3];case 2:return t.sent(),[3,1];case 3:return[2]}}))},e.prototype.decodeAsync=function(e){var t,n,r,o;return x(this,void 0,void 0,(function(){var i,s,a,c,u,h,d,l;return E(this,(function(f){switch(f.label){case 0:i=!1,f.label=1;case 1:f.trys.push([1,6,7,12]),t=S(e),f.label=2;case 2:return[4,t.next()];case 3:if((n=f.sent()).done)return[3,5];if(a=n.value,i)throw this.createExtraByteError(this.totalPos);this.appendBuffer(a);try{s=this.doDecodeSync(),i=!0}catch(e){if(!(e instanceof I))throw e}this.totalPos+=this.pos,f.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return c=f.sent(),r={error:c},[3,12];case 7:return f.trys.push([7,,10,11]),n&&!n.done&&(o=t.return)?[4,o.call(t)]:[3,9];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(r)throw r.error;return[7];case 11:return[7];case 12:if(i){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return[2,s]}throw h=(u=this).headByte,d=u.pos,l=u.totalPos,new RangeError("Insufficient data in parsing ".concat(v(h)," at ").concat(l," (").concat(d," in the current buffer)"))}}))}))},e.prototype.decodeArrayStream=function(e){return this.decodeMultiAsync(e,!0)},e.prototype.decodeStream=function(e){return this.decodeMultiAsync(e,!1)},e.prototype.decodeMultiAsync=function(e,t){return U(this,arguments,(function(){var n,r,o,i,s,a,c,u,h;return E(this,(function(d){switch(d.label){case 0:n=t,r=-1,d.label=1;case 1:d.trys.push([1,13,14,19]),o=S(e),d.label=2;case 2:return[4,T(o.next())];case 3:if((i=d.sent()).done)return[3,12];if(s=i.value,t&&0===r)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),n&&(r=this.readArraySize(),n=!1,this.complete()),d.label=4;case 4:d.trys.push([4,9,,10]),d.label=5;case 5:return[4,T(this.doDecodeSync())];case 6:return[4,d.sent()];case 7:return d.sent(),0==--r?[3,8]:[3,5];case 8:return[3,10];case 9:if(!((a=d.sent())instanceof I))throw a;return[3,10];case 10:this.totalPos+=this.pos,d.label=11;case 11:return[3,2];case 12:return[3,19];case 13:return c=d.sent(),u={error:c},[3,19];case 14:return d.trys.push([14,,17,18]),i&&!i.done&&(h=o.return)?[4,T(h.call(o))]:[3,16];case 15:d.sent(),d.label=16;case 16:return[3,18];case 17:if(u)throw u.error;return[7];case 18:return[7];case 19:return[2]}}))}))},e.prototype.doDecodeSync=function(){e:for(;;){var e=this.readHeadByte(),t=void 0;if(e>=224)t=e-256;else if(e<192)if(e<128)t=e;else if(e<144){if(0!==(r=e-128)){this.pushMapState(r),this.complete();continue e}t={}}else if(e<160){if(0!==(r=e-144)){this.pushArrayState(r),this.complete();continue e}t=[]}else{var n=e-160;t=this.decodeUtf8String(n,0)}else if(192===e)t=null;else if(194===e)t=!1;else if(195===e)t=!0;else if(202===e)t=this.readF32();else if(203===e)t=this.readF64();else if(204===e)t=this.readU8();else if(205===e)t=this.readU16();else if(206===e)t=this.readU32();else if(207===e)t=this.readU64();else if(208===e)t=this.readI8();else if(209===e)t=this.readI16();else if(210===e)t=this.readI32();else if(211===e)t=this.readI64();else if(217===e){n=this.lookU8();t=this.decodeUtf8String(n,1)}else if(218===e){n=this.lookU16();t=this.decodeUtf8String(n,2)}else if(219===e){n=this.lookU32();t=this.decodeUtf8String(n,4)}else if(220===e){if(0!==(r=this.readU16())){this.pushArrayState(r),this.complete();continue e}t=[]}else if(221===e){if(0!==(r=this.readU32())){this.pushArrayState(r),this.complete();continue e}t=[]}else if(222===e){if(0!==(r=this.readU16())){this.pushMapState(r),this.complete();continue e}t={}}else if(223===e){if(0!==(r=this.readU32())){this.pushMapState(r),this.complete();continue e}t={}}else if(196===e){var r=this.lookU8();t=this.decodeBinary(r,1)}else if(197===e){r=this.lookU16();t=this.decodeBinary(r,2)}else if(198===e){r=this.lookU32();t=this.decodeBinary(r,4)}else if(212===e)t=this.decodeExtension(1,0);else if(213===e)t=this.decodeExtension(2,0);else if(214===e)t=this.decodeExtension(4,0);else if(215===e)t=this.decodeExtension(8,0);else if(216===e)t=this.decodeExtension(16,0);else if(199===e){r=this.lookU8();t=this.decodeExtension(r,1)}else if(200===e){r=this.lookU16();t=this.decodeExtension(r,2)}else{if(201!==e)throw new f("Unrecognized type byte: ".concat(v(e)));r=this.lookU32();t=this.decodeExtension(r,4)}this.complete();for(var o=this.stack;o.length>0;){var i=o[o.length-1];if(0===i.type){if(i.array[i.position]=t,i.position++,i.position!==i.size)continue e;o.pop(),t=i.array}else{if(1===i.type){if(s=void 0,"string"!==(s=typeof t)&&"number"!==s)throw new f("The type of key must be string or number but "+typeof t);if("__proto__"===t)throw new f("The key __proto__ is not allowed");i.key=t,i.type=2;continue e}if(i.map[i.key]=t,i.readCount++,i.readCount!==i.size){i.key=null,i.type=1;continue e}o.pop(),t=i.map}}return t}var s},e.prototype.readHeadByte=function(){return-1===this.headByte&&(this.headByte=this.readU8()),this.headByte},e.prototype.complete=function(){this.headByte=-1},e.prototype.readArraySize=function(){var e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:if(e<160)return e-144;throw new f("Unrecognized array type byte: ".concat(v(e)))}},e.prototype.pushMapState=function(e){if(e>this.maxMapLength)throw new f("Max length exceeded: map length (".concat(e,") > maxMapLengthLength (").concat(this.maxMapLength,")"));this.stack.push({type:1,size:e,key:null,readCount:0,map:{}})},e.prototype.pushArrayState=function(e){if(e>this.maxArrayLength)throw new f("Max length exceeded: array length (".concat(e,") > maxArrayLength (").concat(this.maxArrayLength,")"));this.stack.push({type:0,size:e,array:new Array(e),position:0})},e.prototype.decodeUtf8String=function(e,t){var n;if(e>this.maxStrLength)throw new f("Max length exceeded: UTF-8 byte length (".concat(e,") > maxStrLength (").concat(this.maxStrLength,")"));if(this.bytes.byteLength<this.pos+t+e)throw _;var r,o=this.pos+t;return r=this.stateIsMapKey()&&(null===(n=this.keyDecoder)||void 0===n?void 0:n.canBeCached(e))?this.keyDecoder.decode(this.bytes,o,e):e>u?function(e,t,n){var r=e.subarray(t,t+n);return c.decode(r)}(this.bytes,o,e):a(this.bytes,o,e),this.pos+=t+e,r},e.prototype.stateIsMapKey=function(){return this.stack.length>0&&1===this.stack[this.stack.length-1].type},e.prototype.decodeBinary=function(e,t){if(e>this.maxBinLength)throw new f("Max length exceeded: bin length (".concat(e,") > maxBinLength (").concat(this.maxBinLength,")"));if(!this.hasRemaining(e+t))throw _;var n=this.pos+t,r=this.bytes.subarray(n,n+e);return this.pos+=t+e,r},e.prototype.decodeExtension=function(e,t){if(e>this.maxExtLength)throw new f("Max length exceeded: ext length (".concat(e,") > maxExtLength (").concat(this.maxExtLength,")"));var n=this.view.getInt8(this.pos+t),r=this.decodeBinary(e,t+1);return this.extensionCodec.decode(r,n,this.context)},e.prototype.lookU8=function(){return this.view.getUint8(this.pos)},e.prototype.lookU16=function(){return this.view.getUint16(this.pos)},e.prototype.lookU32=function(){return this.view.getUint32(this.pos)},e.prototype.readU8=function(){var e=this.view.getUint8(this.pos);return this.pos++,e},e.prototype.readI8=function(){var e=this.view.getInt8(this.pos);return this.pos++,e},e.prototype.readU16=function(){var e=this.view.getUint16(this.pos);return this.pos+=2,e},e.prototype.readI16=function(){var e=this.view.getInt16(this.pos);return this.pos+=2,e},e.prototype.readU32=function(){var e=this.view.getUint32(this.pos);return this.pos+=4,e},e.prototype.readI32=function(){var e=this.view.getInt32(this.pos);return this.pos+=4,e},e.prototype.readU64=function(){var e,t,n=(e=this.view,t=this.pos,4294967296*e.getUint32(t)+e.getUint32(t+4));return this.pos+=8,n},e.prototype.readI64=function(){var e=o(this.view,this.pos);return this.pos+=8,e},e.prototype.readF32=function(){var e=this.view.getFloat32(this.pos);return this.pos+=4,e},e.prototype.readF64=function(){var e=this.view.getFloat64(this.pos);return this.pos+=8,e},e}(),C={},D=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},N=function(e){return this instanceof N?(this.v=e,this):new N(e)},B=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),i=[];return r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r;function s(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){i.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof N?Promise.resolve(n.value.v).then(c,u):h(i[0][2],n)}catch(e){h(i[0][3],e)}var n}function c(e){a("next",e)}function u(e){a("throw",e)}function h(e,t){e(t),i.shift(),i.length&&a(i[0][0],i[0][1])}};function O(e){if(null==e)throw new Error("Assertion Failure: value must not be null nor undefined")}function P(e){return null!=e[Symbol.asyncIterator]?e:function(e){return B(this,arguments,(function(){var t,n,r,o;return D(this,(function(i){switch(i.label){case 0:t=e.getReader(),i.label=1;case 1:i.trys.push([1,,9,10]),i.label=2;case 2:return[4,N(t.read())];case 3:return n=i.sent(),r=n.done,o=n.value,r?[4,N(void 0)]:[3,5];case 4:return[2,i.sent()];case 5:return O(o),[4,N(o)];case 6:return[4,i.sent()];case 7:return i.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}(e)}function $(e,t){void 0===t&&(t=C);var n=P(e);return new M(t.extensionCodec,t.context,t.maxStrLength,t.maxBinLength,t.maxArrayLength,t.maxMapLength,t.maxExtLength).decodeStream(n)}async function j(e=1e3){return new Promise((t=>{setTimeout(t,e)}))}class R extends Error{}async function F(e){let t=0;for(;;)try{return await e()}catch(e){if(e instanceof R)throw e;if(t>=10)throw console.error("Reached the maximum number of attempts!"),e;const n=t+Math.random();console.error(`Got error (attempts: ${t}, wait: ${n.toFixed(2)})`,e);const r=Math.ceil(n),o=n/r;for(let e=0;e<r;e++)console.warn(`Retrying in ${(n-e*o).toFixed(2)} seconds`),await j(1e3*o);t++}}function H(e){return[`background: ${e}`,"border: 1px solid rgba(0, 0, 0, 0.5)","border-radius: 2px","padding: 0 2px","color: #000","font-weight: bold"].join(";")}!function(e){e.MAYU_SESSION="application/vnd.mayu.session",e.MAYU_STREAM="application/vnd.mayu.eventstream"}(b||(b={}));var z=function(e="mayu/"){return{info:console.info.bind(console,`%c${e}info`,H("#35baf6")),log:console.info.bind(console,`%c${e}log`,H("#ccc")),error:console.error.bind(console,`%c${e}error`,H("#f6685e")),warn:console.warn.bind(console,`%c${e}warn`,H("#ffc107")),success:console.info.bind(console,`%c${e}success`,H("#a2cf6e")),group:console.group.bind(console),groupEnd:console.groupEnd.bind(console)}}();const V=new Promise((async e=>{if("undefined"!=typeof DecompressionStream)return z.success("Using standard DecompressionStream"),e(DecompressionStream);z.warn("Using DecompressionStream polyfill"),e((await import("./DecompressionStreamPolyfill-3ceba43e.js")).default)}));var K=await V;async function Y(e,t){const n=await function(e,t){if(!t)return F((()=>fetch(`/__mayu/session/${e}/init`,{method:"POST"})));return F((()=>fetch(`/__mayu/session/${e}/resume`,{method:"POST",headers:{"content-type":b.MAYU_SESSION},body:t})))}(e,t);if(!n.ok){const e=await n.text();if(503==n.status)throw new Error(`${n.status}: ${e}`);throw new R(`${n.status}: ${e}`)}if(!n.body)throw new R("body is null");const r=new K("deflate-raw");return n.body.pipeThrough(r)}function X(e){return e instanceof Error?e.message:"string"==typeof e?e:String(e)}async function*q(e){let t,n=!0,r=!1;const o=function(){const e=new m;return e.register({type:1,encode(){throw new Error("Not implemented")},decode:e=>new Blob([e],{type:"application/vnd.mayu.session"})}),e}();let i;for(;n;)try{const s=await F((()=>Y(e,t)));try{for await(const n of $(s,{extensionCodec:o})){const[o,s,a]=n;r||(r=!0,yield["system.connected",{}]),t&&(z.info("Clearing encryptedState"),t=void 0);try{switch(s){case"session.transfer":yield["session.transfer",{}],t=a,z.info("Setting encryptedState",a);break;case"pong":yield["ping",{values:{client:(new Date).getTime()-Number(a.pong),server:a.server},region:a.region,instance:a.instance}];break;case"ping":G(e,"ping",{pong:a,ping:(new Date).getTime()});break;default:yield[s,a]}}catch(e){i=X(e),z.error(e)}}}catch(e){i=X(e),z.error(e)}r=!1,n&&(i||="Stream ended unexpectedly"),yield["system.disconnected",{transferring:!!t,reason:i}]}catch(e){if(z.error(e),e instanceof R)return n=!1,r=!1,void(yield["system.disconnected",{reason:e.message}]);await j(1e3)}}async function G(e,t,n){return fetch(`/__mayu/session/${e}/${t}`,{method:"POST",headers:{"content-type":"application/json"},body:(r=n,JSON.stringify(r,((e,t)=>"bigint"==typeof t?Number(t):t instanceof Blob?`Blob{type: ${t.type}, size: ${t.size}}`:t),o))});var r,o}const J=function(){const e=(...e)=>{};return{info:e,log:e,warn:e,error:e,success:e,group:e,groupEnd:e}}();function Q(e,t){if("SCRIPT"!==t.tagName)for(const e of t.childNodes)Q(t,e);else e.replaceChild(function(e){const t=document.createElement("script");t.text=e.innerHTML;for(const n of e.attributes)t.setAttribute(n.name,n.value);return t}(t),t)}function W(e){if(e instanceof HTMLInputElement&&e.autofocus)e.focus();else for(const t of e.childNodes)W(t)}class Z{#e=new Map;constructor(e,t=document.documentElement){this.updateCache(t,e)}apply(e){for(const t of e)this.applyPatch(t)}applyPatch(e){switch(e.type){case"insert":return void this.insert(e);case"move":this.move(e);break;case"remove":this.remove(e.id);break;case"css":{const t=this.#t(e.id).node;e.value?t.style.setProperty(e.attr,e.value):t.style.removeProperty(e.attr)}case"text":"text"in e&&this.updateText(e.id,e.text),"append"in e&&this.appendText(e.id,e.append);break;case"attr":void 0!==e.value?this.setAttribute(e.id,e.name,e.value):this.removeAttribute(e.id,e.name);break;case"stylesheet":for(const t of e.paths){if(document.querySelector(`link[href="${t}"]`))continue;const e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("href",t),document.head.insertAdjacentElement("beforeend",e)}break;default:console.error("Unknown patch",e)}}updateText(e,t){const n=this.#t(e).node;if(n.nodeType!==n.TEXT_NODE)throw new Error("Trying to update text on a non text node");n.textContent=t}appendText(e,t){const n=this.#t(e).node;if(n.nodeType!==n.TEXT_NODE)throw new Error("Trying to update text on a non text node");n.textContent+=t}setAttribute(e,t,n){const r=this.#t(e).node;"open"===t&&r instanceof HTMLDialogElement?r.showModal():r instanceof HTMLInputElement&&("value"===t&&(r.value=n),"checked"===t&&(r.checked=!0),"indeterminate"===t)?r.indeterminate=!0:(t="initial_value"===t?"value":t.replaceAll(/_/g,""),r.setAttribute(t,n))}removeAttribute(e,t){const n=this.#t(e).node;"open"===t&&n instanceof HTMLDialogElement&&(n.open=!1,n.close()),n instanceof HTMLInputElement&&("value"===t&&(n.value=""),"checked"===t&&(n.checked=!1),"indeterminate"===t)?n.indeterminate=!1:n.removeAttribute(t)}insert({parent:e,before:t,after:n,ids:r,html:o}){J.group("Trying to insert html into",e);const i=this.#t(e),s=t||n,a=s&&this.#e.get(s),c=document.createRange().createContextualFragment(`<template>${o}</template>`).firstElementChild.content,u=Array.from(c.childNodes).reverse();[r].flat().forEach(((e,t)=>{i.childIds.add(e.id);const r=this.#e.get(e.id),o=r?.node||u[t],s=a?n?a.node.nextSibling:a.node:null,c=i.node.insertBefore(o,s);r&&(r.node.outerHTML=o.outerHTML),requestIdleCallback((()=>{W(c)})),requestIdleCallback((()=>{Q(i.node,c)})),this.updateCache(c,e)})),J.groupEnd()}#t(e){const t=this.#e.get(e);if(!t)throw J.error("Could not find",e,"in cache!"),J.error(Array.from(this.#e.keys())),new Error(`Could not find ${e} in cache!`);return t}remove(e){J.info("Trying to remove",e);try{const t=this.#t(e),n=t.node.parentNode;if(n){const r=n.__MAYU_ID,o=this.#e.get(r);J.log("Removing child",t.node.textContent),n.removeChild(t.node),o&&o.childIds.delete(e)}else J.warn("Node",t.node.__MAYU_ID,"has no parent??");this.#n(e,!1)}catch(e){J.warn(e)}}move({id:e,parent:t,before:n,after:r}){const o=this.#t(e),i=this.#t(t),s=n||r,a=s&&this.#e.get(s),c=a?a.node:null;J.log("Moving",o.node.textContent,n?"before":r?"after":"last",c?.textContent||i.node.__MAYU_ID),J.log({before:n,after:r}),J.log(c?.textContent),i.node.insertBefore(o.node,c)}#n(e,t=!1){const n=this.#e.get(e);if(n){if(J.group("Removing from cache",e),t){this.#e.get(n.node.parentNode.__MAYU_ID)?.childIds?.delete(e)}this.#e.delete(e),n.childIds.forEach((e=>{this.#n(e,!1)})),n.childIds.delete(e),J.groupEnd()}}isIgnoredNode(e){if(e.nodeType===e.TEXT_NODE)return!1;if(e.nodeType===e.COMMENT_NODE)return!1;if(e.nodeType===e.ELEMENT_NODE){if("string"==typeof e.dataset.mayuId)return!1}return!0}updateCache(e,t){if(!e)throw J.error(t),new Error("No node found for idTreeNode");const n=new Set((t.ch||[]).map((e=>e.id)));this.#n(t.id),this.#e.set(t.id,{node:e,childIds:n}),e.__MAYU_ID=t.id,J.group("Add to cache",t.id,"type",e.nodeName,t.type);let r=0;const o=t.ch||[];e.childNodes.forEach((e=>{if(this.isIgnoredNode(e))return void J.warn("Ignored:",e);const n=o[r++];n?this.updateCache(e,n):J.error("No childIdNode at index",r,"on node",null,"with parent id",t.id,"and child node",null)})),o.length,J.groupEnd()}}function ee(e,t=[],n={}){const r=document.createElement(e);for(const[e,t]of Object.entries(n))t&&(!0===t?r.setAttribute(e,e):r.setAttribute(e,t));return t.forEach((e=>{e instanceof Node?r.appendChild(e):e&&r.appendChild(document.createTextNode(String(e)))})),r}function te(e){if(e instanceof HTMLFormElement){const t=Object.fromEntries(new FormData(e).entries());return{tagName:e.tagName,id:e.id,method:e.method,target:e.target,name:e.name,formData:t}}return e instanceof HTMLSelectElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value}:e instanceof HTMLDetailsElement?{tagName:e.tagName,id:e.id,open:e.open}:e instanceof HTMLInputElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value,checked:e.checked}:e instanceof HTMLButtonElement?{tagName:e.tagName,id:e.id,type:e.type,name:e.name,value:e.value}:e instanceof HTMLElement?{tagName:e.tagName,id:e.id}:{}}const ne=new Promise((e=>{if("loading"!==document.readyState)return e();window.addEventListener("DOMContentLoaded",(()=>e()))}));async function re({type:e,message:t,backtrace:n}){await import("./custom-elements/mayu-exception-63df4e8c.js");const r=n.filter((e=>!/\/vendor\/bundle\//.test(e))).join("\n"),o=ee("mayu-exception",[ee("span",[`${e}: ${t}`],{slot:"title"}),ee("span",[r],{slot:"backtrace"})]);document.body.appendChild(o)}class oe{#r;constructor(e){this.#r=e,ne.then((()=>{window.addEventListener("popstate",(()=>ie(this.#r,location.pathname)))}))}async handle(e,t){(function(e){return!("undefined"!=typeof TouchEvent&&e instanceof TouchEvent)})(e)&&e.preventDefault();const n=function(e){const t={};return t.type=e.constructor.name,e.currentTarget&&(t.currentTarget=te(e.currentTarget)),e.target&&(t.target=te(e.target)),e instanceof MouseEvent&&(t.buttons=e.buttons),e instanceof SubmitEvent&&e.submitter instanceof HTMLElement&&(t.submitter=te(e.submitter)),t}(e);console.log(n),await function(e,t,n){return fetch(`/__mayu/session/${e}/callback/${t}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(n)})}(this.#r,t,n);const r=setTimeout((()=>{}),1);clearTimeout(r)}async navigate(e){if(e.metaKey||e.ctrlKey)return;e.preventDefault();const t=e.target.closest("a");if(!t)return void z.error("Could not find anchor element for",e.target);const n=new URL(t.href);return ie(this.#r,n.pathname+n.search)}}async function ie(e,t){return fetch(`/__mayu/session/${e}/navigate`,{method:"POST",headers:{"content-type":"text/plain; charset=utf-8"},body:t})}var se=async function(e){const t=function(e){const t=e.lastIndexOf("#");if(-1===t)throw new Error(`No # found in script url: ${e}`);return e.slice(t+1)}(e),n=new oe(t);let r;window.Mayu=n;const o=document.createElement("mayu-disconnected"),i=document.createElement("mayu-ping");i.setAttribute("region","Connecting..."),i.setAttribute("status","connecting"),document.body.appendChild(i);for await(const[e,n]of q(t))switch(e){case"system.connected":import("./custom-elements/mayu-ping-c498c2a6.js"),import("./custom-elements/mayu-disconnected-9f349f46.js"),import("./custom-elements/mayu-progress-bar-eb3e1ac8.js"),import("./custom-elements/mayu-exception-63df4e8c.js"),import("./custom-elements/mayu-alert-cd7ad2a4.js"),i.setAttribute("region","Connected!"),i.setAttribute("status","connected"),z.success("Connected!"),document.body.querySelectorAll("mayu-disconnected").forEach((e=>e.remove()));break;case"system.disconnected":if(n.transferring){i.setAttribute("region","Transferring…"),i.setAttribute("status","transferring");break}i.setAttribute("region","Disconnected"),i.setAttribute("status","disconnected"),z.error("Disconnected"),o.setAttribute("reason",n.reason),o.parentElement!==document.body&&document.body.appendChild(o);break;case"session.init":await ne,r=new Z(n.ids);break;case"session.patch":r?.apply(n);break;case"session.navigate":const t=n.path;t!==location.pathname&&(z.info("Navigating to",t),history.pushState({},"",t));break;case"session.action":s(n.type,n.payload);break;case"session.keep_alive":break;case"session.transfer":i.setAttribute("region","Transferring"),i.setAttribute("status","transferring");break;case"session.exception":re(n);break;case"ping":const a=Object.values(n.values),c=a.reduce(((e,t)=>e+t),0)/a.length;i.setAttribute("ping",`${c.toFixed(2)} ms`),i.setAttribute("region",`${n.instance} @ ${n.region}`),i.setAttribute("status","ping");break;default:z.warn("Unhandled event:",e,n)}function s(e,t){switch(e){case"scroll_into_view":!function(e,t){const n=document.querySelector(e);n?n.scrollIntoView({block:"start",inline:"nearest",behavior:"smooth",...t}):console.error("Could not find element to scrollIntoView, selector:",e)}(t.selector,t.options||{});break;case"alert":!async function(e){await import("./custom-elements/mayu-alert-cd7ad2a4.js");const t=document.createElement("mayu-alert");t.setAttribute("message",e),document.body.appendChild(t)}(t);break;default:z.error("Unhandled action:",e,t)}}}(import.meta.url);export{se as default};//# sourceMappingURL=main-4b49dbc4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"main-4b49dbc4.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@mayu-live/client",
3
+ "version": "0.0.0",
4
+ "private": true,
5
+ "license": "AGPL-3.0",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/mayu-live/prototype.git"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/mayu-live/prototype/issues"
13
+ },
14
+ "homepage": "https://github.com/mayu-live/prototype#readme",
15
+ "scripts": {
16
+ "watch": "npm run build -- --watch",
17
+ "build": "rollup -c rollup.config.js",
18
+ "build:production": "npm run build -- --compact",
19
+ "test": "echo \"Error: no test specified\" && exit 1"
20
+ },
21
+ "devDependencies": {
22
+ "@msgpack/msgpack": "^2.8.0",
23
+ "@rollup/plugin-commonjs": "^24.0.0",
24
+ "@rollup/plugin-node-resolve": "^15.0.1",
25
+ "@rollup/plugin-typescript": "^10.0.1",
26
+ "@types/serviceworker": "^0.0.59",
27
+ "esbuild": "^0.16.10",
28
+ "fflate": "^0.7.4",
29
+ "html-minifier-terser": "^7.1.0",
30
+ "rollup": "^3.8.1",
31
+ "rollup-plugin-delete": "^2.0.0",
32
+ "rollup-plugin-visualizer": "^5.8.3",
33
+ "tslib": "^2.4.1",
34
+ "typescript": "^4.9.4"
35
+ },
36
+ "dependencies": {
37
+ "@rollup/plugin-terser": "^0.2.1"
38
+ }
39
+ }
@@ -0,0 +1,81 @@
1
+ import typescript from "@rollup/plugin-typescript";
2
+ import resolve from "@rollup/plugin-node-resolve";
3
+ import commonjs from "@rollup/plugin-commonjs";
4
+ import terser from "@rollup/plugin-terser";
5
+ import del from "rollup-plugin-delete";
6
+ import { visualizer } from "rollup-plugin-visualizer";
7
+ import { minify } from "html-minifier-terser";
8
+
9
+ function entriesJSON() {
10
+ return {
11
+ name: "entriesJSON",
12
+ generateBundle(outputOptions, bundle) {
13
+ const data = {};
14
+
15
+ for (const chunk of Object.values(bundle)) {
16
+ if (chunk.isEntry) {
17
+ data[chunk.name] = chunk.fileName;
18
+ }
19
+ }
20
+
21
+ this.emitFile({
22
+ type: "asset",
23
+ fileName: "entries.json",
24
+ source: JSON.stringify(data, null, 2) + "\n",
25
+ });
26
+ },
27
+ };
28
+ }
29
+
30
+ function minifyHTML(minifyOptions = {}) {
31
+ return {
32
+ name: "minifyHTML",
33
+ async transform(code, id) {
34
+ if (!id.endsWith(".html")) return;
35
+
36
+ const minified = await minify(code, minifyOptions);
37
+
38
+ return {
39
+ code: `export default ${JSON.stringify(minified)};`,
40
+ map: { mappings: "" },
41
+ };
42
+ },
43
+ };
44
+ }
45
+
46
+ export default {
47
+ input: ["src/main.ts"],
48
+ output: {
49
+ dir: "dist/",
50
+ format: "esm",
51
+ entryFileNames: "[name]-[hash].js",
52
+ chunkFileNames: "[name]-[hash].js",
53
+ assetFileNames: "[name]-[hash][extname]",
54
+ sourcemap: true,
55
+ manualChunks(id) {
56
+ if (id.includes("custom-elements")) {
57
+ return "custom-elements/" + id.split("/").slice(-1)[0].split(".")[0];
58
+ }
59
+ },
60
+ },
61
+ plugins: [
62
+ del({ targets: "dist/*" }),
63
+ typescript(),
64
+ commonjs(),
65
+ resolve(),
66
+ minifyHTML({
67
+ removeComments: true,
68
+ collapseWhitespace: true,
69
+ collapseBooleanAttributes: true,
70
+ removeEmptyAttributes: true,
71
+ minifyJS: true,
72
+ minifyCSS: true,
73
+ }),
74
+ terser(),
75
+ entriesJSON(),
76
+ visualizer({
77
+ gzipSize: true,
78
+ brotliSize: true,
79
+ }),
80
+ ],
81
+ };
@@ -0,0 +1,15 @@
1
+ import logger from "./logger";
2
+
3
+ const DecompressionStreamPromise = new Promise<typeof DecompressionStream>(
4
+ async (resolve) => {
5
+ if (typeof DecompressionStream !== "undefined") {
6
+ logger.success("Using standard DecompressionStream");
7
+ return resolve(DecompressionStream);
8
+ }
9
+
10
+ logger.warn("Using DecompressionStream polyfill");
11
+ resolve((await import("./DecompressionStreamPolyfill")).default);
12
+ }
13
+ );
14
+
15
+ export default await DecompressionStreamPromise;
@@ -0,0 +1,43 @@
1
+ import { AsyncInflate } from "fflate";
2
+
3
+ class DecompressionStreamPolyfill extends TransformStream<
4
+ Uint8Array,
5
+ Uint8Array
6
+ > {
7
+ constructor(_format: "deflate-raw") {
8
+ let decompressor: AsyncInflate;
9
+
10
+ super({
11
+ start(controller) {
12
+ decompressor = new AsyncInflate();
13
+
14
+ decompressor.ondata = (err, chunk: Uint8Array, final: boolean) => {
15
+ if (err) {
16
+ controller.error(err);
17
+ return;
18
+ }
19
+
20
+ if (final) {
21
+ controller.terminate();
22
+ } else {
23
+ controller.enqueue(chunk);
24
+ }
25
+ };
26
+ },
27
+ transform(chunk, controller) {
28
+ try {
29
+ decompressor.push(chunk, false);
30
+ } catch (e) {
31
+ controller.error(
32
+ new Error(`DecompressionStreamPolyfill inflation failure: ${e}`)
33
+ );
34
+ }
35
+ },
36
+ flush() {
37
+ decompressor.push(new Uint8Array(), true);
38
+ },
39
+ });
40
+ }
41
+ }
42
+
43
+ export default DecompressionStreamPolyfill as typeof DecompressionStream;
@@ -0,0 +1,4 @@
1
+ export const enum MimeTypes {
2
+ MAYU_SESSION = "application/vnd.mayu.session",
3
+ MAYU_STREAM = "application/vnd.mayu.eventstream",
4
+ }