@pithyjs/core 0.1.0-beta.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 (255) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +513 -0
  3. package/dist/a11y/focus-trap.d.ts +109 -0
  4. package/dist/a11y/focus-trap.d.ts.map +1 -0
  5. package/dist/a11y/focus-trap.js +246 -0
  6. package/dist/a11y/focus-trap.js.map +1 -0
  7. package/dist/a11y/index.d.ts +12 -0
  8. package/dist/a11y/index.d.ts.map +1 -0
  9. package/dist/a11y/index.js +16 -0
  10. package/dist/a11y/index.js.map +1 -0
  11. package/dist/a11y/keyboard-utils.d.ts +165 -0
  12. package/dist/a11y/keyboard-utils.d.ts.map +1 -0
  13. package/dist/a11y/keyboard-utils.js +321 -0
  14. package/dist/a11y/keyboard-utils.js.map +1 -0
  15. package/dist/a11y/roving-tabindex.d.ts +118 -0
  16. package/dist/a11y/roving-tabindex.d.ts.map +1 -0
  17. package/dist/a11y/roving-tabindex.js +249 -0
  18. package/dist/a11y/roving-tabindex.js.map +1 -0
  19. package/dist/a11y/skip-link.d.ts +55 -0
  20. package/dist/a11y/skip-link.d.ts.map +1 -0
  21. package/dist/a11y/skip-link.js +164 -0
  22. package/dist/a11y/skip-link.js.map +1 -0
  23. package/dist/compile/bindSwitchCases.d.ts +16 -0
  24. package/dist/compile/bindSwitchCases.d.ts.map +1 -0
  25. package/dist/compile/bindSwitchCases.js +323 -0
  26. package/dist/compile/bindSwitchCases.js.map +1 -0
  27. package/dist/compile/binds/bindBoundAttributes.d.ts +14 -0
  28. package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -0
  29. package/dist/compile/binds/bindBoundAttributes.js +57 -0
  30. package/dist/compile/binds/bindBoundAttributes.js.map +1 -0
  31. package/dist/compile/binds/bindClassDirectives.d.ts +20 -0
  32. package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -0
  33. package/dist/compile/binds/bindClassDirectives.js +94 -0
  34. package/dist/compile/binds/bindClassDirectives.js.map +1 -0
  35. package/dist/compile/binds/bindComponentsTags.d.ts +17 -0
  36. package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -0
  37. package/dist/compile/binds/bindComponentsTags.js +355 -0
  38. package/dist/compile/binds/bindComponentsTags.js.map +1 -0
  39. package/dist/compile/binds/bindConditionals.d.ts +16 -0
  40. package/dist/compile/binds/bindConditionals.d.ts.map +1 -0
  41. package/dist/compile/binds/bindConditionals.js +102 -0
  42. package/dist/compile/binds/bindConditionals.js.map +1 -0
  43. package/dist/compile/binds/bindDefaultTwoWay.d.ts +35 -0
  44. package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -0
  45. package/dist/compile/binds/bindDefaultTwoWay.js +128 -0
  46. package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -0
  47. package/dist/compile/binds/bindDeferDirectives.d.ts +21 -0
  48. package/dist/compile/binds/bindDeferDirectives.d.ts.map +1 -0
  49. package/dist/compile/binds/bindDeferDirectives.js +465 -0
  50. package/dist/compile/binds/bindDeferDirectives.js.map +1 -0
  51. package/dist/compile/binds/bindErrorBoundary.d.ts +71 -0
  52. package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -0
  53. package/dist/compile/binds/bindErrorBoundary.js +389 -0
  54. package/dist/compile/binds/bindErrorBoundary.js.map +1 -0
  55. package/dist/compile/binds/bindEventHandlers.d.ts +17 -0
  56. package/dist/compile/binds/bindEventHandlers.d.ts.map +1 -0
  57. package/dist/compile/binds/bindEventHandlers.js +174 -0
  58. package/dist/compile/binds/bindEventHandlers.js.map +1 -0
  59. package/dist/compile/binds/bindRefDirectives.d.ts +14 -0
  60. package/dist/compile/binds/bindRefDirectives.d.ts.map +1 -0
  61. package/dist/compile/binds/bindRefDirectives.js +35 -0
  62. package/dist/compile/binds/bindRefDirectives.js.map +1 -0
  63. package/dist/compile/binds/bindTextInterpolations.d.ts +16 -0
  64. package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -0
  65. package/dist/compile/binds/bindTextInterpolations.js +408 -0
  66. package/dist/compile/binds/bindTextInterpolations.js.map +1 -0
  67. package/dist/compile/binds/directiveRegistry.d.ts +46 -0
  68. package/dist/compile/binds/directiveRegistry.d.ts.map +1 -0
  69. package/dist/compile/binds/directiveRegistry.js +50 -0
  70. package/dist/compile/binds/directiveRegistry.js.map +1 -0
  71. package/dist/compile/compileExpression.d.ts +10 -0
  72. package/dist/compile/compileExpression.d.ts.map +1 -0
  73. package/dist/compile/compileExpression.js +26 -0
  74. package/dist/compile/compileExpression.js.map +1 -0
  75. package/dist/compile/compileNodes.d.ts +32 -0
  76. package/dist/compile/compileNodes.d.ts.map +1 -0
  77. package/dist/compile/compileNodes.js +104 -0
  78. package/dist/compile/compileNodes.js.map +1 -0
  79. package/dist/compile/compileTemplate.d.ts +64 -0
  80. package/dist/compile/compileTemplate.d.ts.map +1 -0
  81. package/dist/compile/compileTemplate.js +157 -0
  82. package/dist/compile/compileTemplate.js.map +1 -0
  83. package/dist/compile/contentProjection.d.ts +29 -0
  84. package/dist/compile/contentProjection.d.ts.map +1 -0
  85. package/dist/compile/contentProjection.js +210 -0
  86. package/dist/compile/contentProjection.js.map +1 -0
  87. package/dist/compile/forLoops/bindForLoops.d.ts +21 -0
  88. package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -0
  89. package/dist/compile/forLoops/bindForLoops.js +151 -0
  90. package/dist/compile/forLoops/bindForLoops.js.map +1 -0
  91. package/dist/compile/forLoops/createLoopManager.d.ts +51 -0
  92. package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -0
  93. package/dist/compile/forLoops/createLoopManager.js +429 -0
  94. package/dist/compile/forLoops/createLoopManager.js.map +1 -0
  95. package/dist/compile/forLoops/index.d.ts +6 -0
  96. package/dist/compile/forLoops/index.d.ts.map +1 -0
  97. package/dist/compile/forLoops/index.js +8 -0
  98. package/dist/compile/forLoops/index.js.map +1 -0
  99. package/dist/compile/forLoops/loopHelpers.d.ts +33 -0
  100. package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -0
  101. package/dist/compile/forLoops/loopHelpers.js +69 -0
  102. package/dist/compile/forLoops/loopHelpers.js.map +1 -0
  103. package/dist/compile/forLoops/loopSignals.d.ts +36 -0
  104. package/dist/compile/forLoops/loopSignals.d.ts.map +1 -0
  105. package/dist/compile/forLoops/loopSignals.js +64 -0
  106. package/dist/compile/forLoops/loopSignals.js.map +1 -0
  107. package/dist/compile/forLoops/loopTraversal.d.ts +18 -0
  108. package/dist/compile/forLoops/loopTraversal.d.ts.map +1 -0
  109. package/dist/compile/forLoops/loopTraversal.js +38 -0
  110. package/dist/compile/forLoops/loopTraversal.js.map +1 -0
  111. package/dist/compile/handleConditionalChain.d.ts +15 -0
  112. package/dist/compile/handleConditionalChain.d.ts.map +1 -0
  113. package/dist/compile/handleConditionalChain.js +181 -0
  114. package/dist/compile/handleConditionalChain.js.map +1 -0
  115. package/dist/compile/index.d.ts +15 -0
  116. package/dist/compile/index.d.ts.map +1 -0
  117. package/dist/compile/index.js +19 -0
  118. package/dist/compile/index.js.map +1 -0
  119. package/dist/compile/injectScopedStyle.d.ts +16 -0
  120. package/dist/compile/injectScopedStyle.d.ts.map +1 -0
  121. package/dist/compile/injectScopedStyle.js +50 -0
  122. package/dist/compile/injectScopedStyle.js.map +1 -0
  123. package/dist/compile/nodeExpando.d.ts +12 -0
  124. package/dist/compile/nodeExpando.d.ts.map +1 -0
  125. package/dist/compile/nodeExpando.js +4 -0
  126. package/dist/compile/nodeExpando.js.map +1 -0
  127. package/dist/compile/parseHtml.d.ts +70 -0
  128. package/dist/compile/parseHtml.d.ts.map +1 -0
  129. package/dist/compile/parseHtml.js +164 -0
  130. package/dist/compile/parseHtml.js.map +1 -0
  131. package/dist/compile/pithyTreeToDom.d.ts +16 -0
  132. package/dist/compile/pithyTreeToDom.d.ts.map +1 -0
  133. package/dist/compile/pithyTreeToDom.js +118 -0
  134. package/dist/compile/pithyTreeToDom.js.map +1 -0
  135. package/dist/compile/renderChildren.d.ts +50 -0
  136. package/dist/compile/renderChildren.d.ts.map +1 -0
  137. package/dist/compile/renderChildren.js +76 -0
  138. package/dist/compile/renderChildren.js.map +1 -0
  139. package/dist/compile/ssrMode.d.ts +17 -0
  140. package/dist/compile/ssrMode.d.ts.map +1 -0
  141. package/dist/compile/ssrMode.js +20 -0
  142. package/dist/compile/ssrMode.js.map +1 -0
  143. package/dist/compile/textValue.d.ts +28 -0
  144. package/dist/compile/textValue.d.ts.map +1 -0
  145. package/dist/compile/textValue.js +30 -0
  146. package/dist/compile/textValue.js.map +1 -0
  147. package/dist/config/index.d.ts +37 -0
  148. package/dist/config/index.d.ts.map +1 -0
  149. package/dist/config/index.js +16 -0
  150. package/dist/config/index.js.map +1 -0
  151. package/dist/index.d.ts +7 -0
  152. package/dist/index.d.ts.map +1 -0
  153. package/dist/index.js +7 -0
  154. package/dist/index.js.map +1 -0
  155. package/dist/interfaces/index.d.ts +3 -0
  156. package/dist/interfaces/index.d.ts.map +1 -0
  157. package/dist/interfaces/index.js +3 -0
  158. package/dist/interfaces/index.js.map +1 -0
  159. package/dist/interfaces/ref-signal.interface.d.ts +6 -0
  160. package/dist/interfaces/ref-signal.interface.d.ts.map +1 -0
  161. package/dist/interfaces/ref-signal.interface.js +2 -0
  162. package/dist/interfaces/ref-signal.interface.js.map +1 -0
  163. package/dist/interfaces/ref.interface.d.ts +5 -0
  164. package/dist/interfaces/ref.interface.d.ts.map +1 -0
  165. package/dist/interfaces/ref.interface.js +2 -0
  166. package/dist/interfaces/ref.interface.js.map +1 -0
  167. package/dist/runtime/applyBindings.d.ts +36 -0
  168. package/dist/runtime/applyBindings.d.ts.map +1 -0
  169. package/dist/runtime/applyBindings.js +165 -0
  170. package/dist/runtime/applyBindings.js.map +1 -0
  171. package/dist/runtime/bindings/applyComponent.d.ts +3 -0
  172. package/dist/runtime/bindings/applyComponent.d.ts.map +1 -0
  173. package/dist/runtime/bindings/applyComponent.js +190 -0
  174. package/dist/runtime/bindings/applyComponent.js.map +1 -0
  175. package/dist/runtime/bindings/applyDefer.d.ts +11 -0
  176. package/dist/runtime/bindings/applyDefer.d.ts.map +1 -0
  177. package/dist/runtime/bindings/applyDefer.js +422 -0
  178. package/dist/runtime/bindings/applyDefer.js.map +1 -0
  179. package/dist/runtime/bindings/applySimple.d.ts +11 -0
  180. package/dist/runtime/bindings/applySimple.d.ts.map +1 -0
  181. package/dist/runtime/bindings/applySimple.js +346 -0
  182. package/dist/runtime/bindings/applySimple.js.map +1 -0
  183. package/dist/runtime/bindings/applyStructural.d.ts +5 -0
  184. package/dist/runtime/bindings/applyStructural.d.ts.map +1 -0
  185. package/dist/runtime/bindings/applyStructural.js +312 -0
  186. package/dist/runtime/bindings/applyStructural.js.map +1 -0
  187. package/dist/runtime/bindings/helpers.d.ts +56 -0
  188. package/dist/runtime/bindings/helpers.d.ts.map +1 -0
  189. package/dist/runtime/bindings/helpers.js +121 -0
  190. package/dist/runtime/bindings/helpers.js.map +1 -0
  191. package/dist/runtime/bindings/index.d.ts +7 -0
  192. package/dist/runtime/bindings/index.d.ts.map +1 -0
  193. package/dist/runtime/bindings/index.js +6 -0
  194. package/dist/runtime/bindings/index.js.map +1 -0
  195. package/dist/runtime/bindings/types.d.ts +105 -0
  196. package/dist/runtime/bindings/types.d.ts.map +1 -0
  197. package/dist/runtime/bindings/types.js +5 -0
  198. package/dist/runtime/bindings/types.js.map +1 -0
  199. package/dist/runtime/bootstrap.d.ts +59 -0
  200. package/dist/runtime/bootstrap.d.ts.map +1 -0
  201. package/dist/runtime/bootstrap.js +82 -0
  202. package/dist/runtime/bootstrap.js.map +1 -0
  203. package/dist/runtime/createContextProxy.d.ts +10 -0
  204. package/dist/runtime/createContextProxy.d.ts.map +1 -0
  205. package/dist/runtime/createContextProxy.js +45 -0
  206. package/dist/runtime/createContextProxy.js.map +1 -0
  207. package/dist/runtime/deferHelpers.d.ts +49 -0
  208. package/dist/runtime/deferHelpers.d.ts.map +1 -0
  209. package/dist/runtime/deferHelpers.js +65 -0
  210. package/dist/runtime/deferHelpers.js.map +1 -0
  211. package/dist/runtime/html.d.ts +23 -0
  212. package/dist/runtime/html.d.ts.map +1 -0
  213. package/dist/runtime/html.js +97 -0
  214. package/dist/runtime/html.js.map +1 -0
  215. package/dist/runtime/index.d.ts +8 -0
  216. package/dist/runtime/index.d.ts.map +1 -0
  217. package/dist/runtime/index.js +21 -0
  218. package/dist/runtime/index.js.map +1 -0
  219. package/dist/runtime/lazy.d.ts +144 -0
  220. package/dist/runtime/lazy.d.ts.map +1 -0
  221. package/dist/runtime/lazy.js +295 -0
  222. package/dist/runtime/lazy.js.map +1 -0
  223. package/dist/runtime/module-cache.d.ts +78 -0
  224. package/dist/runtime/module-cache.d.ts.map +1 -0
  225. package/dist/runtime/module-cache.js +109 -0
  226. package/dist/runtime/module-cache.js.map +1 -0
  227. package/dist/runtime/onDestroy.d.ts +29 -0
  228. package/dist/runtime/onDestroy.d.ts.map +1 -0
  229. package/dist/runtime/onDestroy.js +66 -0
  230. package/dist/runtime/onDestroy.js.map +1 -0
  231. package/dist/runtime/parseIdentifiersFromTemplate.d.ts +17 -0
  232. package/dist/runtime/parseIdentifiersFromTemplate.d.ts.map +1 -0
  233. package/dist/runtime/parseIdentifiersFromTemplate.js +68 -0
  234. package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -0
  235. package/dist/types/globals.d.ts +18 -0
  236. package/dist/types/globals.d.ts.map +1 -0
  237. package/dist/types/globals.js +4 -0
  238. package/dist/types/globals.js.map +1 -0
  239. package/dist/types/index.d.ts +11 -0
  240. package/dist/types/index.d.ts.map +1 -0
  241. package/dist/types/index.js +2 -0
  242. package/dist/types/index.js.map +1 -0
  243. package/dist/utilities/index.d.ts +3 -0
  244. package/dist/utilities/index.d.ts.map +1 -0
  245. package/dist/utilities/index.js +3 -0
  246. package/dist/utilities/index.js.map +1 -0
  247. package/dist/utilities/ref-signal.utility.d.ts +32 -0
  248. package/dist/utilities/ref-signal.utility.d.ts.map +1 -0
  249. package/dist/utilities/ref-signal.utility.js +46 -0
  250. package/dist/utilities/ref-signal.utility.js.map +1 -0
  251. package/dist/utilities/ref.untility.d.ts +37 -0
  252. package/dist/utilities/ref.untility.d.ts.map +1 -0
  253. package/dist/utilities/ref.untility.js +47 -0
  254. package/dist/utilities/ref.untility.js.map +1 -0
  255. package/package.json +55 -0
