@spearwolf/shadow-objects 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (184) hide show
  1. package/LICENSE +13 -0
  2. package/README.md +69 -0
  3. package/bundle.js +70 -0
  4. package/package.json +58 -0
  5. package/src/bundle.d.ts +7 -0
  6. package/src/bundle.d.ts.map +1 -0
  7. package/src/bundle.js +5 -0
  8. package/src/bundle.js.map +1 -0
  9. package/src/constants.d.ts +39 -0
  10. package/src/constants.d.ts.map +1 -0
  11. package/src/constants.js +40 -0
  12. package/src/constants.js.map +1 -0
  13. package/src/create-worker.bundle.d.ts +3 -0
  14. package/src/create-worker.bundle.d.ts.map +1 -0
  15. package/src/create-worker.bundle.js +6 -0
  16. package/src/create-worker.bundle.js.map +1 -0
  17. package/src/create-worker.d.ts +3 -0
  18. package/src/create-worker.d.ts.map +1 -0
  19. package/src/create-worker.js +2 -0
  20. package/src/create-worker.js.map +1 -0
  21. package/src/elements/ShaeElement.d.ts +13 -0
  22. package/src/elements/ShaeElement.d.ts.map +1 -0
  23. package/src/elements/ShaeElement.js +58 -0
  24. package/src/elements/ShaeElement.js.map +1 -0
  25. package/src/elements/ShaeEntElement.d.ts +23 -0
  26. package/src/elements/ShaeEntElement.d.ts.map +1 -0
  27. package/src/elements/ShaeEntElement.js +258 -0
  28. package/src/elements/ShaeEntElement.js.map +1 -0
  29. package/src/elements/ShaePropElement.d.ts +26 -0
  30. package/src/elements/ShaePropElement.d.ts.map +1 -0
  31. package/src/elements/ShaePropElement.js +321 -0
  32. package/src/elements/ShaePropElement.js.map +1 -0
  33. package/src/elements/ShaeWorkerElement.d.ts +25 -0
  34. package/src/elements/ShaeWorkerElement.d.ts.map +1 -0
  35. package/src/elements/ShaeWorkerElement.js +208 -0
  36. package/src/elements/ShaeWorkerElement.js.map +1 -0
  37. package/src/elements/constants.d.ts +17 -0
  38. package/src/elements/constants.d.ts.map +1 -0
  39. package/src/elements/constants.js +21 -0
  40. package/src/elements/constants.js.map +1 -0
  41. package/src/elements/events.d.ts +24 -0
  42. package/src/elements/events.d.ts.map +1 -0
  43. package/src/elements/events.js +2 -0
  44. package/src/elements/events.js.map +1 -0
  45. package/src/entities/Entity.d.ts +46 -0
  46. package/src/entities/Entity.d.ts.map +1 -0
  47. package/src/entities/Entity.js +217 -0
  48. package/src/entities/Entity.js.map +1 -0
  49. package/src/entities/Kernel.d.ts +60 -0
  50. package/src/entities/Kernel.d.ts.map +1 -0
  51. package/src/entities/Kernel.js +361 -0
  52. package/src/entities/Kernel.js.map +1 -0
  53. package/src/entities/Registry.d.ts +16 -0
  54. package/src/entities/Registry.d.ts.map +1 -0
  55. package/src/entities/Registry.js +72 -0
  56. package/src/entities/Registry.js.map +1 -0
  57. package/src/entities/ShadowObject.d.ts +18 -0
  58. package/src/entities/ShadowObject.d.ts.map +1 -0
  59. package/src/entities/ShadowObject.js +24 -0
  60. package/src/entities/ShadowObject.js.map +1 -0
  61. package/src/entities/SignalsMap.d.ts +12 -0
  62. package/src/entities/SignalsMap.d.ts.map +1 -0
  63. package/src/entities/SignalsMap.js +34 -0
  64. package/src/entities/SignalsMap.js.map +1 -0
  65. package/src/entities/SignalsPath.d.ts +12 -0
  66. package/src/entities/SignalsPath.d.ts.map +1 -0
  67. package/src/entities/SignalsPath.js +73 -0
  68. package/src/entities/SignalsPath.js.map +1 -0
  69. package/src/entities/events.d.ts +27 -0
  70. package/src/entities/events.d.ts.map +1 -0
  71. package/src/entities/events.js +7 -0
  72. package/src/entities/events.js.map +1 -0
  73. package/src/entities/importModule.d.ts +4 -0
  74. package/src/entities/importModule.d.ts.map +1 -0
  75. package/src/entities/importModule.js +32 -0
  76. package/src/entities/importModule.js.map +1 -0
  77. package/src/index.d.ts +22 -0
  78. package/src/index.d.ts.map +1 -0
  79. package/src/index.js +20 -0
  80. package/src/index.js.map +1 -0
  81. package/src/shadow-objects.d.ts +7 -0
  82. package/src/shadow-objects.d.ts.map +1 -0
  83. package/src/shadow-objects.js +6 -0
  84. package/src/shadow-objects.js.map +1 -0
  85. package/src/shadow-objects.worker.d.ts +2 -0
  86. package/src/shadow-objects.worker.d.ts.map +1 -0
  87. package/src/shadow-objects.worker.js +5 -0
  88. package/src/shadow-objects.worker.js.map +1 -0
  89. package/src/shae-ent.d.ts +2 -0
  90. package/src/shae-ent.d.ts.map +1 -0
  91. package/src/shae-ent.js +4 -0
  92. package/src/shae-ent.js.map +1 -0
  93. package/src/shae-prop.d.ts +2 -0
  94. package/src/shae-prop.d.ts.map +1 -0
  95. package/src/shae-prop.js +4 -0
  96. package/src/shae-prop.js.map +1 -0
  97. package/src/shae-worker.d.ts +2 -0
  98. package/src/shae-worker.d.ts.map +1 -0
  99. package/src/shae-worker.js +4 -0
  100. package/src/shae-worker.js.map +1 -0
  101. package/src/types.d.ts +89 -0
  102. package/src/types.d.ts.map +1 -0
  103. package/src/types.js +2 -0
  104. package/src/types.js.map +1 -0
  105. package/src/utils/FrameLoop.d.ts +8 -0
  106. package/src/utils/FrameLoop.d.ts.map +1 -0
  107. package/src/utils/FrameLoop.js +45 -0
  108. package/src/utils/FrameLoop.js.map +1 -0
  109. package/src/utils/array-utils.d.ts +11 -0
  110. package/src/utils/array-utils.d.ts.map +1 -0
  111. package/src/utils/array-utils.js +27 -0
  112. package/src/utils/array-utils.js.map +1 -0
  113. package/src/utils/attr-utils.d.ts +3 -0
  114. package/src/utils/attr-utils.d.ts.map +1 -0
  115. package/src/utils/attr-utils.js +12 -0
  116. package/src/utils/attr-utils.js.map +1 -0
  117. package/src/utils/constants.d.ts +2 -0
  118. package/src/utils/constants.d.ts.map +1 -0
  119. package/src/utils/constants.js +2 -0
  120. package/src/utils/constants.js.map +1 -0
  121. package/src/utils/generateUUID.d.ts +2 -0
  122. package/src/utils/generateUUID.d.ts.map +1 -0
  123. package/src/utils/generateUUID.js +34 -0
  124. package/src/utils/generateUUID.js.map +1 -0
  125. package/src/utils/props-utils.d.ts +8 -0
  126. package/src/utils/props-utils.d.ts.map +1 -0
  127. package/src/utils/props-utils.js +47 -0
  128. package/src/utils/props-utils.js.map +1 -0
  129. package/src/utils/toNamespace.d.ts +3 -0
  130. package/src/utils/toNamespace.d.ts.map +1 -0
  131. package/src/utils/toNamespace.js +3 -0
  132. package/src/utils/toNamespace.js.map +1 -0
  133. package/src/utils/toUrlString.d.ts +2 -0
  134. package/src/utils/toUrlString.d.ts.map +1 -0
  135. package/src/utils/toUrlString.js +7 -0
  136. package/src/utils/toUrlString.js.map +1 -0
  137. package/src/utils/waitForMessageOfType.d.ts +5 -0
  138. package/src/utils/waitForMessageOfType.d.ts.map +1 -0
  139. package/src/utils/waitForMessageOfType.js +34 -0
  140. package/src/utils/waitForMessageOfType.js.map +1 -0
  141. package/src/view/ComponentChanges.d.ts +30 -0
  142. package/src/view/ComponentChanges.d.ts.map +1 -0
  143. package/src/view/ComponentChanges.js +249 -0
  144. package/src/view/ComponentChanges.js.map +1 -0
  145. package/src/view/ComponentContext.d.ts +76 -0
  146. package/src/view/ComponentContext.d.ts.map +1 -0
  147. package/src/view/ComponentContext.js +344 -0
  148. package/src/view/ComponentContext.js.map +1 -0
  149. package/src/view/ComponentMemory.d.ts +8 -0
  150. package/src/view/ComponentMemory.d.ts.map +1 -0
  151. package/src/view/ComponentMemory.js +79 -0
  152. package/src/view/ComponentMemory.js.map +1 -0
  153. package/src/view/IShadowObjectEnvProxy.d.ts +10 -0
  154. package/src/view/IShadowObjectEnvProxy.d.ts.map +1 -0
  155. package/src/view/IShadowObjectEnvProxy.js +2 -0
  156. package/src/view/IShadowObjectEnvProxy.js.map +1 -0
  157. package/src/view/LocalShadowObjectEnv.d.ts +18 -0
  158. package/src/view/LocalShadowObjectEnv.d.ts.map +1 -0
  159. package/src/view/LocalShadowObjectEnv.js +55 -0
  160. package/src/view/LocalShadowObjectEnv.js.map +1 -0
  161. package/src/view/RemoteWorkerEnv.d.ts +15 -0
  162. package/src/view/RemoteWorkerEnv.d.ts.map +1 -0
  163. package/src/view/RemoteWorkerEnv.js +112 -0
  164. package/src/view/RemoteWorkerEnv.js.map +1 -0
  165. package/src/view/ShadowEnv.d.ts +30 -0
  166. package/src/view/ShadowEnv.d.ts.map +1 -0
  167. package/src/view/ShadowEnv.js +202 -0
  168. package/src/view/ShadowEnv.js.map +1 -0
  169. package/src/view/ViewComponent.d.ts +33 -0
  170. package/src/view/ViewComponent.d.ts.map +1 -0
  171. package/src/view/ViewComponent.js +130 -0
  172. package/src/view/ViewComponent.js.map +1 -0
  173. package/src/view/cloneChangeTrail.d.ts +3 -0
  174. package/src/view/cloneChangeTrail.d.ts.map +1 -0
  175. package/src/view/cloneChangeTrail.js +12 -0
  176. package/src/view/cloneChangeTrail.js.map +1 -0
  177. package/src/worker/MessageRouter.d.ts +14 -0
  178. package/src/worker/MessageRouter.d.ts.map +1 -0
  179. package/src/worker/MessageRouter.js +72 -0
  180. package/src/worker/MessageRouter.js.map +1 -0
  181. package/src/worker/WorkerRuntime.d.ts +7 -0
  182. package/src/worker/WorkerRuntime.d.ts.map +1 -0
  183. package/src/worker/WorkerRuntime.js +15 -0
  184. package/src/worker/WorkerRuntime.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2023-2024 Wolfger Schramm <wolfger@spearwolf.de>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,69 @@
1
+ # Welcome to _shadow-ents_ :wave:
2
+
3
+ shadow-objects is a JavaScript library that's all about making your life easier when dealing with components and web workers. It's like having a superpower for your web development! :muscle:
4
+
5
+ ![architecture overview](./docs/architecture@2x.png)
6
+
7
+ > _ents_ is short for latin _"entitatis"_, which translates to _"shadow entities"_
8
+
9
+
10
+ ## Quick Tour
11
+
12
+ ### Offloading to Web Workers :construction_worker:
13
+
14
+ shadow-objects takes the heavy lifting off your main thread and moves it to web workers. This means your components stay light and breezy, just like a hibiscus flower in the wind. :hibiscus:
15
+
16
+ ### Entities :ghost:
17
+
18
+ Yes, we've got entities too! In shadow-objects, an _entity_ belongs to a _view-component_, but it lives in a _web worker_. That's why we call them _shadow-entities_. They're like the secret agents of your app, working behind the scenes in their own separate world.
19
+
20
+ ### Shadow Objects :package:
21
+
22
+ The _shadow-objects_ are simple functions or classes created by the user (you!) and form logical units of code in which the real work is done behind the scenes.
23
+
24
+ Shadow-objects reside within the context of an entity and have access to the entity's properties and events, which mirror the properties and events of the view-components.
25
+
26
+ Any number of independent shadow-objects can be attached to an entity.
27
+
28
+ Shadow-objects can also provide any _context_ to other shadow-objects:
29
+ - a _context_ has a name and can consist of any JavaScript value or object.
30
+ - a _context_ is inherited by subtrees through the hierarchy of entities.
31
+
32
+
33
+ ### View Components :eyes:
34
+
35
+
36
+ A `<view-component/>` is a virtual component in the view that serves as an access point for the entities.
37
+
38
+ The _shadow-ents_ package provides the custom element `<shadow-objects>` as view component. As a HTML element in the DOM, these might form their own hierarchy.
39
+ This hierarchy is mirrored by the entities in the worker, keeping everything in sync.
40
+
41
+ In the future, implementations as _react_ or _angular_ components are also conceivable.
42
+
43
+
44
+ ### Component Context :brain:
45
+
46
+ The _component-context_ is the root of a view-component hierarchy. It's like the conductor of an orchestra, creating a web worker and making sure the entities and their components are in harmony.
47
+
48
+ ### Kernel :nut_and_bolt:
49
+
50
+ Inside the worker, there's the _kernel_. It's the counterpart to the component-context, taking care of the lifecycle of the entities and their _shadow-objects_.
51
+
52
+ ### Tokens :label:
53
+
54
+ When a view-component is created, you can apply a string-based token. The kernel uses these to decide which shadow-objects to create within each entity. It's like giving your components a secret handshake!
55
+
56
+ ### Event and Property Synchronization :arrows_counterclockwise:
57
+
58
+ View-components can send events to their entities, which are then passed on to the shadow-objects. This also works the other way around. However, property synchronization only goes one way, from view-components to entities.
59
+
60
+ - - -
61
+
62
+ So, that's a quick tour of shadow-objects! It's all about making your web ui faster and more responsive, and assembling your code in a more structured and streamlined way. Give it a try and see the difference it can make in your projects! :rocket:
63
+
64
+ More in-depth documentation here:
65
+ - [ShadowEnv](./src/view/README.md)
66
+ - [ComponentContext](./src/view/ComponentContext.md)
67
+ - [ViewComponent](./src/view/ViewComponent.md)
68
+
69
+ > _but dear adventurer, be warned: everything here is highly experimental and in active development and constant flux!_
package/bundle.js ADDED
@@ -0,0 +1,70 @@
1
+ /*!
2
+ @file @spearwolf/shadow-objects - the slighty different component framework
3
+ @author Wolfger Schramm <wolfger@spearwolf.de>
4
+ @version 0.1.0+bundle.20240802
5
+
6
+ Copyright 2024 Wolfger Schramm
7
+
8
+ Licensed under the Apache License, Version 2.0 (the "License");
9
+ you may not use this file except in compliance with the License.
10
+ You may obtain a copy of the License at
11
+
12
+ http://www.apache.org/licenses/LICENSE-2.0
13
+
14
+ Unless required by applicable law or agreed to in writing, software
15
+ distributed under the License is distributed on an "AS IS" BASIS,
16
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ See the License for the specific language governing permissions and
18
+ limitations under the License.
19
+
20
+ */
21
+ var Z="*",Tt=1,at=2,ht=4,$=Symbol("eventize"),ys="[eventize]",Pe=r=>r===Z,Ot=r=>{switch(typeof r){case"string":case"symbol":return!0;default:return!1}},Pt=typeof console<"u",ms=Pt?console[console.warn?"warn":"log"].bind(console,ys):()=>{},gs=(r,e,t)=>(Object.defineProperty(r,e,{value:t,configurable:!0}),r),vs=0,Rt=class{static publish(r){r.sort((e,t)=>e.order-t.order).forEach(e=>e.emit())}events=new Map;eventNames=new Set;add(r){Array.isArray(r)?r.forEach(e=>this.eventNames.add(e)):this.eventNames.add(r)}remove(r){Array.isArray(r)?r.forEach(e=>this.eventNames.delete(e)):this.eventNames.delete(r),this.clear(r)}clear(r){Array.isArray(r)?r.forEach(e=>this.events.delete(e)):this.events.delete(r)}retain(r,e){this.eventNames.has(r)&&this.events.set(r,{args:e,order:vs++})}isKnown(r){return this.eventNames.has(r)}emit(r,e,t=[]){if(Pe(r))this.eventNames.forEach(s=>this.emit(s,e,t));else if(this.events.has(r)){let{order:s,args:i}=this.events.get(r);t.push({order:s,emit:()=>e.apply(r,i)})}return t}},nt=(r,e,t,s)=>{if(typeof e=="function"){let i=e.apply(r,t);i!=null&&s?.(i)}},bs=(r,e,t,s)=>nt(e,e.emit,[r].concat(t),s),ws=r=>{switch(typeof r){case"function":return Tt;case"string":case"symbol":return at;case"object":return ht}},Es=0,Cs=()=>++Es,_t=class{id;eventName;isCatchEmAll;priority;listener;listenerObject;listenerType;callAfterApply;isRemoved;refCount;constructor(r,e,t,s=null){this.id=Cs(),this.eventName=r,this.isCatchEmAll=Pe(r),this.listener=t,this.listenerObject=s,this.priority=e,this.listenerType=ws(t),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(r,e=null){if(r===this)return!0;let t=typeof r;return t==="number"&&r===this.id?!0:e===null&&(t==="string"||t==="symbol")?r===Z||r===this.eventName:this.listener===r&&this.listenerObject===e}apply(r,e,t){if(this.isRemoved)return;let{listener:s,listenerObject:i}=this;switch(this.listenerType){case Tt:nt(i,s,e,t),this.callAfterApply&&this.callAfterApply();break;case at:nt(i,i[s],e,t),this.callAfterApply&&this.callAfterApply();break;case ht:{let n=s[r];if(this.isCatchEmAll||this.eventName===r){if(typeof n=="function"){let o=n.apply(s,e);o!=null&&t?.(o)}else bs(r,s,e,t);this.callAfterApply&&this.callAfterApply()}break}}}},Ss=(r,e)=>r.priority!==e.priority?e.priority-r.priority:r.id-e.id,xt=r=>r?.slice(0),At=(r,e)=>{let t=r.indexOf(e);t>-1&&r.splice(t,1)},xs=r=>r===ht||r===at,ot=(r,e,t)=>{let s=r.findIndex(i=>i.isEqual(e,t));s>-1&&(r[s].isRemoved=!0,r.splice(s,1))},Oe=(r,e,t)=>{let s=[];for(let i of r)(e==null&&i.listenerObject===t||i.eventName===e&&i.listener===t)&&s.push(i);for(let i of s)ot(r,i,void 0)},it=r=>{r&&(r.forEach(e=>{e.isRemoved=!0}),r.length=0)},As=(r,e)=>r.listenerType===e.listenerType?r.priority===e.priority&&r.eventName===e.eventName&&r.listenerObject===e.listenerObject&&r.listener===e.listener:!1,ks=(r,e)=>{if(xs(r.listenerType))return e.find(t=>As(r,t))},Ts=(r,e)=>{let t=ks(r,e);return t?(t.refCount+=1,t):(e.push(r),e.sort(Ss),r)},Os=class{namedListeners;catchEmAllListeners;getListenersForEventName=r=>{let e=this.namedListeners.get(r);return e||(e=[],this.namedListeners.set(r,e)),e};constructor(){this.namedListeners=new Map,this.catchEmAllListeners=[]}add(r){return Ts(r,r.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(r.eventName))}remove(r,e,t=!1){e==null&&Array.isArray(r)?r.forEach(s=>this.remove(s,null,t)):r==null||e==null&&Pe(r)?this.removeAllListeners():e==null&&Ot(r)?it(this.namedListeners.get(r)):r instanceof _t?r.isRemoved||(r.refCount-=1,r.refCount<1&&(r.isRemoved=!0,this.namedListeners.forEach(s=>At(s,r)),At(this.catchEmAllListeners,r))):t?Pe(r)?Oe(this.catchEmAllListeners,Z,r):this.namedListeners.forEach(s=>Oe(s,r,e)):(this.namedListeners.forEach(s=>{ot(s,r,e),Oe(s,void 0,r)}),ot(this.catchEmAllListeners,r,e),Oe(this.catchEmAllListeners,void 0,r))}removeAllListeners(){this.namedListeners.forEach(r=>it(r)),this.namedListeners.clear(),it(this.catchEmAllListeners)}forEach(r,e){let t=xt(this.catchEmAllListeners),s=xt(this.namedListeners.get(r));if(r===Z||!s||s.length===0)t.forEach(e);else if(t.length===0)s.forEach(e);else{let i=s.length,n=t.length,o=0,a=0;for(;o<i||a<n;){if(o<i){let h=s[o];if(a>=n||h.priority>=t[a].priority){e(h),++o;continue}}a<n&&(e(t[a]),++a)}}}getSubscriptionCount(){let r=this.catchEmAllListeners.length;for(let e of this.namedListeners.values())r+=e.length;return r}},ee=r=>!!(r&&r[$]);function de(r){if(ee(r))return r;let e=new Os,t=new Rt;return gs(r,$,{keeper:t,store:e}),r}var pe={Max:Number.POSITIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY},Ps=(r,e,t,s,i,n,o)=>{let a=r.add(new _t(t,s,i,n));return e.emit(t,a,o),a},Rs=(r,e,t,s)=>{let i=t.length,n=typeof t[0],o,a,h,l;if(i>=2&&i<=3&&n==="number"?(o=Z,[a,h,l]=t):i>=3&&i<=4&&typeof t[1]=="number"?[o,a,h,l]=t:(a=pe.Default,n==="string"||n==="symbol"||Array.isArray(t[0])?[o,h,l]=t:(o=Z,[h,l]=t)),!h&&Pt)throw ms("called with insufficient arguments!",t),"subscribeTo() called with insufficient arguments!";let u=d=>v=>Ps(r,e,v,d,h,l,s);return Array.isArray(o)?o.map(d=>Array.isArray(d)?u(d[1])(d[0]):u(a)(d)):u(a)(o)},Mt=(r,e,t)=>{let s=[],i=Rs(r,e,t,s);return Rt.publish(s),i},kt=r=>e=>{e.callAfterApply=()=>{r?.()}},jt=(r,e)=>Object.assign(()=>E(r,e),Array.isArray(e)?{listeners:e}:{listener:e}),Lt=(r,e,t,s)=>{let{store:i,keeper:n}=r[$];Array.isArray(e)?e.forEach(o=>{i.forEach(o,a=>a.apply(o,t,s)),n.retain(o,t)}):e!==Z&&(i.forEach(e,o=>{o.apply(e,t,s)}),n.retain(e,t))},g=(r,...e)=>{let t=de(r),{store:s,keeper:i}=t[$];return jt(t,Mt(s,i,e))},P=(r,...e)=>{let t=de(r),{store:s,keeper:i}=t[$],n=Mt(s,i,e),o=jt(t,n),a=!1,h=()=>{a||(o(),a=!0)};return Array.isArray(n)?n.forEach(kt(h)):kt(h)(n),h},ae=(r,e)=>new Promise(t=>{P(r,e,t)}),E=(r,e,t)=>{if(!ee(r))throw new Error("object is not eventized");let{store:s,keeper:i}=r[$],n=typeof e,o=t!=null&&(n==="string"||n==="symbol");s.remove(e,t,o),Array.isArray(e)?i.remove(e.filter(a=>typeof a=="string")):Ot(e)&&i.remove(e)},p=(r,e,...t)=>{if(!ee(r))throw new Error("object is not eventized");Lt(r,e,t)},_s=(r,e,...t)=>{if(!ee(r))throw new Error("object is not eventized");let s=[];return Lt(r,e,t,i=>{s.push(i)}),s=s.map(i=>Array.isArray(i)?Promise.all(i):Promise.resolve(i)),s.length>0?Promise.all(s):Promise.resolve()},N=(r,e)=>{let t=de(r),{keeper:s}=t[$];s.add(e)},ye=(r,e)=>{if(!ee(r))throw new Error("object is not eventized");let{keeper:t}=r[$];t.clear(e)},k=(()=>{let r=(e={})=>de(e);return r.inject=(e={})=>(e=de(e),Object.assign(e,{on:(...t)=>g(e,...t),once:(...t)=>P(e,...t),onceAsync:t=>ae(e,t),off:(t,s)=>E(e,t,s),emit:(t,...s)=>p(e,t,...s),emitAsync:(t,...s)=>_s(e,t,...s),retain:t=>N(e,t),retainClear:t=>ye(e,t)}),e),r.is=ee,r})();var lt=r=>ee(r)?r[$]?.store?.getSubscriptionCount()??0:0;var O=Symbol("signal"),ct=Symbol("destroySignal"),ut=Symbol("createEffect"),Ft=Symbol("destroyEffect");var he=class{#e;#t;constructor(e="id",t=1){this.#e=e,this.#t=t}make(){return Symbol(`${this.#e}${this.#t++}`)}};var V=k(),te=k(),B=k();var se=class{static current;#e=new Set;batch(e){this.#e.add(e)}run(){p(B,Array.from(this.#e))}},$t=()=>se.current;function R(r){let e=se.current;e?e=void 0:e=se.current=new se;try{r()}finally{e&&(se.current=void 0,e.run())}}var ft=[],Re=()=>ft.at(-1),Nt=(r,e)=>{ft.push(r);try{return e()}finally{ft.pop()}};var Ms=r=>r!=null&&typeof r.then=="function",_e=class r{static idGen=new he("ef");static count=0;id;callback;#e;#t=new Set;#s=new Set;parentEffect;childEffects=[];curChildEffectSlot=0;autorun=!0;shouldRun=!0;#i;#r=!1;constructor(e,t){this.callback=e,this.autorun=t?.autorun??!0,this.#i=t?.dependencies,this.id=r.idGen.make(),g(B,this.id,"recall",this),++r.count}hasStaticDeps(){return this.#i!=null&&this.#i.length>0}saveSignalsFromDeps(){for(let e of this.#i)this.whenSignalIsRead(C(e).id)}static createEffect(e,t,s){let i=Array.isArray(t)?t:void 0,n=i?s??{dependencies:i}:t;n&&i&&(n.dependencies=i);let o,a=Re();return a!=null?(o=a.getCurrentChildEffect(),o==null&&(o=new r(e,n),a.attachChildEffect(o),p(B,ut,o)),a.curChildEffectSlot++):(o=new r(e,n),p(B,ut,o)),o.hasStaticDeps()?o.saveSignalsFromDeps():o.autorun&&o.run(),[o.run.bind(o),o.destroy.bind(o)]}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(e){this.childEffects.push(e),this.parentEffect=this}run(){if(this.#r||!this.shouldRun)return;let e=$t();e?e.batch(this.id):(this.runCleanupCallback(),this.curChildEffectSlot=0,this.shouldRun=!1,this.hasStaticDeps()?this.#e=this.callback():this.#e=Nt(this,this.callback))}recall(){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(e){this.#t.has(e)||(this.#t.add(e),g(V,e,"recall",this),P(te,e,ct,this))}[ct](e){!this.#s.has(e)&&this.#t.has(e)&&(this.#s.add(e),E(V,e,this),this.#s.size===this.#t.size&&this.destroy())}runCleanupCallback(){if(this.#e!=null){let e=this.#e;this.#e=void 0,Ms(e)?Promise.resolve(e).then(t=>{typeof t=="function"&&t()}):e()}}destroy(){this.#r||(p(B,Ft,this),this.runCleanupCallback(),E(V,this),E(B,this),E(te,this),this.#r=!0,this.#t.clear(),this.#s.clear(),this.childEffects.forEach(e=>{e.destroy()}),this.childEffects.length=0,--r.count)}};var b=(...r)=>_e.createEffect(...r);var D=new WeakMap,T=(r,e)=>D.get(r)?.signals[e],Dt=r=>{let e=D.get(r)?.signals;if(e)return Object.values(e)};var Wt=(r,e,t)=>{let s=D.get(r);s?s.signals[e]=t:D.set(r,{signals:{[e]:t},effects:{}})};function dt(...r){for(let e of r)if(D.has(e)){let t=D.get(e);for(let s of Object.values(t.signals))_(s);t.signals={}}}function pt(...r){for(let e of r)if(D.has(e)){let{signals:t,effects:s}=D.get(e);for(let i of Object.values(t))_(i);for(let[,i]of Object.values(s))i();D.delete(e)}}function It(r){let e=C(q(r)?r:T(...r));e!=null&&!e.muted&&!e.destroyed&&Me(e.id,e.value,{touch:!0})}function W(r){return q(r)?C(r)?.value:C(T(...r))?.value}var je=class{[O];constructor(e){this[O]=e}get get(){return this[O].reader}get set(){return this[O].writer}*[Symbol.iterator](){yield this.get,yield this.set}get value(){return W(this.get)}set value(e){this.set(e)}onChange(e){let[,t]=b(()=>e(this.value),[this.get]);return t}get muted(){return this[O].muted}set muted(e){this[O].muted=e}touch(){It(this)}destroy(){_(this)}};var yt=0;function zt(r){yt++;try{r()}finally{yt--}}function Ut(){return yt>0}var js=new he("si");function Vt(r){Ut()||Re()?.whenSignalIsRead(r)}function Me(r,e,t){p(V,r,e,t)}var q=r=>r!=null&&r[O]!=null,Ls=r=>{let e=t=>(t?b(()=>(r.destroyed||Vt(r.id),t(r.value)),[e]):r.destroyed||(r.beforeReadFn?.(),Vt(r.id)),r.value);return Object.defineProperty(e,O,{value:r}),e},Le=class r{static instanceCount=0;id;lazy;compareFn;beforeReadFn;muted=!1;destroyed=!1;#e=void 0;get value(){return this.lazy&&(this.#e=this.valueFn(),this.valueFn=void 0,this.lazy=!1),this.#e}set value(e){this.#e=e}valueFn;reader;writer=(e,t)=>{let s=t?.lazy??!1,n=t?.compareFn??this.compareFn??((a,h)=>a===h);if((s!==this.lazy||s&&e!==this.valueFn||!s&&!n(e,this.#e))&&(s?(this.#e=void 0,this.valueFn=e,this.lazy=!0):(this.#e=e,this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){Me(this.id,this.#e);return}(t?.touch??!1)&&Me(this.id,this.#e,{touch:!0})};object;constructor(e,t){this.id=js.make(),++r.instanceCount,this.lazy=e,this.lazy?(this.value=void 0,this.valueFn=t):(this.value=t,this.valueFn=void 0),this.reader=Ls(this),this.object=new je(this)}},C=r=>r?.[O];function y(r=void 0,e){let t;if(q(r))t=C(r);else{let s=e?.lazy??!1;t=new Le(s,r),t.beforeReadFn=e?.beforeReadFn,t.compareFn=e?.compareFn}return t.object}var _=(...r)=>{for(let e of r){let t=C(e);t!=null&&!t.destroyed&&(t.destroyed=!0,t.beforeReadFn=void 0,--Le.instanceCount,p(te,t.id,t.id))}};var S,le=new WeakMap,me=new WeakMap,Bt=r=>typeof r=="function",G;(function(r){r.Signal="signal",r.Function="function",r.Property="property"})(G||(G={}));var ge=class{static Value="value";static Mute="mute";static Unmute="unmute";static Destroy="destroy";static#e(e){if(!e.isDestroyed){let t=e.#o,s=le.get(t);s?s.add(e):(s=new Set([e]),le.set(t,s))}}static#t(e){if(!e.isDestroyed){let t=e.#o,s=le.get(t);s&&(s.delete(e),s.size===0&&le.delete(t))}}static#s(e,t){if(!t.isDestroyed){let s=me.get(e);s?s.add(t):(s=new Set([t]),me.set(e,s))}}static#i(e,t){if(!t.isDestroyed){let s=me.get(e);s&&(s.delete(t),s.size===0&&me.delete(e))}}static findConnectionsBySignal(e){return le.get(C(e))}static findConnectionsByTarget(e){let t=me.get(e);return t?Array.from(t):void 0}static findConnectionsByObject(e){let t=new Set,s=Dt(e);if(s)for(let n of s.flatMap(o=>{let a=S.findConnectionsBySignal(o);return a?Array.from(a):[]}))t.add(n);let i=S.findConnectionsByTarget(e);if(i)for(let n of i)t.add(n);return t.size>0?Array.from(t):void 0}static findConnection(e,t){let s=le.get(C(e));if(s!=null){let i=Array.from(s),n=-1;if(q(t)){let o=C(t);n=i.findIndex(a=>a.#a===o)}else Bt(t)?n=i.findIndex(o=>o.#a===t):n=i.findIndex(o=>{if(o.#h===G.Property){let a=o.#a;return a[0]===t[0]&&a[1]===t[1]}return!1});if(n>=0)return i[n]}}#r;#n=!1;get isMuted(){return this.#n}#o;#a;#h;#c;constructor(e,t,s){let i=S.findConnection(e,t);if(i!=null)return i;k(this),N(this,S.Value),this.#o=C(e),q(t)?(this.#a=C(t),this.#h=G.Signal):Bt(t)?(this.#a=t,this.#h=G.Function):(this.#a=t,this.#h=G.Property),this.#c=s,this.#r=g(V,this.#o.id,(n,o)=>{o?.touch===!0?this.touch():this.#l(!1)}),P(te,this.#o.id,"destroy",this),S.#e(this),s!=null&&S.#s(s,this),this.touch()}nextValue(){return new Promise((e,t)=>{let s=0,i=[g(this,S.Value,n=>{s===1?(i.forEach(o=>{o()}),e(n)):++s}),g(this,S.Destroy,()=>{i.forEach(n=>{n()}),t()})]})}#l(e){if(!this.#n&&!this.isDestroyed){let{value:t}=this.#o;if(this.#h===G.Signal)this.#a.writer(t,e?{touch:e}:void 0);else if(this.#h===G.Function)this.#a(t);else{let[s,i]=this.#a;s[i](t)}p(this,S.Value,t)}return this}touch(){return this.#l(!0)}mute(){return!this.isDestroyed&&!this.#n&&(this.#n=!0,p(this,S.Mute,this)),this}unmute(){return!this.isDestroyed&&this.#n&&(this.#n=!1,p(this,S.Unmute,this)),this}toggle(){return this.isDestroyed||(this.#n=!this.#n,p(this,this.#n?S.Mute:S.Unmute,this)),this.#n}destroy(){this.isDestroyed||(p(this,S.Destroy,this),E(this),S.#t(this),this.#r?.(),this.#r=void 0,this.#o=void 0,this.#a=void 0,this.#c!=null&&(S.#i(this.#c,this),this.#c=void 0))}get isDestroyed(){return this.#r==null}hasTarget(e){return this.#c===e}};S=ge;function re(r,e){let t=Array.isArray(r)?T(...r):r,s=Array.isArray(e),i=s?T(...e)??e:e,n=s?e[0]:e;return new ge(t,i,n)}var M;(function(r){r[r.StructuralChanges=1]="StructuralChanges",r[r.ContentUpdates=2]="ContentUpdates",r[r.Removal=3]="Removal"})(M||(M={}));var m;(function(r){r[r.CreateEntities=1]="CreateEntities",r[r.DestroyEntities=2]="DestroyEntities",r[r.SetParent=3]="SetParent",r[r.UpdateOrder=4]="UpdateOrder",r[r.ChangeProperties=5]="ChangeProperties",r[r.ChangeToken=6]="ChangeToken",r[r.SendEvents=7]="SendEvents"})(m||(m={}));var ie=Symbol.for("ShadowEntsGlobalNS"),I="#void",qt="contextLost",Gt="configure",Ht="changeTrail",Qt="destroy",Kt="loaded",Yt="appliedChangeTrail",Jt="importedModule",Xt="destroyed",ce="messageToView",Zt=16e3,es=16e3,ts=4e3,ss=1e3,mt="shadowObjects";function rs(r,e){r.indexOf(e)===-1&&r.push(e)}function gt(r,e){let t=r.indexOf(e);t!==-1&&r.splice(t,1),r.push(e)}function H(r,e){let t=r.indexOf(e);t!==-1&&r.splice(t,1)}var ne=r=>typeof r=="string"?r.trim()||ie:typeof r=="symbol"?r:ie;var ve=class{#e;get uuid(){return this.#e}#t=0;constructor(e){this.#e=e}#s=!0;#i=0;#r=0;hasChanges(){return this.#t>0}get isNew(){return this.#s}get isCreated(){return this.#i>0&&this.#i>this.#r}get isDestroyed(){return this.#r>0&&this.#r>=this.#i}#n=I;#o;#a=0;#h;#c;#l;create(e=I,t,s=0){this.#t++,this.#i++,this.#h=e,this.#c=t,this.#l=s||void 0}destroy(){this.#r++,this.#t++}clear(){this.#t=0,this.#s=!1,this.#h=void 0,this.#c=void 0,this.#l=void 0,this.#f.clear(),this.#y.length=0,this.#p.length=0,this.#d.clear()}changeToken(e){e===this.#n?this.#h=void 0:(this.#h=e,this.#t++)}setParent(e){e===this.#o?this.#c=void 0:(this.#c=e??null,this.#t++)}changeOrder(e){e===this.#a?this.#l=void 0:(this.#l=e,this.#t++)}#u=new Map;#f=new Map;#y=[];changeProperty(e,t,s){let i=this.#u.get(e);s==null&&t!==i||s!=null&&!s(t,i)?(this.#f.set(e,t),gt(this.#y,e),this.#t++):(this.#f.delete(e),H(this.#y,e))}removeProperty(e){let t=this.#u.has(e);this.#f.has(e)?(this.#f.delete(e),t||H(this.#y,e)):t&&(gt(this.#y,e),this.#t++)}#p=[];#d=new Set;createEvent(e,t,s){this.#p.push({type:e,data:t}),s?.forEach(i=>this.#d.add(i)),this.#t++}transferEventsTo(e){this.#p.length>0&&(e.#p.push(...this.#p),this.#p.length=0),this.#d.size>0&&(e.#d=new Set([...e.#d,...this.#d]),this.#d.clear())}buildChangeTrail(e,t){let{isNew:s,isCreated:i,isDestroyed:n}=this;if(!(s&&n))switch(t){case M.StructuralChanges:s?e.push(this.makeCreateEntityChange()):n||(this.#c!==void 0&&this.#c!==this.#o?e.push(this.makeSetParentChange()):this.#l!==void 0&&this.#l!==this.#a&&e.push(this.makeUpdateOrderChange()),this.#h!==void 0&&this.#h!==this.#n&&e.push(this.makeChangeToken()));break;case M.ContentUpdates:!s&&i&&this.#y.length>0&&e.push(this.makeChangePropertyChange()),this.#p.length>0&&e.push(this.makeEvents());break;case M.Removal:n&&e.push(this.makeDestroyEntityChange());break}}makeEvents(){let e={type:m.SendEvents,uuid:this.#e,events:this.#p.slice(0)};return this.#d.size>0&&(e.transferables=Array.from(this.#d)),e}makeCreateEntityChange(){let e={type:m.CreateEntities,uuid:this.#e,token:this.#h};return this.#n=this.#h,this.#c!==void 0&&(e.parentUuid=this.#o=this.#c),this.#f.size>0&&(e.properties=Array.from(this.#f.entries()).filter(([,t])=>t!==void 0),e.properties.forEach(([t,s])=>this.#u.set(t,s))),this.#l!==void 0&&this.#l!==this.#a&&(e.order=this.#a=this.#l),e}makeDestroyEntityChange(){return{type:m.DestroyEntities,uuid:this.#e}}makeSetParentChange(){this.#o=this.#c??void 0;let e={type:m.SetParent,uuid:this.#e,parentUuid:this.#o};return this.#l!==void 0&&this.#l!==this.#a&&(e.order=this.#a=this.#l),e}makeUpdateOrderChange(){return this.#a=this.#l??0,{type:m.UpdateOrder,uuid:this.#e,order:this.#a}}makeChangeToken(){return this.#n=this.#h??I,{type:m.ChangeToken,uuid:this.#e,token:this.#n}}makeChangePropertyChange(){let e=this.#y.map(t=>{if(this.#f.has(t)){let s=this.#f.get(t);return this.#u.set(t,s),[t,s]}else return this.#u.delete(t),[t,void 0]});return{type:m.ChangeProperties,uuid:this.#e,properties:e}}};var is=r=>{if(!(r===void 0||r.length===0))return r.filter(e=>e.length===1||e[1]!==void 0)},vt=(r,e)=>{if(r===e||e===void 0)return r;if(r===void 0)return is(e);for(let[t,s]of e){let i=r.find(([n])=>n===t);i===void 0?r.push([t,s]):i[1]=s}return is(r)};var Fe=class{#e=new Map;get[Symbol.iterator](){return this.#e.entries.bind(this.#e)}clear(){this.#e.clear()}isEmpty(){return this.#e.size===0}hasComponentState(e){return this.#e.has(e)}getComponentState(e){return this.#e.get(e)}write(e){for(let t of e)if(t.type===m.CreateEntities)this.createEntity(t);else if(this.#e.has(t.uuid))switch(t.type){case m.DestroyEntities:this.destroyEntity(t);break;case m.SetParent:this.setParent(t);break;case m.UpdateOrder:this.updateOrder(t);break;case m.ChangeToken:this.changeToken(t);break;case m.ChangeProperties:this.changeProperties(t);break}}changeProperties({uuid:e,properties:t}){let s=this.getComponentState(e);s.properties=vt(s.properties,t)}changeToken({uuid:e,token:t}){this.getComponentState(e).token=t||I}updateOrder({uuid:e,order:t}){this.getComponentState(e).order=t??0}setParent({uuid:e,parentUuid:t,order:s}){let i=this.getComponentState(e);i.parentUuid=t,i.order=s??0}destroyEntity({uuid:e}){this.#e.delete(e)}createEntity({uuid:e,token:t,parentUuid:s,order:i,properties:n}){this.#e.set(e,{token:t||I,parentUuid:s,order:i??0,properties:vt(void 0,n)})}};var j=class r{static getContextsMap(){return globalThis.__shadowEntsContexts==null&&(globalThis.__shadowEntsContexts=new Map),globalThis.__shadowEntsContexts}static get(e){let t=ne(e),s=r.getContextsMap();return s.has(t)?s.get(t):new r(t)}#e=new Map;#t=[];#s=new Fe;constructor(e=ie){let t=ne(e),s=r.getContextsMap();if(s.has(t))return s.get(t);this.ns=t,s.set(t,this)}addComponent(e){let t;this.#e.has(e.uuid)?(t=this.#e.get(e.uuid),t.component=e,t.children=[]):(t={component:e,children:[],changes:new ve(e.uuid),propIsEqual:void 0},this.#e.set(e.uuid,t)),t.changes.create(e.token,e.parent?.uuid,e.order),e.parent?(this.addToChildren(e.parent,e),t.changes.setParent(e.parent.uuid)):this.#n(e,this.#t),this.#o=void 0}hasComponent(e){return this.#e.has(e.uuid)}hasComponents(){return this.#e.size>0}isRootComponent(e){return this.#t.includes(e.uuid)}destroyComponent(e){if(this.hasComponent(e)){let t=this.#e.get(e.uuid);t.children.slice(0).forEach(s=>this.#e.get(s)?.component.removeFromParent()),t.changes.destroy(),this.#o=void 0}}getChildren(e){return this.#e.get(e.uuid)?.children.map(t=>this.#e.get(t).component)??[]}removeFromParent(e,t){if(this.hasComponent(t)){let s=this.#e.get(e),i=this.#e.get(t.uuid),n=i.children.indexOf(e);n!==-1&&(i.children.splice(n,1),s.changes.setParent(void 0)),this.#n(s.component,this.#t),this.#o=void 0}}changeToken(e,t){this.#e.get(e.uuid)?.changes.changeToken(t)}isChildOf(e,t){return this.hasComponent(t)?this.#e.get(t.uuid).children.includes(e.uuid):!1}addToChildren(e,t){let s=this.#e.get(e.uuid);if(s)this.#n(t,s.children),this.#e.get(t.uuid)?.changes.setParent(e.uuid),H(this.#t,t.uuid),this.#o=void 0;else throw new Error(`the view component ${e.uuid} cannot have a child added to it because the component do not exist!`)}removeSubTree(e){let t=this.#e.get(e);t&&(t.children.slice(0).forEach(s=>this.removeSubTree(s)),this.destroyComponent(t.component),this.#i(e))}setProperty(e,t,s,i){let n=this.#e.get(e.uuid);return n!=null?(i!=null?(n.propIsEqual??=new Map,n.propIsEqual.set(t,i)):n.propIsEqual?.has(t)&&n.propIsEqual.delete(t),n.changes.changeProperty(t,s,i)):!1}removeProperty(e,t){this.#e.get(e.uuid)?.changes.removeProperty(t)}changeOrder(e){if(e.parent){let t=this.#e.get(e.parent.uuid);H(t.children,e.uuid),this.#n(e,t.children)}else H(this.#t,e.uuid),this.#n(e,this.#t);this.#e.get(e.uuid)?.changes.changeOrder(e.order),this.#o=void 0}traverseLevelOrderBFS(){return this.#a().map(e=>e.component)}dispatchShadowObjectsEvent(e,t,s,i){this.#e.get(e.uuid)?.changes.createEvent(t,s,i)}broadcastEvent(e,t=void 0){for(let s of this.traverseLevelOrderBFS())s.dispatchEvent(e,t,!1)}dispatchMessage(e,t,s=void 0,i=!1){this.#e.get(e)?.component.dispatchEvent(t,s,i)}buildChangeTrails(e=!0){let t=[];if(!this.hasComponents())return t;let s=this.#r();for(let i of s)i.buildChangeTrail(t,M.StructuralChanges);for(let i of s)i.buildChangeTrail(t,M.ContentUpdates);for(let i of s)i.buildChangeTrail(t,M.Removal),(i.isDestroyed||i.isNew&&!i.isCreated)&&this.#i(i.uuid),e&&i.clear();return this.#s.write(t),t}reCreateChanges(){if(!this.#s.isEmpty()){this.buildChangeTrails(!1);for(let[e,t]of this.#s){let s=this.#e.get(e);if(s){let i=new ve(e);if(i.create(t.token,t.parentUuid,t.order),t.properties)for(let[n,o]of t.properties)i.changeProperty(n,o,s.propIsEqual?.get(n));s.changes.transferEventsTo(i),s.changes.clear(),s.changes=i}}this.#s.clear(),this.broadcastEvent(qt)}}clear(){if(this.#o=void 0,this.#s.clear(),this.#t.slice(0).forEach(e=>this.removeSubTree(e)),this.#t.length!==0)throw new Error("component-context panic: #rootComponents is not empty!");if(this.#e.size!==0)throw new Error("component-context panic: #components is not empty!")}#i(e){this.#e.has(e)&&(this.#e.delete(e),H(this.#t,e),this.#o=void 0)}#r(){return this.#a().filter(e=>e.changes.hasChanges()).map(e=>e.changes)}#n(e,t){if(t.length===0){t.push(e.uuid);return}if(t.includes(e.uuid))return;let s=t.length,i=new Array(s);if(i[0]=this.#e.get(t[0]).component,e.order<i[0].order){t.unshift(e.uuid);return}if(s===1){t.push(e.uuid);return}let n=s-1;if(i[n]=this.#e.get(t[n]).component,e.order>=i[n].order){t.push(e.uuid);return}if(s===2){t.splice(1,0,e.uuid);return}for(let o=n-1;o>=1;o--)if(i[o]=this.#e.get(t[o]).component,e.order>=i[o].order){t.splice(o+1,0,e.uuid);return}}#o;#a(){if(this.#o)return this.#o;let e=new Map,t=(s,i)=>{let n=this.#e.get(s);if(n!=null){e.has(i)?e.get(i).push(n):e.set(i,[n]);for(let o of n.children)t(o,i+1)}};return this.#t.forEach(s=>t(s,0)),this.#o=Array.from(e.entries()).sort((s,i)=>s[0]-i[0]).map(([,s])=>s).flat(),this.#o}};function Q(r,e,t,s,i,n){function o(fe){if(fe!==void 0&&typeof fe!="function")throw new TypeError("Function expected");return fe}for(var a=s.kind,h=a==="getter"?"get":a==="setter"?"set":"value",l=!e&&r?s.static?r:r.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),d,v=!1,oe=t.length-1;oe>=0;oe--){var c={};for(var f in s)c[f]=f==="access"?{}:s[f];for(var f in s.access)c.access[f]=s.access[f];c.addInitializer=function(fe){if(v)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(fe||null))};var w=(0,t[oe])(a==="accessor"?{get:u.get,set:u.set}:u[h],c);if(a==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(d=o(w.get))&&(u.get=d),(d=o(w.set))&&(u.set=d),(d=o(w.init))&&i.unshift(d)}else(d=o(w))&&(a==="field"?i.unshift(d):u[h]=d)}l&&Object.defineProperty(l,s.name,u),v=!0}function A(r,e,t){for(var s=arguments.length>2,i=0;i<e.length;i++)t=s?e[i].call(r,t):e[i].call(r);return s?t:void 0}var ns=r=>{if(typeof r=="symbol")return r;let e=r.indexOf("$");return e>=0?r.slice(0,e):r};function be(r){return function(e,t){let s=r?.name??ns(t.name),i=!!(r?.readAsValue??!1);return{get(){let n=T(this,s);if(n)return i?W(n):n()},set(n){C(T(this,s))?.writer(n)},init(n){let[o,a]=y(void 0,r);return Wt(this,s,o),a(n),W(o)}}}}function we(r){return function(e,t){let s=r?.name??ns(t.name);return{get(){return T(this,s)}}}}var L=(()=>{var r;let e,t=[],s=[],i,n=[],o=[],a,h=[],l=[],u,d=[],v=[];return class z{static{let c=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;e=[be()],i=[we()],a=[be()],u=[we()],Q(this,null,e,{kind:"accessor",name:"viewReady",static:!1,private:!1,access:{has:f=>"viewReady"in f,get:f=>f.viewReady,set:(f,w)=>{f.viewReady=w}},metadata:c},t,s),Q(this,null,i,{kind:"accessor",name:"viewReady$",static:!1,private:!1,access:{has:f=>"viewReady$"in f,get:f=>f.viewReady$,set:(f,w)=>{f.viewReady$=w}},metadata:c},n,o),Q(this,null,a,{kind:"accessor",name:"proxyReady",static:!1,private:!1,access:{has:f=>"proxyReady"in f,get:f=>f.proxyReady,set:(f,w)=>{f.proxyReady=w}},metadata:c},h,l),Q(this,null,u,{kind:"accessor",name:"proxyReady$",static:!1,private:!1,access:{has:f=>"proxyReady$"in f,get:f=>f.proxyReady$,set:(f,w)=>{f.proxyReady$=w}},metadata:c},d,v),c&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:c})}static{this.AfterSync="afterSync"}static{this.ContextLost="contextLost"}static{this.ContextCreated="contextCreated"}static get(c){if(c!=null)return globalThis.__shadowEnvs?.get(c)}#e;#t;#s;#i;#r;#n;#o;get viewReady(){return this.#o}set viewReady(c){this.#o=c}#a;get viewReady$(){return this.#a}set viewReady$(c){this.#a=c}#h;get proxyReady(){return this.#h}set proxyReady(c){this.#h=c}#c;get proxyReady$(){return this.#c}set proxyReady$(c){this.#c=c}constructor(){this.#s=!1,this.#i=!1,this.#r=!1,this.ns$=y(),this.#o=A(this,t,!1),this.#a=(A(this,s),A(this,n,void 0)),this.#h=(A(this,o),A(this,h,!1)),this.#c=(A(this,l),A(this,d,void 0)),this.ready=(A(this,v),()=>this.isReady?Promise.resolve(this):ae(this,z.ContextCreated)),this.#l=()=>{this.#s&&this.#u()},N(this,z.ContextCreated),g(this,z.ContextLost,pe.AAA,()=>{ye(this,z.ContextCreated)}),b(()=>{if(this.viewReady&&this.proxyReady)return this.view.reCreateChanges(),p(this,z.ContextCreated,this),this.#i&&(this.#i=!1,this.#u()),()=>{p(this,z.ContextLost,this)}},[this.viewReady$,this.proxyReady$])}get view(){return this.#e}set view(c){c!==this.#e&&(this.#e&&this.#e.ns&&globalThis.__shadowEnvs&&globalThis.__shadowEnvs.delete(this.#e.ns),this.#e=c??void 0,this.#e&&this.#e.ns&&(globalThis.__shadowEnvs??=new Map,globalThis.__shadowEnvs.has(this.#e.ns)&&globalThis.__shadowEnvs.get(this.#e.ns)!==this&&console.warn("ShadowEnv: overwrite a namespace already in use",this.#e.ns,globalThis.__shadowEnvs.get(this.#e.ns)),globalThis.__shadowEnvs.set(this.#e.ns,this)),this.viewReady=!!c)}get envProxy(){return this.#t}set envProxy(c){if(c!==this.#t){let f=this.#t;this.#t=c??void 0,this.#t&&(this.#t.onMessageToView=this.#f.bind(this)),f&&f.destroy(),this.proxyReady=!1,c?.start().then(()=>{this.proxyReady=!0}).catch(w=>{console.error("ShadowEnv: failed to start envProxy",w),this.proxyReady=!1})}}get isReady(){return!!(this.#e&&this.#t&&this.proxyReady)}sync(){if(!this.isReady){this.#i=!0;return}this.#s||(this.#s=!0,queueMicrotask(this.#l))}syncWait(){return this.#r=!0,this.sync(),this.#n?this.#n:(this.#n=ae(this,z.AfterSync).then(c=>(this.#n=void 0,c)),this.#n)}destroy(){let c=this.#e?.ns;this.envProxy?.destroy(),this.envProxy=void 0,this.view=void 0,c&&globalThis.__shadowEnvs.has(c)&&globalThis.__shadowEnvs.get(c)===this&&globalThis.__shadowEnvs.delete(c)}#l;async#u(){if(this.#s=!1,this.isReady){let c=this.view.buildChangeTrails();if(c.length>0)try{let f=this.#r;this.#r=!1,await this.envProxy.applyChangeTrail(c,f)}catch(f){console.error("ShadowEnv: failed to apply change trail",f)}finally{p(this,z.AfterSync,c)}}}#f(c){console.debug("ShadowEnv: onMessageToView",c.type,c.data),this.view?.dispatchMessage(c.uuid,c.type,c.data,c.traverseChildren)}}})();var x=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],$s=()=>{let r=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(x[r&255]+x[r>>8&255]+x[r>>16&255]+x[r>>24&255]+"-"+x[e&255]+x[e>>8&255]+"-"+x[e>>16&15|64]+x[e>>24&255]+"-"+x[t&63|128]+x[t>>8&255]+"-"+x[t>>16&255]+x[t>>24&255]+x[s&255]+x[s>>8&255]+x[s>>16&255]+x[s>>24&255]).toLowerCase()},os=()=>globalThis?.crypto?.randomUUID?.()??$s();var Ee=class extends Error{constructor(e){super(e),this.name="ViewComponentError"}},$e=class r{#e;#t;#s;#i;#r=0;get uuid(){return this.#e}get token(){return this.#t}set token(e){e??=I,e!==this.#t&&(this.#t=e,this.#s?.changeToken(this,e))}get parent(){return this.#i}set parent(e){if(e){if(e.#s!==this.#s)throw new Ee("cannot set parent from different context");e.addChild(this)}else this.removeFromParent()}get context(){return this.#s}set context(e){this.#s!=e&&(this.#s&&this.destroy(),this.#s=e,e&&e.addComponent(this))}get order(){return this.#r}set order(e){let t=this.#r;this.#r=e??0,t!==this.#r&&this.#s.changeOrder(this)}constructor(e,t){k(this),t instanceof r&&(t={parent:t}),this.#e=t?.uuid??os(),this.#t=e,this.#r=t?.order??0,this.#i=t?.parent;let s=t?.context??j.get();if(this.#i&&this.#i.#s!==s)throw new Ee("cannot set parent from different context");this.context=s}isChildOf(e){return this.#i===e}removeFromParent(){this.#i&&(this.#s?.removeFromParent(this.uuid,this.#i),this.#i=void 0)}addChild(e){if(e.#s!==this.#s)throw new Ee("cannot add a child from another context");e.isChildOf(this)||(e.removeFromParent(),e.#i=this,this.#s.addToChildren(this,e))}setProperty(e,t,s){this.#s.setProperty(this,e,t,s)}removeProperty(e){this.#s.removeProperty(this,e)}dispatchShadowObjectsEvent(e,t,s){this.#s.dispatchShadowObjectsEvent(this,e,t,s)}dispatchEvent(e,t,s){if(p(this,e,t),s)for(let i of this.#s.getChildren(this))i.dispatchEvent(e,t,s)}destroy(){this.removeFromParent(),this.#s?.destroyComponent(this),this.#s=void 0}};var Ne="shaeRequestEntParent",De="shaeReRequestEntParent",as="shae-worker",We="shae-ent",hs="shae-prop",K="token",Y="ns",Ie="local",ls="no-autostart",ze="no-structured-clone",F="auto-sync",Ue="src",Ve="name",Be="value",qe="type",Ge="no-trim";var Ce=new Set(["on","true","yes","local","1"]);var cs=r=>ne(r.getAttribute(Y)),Se=(r,e)=>{if(r.hasAttribute(e)){let t=r.getAttribute(e)?.trim()?.toLowerCase()||"1";return Ce.has(t)}return!1};var J=class extends HTMLElement{static{this.observedAttributes=[Y]}get ns(){return this.ns$.value}set ns(e){typeof e=="symbol"?this.ns$.set(e):this.ns$.set(ne(e))}constructor(){super(),this.isShaeElement=!0,this.ns$=y(ie),this.#e=!1,this.ns$.onChange(e=>{typeof e=="string"&&e.length>0?this.getAttribute(Y)!==e&&this.setAttribute(Y,e):this.removeAttribute(Y)})}connectedCallback(){this.#t()}attributeChangedCallback(e){e===Y&&this.#t()}#e;syncShadowObjects(){this.#e||(this.#e=!0,queueMicrotask(()=>{this.#e=!1,L.get(this.ns)?.sync()}))}#t(){this.ns$.set(cs(this))}};var He=class extends J{static{this.observedAttributes=[...J.observedAttributes,K]}get componentContext(){return this.componentContext$.value}get viewComponent(){return this.viewComponent$.value}get uuid(){return this.viewComponent?.uuid}get token(){return this.token$.value}set token(e){this.token$.set(e)}constructor(){super(),this.isShaeEntElement=!0,this.componentContext$=y(),this.viewComponent$=y(),this.token$=y(),this.#r=!0,this.#c=()=>{let e=this.findShadowRootHost();e!=null&&this.dispatchEvent(new CustomEvent(De,{bubbles:!0,composed:!0,detail:{requester:this,shadowRootHost:e}}))},this.#l=e=>{let t=e.detail?.requester;if(t===this||!t?.isShaeEntElement||t.ns!==this.ns)return;let s=e.detail?.shadowRootHost;s&&this.#a?.has(s)&&this.#n()},this.#u=e=>{let t=e.detail?.requester;t!==this&&t?.isShaeEntElement&&t.ns===this.ns&&(e.stopPropagation(),t.#h(this))},this.#f(),this.token$.onChange(e=>{e==null?this.removeAttribute(K):this.getAttribute(K)!==e&&this.setAttribute(K,e)}),this.ns$.onChange(e=>{this.componentContext$.set(j.get(e)),this.isConnected&&this.#n()}),b(()=>{let e=this.viewComponent$.get();if(e){let t=e.context?.ns;return()=>{e.destroy(),t&&t!==this.ns?L.get(t)?.sync():this.syncShadowObjects()}}}),this.token$.onChange(e=>{let t=this.viewComponent$.value;t&&(t.token=e,this.syncShadowObjects())})}#e;#t(){this.#e?.();let e=this.componentContext$.onChange(t=>{let s=this.token$.value,i=this.viewComponent$.value;i?i.context=t:t&&(i=new $e(s,{context:t}),this.viewComponent$.set(i)),this.syncShadowObjects()});this.#e=()=>{e()}}#s(){this.#e?.(),this.#e=void 0}#i;#r;findShadowRootHost(){if(this.#r){this.#r=!1;let e=this;for(;e;){if(e.parentElement==null){let t=e.parentNode;t&&(this.#i=t.host);break}e=e.parentElement}}return this.#i}connectedCallback(){this.#r=!0,this.addEventListener("slotchange",this.#c,{capture:!1,passive:!1}),this.addEventListener(Ne,this.#u,{capture:!1,passive:!1}),this.#t(),zt(()=>this.#f()),super.connectedCallback(),this.componentContext==null&&this.componentContext$.set(j.get(this.ns)),this.#n(),this.syncShadowObjects()}attributeChangedCallback(e){super.attributeChangedCallback(e),e===K&&this.#f()}disconnectedCallback(){this.#r=!0,this.removeEventListener("slotchange",this.#c,{capture:!1}),this.removeEventListener(Ne,this.#u,{capture:!1}),this.#h(void 0),this.componentContext$.set(void 0),this.syncShadowObjects(),this.#s()}#n(){this.dispatchEvent(new CustomEvent(Ne,{bubbles:!0,composed:!0,detail:{requester:this}}))}#o;#a;#h(e){if(this.entParentNode!==e){if(this.entParentNode&&this.entParentNode.removeEventListener(De,this.#l,{capture:!1}),this.entParentNode=e,this.entParentNode&&this.entParentNode.addEventListener(De,this.#l,{capture:!1,passive:!1}),this.#a=void 0,e){let t=[],s=this.parentElement;for(;s&&s!==e;)t.push(s),s.parentElement==null&&s.parentNode?s=s.parentNode.host:s=s.parentElement;t.length>0&&(this.#a=new WeakSet(t))}if(this.#o?.(),this.#o=void 0,e){let[,t]=b(()=>{let s=this.viewComponent$.get();if(s){let i=e.viewComponent$.get();s.parent=i&&i.context===s.context?i:void 0,s.parent==null&&queueMicrotask(()=>{this.#n()}),this.syncShadowObjects()}});this.#o=t}else{let t=this.viewComponent;t.parent&&(t.parent=void 0,this.syncShadowObjects())}}}#c;#l;#u;#f(){if(this.hasAttribute(K)){let e=this.getAttribute(K)?.trim()||void 0;this.token$.set(e)}}};customElements.define(We,He);var Ns=r=>{let e=r.parentElement;for(;e;){if(e.isShaeEntElement)return e;e=e.parentElement}},Ds=new Set(["string","text","number","bigint","float","int","integer","hex","hexadecimal","oct","octal","bin","binary","bool","boolean","[]","text[]","string[]","number[]","float[]","int[]","integer[]","hex[]","hexadecimal[]","oct[]","octal[]","bin[]","binary[]","bool[]","boolean[]","int8array","uint8array","uint8clampedarray","int16array","uint16array","int32array","uint32array","float32array","float64array","bigint64array","biguint64array","json"]),Qe=class extends HTMLElement{static{this.observedAttributes=[Ve,Be,qe,Ge]}get name(){return this.name$.value}get value(){return this.valueOut$.value}set value(e){this.valueIn$.set(e)}get shouldTrim(){return this.shouldTrim$.value}get entNode(){return this.entNode$.value}set entNode(e){this.entNode$.set(e)}get viewComponent(){return this.viewComponent$.value}constructor(){super(),this.isShaeEntElement=!0,this.entNode$=y(),this.viewComponent$=y(),this.name$=y(),this.valueIn$=y(),this.valueOut$=y(),this.type$=y(),this.shouldTrim$=y(!0),this.#e=()=>{this.entNode$.set(Ns(this))},this.#t=()=>{queueMicrotask(()=>{this.isConnected||this.entNode$.set(void 0)})},this.#s=()=>{this.name$.set(this.getAttribute(Ve)?.trim()??void 0)},this.#i=()=>{this.valueIn$.set(this.getAttribute(Be))},this.#r=()=>{let e=this.getAttribute(qe)?.trim().toLowerCase();e&&!Ds.has(e)&&(console.warn(`[shae-prop:"${this.name}"] unknown type "${e}"`,{shaeProp:this}),e=void 0),this.type$.set(e)},this.#n=()=>{this.shouldTrim$.set(!Se(this,Ge))},this.entNode$.onChange(e=>{if(e){let t=re(e.viewComponent$,this.viewComponent$);return()=>{t.destroy()}}else this.viewComponent$.set(void 0)}),b(()=>{let e=this.viewComponent$.get();if(e){let t=this.name$.get();if(t){let s=this.valueOut$.get();e.setProperty(t,s),this.isConnected&&this.entNode?.syncShadowObjects()}}}),b(()=>{let e=this.type$.get(),t=this.shouldTrim$.get(),s=this.valueIn$.get();if(t&&typeof s=="string"&&(s=s.trim()),s=s||void 0,s!=null&&typeof s=="string"&&e)switch(e){case"string":case"text":break;case"number":s=Number(s);break;case"bigint":s=BigInt(s);break;case"float":s=parseFloat(s);break;case"int":case"integer":s=parseInt(s,10);break;case"hex":case"hexadecimal":s=parseInt(s,16);break;case"oct":case"octal":s=parseInt(s,8);break;case"bin":case"binary":s=parseInt(s,2);break;case"bool":case"boolean":s=Ce.has(s.toLowerCase());break;case"[]":case"text[]":case"string[]":s=s.split(/\W+/);break;case"number[]":s=s.split(/\W+/).map(i=>Number(i));break;case"float[]":s=s.split(/\W+/).map(i=>parseFloat(i));break;case"int[]":case"integer[]":s=s.split(/\W+/).map(i=>parseInt(i));break;case"hex[]":case"hexadecimal[]":s=s.split(/\W+/).map(i=>parseInt(i,16));break;case"oct[]":case"octal[]":s=s.split(/\W+/).map(i=>parseInt(i,8));break;case"bin[]":case"binary[]":s=s.split(/\W+/).map(i=>parseInt(i,2));break;case"bool[]":case"boolean[]":s=s.split(/\W+/).map(i=>Ce.has(i.toLowerCase()));break;case"int8array":s=new Int8Array(s.split(/\W+/).map(i=>Number(i)));break;case"uint8array":s=new Uint8Array(s.split(/\W+/).map(i=>Number(i)));break;case"uint8clampedarray":s=new Uint8ClampedArray(s.split(/\W+/).map(i=>Number(i)));break;case"int16array":s=new Int16Array(s.split(/\W+/).map(i=>Number(i)));break;case"uint16array":s=new Uint16Array(s.split(/\W+/).map(i=>Number(i)));break;case"int32array":s=new Int32Array(s.split(/\W+/).map(i=>Number(i)));break;case"uint32array":s=new Uint32Array(s.split(/\W+/).map(i=>Number(i)));break;case"float32array":s=new Float32Array(s.split(/\W+/).map(i=>Number(i)));break;case"float64array":s=new Float64Array(s.split(/\W+/).map(i=>Number(i)));break;case"bigint64array":s=new BigInt64Array(s.split(/\W+/).map(i=>BigInt(i)));break;case"biguint64array":s=new BigUint64Array(s.split(/\W+/).map(i=>BigInt(i)));break;case"json":s=JSON.parse(s);break;default:console.warn(`[shae-prop:"${this.name}"] unknown type "${e}"`,{value:s,shaeProp:this})}this.valueOut$.set(s)}),R(()=>{this.#s(),this.#i(),this.#r(),this.#n()})}connectedCallback(){R(()=>{this.#e(),this.#s(),this.#i(),this.#r(),this.#n()})}attributeChangedCallback(e){switch(e){case Ve:this.#s();break;case Be:this.#i();break;case qe:this.#r();break;case Ge:this.#n();break}}disconnectedCallback(){this.#t()}#e;#t;#s;#i;#r;#n};customElements.whenDefined(We).then(()=>customElements.define(hs,Qe));var Ke,bt=null,ue=class{static{this.OnFrame=Symbol("onFrame")}#e=0;#t=0;constructor(){if(bt)return bt;k(this),bt=this}start(e){if(e!=null)return lt(this)===0&&this.#i(),g(this,Ke.OnFrame,e),this.#t++,()=>{this.stop(e)}}stop(e){E(this,Ke.OnFrame,e),lt(this)===0&&this.#r()}#s=e=>{p(this,Ke.OnFrame,e),this.#i()};#i(){this.#e=requestAnimationFrame(this.#s)}#r(){cancelAnimationFrame(this.#e),this.#e=0}};Ke=ue;var Ye=class{#e=new Map;keys(){return this.#e.keys()}entries(){return this.#e.entries()}clear(){for(let e of this.#e.values())e.destroy();this.#e.clear()}hasSignal(e){return this.#e.has(e)}getSignal(e){if(!this.#e.has(e)){let t=y();return this.#e.set(e,t),t}return this.#e.get(e)}getSignalReader(e){return this.getSignal(e).get}getSignalWriter(e){return this.getSignal(e).set}};var Xe=(()=>{let r,e=[],t=[],s,i=[],n=[];return class Je{static{let a=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;r=[be()],s=[we()],Q(this,null,r,{kind:"accessor",name:"value",static:!1,private:!1,access:{has:h=>"value"in h,get:h=>h.value,set:(h,l)=>{h.value=l}},metadata:a},e,t),Q(this,null,s,{kind:"accessor",name:"value$",static:!1,private:!1,access:{has:h=>"value$"in h,get:h=>h.value$,set:(h,l)=>{h.value$=l}},metadata:a},i,n),a&&Object.defineProperty(this,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:a})}static{this.Value="value"}#e=[];#t;#s=A(this,e,void 0);get value(){return this.#s}set value(a){this.#s=a}#i=(A(this,t),A(this,i,void 0));get value$(){return this.#i}set value$(a){this.#i=a}constructor(){A(this,n),N(this,Je.Value),this.value$(a=>p(this,Je.Value,a))}add(...a){for(let h of a)this.#e.push(h);this.#n()}clear(){this.#e.length=0,this.#r()}dispose(){this.clear(),E(this),pt(this),ye(this,Je.Value)}#r(){this.#t?.(),this.#t=void 0}#n(){this.#r();let[a,h]=b(()=>{for(let l of this.#e){let u=W(l);if(u!=null){this.value=u;return}}this.value=void 0},this.#e);this.#t=h,a()}}})();var wt="onCreate",X="onDestroy",us="onViewEvent";var Ze=class{#e;#t;#s=new Ye;#i=new Map;#r;#n;#o=new Set;#a=[];#h=0;get kernel(){return this.#e}get uuid(){return this.#t}get order(){return this.#h}set order(e){this.#h!==e&&(this.#h=e,this.#r&&this.parent.resortChildren())}get parentUuid(){return this.#r||void 0}set parentUuid(e){this.#r!==e&&(this.removeFromParent(),this.#r=e||void 0,this.#n=e?this.#e.getEntity(e):void 0,this.#n&&this.#n.addChild(this))}get parent(){return!this.#n&&this.#r&&(this.#n=this.#e.getEntity(this.#r)),this.#n}set parent(e){this.parentUuid=e?.uuid}get hasParent(){return!!this.#r}get children(){return this.#a}constructor(e,t){this.#e=e,this.#t=t,P(this,X,pe.Min,this)}traverse(e){e(this);for(let t of this.#a)t.traverse(e)}onDestroy(){this.#s.clear(),E(this);for(let e of this.#i.values())e.unsubscribeFromPath(),e.unsubscribeFromParent?.(),e.ctxPath.dispose(),dt(e.inherited,e.provide,e.context);this.#r=void 0,this.#n=void 0,this.#o.clear(),this.#a.length=0}addChild(e){if(this.#a.length===0){this.#o.add(e.uuid),this.#a.push(e);return}if(this.#o.has(e.uuid))throw new Error(`child with uuid: ${e.uuid} already exists! parentUuid: ${this.uuid}`);this.#o.add(e.uuid),this.#a.push(e),this.resortChildren();for(let[,t]of e.#i)e.#u(t)}resortChildren(){this.#a.sort((e,t)=>e.order-t.order)}removeChild(e){this.#o.has(e.uuid)&&(this.#o.delete(e.uuid),this.#a.splice(this.#a.indexOf(e),1))}removeFromParent(){if(this.#n){this.#n.removeChild(this),this.#n=void 0,this.#r=void 0;for(let[,e]of this.#i)e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0)}}dispatchMessageToView(e,t,s,i=!1){this.#e.dispatchMessageToView({uuid:this.#t,type:e,data:t,transferables:s,traverseChildren:i})}dispatchViewEvents(e){for(let{type:t,data:s}of e)p(this,us,t,s)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}#c(e){return this.#s.getSignal(e)}getPropertyReader(e){return this.#c(e).get}getPropertyWriter(e){return this.#c(e).set}setProperties(e){R(()=>{for(let[t,s]of e)this.setProperty(t,s)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return W(this.getPropertyReader(e))}propKeys(){return Array.from(this.#s.keys())}propEntries(){return Array.from(this.#s.entries()).map(([e,t])=>[e,t.value])}hasContext(e){return this.#i.has(e)}useContext(e){return this.#l(e).context.get}provideContext(e){return this.#l(e).provide}#l(e){let t=this.#i.get(e);if(t==null){let s=y(),i=y(),n=y(),o=new Xe;o.add(i.get,s.get);let a=g(o,Xe.Value,h=>{queueMicrotask(()=>{n.set(h)})});t={name:e,inherited:s,provide:i,context:n,ctxPath:o,unsubscribeFromPath:a},this.#i.set(e,t),this.#u(t)}return t}#u(e){this.parent&&(e.unsubscribeFromParent?.(),e.unsubscribeFromParent=g(this.parent.#l(e.name).ctxPath,Xe.Value,t=>{e.inherited.set(t)}))}};var xe=class{static get(e){return e??Ws}#e=new Map;#t=new Map;define(e,t){this.#e.has(e)?rs(this.#e.get(e).constructors,t):this.#e.set(e,{token:e,constructors:[t]})}appendRoute(e,t){if(this.#t.has(e)){let s=this.#t.get(e);for(let i of t)s.add(i)}else this.#t.set(e,new Set(t))}clearRoute(e){this.#t.delete(e)}findTokensByRoute(e){let t=new Set([e]),s=this.#t.has(e)?[...this.#t.get(e)]:[];for(;s.length;){let i=s.shift();t.has(i)||(t.add(i),this.#t.has(i)&&s.push(...Array.from(this.#t.get(i)).filter(n=>!t.has(n))))}return Array.from(t)}findConstructors(e){let t=this.findTokensByRoute(e),s=new Set;for(let i of t){let n=this.#e.get(i);if(n)for(let o of n.constructors)s.add(o)}return s.size>0?Array.from(s):void 0}hasToken(e){return this.#e.has(e)}hasRoute(e){return this.#t.has(e)}clear(){this.#e.clear(),this.#t.clear()}},Ws=new xe;var U;(function(r){r[r.CreateAndDestroy=0]="CreateAndDestroy",r[r.JustCreate=1]="JustCreate",r[r.DestroyOnly=2]="DestroyOnly"})(U||(U={}));var fs=r=>r.displayName||r.name,et=class{#e=new Map;#t=new Set;#s;#i;#r=!0;constructor(e){k(this),this.registry=xe.get(e)}getEntity(e){let t=this.#e.get(e)?.entity;if(!t)throw new Error(`entity with uuid "${e}" not found!`);return t}hasEntity(e){return this.#e.has(e)}traverseLevelOrderBFS(e=!1){if(this.#r){let t=new Map,s=(i,n)=>{let o=this.getEntity(i);t.has(n)?t.get(n).push(o):t.set(n,[o]);for(let a of o.children)s(a.uuid,n+1)};this.#t.forEach(i=>s(i,0)),this.#s=Array.from(t.entries()).sort((i,n)=>i[0]-n[0]).map(([,i])=>i).flat(),this.#i=this.#s.slice().reverse(),this.#r=!1}return e?this.#i:this.#s}getEntityGraph(){return Array.from(this.#t).map(e=>this.getEntityGraphNode(e))}getEntityGraphNode(e){if(!this.#e.has(e))return;let{token:t,entity:s}=this.#e.get(e);return{token:t,entity:s,props:Object.fromEntries(s.propEntries()),children:s.children.map(i=>this.getEntityGraphNode(i.uuid))}}upgradeEntities(){for(let e of this.traverseLevelOrderBFS(!0))this.updateShadowObjects(e.uuid,U.DestroyOnly);for(let e of this.traverseLevelOrderBFS(!1))this.updateShadowObjects(e.uuid,U.JustCreate)}run(e){R(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case m.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties),this.#r=!0;break;case m.DestroyEntities:this.destroyEntity(e.uuid),this.#r=!0;break;case m.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),this.#r=!0;break;case m.UpdateOrder:this.updateOrder(e.uuid,e.order),this.#r=!0;break;case m.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case m.ChangeToken:this.changeToken(e.uuid,e.token);break;case m.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,s,i=0,n){let o=new Ze(this,e);o.order=i;let a={token:t,entity:o,usedConstructors:new Map};this.#e.set(e,a),s&&(o.parentUuid=s),o.hasParent||this.#t.add(e),n&&o.setProperties(n),this.createShadowObjects(e)}destroyEntity(e){if(!this.#e.has(e))return;let{entity:t,usedConstructors:s}=this.#e.get(e);t.removeFromParent(),p(t,X,this),s.clear(),this.#e.delete(t.uuid),this.#t.delete(t.uuid)}setParent(e,t,s=0){let i=this.getEntity(e);i.parentUuid===t&&i.order===s||(i.removeFromParent(),i.order=s,i.parentUuid=t,i.hasParent?this.#t.delete(e):this.#t.add(e))}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){this.getEntity(e)?.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t)}changeToken(e,t){if(!this.#e.has(e))return;let s=this.#e.get(e);s.token!==t&&(s.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{p(this,ce,e)})}updateShadowObjects(e,t=U.CreateAndDestroy){let s=this.#e.get(e),i=new Set(this.registry.findConstructors(s.token)),n=t===U.CreateAndDestroy||t===U.DestroyOnly,o=t===U.CreateAndDestroy||t===U.JustCreate;if(n){for(let[a,h]of s.usedConstructors)if(!i.has(a)){s.usedConstructors.delete(a);for(let l of h)this.destroyShadowObject(l,s.entity)}}if(o)for(let a of i)s.usedConstructors.has(a)||this.constructShadowObject(a,s)}constructShadowObject(e,t){let s=new Set,i=new Set,n=new Map,o=new Map,a=new Map,h=k(new e({entity:t.entity,provideContext(l,u,d){let v=o.get(l);if(v===void 0){v=y(u,d?{compareFn:d}:void 0),o.set(l,v);let oe=re(v,t.entity.provideContext(l));i.add(oe.destroy.bind(oe))}return v},useContext(l,u){let d=n.get(l);if(d===void 0){[d]=y(void 0,u?{compareFn:u}:void 0),n.set(l,d);let v=re(t.entity.useContext(l),d);i.add(v.destroy.bind(v))}return d},useProperty(l,u){let d=a.get(l);if(d===void 0){[d]=y(void 0,u?{compareFn:u}:void 0),a.set(l,d);let v=re(t.entity.getPropertyReader(l),d);i.add(v.destroy.bind(v))}return d},createEffect(...l){let u=b(...l);return i.add(u[1]),u},createSignal(...l){let u=y(...l);return i.add(()=>{_(u)}),u},on(...l){let u=g(...l);return i.add(u),u},onDestroy(l){s.add(l)}}));return console.debug("[Kernel] create shadow-object",fs(e),{shadowObject:h,entity:t.entity}),P(h,X,()=>{console.debug("[Kernel] destroy shadow-object",fs(e),{shadowObject:h,entity:t.entity});for(let u of s)u();for(let u of i)u();for(let u of n.values())_(u);for(let u of a.values())_(u);for(let[u]of o.values())_(u);s.clear(),i.clear(),n.clear(),a.clear(),o.clear();let l=t.usedConstructors.get(e);l&&(l.delete(h),l.size===0&&t.usedConstructors.delete(e))}),t.usedConstructors.has(e)?t.usedConstructors.get(e).add(h):t.usedConstructors.set(e,new Set([h])),this.attachShadowObject(h,t.entity),h}createShadowObjects(e){let t=this.#e.get(e);this.registry.findConstructors(t.token)?.forEach(s=>{this.constructShadowObject(s,t)})}findShadowObjects(e){if(!this.#e.has(e))return[];let{usedConstructors:t}=this.#e.get(e);return Array.from(new Set(Array.from(t.values()).map(s=>Array.from(s)).flat()))}attachShadowObject(e,t){g(t,e),typeof e[wt]=="function"&&e[wt](t)}destroyShadowObject(e,t){typeof e[X]=="function"&&e[X](t),p(e,X,t),E(t,e)}destroy(){for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}};async function Et(r,e,t,s=!0){if(t.has(e)){console.warn("importModule: skipping already imported module",e);return}else t.add(e);e.extends&&await Promise.all(e.extends.map(n=>Et(r,n,t,!1)));let{registry:i}=r;if(e.define)for(let[n,o]of Object.entries(e.define))i.define(n,o);if(e.routes)for(let[n,o]of Object.entries(e.routes))i.appendRoute(n,o);await(e.initialize?.({define:(n,o)=>i.define(n,o),kernel:r,registry:i})??Promise.resolve()),s&&r.upgradeEntities()}var tt=r=>(typeof r=="string"&&(r=new URL(r,globalThis.location.href)),r.toString());function ds(r){return r.map(e=>{if(e.transferables&&e.transferables.length>0){let{transferables:t,...s}=e;return structuredClone(s,{transfer:t})}else return structuredClone(e)})}var st=class{#e;get registry(){return this.kernel.registry}constructor(e){this.#e=new Set,this.isLocalEnv=!0,this.disableStructuredClone=!1,this.kernel=new et(e),g(this.kernel,ce,t=>{if(this.onMessageToView!=null){let{type:s,uuid:i,traverseChildren:n}=t,o=structuredClone(t.data,{transfer:t.transferables});this.onMessageToView({type:s,uuid:i,data:o,traverseChildren:n})}})}start(){return Promise.resolve()}applyChangeTrail(e,t){let s={changeTrail:this.disableStructuredClone?e:ds(e)},i;try{this.kernel.run(s),i=Promise.resolve()}catch(n){i=Promise.reject(n)}return i}async importScript(e){let t=await import(tt(e));t[mt]&&await this.importModule(t[mt])}async importModule(e){return Et(this.kernel,e,this.#e)}destroy(){this.kernel.destroy(),this.registry.clear(),this.#e.clear()}};function Ct(r){let e=new Blob([r],{type:"text/javascript"}),t=URL.createObjectURL(e),s=new Worker(t);return URL.revokeObjectURL(t),s}function St(){return Ct(`var is=Object.defineProperty;var ht=Object.getOwnPropertySymbols;var rs=Object.prototype.hasOwnProperty,ns=Object.prototype.propertyIsEnumerable;var lt=e=>{throw TypeError(e)};var as=(e,t,s)=>t in e?is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var ut=(e,t)=>{var s={};for(var i in e)rs.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(e!=null&&ht)for(var i of ht(e))t.indexOf(i)<0&&ns.call(e,i)&&(s[i]=e[i]);return s};var f=(e,t,s)=>as(e,typeof t!="symbol"?t+"":t,s),$e=(e,t,s)=>t.has(e)||lt("Cannot "+s);var r=(e,t,s)=>($e(e,t,"read from private field"),s?s.call(e):t.get(e)),c=(e,t,s)=>t.has(e)?lt("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),u=(e,t,s,i)=>($e(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),m=(e,t,s)=>($e(e,t,"access private method"),s);var dt=(e,t,s,i)=>({set _(n){u(e,t,n,s)},get _(){return r(e,t,i)}});var ct;(function(e){e[e.StructuralChanges=1]="StructuralChanges",e[e.ContentUpdates=2]="ContentUpdates",e[e.Removal=3]="Removal"})(ct||(ct={}));var U;(function(e){e[e.CreateEntities=1]="CreateEntities",e[e.DestroyEntities=2]="DestroyEntities",e[e.SetParent=3]="SetParent",e[e.UpdateOrder=4]="UpdateOrder",e[e.ChangeProperties=5]="ChangeProperties",e[e.ChangeToken=6]="ChangeToken",e[e.SendEvents=7]="SendEvents"})(U||(U={}));var ri=Symbol.for("ShadowEntsGlobalNS"),os="configure",hs="changeTrail",ls="destroy",us="loaded",ft="appliedChangeTrail",Ge="importedModule",ds="destroyed",He="messageToView",We="shadowObjects",de="*",Rt=1,rt=2,nt=4,se=Symbol("eventize"),cs="[eventize]",Ue=e=>e===de,Tt=e=>{switch(typeof e){case"string":case"symbol":return!0;default:return!1}},Dt=typeof console<"u",fs=Dt?console[console.warn?"warn":"log"].bind(console,cs):()=>{},ys=(e,t,s)=>(Object.defineProperty(e,t,{value:s,configurable:!0}),e),ps=0,Lt=class{constructor(){f(this,"events",new Map);f(this,"eventNames",new Set)}static publish(e){e.sort((t,s)=>t.order-s.order).forEach(t=>t.emit())}add(e){Array.isArray(e)?e.forEach(t=>this.eventNames.add(t)):this.eventNames.add(e)}remove(e){Array.isArray(e)?e.forEach(t=>this.eventNames.delete(t)):this.eventNames.delete(e),this.clear(e)}clear(e){Array.isArray(e)?e.forEach(t=>this.events.delete(t)):this.events.delete(e)}retain(e,t){this.eventNames.has(e)&&this.events.set(e,{args:t,order:ps++})}isKnown(e){return this.eventNames.has(e)}emit(e,t,s=[]){if(Ue(e))this.eventNames.forEach(i=>this.emit(i,t,s));else if(this.events.has(e)){let{order:i,args:n}=this.events.get(e);s.push({order:i,emit:()=>t.apply(e,n)})}return s}},Qe=(e,t,s,i)=>{if(typeof t=="function"){let n=t.apply(e,s);n!=null&&(i==null||i(n))}},vs=(e,t,s,i)=>Qe(t,t.emit,[e].concat(s),i),gs=e=>{switch(typeof e){case"function":return Rt;case"string":case"symbol":return rt;case"object":return nt}},ms=0,bs=()=>++ms,xt=class{constructor(e,t,s,i=null){f(this,"id");f(this,"eventName");f(this,"isCatchEmAll");f(this,"priority");f(this,"listener");f(this,"listenerObject");f(this,"listenerType");f(this,"callAfterApply");f(this,"isRemoved");f(this,"refCount");this.id=bs(),this.eventName=e,this.isCatchEmAll=Ue(e),this.listener=s,this.listenerObject=i,this.priority=t,this.listenerType=gs(s),this.callAfterApply=void 0,this.isRemoved=!1,this.refCount=1}isEqual(e,t=null){if(e===this)return!0;let s=typeof e;return s==="number"&&e===this.id?!0:t===null&&(s==="string"||s==="symbol")?e===de||e===this.eventName:this.listener===e&&this.listenerObject===t}apply(e,t,s){if(this.isRemoved)return;let{listener:i,listenerObject:n}=this;switch(this.listenerType){case Rt:Qe(n,i,t,s),this.callAfterApply&&this.callAfterApply();break;case rt:Qe(n,n[i],t,s),this.callAfterApply&&this.callAfterApply();break;case nt:{let o=i[e];if(this.isCatchEmAll||this.eventName===e){if(typeof o=="function"){let a=o.apply(i,t);a!=null&&(s==null||s(a))}else vs(e,i,t,s);this.callAfterApply&&this.callAfterApply()}break}}}},ws=(e,t)=>e.priority!==t.priority?t.priority-e.priority:e.id-t.id,yt=e=>e==null?void 0:e.slice(0),pt=(e,t)=>{let s=e.indexOf(t);s>-1&&e.splice(s,1)},Es=e=>e===nt||e===rt,Xe=(e,t,s)=>{let i=e.findIndex(n=>n.isEqual(t,s));i>-1&&(e[i].isRemoved=!0,e.splice(i,1))},Ne=(e,t,s)=>{let i=[];for(let n of e)(t==null&&n.listenerObject===s||n.eventName===t&&n.listener===s)&&i.push(n);for(let n of i)Xe(e,n,void 0)},Je=e=>{e&&(e.forEach(t=>{t.isRemoved=!0}),e.length=0)},Cs=(e,t)=>e.listenerType===t.listenerType?e.priority===t.priority&&e.eventName===t.eventName&&e.listenerObject===t.listenerObject&&e.listener===t.listener:!1,As=(e,t)=>{if(Es(e.listenerType))return t.find(s=>Cs(e,s))},Ss=(e,t)=>{let s=As(e,t);return s?(s.refCount+=1,s):(t.push(e),t.sort(ws),e)},ks=class{constructor(){f(this,"namedListeners");f(this,"catchEmAllListeners");f(this,"getListenersForEventName",e=>{let t=this.namedListeners.get(e);return t||(t=[],this.namedListeners.set(e,t)),t});this.namedListeners=new Map,this.catchEmAllListeners=[]}add(e){return Ss(e,e.isCatchEmAll?this.catchEmAllListeners:this.getListenersForEventName(e.eventName))}remove(e,t,s=!1){t==null&&Array.isArray(e)?e.forEach(i=>this.remove(i,null,s)):e==null||t==null&&Ue(e)?this.removeAllListeners():t==null&&Tt(e)?Je(this.namedListeners.get(e)):e instanceof xt?e.isRemoved||(e.refCount-=1,e.refCount<1&&(e.isRemoved=!0,this.namedListeners.forEach(i=>pt(i,e)),pt(this.catchEmAllListeners,e))):s?Ue(e)?Ne(this.catchEmAllListeners,de,e):this.namedListeners.forEach(i=>Ne(i,e,t)):(this.namedListeners.forEach(i=>{Xe(i,e,t),Ne(i,void 0,e)}),Xe(this.catchEmAllListeners,e,t),Ne(this.catchEmAllListeners,void 0,e))}removeAllListeners(){this.namedListeners.forEach(e=>Je(e)),this.namedListeners.clear(),Je(this.catchEmAllListeners)}forEach(e,t){let s=yt(this.catchEmAllListeners),i=yt(this.namedListeners.get(e));if(e===de||!i||i.length===0)s.forEach(t);else if(s.length===0)i.forEach(t);else{let n=i.length,o=s.length,a=0,h=0;for(;a<n||h<o;){if(a<n){let l=i[a];if(h>=o||l.priority>=s[h].priority){t(l),++a;continue}}h<o&&(t(s[h]),++h)}}}getSubscriptionCount(){let e=this.catchEmAllListeners.length;for(let t of this.namedListeners.values())e+=t.length;return e}},Ee=e=>!!(e&&e[se]);function Oe(e){if(Ee(e))return e;let t=new ks,s=new Lt;return ys(e,se,{keeper:s,store:t}),e}var Nt={Max:Number.POSITIVE_INFINITY,AAA:1e9,BB:1e6,C:1e3,Default:0,Low:-1e4,Min:Number.NEGATIVE_INFINITY},Os=(e,t,s,i,n,o,a)=>{let h=e.add(new xt(s,i,n,o));return t.emit(s,h,a),h},Ps=(e,t,s,i)=>{let n=s.length,o=typeof s[0],a,h,l,d;if(n>=2&&n<=3&&o==="number"?(a=de,[h,l,d]=s):n>=3&&n<=4&&typeof s[1]=="number"?[a,h,l,d]=s:(h=Nt.Default,o==="string"||o==="symbol"||Array.isArray(s[0])?[a,l,d]=s:(a=de,[l,d]=s)),!l&&Dt)throw fs("called with insufficient arguments!",s),"subscribeTo() called with insufficient arguments!";let y=p=>ie=>Os(e,t,ie,p,l,d,i);return Array.isArray(a)?a.map(p=>Array.isArray(p)?y(p[1])(p[0]):y(h)(p)):y(h)(a)},zt=(e,t,s)=>{let i=[],n=Ps(e,t,s,i);return Lt.publish(i),n},vt=e=>t=>{t.callAfterApply=()=>{e==null||e()}},Vt=(e,t)=>Object.assign(()=>x(e,t),Array.isArray(t)?{listeners:t}:{listener:t}),Ut=(e,t,s,i)=>{let{store:n,keeper:o}=e[se];Array.isArray(t)?t.forEach(a=>{n.forEach(a,h=>h.apply(a,s,i)),o.retain(a,s)}):t!==de&&(n.forEach(t,a=>{a.apply(t,s,i)}),o.retain(t,s))},N=(e,...t)=>{let s=Oe(e),{store:i,keeper:n}=s[se];return Vt(s,zt(i,n,t))},Ce=(e,...t)=>{let s=Oe(e),{store:i,keeper:n}=s[se],o=zt(i,n,t),a=Vt(s,o),h=!1,l=()=>{h||(a(),h=!0)};return Array.isArray(o)?o.forEach(vt(l)):vt(l)(o),l},js=(e,t)=>new Promise(s=>{Ce(e,t,s)}),x=(e,t,s)=>{if(!Ee(e))throw new Error("object is not eventized");let{store:i,keeper:n}=e[se],o=typeof t,a=s!=null&&(o==="string"||o==="symbol");i.remove(t,s,a),Array.isArray(t)?n.remove(t.filter(h=>typeof h=="string")):Tt(t)&&n.remove(t)},E=(e,t,...s)=>{if(!Ee(e))throw new Error("object is not eventized");Ut(e,t,s)},Ms=(e,t,...s)=>{if(!Ee(e))throw new Error("object is not eventized");let i=[];return Ut(e,t,s,n=>{i.push(n)}),i=i.map(n=>Array.isArray(n)?Promise.all(n):Promise.resolve(n)),i.length>0?Promise.all(i):Promise.resolve()},at=(e,t)=>{let s=Oe(e),{keeper:i}=s[se];i.add(t)},It=(e,t)=>{if(!Ee(e))throw new Error("object is not eventized");let{keeper:s}=e[se];s.clear(t)},we=(()=>{let e=(t={})=>Oe(t);return e.inject=(t={})=>(t=Oe(t),Object.assign(t,{on:(...s)=>N(t,...s),once:(...s)=>Ce(t,...s),onceAsync:s=>js(t,s),off:(s,i)=>x(t,s,i),emit:(s,...i)=>E(t,s,...i),emitAsync:(s,...i)=>Ms(t,s,...i),retain:s=>at(t,s),retainClear:s=>It(t,s)}),t),e.is=Ee,e})(),B=Symbol("signal"),gt=Symbol("destroySignal"),mt=Symbol("createEffect"),Fs=Symbol("destroyEffect"),Me,Fe,St,Bt=(St=class{constructor(e="id",t=1){c(this,Me);c(this,Fe);u(this,Me,e),u(this,Fe,t)}make(){return Symbol(\`\${r(this,Me)}\${dt(this,Fe)._++}\`)}},Me=new WeakMap,Fe=new WeakMap,St),ke=we(),Ie=we(),ye=we(),qe,Re,Se=(qe=class{constructor(){c(this,Re,new Set)}batch(e){r(this,Re).add(e)}run(){E(ye,Array.from(r(this,Re)))}},Re=new WeakMap,f(qe,"current"),qe),Rs=()=>Se.current;function $t(e){let t=Se.current;t?t=void 0:t=Se.current=new Se;try{e()}finally{t&&(Se.current=void 0,t.run())}}var Ze=[],Gt=()=>Ze.at(-1),Ts=(e,t)=>{Ze.push(e);try{return t()}finally{Ze.pop()}},Ds=e=>e!=null&&typeof e.then=="function",F,X,Z,ae,oe,ve,Ls=(F=class{constructor(t,s){f(this,"id");f(this,"callback");c(this,X);c(this,Z,new Set);c(this,ae,new Set);f(this,"parentEffect");f(this,"childEffects",[]);f(this,"curChildEffectSlot",0);f(this,"autorun",!0);f(this,"shouldRun",!0);c(this,oe);c(this,ve,!1);var i;this.callback=t,this.autorun=(i=s==null?void 0:s.autorun)!=null?i:!0,u(this,oe,s==null?void 0:s.dependencies),this.id=F.idGen.make(),N(ye,this.id,"recall",this),++F.count}hasStaticDeps(){return r(this,oe)!=null&&r(this,oe).length>0}saveSignalsFromDeps(){for(let t of r(this,oe))this.whenSignalIsRead(M(t).id)}static createEffect(t,s,i){let n=Array.isArray(s)?s:void 0,o=n?i!=null?i:{dependencies:n}:s;o&&n&&(o.dependencies=n);let a,h=Gt();return h!=null?(a=h.getCurrentChildEffect(),a==null&&(a=new F(t,o),h.attachChildEffect(a),E(ye,mt,a)),h.curChildEffectSlot++):(a=new F(t,o),E(ye,mt,a)),a.hasStaticDeps()?a.saveSignalsFromDeps():a.autorun&&a.run(),[a.run.bind(a),a.destroy.bind(a)]}getCurrentChildEffect(){return this.childEffects[this.curChildEffectSlot]}attachChildEffect(t){this.childEffects.push(t),this.parentEffect=this}run(){if(r(this,ve)||!this.shouldRun)return;let t=Rs();t?t.batch(this.id):(this.runCleanupCallback(),this.curChildEffectSlot=0,this.shouldRun=!1,this.hasStaticDeps()?u(this,X,this.callback()):u(this,X,Ts(this,this.callback)))}recall(){this.shouldRun=!0,this.autorun&&this.run()}whenSignalIsRead(t){r(this,Z).has(t)||(r(this,Z).add(t),N(ke,t,"recall",this),Ce(Ie,t,gt,this))}[gt](t){!r(this,ae).has(t)&&r(this,Z).has(t)&&(r(this,ae).add(t),x(ke,t,this),r(this,ae).size===r(this,Z).size&&this.destroy())}runCleanupCallback(){if(r(this,X)!=null){let t=r(this,X);u(this,X,void 0),Ds(t)?Promise.resolve(t).then(s=>{typeof s=="function"&&s()}):t()}}destroy(){r(this,ve)||(E(ye,Fs,this),this.runCleanupCallback(),x(ke,this),x(ye,this),x(Ie,this),u(this,ve,!0),r(this,Z).clear(),r(this,ae).clear(),this.childEffects.forEach(t=>{t.destroy()}),this.childEffects.length=0,--F.count)}},X=new WeakMap,Z=new WeakMap,ae=new WeakMap,oe=new WeakMap,ve=new WeakMap,f(F,"idGen",new Bt("ef")),f(F,"count",0),F),Be=(...e)=>Ls.createEffect(...e),H=new WeakMap,ce=(e,t)=>{var s;return(s=H.get(e))==null?void 0:s.signals[t]},xs=e=>{var s;let t=(s=H.get(e))==null?void 0:s.signals;if(t)return Object.values(t)},Ns=(e,t,s)=>{let i=H.get(e);i?i.signals[t]=s:H.set(e,{signals:{[t]:s},effects:{}})};function zs(...e){for(let t of e)if(H.has(t)){let s=H.get(t);for(let i of Object.values(s.signals))ne(i);s.signals={}}}function Vs(...e){for(let t of e)if(H.has(t)){let{signals:s,effects:i}=H.get(t);for(let n of Object.values(s))ne(n);for(let[,n]of Object.values(i))n();H.delete(t)}}function Us(e){let t=M(je(e)?e:ce(...e));t!=null&&!t.muted&&!t.destroyed&&_e(t.id,t.value,{touch:!0})}function Pe(e){var t,s;return je(e)?(t=M(e))==null?void 0:t.value:(s=M(ce(...e)))==null?void 0:s.value}var kt,Is=class{constructor(e){f(this,kt);this[B]=e}get get(){return this[B].reader}get set(){return this[B].writer}*[(kt=B,Symbol.iterator)](){yield this.get,yield this.set}get value(){return Pe(this.get)}set value(e){this.set(e)}onChange(e){let[,t]=Be(()=>e(this.value),[this.get]);return t}get muted(){return this[B].muted}set muted(e){this[B].muted=e}touch(){Us(this)}destroy(){ne(this)}},Bs=0;function $s(){return Bs>0}var Gs=new Bt("si");function bt(e){var t;$s()||((t=Gt())==null||t.whenSignalIsRead(e))}function _e(e,t,s){E(ke,e,t,s)}var je=e=>e!=null&&e[B]!=null,Ws=e=>{let t=s=>{var i;return s?Be(()=>(e.destroyed||bt(e.id),s(e.value)),[t]):e.destroyed||((i=e.beforeReadFn)==null||i.call(e),bt(e.id)),e.value};return Object.defineProperty(t,B,{value:e}),t},he,D,Wt=(he=class{constructor(t,s){f(this,"id");f(this,"lazy");f(this,"compareFn");f(this,"beforeReadFn");f(this,"muted",!1);f(this,"destroyed",!1);c(this,D);f(this,"valueFn");f(this,"reader");f(this,"writer",(t,s)=>{var o,a,h,l;let i=(o=s==null?void 0:s.lazy)!=null?o:!1,n=(h=(a=s==null?void 0:s.compareFn)!=null?a:this.compareFn)!=null?h:(d,y)=>d===y;if((i!==this.lazy||i&&t!==this.valueFn||!i&&!n(t,r(this,D)))&&(i?(u(this,D,void 0),this.valueFn=t,this.lazy=!0):(u(this,D,t),this.valueFn=void 0,this.lazy=!1),!this.muted&&!this.destroyed)){_e(this.id,r(this,D));return}(l=s==null?void 0:s.touch)!=null&&l&&_e(this.id,r(this,D),{touch:!0})});f(this,"object");this.id=Gs.make(),++he.instanceCount,this.lazy=t,this.lazy?(this.value=void 0,this.valueFn=s):(this.value=s,this.valueFn=void 0),this.reader=Ws(this),this.object=new Is(this)}get value(){return this.lazy&&(u(this,D,this.valueFn()),this.valueFn=void 0,this.lazy=!1),r(this,D)}set value(t){u(this,D,t)}},D=new WeakMap,f(he,"instanceCount",0),he),M=e=>e==null?void 0:e[B];function q(e=void 0,t){var i;let s;if(je(e))s=M(e);else{let n=(i=t==null?void 0:t.lazy)!=null?i:!1;s=new Wt(n,e),s.beforeReadFn=t==null?void 0:t.beforeReadFn,s.compareFn=t==null?void 0:t.compareFn}return s.object}var ne=(...e)=>{for(let t of e){let s=M(t);s!=null&&!s.destroyed&&(s.destroyed=!0,s.beforeReadFn=void 0,--Wt.instanceCount,E(Ie,s.id,s.id))}},b,fe=new WeakMap,Ae=new WeakMap,wt=e=>typeof e=="function",Q;(function(e){e.Signal="signal",e.Function="function",e.Property="property"})(Q||(Q={}));var re,V,Kt,Yt,qt,Ht,le,A,z,S,$,_,Te,et,Jt=(re=class{constructor(e,t,s){c(this,Te);c(this,le);c(this,A,!1);c(this,z);c(this,S);c(this,$);c(this,_);var n,o;let i=b.findConnection(e,t);if(i!=null)return i;we(this),at(this,b.Value),u(this,z,M(e)),je(t)?(u(this,S,M(t)),u(this,$,Q.Signal)):wt(t)?(u(this,S,t),u(this,$,Q.Function)):(u(this,S,t),u(this,$,Q.Property)),u(this,_,s),u(this,le,N(ke,r(this,z).id,(a,h)=>{(h==null?void 0:h.touch)===!0?this.touch():m(this,Te,et).call(this,!1)})),Ce(Ie,r(this,z).id,"destroy",this),m(n=b,V,Kt).call(n,this),s!=null&&m(o=b,V,qt).call(o,s,this),this.touch()}static findConnectionsBySignal(e){return fe.get(M(e))}static findConnectionsByTarget(e){let t=Ae.get(e);return t?Array.from(t):void 0}static findConnectionsByObject(e){let t=new Set,s=xs(e);if(s)for(let n of s.flatMap(o=>{let a=b.findConnectionsBySignal(o);return a?Array.from(a):[]}))t.add(n);let i=b.findConnectionsByTarget(e);if(i)for(let n of i)t.add(n);return t.size>0?Array.from(t):void 0}static findConnection(e,t){let s=fe.get(M(e));if(s!=null){let i=Array.from(s),n=-1;if(je(t)){let o=M(t);n=i.findIndex(a=>r(a,S)===o)}else wt(t)?n=i.findIndex(o=>r(o,S)===t):n=i.findIndex(o=>{if(r(o,$)===Q.Property){let a=r(o,S);return a[0]===t[0]&&a[1]===t[1]}return!1});if(n>=0)return i[n]}}get isMuted(){return r(this,A)}nextValue(){return new Promise((e,t)=>{let s=0,i=[N(this,b.Value,n=>{s===1?(i.forEach(o=>{o()}),e(n)):++s}),N(this,b.Destroy,()=>{i.forEach(n=>{n()}),t()})]})}touch(){return m(this,Te,et).call(this,!0)}mute(){return!this.isDestroyed&&!r(this,A)&&(u(this,A,!0),E(this,b.Mute,this)),this}unmute(){return!this.isDestroyed&&r(this,A)&&(u(this,A,!1),E(this,b.Unmute,this)),this}toggle(){return this.isDestroyed||(u(this,A,!r(this,A)),E(this,r(this,A)?b.Mute:b.Unmute,this)),r(this,A)}destroy(){var e,t,s;this.isDestroyed||(E(this,b.Destroy,this),x(this),m(e=b,V,Yt).call(e,this),(t=r(this,le))==null||t.call(this),u(this,le,void 0),u(this,z,void 0),u(this,S,void 0),r(this,_)!=null&&(m(s=b,V,Ht).call(s,r(this,_),this),u(this,_,void 0)))}get isDestroyed(){return r(this,le)==null}hasTarget(e){return r(this,_)===e}},V=new WeakSet,Kt=function(e){if(!e.isDestroyed){let t=r(e,z),s=fe.get(t);s?s.add(e):(s=new Set([e]),fe.set(t,s))}},Yt=function(e){if(!e.isDestroyed){let t=r(e,z),s=fe.get(t);s&&(s.delete(e),s.size===0&&fe.delete(t))}},qt=function(e,t){if(!t.isDestroyed){let s=Ae.get(e);s?s.add(t):(s=new Set([t]),Ae.set(e,s))}},Ht=function(e,t){if(!t.isDestroyed){let s=Ae.get(e);s&&(s.delete(t),s.size===0&&Ae.delete(e))}},le=new WeakMap,A=new WeakMap,z=new WeakMap,S=new WeakMap,$=new WeakMap,_=new WeakMap,Te=new WeakSet,et=function(e){if(!r(this,A)&&!this.isDestroyed){let{value:t}=r(this,z);if(r(this,$)===Q.Signal)r(this,S).writer(t,e?{touch:e}:void 0);else if(r(this,$)===Q.Function)r(this,S).call(this,t);else{let[s,i]=r(this,S);s[i](t)}E(this,b.Value,t)}return this},c(re,V),f(re,"Value","value"),f(re,"Mute","mute"),f(re,"Unmute","unmute"),f(re,"Destroy","destroy"),re);b=Jt;function Ke(e,t){var a;let s=Array.isArray(e)?ce(...e):e,i=Array.isArray(t),n=i&&(a=ce(...t))!=null?a:t,o=i?t[0]:t;return new Jt(s,n,o)}var L,Ot,Js=(Ot=class{constructor(){c(this,L,new Map)}keys(){return r(this,L).keys()}entries(){return r(this,L).entries()}clear(){for(let e of r(this,L).values())e.destroy();r(this,L).clear()}hasSignal(e){return r(this,L).has(e)}getSignal(e){if(!r(this,L).has(e)){let t=q();return r(this,L).set(e,t),t}return r(this,L).get(e)}getSignalReader(e){return this.getSignal(e).get}getSignalWriter(e){return this.getSignal(e).set}},L=new WeakMap,Ot);function Et(e,t,s,i,n,o){function a(T){if(T!==void 0&&typeof T!="function")throw new TypeError("Function expected");return T}for(var h=i.kind,l=h==="getter"?"get":h==="setter"?"set":"value",d=!t&&e?i.static?e:e.prototype:null,y=t||(d?Object.getOwnPropertyDescriptor(d,i.name):{}),p,ie=!1,C=s.length-1;C>=0;C--){var xe={};for(var v in i)xe[v]=v==="access"?{}:i[v];for(var v in i.access)xe.access[v]=i.access[v];xe.addInitializer=function(T){if(ie)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(T||null))};var g=(0,s[C])(h==="accessor"?{get:y.get,set:y.set}:y[l],xe);if(h==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(p=a(g.get))&&(y.get=p),(p=a(g.set))&&(y.set=p),(p=a(g.init))&&n.unshift(p)}else(p=a(g))&&(h==="field"?n.unshift(p):y[l]=p)}d&&Object.defineProperty(d,i.name,y),ie=!0}function ze(e,t,s){for(var i=arguments.length>2,n=0;n<t.length;n++)s=i?t[n].call(e,s):t[n].call(e);return i?s:void 0}var Qt=e=>{if(typeof e=="symbol")return e;let t=e.indexOf("$");return t>=0?e.slice(0,t):e};function Ks(e){return function(t,s){var o,a;let i=(o=e==null?void 0:e.name)!=null?o:Qt(s.name),n=!!((a=e==null?void 0:e.readAsValue)!=null&&a);return{get(){let h=ce(this,i);if(h)return n?Pe(h):h()},set(h){var l;(l=M(ce(this,i)))==null||l.writer(h)},init(h){let[l,d]=q(void 0,e);return Ns(this,i,l),d(h),Pe(l)}}}}function Ys(e){return function(t,s){var n;let i=(n=e==null?void 0:e.name)!=null?n:Qt(s.name);return{get(){return ce(this,i)}}}}var Ye=(()=>{var a,h,l,d,y,tt,Xt,C;let e,t=[],s=[],i,n=[],o=[];return C=class{constructor(){c(this,y);c(this,a,[]);c(this,h);c(this,l,ze(this,t,void 0));c(this,d,(ze(this,s),ze(this,n,void 0)));ze(this,o),at(this,C.Value),this.value$(v=>E(this,C.Value,v))}get value(){return r(this,l)}set value(v){u(this,l,v)}get value$(){return r(this,d)}set value$(v){u(this,d,v)}add(...v){for(let g of v)r(this,a).push(g);m(this,y,Xt).call(this)}clear(){r(this,a).length=0,m(this,y,tt).call(this)}dispose(){this.clear(),x(this),Vs(this),It(this,C.Value)}},a=new WeakMap,h=new WeakMap,l=new WeakMap,d=new WeakMap,y=new WeakSet,tt=function(){var v;(v=r(this,h))==null||v.call(this),u(this,h,void 0)},Xt=function(){m(this,y,tt).call(this);let[v,g]=Be(()=>{for(let T of r(this,a)){let ot=Pe(T);if(ot!=null){this.value=ot;return}}this.value=void 0},r(this,a));u(this,h,g),v()},(()=>{let v=typeof Symbol=="function"&&Symbol.metadata?Object.create(null):void 0;e=[Ks()],i=[Ys()],Et(C,null,e,{kind:"accessor",name:"value",static:!1,private:!1,access:{has:g=>"value"in g,get:g=>g.value,set:(g,T)=>{g.value=T}},metadata:v},t,s),Et(C,null,i,{kind:"accessor",name:"value$",static:!1,private:!1,access:{has:g=>"value$"in g,get:g=>g.value$,set:(g,T)=>{g.value$=T}},metadata:v},n,o),v&&Object.defineProperty(C,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:v})})(),C.Value="value",C})(),Ct="onCreate",pe="onDestroy",qs="onViewEvent",ee,ge,ue,G,P,k,W,j,me,R,st,Ve,it,Pt,Hs=(Pt=class{constructor(e,t){c(this,R);c(this,ee);c(this,ge);c(this,ue,new Js);c(this,G,new Map);c(this,P);c(this,k);c(this,W,new Set);c(this,j,[]);c(this,me,0);u(this,ee,e),u(this,ge,t),Ce(this,pe,Nt.Min,this)}get kernel(){return r(this,ee)}get uuid(){return r(this,ge)}get order(){return r(this,me)}set order(e){r(this,me)!==e&&(u(this,me,e),r(this,P)&&this.parent.resortChildren())}get parentUuid(){return r(this,P)||void 0}set parentUuid(e){r(this,P)!==e&&(this.removeFromParent(),u(this,P,e||void 0),u(this,k,e?r(this,ee).getEntity(e):void 0),r(this,k)&&r(this,k).addChild(this))}get parent(){return!r(this,k)&&r(this,P)&&u(this,k,r(this,ee).getEntity(r(this,P))),r(this,k)}set parent(e){this.parentUuid=e==null?void 0:e.uuid}get hasParent(){return!!r(this,P)}get children(){return r(this,j)}traverse(e){e(this);for(let t of r(this,j))t.traverse(e)}onDestroy(){var e;r(this,ue).clear(),x(this);for(let t of r(this,G).values())t.unsubscribeFromPath(),(e=t.unsubscribeFromParent)==null||e.call(t),t.ctxPath.dispose(),zs(t.inherited,t.provide,t.context);u(this,P,void 0),u(this,k,void 0),r(this,W).clear(),r(this,j).length=0}addChild(e){var t;if(r(this,j).length===0){r(this,W).add(e.uuid),r(this,j).push(e);return}if(r(this,W).has(e.uuid))throw new Error(\`child with uuid: \${e.uuid} already exists! parentUuid: \${this.uuid}\`);r(this,W).add(e.uuid),r(this,j).push(e),this.resortChildren();for(let[,s]of r(e,G))m(t=e,R,it).call(t,s)}resortChildren(){r(this,j).sort((e,t)=>e.order-t.order)}removeChild(e){r(this,W).has(e.uuid)&&(r(this,W).delete(e.uuid),r(this,j).splice(r(this,j).indexOf(e),1))}removeFromParent(){if(r(this,k)){r(this,k).removeChild(this),u(this,k,void 0),u(this,P,void 0);for(let[,e]of r(this,G))e.unsubscribeFromParent&&(e.unsubscribeFromParent(),e.unsubscribeFromParent=void 0)}}dispatchMessageToView(e,t,s,i=!1){r(this,ee).dispatchMessageToView({uuid:r(this,ge),type:e,data:t,transferables:s,traverseChildren:i})}dispatchViewEvents(e){for(let{type:t,data:s}of e)E(this,qs,t,s)}dispatchViewEvent(e,t){this.dispatchViewEvents([{type:e,data:t}])}getPropertyReader(e){return m(this,R,st).call(this,e).get}getPropertyWriter(e){return m(this,R,st).call(this,e).set}setProperties(e){$t(()=>{for(let[t,s]of e)this.setProperty(t,s)})}setProperty(e,t){this.getPropertyWriter(e)(t)}getProperty(e){return Pe(this.getPropertyReader(e))}propKeys(){return Array.from(r(this,ue).keys())}propEntries(){return Array.from(r(this,ue).entries()).map(([e,t])=>[e,t.value])}hasContext(e){return r(this,G).has(e)}useContext(e){return m(this,R,Ve).call(this,e).context.get}provideContext(e){return m(this,R,Ve).call(this,e).provide}},ee=new WeakMap,ge=new WeakMap,ue=new WeakMap,G=new WeakMap,P=new WeakMap,k=new WeakMap,W=new WeakMap,j=new WeakMap,me=new WeakMap,R=new WeakSet,st=function(e){return r(this,ue).getSignal(e)},Ve=function(e){let t=r(this,G).get(e);if(t==null){let s=q(),i=q(),n=q(),o=new Ye;o.add(i.get,s.get);let a=N(o,Ye.Value,h=>{queueMicrotask(()=>{n.set(h)})});t={name:e,inherited:s,provide:i,context:n,ctxPath:o,unsubscribeFromPath:a},r(this,G).set(e,t),m(this,R,it).call(this,t)}return t},it=function(e){var t,s;this.parent&&((t=e.unsubscribeFromParent)==null||t.call(e),e.unsubscribeFromParent=N(m(s=this.parent,R,Ve).call(s,e.name).ctxPath,Ye.Value,i=>{e.inherited.set(i)}))},Pt);function Qs(e,t){e.indexOf(t)===-1&&e.push(t)}var J,O,jt,Zt=(jt=class{constructor(){c(this,J,new Map);c(this,O,new Map)}static get(e){return e!=null?e:Xs}define(e,t){r(this,J).has(e)?Qs(r(this,J).get(e).constructors,t):r(this,J).set(e,{token:e,constructors:[t]})}appendRoute(e,t){if(r(this,O).has(e)){let s=r(this,O).get(e);for(let i of t)s.add(i)}else r(this,O).set(e,new Set(t))}clearRoute(e){r(this,O).delete(e)}findTokensByRoute(e){let t=new Set([e]),s=r(this,O).has(e)?[...r(this,O).get(e)]:[];for(;s.length;){let i=s.shift();t.has(i)||(t.add(i),r(this,O).has(i)&&s.push(...Array.from(r(this,O).get(i)).filter(n=>!t.has(n))))}return Array.from(t)}findConstructors(e){let t=this.findTokensByRoute(e),s=new Set;for(let i of t){let n=r(this,J).get(i);if(n)for(let o of n.constructors)s.add(o)}return s.size>0?Array.from(s):void 0}hasToken(e){return r(this,J).has(e)}hasRoute(e){return r(this,O).has(e)}clear(){r(this,J).clear(),r(this,O).clear()}},J=new WeakMap,O=new WeakMap,jt),Xs=new Zt,I;(function(e){e[e.CreateAndDestroy=0]="CreateAndDestroy",e[e.JustCreate=1]="JustCreate",e[e.DestroyOnly=2]="DestroyOnly"})(I||(I={}));var At=e=>e.displayName||e.name,w,K,be,De,Y,Mt,Zs=(Mt=class{constructor(e){c(this,w,new Map);c(this,K,new Set);c(this,be);c(this,De);c(this,Y,!0);we(this),this.registry=Zt.get(e)}getEntity(e){var s;let t=(s=r(this,w).get(e))==null?void 0:s.entity;if(!t)throw new Error(\`entity with uuid "\${e}" not found!\`);return t}hasEntity(e){return r(this,w).has(e)}traverseLevelOrderBFS(e=!1){if(r(this,Y)){let t=new Map,s=(i,n)=>{let o=this.getEntity(i);t.has(n)?t.get(n).push(o):t.set(n,[o]);for(let a of o.children)s(a.uuid,n+1)};r(this,K).forEach(i=>s(i,0)),u(this,be,Array.from(t.entries()).sort((i,n)=>i[0]-n[0]).map(([,i])=>i).flat()),u(this,De,r(this,be).slice().reverse()),u(this,Y,!1)}return e?r(this,De):r(this,be)}getEntityGraph(){return Array.from(r(this,K)).map(e=>this.getEntityGraphNode(e))}getEntityGraphNode(e){if(!r(this,w).has(e))return;let{token:t,entity:s}=r(this,w).get(e);return{token:t,entity:s,props:Object.fromEntries(s.propEntries()),children:s.children.map(i=>this.getEntityGraphNode(i.uuid))}}upgradeEntities(){for(let e of this.traverseLevelOrderBFS(!0))this.updateShadowObjects(e.uuid,I.DestroyOnly);for(let e of this.traverseLevelOrderBFS(!1))this.updateShadowObjects(e.uuid,I.JustCreate)}run(e){$t(()=>{for(let t of e.changeTrail)this.parse(t)})}parse(e){switch(e.type){case U.CreateEntities:this.createEntity(e.uuid,e.token,e.parentUuid,e.order,e.properties),u(this,Y,!0);break;case U.DestroyEntities:this.destroyEntity(e.uuid),u(this,Y,!0);break;case U.SetParent:this.setParent(e.uuid,e.parentUuid,e.order),u(this,Y,!0);break;case U.UpdateOrder:this.updateOrder(e.uuid,e.order),u(this,Y,!0);break;case U.ChangeProperties:this.changeProperties(e.uuid,e.properties);break;case U.ChangeToken:this.changeToken(e.uuid,e.token);break;case U.SendEvents:this.dispatchEventsToEntity(e.uuid,e.events);break}}createEntity(e,t,s,i=0,n){let o=new Hs(this,e);o.order=i;let a={token:t,entity:o,usedConstructors:new Map};r(this,w).set(e,a),s&&(o.parentUuid=s),o.hasParent||r(this,K).add(e),n&&o.setProperties(n),this.createShadowObjects(e)}destroyEntity(e){if(!r(this,w).has(e))return;let{entity:t,usedConstructors:s}=r(this,w).get(e);t.removeFromParent(),E(t,pe,this),s.clear(),r(this,w).delete(t.uuid),r(this,K).delete(t.uuid)}setParent(e,t,s=0){let i=this.getEntity(e);i.parentUuid===t&&i.order===s||(i.removeFromParent(),i.order=s,i.parentUuid=t,i.hasParent?r(this,K).delete(e):r(this,K).add(e))}updateOrder(e,t){this.getEntity(e).order=t}dispatchEventsToEntity(e,t){var s;(s=this.getEntity(e))==null||s.dispatchViewEvents(t)}changeProperties(e,t){this.getEntity(e).setProperties(t)}changeToken(e,t){if(!r(this,w).has(e))return;let s=r(this,w).get(e);s.token!==t&&(s.token=t,this.updateShadowObjects(e))}dispatchMessageToView(e){queueMicrotask(()=>{E(this,He,e)})}updateShadowObjects(e,t=I.CreateAndDestroy){let s=r(this,w).get(e),i=new Set(this.registry.findConstructors(s.token)),n=t===I.CreateAndDestroy||t===I.DestroyOnly,o=t===I.CreateAndDestroy||t===I.JustCreate;if(n){for(let[a,h]of s.usedConstructors)if(!i.has(a)){s.usedConstructors.delete(a);for(let l of h)this.destroyShadowObject(l,s.entity)}}if(o)for(let a of i)s.usedConstructors.has(a)||this.constructShadowObject(a,s)}constructShadowObject(e,t){let s=new Set,i=new Set,n=new Map,o=new Map,a=new Map,h=we(new e({entity:t.entity,provideContext(l,d,y){let p=o.get(l);if(p===void 0){p=q(d,y?{compareFn:y}:void 0),o.set(l,p);let ie=Ke(p,t.entity.provideContext(l));i.add(ie.destroy.bind(ie))}return p},useContext(l,d){let y=n.get(l);if(y===void 0){[y]=q(void 0,d?{compareFn:d}:void 0),n.set(l,y);let p=Ke(t.entity.useContext(l),y);i.add(p.destroy.bind(p))}return y},useProperty(l,d){let y=a.get(l);if(y===void 0){[y]=q(void 0,d?{compareFn:d}:void 0),a.set(l,y);let p=Ke(t.entity.getPropertyReader(l),y);i.add(p.destroy.bind(p))}return y},createEffect(...l){let d=Be(...l);return i.add(d[1]),d},createSignal(...l){let d=q(...l);return i.add(()=>{ne(d)}),d},on(...l){let d=N(...l);return i.add(d),d},onDestroy(l){s.add(l)}}));return console.debug("[Kernel] create shadow-object",At(e),{shadowObject:h,entity:t.entity}),Ce(h,pe,()=>{console.debug("[Kernel] destroy shadow-object",At(e),{shadowObject:h,entity:t.entity});for(let d of s)d();for(let d of i)d();for(let d of n.values())ne(d);for(let d of a.values())ne(d);for(let[d]of o.values())ne(d);s.clear(),i.clear(),n.clear(),a.clear(),o.clear();let l=t.usedConstructors.get(e);l&&(l.delete(h),l.size===0&&t.usedConstructors.delete(e))}),t.usedConstructors.has(e)?t.usedConstructors.get(e).add(h):t.usedConstructors.set(e,new Set([h])),this.attachShadowObject(h,t.entity),h}createShadowObjects(e){var s;let t=r(this,w).get(e);(s=this.registry.findConstructors(t.token))==null||s.forEach(i=>{this.constructShadowObject(i,t)})}findShadowObjects(e){if(!r(this,w).has(e))return[];let{usedConstructors:t}=r(this,w).get(e);return Array.from(new Set(Array.from(t.values()).map(s=>Array.from(s)).flat()))}attachShadowObject(e,t){N(t,e),typeof e[Ct]=="function"&&e[Ct](t)}destroyShadowObject(e,t){typeof e[pe]=="function"&&e[pe](t),E(e,pe,t),x(t,e)}destroy(){for(let e of this.traverseLevelOrderBFS().reverse())this.destroyEntity(e.uuid)}},w=new WeakMap,K=new WeakMap,be=new WeakMap,De=new WeakMap,Y=new WeakMap,Mt);async function _t(e,t,s,i=!0){var o,a;if(s.has(t)){console.warn("importModule: skipping already imported module",t);return}else s.add(t);t.extends&&await Promise.all(t.extends.map(h=>_t(e,h,s,!1)));let{registry:n}=e;if(t.define)for(let[h,l]of Object.entries(t.define))n.define(h,l);if(t.routes)for(let[h,l]of Object.entries(t.routes))n.appendRoute(h,l);await((a=(o=t.initialize)==null?void 0:o.call(t,{define:(h,l)=>n.define(h,l),kernel:e,registry:n}))!=null?a:Promise.resolve()),i&&e.upgradeEntities()}var _s=e=>(typeof e=="string"&&(e=new URL(e,globalThis.location.href)),e.toString()),Le,te,es,ts,ss,Ft,ei=(Ft=class{constructor(e){c(this,te);c(this,Le,new Set);var t,s;this.kernel=(t=e==null?void 0:e.kernel)!=null?t:new Zs,this.postMessage=(s=e==null?void 0:e.postMessage)!=null?s:self.postMessage.bind(self),N(this.kernel,He,"onMessageToView",this)}route(e){var t;switch(e.data.type){case os:m(this,te,es).call(this,e.data);break;case hs:m(this,te,ts).call(this,e.data);break;case ls:m(this,te,ss).call(this,e.data);break;default:console.warn("[MessageRouter] unknown message",(t=e.data.type)!=null?t:e.data)}}onMessageToView(e){let i=e,{transferables:t}=i,s=ut(i,["transferables"]);this.postMessage({type:He,data:s},{transfer:t})}},Le=new WeakMap,te=new WeakSet,es=async function(e){try{let t=await import(_s(e.importModule));t[We]?(await _t(this.kernel,t[We],r(this,Le)),this.postMessage({type:Ge,url:e.importModule})):this.postMessage({type:Ge,url:e.importModule,error:\`module has no "\${We}" export\`})}catch(t){console.error("[MessageRouter] failed to import module",t),this.postMessage({type:Ge,url:e.importModule,error:\`\${t}\`})}},ts=function(e){try{this.kernel.run(e)}catch(t){console.error("[MessageRouter] failed to apply change trail",t),this.postMessage({type:ft,serial:e.serial,error:t.toString()})}e.serial&&this.postMessage({type:ft,serial:e.serial})},ss=function(e){console.debug("[MessageRouter] on destroy",e),x(this.kernel,this),r(this,Le).clear(),this.postMessage({type:ds})},Ft),ti=class{constructor(){this.router=new ei,this.onmessage=e=>{this.router.route(e)}}start(){self.addEventListener("message",this.onmessage),self.postMessage({type:us})}};console.debug("@spearwolf/shadow-objects/WorkerRuntime: hello!");var si=new ti;si.start();
22
+ /*! Bundled license information:
23
+
24
+ @spearwolf/eventize/lib/index.mjs:
25
+ (*!
26
+ =============================================================================
27
+ @spearwolf/eventize 4.0.0+build.20240722
28
+ \u2014 https://github.com/spearwolf/eventize.git
29
+ =============================================================================
30
+
31
+ Copyright 2015-2024 Wolfger Schramm
32
+
33
+ Licensed under the Apache License, Version 2.0 (the "License");
34
+ you may not use this file except in compliance with the License.
35
+ You may obtain a copy of the License at
36
+
37
+ http://www.apache.org/licenses/LICENSE-2.0
38
+
39
+ Unless required by applicable law or agreed to in writing, software
40
+ distributed under the License is distributed on an "AS IS" BASIS,
41
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42
+ See the License for the specific language governing permissions and
43
+ limitations under the License.
44
+ *)
45
+ */
46
+ `)}var ps=()=>new St;var Ae=(r,e,t=1e3,s)=>new Promise((i,n)=>{let o,a,h=()=>{clearTimeout(o),r.removeEventListener("message",a)};t!==0&&t!==1/0&&(o=setTimeout(()=>{h(),n(new Error(`Timeout waiting for message of type: ${e}`))},t)),a=l=>{if(l.data.type===e)try{(!s||s(l.data))&&(h(),i())}catch(u){h(),n(u.toString())}},r.addEventListener("message",a)});var Is=r=>{let e;if(r!=null&&Array.isArray(r))for(let t of r)t.transferables&&(e?e=[...e,...t.transferables]:e=t.transferables,delete t.transferables);return e},rt=class r{static{this.WorkerLoaded="workerLoaded"}#e;#t=!1;#s=0;get isDestroyed(){return this.#t}get workerLoaded(){return ae(this,r.WorkerLoaded)}constructor(){N(this,r.WorkerLoaded)}async start(){if(this.#e)return console.warn("RemoteWorkerEnv: already started"),this.workerLoaded.then(()=>{if(this.isDestroyed)throw"RemoteWorkerEnv: worker was destroyed"});let e=this.#e=ps();try{if(await Ae(e,Kt,Zt),this.isDestroyed)throw"RemoteWorkerEnv: worker was destroyed";e.addEventListener("message",this.onMessageFromWorker.bind(this)),queueMicrotask(()=>{p(this,r.WorkerLoaded,this)})}catch(t){throw console.error("RemoteWorkerEnv: failed to start",t),this.#e=void 0,t}}onMessageFromWorker(e){e.data?.type===ce?this.onMessageToView?.(e.data.data):console.debug("RemoteWorkerEnv: message from worker",e)}applyChangeTrail(e,t){let s=Is(e),i={type:Ht,changeTrail:e},n=++this.#s;return t&&(i.serial=n),this.#e.postMessage(i,s),t?Ae(this.#e,Yt,ts,o=>{if(o.error)throw o.error;return o.serial===n}):Promise.resolve()}importScript(e){return e=tt(e),this.#e.postMessage({type:Gt,importModule:e}),Ae(this.#e,Jt,es,t=>{if(t.error)throw t.error;return t.url===e})}destroy(){if(!this.#e)return;let e=this.#e;this.#e=void 0,this.#t=!0,e.postMessage({type:Qt}),Ae(e,Xt,ss).finally(()=>{e.terminate()})}};var ke,Te=class extends J{static{this.observedAttributes=[...J.observedAttributes,Ie,Ue,ze]}static{this.DefaultAutoSync="frame"}#e;#t;#s;#i;constructor(){super(),this.isShaeWorkerElement=!0,this.shadowEnv=new L,this.autostart=!0,this.isConnected$=y(!1),this.autoSync$=y(ke.DefaultAutoSync),this.#e=!1,this.#t=!1,this.ns$.onChange(e=>{this.shadowEnv.view=j.get(e)}),g(this.shadowEnv,L.ContextCreated,()=>{this.dispatchEvent(new CustomEvent(L.ContextCreated.toLowerCase(),{bubbles:!1,detail:{shadowEnv:this.shadowEnv}}))}),g(this.shadowEnv,L.ContextLost,()=>{this.dispatchEvent(new CustomEvent(L.ContextLost.toLowerCase(),{bubbles:!1,detail:{shadowEnv:this.shadowEnv}}))}),this.autoSync$.onChange(e=>{let t=this.hasAttribute(F),s=t?this.getAttribute(F):void 0;e===ke.DefaultAutoSync?t&&s!==e&&this.setAttribute(F,e):s!==e&&this.setAttribute(F,e)}),this.#n()}get shouldAutostart(){return this.autostart&&!Se(this,ls)}get autoSync(){return this.autoSync$.value}set autoSync(e){typeof e!="string"&&(e=e?ke.DefaultAutoSync:"no"),this.autoSync$.set(`${e}`.trim().toLowerCase())}get frameLoop(){return this.#s==null&&(this.#s=new ue),this.#s}[ue.OnFrame](){this.syncShadowObjects()}async importScript(e){if(!e)throw new Error("src is blank");let t=await this.shadowEnv.ready();return console.log("shadowEnv",t),await t.envProxy.importScript(e),this}connectedCallback(){super.connectedCallback(),R(()=>{this.hasAttribute(F)&&this.autoSync$.set(this.getAttribute(F)),this.isConnected$.set(!0)}),this.shouldAutostart&&this.start()}disconnectedCallback(){this.isConnected$.set(!1),this.#r()}attributeChangedCallback(e){if(super.attributeChangedCallback(e),e===Ie&&this.shadowEnv.envProxy!=null)throw new Error('[ShaeWorkerElement] Changing the "local" attribute after the shadowEnv has been created is not supported.');e===ze&&this.#o(),e===F&&(this.autoSync=this.hasAttribute(F)?this.getAttribute(F):!0),e===Ue&&this.importScript(this.getAttribute(Ue))}start(){if(!this.#t){if(this.#e=!1,this.shadowEnv.view==null&&(this.shadowEnv.view=j.get(this.ns)),this.shadowEnv.envProxy==null){let e=Se(this,Ie)?new st:new rt;this.shadowEnv.envProxy=e,this.#o()}this.#t=!0}return this.shadowEnv.ready()}destroy(){this.shadowEnv.envProxy=void 0,this.#i?.(),this.#i=void 0}#r(){this.#e||(this.#e=!0,queueMicrotask(()=>{this.#e&&this.destroy()}))}#n(){let[,e]=b(()=>{if(this.isConnected$.get()){let t=(this.autoSync$.get()||ke.DefaultAutoSync).trim().toLowerCase(),s;if(["true","yes","on","frame","auto-sync"].includes(t))return this.frameLoop.start(this),()=>{this.frameLoop.stop(this)};if(t.toLowerCase().endsWith("fps")){let i=parseInt(t,10);i>0?s=Math.floor(1e3/i):console.warn(`[ShaeWorkerElement] invalid auto-sync value: ${t}`)}else s=parseInt(t,10),isNaN(s)&&(s=void 0,["false","no","off"].includes(t)||console.warn(`[ShaeWorkerElement] invalid auto-sync value: ${t}`));if(s!==void 0&&s>0){let i=setInterval(()=>{this.syncShadowObjects()},s);return()=>{clearInterval(i)}}}},[this.autoSync$,this.isConnected$]);this.#i=e}#o(){let e=this.shadowEnv.envProxy;e&&e.isLocalEnv&&(e.disableStructuredClone=this.hasAttribute(ze))}};ke=Te;customElements.define(as,Te);globalThis.SHADOW_ENTS_BUNDLE_LOADED=!0;
47
+ /*! Bundled license information:
48
+
49
+ @spearwolf/eventize/lib/index.mjs:
50
+ (*!
51
+ =============================================================================
52
+ @spearwolf/eventize 4.0.0+build.20240722
53
+ — https://github.com/spearwolf/eventize.git
54
+ =============================================================================
55
+
56
+ Copyright 2015-2024 Wolfger Schramm
57
+
58
+ Licensed under the Apache License, Version 2.0 (the "License");
59
+ you may not use this file except in compliance with the License.
60
+ You may obtain a copy of the License at
61
+
62
+ http://www.apache.org/licenses/LICENSE-2.0
63
+
64
+ Unless required by applicable law or agreed to in writing, software
65
+ distributed under the License is distributed on an "AS IS" BASIS,
66
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67
+ See the License for the specific language governing permissions and
68
+ limitations under the License.
69
+ *)
70
+ */
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@spearwolf/shadow-objects",
3
+ "description": "the slighty different component framework",
4
+ "version": "0.1.0",
5
+ "author": {
6
+ "name": "Wolfger Schramm",
7
+ "email": "wolfger@spearwolf.de",
8
+ "url": "https://www.spearwolf.de"
9
+ },
10
+ "license": "Apache-2.0",
11
+ "type": "module",
12
+ "main": "src/index.js",
13
+ "module": "src/index.js",
14
+ "types": "src/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "default": "./src/index.js",
18
+ "types": "./src/index.d.ts"
19
+ },
20
+ "./bundle.js": {
21
+ "default": "./bundle.js"
22
+ },
23
+ "./shadow-objects.worker.js": {
24
+ "default": "./src/shadow-objects.worker.js",
25
+ "types": "./src/shadow-objects.worker.d.ts"
26
+ },
27
+ "./shadow-objects.js": {
28
+ "default": "./src/shadow-objects.js",
29
+ "types": "./src/shadow-objects.d.ts"
30
+ },
31
+ "./shae-ent.js": {
32
+ "default": "./src/shae-ent.js",
33
+ "types": "./src/shae-ent.d.ts"
34
+ },
35
+ "./shae-prop.js": {
36
+ "default": "./src/shae-prop.js",
37
+ "types": "./src/shae-prop.d.ts"
38
+ },
39
+ "./shae-worker.js": {
40
+ "default": "./src/shae-worker.js",
41
+ "types": "./src/shae-worker.d.ts"
42
+ }
43
+ },
44
+ "sideEffects": [
45
+ "bundle.js",
46
+ "src/bundle.js",
47
+ "src/index.js",
48
+ "src/view/ComponentContext.js",
49
+ "src/view/ShadowEnv.js",
50
+ "src/shae-ent.js",
51
+ "src/shae-prop.js",
52
+ "src/shae-worker.js"
53
+ ],
54
+ "dependencies": {
55
+ "@spearwolf/eventize": "^4.0.0",
56
+ "@spearwolf/signalize": "^0.15.0"
57
+ }
58
+ }
@@ -0,0 +1,7 @@
1
+ import './shae-ent.js';
2
+ import './shae-prop.js';
3
+ import './shae-worker.js';
4
+ declare global {
5
+ var SHADOW_ENTS_BUNDLE_LOADED: boolean;
6
+ }
7
+ //# sourceMappingURL=bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,gBAAgB,CAAC;AACxB,OAAO,kBAAkB,CAAC;AAE1B,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,yBAAyB,EAAE,OAAO,CAAC;CACxC"}
package/src/bundle.js ADDED
@@ -0,0 +1,5 @@
1
+ import './shae-ent.js';
2
+ import './shae-prop.js';
3
+ import './shae-worker.js';
4
+ globalThis.SHADOW_ENTS_BUNDLE_LOADED = true;
5
+ //# sourceMappingURL=bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bundle.js","sourceRoot":"","sources":["../../src/bundle.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AACvB,OAAO,gBAAgB,CAAC;AACxB,OAAO,kBAAkB,CAAC;AAO1B,UAAU,CAAC,yBAAyB,GAAG,IAAI,CAAC"}
@@ -0,0 +1,39 @@
1
+ import type { NamespaceType } from './types.ts';
2
+ export declare enum ChangeTrailPhase {
3
+ StructuralChanges = 1,
4
+ ContentUpdates = 2,
5
+ Removal = 3
6
+ }
7
+ export declare enum ComponentChangeType {
8
+ CreateEntities = 1,
9
+ DestroyEntities = 2,
10
+ SetParent = 3,
11
+ UpdateOrder = 4,
12
+ ChangeProperties = 5,
13
+ ChangeToken = 6,
14
+ SendEvents = 7
15
+ }
16
+ export declare const GlobalNS: NamespaceType;
17
+ export declare const VoidToken = "#void";
18
+ /**
19
+ * The event is dispatched by {@link ComponentContext.reCreateChanges} and forwarded to all {@link ViewComponent}.
20
+ * The event itself has no other data.
21
+ */
22
+ export declare const ContextLost = "contextLost";
23
+ export declare const Configure = "configure";
24
+ export declare const ChangeTrail = "changeTrail";
25
+ export declare const Destroy = "destroy";
26
+ export declare const Loaded = "loaded";
27
+ export declare const AppliedChangeTrail = "appliedChangeTrail";
28
+ export declare const ImportedModule = "importedModule";
29
+ export declare const Destroyed = "destroyed";
30
+ /**
31
+ * The `messageToView` event is fired when the kernel receives a message from an entity (to its view component counterpart)
32
+ */
33
+ export declare const MessageToView = "messageToView";
34
+ export declare const WorkerLoadTimeout = 16000;
35
+ export declare const WorkerConfigureTimeout = 16000;
36
+ export declare const WorkerChangeTrailTimeout = 4000;
37
+ export declare const WorkerDestroyTimeout = 1000;
38
+ export declare const ShadowObjectsExport = "shadowObjects";
39
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAE9C,oBAAY,gBAAgB;IAC1B,iBAAiB,IAAI;IACrB,cAAc,IAAA;IACd,OAAO,IAAA;CACR;AAED,oBAAY,mBAAmB;IAC7B,cAAc,IAAI;IAClB,eAAe,IAAA;IACf,SAAS,IAAA;IACT,WAAW,IAAA;IACX,gBAAgB,IAAA;IAChB,WAAW,IAAA;IACX,UAAU,IAAA;CACX;AAED,eAAO,MAAM,QAAQ,EAAE,aAAgD,CAAC;AAExE,eAAO,MAAM,SAAS,UAAU,CAAC;AAEjC;;;GAGG;AACH,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,OAAO,YAAY,CAAC;AAEjC,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,SAAS,cAAc,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,aAAa,kBAAkB,CAAC;AAE7C,eAAO,MAAM,iBAAiB,QAAQ,CAAC;AACvC,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAC5C,eAAO,MAAM,wBAAwB,OAAO,CAAC;AAC7C,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,eAAO,MAAM,mBAAmB,kBAAkB,CAAC"}
@@ -0,0 +1,40 @@
1
+ export var ChangeTrailPhase;
2
+ (function (ChangeTrailPhase) {
3
+ ChangeTrailPhase[ChangeTrailPhase["StructuralChanges"] = 1] = "StructuralChanges";
4
+ ChangeTrailPhase[ChangeTrailPhase["ContentUpdates"] = 2] = "ContentUpdates";
5
+ ChangeTrailPhase[ChangeTrailPhase["Removal"] = 3] = "Removal";
6
+ })(ChangeTrailPhase || (ChangeTrailPhase = {}));
7
+ export var ComponentChangeType;
8
+ (function (ComponentChangeType) {
9
+ ComponentChangeType[ComponentChangeType["CreateEntities"] = 1] = "CreateEntities";
10
+ ComponentChangeType[ComponentChangeType["DestroyEntities"] = 2] = "DestroyEntities";
11
+ ComponentChangeType[ComponentChangeType["SetParent"] = 3] = "SetParent";
12
+ ComponentChangeType[ComponentChangeType["UpdateOrder"] = 4] = "UpdateOrder";
13
+ ComponentChangeType[ComponentChangeType["ChangeProperties"] = 5] = "ChangeProperties";
14
+ ComponentChangeType[ComponentChangeType["ChangeToken"] = 6] = "ChangeToken";
15
+ ComponentChangeType[ComponentChangeType["SendEvents"] = 7] = "SendEvents";
16
+ })(ComponentChangeType || (ComponentChangeType = {}));
17
+ export const GlobalNS = Symbol.for('ShadowEntsGlobalNS');
18
+ export const VoidToken = '#void';
19
+ /**
20
+ * The event is dispatched by {@link ComponentContext.reCreateChanges} and forwarded to all {@link ViewComponent}.
21
+ * The event itself has no other data.
22
+ */
23
+ export const ContextLost = 'contextLost';
24
+ export const Configure = 'configure';
25
+ export const ChangeTrail = 'changeTrail';
26
+ export const Destroy = 'destroy';
27
+ export const Loaded = 'loaded';
28
+ export const AppliedChangeTrail = 'appliedChangeTrail';
29
+ export const ImportedModule = 'importedModule';
30
+ export const Destroyed = 'destroyed';
31
+ /**
32
+ * The `messageToView` event is fired when the kernel receives a message from an entity (to its view component counterpart)
33
+ */
34
+ export const MessageToView = 'messageToView';
35
+ export const WorkerLoadTimeout = 16000;
36
+ export const WorkerConfigureTimeout = 16000;
37
+ export const WorkerChangeTrailTimeout = 4000;
38
+ export const WorkerDestroyTimeout = 1000;
39
+ export const ShadowObjectsExport = 'shadowObjects';
40
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,iFAAqB,CAAA;IACrB,2EAAc,CAAA;IACd,6DAAO,CAAA;AACT,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,CAAN,IAAY,mBAQX;AARD,WAAY,mBAAmB;IAC7B,iFAAkB,CAAA;IAClB,mFAAe,CAAA;IACf,uEAAS,CAAA;IACT,2EAAW,CAAA;IACX,qFAAgB,CAAA;IAChB,2EAAW,CAAA;IACX,yEAAU,CAAA;AACZ,CAAC,EARW,mBAAmB,KAAnB,mBAAmB,QAQ9B;AAED,MAAM,CAAC,MAAM,QAAQ,GAAkB,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAExE,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAEzC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AAEjC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAC;AAE7C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAC5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAEzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: () => any;
2
+ export default _default;
3
+ //# sourceMappingURL=create-worker.bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-worker.bundle.d.ts","sourceRoot":"","sources":["../../src/create-worker.bundle.ts"],"names":[],"mappings":";AAMA,wBAAkC"}
@@ -0,0 +1,6 @@
1
+ // @ts-ignore
2
+ import Worker from './bundle.worker.js';
3
+ // This module is converted to inline worker code using the esbuild-plugin-inline-worker plugin.
4
+ // It is done in the bundle.mjs build script.
5
+ export default () => new Worker();
6
+ //# sourceMappingURL=create-worker.bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-worker.bundle.js","sourceRoot":"","sources":["../../src/create-worker.bundle.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,MAAM,MAAM,oBAAoB,CAAC;AAExC,gGAAgG;AAChG,6CAA6C;AAE7C,eAAe,GAAG,EAAE,CAAC,IAAI,MAAM,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: () => Worker;
2
+ export default _default;
3
+ //# sourceMappingURL=create-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-worker.d.ts","sourceRoot":"","sources":["../../src/create-worker.ts"],"names":[],"mappings":";AAAA,wBAA0G"}
@@ -0,0 +1,2 @@
1
+ export default () => new Worker(new URL('./shadow-objects.worker.js', import.meta.url), { type: 'module' });
2
+ //# sourceMappingURL=create-worker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-worker.js","sourceRoot":"","sources":["../../src/create-worker.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,GAAG,CAAC,4BAA4B,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare class ShaeElement extends HTMLElement {
2
+ #private;
3
+ static observedAttributes: string[];
4
+ readonly isShaeElement = true;
5
+ readonly ns$: import("@spearwolf/signalize").SignalObject<string | symbol>;
6
+ get ns(): string | symbol;
7
+ set ns(ns: string | symbol);
8
+ constructor();
9
+ connectedCallback(): void;
10
+ attributeChangedCallback(name: string): void;
11
+ syncShadowObjects(): void;
12
+ }
13
+ //# sourceMappingURL=ShaeElement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShaeElement.d.ts","sourceRoot":"","sources":["../../../src/elements/ShaeElement.ts"],"names":[],"mappings":"AAOA,qBAAa,WAAY,SAAQ,WAAW;;IAC1C,MAAM,CAAC,kBAAkB,WAAa;IAEtC,QAAQ,CAAC,aAAa,QAAQ;IAE9B,QAAQ,CAAC,GAAG,+DAA2C;IAEvD,IAAI,EAAE,IAAI,MAAM,GAAG,MAAM,CAExB;IAED,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAMzB;;IAgBD,iBAAiB;IAIjB,wBAAwB,CAAC,IAAI,EAAE,MAAM;IAQrC,iBAAiB;CAYlB"}