@@ -0,0 +1,7 @@
1
+ export * from './types';
2
+ export * from './compile';
3
+ export * from './runtime';
4
+ export * from './utilities';
5
+ export * from './interfaces';
6
+ export * from './a11y';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ export * from './types';
2
+ export * from './compile';
3
+ export * from './runtime';
4
+ export * from './utilities';
5
+ export * from './interfaces';
6
+ export * from './a11y';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './ref.interface';
2
+ export * from './ref-signal.interface';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './ref.interface';
2
+ export * from './ref-signal.interface';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface RefSignal<T extends HTMLElement = HTMLElement> {
2
+ (): T | null;
3
+ set: (el: T | null) => void;
4
+ current: T | null;
5
+ }
6
+ //# sourceMappingURL=ref-signal.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-signal.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/ref-signal.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW;IAC5D,IAAI,CAAC,GAAG,IAAI,CAAC;IACb,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5B,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ref-signal.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref-signal.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref-signal.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export interface Ref<T> {
2
+ readonly current: T | null;
3
+ set: (el: T | null) => void;
4
+ }
5
+ //# sourceMappingURL=ref.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/ref.interface.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,GAAG,CAAC,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAC3B,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ref.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ref.interface.js","sourceRoot":"","sources":["../../src/interfaces/ref.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.runtime.apply-bindings",
4
+ "title": "AOT Binding Applicator",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import { type Desc, type EventDesc, type InterpDesc, type ClassDesc, type StyleDesc, type BoundDesc, type RefDesc, type BindDesc, type CompDesc, type DeferDesc, type ErrorDesc, type ProjDesc, type IfDesc, type ForDesc, type SwitchDesc } from './bindings';
9
+ export type { Desc, EventDesc, InterpDesc, ClassDesc, StyleDesc, BoundDesc, RefDesc, BindDesc, CompDesc, DeferDesc, ErrorDesc, ProjDesc, IfDesc, ForDesc, SwitchDesc, };
10
+ /**
11
+ * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
12
+ *
13
+ * This is the Phase 5 runtime binder — the counterpart to the build-time
14
+ * codegen (Phases 1-4). It processes descriptor arrays emitted by
15
+ * generateDomFactory + generateBindings and wires reactive effects,
16
+ * event handlers, component mounts, and structural directive logic.
17
+ *
18
+ * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:
19
+ * 1. Structural: switch → if → for
20
+ * 2. Non-structural: ref → error → projection → component → bind →
21
+ * interpolation → event → class → style → bound attr → defer
22
+ *
23
+ * Differences from JIT bindTemplateDirectives:
24
+ * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)
25
+ * - AOT omits the `custom-directive` step (router directives handled at build time)
26
+ *
27
+ * @param fragment - DOM fragment created by the AOT factory function
28
+ * @param bindings - Array of binding descriptors from codegen
29
+ * @param context - Reactive context object with signals, methods, components
30
+ */
31
+ /** @codexApi {"parent":"pithy.runtime.apply-bindings","name":"__applyBindings","stability":"experimental","signature":"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>) => { el: DocumentFragment; destroy: () => void }"} */
32
+ export declare function __applyBindings(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>): {
33
+ el: DocumentFragment;
34
+ destroy: () => void;
35
+ };
36
+ //# sourceMappingURL=applyBindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyBindings.d.ts","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAGF,OAAO,EAkBL,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,KAAK,MAAM,EACX,KAAK,OAAO,EACZ,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AAGpB,YAAY,EACV,IAAI,EACJ,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,SAAS,EACT,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,UAAU,GACX,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,8PAA8P;AAC9P,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,QAAQ,EAAE,IAAI,EAAE,EAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B;IAAE,EAAE,EAAE,gBAAgB,CAAC;IAAC,OAAO,EAAE,MAAM,IAAI,CAAA;CAAE,CAuI/C"}
@@ -0,0 +1,165 @@
1
+ /** @codex
2
+ {
3
+ "id": "pithy.runtime.apply-bindings",
4
+ "title": "AOT Binding Applicator",
5
+ "category": "runtime"
6
+ }
7
+ */
8
+ import { drainDestroyCallbacks } from './onDestroy';
9
+ import { buildPidMap, buildCommentMap, mergeContexts, applyRef, applyError, applyProjection, applyComponent, applyBind, applyInterpolation, applyEvent, applyClass, applyStyle, applyBound, applyIf, applyFor, applySwitch, applyDefer, } from './bindings';
10
+ // ─── Main entry point ─────────────────────────────────────────────────────────
11
+ /**
12
+ * Applies pre-extracted binding descriptors to an AOT-generated DOM fragment.
13
+ *
14
+ * This is the Phase 5 runtime binder — the counterpart to the build-time
15
+ * codegen (Phases 1-4). It processes descriptor arrays emitted by
16
+ * generateDomFactory + generateBindings and wires reactive effects,
17
+ * event handlers, component mounts, and structural directive logic.
18
+ *
19
+ * **Binding order** mirrors (but is not identical to) bindTemplateDirectives:
20
+ * 1. Structural: switch → if → for
21
+ * 2. Non-structural: ref → error → projection → component → bind →
22
+ * interpolation → event → class → style → bound attr → defer
23
+ *
24
+ * Differences from JIT bindTemplateDirectives:
25
+ * - AOT has an explicit `style` phase (JIT folds inline styles into bound attrs)
26
+ * - AOT omits the `custom-directive` step (router directives handled at build time)
27
+ *
28
+ * @param fragment - DOM fragment created by the AOT factory function
29
+ * @param bindings - Array of binding descriptors from codegen
30
+ * @param context - Reactive context object with signals, methods, components
31
+ */
32
+ /** @codexApi {"parent":"pithy.runtime.apply-bindings","name":"__applyBindings","stability":"experimental","signature":"(fragment: DocumentFragment, bindings: Desc[], context: Record<string, unknown>) => { el: DocumentFragment; destroy: () => void }"} */
33
+ export function __applyBindings(fragment, bindings, context) {
34
+ // Drain onDestroy() callbacks BEFORE processing bindings — child components
35
+ // instantiated during binding will drain their own callbacks independently.
36
+ const destroyCallbacks = drainDestroyCallbacks();
37
+ const disposers = [];
38
+ // Merge parent component + async (SSR) contexts — AOT factories bypass html()
39
+ const ctx = mergeContexts(context);
40
+ // Build lookup maps
41
+ const pidMap = buildPidMap(fragment);
42
+ const commentMap = buildCommentMap(fragment);
43
+ // Group descriptors by type for ordered processing
44
+ const byType = new Map();
45
+ for (const d of bindings) {
46
+ const list = byType.get(d.t) ?? [];
47
+ list.push(d);
48
+ byType.set(d.t, list);
49
+ }
50
+ try {
51
+ // ─── Phase 1: Structural directives (shape-changing) ─────────────────
52
+ // Order: switch → if → for (matches bindStructuralDirectives)
53
+ for (const d of (byType.get('switch') ?? [])) {
54
+ applySwitch(d, pidMap, ctx, disposers);
55
+ }
56
+ for (const d of (byType.get('if') ?? [])) {
57
+ applyIf(d, commentMap, ctx, disposers);
58
+ }
59
+ for (const d of (byType.get('for') ?? [])) {
60
+ applyFor(d, commentMap, ctx, disposers);
61
+ }
62
+ // ─── Phase 2: Non-structural bindings ────────────────────────────────
63
+ // Order matches bindTemplateDirectives: ref → error → proj → comp →
64
+ // bind → interp → event → class → style → bound → defer
65
+ for (const d of (byType.get('ref') ?? [])) {
66
+ const el = pidMap.get(d.pid);
67
+ if (el)
68
+ applyRef(d, el, ctx, disposers);
69
+ }
70
+ for (const d of (byType.get('error') ?? [])) {
71
+ const el = pidMap.get(d.pid);
72
+ if (el)
73
+ applyError(d, el, ctx, disposers);
74
+ }
75
+ for (const d of (byType.get('proj') ?? [])) {
76
+ applyProjection(d, commentMap, ctx, disposers);
77
+ }
78
+ for (const d of (byType.get('comp') ?? [])) {
79
+ const el = pidMap.get(d.pid);
80
+ if (el)
81
+ applyComponent(d, el, ctx, disposers, pidMap);
82
+ }
83
+ for (const d of (byType.get('bind') ?? [])) {
84
+ const el = pidMap.get(d.pid);
85
+ if (el)
86
+ applyBind(d, el, ctx, disposers);
87
+ }
88
+ for (const d of (byType.get('interp') ?? [])) {
89
+ // pid === '' means root-level text node (no parent element with data-pid)
90
+ const el = d.pid === '' ? fragment : pidMap.get(d.pid);
91
+ if (el)
92
+ applyInterpolation(d, el, ctx, disposers);
93
+ }
94
+ for (const d of (byType.get('event') ?? [])) {
95
+ const el = pidMap.get(d.pid);
96
+ if (el)
97
+ applyEvent(d, el, ctx, disposers);
98
+ }
99
+ for (const d of (byType.get('class') ?? [])) {
100
+ const el = pidMap.get(d.pid);
101
+ if (el)
102
+ applyClass(d, el, ctx, disposers);
103
+ }
104
+ for (const d of (byType.get('style') ?? [])) {
105
+ const el = pidMap.get(d.pid);
106
+ if (el)
107
+ applyStyle(d, el, ctx, disposers);
108
+ }
109
+ for (const d of (byType.get('bound') ?? [])) {
110
+ const el = pidMap.get(d.pid);
111
+ if (el)
112
+ applyBound(d, el, ctx, disposers);
113
+ }
114
+ for (const d of (byType.get('defer') ?? [])) {
115
+ const el = pidMap.get(d.pid);
116
+ if (el)
117
+ applyDefer(d, el, ctx, disposers);
118
+ }
119
+ }
120
+ catch (err) {
121
+ // Clean up any disposers already registered during partial binding
122
+ for (let i = disposers.length - 1; i >= 0; i--) {
123
+ try {
124
+ disposers[i]();
125
+ }
126
+ catch {
127
+ /* ignore */
128
+ }
129
+ }
130
+ for (let i = destroyCallbacks.length - 1; i >= 0; i--) {
131
+ try {
132
+ destroyCallbacks[i]();
133
+ }
134
+ catch {
135
+ /* ignore */
136
+ }
137
+ }
138
+ throw err;
139
+ }
140
+ return {
141
+ el: fragment,
142
+ destroy() {
143
+ // Reverse order: child disposers (pushed later) run before parents
144
+ for (let i = disposers.length - 1; i >= 0; i--) {
145
+ try {
146
+ disposers[i]();
147
+ }
148
+ catch {
149
+ /* ignore disposal errors */
150
+ }
151
+ }
152
+ disposers.length = 0;
153
+ // onDestroy callbacks in LIFO order, after template disposers
154
+ for (let i = destroyCallbacks.length - 1; i >= 0; i--) {
155
+ try {
156
+ destroyCallbacks[i]();
157
+ }
158
+ catch {
159
+ /* ignore disposal errors */
160
+ }
161
+ }
162
+ },
163
+ };
164
+ }
165
+ //# sourceMappingURL=applyBindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyBindings.js","sourceRoot":"","sources":["../../src/runtime/applyBindings.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EACL,WAAW,EACX,eAAe,EACf,aAAa,EACb,QAAQ,EACR,UAAU,EACV,eAAe,EACf,cAAc,EACd,SAAS,EACT,kBAAkB,E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E,CAAC;YACjB,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACtD,IAAI,CAAC;gBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,YAAY;YACd,CAAC;QACH,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,QAAQ;QACZ,OAAO;YACL,mEAAmE;YACnE,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC/C,IAAI,CAAC;oBACH,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;YACD,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;YACrB,8DAA8D;YAC9D,KAAK,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;gBACtD,IAAI,CAAC;oBACH,gBAAgB,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,CAAC;gBAAC,MAAM,CAAC;oBACP,4BAA4B;gBAC9B,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CompDesc, BindingContext } from './types';
2
+ export declare function applyComponent(d: CompDesc, el: Element, ctx: BindingContext, disposers: (() => void)[], pidMap: Map<string, Element>): void;
3
+ //# sourceMappingURL=applyComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyComponent.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AA4DxD,wBAAgB,cAAc,CAC5B,CAAC,EAAE,QAAQ,EACX,EAAE,EAAE,OAAO,EACX,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,EACzB,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,GAC3B,IAAI,CAuJN"}
@@ -0,0 +1,190 @@
1
+ import { compileExpression } from '../../compile/compileExpression';
2
+ import { boundaryForElement, setBoundaryError, runWithBoundary, } from '../../compile/binds/bindErrorBoundary';
3
+ import { nativeTags } from '@pithyjs/compiler';
4
+ import { nearestCtx } from './helpers';
5
+ import { pithyGlobals } from '../../types/globals';
6
+ /** Map kebab-case or lowered DOM attr name to expected camelCase prop name. */
7
+ function normalizePropName(authored, expectedProps) {
8
+ if (expectedProps.length === 0)
9
+ return authored;
10
+ const map = new Map(expectedProps.map(p => [p.toLowerCase(), p]));
11
+ return map.get(authored.toLowerCase()) ?? authored;
12
+ }
13
+ /** Cache for extractExpectedPropNames to avoid re-parsing the same function. */
14
+ const propNamesCache = new WeakMap();
15
+ /**
16
+ * Extract destructured prop names from component function signature.
17
+ * NOTE: Uses fn.toString() which may return mangled names under aggressive
18
+ * minification (Terser). In that case, prop name normalization becomes a
19
+ * no-op and props are passed as-is (kebab/lowered). This is acceptable
20
+ * because Vite's default esbuild minifier preserves parameter names.
21
+ */
22
+ function extractExpectedPropNames(fn) {
23
+ const cached = propNamesCache.get(fn);
24
+ if (cached)
25
+ return cached;
26
+ try {
27
+ const src = fn.toString();
28
+ const m = src.match(/\(\s*\{\s*([^}]*)\s*\}/);
29
+ if (!m) {
30
+ propNamesCache.set(fn, []);
31
+ return [];
32
+ }
33
+ const names = m[1]
34
+ .split(',')
35
+ .map(s => s.trim())
36
+ .filter(Boolean)
37
+ .filter(s => !s.startsWith('...'))
38
+ .map(s => s.split(/[:=]/)[0].trim());
39
+ // Detect likely minification: single-char names suggest mangled output
40
+ if (import.meta.env?.DEV &&
41
+ names.length > 0 &&
42
+ names.every(n => n.length === 1)) {
43
+ console.warn(`[AOT] extractExpectedPropNames: detected single-char names (${names.join(',')}) — prop normalization may not work under minification`);
44
+ }
45
+ propNamesCache.set(fn, names);
46
+ return names;
47
+ }
48
+ catch {
49
+ return [];
50
+ }
51
+ }
52
+ export function applyComponent(d, el, ctx, disposers, pidMap) {
53
+ // Skip native HTML elements — prevents <div> matching a `div` in context.
54
+ // Only apply when the authored tag is already lowercase; PascalCase tags like
55
+ // <Button> are valid components even though "button" is a native tag.
56
+ const tagLower = d.tag.toLowerCase();
57
+ if (d.tag === tagLower && nativeTags.has(tagLower))
58
+ return;
59
+ // Case-insensitive tag lookup
60
+ let candidate;
61
+ for (const key of Object.keys(ctx)) {
62
+ if (key.toLowerCase() === tagLower) {
63
+ candidate = ctx[key];
64
+ break;
65
+ }
66
+ }
67
+ if (!candidate)
68
+ return;
69
+ // Support default exports
70
+ if (candidate &&
71
+ typeof candidate === 'object' &&
72
+ 'default' in candidate &&
73
+ typeof candidate.default === 'function') {
74
+ candidate = candidate.default;
75
+ }
76
+ if (typeof candidate !== 'function')
77
+ return;
78
+ const componentFn = candidate;
79
+ const localCtx = nearestCtx(el, ctx);
80
+ // Extract expected props for case-insensitive normalization
81
+ const expectedProps = extractExpectedPropNames(componentFn);
82
+ // Evaluate prop expressions with prop name normalization
83
+ const props = {};
84
+ for (const [rawName, expr] of Object.entries(d.props)) {
85
+ const propName = normalizePropName(rawName, expectedProps);
86
+ try {
87
+ const fn = compileExpression(expr, localCtx);
88
+ props[propName] = fn();
89
+ }
90
+ catch {
91
+ // Leave undefined — child uses defaults
92
+ }
93
+ }
94
+ // Collect slot content from el's children — move original nodes instead
95
+ // of cloning to preserve any expandos (__pithyCtx) and event listeners.
96
+ // The placeholder el is about to be replaced, so its children are orphaned anyway.
97
+ const slotMap = new Map();
98
+ const children = Array.from(el.childNodes);
99
+ const slotGroups = new Map();
100
+ for (const child of children) {
101
+ const slotName = child.nodeType === Node.ELEMENT_NODE
102
+ ? child.getAttribute('slot') || ''
103
+ : '';
104
+ if (!slotGroups.has(slotName))
105
+ slotGroups.set(slotName, []);
106
+ slotGroups.get(slotName).push(child);
107
+ }
108
+ for (const [slotName, nodes] of slotGroups) {
109
+ slotMap.set(slotName, () => {
110
+ const frag = document.createDocumentFragment();
111
+ for (const node of nodes) {
112
+ frag.appendChild(node);
113
+ }
114
+ return frag;
115
+ });
116
+ }
117
+ const componentContext = { ...localCtx, __slotMap: slotMap };
118
+ // Find nearest error boundary
119
+ const boundaryEl = el.closest('[data-error]');
120
+ const boundary = boundaryForElement(boundaryEl);
121
+ let out;
122
+ try {
123
+ out = runWithBoundary(boundary, () => {
124
+ const g = pithyGlobals();
125
+ const originalContext = g.__pithyComponentContext;
126
+ const wasRendering = g.__pithyRenderingComponent;
127
+ g.__pithyComponentContext = componentContext;
128
+ g.__pithyRenderingComponent = true;
129
+ try {
130
+ return componentFn(props);
131
+ }
132
+ finally {
133
+ g.__pithyComponentContext = originalContext;
134
+ g.__pithyRenderingComponent = wasRendering;
135
+ }
136
+ });
137
+ }
138
+ catch (err) {
139
+ if (boundary) {
140
+ setBoundaryError(boundary, err instanceof Error ? err : new Error(String(err)));
141
+ return;
142
+ }
143
+ console.error(`[AOT] Component <${d.tag}> crashed:`, err);
144
+ return;
145
+ }
146
+ if (!out || typeof out !== 'object' || !('el' in out))
147
+ return;
148
+ const { el: renderedEl, destroy } = out;
149
+ // Capture rendered root element before fragment is consumed by replaceWith
150
+ const forwardedClass = el.getAttribute('class');
151
+ const renderedRoot = renderedEl instanceof DocumentFragment
152
+ ? renderedEl.firstElementChild
153
+ : renderedEl instanceof HTMLElement
154
+ ? renderedEl
155
+ : null;
156
+ try {
157
+ if (renderedEl instanceof DocumentFragment) {
158
+ el.replaceWith(...Array.from(renderedEl.childNodes));
159
+ }
160
+ else {
161
+ el.replaceWith(renderedEl);
162
+ }
163
+ }
164
+ catch (err) {
165
+ console.error(`[AOT] Failed to replace <${d.tag}>:`, err);
166
+ }
167
+ if (forwardedClass && renderedRoot) {
168
+ for (const cls of forwardedClass.split(/\s+/)) {
169
+ if (cls)
170
+ renderedRoot.classList.add(cls);
171
+ }
172
+ }
173
+ // Re-target the component pid to the rendered root so subsequent binding
174
+ // passes (event, bound, class, style) apply to the component's actual DOM
175
+ // element. This matches the JIT path where data-on-* attributes are
176
+ // forwarded from the placeholder to the rendered root.
177
+ if (renderedRoot) {
178
+ pidMap.set(d.pid, renderedRoot);
179
+ }
180
+ else {
181
+ if (import.meta.env?.DEV &&
182
+ (forwardedClass || (d.props && Object.keys(d.props).length > 0))) {
183
+ console.warn(`[AOT] <${d.tag}> has forwarded attributes but returns a fragment with no single root element — forwarding skipped.`);
184
+ }
185
+ pidMap.delete(d.pid);
186
+ }
187
+ if (typeof destroy === 'function')
188
+ disposers.push(destroy);
189
+ }
190
+ //# sourceMappingURL=applyComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyComponent.js","sourceRoot":"","sources":["../../../src/runtime/bindings/applyComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,GAChB,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQnD,+EAA+E;AAC/E,SAAS,iBAAiB,CAAC,QAAgB,EAAE,aAAuB;IAClE,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAChD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,GAAG,CAAC,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C;QAC3C,CAAC;IACH,CAAC;IAED,yEAAyE;IACzE,0EAA0E;IAC1E,oEAAoE;IACpE,uDAAuD;IACvD,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;IAClC,CAAC;SAAM,CAAC;QACN,IACE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG;YACpB,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,EAChE,CAAC;YACD,OAAO,CAAC,IAAI,CACV,UAAU,CAAC,CAAC,GAAG,qGAAqG,CACrH,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { DeferDesc, BindingContext } from './types';
2
+ /**
3
+ * Apply @defer directive from a binding descriptor.
4
+ *
5
+ * Mirrors the JIT `bindDeferDirectives.ts` logic, adapted for descriptor-driven
6
+ * input. Handles visible/when triggers, priority scheduling, timeout, mount
7
+ * generation guards, placeholder/error slot management, error boundary
8
+ * integration, external retry, and full cleanup.
9
+ */
10
+ export declare function applyDefer(d: DeferDesc, element: HTMLElement, ctx: BindingContext, disposers: (() => void)[]): void;
11
+ //# sourceMappingURL=applyDefer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"applyDefer.d.ts","sourceRoot":"","sources":["../../../src/runtime/bindings/applyDefer.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AASzD;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,CAAC,EAAE,SAAS,EACZ,OAAO,EAAE,WAAW,EACpB,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,GACxB,IAAI,CAwdN"}