arcanajs 6.1.0-beta.2 → 6.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.
@@ -1 +1 @@
1
- {"version":3,"file":"arcanajs.js","mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACj4CA;AAAA;;AAuGA;AAAA;;;AA5GA;;;;;;;;;;;;;;AAKA;AAWA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAKA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AA/FA;AAHA;AACA;AAGA;AACA;AACA;AACA;AA4FA;AApGA;AAsGA;;;;;;;;;;;;;;;;;;;;;;;ACpEA;AAAA;;AAnBA;AAAA;;AASA;AAAA;;AApBA;AAAA;;;AAVA;AAIA;AACA;AAKA;AAIA;AACA;AACA;AAKA;AAGA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;;;;;;;;;;;;;;;;AC7BA;;;AAAA;;;AAbA;AACA;AAEA;;;;;;;;;;;;;;AAUA;AAUA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAGA;AACA;AACA;AAIA;AACA;AAEA;AAKA;AAEA;AACA;AACA;AApFA;AACA;AACA;AACA;AACA;AAiFA;;;;;;;;;;;;;;;;ACjEA;;;AAAA;;;AArCA;AACA;AACA;AAKA;;;;;;;;;;;;;;;;;;;AA8BA;AAIA;;AAEA;AAEA;AAEA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AAEA;AACA;AAEA;;AAEA;AAMA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAKA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;;AA1KA;AACA;;AA0KA;;;;;;;;;;;;;;;;;;;;;;;AC/LA;AAAA;;AAVA;AAAA;;AA6FA;AAAA;;AA1FA;AAAA;;AAAA;AAAA;;AAgCA;AAAA;;AAhCA;AAAA;;AAmDA;AAAA;;AACA;AAAA;;AApDA;AAAA;;AAQA;AAAA;;AACA;AAAA;;AACA;AAAA;;AAiDA;AAAA;;AACA;AAAA;;AAqBA;AAAA;;AARA;AAAA;;AACA;AAAA;;AAcA;AAAA;;AAlBA;AAAA;;AAmEA;AAAA;;AA1HA;AAAA;;AA0EA;AAAA;;AAxCA;AAAA;;AAjCA;AAAA;;AAkCA;AAAA;;AAyCA;AAAA;;AAZA;AAAA;;AACA;AAAA;;AArDA;AAAA;;AA4CA;AAAA;;AAtDA;AAAA;;AAWA;AAAA;;AAVA;AAAA;;AACA;AAAA;;AAUA;AAAA;;AA6BA;AAAA;;AA5BA;AAAA;;AACA;AAAA;;AA8BA;AAAA;;AA+BA;AAAA;;AAVA;AAAA;;AAjDA;AAAA;;AAuCA;AAAA;;AAqBA;AAAA;;AA3DA;AAAA;;;AA5CA;AAUA;AAWA;AASA;AAeA;AAkBA;AASA;AAaA;AAQA;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA;AAIA;AAAA;AAAA;AACA;AACA;;;;;;;;;;;;;;;;AChHA;;;AAAA;;;AAzCA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;AA6BA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAKA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;AChBA;AAAA;;AAGA;AAAA;;AACA;AAAA;;AAFA;AAAA;;AAGA;AAAA;;AARA;AAAA;;;AA1HA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAEA;;AAEA;AAqCA;;AAEA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AAKA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AA7FA;AAbA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAGA;AACA;AACA;AA0EA;AAEA;;;;;;;;;;;;;;;;;;;ACtHA;;;AAFA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AC3BA;;;AAAA;;;AALA;;;;;;AAGA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;AClCA;;;AAAA;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;AC+HA;AAAA;;AAwBA;AAAA;;AAwBA;AAAA;;AAuBA;AAAA;;AAAA;AAAA;;;AAvMA;;;;;;;AAOA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAEA;;;AAGA;AAKA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAqBA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AASA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAKA;AAIA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AC3MA;;;AAFA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AC5BA;;;AAAA;;;AAAA;AAKA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACgHA;AAAA;;AAiWA;AAAA;;AAxcA;AAAA;;AAgoBA;AAAA;;AACA;AAAA;;;AA/qBA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAcA;;AAEA;AAIA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AArBA;AA0BA;AAoBA;;;;;;AAMA;AAEA;AACA;AACA;AACA;AAEA;;;;;AAKA;AAEA;AAEA;AACA;AAEA;;;;;;;;AAQA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AAIA;AAEA;;AAEA;AAEA;AACA;AAzFA;AAPA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAgFA;AAKA;AAaA;;AAEA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;;AAGA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAIA;AAEA;AAEA;AAIA;AACA;AAGA;AACA;AACA;AAKA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAOA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AAAA;AAGA;AACA;AAOA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AAEA;AAGA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AApVA;AANA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAiVA;AAKA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAKA;AACA;AACA;AAEA;;;;;;AAMA;AAMA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;AAKA;AAEA;AACA;AAEA;;;;;AAKA;AAKA;AACA;AACA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;;;;;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AArLA;AACA;AAuLA;;;;;;;;;;;;;;;;ACnrBA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAOA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAvBA;AAFA;AAGA;AACA;AAsBA;;;;;;;;;;;;;;;;ACvBA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AASA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAlCA;AAHA;AACA;AAGA;AACA;AACA;AAgCA;;;;;;;;;;;;;;;;ACnCA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAoBA;;AAEA;AAEA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAjJA;AATA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AA0IA;;;;;;;;;;;;;;;;AC/IA;;;AAAA;;;AAvBA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAcA;AAeA;;AAEA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AAMA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAKA;AAEA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAOA;AACA;AAKA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AA5MA;AAHA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoMA;;;;;;;;;;;;;;;;AC9NA;;;AAAA;;;AAPA;;;;;;;;;;;;;;AAOA;AAUA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAvFA;AAJA;AACA;AACA;AAGA;AACA;AACA;AAqFA;;;;;;;;;;;;;;;;AC5FA;;;AAAA;;;AAXA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAMA;AAOA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAMA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAMA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAhIA;AAFA;AAGA;AACA;AA+HA;;;;;;;;;;;;;;;;ACTA;;;AAAA;;;;AAtIA;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAGA;AAGA;AAEA;;;;;;;;;;;;;;;;ACoIA;;;AAAA;;;AA1QA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;;AAEA;AAMA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;;;;;;;;;;;;;;ACrCA;;;AAAA;;;;AArOA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AAgBA;AACA;AAOA;AACA;AAEA;AAEA;AACA;AAMA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AAOA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;ACvGA;;;AAAA;;;;AA9HA;AACA;;;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA;AAUA;AACA;AAEA;AACA;AAAA;AAAA;;AACA;;AAEA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;;;;;;;AAGA;;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;ACtHA;;;AAAA;;;AARA;AACA;;;;;;AAOA;;;;;;;;;;;;;;;;ACLA;;;AAAA;;;AAHA;AAGA;;;;;;;;;;;;;;;;;;;;;;;ACyCA;AAAA;;AAQA;AAAA;;AAYA;AAAA;;AAkDA;AAAA;;;;AAlHA;AACA;;;;;;AA2BA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAQA;AAIA;AACA;AAAA;;;;;;AAEA;AAKA;;AAGA;AAEA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;AClEA;AAAA;;AAKA;AAAA;;AAYA;AAAA;;AAyBA;AAAA;;;;AAtIA;AACA;;;;;;AA2FA;AAKA;AAIA;AACA;AAAA;;;;;;AAEA;AAKA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAKA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;ACtEA;;;AAAA;;;;AA1EA;AAKA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;AAMA;AAeA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;AACA;AAIA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;;AAEA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAEA;;AAEA;AAGA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAGA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;;;;;AAAA;AAMA;AACA;AACA;AAAA;AAAA;AAAA;;;;;;;;;;;AAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;;;;;AAAA;AAAA;;;;;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;AC3hBA;AAAA;;AAcA;AAAA;;;;AA3BA;AACA;;;;;;AAYA;AAOA;AACA;AACA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;;;;;;;;ACSA;AAAA;;AA8CA;AAAA;;AAtCA;AAAA;;AAyJA;AAAA;;AA1HA;AAAA;;AARA;AAAA;;AAuBA;AAAA;;;AA1FA;AACA;AA+BA;AACA;AACA;AAEA;AAQA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AAKA;AACA;AAEA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA;AAQA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;AClMA;;;AAAA;;;AAHA;AACA;AAEA;;;;;;;;;;;;;;;;AC8HA;;;AAAA;;;AAjIA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAEA;AAEA;AACA;AACA;AAEA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAGA;AAEA;AACA;AAOA;;;;;;;;;;;;;;;;;;;;;;;AC7FA;AAAA;;AA2FA;AAAA;;AAjEA;AAAA;;AAPA;AAAA;;AAXA;AAAA;;;AA5CA;AACA;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAGA;AAQA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;ACjHA;AAAA;;AAQA;AAAA;;AAmGA;AAAA;;AAMA;AAAA;;AApBA;AAAA;;AAOA;AAAA;;;;AAlHA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;AACA;AAGA;AAQA;AAIA;AACA;AACA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;;;;;;;;AAuBA;AAKA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AACA;AAAA;AAAA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;ACpHA;;;AAAA;;;AAXA;AAWA;AAIA;AACA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;ACvBA;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;AAOA;AAAA;;AAmCA;AAAA;;AA8FA;AAAA;;AAsBA;AAAA;;AAzCA;AAAA;;AA/BA;AAAA;;AA/BA;AAAA;;AApBA;AAAA;;AA8FA;AAAA;;;;;;;;;;;;;;;;AA1HA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAEA;AACA;AAQA;AAGA;AACA;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAUA;AACA;AACA;AAUA;AACA;AACA;AAKA;AACA;AAOA;AAcA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;AC9LA;;;AAAA;;;;AAVA;AACA;AACA;AACA;;;;;;AAOA;AAKA;AAEA;;AAEA;;AACA;;AAAA;AAAA;;;;;;;AACA;AAAA;AAAA;;;;;;;;;;;;AAEA;AACA;AAAA;;AAEA;AAAA;;AACA;AAAA;;;;;;AACA;AAAA;;;;;;AACA;AACA;AACA;AAAA;AAAA;;;;;;AAEA;AAAA;;;;;;;;;;;;AAGA;AAAA;;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;AACA;AAAA;AAAA;;;;;;;;;;;AAEA;AAAA;AACA;;;;;;AAEA;AAAA;AAAA;;;;;;AAGA;AAAA;AACA;;;;;;;;;;;;AAIA;AAAA;;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;;;;;;;AAKA;AACA;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;;;;;;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AAIA;AAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;AAOA;AAAA;;AAAA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;ACjIA;;;AAAA;;;;AARA;AACA;AACA;AACA;;;;;;AAKA;AACA;;AAEA;;AACA;AAAA;;;;;;AACA;AACA;AACA;;;;;;;;;;;;AAGA;AACA;AAAA;;AAEA;AAAA;;AACA;AAAA;;;;;;AACA;AAAA;;;;;;AACA;AACA;AACA;AAAA;AAAA;;;;;;AAEA;AAAA;;;;;;;;;;;;AAGA;AAAA;;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;AAAA;;;;;;AAGA;AAAA;AAAA;;;;;;AAGA;AAAA;AACA;;AACA;AACA;AAAA;;AAAA;AAAA;AAAA;;;;;;;AAAA;AAAA;;AAIA;;;;;;;;;;;;AAKA;AAAA;;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;AAKA;AAAA;;AAAA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AC7GA;;;;;;AAMA;;;;AACA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAGA;;;;;;;;;AASA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;AAOA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAtGA;;;;;;;;;;;;ACRA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AEvBA;AACA;AACA;AACA","sources":["webpack://arcanajs/./node_modules/reflect-metadata/Reflect.js","webpack://arcanajs/./src/lib/di/Container.ts","webpack://arcanajs/./src/lib/di/decorators/metadata.ts","webpack://arcanajs/./src/lib/di/providers/AutoRegisterProvider.ts","webpack://arcanajs/./src/lib/di/support/ClassScanner.ts","webpack://arcanajs/./src/lib/index.server.ts","webpack://arcanajs/./src/lib/server/ArcanaJSMiddleware.ts","webpack://arcanajs/./src/lib/server/ArcanaJSServer.ts","webpack://arcanajs/./src/lib/server/ControllerBinder.ts","webpack://arcanajs/./src/lib/server/CsrfMiddleware.ts","webpack://arcanajs/./src/lib/server/DefaultTemplate.ts","webpack://arcanajs/./src/lib/server/DynamicRouter.ts","webpack://arcanajs/./src/lib/server/MiddlewareBinder.ts","webpack://arcanajs/./src/lib/server/ResponseHandlerMiddleware.ts","webpack://arcanajs/./src/lib/server/Router.ts","webpack://arcanajs/./src/lib/server/ServiceProvider.ts","webpack://arcanajs/./src/lib/server/config/ConfigurationManager.ts","webpack://arcanajs/./src/lib/server/lifecycle/ServerLifecycle.ts","webpack://arcanajs/./src/lib/server/middleware/MiddlewareManager.ts","webpack://arcanajs/./src/lib/server/providers/ProviderManager.ts","webpack://arcanajs/./src/lib/server/views/ViewsResolver.ts","webpack://arcanajs/./src/lib/shared/components/Body.tsx","webpack://arcanajs/./src/lib/shared/components/Head.tsx","webpack://arcanajs/./src/lib/shared/components/Link.tsx","webpack://arcanajs/./src/lib/shared/components/Page.tsx","webpack://arcanajs/./src/lib/shared/context/HeadContext.tsx","webpack://arcanajs/./src/lib/shared/context/PageContext.tsx","webpack://arcanajs/./src/lib/shared/context/RequestContext.tsx","webpack://arcanajs/./src/lib/shared/context/RouterContext.tsx","webpack://arcanajs/./src/lib/shared/core/ArcanaJSApp.tsx","webpack://arcanajs/./src/lib/shared/core/PageProvider.tsx","webpack://arcanajs/./src/lib/shared/hooks/useError.ts","webpack://arcanajs/./src/lib/shared/hooks/useHead.ts","webpack://arcanajs/./src/lib/shared/hooks/useRouter.ts","webpack://arcanajs/./src/lib/shared/hooks/useRuntimeConfig.ts","webpack://arcanajs/./src/lib/shared/hooks/useState.tsx","webpack://arcanajs/./src/lib/shared/utils/createSingletonContext.ts","webpack://arcanajs/./src/lib/shared/utils/redirect.ts","webpack://arcanajs/./src/lib/shared/views/ErrorPage.tsx","webpack://arcanajs/./src/lib/shared/views/NotFoundPage.tsx","webpack://arcanajs/./src/utils/ModuleLoader.ts","webpack://arcanajs/external commonjs \"arcanajs-views\"","webpack://arcanajs/external commonjs \"compression\"","webpack://arcanajs/external commonjs \"cookie-parser\"","webpack://arcanajs/external node-commonjs \"crypto\"","webpack://arcanajs/external commonjs \"express\"","webpack://arcanajs/external node-commonjs \"fs\"","webpack://arcanajs/external commonjs \"helmet\"","webpack://arcanajs/external node-commonjs \"node:fs\"","webpack://arcanajs/external node-commonjs \"node:path\"","webpack://arcanajs/external node-commonjs \"path\"","webpack://arcanajs/external commonjs \"react\"","webpack://arcanajs/external commonjs \"react-dom/server\"","webpack://arcanajs/external commonjs \"react/jsx-dev-runtime\"","webpack://arcanajs/webpack/bootstrap","webpack://arcanajs/webpack/before-startup","webpack://arcanajs/webpack/startup","webpack://arcanajs/webpack/after-startup"],"sourcesContent":["/*! *****************************************************************************\nCopyright (C) Microsoft. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\nvar Reflect;\n(function (Reflect) {\n // Metadata Proposal\n // https://rbuckton.github.io/reflect-metadata/\n (function (factory) {\n var root = typeof globalThis === \"object\" ? globalThis :\n typeof global === \"object\" ? global :\n typeof self === \"object\" ? self :\n typeof this === \"object\" ? this :\n sloppyModeThis();\n var exporter = makeExporter(Reflect);\n if (typeof root.Reflect !== \"undefined\") {\n exporter = makeExporter(root.Reflect, exporter);\n }\n factory(exporter, root);\n if (typeof root.Reflect === \"undefined\") {\n root.Reflect = Reflect;\n }\n function makeExporter(target, previous) {\n return function (key, value) {\n Object.defineProperty(target, key, { configurable: true, writable: true, value: value });\n if (previous)\n previous(key, value);\n };\n }\n function functionThis() {\n try {\n return Function(\"return this;\")();\n }\n catch (_) { }\n }\n function indirectEvalThis() {\n try {\n return (void 0, eval)(\"(function() { return this; })()\");\n }\n catch (_) { }\n }\n function sloppyModeThis() {\n return functionThis() || indirectEvalThis();\n }\n })(function (exporter, root) {\n var hasOwn = Object.prototype.hasOwnProperty;\n // feature test for Symbol support\n var supportsSymbol = typeof Symbol === \"function\";\n var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== \"undefined\" ? Symbol.toPrimitive : \"@@toPrimitive\";\n var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== \"undefined\" ? Symbol.iterator : \"@@iterator\";\n var supportsCreate = typeof Object.create === \"function\"; // feature test for Object.create support\n var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support\n var downLevel = !supportsCreate && !supportsProto;\n var HashMap = {\n // create an object in dictionary mode (a.k.a. \"slow\" mode in v8)\n create: supportsCreate\n ? function () { return MakeDictionary(Object.create(null)); }\n : supportsProto\n ? function () { return MakeDictionary({ __proto__: null }); }\n : function () { return MakeDictionary({}); },\n has: downLevel\n ? function (map, key) { return hasOwn.call(map, key); }\n : function (map, key) { return key in map; },\n get: downLevel\n ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }\n : function (map, key) { return map[key]; },\n };\n // Load global or shim versions of Map, Set, and WeakMap\n var functionPrototype = Object.getPrototypeOf(Function);\n var _Map = typeof Map === \"function\" && typeof Map.prototype.entries === \"function\" ? Map : CreateMapPolyfill();\n var _Set = typeof Set === \"function\" && typeof Set.prototype.entries === \"function\" ? Set : CreateSetPolyfill();\n var _WeakMap = typeof WeakMap === \"function\" ? WeakMap : CreateWeakMapPolyfill();\n var registrySymbol = supportsSymbol ? Symbol.for(\"@reflect-metadata:registry\") : undefined;\n var metadataRegistry = GetOrCreateMetadataRegistry();\n var metadataProvider = CreateMetadataProvider(metadataRegistry);\n /**\n * Applies a set of decorators to a property of a target object.\n * @param decorators An array of decorators.\n * @param target The target object.\n * @param propertyKey (Optional) The property key to decorate.\n * @param attributes (Optional) The property descriptor for the target key.\n * @remarks Decorators are applied in reverse order.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Example = Reflect.decorate(decoratorsArray, Example);\n *\n * // property (on constructor)\n * Reflect.decorate(decoratorsArray, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.decorate(decoratorsArray, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Object.defineProperty(Example, \"staticMethod\",\n * Reflect.decorate(decoratorsArray, Example, \"staticMethod\",\n * Object.getOwnPropertyDescriptor(Example, \"staticMethod\")));\n *\n * // method (on prototype)\n * Object.defineProperty(Example.prototype, \"method\",\n * Reflect.decorate(decoratorsArray, Example.prototype, \"method\",\n * Object.getOwnPropertyDescriptor(Example.prototype, \"method\")));\n *\n */\n function decorate(decorators, target, propertyKey, attributes) {\n if (!IsUndefined(propertyKey)) {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsObject(target))\n throw new TypeError();\n if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))\n throw new TypeError();\n if (IsNull(attributes))\n attributes = undefined;\n propertyKey = ToPropertyKey(propertyKey);\n return DecorateProperty(decorators, target, propertyKey, attributes);\n }\n else {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsConstructor(target))\n throw new TypeError();\n return DecorateConstructor(decorators, target);\n }\n }\n exporter(\"decorate\", decorate);\n // 4.1.2 Reflect.metadata(metadataKey, metadataValue)\n // https://rbuckton.github.io/reflect-metadata/#reflect.metadata\n /**\n * A default metadata decorator factory that can be used on a class, class member, or parameter.\n * @param metadataKey The key for the metadata entry.\n * @param metadataValue The value for the metadata entry.\n * @returns A decorator function.\n * @remarks\n * If `metadataKey` is already defined for the target and target key, the\n * metadataValue for that key will be overwritten.\n * @example\n *\n * // constructor\n * @Reflect.metadata(key, value)\n * class Example {\n * }\n *\n * // property (on constructor, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticProperty;\n * }\n *\n * // property (on prototype, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * property;\n * }\n *\n * // method (on constructor)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticMethod() { }\n * }\n *\n * // method (on prototype)\n * class Example {\n * @Reflect.metadata(key, value)\n * method() { }\n * }\n *\n */\n function metadata(metadataKey, metadataValue) {\n function decorator(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))\n throw new TypeError();\n OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n return decorator;\n }\n exporter(\"metadata\", metadata);\n /**\n * Define a unique metadata entry on the target.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param metadataValue A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey (Optional) The property key for the target.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): Decorator {\n * return (target, key?) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n *\n */\n function defineMetadata(metadataKey, metadataValue, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n exporter(\"defineMetadata\", defineMetadata);\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasMetadata\", hasMetadata);\n /**\n * Gets a value indicating whether the target object has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasOwnMetadata\", hasOwnMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getMetadata\", getMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getOwnMetadata\", getOwnMetadata);\n /**\n * Gets the metadata keys defined on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryMetadataKeys(target, propertyKey);\n }\n exporter(\"getMetadataKeys\", getMetadataKeys);\n /**\n * Gets the unique metadata keys defined on the target object.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getOwnMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryOwnMetadataKeys(target, propertyKey);\n }\n exporter(\"getOwnMetadataKeys\", getOwnMetadataKeys);\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function deleteMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n var provider = GetMetadataProvider(target, propertyKey, /*Create*/ false);\n if (IsUndefined(provider))\n return false;\n return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"deleteMetadata\", deleteMetadata);\n function DecorateConstructor(decorators, target) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsConstructor(decorated))\n throw new TypeError();\n target = decorated;\n }\n }\n return target;\n }\n function DecorateProperty(decorators, target, propertyKey, descriptor) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target, propertyKey, descriptor);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsObject(decorated))\n throw new TypeError();\n descriptor = decorated;\n }\n }\n return descriptor;\n }\n // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata\n function OrdinaryHasMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return true;\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryHasMetadata(MetadataKey, parent, P);\n return false;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ false);\n if (IsUndefined(provider))\n return false;\n return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));\n }\n // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata\n function OrdinaryGetMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return OrdinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryGetMetadata(MetadataKey, parent, P);\n return undefined;\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ false);\n if (IsUndefined(provider))\n return;\n return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ true);\n provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);\n }\n // 3.1.6.1 OrdinaryMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys\n function OrdinaryMetadataKeys(O, P) {\n var ownKeys = OrdinaryOwnMetadataKeys(O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (parent === null)\n return ownKeys;\n var parentKeys = OrdinaryMetadataKeys(parent, P);\n if (parentKeys.length <= 0)\n return ownKeys;\n if (ownKeys.length <= 0)\n return parentKeys;\n var set = new _Set();\n var keys = [];\n for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {\n var key = ownKeys_1[_i];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {\n var key = parentKeys_1[_a];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n return keys;\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var provider = GetMetadataProvider(O, P, /*create*/ false);\n if (!provider) {\n return [];\n }\n return provider.OrdinaryOwnMetadataKeys(O, P);\n }\n // 6 ECMAScript Data Types and Values\n // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values\n function Type(x) {\n if (x === null)\n return 1 /* Null */;\n switch (typeof x) {\n case \"undefined\": return 0 /* Undefined */;\n case \"boolean\": return 2 /* Boolean */;\n case \"string\": return 3 /* String */;\n case \"symbol\": return 4 /* Symbol */;\n case \"number\": return 5 /* Number */;\n case \"object\": return x === null ? 1 /* Null */ : 6 /* Object */;\n default: return 6 /* Object */;\n }\n }\n // 6.1.1 The Undefined Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type\n function IsUndefined(x) {\n return x === undefined;\n }\n // 6.1.2 The Null Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type\n function IsNull(x) {\n return x === null;\n }\n // 6.1.5 The Symbol Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type\n function IsSymbol(x) {\n return typeof x === \"symbol\";\n }\n // 6.1.7 The Object Type\n // https://tc39.github.io/ecma262/#sec-object-type\n function IsObject(x) {\n return typeof x === \"object\" ? x !== null : typeof x === \"function\";\n }\n // 7.1 Type Conversion\n // https://tc39.github.io/ecma262/#sec-type-conversion\n // 7.1.1 ToPrimitive(input [, PreferredType])\n // https://tc39.github.io/ecma262/#sec-toprimitive\n function ToPrimitive(input, PreferredType) {\n switch (Type(input)) {\n case 0 /* Undefined */: return input;\n case 1 /* Null */: return input;\n case 2 /* Boolean */: return input;\n case 3 /* String */: return input;\n case 4 /* Symbol */: return input;\n case 5 /* Number */: return input;\n }\n var hint = PreferredType === 3 /* String */ ? \"string\" : PreferredType === 5 /* Number */ ? \"number\" : \"default\";\n var exoticToPrim = GetMethod(input, toPrimitiveSymbol);\n if (exoticToPrim !== undefined) {\n var result = exoticToPrim.call(input, hint);\n if (IsObject(result))\n throw new TypeError();\n return result;\n }\n return OrdinaryToPrimitive(input, hint === \"default\" ? \"number\" : hint);\n }\n // 7.1.1.1 OrdinaryToPrimitive(O, hint)\n // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive\n function OrdinaryToPrimitive(O, hint) {\n if (hint === \"string\") {\n var toString_1 = O.toString;\n if (IsCallable(toString_1)) {\n var result = toString_1.call(O);\n if (!IsObject(result))\n return result;\n }\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n else {\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n var toString_2 = O.toString;\n if (IsCallable(toString_2)) {\n var result = toString_2.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n throw new TypeError();\n }\n // 7.1.2 ToBoolean(argument)\n // https://tc39.github.io/ecma262/2016/#sec-toboolean\n function ToBoolean(argument) {\n return !!argument;\n }\n // 7.1.12 ToString(argument)\n // https://tc39.github.io/ecma262/#sec-tostring\n function ToString(argument) {\n return \"\" + argument;\n }\n // 7.1.14 ToPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-topropertykey\n function ToPropertyKey(argument) {\n var key = ToPrimitive(argument, 3 /* String */);\n if (IsSymbol(key))\n return key;\n return ToString(key);\n }\n // 7.2 Testing and Comparison Operations\n // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations\n // 7.2.2 IsArray(argument)\n // https://tc39.github.io/ecma262/#sec-isarray\n function IsArray(argument) {\n return Array.isArray\n ? Array.isArray(argument)\n : argument instanceof Object\n ? argument instanceof Array\n : Object.prototype.toString.call(argument) === \"[object Array]\";\n }\n // 7.2.3 IsCallable(argument)\n // https://tc39.github.io/ecma262/#sec-iscallable\n function IsCallable(argument) {\n // NOTE: This is an approximation as we cannot check for [[Call]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.4 IsConstructor(argument)\n // https://tc39.github.io/ecma262/#sec-isconstructor\n function IsConstructor(argument) {\n // NOTE: This is an approximation as we cannot check for [[Construct]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.7 IsPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-ispropertykey\n function IsPropertyKey(argument) {\n switch (Type(argument)) {\n case 3 /* String */: return true;\n case 4 /* Symbol */: return true;\n default: return false;\n }\n }\n function SameValueZero(x, y) {\n return x === y || x !== x && y !== y;\n }\n // 7.3 Operations on Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-objects\n // 7.3.9 GetMethod(V, P)\n // https://tc39.github.io/ecma262/#sec-getmethod\n function GetMethod(V, P) {\n var func = V[P];\n if (func === undefined || func === null)\n return undefined;\n if (!IsCallable(func))\n throw new TypeError();\n return func;\n }\n // 7.4 Operations on Iterator Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects\n function GetIterator(obj) {\n var method = GetMethod(obj, iteratorSymbol);\n if (!IsCallable(method))\n throw new TypeError(); // from Call\n var iterator = method.call(obj);\n if (!IsObject(iterator))\n throw new TypeError();\n return iterator;\n }\n // 7.4.4 IteratorValue(iterResult)\n // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue\n function IteratorValue(iterResult) {\n return iterResult.value;\n }\n // 7.4.5 IteratorStep(iterator)\n // https://tc39.github.io/ecma262/#sec-iteratorstep\n function IteratorStep(iterator) {\n var result = iterator.next();\n return result.done ? false : result;\n }\n // 7.4.6 IteratorClose(iterator, completion)\n // https://tc39.github.io/ecma262/#sec-iteratorclose\n function IteratorClose(iterator) {\n var f = iterator[\"return\"];\n if (f)\n f.call(iterator);\n }\n // 9.1 Ordinary Object Internal Methods and Internal Slots\n // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\n // 9.1.1.1 OrdinaryGetPrototypeOf(O)\n // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof\n function OrdinaryGetPrototypeOf(O) {\n var proto = Object.getPrototypeOf(O);\n if (typeof O !== \"function\" || O === functionPrototype)\n return proto;\n // TypeScript doesn't set __proto__ in ES5, as it's non-standard.\n // Try to determine the superclass constructor. Compatible implementations\n // must either set __proto__ on a subclass constructor to the superclass constructor,\n // or ensure each class has a valid `constructor` property on its prototype that\n // points back to the constructor.\n // If this is not the same as Function.[[Prototype]], then this is definately inherited.\n // This is the case when in ES6 or when using __proto__ in a compatible browser.\n if (proto !== functionPrototype)\n return proto;\n // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.\n var prototype = O.prototype;\n var prototypeProto = prototype && Object.getPrototypeOf(prototype);\n if (prototypeProto == null || prototypeProto === Object.prototype)\n return proto;\n // If the constructor was not a function, then we cannot determine the heritage.\n var constructor = prototypeProto.constructor;\n if (typeof constructor !== \"function\")\n return proto;\n // If we have some kind of self-reference, then we cannot determine the heritage.\n if (constructor === O)\n return proto;\n // we have a pretty good guess at the heritage.\n return constructor;\n }\n // Global metadata registry\n // - Allows `import \"reflect-metadata\"` and `import \"reflect-metadata/no-conflict\"` to interoperate.\n // - Uses isolated metadata if `Reflect` is frozen before the registry can be installed.\n /**\n * Creates a registry used to allow multiple `reflect-metadata` providers.\n */\n function CreateMetadataRegistry() {\n var fallback;\n if (!IsUndefined(registrySymbol) &&\n typeof root.Reflect !== \"undefined\" &&\n !(registrySymbol in root.Reflect) &&\n typeof root.Reflect.defineMetadata === \"function\") {\n // interoperate with older version of `reflect-metadata` that did not support a registry.\n fallback = CreateFallbackProvider(root.Reflect);\n }\n var first;\n var second;\n var rest;\n var targetProviderMap = new _WeakMap();\n var registry = {\n registerProvider: registerProvider,\n getProvider: getProvider,\n setProvider: setProvider,\n };\n return registry;\n function registerProvider(provider) {\n if (!Object.isExtensible(registry)) {\n throw new Error(\"Cannot add provider to a frozen registry.\");\n }\n switch (true) {\n case fallback === provider: break;\n case IsUndefined(first):\n first = provider;\n break;\n case first === provider: break;\n case IsUndefined(second):\n second = provider;\n break;\n case second === provider: break;\n default:\n if (rest === undefined)\n rest = new _Set();\n rest.add(provider);\n break;\n }\n }\n function getProviderNoCache(O, P) {\n if (!IsUndefined(first)) {\n if (first.isProviderFor(O, P))\n return first;\n if (!IsUndefined(second)) {\n if (second.isProviderFor(O, P))\n return first;\n if (!IsUndefined(rest)) {\n var iterator = GetIterator(rest);\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n return undefined;\n }\n var provider = IteratorValue(next);\n if (provider.isProviderFor(O, P)) {\n IteratorClose(iterator);\n return provider;\n }\n }\n }\n }\n }\n if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {\n return fallback;\n }\n return undefined;\n }\n function getProvider(O, P) {\n var providerMap = targetProviderMap.get(O);\n var provider;\n if (!IsUndefined(providerMap)) {\n provider = providerMap.get(P);\n }\n if (!IsUndefined(provider)) {\n return provider;\n }\n provider = getProviderNoCache(O, P);\n if (!IsUndefined(provider)) {\n if (IsUndefined(providerMap)) {\n providerMap = new _Map();\n targetProviderMap.set(O, providerMap);\n }\n providerMap.set(P, provider);\n }\n return provider;\n }\n function hasProvider(provider) {\n if (IsUndefined(provider))\n throw new TypeError();\n return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);\n }\n function setProvider(O, P, provider) {\n if (!hasProvider(provider)) {\n throw new Error(\"Metadata provider not registered.\");\n }\n var existingProvider = getProvider(O, P);\n if (existingProvider !== provider) {\n if (!IsUndefined(existingProvider)) {\n return false;\n }\n var providerMap = targetProviderMap.get(O);\n if (IsUndefined(providerMap)) {\n providerMap = new _Map();\n targetProviderMap.set(O, providerMap);\n }\n providerMap.set(P, provider);\n }\n return true;\n }\n }\n /**\n * Gets or creates the shared registry of metadata providers.\n */\n function GetOrCreateMetadataRegistry() {\n var metadataRegistry;\n if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {\n metadataRegistry = root.Reflect[registrySymbol];\n }\n if (IsUndefined(metadataRegistry)) {\n metadataRegistry = CreateMetadataRegistry();\n }\n if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {\n Object.defineProperty(root.Reflect, registrySymbol, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: metadataRegistry\n });\n }\n return metadataRegistry;\n }\n function CreateMetadataProvider(registry) {\n // [[Metadata]] internal slot\n // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots\n var metadata = new _WeakMap();\n var provider = {\n isProviderFor: function (O, P) {\n var targetMetadata = metadata.get(O);\n if (IsUndefined(targetMetadata))\n return false;\n return targetMetadata.has(P);\n },\n OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata,\n OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata,\n OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata,\n OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys,\n OrdinaryDeleteMetadata: OrdinaryDeleteMetadata,\n };\n metadataRegistry.registerProvider(provider);\n return provider;\n function GetOrCreateMetadataMap(O, P, Create) {\n var targetMetadata = metadata.get(O);\n var createdTargetMetadata = false;\n if (IsUndefined(targetMetadata)) {\n if (!Create)\n return undefined;\n targetMetadata = new _Map();\n metadata.set(O, targetMetadata);\n createdTargetMetadata = true;\n }\n var metadataMap = targetMetadata.get(P);\n if (IsUndefined(metadataMap)) {\n if (!Create)\n return undefined;\n metadataMap = new _Map();\n targetMetadata.set(P, metadataMap);\n if (!registry.setProvider(O, P, provider)) {\n targetMetadata.delete(P);\n if (createdTargetMetadata) {\n metadata.delete(O);\n }\n throw new Error(\"Wrong provider for target.\");\n }\n }\n return metadataMap;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n return ToBoolean(metadataMap.has(MetadataKey));\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return undefined;\n return metadataMap.get(MetadataKey);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);\n metadataMap.set(MetadataKey, MetadataValue);\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var keys = [];\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return keys;\n var keysObj = metadataMap.keys();\n var iterator = GetIterator(keysObj);\n var k = 0;\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n keys.length = k;\n return keys;\n }\n var nextValue = IteratorValue(next);\n try {\n keys[k] = nextValue;\n }\n catch (e) {\n try {\n IteratorClose(iterator);\n }\n finally {\n throw e;\n }\n }\n k++;\n }\n }\n function OrdinaryDeleteMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n if (!metadataMap.delete(MetadataKey))\n return false;\n if (metadataMap.size === 0) {\n var targetMetadata = metadata.get(O);\n if (!IsUndefined(targetMetadata)) {\n targetMetadata.delete(P);\n if (targetMetadata.size === 0) {\n metadata.delete(targetMetadata);\n }\n }\n }\n return true;\n }\n }\n function CreateFallbackProvider(reflect) {\n var defineMetadata = reflect.defineMetadata, hasOwnMetadata = reflect.hasOwnMetadata, getOwnMetadata = reflect.getOwnMetadata, getOwnMetadataKeys = reflect.getOwnMetadataKeys, deleteMetadata = reflect.deleteMetadata;\n var metadataOwner = new _WeakMap();\n var provider = {\n isProviderFor: function (O, P) {\n var metadataPropertySet = metadataOwner.get(O);\n if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {\n return true;\n }\n if (getOwnMetadataKeys(O, P).length) {\n if (IsUndefined(metadataPropertySet)) {\n metadataPropertySet = new _Set();\n metadataOwner.set(O, metadataPropertySet);\n }\n metadataPropertySet.add(P);\n return true;\n }\n return false;\n },\n OrdinaryDefineOwnMetadata: defineMetadata,\n OrdinaryHasOwnMetadata: hasOwnMetadata,\n OrdinaryGetOwnMetadata: getOwnMetadata,\n OrdinaryOwnMetadataKeys: getOwnMetadataKeys,\n OrdinaryDeleteMetadata: deleteMetadata,\n };\n return provider;\n }\n /**\n * Gets the metadata provider for an object. If the object has no metadata provider and this is for a create operation,\n * then this module's metadata provider is assigned to the object.\n */\n function GetMetadataProvider(O, P, Create) {\n var registeredProvider = metadataRegistry.getProvider(O, P);\n if (!IsUndefined(registeredProvider)) {\n return registeredProvider;\n }\n if (Create) {\n if (metadataRegistry.setProvider(O, P, metadataProvider)) {\n return metadataProvider;\n }\n throw new Error(\"Illegal state.\");\n }\n return undefined;\n }\n // naive Map shim\n function CreateMapPolyfill() {\n var cacheSentinel = {};\n var arraySentinel = [];\n var MapIterator = /** @class */ (function () {\n function MapIterator(keys, values, selector) {\n this._index = 0;\n this._keys = keys;\n this._values = values;\n this._selector = selector;\n }\n MapIterator.prototype[\"@@iterator\"] = function () { return this; };\n MapIterator.prototype[iteratorSymbol] = function () { return this; };\n MapIterator.prototype.next = function () {\n var index = this._index;\n if (index >= 0 && index < this._keys.length) {\n var result = this._selector(this._keys[index], this._values[index]);\n if (index + 1 >= this._keys.length) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n else {\n this._index++;\n }\n return { value: result, done: false };\n }\n return { value: undefined, done: true };\n };\n MapIterator.prototype.throw = function (error) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n throw error;\n };\n MapIterator.prototype.return = function (value) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n return { value: value, done: true };\n };\n return MapIterator;\n }());\n var Map = /** @class */ (function () {\n function Map() {\n this._keys = [];\n this._values = [];\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n Object.defineProperty(Map.prototype, \"size\", {\n get: function () { return this._keys.length; },\n enumerable: true,\n configurable: true\n });\n Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };\n Map.prototype.get = function (key) {\n var index = this._find(key, /*insert*/ false);\n return index >= 0 ? this._values[index] : undefined;\n };\n Map.prototype.set = function (key, value) {\n var index = this._find(key, /*insert*/ true);\n this._values[index] = value;\n return this;\n };\n Map.prototype.delete = function (key) {\n var index = this._find(key, /*insert*/ false);\n if (index >= 0) {\n var size = this._keys.length;\n for (var i = index + 1; i < size; i++) {\n this._keys[i - 1] = this._keys[i];\n this._values[i - 1] = this._values[i];\n }\n this._keys.length--;\n this._values.length--;\n if (SameValueZero(key, this._cacheKey)) {\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n return true;\n }\n return false;\n };\n Map.prototype.clear = function () {\n this._keys.length = 0;\n this._values.length = 0;\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n };\n Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };\n Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };\n Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };\n Map.prototype[\"@@iterator\"] = function () { return this.entries(); };\n Map.prototype[iteratorSymbol] = function () { return this.entries(); };\n Map.prototype._find = function (key, insert) {\n if (!SameValueZero(this._cacheKey, key)) {\n this._cacheIndex = -1;\n for (var i = 0; i < this._keys.length; i++) {\n if (SameValueZero(this._keys[i], key)) {\n this._cacheIndex = i;\n break;\n }\n }\n }\n if (this._cacheIndex < 0 && insert) {\n this._cacheIndex = this._keys.length;\n this._keys.push(key);\n this._values.push(undefined);\n }\n return this._cacheIndex;\n };\n return Map;\n }());\n return Map;\n function getKey(key, _) {\n return key;\n }\n function getValue(_, value) {\n return value;\n }\n function getEntry(key, value) {\n return [key, value];\n }\n }\n // naive Set shim\n function CreateSetPolyfill() {\n var Set = /** @class */ (function () {\n function Set() {\n this._map = new _Map();\n }\n Object.defineProperty(Set.prototype, \"size\", {\n get: function () { return this._map.size; },\n enumerable: true,\n configurable: true\n });\n Set.prototype.has = function (value) { return this._map.has(value); };\n Set.prototype.add = function (value) { return this._map.set(value, value), this; };\n Set.prototype.delete = function (value) { return this._map.delete(value); };\n Set.prototype.clear = function () { this._map.clear(); };\n Set.prototype.keys = function () { return this._map.keys(); };\n Set.prototype.values = function () { return this._map.keys(); };\n Set.prototype.entries = function () { return this._map.entries(); };\n Set.prototype[\"@@iterator\"] = function () { return this.keys(); };\n Set.prototype[iteratorSymbol] = function () { return this.keys(); };\n return Set;\n }());\n return Set;\n }\n // naive WeakMap shim\n function CreateWeakMapPolyfill() {\n var UUID_SIZE = 16;\n var keys = HashMap.create();\n var rootKey = CreateUniqueKey();\n return /** @class */ (function () {\n function WeakMap() {\n this._key = CreateUniqueKey();\n }\n WeakMap.prototype.has = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.has(table, this._key) : false;\n };\n WeakMap.prototype.get = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.get(table, this._key) : undefined;\n };\n WeakMap.prototype.set = function (target, value) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ true);\n table[this._key] = value;\n return this;\n };\n WeakMap.prototype.delete = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? delete table[this._key] : false;\n };\n WeakMap.prototype.clear = function () {\n // NOTE: not a real clear, just makes the previous data unreachable\n this._key = CreateUniqueKey();\n };\n return WeakMap;\n }());\n function CreateUniqueKey() {\n var key;\n do\n key = \"@@WeakMap@@\" + CreateUUID();\n while (HashMap.has(keys, key));\n keys[key] = true;\n return key;\n }\n function GetOrCreateWeakMapTable(target, create) {\n if (!hasOwn.call(target, rootKey)) {\n if (!create)\n return undefined;\n Object.defineProperty(target, rootKey, { value: HashMap.create() });\n }\n return target[rootKey];\n }\n function FillRandomBytes(buffer, size) {\n for (var i = 0; i < size; ++i)\n buffer[i] = Math.random() * 0xff | 0;\n return buffer;\n }\n function GenRandomBytes(size) {\n if (typeof Uint8Array === \"function\") {\n var array = new Uint8Array(size);\n if (typeof crypto !== \"undefined\") {\n crypto.getRandomValues(array);\n }\n else if (typeof msCrypto !== \"undefined\") {\n msCrypto.getRandomValues(array);\n }\n else {\n FillRandomBytes(array, size);\n }\n return array;\n }\n return FillRandomBytes(new Array(size), size);\n }\n function CreateUUID() {\n var data = GenRandomBytes(UUID_SIZE);\n // mark as random - RFC 4122 § 4.4\n data[6] = data[6] & 0x4f | 0x40;\n data[8] = data[8] & 0xbf | 0x80;\n var result = \"\";\n for (var offset = 0; offset < UUID_SIZE; ++offset) {\n var byte = data[offset];\n if (offset === 4 || offset === 6 || offset === 8)\n result += \"-\";\n if (byte < 16)\n result += \"0\";\n result += byte.toString(16).toLowerCase();\n }\n return result;\n }\n }\n // uses a heuristic used by v8 and chakra to force an object into dictionary mode.\n function MakeDictionary(obj) {\n obj.__ = undefined;\n delete obj.__;\n return obj;\n }\n });\n})(Reflect || (Reflect = {}));\n","import \"reflect-metadata\";\n\nexport type ClassConstructor<T = any> = new (...args: any[]) => T;\nexport type FactoryFunction<T = any> = (container: Container) => T;\n\nexport class Container {\n private static instance: Container;\n private bindings: Map<string | ClassConstructor, FactoryFunction> = new Map();\n private singletons: Map<string | ClassConstructor, any> = new Map();\n\n constructor() {\n if (!Container.instance) {\n Container.instance = this;\n }\n }\n\n /**\n * Get the global container instance\n */\n public static getInstance(): Container {\n if (!Container.instance) {\n Container.instance = new Container();\n }\n return Container.instance;\n }\n\n /**\n * Bind a class or factory to the container\n */\n public bind<T>(\n key: string | ClassConstructor<T>,\n value: ClassConstructor<T> | FactoryFunction<T>\n ): void {\n if (this.isConstructor(value)) {\n this.bindings.set(key, () => this.build(value));\n } else {\n this.bindings.set(key, value as FactoryFunction<T>);\n }\n }\n\n /**\n * Bind a singleton to the container\n */\n public singleton<T>(\n key: string | ClassConstructor<T>,\n value: ClassConstructor<T> | FactoryFunction<T>\n ): void {\n const factory = this.isConstructor(value)\n ? () => this.build(value)\n : (value as FactoryFunction<T>);\n\n this.bindings.set(key, () => {\n if (!this.singletons.has(key)) {\n this.singletons.set(key, factory(this));\n }\n return this.singletons.get(key);\n });\n }\n\n /**\n * Resolve a dependency from the container\n */\n public make<T>(key: string | ClassConstructor<T>): T {\n if (this.bindings.has(key)) {\n return this.bindings.get(key)!(this);\n }\n\n // If it's a class and not bound, try to build it directly\n if (this.isConstructor(key)) {\n return this.build(key);\n }\n\n throw new Error(`Service not found: ${key.toString()}`);\n }\n\n /**\n * Check if a service is registered in the container\n */\n public has(key: string | ClassConstructor): boolean {\n return this.bindings.has(key);\n }\n\n /**\n * Alias for make() - resolve a dependency from the container\n */\n public resolve<T>(key: string | ClassConstructor<T>): T {\n return this.make(key);\n }\n\n /**\n * Instantiate a class, resolving its dependencies\n */\n private build<T>(target: ClassConstructor<T>): T {\n // Get constructor parameters using reflect-metadata\n const params = Reflect.getMetadata(\"design:paramtypes\", target) || [];\n\n const injections = params.map((param: any) => {\n return this.make(param);\n });\n\n return new target(...injections);\n }\n\n private isConstructor(obj: any): obj is ClassConstructor {\n return !!obj.prototype && !!obj.prototype.constructor.name;\n }\n}\n\nexport const container = Container.getInstance();\n","import \"reflect-metadata\";\nimport { ClassConstructor } from \"../Container\";\nimport { InjectableMetadata } from \"./types\";\n\nconst INJECTABLE_METADATA_KEY = \"arcanajs:injectable\";\nconst globalInjectables: InjectableMetadata[] = [];\n\n/**\n * Set injectable metadata for a class\n */\nexport function setInjectableMetadata(\n target: ClassConstructor,\n metadata: InjectableMetadata\n): void {\n Reflect.defineMetadata(INJECTABLE_METADATA_KEY, metadata, target);\n globalInjectables.push(metadata);\n}\n\n/**\n * Get injectable metadata for a class\n */\nexport function getInjectableMetadata(\n target: ClassConstructor\n): InjectableMetadata | undefined {\n return Reflect.getMetadata(INJECTABLE_METADATA_KEY, target);\n}\n\n/**\n * Check if a class is injectable\n */\nexport function isInjectable(target: any): boolean {\n if (!target || typeof target !== \"function\") {\n return false;\n }\n return Reflect.hasMetadata(INJECTABLE_METADATA_KEY, target);\n}\n\n/**\n * Get all registered injectable classes\n */\nexport function getAllInjectables(): InjectableMetadata[] {\n return globalInjectables;\n}\n","import { ServiceProvider } from \"../../server/ServiceProvider\";\nimport { getAllInjectables } from \"../decorators/metadata\";\nimport { AutoDiscoveryConfig } from \"../decorators/types\";\nimport { ClassScanner } from \"../support/ClassScanner\";\n\nexport interface AutoRegisterConfig extends AutoDiscoveryConfig {\n directories: string[];\n}\n\n/**\n * Service provider that automatically discovers and registers\n * classes decorated with @Injectable, @Service, @Repository, or @Controller\n */\nexport class AutoRegisterProvider extends ServiceProvider {\n private config: AutoRegisterConfig;\n private scanner: ClassScanner;\n\n constructor(app: any, config: AutoRegisterConfig) {\n super(app);\n this.config = config;\n this.scanner = new ClassScanner();\n }\n\n async register(): Promise<void> {\n if (!this.config.enabled) {\n return;\n }\n\n const debug = this.config.debug || false;\n\n if (debug) {\n console.log(\"[AutoRegisterProvider] Starting auto-discovery...\");\n }\n\n // First, try to get injectables from the global registry\n // (in case they were already imported elsewhere)\n let injectables = getAllInjectables();\n\n // If directories are specified, scan them for additional injectables\n if (this.config.directories && this.config.directories.length > 0) {\n const discovered = await this.scanner.scan({\n directories: this.config.directories,\n include: this.config.include,\n exclude: this.config.exclude,\n debug,\n });\n\n // Merge with existing injectables (avoid duplicates)\n const existingTargets = new Set(injectables.map((i) => i.target));\n for (const injectable of discovered) {\n if (!existingTargets.has(injectable.target)) {\n injectables.push(injectable);\n }\n }\n }\n\n if (injectables.length === 0) {\n if (debug) {\n console.warn(\n \"[AutoRegisterProvider] No injectable classes found. Make sure your classes are decorated with @Injectable, @Service, @Repository, or @Controller.\"\n );\n }\n return;\n }\n\n // Register all discovered injectables\n let registeredCount = 0;\n for (const injectable of injectables) {\n try {\n const key = injectable.key || injectable.target;\n\n if (injectable.scope === \"singleton\") {\n this.app.container.singleton(key, injectable.target);\n } else {\n this.app.container.bind(key, injectable.target);\n }\n\n registeredCount++;\n\n if (debug) {\n console.log(\n `[AutoRegisterProvider] Registered ${injectable.target.name} as ${injectable.scope}`\n );\n }\n } catch (error) {\n console.error(\n `[AutoRegisterProvider] Failed to register ${injectable.target.name}:`,\n error\n );\n }\n }\n\n console.log(\n `✓ Auto-registered ${registeredCount} injectable class${\n registeredCount !== 1 ? \"es\" : \"\"\n }`\n );\n }\n\n async boot(): Promise<void> {\n // Nothing to do on boot\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleLoader } from \"../../../utils/ModuleLoader\";\nimport { ClassConstructor } from \"../../di/Container\";\nimport {\n getInjectableMetadata,\n isInjectable,\n} from \"../../di/decorators/metadata\";\nimport { InjectableMetadata } from \"../../di/decorators/types\";\n\nexport interface ScanOptions {\n /**\n * Directories to scan\n */\n directories: string[];\n\n /**\n * File patterns to include (glob patterns)\n * @default ['**\\/*.ts', '**\\/*.js']\n */\n include?: string[];\n\n /**\n * File patterns to exclude (glob patterns)\n * @default ['**\\/*.test.ts', '**\\/*.spec.ts', '**\\/node_modules/**']\n */\n exclude?: string[];\n\n /**\n * Enable debug logging\n */\n debug?: boolean;\n}\n\n/**\n * Scans directories for classes decorated with @Injectable and related decorators\n */\nexport class ClassScanner {\n private readonly scannedFiles = new Set<string>();\n private tsSupportRegistered = false;\n\n /**\n * Scan directories and return all injectable classes\n */\n async scan(options: ScanOptions): Promise<InjectableMetadata[]> {\n const {\n directories,\n include = [\"**/*.ts\", \"**/*.js\"],\n exclude = [\"**/*.test.ts\", \"**/*.spec.ts\", \"**/node_modules/**\"],\n debug = false,\n } = options;\n\n const injectables: InjectableMetadata[] = [];\n const root = process.cwd();\n\n for (const dir of directories) {\n const absoluteDir = path.isAbsolute(dir) ? dir : path.resolve(root, dir);\n\n if (!fs.existsSync(absoluteDir)) {\n if (debug) {\n console.warn(`[ClassScanner] Directory not found: ${absoluteDir}`);\n }\n continue;\n }\n\n if (debug) {\n console.log(`[ClassScanner] Scanning directory: ${absoluteDir}`);\n }\n\n const files = await this.scanDirectory(absoluteDir, include, exclude);\n\n for (const file of files) {\n if (this.scannedFiles.has(file)) continue;\n this.scannedFiles.add(file);\n\n try {\n const discovered = await this.scanFile(file, debug);\n injectables.push(...discovered);\n } catch (error) {\n if (debug) {\n console.error(`[ClassScanner] Error scanning file ${file}:`, error);\n }\n }\n }\n }\n\n if (debug) {\n console.log(\n `[ClassScanner] Found ${injectables.length} injectable classes`\n );\n }\n\n return injectables;\n }\n\n /**\n * Recursively scan a directory for files\n */\n private async scanDirectory(\n dir: string,\n include: string[],\n exclude: string[]\n ): Promise<string[]> {\n const files: string[] = [];\n\n const traverse = (currentDir: string) => {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n // Check exclude patterns\n if (this.matchesPatterns(fullPath, exclude)) {\n continue;\n }\n\n if (entry.isDirectory()) {\n traverse(fullPath);\n } else if (entry.isFile()) {\n // Check include patterns\n if (this.matchesPatterns(fullPath, include)) {\n files.push(fullPath);\n }\n }\n }\n };\n\n traverse(dir);\n return files;\n }\n\n /**\n * Scan a single file for injectable classes\n */\n private async scanFile(\n filePath: string,\n debug: boolean\n ): Promise<InjectableMetadata[]> {\n const injectables: InjectableMetadata[] = [];\n\n // Register ts-node if needed for TypeScript files\n if (filePath.endsWith(\".ts\") && !filePath.endsWith(\".d.ts\")) {\n this.registerTsSupport(filePath, debug);\n }\n\n try {\n // Dynamic import to load the module\n const moduleExports = ModuleLoader.require(filePath);\n\n // Check all exports for injectable classes\n for (const key of Object.keys(moduleExports)) {\n const exported = moduleExports[key];\n\n if (isInjectable(exported)) {\n const metadata = getInjectableMetadata(exported as ClassConstructor);\n if (metadata) {\n injectables.push(metadata);\n if (debug) {\n console.log(\n `[ClassScanner] Found injectable: ${exported.name} (${metadata.scope})`\n );\n }\n }\n }\n }\n } catch (error) {\n // Silently skip files that can't be imported\n if (debug) {\n console.warn(`[ClassScanner] Could not import ${filePath}:`, error);\n }\n }\n\n return injectables;\n }\n\n /**\n * Register ts-node once so Node can import TS files.\n */\n private registerTsSupport(filePath: string, debug: boolean) {\n if (this.tsSupportRegistered) return;\n this.tsSupportRegistered = ModuleLoader.registerTsNode();\n }\n\n /**\n * Check if a path matches any of the given patterns\n */\n private matchesPatterns(filePath: string, patterns: string[]): boolean {\n return patterns.some((pattern) => {\n // Simple glob matching (supports ** and *)\n const regexPattern = this.buildRegexPattern(pattern);\n\n const regex = new RegExp(regexPattern);\n return regex.test(filePath);\n });\n }\n\n private buildRegexPattern(pattern: string): string {\n const escapedDots = pattern.split(\".\").join(String.raw`\\.`);\n const withPlaceholder = escapedDots.split(\"**\").join(\"__DOUBLE_STAR__\");\n const singleStars = withPlaceholder.split(\"*\").join(\"[^/]*\");\n return singleStars.split(\"__DOUBLE_STAR__\").join(\".*\");\n }\n\n /**\n * Clear the scanned files cache\n */\n clear(): void {\n this.scannedFiles.clear();\n }\n}\n","import { Express } from \"express\";\nimport ArcanaJSServer, { ArcanaJSConfig } from \"./server/ArcanaJSServer\";\n\n// ============================================================================\n// Server Core Exports\n// ============================================================================\n\n// Server\nexport { default as ArcanaJSServer } from \"./server/ArcanaJSServer\";\nexport type { ArcanaJSConfig } from \"./server/ArcanaJSServer\";\n\nexport { Express, NextFunction, Request, Response } from \"express\";\n\n// ============================================================================\n// Routing Exports\n// ============================================================================\n\nexport {\n ArcanaJSRouter,\n default as Route,\n RouteBuilder,\n RouteRegistry,\n} from \"./server/Router\";\n\n// Dynamic router utilities\nexport {\n createDynamicRouter,\n generateViewUrl,\n getViewRoutes,\n matchPattern,\n matchRoute,\n} from \"./server/DynamicRouter\";\n\n// ============================================================================\n// Universal Redirect (SSR + SPA)\n// ============================================================================\n\nexport {\n getSSRContext,\n isRedirectError,\n navigateTo,\n permanentRedirect,\n redirect,\n RedirectError,\n setSSRContext,\n temporaryRedirect,\n} from \"./shared/utils/redirect\";\n\n// ============================================================================\n// Middleware Exports\n// ============================================================================\n\nexport type { Middleware } from \"./validation/http/Middleware\";\n\n// ============================================================================\n// SSR Context & Utilities (for server-side rendering)\n// ============================================================================\n\n// Request context for SSR\nexport {\n createRequestContext,\n getClientRequestContext,\n RequestContext,\n RequestContextProvider,\n} from \"./shared/context/RequestContext\";\nexport type { RequestContextType } from \"./shared/context/RequestContext\";\n\n// Router context for SSR\nexport {\n parseQueryString,\n RouterContext,\n RouterProvider,\n serializeQueryString,\n} from \"./shared/context/RouterContext\";\nexport type {\n NavigateOptions,\n RouterContextType,\n} from \"./shared/context/RouterContext\";\n\n// Shared state for SSR\nexport {\n clearSharedState,\n getSharedState,\n setSharedState,\n SharedStateContext,\n SharedStateProvider,\n} from \"./shared/hooks/useState\";\n\n// Runtime config\nexport {\n getPublicRuntimeConfig,\n getRuntimeConfig,\n RuntimeConfigContext,\n setRuntimeConfig,\n} from \"./shared/hooks/useRuntimeConfig\";\nexport type { RuntimeConfig } from \"./shared/hooks/useRuntimeConfig\";\n\n// Error handling\nexport {\n clearGlobalError,\n createError,\n ErrorContext,\n getGlobalError,\n setGlobalError,\n showError,\n} from \"./shared/hooks/useError\";\nexport type { ArcanaError } from \"./shared/hooks/useError\";\n\n// ============================================================================\n// Server Factory Function\n// ============================================================================\n\n/**\n * Create an ArcanaJS server with the given Express app\n *\n * @param app - Express application instance\n * @param config - Optional ArcanaJS configuration\n * @returns ArcanaJSServer instance\n *\n * @example\n * ```typescript\n * import express from 'express';\n * import { createArcanaServer, Route } from 'arcanajs/server';\n *\n * const app = express();\n *\n * // Define routes with professional features\n * Route.get('/users/:id', [UserController, 'show'])\n * .name('user.show')\n * .whereNumber('id');\n *\n * // Redirects (SSR + SPA compatible)\n * Route.redirect('/old-path', '/new-path');\n *\n * // Generate URL from route name\n * const url = Route.urlFor('user.show', { id: 1 }); // '/users/1'\n *\n * // List all routes\n * Route.printRoutes();\n *\n * const server = createArcanaServer(app, {\n * port: 3000,\n * viewsDir: 'src/resources/views',\n * });\n *\n * server.start();\n * ```\n */\nexport function createArcanaServer(\n app: Express,\n config?: Partial<ArcanaJSConfig>\n): ArcanaJSServer {\n const server = new ArcanaJSServer({ ...config });\n return server;\n}\n","import { NextFunction, Request, Response } from \"express\";\nimport fs from \"fs\";\nimport React from \"react\";\nimport { renderToString } from \"react-dom/server\";\nimport { HeadContext, HeadManager } from \"../shared/context/HeadContext\";\nimport { ArcanaJSApp } from \"../shared/core/ArcanaJSApp\";\nimport { defaultHtmlTemplate } from \"./DefaultTemplate\";\n\nconst DEFAULT_HTML_TEMPLATE = defaultHtmlTemplate;\n\n// Extend Express Response interface\ndeclare global {\n namespace Express {\n interface Response {\n /**\n * Renders a React page using ArcanaJS SSR.\n *\n * @param page - The name of the page component to render.\n * @param data - Initial data to pass to the page component (default: {}).\n * @param params - Route parameters (default: {}).\n * @returns The Express Response object.\n */\n renderPage(\n page: string,\n data?: any,\n params?: Record<string, string>\n ): Response;\n }\n }\n}\n\ninterface ArcanaJSOptions {\n views: Record<string, React.FC<any>>;\n indexFile?: string;\n layout?: React.FC<any>;\n}\n\n// Helper to prevent XSS in initial data\nconst safeStringify = (obj: any) => {\n return JSON.stringify(obj).replace(/</g, \"\\\\u003c\");\n};\n\nexport const createArcanaJSMiddleware = (options: ArcanaJSOptions) => {\n const { views, indexFile, layout } = options;\n let cachedIndexHtml: string | null = null;\n\n const getIndexHtml = (\n callback: (err: NodeJS.ErrnoException | null, data: string) => void\n ) => {\n if (process.env.NODE_ENV === \"production\" && cachedIndexHtml) {\n return callback(null, cachedIndexHtml);\n }\n\n if (indexFile && fs.existsSync(indexFile)) {\n fs.readFile(indexFile, \"utf8\", (err, htmlData) => {\n if (!err && process.env.NODE_ENV === \"production\") {\n cachedIndexHtml = htmlData;\n }\n callback(err, htmlData);\n });\n } else {\n if (process.env.NODE_ENV === \"production\") {\n cachedIndexHtml = DEFAULT_HTML_TEMPLATE;\n }\n callback(null, DEFAULT_HTML_TEMPLATE);\n }\n };\n\n return (req: Request, res: Response, next: NextFunction) => {\n res.renderPage = (\n page: string,\n data: any = {},\n params: Record<string, string> = {}\n ) => {\n const csrfToken = res.locals.csrfToken;\n\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n return res.json({ page, data, params, csrfToken });\n }\n try {\n const headTags: React.ReactNode[] = [];\n const headManager: HeadManager = {\n tags: headTags,\n push: (nodes) => headTags.push(nodes),\n };\n\n const appHtml = renderToString(\n React.createElement(\n HeadContext.Provider,\n { value: headManager },\n React.createElement(ArcanaJSApp, {\n initialPage: page,\n initialData: data,\n initialParams: params,\n initialUrl: req.path,\n csrfToken: csrfToken,\n views: views,\n layout: layout,\n })\n )\n );\n\n const headHtml = renderToString(\n React.createElement(React.Fragment, null, ...headTags)\n );\n\n getIndexHtml((err, htmlData) => {\n if (err) {\n console.error(\"Error reading index.html\", err);\n return res.status(500).send(\"Server Error\");\n }\n\n const scriptContent = safeStringify({\n page,\n data,\n params,\n csrfToken,\n });\n const nonce = res.locals.nonce || \"\";\n const scriptTag = `<script id=\"__ARCANAJS_DATA__\" type=\"application/json\" nonce=\"${nonce}\">${scriptContent}</script>`;\n\n // Inject HMR port for the client (script is auto-injected by webpack)\n const hmrPortScript = process.env.ARCANAJS_HMR_PORT\n ? `<script nonce=\"${nonce}\">window.__ARCANAJS_HMR_PORT__ = ${process.env.ARCANAJS_HMR_PORT};</script>`\n : \"\";\n\n const html = htmlData\n .replace(\"<!--HEAD_CONTENT-->\", headHtml)\n .replace(\"<!--APP_CONTENT-->\", appHtml)\n .replace(\"<!--ARCANAJS_DATA_SCRIPT-->\", scriptTag + hmrPortScript);\n\n res.send(html);\n });\n } catch (error) {\n console.error(\"SSR Error:\", error);\n return res.status(500).send(\"Internal Server Error\");\n }\n return res;\n };\n next();\n };\n};\n","import express, { Express } from \"express\";\nimport { Container } from \"../di/Container\";\nimport { ConfigurationManager } from \"./config/ConfigurationManager\";\nimport { ArcanaJSConfig, ResolvedViews } from \"./config/types\";\nimport { ServerLifecycle } from \"./lifecycle/ServerLifecycle\";\nimport { MiddlewareManager } from \"./middleware/MiddlewareManager\";\nimport { ProviderManager } from \"./providers/ProviderManager\";\nimport { ViewsResolver } from \"./views/ViewsResolver\";\n\n/**\n * Main ArcanaJS Server class - orchestrates all components\n */\nclass ArcanaJSServer {\n public app: Express;\n public container: Container;\n\n private config: ArcanaJSConfig;\n private configManager: ConfigurationManager;\n private providerManager: ProviderManager;\n private middlewareManager: MiddlewareManager;\n private viewsResolver: ViewsResolver;\n private lifecycle: ServerLifecycle;\n\n private resolvedViews!: ResolvedViews;\n private initialized = false;\n\n constructor(config: ArcanaJSConfig) {\n this.config = config;\n this.app = express();\n this.container = Container.getInstance();\n\n // Initialize managers\n this.configManager = new ConfigurationManager(this.container, config);\n this.providerManager = new ProviderManager(this, config);\n this.middlewareManager = new MiddlewareManager(this.app, config);\n this.viewsResolver = new ViewsResolver(config);\n this.lifecycle = new ServerLifecycle(\n this.app,\n config.autoHandleSignals !== false,\n {\n onShutdown: () => this.providerManager.shutdown(),\n }\n );\n\n // Setup middleware immediately\n this.setupMiddleware();\n }\n\n /**\n * Initialize async components (config, providers)\n */\n private async initializeAsync(): Promise<void> {\n if (this.initialized) return;\n\n await this.configManager.load();\n await this.providerManager.register();\n await this.providerManager.boot();\n\n this.initialized = true;\n }\n\n /**\n * Setup all middleware and routes\n */\n private setupMiddleware(): void {\n // Resolve views\n this.resolvedViews = this.viewsResolver.resolve();\n\n // Setup middleware with resolved views and routes\n this.middlewareManager.setup(\n this.resolvedViews,\n this.config.routes,\n this.config.apiRoutes\n );\n }\n\n /**\n * Start the server\n */\n public async start(): Promise<void> {\n await this.initializeAsync();\n\n const port = this.config.port || process.env.PORT || 3000;\n await this.lifecycle.start(port);\n }\n\n /**\n * Stop the server\n */\n public async stop(): Promise<void> {\n await this.lifecycle.stop();\n }\n\n /**\n * Get the resolved views\n */\n public getViews(): ResolvedViews {\n return this.resolvedViews;\n }\n\n /**\n * Get the configuration manager\n */\n public getConfigManager(): ConfigurationManager {\n return this.configManager;\n }\n\n /**\n * Get the provider manager\n */\n public getProviderManager(): ProviderManager {\n return this.providerManager;\n }\n\n /**\n * Check if server is running\n */\n public isRunning(): boolean {\n return this.lifecycle.isRunning();\n }\n}\n\nexport default ArcanaJSServer;\n\n// Re-export types and managers for external use\nexport { ConfigurationManager } from \"./config/ConfigurationManager\";\nexport type { ArcanaJSConfig, ResolvedViews } from \"./config/types\";\nexport { ServerLifecycle } from \"./lifecycle/ServerLifecycle\";\nexport { MiddlewareManager } from \"./middleware/MiddlewareManager\";\nexport { ProviderManager } from \"./providers/ProviderManager\";\nexport { ViewsResolver } from \"./views/ViewsResolver\";\n","import { NextFunction, Request, Response } from \"express\";\n\nimport { container } from \"../di/Container\";\n\nexport default class ControllerBinder {\n static handle(controller: any, method: string) {\n // Instantiate the controller once (Singleton pattern) for performance\n // This assumes controllers are stateless, which is best practice.\n let instance: any;\n try {\n instance = container.make(controller);\n } catch (e) {\n // Fallback if controller is not a class or fails to instantiate\n console.warn(`Failed to instantiate controller ${controller.name}`, e);\n instance = controller;\n }\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n // Call the method\n if (typeof instance[method] === \"function\") {\n await instance[method](req, res, next);\n } else {\n throw new Error(\n `Method ${method} not found on controller ${controller.name}`\n );\n }\n } catch (error) {\n next(error);\n }\n };\n }\n}\n","import crypto from \"crypto\";\nimport { NextFunction, Request, Response } from \"express\";\n\nconst CSRF_COOKIE_NAME = \"_csrf\";\n\nexport const createCsrfMiddleware = () => {\n return (req: Request, res: Response, next: NextFunction) => {\n // 1. Generate or retrieve token\n let token = req.cookies[CSRF_COOKIE_NAME];\n\n if (!token) {\n token = crypto.randomBytes(32).toString(\"hex\");\n res.cookie(CSRF_COOKIE_NAME, token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === \"production\",\n sameSite: \"strict\",\n });\n }\n\n // 2. Expose token to the response locals (for injection into the view)\n res.locals.csrfToken = token;\n\n // 3. Verify token on state-changing methods\n const method = req.method.toUpperCase();\n if ([\"POST\", \"PUT\", \"DELETE\", \"PATCH\"].includes(method)) {\n const headerToken = req.headers[\"x-csrf-token\"];\n\n if (!headerToken || headerToken !== token) {\n return res.status(403).json({ error: \"Invalid CSRF Token\" });\n }\n }\n\n next();\n };\n};\n","export const defaultHtmlTemplate = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <!--HEAD_CONTENT-->\n </head>\n <body>\n <div id=\"root\"><!--APP_CONTENT--></div>\n <!--ARCANAJS_DATA_SCRIPT-->\n </body>\n</html>`;\n","import { NextFunction, Request, Response } from \"express\";\n\n/**\n * Represents matched parameters from dynamic routing\n */\ninterface RouteMatch {\n viewName: string;\n params: Record<string, string>;\n}\n\n/**\n * Match a request path against view patterns\n * Supports:\n * - Exact matches: 'users' matches '/users'\n * - Dynamic segments: 'users/[id]' matches '/users/123'\n * - Catch-all segments: 'docs/[...slug]' matches '/docs/a/b/c'\n * - Optional catch-all: 'docs/[[...slug]]' matches '/docs' and '/docs/a/b/c'\n */\nfunction matchRoute(\n views: Record<string, any>,\n path: string\n): RouteMatch | null {\n // Handle root path\n if (path === \"\") {\n path = \"index\";\n }\n\n // 1. Try exact match first\n if (views[path]) {\n return { viewName: path, params: {} };\n }\n\n // 2. Try dynamic and catch-all matches\n for (const viewName of Object.keys(views)) {\n const match = matchPattern(viewName, path);\n if (match) {\n return { viewName, params: match };\n }\n }\n\n return null;\n}\n\n/**\n * Match a single pattern against a path\n * Returns params object if matched, null otherwise\n */\nfunction matchPattern(\n pattern: string,\n path: string\n): Record<string, string> | null {\n const patternParts = pattern.split(\"/\");\n const pathParts = path.split(\"/\");\n const params: Record<string, string> = {};\n\n let patternIndex = 0;\n let pathIndex = 0;\n\n while (patternIndex < patternParts.length) {\n const patternPart = patternParts[patternIndex];\n\n // Optional catch-all: [[...param]]\n if (patternPart.startsWith(\"[[...\") && patternPart.endsWith(\"]]\")) {\n const paramName = patternPart.slice(5, -2);\n\n // Match remaining path parts (can be empty)\n if (pathIndex < pathParts.length) {\n params[paramName] = pathParts.slice(pathIndex).join(\"/\");\n } else {\n params[paramName] = \"\";\n }\n\n return params;\n }\n\n // Required catch-all: [...param]\n if (patternPart.startsWith(\"[...\") && patternPart.endsWith(\"]\")) {\n const paramName = patternPart.slice(4, -1);\n\n // Must have at least one segment\n if (pathIndex >= pathParts.length) {\n return null;\n }\n\n // Match remaining path parts\n params[paramName] = pathParts.slice(pathIndex).join(\"/\");\n return params;\n }\n\n // Dynamic segment: [param]\n if (patternPart.startsWith(\"[\") && patternPart.endsWith(\"]\")) {\n if (pathIndex >= pathParts.length) {\n return null; // No corresponding path part\n }\n\n const paramName = patternPart.slice(1, -1);\n params[paramName] = pathParts[pathIndex];\n patternIndex++;\n pathIndex++;\n continue;\n }\n\n // Static segment - must match exactly\n if (pathIndex >= pathParts.length || patternPart !== pathParts[pathIndex]) {\n return null;\n }\n\n patternIndex++;\n pathIndex++;\n }\n\n // Path must be fully consumed unless pattern ends with catch-all\n if (pathIndex !== pathParts.length) {\n return null;\n }\n\n return params;\n}\n\n/**\n * Create dynamic router middleware for views\n *\n * Supports file-based routing patterns:\n * - `/users` → 'users' view\n * - `/users/123` → 'users/[id]' view with params.id = '123'\n * - `/docs/a/b/c` → 'docs/[...slug]' view with params.slug = 'a/b/c'\n * - `/docs` or `/docs/x` → 'docs/[[...slug]]' view (optional catch-all)\n *\n * @example\n * // Views structure:\n * {\n * 'index': IndexPage,\n * 'users': UsersPage,\n * 'users/[id]': UserDetailPage,\n * 'docs/[...slug]': DocsPage,\n * 'blog/[[...slug]]': BlogPage,\n * }\n */\nexport const createDynamicRouter = (views: Record<string, any>) => {\n return (req: Request, res: Response, next: NextFunction) => {\n // Remove leading slash\n const path = req.path.substring(1);\n\n // Try to match the route\n const match = matchRoute(views, path);\n\n if (match) {\n return res.renderPage(match.viewName, {}, match.params);\n }\n\n // If not found, pass to the next middleware (usually 404 handler)\n next();\n };\n};\n\n/**\n * Utility to generate a URL from a view name and params\n *\n * @example\n * generateViewUrl('users/[id]', { id: '123' }); // '/users/123'\n * generateViewUrl('docs/[...slug]', { slug: 'api/auth' }); // '/docs/api/auth'\n */\nexport function generateViewUrl(\n viewName: string,\n params: Record<string, string> = {}\n): string {\n let url = viewName;\n\n // Replace dynamic segments with params\n for (const [key, value] of Object.entries(params)) {\n // Match catch-all patterns\n url = url.replace(`[...${key}]`, value);\n url = url.replace(`[[...${key}]]`, value);\n // Match dynamic segments\n url = url.replace(`[${key}]`, value);\n }\n\n // Handle empty optional catch-all\n url = url.replace(/\\/\\[\\[\\.\\.\\..*?\\]\\]/g, \"\");\n\n return `/${url}`;\n}\n\n/**\n * Get all routes from views with their patterns\n */\nexport function getViewRoutes(views: Record<string, any>): Array<{\n pattern: string;\n type: \"static\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\";\n}> {\n return Object.keys(views).map((viewName) => {\n let type: \"static\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\" =\n \"static\";\n\n if (viewName.includes(\"[[...\")) {\n type = \"optional-catch-all\";\n } else if (viewName.includes(\"[...\")) {\n type = \"catch-all\";\n } else if (viewName.includes(\"[\")) {\n type = \"dynamic\";\n }\n\n return {\n pattern: `/${viewName}`,\n type,\n };\n });\n}\n\nexport { matchPattern, matchRoute };\n","import { NextFunction, Request, Response } from \"express\";\n\nimport { container } from \"../di/Container\";\n\nexport default class MiddlewareBinder {\n static handle(middleware: any, method: string = \"handle\") {\n // Instantiate the middleware once (Singleton pattern) for performance\n let instance: any;\n try {\n instance = container.make(middleware);\n } catch (e) {\n // Fallback if middleware is not a class or fails to instantiate\n instance = middleware;\n }\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n // Call the method\n if (typeof instance[method] === \"function\") {\n await instance[method](req, res, next);\n } else {\n throw new Error(\n `Method ${method} not found on middleware ${middleware.name}`\n );\n }\n } catch (error) {\n next(error);\n }\n };\n }\n}\n","import type { NextFunction, Request, Response } from \"express\";\n\nexport const responseHandler = (\n req: Request,\n res: Response,\n next: NextFunction\n) => {\n res.success = (\n data: string | object | null = {},\n message: string = \"Success\",\n status: number = 200\n ) => {\n return res.status(status).json({\n success: true,\n message,\n data,\n error: null,\n });\n };\n\n res.error = (\n message: string = \"Error\",\n status: number = 500,\n error: string | object | null | undefined | unknown = null,\n data: string | object | null = null\n ) => {\n const errorResponse: string | object | null = error\n ? typeof error === \"object\" && error !== null\n ? error instanceof Error\n ? error.toString()\n : error\n : error.toString()\n : null;\n\n return res.status(status).json({\n success: false,\n message,\n data,\n error: errorResponse,\n });\n };\n\n next();\n};\n","import express, {\n Router as ExpressRouter,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\nimport ControllerBinder from \"./ControllerBinder\";\nimport MiddlewareBinder from \"./MiddlewareBinder\";\n\n/**\n * Route definition for internal storage\n */\ninterface RouteDefinition {\n method: string;\n path: string;\n name?: string;\n constraints: Record<string, RegExp>;\n middlewares: RequestHandler[];\n action: any;\n}\n\n/**\n * Named routes registry for reverse routing\n */\nclass RouteRegistry {\n private static routes: Map<string, RouteDefinition> = new Map();\n\n static register(name: string, route: RouteDefinition): void {\n this.routes.set(name, route);\n }\n\n static get(name: string): RouteDefinition | undefined {\n return this.routes.get(name);\n }\n\n static has(name: string): boolean {\n return this.routes.has(name);\n }\n\n static all(): Map<string, RouteDefinition> {\n return this.routes;\n }\n\n static clear(): void {\n this.routes.clear();\n }\n}\n\n/**\n * Route builder for chaining route configuration\n */\nexport class RouteBuilder {\n private routeName?: string;\n private routeConstraints: Record<string, RegExp> = {};\n private registerFn: (\n name?: string,\n constraints?: Record<string, RegExp>\n ) => void;\n\n constructor(\n registerFn: (name?: string, constraints?: Record<string, RegExp>) => void\n ) {\n this.registerFn = registerFn;\n // Auto-register without name if not chained\n setTimeout(() => {\n if (!this.routeName) {\n this.registerFn(undefined, this.routeConstraints);\n }\n }, 0);\n }\n\n /**\n * Assign a name to the route for reverse routing\n *\n * @example\n * Route.get('/users/:id', handler).name('user.show');\n * // Later: Route.urlFor('user.show', { id: 1 }) => '/users/1'\n */\n name(routeName: string): this {\n this.routeName = routeName;\n this.registerFn(routeName, this.routeConstraints);\n return this;\n }\n\n /**\n * Add parameter constraints to the route\n *\n * @example\n * Route.get('/users/:id', handler).where('id', /^\\d+$/);\n */\n where(param: string, pattern: RegExp | string): this {\n this.routeConstraints[param] =\n typeof pattern === \"string\" ? new RegExp(pattern) : pattern;\n return this;\n }\n\n /**\n * Add multiple constraints at once\n *\n * @example\n * Route.get('/posts/:year/:month', handler).whereAll({\n * year: /^\\d{4}$/,\n * month: /^\\d{2}$/\n * });\n */\n whereAll(constraints: Record<string, RegExp | string>): this {\n for (const [param, pattern] of Object.entries(constraints)) {\n this.where(param, pattern);\n }\n return this;\n }\n\n /**\n * Constraint: parameter must be numeric\n */\n whereNumber(param: string): this {\n return this.where(param, /^\\d+$/);\n }\n\n /**\n * Constraint: parameter must be alphabetic\n */\n whereAlpha(param: string): this {\n return this.where(param, /^[a-zA-Z]+$/);\n }\n\n /**\n * Constraint: parameter must be alphanumeric\n */\n whereAlphaNumeric(param: string): this {\n return this.where(param, /^[a-zA-Z0-9]+$/);\n }\n\n /**\n * Constraint: parameter must be a UUID\n */\n whereUuid(param: string): this {\n return this.where(\n param,\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\n );\n }\n\n /**\n * Constraint: parameter must be a slug\n */\n whereSlug(param: string): this {\n return this.where(param, /^[a-z0-9]+(?:-[a-z0-9]+)*$/);\n }\n}\n\n/**\n * Provides Routing syntax for defining routes with prefixes, middlewares, and groups for ArcanaJS Framework\n */\nexport class ArcanaJSRouter {\n private router: ExpressRouter;\n private middlewareStack: RequestHandler[];\n private prefixStack: string[];\n private isApiMode: boolean = false;\n private registeredRoutes: RouteDefinition[] = [];\n\n constructor() {\n this.router = express.Router();\n this.middlewareStack = [];\n this.prefixStack = [];\n }\n\n /**\n * Add middleware to the current stack\n */\n middleware(...middleware: any[]): ArcanaJSRouter {\n const newRouter = this._clone();\n const resolvedMiddlewares = middleware.map((m) =>\n this._resolveMiddleware(m)\n );\n newRouter.middlewareStack = [\n ...this.middlewareStack,\n ...resolvedMiddlewares,\n ];\n return newRouter;\n }\n\n /**\n * Add prefix to the current stack\n */\n prefix(prefix: string): ArcanaJSRouter {\n const newRouter = this._clone();\n newRouter.prefixStack = [\n ...this.prefixStack,\n prefix.replace(/^\\/|\\/$/g, \"\"),\n ];\n return newRouter;\n }\n\n /**\n * Mark routes as API-only (JSON responses, no HTML)\n */\n api(): ArcanaJSRouter {\n const newRouter = this._clone();\n newRouter.isApiMode = true;\n return newRouter;\n }\n\n /**\n * Create a route group\n */\n group(callback: (router: ArcanaJSRouter) => void): ArcanaJSRouter {\n callback(this);\n return this;\n }\n\n /**\n * Define a GET route\n */\n get(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"get\", path, action, middlewares);\n }\n\n /**\n * Define a POST route\n */\n post(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"post\", path, action, middlewares);\n }\n\n /**\n * Define a PUT route\n */\n put(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"put\", path, action, middlewares);\n }\n\n /**\n * Define a DELETE route\n */\n delete(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"delete\", path, action, middlewares);\n }\n\n /**\n * Define a PATCH route\n */\n patch(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"patch\", path, action, middlewares);\n }\n\n /**\n * Define an OPTIONS route\n */\n options(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"options\", path, action, middlewares);\n }\n\n /**\n * Define a resource route\n * Registers index, create, store, show, edit, update, destroy routes\n */\n resource(\n path: string,\n controller: any,\n options?: { only?: string[]; except?: string[] }\n ): ArcanaJSRouter {\n const resourceName = path.replace(/^\\//, \"\").replace(/\\//g, \".\");\n const actions = [\n \"index\",\n \"create\",\n \"store\",\n \"show\",\n \"edit\",\n \"update\",\n \"destroy\",\n ];\n\n const shouldInclude = (action: string) => {\n if (options?.only) return options.only.includes(action);\n if (options?.except) return !options.except.includes(action);\n return true;\n };\n\n if (shouldInclude(\"index\"))\n this.get(path, controller, \"index\").name(`${resourceName}.index`);\n if (shouldInclude(\"create\"))\n this.get(`${path}/create`, controller, \"create\").name(\n `${resourceName}.create`\n );\n if (shouldInclude(\"store\"))\n this.post(path, controller, \"store\").name(`${resourceName}.store`);\n if (shouldInclude(\"show\"))\n this.get(`${path}/:id`, controller, \"show\").name(`${resourceName}.show`);\n if (shouldInclude(\"edit\"))\n this.get(`${path}/:id/edit`, controller, \"edit\").name(\n `${resourceName}.edit`\n );\n if (shouldInclude(\"update\")) {\n this.put(`${path}/:id`, controller, \"update\").name(\n `${resourceName}.update`\n );\n this.patch(`${path}/:id`, controller, \"update\");\n }\n if (shouldInclude(\"destroy\"))\n this.delete(`${path}/:id`, controller, \"destroy\").name(\n `${resourceName}.destroy`\n );\n\n return this;\n }\n\n /**\n * Get the underlying Express router\n */\n getRouter(): ExpressRouter {\n return this.router;\n }\n\n /**\n * Get all registered routes\n */\n getRoutes(): RouteDefinition[] {\n return this.registeredRoutes;\n }\n\n /**\n * Clone the current router instance\n */\n private _clone(): ArcanaJSRouter {\n const newRouter = new ArcanaJSRouter();\n newRouter.router = this.router;\n newRouter.middlewareStack = [...this.middlewareStack];\n newRouter.prefixStack = [...this.prefixStack];\n newRouter.isApiMode = this.isApiMode;\n newRouter.registeredRoutes = this.registeredRoutes;\n return newRouter;\n }\n\n /**\n * Add a route to the router\n */\n private _addRoute(\n method: \"get\" | \"post\" | \"put\" | \"delete\" | \"patch\" | \"options\",\n path: string,\n action: any,\n routeMiddlewares: any[] = []\n ): RouteBuilder {\n const fullPath = this._buildPath(path);\n const handler = this._buildHandler(action);\n const flatMiddlewares = routeMiddlewares.flat(Infinity);\n const resolvedMiddlewares = flatMiddlewares.map((m) =>\n this._resolveMiddleware(m)\n );\n\n // API mode middleware\n const apiMiddleware: RequestHandler[] = this.isApiMode\n ? [\n (_req: Request, res: Response, next: NextFunction) => {\n res.setHeader(\"Content-Type\", \"application/json\");\n next();\n },\n ]\n : [];\n\n const middlewares = [\n ...apiMiddleware,\n ...this.middlewareStack,\n ...resolvedMiddlewares,\n ];\n\n // Create route definition\n const routeDef: RouteDefinition = {\n method: method.toUpperCase(),\n path: fullPath,\n constraints: {},\n middlewares,\n action,\n };\n\n // Create builder that will register the route\n let registered = false;\n const builder = new RouteBuilder((name, constraints) => {\n if (registered) return;\n registered = true;\n\n routeDef.name = name;\n routeDef.constraints = constraints || {};\n\n // Add constraint validation middleware if there are constraints\n const constraintMiddleware: RequestHandler[] =\n Object.keys(routeDef.constraints).length > 0\n ? [this._createConstraintMiddleware(routeDef.constraints)]\n : [];\n\n // Register with Express\n this.router[method](\n fullPath,\n ...constraintMiddleware,\n ...middlewares,\n handler\n );\n\n // Store route definition\n this.registeredRoutes.push(routeDef);\n\n // Register named route\n if (name) {\n RouteRegistry.register(name, routeDef);\n }\n });\n\n return builder;\n }\n\n /**\n * Create middleware for parameter constraint validation\n */\n private _createConstraintMiddleware(\n constraints: Record<string, RegExp>\n ): RequestHandler {\n return (req: Request, res: Response, next: NextFunction) => {\n for (const [param, pattern] of Object.entries(constraints)) {\n const value = req.params[param];\n if (value && !pattern.test(value)) {\n return res.status(404).json({\n error: \"Not Found\",\n message: `Parameter '${param}' does not match required pattern`,\n });\n }\n }\n next();\n };\n }\n\n /**\n * Resolve middleware to RequestHandler\n */\n private _resolveMiddleware(middleware: any): RequestHandler {\n if (typeof middleware === \"function\" && !middleware.prototype?.handle) {\n // It's a standard express middleware function\n return middleware;\n }\n\n if (Array.isArray(middleware) && middleware.length === 2) {\n // It's [MiddlewareClass, 'method']\n const [middlewareClass, method] = middleware;\n return MiddlewareBinder.handle(middlewareClass, method);\n }\n\n if (\n typeof middleware === \"function\" ||\n (typeof middleware === \"object\" && middleware !== null)\n ) {\n // It's a Middleware Class (constructor) or instance\n // Default to 'handle' method\n return MiddlewareBinder.handle(middleware, \"handle\");\n }\n\n throw new Error(\n \"Invalid middleware. Must be a function, [Class, 'method'], or Class.\"\n );\n }\n\n /**\n * Build the full path with prefixes\n */\n private _buildPath(path: string): string {\n const cleanPath = path.replace(/^\\//, \"\");\n const prefixes = this.prefixStack.filter((p) => p !== \"\");\n\n if (prefixes.length === 0) {\n return `/${cleanPath}`;\n }\n\n return `/${prefixes.join(\"/\")}/${cleanPath}`.replace(/\\/+/g, \"/\");\n }\n\n /**\n * Build the route handler\n */\n private _buildHandler(action: any): RequestHandler {\n if (typeof action === \"function\") {\n return action;\n }\n\n if (Array.isArray(action) && action.length === 2) {\n const [controller, method] = action;\n return ControllerBinder.handle(controller, method);\n }\n\n throw new Error(\n 'Action must be a function or array [Controller, \"method\"]'\n );\n }\n}\n\n/**\n * Static Route class for ArcanaJS Routing\n */\nexport class Route {\n private static _router = new ArcanaJSRouter();\n private static _allRoutes: RouteDefinition[] = [];\n\n static middleware(...middleware: any[]): typeof Route {\n this._router = this._router.middleware(...middleware);\n return this;\n }\n\n static prefix(prefix: string): typeof Route {\n this._router = this._router.prefix(prefix);\n return this;\n }\n\n /**\n * Mark following routes as API-only (JSON responses)\n */\n static api(): typeof Route {\n this._router = this._router.api();\n return this;\n }\n\n static group(callback: (router: ArcanaJSRouter) => void): typeof Route {\n this._router.group(callback);\n return this;\n }\n\n static get(path: string, ...args: any[]): RouteBuilder {\n return this._router.get(path, ...args);\n }\n\n static post(path: string, ...args: any[]): RouteBuilder {\n return this._router.post(path, ...args);\n }\n\n static put(path: string, ...args: any[]): RouteBuilder {\n return this._router.put(path, ...args);\n }\n\n static delete(path: string, ...args: any[]): RouteBuilder {\n return this._router.delete(path, ...args);\n }\n\n static patch(path: string, ...args: any[]): RouteBuilder {\n return this._router.patch(path, ...args);\n }\n\n static options(path: string, ...args: any[]): RouteBuilder {\n return this._router.options(path, ...args);\n }\n\n static resource(\n path: string,\n controller: any,\n options?: { only?: string[]; except?: string[] }\n ): typeof Route {\n this._router.resource(path, controller, options);\n return this;\n }\n\n /**\n * Define a redirect route\n *\n * @example\n * Route.redirect('/old-path', '/new-path');\n * Route.redirect('/legacy', '/modern', 301);\n */\n static redirect(\n from: string,\n to: string,\n status: number = 302\n ): typeof Route {\n this._router.get(from, (req: Request, res: Response) => {\n // Check if this is an ArcanaJS SPA request\n const isArcanaRequest = req.headers[\"x-arcanajs-request\"] === \"true\";\n\n if (isArcanaRequest) {\n // For SPA navigation, return JSON with redirect info\n res.json({\n redirect: true,\n url: to,\n status,\n });\n } else {\n // For SSR/traditional navigation, use HTTP redirect\n res.redirect(status, to);\n }\n });\n return this;\n }\n\n /**\n * Define a permanent redirect (301)\n *\n * @example\n * Route.permanentRedirect('/old', '/new');\n */\n static permanentRedirect(from: string, to: string): typeof Route {\n return this.redirect(from, to, 301);\n }\n\n /**\n * Generate URL for a named route\n *\n * @example\n * Route.urlFor('user.show', { id: 1 }); // => '/users/1'\n */\n static urlFor(\n name: string,\n params: Record<string, string | number> = {}\n ): string {\n const route = RouteRegistry.get(name);\n if (!route) {\n throw new Error(\n `Route '${name}' not found. Make sure to define routes with .name('${name}')`\n );\n }\n\n let url = route.path;\n\n // Replace named parameters\n for (const [key, value] of Object.entries(params)) {\n url = url.replace(`:${key}`, String(value));\n }\n\n // Check for any remaining unresolved parameters\n const unresolvedParams = url.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);\n if (unresolvedParams) {\n throw new Error(\n `Missing required parameters: ${unresolvedParams.join(\", \")}`\n );\n }\n\n return url;\n }\n\n /**\n * Check if a named route exists\n */\n static hasRoute(name: string): boolean {\n return RouteRegistry.has(name);\n }\n\n /**\n * List all registered routes\n *\n * @example\n * const routes = Route.list();\n * console.table(routes);\n */\n static list(): Array<{ method: string; path: string; name?: string }> {\n return this._allRoutes.map((r) => ({\n method: r.method,\n path: r.path,\n name: r.name,\n }));\n }\n\n /**\n * Print all routes to console in a formatted table\n */\n static printRoutes(): void {\n const routes = this.list();\n console.log(\"\\n📍 Registered Routes:\\n\");\n console.log(\"─\".repeat(60));\n console.log(\"METHOD\".padEnd(10) + \"PATH\".padEnd(35) + \"NAME\");\n console.log(\"─\".repeat(60));\n for (const route of routes) {\n console.log(\n route.method.padEnd(10) + route.path.padEnd(35) + (route.name || \"-\")\n );\n }\n console.log(\"─\".repeat(60));\n console.log(`Total: ${routes.length} routes\\n`);\n }\n\n static getRouter(): ExpressRouter {\n const router = this._router.getRouter();\n this._allRoutes = [...this._allRoutes, ...this._router.getRoutes()];\n this._router = new ArcanaJSRouter(); // Reset for next use\n return router;\n }\n}\n\nexport { RouteRegistry };\nexport default Route;\n","import { IApplication } from \"./types/IApplication\";\n\nexport abstract class ServiceProvider {\n protected app: IApplication;\n\n constructor(app: IApplication) {\n this.app = app;\n }\n\n /**\n * Register any application services.\n */\n register(): void {\n //\n }\n\n /**\n * Bootstrap any application services.\n */\n boot(): void {\n //\n }\n\n /**\n * Shutdown any application services.\n */\n async shutdown(): Promise<void> {\n //\n }\n}\n","import { Container } from \"../../di/Container\";\nimport { ArcanaJSConfig } from \"./types\";\n\n/**\n * Manages configuration loading and registration in the DI container\n */\nexport class ConfigurationManager {\n private container: Container;\n private config: ArcanaJSConfig;\n\n constructor(container: Container, config: ArcanaJSConfig) {\n this.container = container;\n this.config = config;\n }\n\n /**\n * Load and register all configurations in the container\n */\n public async load(): Promise<void> {\n if (this.config.auth) {\n this.container.singleton(\"AuthConfig\", () => this.config.auth);\n }\n\n if (this.config.mail) {\n this.container.singleton(\"MailConfig\", () => this.config.mail);\n }\n\n if (this.config.database) {\n this.container.singleton(\"DatabaseConfig\", () => this.config.database);\n }\n }\n\n /**\n * Get a specific configuration value\n */\n public get<T>(key: keyof ArcanaJSConfig): T | undefined {\n return this.config[key] as T | undefined;\n }\n\n /**\n * Get the full configuration object\n */\n public getAll(): ArcanaJSConfig {\n return this.config;\n }\n}\n","import { Express } from \"express\";\nimport http from \"http\";\n\nexport interface LifecycleHandlers {\n onShutdown: () => Promise<void>;\n}\n\n/**\n * Manages server lifecycle (start, stop, signal handling)\n */\nexport class ServerLifecycle {\n private app: Express;\n private serverInstance?: http.Server;\n private isShuttingDown = false;\n private autoHandleSignals: boolean;\n private handlers: LifecycleHandlers;\n\n private _sigintHandler?: () => void;\n private _sigtermHandler?: () => void;\n\n constructor(\n app: Express,\n autoHandleSignals: boolean,\n handlers: LifecycleHandlers\n ) {\n this.app = app;\n this.autoHandleSignals = autoHandleSignals;\n this.handlers = handlers;\n }\n\n /**\n * Start the HTTP server\n */\n public async start(port: number | string): Promise<void> {\n if (this.serverInstance) {\n console.warn(\n \"Server is already running. Call stop() before starting again.\"\n );\n return;\n }\n\n this.serverInstance = this.app.listen(port, () => {\n console.log(`✓ Server is running on http://localhost:${port}`);\n });\n\n this.setupServerErrorHandler(port);\n\n if (this.autoHandleSignals) {\n this.setupSignalHandlers();\n }\n }\n\n /**\n * Setup server error handler\n */\n private setupServerErrorHandler(port: number | string): void {\n this.serverInstance!.on(\"error\", (error: any) => {\n if (error.code === \"EADDRINUSE\") {\n console.error(`✗ Port ${port} is already in use`);\n process.exit(1);\n } else {\n console.error(\"✗ Server error:\", error);\n }\n });\n }\n\n /**\n * Setup process signal handlers for graceful shutdown\n */\n private setupSignalHandlers(): void {\n const shutdown = async (signal: string) => {\n if (this.isShuttingDown) return;\n this.isShuttingDown = true;\n console.log(`\\n⚠ Received ${signal}, shutting down gracefully...`);\n\n // Force exit after 5s if graceful shutdown hangs (reduced from 10s for dev mode)\n const forceExit = setTimeout(() => {\n console.error(\"✗ Shutdown timed out, forcing exit\");\n process.exit(1);\n }, 5000);\n forceExit.unref();\n\n try {\n await this.stop();\n clearTimeout(forceExit);\n console.log(\"✓ Shutdown complete\");\n process.exit(0);\n } catch (err) {\n clearTimeout(forceExit);\n console.error(\"✗ Error during shutdown:\", err);\n process.exit(1);\n }\n };\n\n this._sigintHandler = () => shutdown(\"SIGINT\");\n this._sigtermHandler = () => shutdown(\"SIGTERM\");\n\n process.on(\"SIGINT\", this._sigintHandler);\n process.on(\"SIGTERM\", this._sigtermHandler);\n\n console.log(\"✓ Signal handlers registered (Ctrl+C to stop)\");\n }\n\n /**\n * Stop the HTTP server\n */\n public async stop(): Promise<void> {\n if (this.isShuttingDown && !this.serverInstance) return;\n this.isShuttingDown = true;\n\n // Close HTTP server\n if (this.serverInstance) {\n console.log(\"⏳ Stopping HTTP server...\");\n await new Promise<void>((resolve, reject) => {\n this.serverInstance!.close((err) => {\n if (err) {\n console.error(\"✗ Error closing HTTP server:\", err);\n return reject(err);\n }\n resolve();\n });\n });\n this.serverInstance = undefined;\n console.log(\"✓ HTTP server stopped\");\n } else {\n console.log(\"ℹ HTTP server is not running\");\n }\n\n // Call shutdown handler for providers, etc.\n await this.handlers.onShutdown();\n\n // Remove signal handlers\n this.removeSignalHandlers();\n }\n\n /**\n * Remove registered signal handlers\n */\n private removeSignalHandlers(): void {\n try {\n if (this._sigintHandler) {\n process.removeListener(\"SIGINT\", this._sigintHandler);\n this._sigintHandler = undefined;\n }\n if (this._sigtermHandler) {\n process.removeListener(\"SIGTERM\", this._sigtermHandler);\n this._sigtermHandler = undefined;\n }\n } catch (err) {\n // Ignore errors while removing listeners\n }\n }\n\n /**\n * Check if server is currently running\n */\n public isRunning(): boolean {\n return !!this.serverInstance;\n }\n\n /**\n * Get the HTTP server instance\n */\n public getServerInstance(): http.Server | undefined {\n return this.serverInstance;\n }\n}\n","import compression from \"compression\";\nimport cookieParser from \"cookie-parser\";\nimport express, { Express, RequestHandler } from \"express\";\nimport helmet from \"helmet\";\nimport path from \"path\";\nimport React from \"react\";\nimport { createArcanaJSMiddleware } from \"../ArcanaJSMiddleware\";\nimport { createCsrfMiddleware } from \"../CsrfMiddleware\";\nimport { createDynamicRouter } from \"../DynamicRouter\";\nimport { responseHandler } from \"../ResponseHandlerMiddleware\";\nimport { ArcanaJSConfig, ResolvedViews } from \"../config/types\";\n\nexport interface MiddlewareConfig {\n staticDir: string;\n distDir: string;\n indexFile: string;\n layout?: React.FC<any>;\n apiBase: string;\n}\n\n/**\n * Manages Express middleware setup and configuration\n */\nexport class MiddlewareManager {\n private app: Express;\n private config: MiddlewareConfig;\n\n constructor(app: Express, config: ArcanaJSConfig) {\n this.app = app;\n this.config = {\n staticDir: config.staticDir || \"public\",\n distDir: config.distDir || \".arcanajs/client\",\n indexFile: config.indexFile || \".arcanajs/client/index.html\",\n layout: config.layout,\n apiBase: config.apiBase || \"/api\",\n };\n }\n\n /**\n * Setup all middleware in the correct order\n */\n public setup(\n views: ResolvedViews,\n routes?: RequestHandler | RequestHandler[],\n apiRoutes?: RequestHandler | RequestHandler[]\n ): void {\n const root = process.cwd();\n\n this.setupNonceGeneration();\n this.setupSecurityHeaders();\n this.setupParsers();\n this.setupStaticFiles(root);\n this.setupCompression();\n this.setupArcanaJSMiddleware(views, root);\n this.mountRoutes(apiRoutes, this.config.apiBase);\n this.mountRoutes(routes);\n this.setupDynamicRouter(views);\n this.setupErrorHandlers();\n }\n\n /**\n * Generate nonce for CSP\n */\n private setupNonceGeneration(): void {\n this.app.use(\n (\n req: express.Request,\n res: express.Response,\n next: express.NextFunction\n ) => {\n const nonce = require(\"crypto\").randomBytes(16).toString(\"base64\");\n res.locals.nonce = nonce;\n next();\n }\n );\n }\n\n /**\n * Setup security headers with Helmet\n */\n private setupSecurityHeaders(): void {\n const isDevelopment = process.env.NODE_ENV === \"development\";\n\n this.app.use(\n helmet({\n contentSecurityPolicy: {\n directives: {\n ...helmet.contentSecurityPolicy.getDefaultDirectives(),\n \"style-src\": [\"'self'\", \"'unsafe-inline'\"],\n \"script-src\": [\n \"'self'\",\n (req, res) => `'nonce-${(res as express.Response).locals.nonce}'`,\n ],\n \"connect-src\": isDevelopment\n ? [\"'self'\", \"ws://localhost:*\", \"wss://localhost:*\"]\n : [\"'self'\"],\n },\n },\n })\n );\n }\n\n /**\n * Setup body parsers and cookie parser\n */\n private setupParsers(): void {\n this.app.use(cookieParser());\n this.app.use(express.json());\n this.app.use(express.urlencoded({ extended: true }));\n this.app.use(createCsrfMiddleware());\n this.app.use(responseHandler);\n }\n\n /**\n * Setup static file serving\n */\n private setupStaticFiles(root: string): void {\n const isProduction = process.env.NODE_ENV === \"production\";\n const staticOptions = { index: false, maxAge: isProduction ? \"1y\" : \"0\" };\n\n const staticPaths = [\n path.resolve(root, this.config.distDir),\n path.resolve(root, this.config.staticDir),\n ].filter((p, i, a) => a.indexOf(p) === i);\n\n for (const p of staticPaths) {\n this.app.use(express.static(p, staticOptions));\n }\n }\n\n /**\n * Setup response compression\n */\n private setupCompression(): void {\n this.app.use(compression());\n }\n\n /**\n * Setup ArcanaJS specific middleware\n */\n private setupArcanaJSMiddleware(views: ResolvedViews, root: string): void {\n this.app.use(\n createArcanaJSMiddleware({\n views,\n indexFile: path.resolve(root, this.config.indexFile),\n layout: this.config.layout,\n })\n );\n }\n\n /**\n * Mount routes (API or web)\n */\n private mountRoutes(\n target: RequestHandler | RequestHandler[] | undefined,\n base?: string\n ): void {\n if (!target) return;\n\n const items = Array.isArray(target) ? target : [target];\n for (const r of items) {\n if (!r) continue;\n try {\n if (typeof (r as any).getRouter === \"function\") {\n this.app.use(base || \"/\", (r as any).getRouter());\n } else {\n this.app.use(base || \"/\", r as RequestHandler);\n }\n if (base) {\n console.log(`API routes mounted at ${base}`);\n }\n } catch (err) {\n console.error(\n `Error mounting routes${base ? ` at ${base}` : \"\"}:`,\n err\n );\n }\n }\n }\n\n /**\n * Setup dynamic router for views\n */\n private setupDynamicRouter(views: ResolvedViews): void {\n this.app.use(createDynamicRouter(views));\n }\n\n /**\n * Setup 404 and error handlers\n */\n private setupErrorHandlers(): void {\n // 404 handler\n this.app.use((req: express.Request, res: express.Response) => {\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n res.status(404).json({\n page: \"NotFoundPage\",\n data: { url: req.url },\n params: {},\n csrfToken: res.locals.csrfToken,\n });\n } else {\n res.status(404).renderPage(\"NotFoundPage\", { url: req.url });\n }\n });\n\n // Error handler\n this.app.use(\n (\n err: any,\n req: express.Request,\n res: express.Response,\n next: express.NextFunction\n ) => {\n console.error(err);\n const message =\n process.env.NODE_ENV === \"production\"\n ? \"Internal Server Error\"\n : err.message;\n\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n res.status(500).json({\n page: \"ErrorPage\",\n data: { message },\n params: {},\n csrfToken: res.locals.csrfToken,\n });\n } else {\n res.status(500).renderPage(\"ErrorPage\", { message });\n }\n }\n );\n }\n}\n","import {\n AutoRegisterConfig,\n AutoRegisterProvider,\n} from \"../../di/providers/AutoRegisterProvider\";\nimport { ServiceProvider } from \"../ServiceProvider\";\nimport { ArcanaJSConfig } from \"../config/types\";\n\n/**\n * Manages service providers lifecycle (registration, boot, shutdown)\n */\nexport class ProviderManager {\n private providers: ServiceProvider[] = [];\n private app: any;\n private config: ArcanaJSConfig;\n\n constructor(app: any, config: ArcanaJSConfig) {\n this.app = app;\n this.config = config;\n }\n\n /**\n * Register all service providers\n */\n public async register(): Promise<void> {\n // Auto-discovery provider\n if (this.config.autoDiscovery && this.config.autoDiscovery.enabled) {\n await this.registerAutoDiscoveryProvider();\n }\n\n // Custom providers\n if (this.config.providers) {\n await this.registerCustomProviders();\n }\n }\n\n /**\n * Register auto-discovery provider with ArcanaJS structure\n */\n private async registerAutoDiscoveryProvider(): Promise<void> {\n const directories = [\n \"src/app/Http/Controllers\",\n \"src/app/Services\",\n \"src/app/Repositories\",\n ];\n\n const config: AutoRegisterConfig = {\n ...this.config.autoDiscovery!,\n directories,\n };\n\n const provider = new AutoRegisterProvider(this.app, config);\n await provider.register();\n this.providers.push(provider);\n }\n\n /**\n * Register custom service providers\n */\n private async registerCustomProviders(): Promise<void> {\n for (const ProviderClass of this.config.providers!) {\n const provider = new ProviderClass(this.app);\n await provider.register();\n this.providers.push(provider);\n }\n }\n\n /**\n * Boot all registered providers\n */\n public async boot(): Promise<void> {\n for (const provider of this.providers) {\n await provider.boot();\n }\n }\n\n /**\n * Shutdown all providers gracefully\n */\n public async shutdown(): Promise<void> {\n if (this.providers.length === 0) return;\n\n console.log(\"⏳ Shutting down providers...\");\n for (const provider of this.providers) {\n if (provider.shutdown) {\n try {\n await provider.shutdown();\n console.log(`✓ ${provider.constructor.name} shut down`);\n } catch (err) {\n console.error(\n `✗ Error shutting down provider ${provider.constructor.name}:`,\n err\n );\n }\n }\n }\n }\n\n /**\n * Get all registered providers\n */\n public getProviders(): ServiceProvider[] {\n return this.providers;\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport React from \"react\";\nimport { ModuleLoader } from \"../../../utils/ModuleLoader\";\nimport ErrorPage from \"../../shared/views/ErrorPage\";\nimport NotFoundPage from \"../../shared/views/NotFoundPage\";\nimport { ArcanaJSConfig, ResolvedViews } from \"../config/types\";\n\n/**\n * Resolves and loads view components from various sources\n */\nexport class ViewsResolver {\n private config: ArcanaJSConfig;\n\n constructor(config: ArcanaJSConfig) {\n this.config = config;\n }\n\n /**\n * Resolve views from all possible sources in priority order\n */\n public resolve(): ResolvedViews {\n let resolvedViews = this.config.views;\n\n // Try loading from context\n if (!resolvedViews && this.config.viewsContext) {\n resolvedViews = this.loadFromContext(this.config.viewsContext);\n }\n\n // Try loading from alias\n if (!resolvedViews) {\n resolvedViews = this.loadFromAlias();\n }\n\n // Try discovering views\n if (!resolvedViews) {\n resolvedViews = this.discoverViews();\n }\n\n // Warn if no views found\n if (!resolvedViews || Object.keys(resolvedViews).length === 0) {\n console.warn(\"No views found. Please check your views directory.\");\n resolvedViews = {} as Record<string, React.FC<any>>;\n }\n\n // Add default pages\n return {\n ...resolvedViews,\n NotFoundPage: resolvedViews.NotFoundPage || NotFoundPage,\n ErrorPage: resolvedViews.ErrorPage || ErrorPage,\n } as ResolvedViews;\n }\n\n /**\n * Load views from a webpack context\n */\n private loadFromContext(context: any): Record<string, React.FC<any>> {\n const views: Record<string, React.FC<any>> = {};\n context.keys().forEach((key: string) => {\n const viewName = key.replace(/^\\.\\/(.*)\\.tsx$/, \"$1\");\n views[viewName] = context(key).default;\n });\n return views;\n }\n\n /**\n * Load views from webpack alias\n */\n private loadFromAlias(): Record<string, React.FC<any>> | undefined {\n try {\n // @ts-ignore - This alias is injected by Webpack\n const injectedViews = require(\"arcanajs-views\");\n if (injectedViews) {\n return this.loadFromContext(injectedViews);\n }\n } catch (e) {\n // Alias not available\n }\n return undefined;\n }\n\n /**\n * Discover views by scanning the views directory\n */\n private discoverViews(): Record<string, React.FC<any>> {\n const views: Record<string, React.FC<any>> = {};\n const viewsDir = this.config.viewsDir\n ? path.resolve(process.cwd(), this.config.viewsDir)\n : path.resolve(process.cwd(), \"src/resources/views\");\n\n if (!fs.existsSync(viewsDir)) {\n return views;\n }\n\n this.traverseDirectory(viewsDir, viewsDir, views);\n return views;\n }\n\n /**\n * Recursively traverse a directory to find view files\n */\n private traverseDirectory(\n dir: string,\n baseDir: string,\n views: Record<string, React.FC<any>>\n ): void {\n const files = fs.readdirSync(dir);\n\n files.forEach((file) => {\n const fullPath = path.join(dir, file);\n const stat = fs.statSync(fullPath);\n\n if (stat.isDirectory()) {\n this.traverseDirectory(fullPath, baseDir, views);\n } else if (file.endsWith(\".tsx\") || file.endsWith(\".jsx\")) {\n this.loadViewFile(fullPath, baseDir, views);\n }\n });\n }\n\n /**\n * Load a single view file\n */\n private loadViewFile(\n fullPath: string,\n baseDir: string,\n views: Record<string, React.FC<any>>\n ): void {\n const relativePath = path.relative(baseDir, fullPath);\n const viewName = relativePath.replace(/\\.(tsx|jsx)$/, \"\");\n\n try {\n // Register ts-node if needed for TypeScript files\n if (fullPath.endsWith(\".tsx\") || fullPath.endsWith(\".ts\")) {\n ModuleLoader.registerTsNode();\n }\n\n const pageModule = ModuleLoader.require(fullPath);\n views[viewName] = pageModule.default || pageModule;\n } catch (error) {\n console.error(`Failed to load view ${viewName}:`, error);\n }\n }\n}\n","import React from \"react\";\n\n/**\n * BodyProps - Props for the Body component\n */\nexport interface BodyProps {\n /** Body content */\n children: React.ReactNode;\n /** Additional CSS class for the body wrapper */\n className?: string;\n /** Body ID for styling/testing */\n id?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n /** Reference to the body element */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Body - Page content wrapper component for ArcanaJS\n *\n * Use this component to wrap your page content. It provides semantic\n * structure and separation from the Head component.\n *\n * ## Why Use Body?\n *\n * 1. **Semantic Structure** - Clearly separates meta (Head) from content (Body)\n * 2. **Styling Hook** - Easy to apply global page styles\n * 3. **Layout Support** - Works with layouts for consistent page structure\n * 4. **SSR-Ready** - Consistent rendering between server and client\n *\n * @example\n * ```tsx\n * // Basic usage with Page and Head\n * import { Page, Head, Body } from 'arcanajs/client';\n *\n * export default function HomePage() {\n * return (\n * <Page>\n * <Head>\n * <title>Home</title>\n * </Head>\n * <Body>\n * <header>...</header>\n * <main>...</main>\n * <footer>...</footer>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With styling\n * import { Page, Body } from 'arcanajs/client';\n *\n * export default function DarkPage() {\n * return (\n * <Page title=\"Dark Mode\">\n * <Body className=\"bg-gray-900 text-white min-h-screen\">\n * <div className=\"container mx-auto py-8\">\n * <h1>Welcome to the dark side</h1>\n * </div>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Full page structure\n * import { Page, Head, Body, usePage, Link } from 'arcanajs/client';\n *\n * interface PageData {\n * posts: Array<{ id: string; title: string }>;\n * }\n *\n * export default function BlogPage() {\n * const { posts } = usePage<PageData>();\n *\n * return (\n * <Page>\n * <Head>\n * <title>Blog</title>\n * <meta name=\"description\" content=\"Latest articles\" />\n * </Head>\n * <Body className=\"min-h-screen flex flex-col\">\n * <header className=\"border-b p-4\">\n * <nav>\n * <Link href=\"/\">Home</Link>\n * <Link href=\"/blog\">Blog</Link>\n * </nav>\n * </header>\n *\n * <main className=\"flex-1 p-4\">\n * <h1>Latest Posts</h1>\n * <ul>\n * {posts.map(post => (\n * <li key={post.id}>\n * <Link href={`/blog/${post.id}`}>{post.title}</Link>\n * </li>\n * ))}\n * </ul>\n * </main>\n *\n * <footer className=\"border-t p-4 text-center\">\n * © 2025 My Blog\n * </footer>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n */\nconst Body = React.forwardRef<HTMLDivElement, BodyProps>(\n ({ children, className, id, style }, ref) => {\n return (\n <div\n ref={ref}\n className={className}\n id={id}\n style={style}\n data-arcanajs-body\n >\n {children}\n </div>\n );\n }\n);\n\nBody.displayName = \"Body\";\n\nexport default Body;\n","import React, { useEffect, useRef } from \"react\";\nimport { useHead } from \"../hooks/useHead\";\n\n/**\n * HeadProps - Props for the Head component\n */\nexport interface HeadProps {\n /** Child elements (title, meta, link, script, style) */\n children: React.ReactNode;\n}\n\n/**\n * Common meta tag definitions for convenience\n */\nexport interface MetaDefinition {\n /** Standard name attribute */\n name?: string;\n /** Open Graph / Twitter property */\n property?: string;\n /** HTTP equiv */\n httpEquiv?: string;\n /** Content value */\n content: string;\n /** Charset (for charset meta) */\n charset?: string;\n}\n\n/**\n * Head - Document head management component for ArcanaJS\n *\n * Use this component to manage document head elements like title,\n * meta tags, links, and scripts. Works seamlessly with SSR.\n *\n * ## Supported Elements\n *\n * - `<title>` - Page title\n * - `<meta>` - Meta tags (SEO, Open Graph, Twitter)\n * - `<link>` - Stylesheets, preload, canonical\n * - `<script>` - External scripts, JSON-LD\n * - `<style>` - Inline styles (use sparingly)\n *\n * @example\n * ```tsx\n * // Basic SEO tags\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <title>My Awesome Page</title>\n * <meta name=\"description\" content=\"Page description for SEO\" />\n * <meta name=\"keywords\" content=\"react, arcanajs, framework\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // Social media / Open Graph\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <title>Share This!</title>\n * <meta property=\"og:title\" content=\"Share This!\" />\n * <meta property=\"og:description\" content=\"Check out this page\" />\n * <meta property=\"og:image\" content=\"https://example.com/og.jpg\" />\n * <meta property=\"og:url\" content=\"https://example.com/page\" />\n * <meta name=\"twitter:card\" content=\"summary_large_image\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // Preloading resources\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <link rel=\"preload\" href=\"/fonts/Inter.woff2\" as=\"font\" crossOrigin=\"\" />\n * <link rel=\"preconnect\" href=\"https://api.example.com\" />\n * <link rel=\"canonical\" href=\"https://example.com/page\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // JSON-LD structured data\n * import { Head } from 'arcanajs/client';\n *\n * const structuredData = {\n * \"@context\": \"https://schema.org\",\n * \"@type\": \"Article\",\n * \"headline\": \"My Article\",\n * };\n *\n * <Head>\n * <script\n * type=\"application/ld+json\"\n * dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}\n * />\n * </Head>\n * ```\n */\nconst Head: React.FC<HeadProps> = ({ children }) => {\n const headManager = useHead();\n const processedRef = useRef(false);\n\n // Server-side: Push tags to context\n if (typeof window === \"undefined\" && headManager && !processedRef.current) {\n processedRef.current = true;\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n headManager.push(\n React.cloneElement(child as React.ReactElement<any>, {\n \"data-arcanajs-head\": \"true\",\n })\n );\n }\n });\n }\n\n // Client-side: Update DOM\n useEffect(() => {\n const managedElements: HTMLElement[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) return;\n\n const reactElement = child as React.ReactElement<any>;\n const tagType = reactElement.type;\n\n // Handle title\n if (tagType === \"title\") {\n const newTitle = reactElement.props.children;\n if (typeof newTitle === \"string\") {\n document.title = newTitle;\n }\n return;\n }\n\n // Handle meta tags\n if (tagType === \"meta\") {\n const props = reactElement.props;\n const element = createOrUpdateElement(\"meta\", props, {\n identifiers: [\"name\", \"property\", \"http-equiv\", \"charset\"],\n });\n if (element) managedElements.push(element);\n return;\n }\n\n // Handle link tags\n if (tagType === \"link\") {\n const props = reactElement.props;\n const element = createOrUpdateElement(\"link\", props, {\n identifiers: [\"rel\", \"href\"],\n });\n if (element) managedElements.push(element);\n return;\n }\n\n // Handle script tags\n if (tagType === \"script\") {\n const props = reactElement.props;\n const script = document.createElement(\"script\");\n\n Object.keys(props).forEach((key) => {\n if (key === \"dangerouslySetInnerHTML\") {\n script.innerHTML = props[key].__html;\n } else if (key === \"children\") {\n script.innerHTML = typeof props[key] === \"string\" ? props[key] : \"\";\n } else if (key !== \"key\" && key !== \"ref\") {\n script.setAttribute(\n key === \"className\" ? \"class\" : key,\n props[key]\n );\n }\n });\n\n script.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(script);\n managedElements.push(script);\n return;\n }\n\n // Handle style tags\n if (tagType === \"style\") {\n const props = reactElement.props;\n const style = document.createElement(\"style\");\n\n if (props.dangerouslySetInnerHTML) {\n style.innerHTML = props.dangerouslySetInnerHTML.__html;\n } else if (props.children) {\n style.innerHTML =\n typeof props.children === \"string\" ? props.children : \"\";\n }\n\n style.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(style);\n managedElements.push(style);\n return;\n }\n });\n\n return () => {\n // Cleanup managed elements on unmount\n managedElements.forEach((el) => {\n if (el.parentNode) {\n el.remove();\n }\n });\n };\n }, [children]);\n\n return null;\n};\n\n/**\n * Helper to create or update head elements\n */\nfunction createOrUpdateElement(\n tagName: string,\n props: Record<string, any>,\n options: { identifiers: string[] }\n): HTMLElement | null {\n let selector = tagName;\n let hasIdentifier = false;\n\n // Build selector from identifiers\n for (const id of options.identifiers) {\n const propName = id === \"http-equiv\" ? \"httpEquiv\" : id;\n if (props[propName]) {\n selector += `[${id}=\"${props[propName]}\"]`;\n hasIdentifier = true;\n }\n }\n\n if (!hasIdentifier && tagName !== \"link\") {\n return null; // Skip elements without identifiers (except links which can be unique by href)\n }\n\n // Try to find existing element\n let element =\n document.querySelector(selector + '[data-arcanajs-head=\"true\"]') ||\n document.querySelector(selector);\n\n if (element) {\n // Update existing element\n Object.keys(props).forEach((key) => {\n if (key !== \"key\" && key !== \"ref\" && key !== \"children\") {\n const attrName = key === \"className\" ? \"class\" : key;\n element!.setAttribute(attrName, props[key]);\n }\n });\n element.setAttribute(\"data-arcanajs-head\", \"true\");\n } else {\n // Create new element\n element = document.createElement(tagName);\n Object.keys(props).forEach((key) => {\n if (key !== \"key\" && key !== \"ref\" && key !== \"children\") {\n const attrName = key === \"className\" ? \"class\" : key;\n element!.setAttribute(attrName, props[key]);\n }\n });\n element.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(element);\n }\n\n return element as HTMLElement;\n}\n\nexport default Head;\n","import React, { useCallback, useEffect, useRef } from \"react\";\nimport useRouter from \"../hooks/useRouter\";\n\n/**\n * Prefetch strategy for Link component\n */\nexport type PrefetchStrategy = \"hover\" | \"visible\" | \"mount\" | false;\n\nexport interface LinkProps\n extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n href: string;\n /**\n * Prefetch strategy:\n * - 'hover': Prefetch on mouse hover (default when prefetch=true)\n * - 'visible': Prefetch when link enters viewport (Intersection Observer)\n * - 'mount': Prefetch immediately on component mount\n * - false: Disable prefetching\n */\n prefetch?: boolean | PrefetchStrategy;\n /** Replace current history entry instead of pushing */\n replace?: boolean;\n /** Scroll to top after navigation (default: true) */\n scroll?: boolean;\n /** State to pass through navigation */\n state?: any;\n /**\n * Shallow navigation - update URL without re-fetching data\n * Useful for updating query params without full navigation\n */\n shallow?: boolean;\n /**\n * Active class name when this link matches current URL\n * If provided, adds this class when link is active\n */\n activeClassName?: string;\n /**\n * Require exact match for active class (default: true)\n * If false, matches if current URL starts with href\n */\n exact?: boolean;\n}\n\n/**\n * Link - Professional navigation link component\n *\n * Features:\n * - Client-side navigation with ArcanaJS router\n * - Smart prefetching with multiple strategies (hover, visible, mount)\n * - Intersection Observer for viewport-based prefetching\n * - External link detection and handling\n * - Async/await navigation support\n * - Active link styling support\n * - State passing through navigation\n * - Shallow navigation for query updates\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Link href=\"/about\">About</Link>\n *\n * // Prefetch on hover (default when prefetch=true)\n * <Link href=\"/products\" prefetch>Products</Link>\n *\n * // Prefetch when visible in viewport\n * <Link href=\"/blog\" prefetch=\"visible\">Blog</Link>\n *\n * // With replace instead of push\n * <Link href=\"/login\" replace>Login</Link>\n *\n * // Pass state through navigation\n * <Link href=\"/checkout\" state={{ from: 'cart' }}>Checkout</Link>\n *\n * // Active link styling\n * <Link href=\"/dashboard\" activeClassName=\"is-active\">Dashboard</Link>\n *\n * // Shallow navigation (for query params)\n * <Link href=\"/products?sort=price\" shallow>Sort by Price</Link>\n * ```\n */\nconst Link: React.FC<LinkProps> = ({\n href,\n children,\n prefetch = false,\n replace = false,\n scroll = true,\n state,\n shallow = false,\n activeClassName,\n exact = true,\n className = \"\",\n onClick,\n onMouseEnter,\n ...props\n}) => {\n const router = useRouter();\n const {\n push,\n replace: routerReplace,\n prefetch: prefetchRoute,\n currentUrl,\n isNavigating,\n } = router;\n const linkRef = useRef<HTMLAnchorElement>(null);\n const prefetchedRef = useRef(false);\n\n const isExternal = /^https?:\\/\\//.test(href);\n\n // Determine if link is active\n const isActive =\n !isExternal &&\n (exact\n ? currentUrl === href || currentUrl === href.split(\"?\")[0]\n : currentUrl.startsWith(href.split(\"?\")[0]));\n\n // Combine classNames\n const combinedClassName = [className, isActive && activeClassName]\n .filter(Boolean)\n .join(\" \");\n\n // Determine prefetch strategy\n const prefetchStrategy: PrefetchStrategy =\n prefetch === true ? \"hover\" : prefetch === false ? false : prefetch;\n\n // Prefetch handler\n const doPrefetch = useCallback(() => {\n if (prefetchedRef.current || isExternal || !prefetchRoute) return;\n prefetchedRef.current = true;\n prefetchRoute(href).catch(() => {\n prefetchedRef.current = false;\n });\n }, [href, isExternal, prefetchRoute]);\n\n // Intersection Observer for 'visible' strategy\n useEffect(() => {\n if (prefetchStrategy !== \"visible\" || typeof window === \"undefined\") return;\n\n const element = linkRef.current;\n if (!element) return;\n\n if (!(\"IntersectionObserver\" in window)) {\n const timeoutId = setTimeout(doPrefetch, 1000);\n return () => clearTimeout(timeoutId);\n }\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n doPrefetch();\n observer.disconnect();\n }\n });\n },\n {\n root: null,\n rootMargin: \"100px\",\n threshold: 0,\n }\n );\n\n observer.observe(element);\n\n return () => {\n observer.disconnect();\n };\n }, [prefetchStrategy, doPrefetch]);\n\n // Mount prefetch for 'mount' strategy\n useEffect(() => {\n if (prefetchStrategy !== \"mount\" || typeof window === \"undefined\") return;\n\n const timeoutId = setTimeout(doPrefetch, 100);\n return () => clearTimeout(timeoutId);\n }, [prefetchStrategy, doPrefetch]);\n\n const handleClick = async (e: React.MouseEvent<HTMLAnchorElement>) => {\n onClick?.(e);\n\n // Don't handle if default prevented or modifier keys pressed\n if (\n e.defaultPrevented ||\n e.metaKey ||\n e.ctrlKey ||\n e.shiftKey ||\n e.altKey\n ) {\n return;\n }\n\n e.preventDefault();\n\n if (isExternal) {\n window.open(href, \"_blank\", \"noopener,noreferrer\");\n } else {\n const options = { scroll, state, shallow };\n\n if (replace) {\n routerReplace(href, options);\n } else {\n push(href, options);\n }\n }\n };\n\n const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseEnter?.(e);\n\n if (prefetchStrategy === \"hover\" && !isExternal) {\n doPrefetch();\n }\n };\n\n return (\n <a\n ref={linkRef}\n href={href}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n className={combinedClassName || undefined}\n aria-current={isActive ? \"page\" : undefined}\n {...props}\n >\n {children}\n </a>\n );\n};\n\nexport default Link;\n","import React from \"react\";\nimport Head from \"./Head\";\n\n/**\n * PageProps - Props for the Page component\n */\nexport interface PageProps {\n /** Page content */\n children: React.ReactNode;\n /** Page title (shorthand for <Head><title>...</title></Head>) */\n title?: string;\n /** Page description (shorthand for meta description) */\n description?: string;\n /** Open Graph image URL */\n ogImage?: string;\n /** Canonical URL */\n canonical?: string;\n /** Additional CSS class for the page wrapper */\n className?: string;\n /** Page ID for styling/testing */\n id?: string;\n}\n\n/**\n * Page - Developer-facing page wrapper component for ArcanaJS\n *\n * Use this component as the root of your page views. It provides a clean\n * structure for organizing page meta tags and content.\n *\n * ## Page Structure\n *\n * ArcanaJS pages follow a simple pattern:\n * - `<Page>` - Root wrapper (this component)\n * - `<Head>` - Meta tags, title, links\n * - `<Body>` - Page content\n *\n * @example\n * ```tsx\n * // Basic usage\n * import { Page, Head, Body } from 'arcanajs/client';\n *\n * export default function HomePage() {\n * return (\n * <Page>\n * <Head>\n * <title>My Page</title>\n * <meta name=\"description\" content=\"Page description\" />\n * </Head>\n * <Body>\n * <h1>Welcome!</h1>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With shorthand props\n * import { Page, Body } from 'arcanajs/client';\n *\n * export default function AboutPage() {\n * return (\n * <Page\n * title=\"About Us\"\n * description=\"Learn more about our company\"\n * ogImage=\"/images/about-og.jpg\"\n * >\n * <Body>\n * <h1>About Us</h1>\n * <p>Our story...</p>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With usePage hook for server data\n * import { Page, Head, Body, usePage } from 'arcanajs/client';\n *\n * interface PageData {\n * user: { name: string };\n * }\n *\n * export default function ProfilePage() {\n * const { user } = usePage<PageData>();\n *\n * return (\n * <Page title={`${user.name}'s Profile`}>\n * <Body>\n * <h1>{user.name}</h1>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n */\nconst Page: React.FC<PageProps> = ({\n children,\n title,\n description,\n ogImage,\n canonical,\n className,\n id,\n}) => {\n // Check if Head is provided in children, if not and we have meta props, create one\n const hasHeadProps = !!(title || description || ogImage || canonical);\n\n return (\n <div className={className} id={id} data-arcanajs-page>\n {hasHeadProps && (\n <Head>\n {title && <title>{title}</title>}\n {description && <meta name=\"description\" content={description} />}\n {ogImage && <meta property=\"og:image\" content={ogImage} />}\n {canonical && <link rel=\"canonical\" href={canonical} />}\n </Head>\n )}\n {children}\n </div>\n );\n};\n\nexport default Page;\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\nexport interface HeadManager {\n tags: React.ReactNode[];\n push: (tags: React.ReactNode) => void;\n}\n\nexport const HeadContext = createSingletonContext<HeadManager | null>(\n \"HeadContext\",\n null\n);\n","import { createSingletonContext } from \"../utils/createSingletonContext\";\n\n// PageContext holds the page data (may be null before hydration).\nexport const PageContext = createSingletonContext<any | null>(\n \"PageContext\",\n null\n);\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Request context data structure\n * Contains SSR-specific information from the incoming request\n */\nexport interface RequestContextType {\n /** Request headers */\n headers: Record<string, string | undefined>;\n /** Request cookies */\n cookies: Record<string, string | undefined>;\n /** Request URL */\n url: string;\n /** Request path */\n path: string;\n /** Query parameters */\n query: Record<string, string | string[] | undefined>;\n /** Request method */\n method: string;\n /** Client IP address */\n ip?: string;\n /** User agent */\n userAgent?: string;\n /** Whether this is an SSR request */\n isSSR: boolean;\n}\n\n/**\n * Default request context (client-side)\n */\nconst defaultRequestContext: RequestContextType = {\n headers: {},\n cookies: {},\n url: typeof window !== \"undefined\" ? window.location.href : \"\",\n path: typeof window !== \"undefined\" ? window.location.pathname : \"\",\n query: {},\n method: \"GET\",\n isSSR: false,\n};\n\n/**\n * Request context for SSR\n */\nexport const RequestContext = createSingletonContext<RequestContextType | null>(\n \"RequestContext\",\n null\n);\n\n/**\n * Request context provider for SSR\n */\nexport const RequestContextProvider: React.FC<{\n value: RequestContextType;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return (\n <RequestContext.Provider value={value}>{children}</RequestContext.Provider>\n );\n};\n\n/**\n * Create request context from Express request\n */\nexport function createRequestContext(\n req: any // Express Request\n): RequestContextType {\n const headers: Record<string, string | undefined> = {};\n\n // Copy headers (lowercase keys)\n if (req.headers) {\n for (const [key, value] of Object.entries(req.headers)) {\n headers[key.toLowerCase()] = Array.isArray(value)\n ? value.join(\", \")\n : (value as string);\n }\n }\n\n // Parse cookies\n const cookies: Record<string, string | undefined> = {};\n if (req.cookies) {\n Object.assign(cookies, req.cookies);\n } else if (headers.cookie) {\n // Parse cookie header manually\n headers.cookie.split(\";\").forEach((cookie) => {\n const [key, ...valueParts] = cookie.trim().split(\"=\");\n if (key) {\n cookies[key] = valueParts.join(\"=\");\n }\n });\n }\n\n // Parse query\n const query: Record<string, string | string[] | undefined> = {};\n if (req.query) {\n Object.assign(query, req.query);\n }\n\n return {\n headers,\n cookies,\n url: req.url || req.originalUrl || \"\",\n path: req.path || \"\",\n query,\n method: req.method || \"GET\",\n ip: req.ip || req.headers?.[\"x-forwarded-for\"] || req.socket?.remoteAddress,\n userAgent: headers[\"user-agent\"],\n isSSR: true,\n };\n}\n\n/**\n * Get request context on client (returns default values)\n */\nexport function getClientRequestContext(): RequestContextType {\n if (typeof window === \"undefined\") {\n return defaultRequestContext;\n }\n\n // Parse cookies from document.cookie\n const cookies: Record<string, string | undefined> = {};\n document.cookie.split(\";\").forEach((cookie) => {\n const [key, ...valueParts] = cookie.trim().split(\"=\");\n if (key) {\n try {\n cookies[key] = decodeURIComponent(valueParts.join(\"=\"));\n } catch {\n cookies[key] = valueParts.join(\"=\");\n }\n }\n });\n\n // Parse query from URL\n const query: Record<string, string | string[] | undefined> = {};\n const searchParams = new URLSearchParams(window.location.search);\n searchParams.forEach((value, key) => {\n const existing = query[key];\n if (existing === undefined) {\n query[key] = value;\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n query[key] = [existing, value];\n }\n });\n\n return {\n headers: {\n \"user-agent\": navigator.userAgent,\n },\n cookies,\n url: window.location.href,\n path: window.location.pathname,\n query,\n method: \"GET\",\n userAgent: navigator.userAgent,\n isSSR: false,\n };\n}\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Navigation options for programmatic navigation\n */\nexport interface NavigateOptions {\n /** Replace current history entry instead of pushing */\n replace?: boolean;\n /** State to pass to the destination */\n state?: any;\n /** Scroll to top after navigation (default: true) */\n scroll?: boolean;\n /** Shallow navigation - update URL without re-fetching data */\n shallow?: boolean;\n}\n\n/**\n * Router context type with full navigation capabilities\n */\nexport interface RouterContextType {\n // ============================================================================\n // Navigation Methods\n // ============================================================================\n\n /** Navigate to a URL (fire-and-forget) */\n navigateTo: (url: string, options?: NavigateOptions) => void;\n\n /** Navigate to a URL (returns promise) */\n navigateToAsync?: (url: string, options?: NavigateOptions) => Promise<void>;\n\n /** Navigate using push (alias for navigateTo) */\n push: (url: string, options?: NavigateOptions) => void;\n\n /** Replace current history entry with new URL */\n replace: (url: string, options?: NavigateOptions) => void;\n\n /** Go back in history */\n back: () => void;\n\n /** Go forward in history */\n forward: () => void;\n\n /** Refresh current page data */\n refresh: () => Promise<void>;\n\n /** Prefetch a route for faster navigation */\n prefetchRoute?: (url: string) => Promise<void>;\n\n // ============================================================================\n // Current Route State\n // ============================================================================\n\n /** Current page name */\n currentPage: string;\n\n /** Current URL path */\n currentUrl: string;\n\n /** Alias for currentUrl */\n pathname: string;\n\n /** Route parameters (dynamic segments) */\n params: Record<string, string>;\n\n /** Parsed query string parameters */\n query: Record<string, string | string[]>;\n\n /** Navigation state passed via options */\n state?: any;\n\n // ============================================================================\n // Authentication & Security\n // ============================================================================\n\n /** CSRF token for form submissions */\n csrfToken?: string;\n\n // ============================================================================\n // Navigation Events & State\n // ============================================================================\n\n /** Whether navigation is in progress */\n isNavigating: boolean;\n\n /** Callback when navigation completes */\n onNavigate?: (url: string) => void;\n\n /** Previous URL before navigation */\n previousUrl?: string;\n}\n\nexport const RouterContext = createSingletonContext<RouterContextType | null>(\n \"RouterContext\",\n null\n);\n\nexport const RouterProvider: React.FC<{\n value: RouterContextType;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return (\n <RouterContext.Provider value={value}>{children}</RouterContext.Provider>\n );\n};\n\n/**\n * Parse query string into object\n */\nexport function parseQueryString(\n search: string\n): Record<string, string | string[]> {\n const query: Record<string, string | string[]> = {};\n\n if (typeof window === \"undefined\") return query;\n\n const params = new URLSearchParams(search);\n params.forEach((value, key) => {\n const existing = query[key];\n if (existing === undefined) {\n query[key] = value;\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n query[key] = [existing, value];\n }\n });\n\n return query;\n}\n\n/**\n * Serialize query object to string\n */\nexport function serializeQueryString(\n query: Record<string, string | string[] | undefined>\n): string {\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((v) => params.append(key, v));\n } else {\n params.set(key, value);\n }\n }\n\n const str = params.toString();\n return str ? `?${str}` : \"\";\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n NavigateOptions,\n parseQueryString,\n RouterProvider,\n} from \"../context/RouterContext\";\nimport { isRedirectError, setClientNavigate } from \"../utils/redirect\";\nimport PageProvider from \"./PageProvider\";\n\n/**\n * Scroll restoration behavior\n */\nexport type ScrollRestoration = \"auto\" | \"manual\" | \"none\";\n\n/**\n * Navigation guard callback\n * Return false to prevent navigation\n */\nexport type BeforeNavigateCallback = (\n to: string,\n from: string\n) => boolean | Promise<boolean>;\n\n/**\n * After navigation callback\n */\nexport type AfterNavigateCallback = (to: string, from: string) => void;\n\nexport interface ArcanaJSAppProps<\n TData = any,\n TParams extends Record<string, string> = Record<string, string>\n> {\n initialPage: string;\n initialData: TData;\n initialParams?: TParams;\n initialUrl?: string;\n csrfToken?: string;\n views: Record<\n string,\n React.ComponentType<{\n data: TData;\n navigateTo: (url: string) => Promise<void>;\n params: TParams;\n }>\n >;\n layout?: React.FC<{ children: React.ReactNode }>;\n onNavigate?: (url: string) => void;\n /** Maximum number of entries to keep in the navigation cache */\n cacheLimit?: number;\n\n // ============================================================================\n // New Pro Features\n // ============================================================================\n\n /**\n * Scroll restoration behavior\n * - 'auto': Restore scroll position on back/forward, scroll to top on new navigation\n * - 'manual': User controls scroll behavior\n * - 'none': No automatic scroll handling\n */\n scrollRestoration?: ScrollRestoration;\n\n /**\n * Navigation guard - called before navigation\n * Return false to prevent navigation\n */\n beforeNavigate?: BeforeNavigateCallback;\n\n /**\n * Callback after navigation completes\n */\n afterNavigate?: AfterNavigateCallback;\n}\n\nexport const ArcanaJSApp = <\n TData = any,\n TParams extends Record<string, string> = Record<string, string>\n>(\n props: ArcanaJSAppProps<TData, TParams>\n) => {\n const {\n initialPage,\n initialData,\n initialParams = {} as TParams,\n initialUrl,\n csrfToken,\n views,\n layout: Layout,\n onNavigate,\n cacheLimit = 50,\n scrollRestoration = \"auto\",\n beforeNavigate,\n afterNavigate,\n } = props;\n\n const [page, setPage] = useState<string>(initialPage);\n const [data, setData] = useState<TData>(initialData);\n const [params, setParams] = useState<TParams>(initialParams);\n const [url, setUrl] = useState<string>(\n initialUrl ||\n (typeof window !== \"undefined\" ? window.location.pathname : \"/\")\n );\n const [isNavigating, setIsNavigating] = useState(false);\n const [navigationState, setNavigationState] = useState<any>(undefined);\n const [previousUrl, setPreviousUrl] = useState<string | undefined>(undefined);\n\n // Navigation cache to store previously visited pages (LRU via Map ordering)\n const navigationCache = useRef(\n new Map<string, { page: string; data: TData; params: TParams }>()\n );\n\n // Scroll position storage for scroll restoration\n const scrollPositions = useRef(new Map<string, { x: number; y: number }>());\n\n // Track prefetch in-flight to avoid duplicate requests\n const prefetchInFlight = useRef(new Set<string>());\n\n // Abort controller for in-flight navigation fetch\n const currentAbort = useRef<AbortController | null>(null);\n\n // Save scroll position before navigation\n const saveScrollPosition = useCallback(() => {\n if (typeof window !== \"undefined\" && scrollRestoration !== \"none\") {\n scrollPositions.current.set(url, {\n x: window.scrollX,\n y: window.scrollY,\n });\n }\n }, [url, scrollRestoration]);\n\n // Restore scroll position or scroll to top\n const handleScroll = useCallback(\n (targetUrl: string, isRestore: boolean, options?: NavigateOptions) => {\n if (typeof window === \"undefined\" || scrollRestoration === \"none\") return;\n if (options?.scroll === false) return;\n\n setTimeout(() => {\n if (isRestore && scrollRestoration === \"auto\") {\n const saved = scrollPositions.current.get(targetUrl);\n if (saved) {\n window.scrollTo({\n left: saved.x,\n top: saved.y,\n behavior: \"instant\",\n });\n return;\n }\n }\n\n if (scrollRestoration === \"auto\") {\n try {\n window.scrollTo({ top: 0, behavior: \"smooth\" });\n } catch {\n window.scrollTo(0, 0);\n }\n }\n }, 0);\n },\n [scrollRestoration]\n );\n\n // Core navigation function\n const navigateTo = useCallback(\n async (newUrl: string, options: NavigateOptions = {}): Promise<void> => {\n const {\n replace = false,\n state,\n shallow = false,\n scroll = true,\n } = options;\n\n // Run before navigation guard\n if (beforeNavigate) {\n try {\n const shouldProceed = await beforeNavigate(newUrl, url);\n if (!shouldProceed) {\n return;\n }\n } catch (error) {\n console.error(\"beforeNavigate error:\", error);\n return;\n }\n }\n\n // Save current scroll position\n saveScrollPosition();\n\n // Store previous URL\n setPreviousUrl(url);\n\n // Shallow navigation - just update URL without fetching\n if (shallow) {\n setUrl(newUrl);\n setNavigationState(state);\n\n if (replace) {\n window.history.replaceState(\n { page, data, params, state },\n \"\",\n newUrl\n );\n } else {\n window.history.pushState({ page, data, params, state }, \"\", newUrl);\n }\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n return;\n }\n\n // Check cache first for instant navigation\n const map = navigationCache.current;\n if (map.has(newUrl)) {\n const cached = map.get(newUrl)!;\n setPage(cached.page);\n setData(cached.data);\n setParams(cached.params || ({} as TParams));\n setUrl(newUrl);\n setNavigationState(state);\n\n const historyState = { ...cached, state };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n\n handleScroll(newUrl, false, { scroll });\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n return;\n }\n\n setIsNavigating(true);\n\n // Abort previous request\n currentAbort.current?.abort();\n const controller = new AbortController();\n currentAbort.current = controller;\n\n try {\n const response = await fetch(newUrl, {\n headers: { \"X-ArcanaJS-Request\": \"true\" },\n cache: \"no-store\",\n signal: controller.signal,\n });\n\n if (!response.ok) {\n if (response.status === 404) {\n setPage(\"NotFoundPage\");\n setUrl(newUrl);\n const historyState = { page: \"NotFoundPage\", data: {} };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n return;\n }\n throw new Error(\n `Navigation failed: ${response.status} ${response.statusText}`\n );\n }\n\n const contentType = response.headers.get(\"content-type\") || \"\";\n if (!contentType.includes(\"application/json\")) {\n window.location.href = newUrl;\n return;\n }\n\n const json = await response.json();\n\n // Handle redirect response from server\n if (json.redirect) {\n await navigateTo(json.url, { replace: true });\n return;\n }\n\n const payload = {\n page: json.page as string,\n data: json.data as TData,\n params: (json.params || {}) as TParams,\n };\n setCache(newUrl, payload);\n\n const historyState = { ...payload, state };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n\n setPage(payload.page);\n setData(payload.data);\n setParams(payload.params || ({} as TParams));\n setUrl(newUrl);\n setNavigationState(state);\n\n handleScroll(newUrl, false, { scroll });\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n } catch (err: any) {\n if (err?.name === \"AbortError\") return;\n if (isRedirectError(err)) return;\n console.error(\"Navigation failed\", err);\n throw err;\n } finally {\n if (currentAbort.current === controller) currentAbort.current = null;\n setIsNavigating(false);\n }\n },\n [\n url,\n page,\n data,\n params,\n onNavigate,\n beforeNavigate,\n afterNavigate,\n saveScrollPosition,\n handleScroll,\n ]\n );\n\n // Set client navigate for universal redirect\n useEffect(() => {\n setClientNavigate((targetUrl, options) => {\n void navigateTo(targetUrl, { replace: options?.replace });\n });\n\n return () => {\n setClientNavigate(null);\n };\n }, [navigateTo]);\n\n // Initialize history state and popstate handler\n useEffect(() => {\n if (typeof window !== \"undefined\" && !window.history.state) {\n window.history.replaceState(\n { page: initialPage, data: initialData, params: initialParams },\n \"\",\n window.location.href\n );\n }\n\n const handlePopState = (event: PopStateEvent) => {\n if (event.state) {\n saveScrollPosition();\n setPage(event.state.page);\n setData(event.state.data);\n setParams(event.state.params || ({} as TParams));\n setNavigationState(event.state.state);\n const newUrl = window.location.pathname;\n setPreviousUrl(url);\n setUrl(newUrl);\n\n handleScroll(newUrl, true);\n\n if (afterNavigate) afterNavigate(newUrl, url);\n } else {\n const path = window.location.pathname;\n void navigateTo(path).catch(() => {\n window.location.reload();\n });\n }\n };\n\n window.addEventListener(\"popstate\", handlePopState);\n return () => {\n window.removeEventListener(\"popstate\", handlePopState);\n currentAbort.current?.abort();\n };\n }, []);\n\n const setCache = useCallback(\n (key: string, value: { page: string; data: TData; params: TParams }) => {\n const map = navigationCache.current;\n if (map.has(key)) map.delete(key);\n map.set(key, value);\n if (map.size > cacheLimit) {\n const firstKey = map.keys().next().value;\n if (firstKey !== undefined) map.delete(firstKey);\n }\n },\n [cacheLimit]\n );\n\n /**\n * Prefetch a route to warm the navigation cache\n */\n const prefetchRoute = useCallback(\n async (prefetchUrl: string): Promise<void> => {\n if (navigationCache.current.has(prefetchUrl)) return;\n if (prefetchInFlight.current.has(prefetchUrl)) return;\n if (/^https?:\\/\\//.test(prefetchUrl)) return;\n\n prefetchInFlight.current.add(prefetchUrl);\n\n try {\n const response = await fetch(prefetchUrl, {\n headers: { \"X-ArcanaJS-Request\": \"true\" },\n });\n\n if (!response.ok) return;\n\n const contentType = response.headers.get(\"content-type\") || \"\";\n if (!contentType.includes(\"application/json\")) return;\n\n const json = await response.json();\n\n const payload = {\n page: json.page as string,\n data: json.data as TData,\n params: (json.params || {}) as TParams,\n };\n\n setCache(prefetchUrl, payload);\n } catch {\n // Silently ignore prefetch errors\n } finally {\n prefetchInFlight.current.delete(prefetchUrl);\n }\n },\n [setCache]\n );\n\n /**\n * Refresh current page data\n */\n const refresh = useCallback(async (): Promise<void> => {\n // Clear cache for current URL\n navigationCache.current.delete(url);\n // Re-navigate to current URL with replace\n await navigateTo(url, { replace: true, scroll: false });\n }, [url, navigateTo]);\n\n /**\n * Replace current history entry\n */\n const replace = useCallback(\n (newUrl: string, options: Omit<NavigateOptions, \"replace\"> = {}) => {\n void navigateTo(newUrl, { ...options, replace: true });\n },\n [navigateTo]\n );\n\n /**\n * Go back in history\n */\n const back = useCallback(() => {\n if (typeof window !== \"undefined\") {\n window.history.back();\n }\n }, []);\n\n /**\n * Go forward in history\n */\n const forward = useCallback(() => {\n if (typeof window !== \"undefined\") {\n window.history.forward();\n }\n }, []);\n\n // Parse current query string\n const query = useMemo(() => {\n if (typeof window === \"undefined\") return {};\n return parseQueryString(window.location.search);\n }, [url]);\n\n // Memoize renderPage to prevent unnecessary re-renders\n const content = useMemo(() => {\n const Component = (views[page] ||\n views[\"NotFoundPage\"] ||\n (() => <div>404 Not Found</div>)) as React.ComponentType<{\n data: TData;\n navigateTo: (url: string) => Promise<void>;\n params: TParams;\n }>;\n\n return (\n <PageProvider data={data}>\n <Component data={data} navigateTo={navigateTo} params={params} />\n </PageProvider>\n );\n }, [page, data, params, views, navigateTo]);\n\n // Memoize router context value\n const routerValue = useMemo(\n () => ({\n // Navigation methods\n navigateTo: (targetUrl: string, options?: NavigateOptions) => {\n void navigateTo(targetUrl, options);\n },\n navigateToAsync: navigateTo,\n push: (targetUrl: string, options?: NavigateOptions) => {\n void navigateTo(targetUrl, options);\n },\n replace,\n back,\n forward,\n refresh,\n prefetchRoute,\n\n // Current route state\n currentPage: page,\n currentUrl: url,\n pathname: url,\n params,\n query,\n state: navigationState,\n\n // Authentication\n csrfToken,\n\n // Navigation state\n isNavigating,\n onNavigate,\n previousUrl,\n }),\n [\n navigateTo,\n replace,\n back,\n forward,\n refresh,\n prefetchRoute,\n page,\n url,\n params,\n query,\n navigationState,\n csrfToken,\n isNavigating,\n onNavigate,\n previousUrl,\n ]\n );\n\n return (\n <RouterProvider value={routerValue}>\n {Layout ? <Layout>{content}</Layout> : <>{content}</>}\n </RouterProvider>\n );\n};\n","import React from \"react\";\nimport { PageContext } from \"../context/PageContext\";\n\n/**\n * PageProvider - Internal framework component for ArcanaJS\n *\n * This is an INTERNAL component used by the ArcanaJS framework to provide\n * page data context. Developers should NOT use this directly.\n *\n * Use the `Page` component instead for creating pages.\n *\n * @internal\n */\nexport const PageProvider = <T,>({\n data,\n children,\n}: {\n data?: T;\n children: React.ReactNode;\n}) => {\n return (\n <PageContext.Provider value={data as unknown}>\n {children}\n </PageContext.Provider>\n );\n};\n\nexport default PageProvider;\n","import { useCallback, useContext, useState } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Error structure for ArcanaJS\n */\nexport interface ArcanaError {\n /** HTTP status code */\n statusCode: number;\n /** Error message */\n message: string;\n /** Unique error identifier */\n name?: string;\n /** Stack trace (dev only) */\n stack?: string;\n /** Original error */\n cause?: Error;\n /** Whether this is a fatal error */\n fatal?: boolean;\n /** Data associated with the error */\n data?: any;\n}\n\n/**\n * Error context for global error state\n */\ninterface ErrorContextType {\n error: ArcanaError | null;\n setError: (error: ArcanaError | null) => void;\n clearError: () => void;\n}\n\n// Global error state\nlet globalError: ArcanaError | null = null;\nconst errorListeners: Array<(error: ArcanaError | null) => void> = [];\n\nexport const ErrorContext = createSingletonContext<ErrorContextType | null>(\n \"ErrorContext\",\n null\n);\n\n/**\n * Create error from various inputs\n */\nexport function createError(options: {\n statusCode?: number;\n message: string;\n name?: string;\n fatal?: boolean;\n cause?: Error;\n data?: any;\n}): ArcanaError {\n return {\n statusCode: options.statusCode || 500,\n message: options.message,\n name: options.name || \"ArcanaError\",\n fatal: options.fatal ?? false,\n cause: options.cause,\n data: options.data,\n stack:\n process.env.NODE_ENV === \"development\" ? options.cause?.stack : undefined,\n };\n}\n\n/**\n * Set global error (for server-side or non-React contexts)\n */\nexport function setGlobalError(error: ArcanaError | null): void {\n globalError = error;\n errorListeners.forEach((listener) => listener(error));\n}\n\n/**\n * Get global error\n */\nexport function getGlobalError(): ArcanaError | null {\n return globalError;\n}\n\n/**\n * Clear global error\n */\nexport function clearGlobalError(): void {\n globalError = null;\n errorListeners.forEach((listener) => listener(null));\n}\n\n/**\n * Show error page (throws error for error boundary)\n */\nexport function showError(options: {\n statusCode?: number;\n message: string;\n fatal?: boolean;\n}): never {\n const error = createError(options);\n setGlobalError(error);\n\n // Throw to trigger error boundary\n throw new Error(error.message);\n}\n\n/**\n * useError - Error handling hook\n *\n * Provides access to the global error state and methods\n * to create/clear errors. Works with ArcanaJS error pages.\n *\n * @example\n * ```tsx\n * // Check for errors\n * const { error, clearError } = useError();\n *\n * if (error) {\n * return (\n * <div>\n * <h1>Error {error.statusCode}</h1>\n * <p>{error.message}</p>\n * <button onClick={clearError}>Try Again</button>\n * </div>\n * );\n * }\n *\n * // Create an error\n * const { setError } = useError();\n *\n * const handleNotFound = () => {\n * setError({\n * statusCode: 404,\n * message: 'Resource not found',\n * });\n * };\n *\n * // Throw a fatal error\n * import { showError } from 'arcanajs/client';\n *\n * if (!user) {\n * showError({\n * statusCode: 401,\n * message: 'Authentication required',\n * fatal: true,\n * });\n * }\n * ```\n */\nfunction useError(): {\n error: ArcanaError | null;\n setError: (\n error: Partial<ArcanaError> & { message: string; statusCode?: number }\n ) => void;\n clearError: () => void;\n} {\n const context = useContext(ErrorContext);\n\n // Use context if available (within ErrorProvider)\n if (context) {\n return {\n error: context.error,\n setError: (err) => context.setError(createError(err)),\n clearError: context.clearError,\n };\n }\n\n // Fallback to global state\n const [error, setLocalError] = useState<ArcanaError | null>(globalError);\n\n // Subscribe to global error changes\n useState(() => {\n const listener = (err: ArcanaError | null) => setLocalError(err);\n errorListeners.push(listener);\n return () => {\n const index = errorListeners.indexOf(listener);\n if (index > -1) errorListeners.splice(index, 1);\n };\n });\n\n const setError = useCallback(\n (err: Partial<ArcanaError> & { message: string; statusCode?: number }) => {\n const arcanaError = createError(err);\n setGlobalError(arcanaError);\n setLocalError(arcanaError);\n },\n []\n );\n\n const clearError = useCallback(() => {\n clearGlobalError();\n setLocalError(null);\n }, []);\n\n return {\n error,\n setError,\n clearError,\n };\n}\n\nexport default useError;\n","import { useContext } from \"react\";\nimport { HeadContext } from \"../context/HeadContext\";\n\nexport const useHead = () => useContext(HeadContext);\n","import { useContext } from \"react\";\nimport { RouterContext } from \"../context/RouterContext\";\n\n/**\n * useRouter - Professional routing hook for ArcanaJS\n *\n * Provides complete navigation methods and current route state.\n * Works in both SSR and client-side contexts.\n *\n * @example\n * ```tsx\n * const router = useRouter();\n *\n * // Push navigation\n * router.push('/dashboard');\n *\n * // Replace current entry\n * router.replace('/settings');\n *\n * // Navigation with options\n * router.push('/page', { scroll: false, state: { from: 'home' } });\n *\n * // Go back/forward\n * router.back();\n * router.forward();\n *\n * // Refresh current page data\n * await router.refresh();\n *\n * // Prefetch a route\n * router.prefetch('/about');\n *\n * // Access route info\n * console.log(router.pathname); // '/users/123'\n * console.log(router.params); // { id: '123' }\n * console.log(router.query); // { sort: 'asc' }\n * console.log(router.state); // { from: 'home' }\n *\n * // Check navigation state\n * if (router.isNavigating) {\n * return <Spinner />;\n * }\n * ```\n */\nconst useRouter = () => {\n const context = useContext(RouterContext);\n if (!context) {\n throw new Error(\"useRouter must be used within an ArcanaJSApp\");\n }\n\n return {\n // ============================================================================\n // Navigation Methods\n // ============================================================================\n\n /** Navigate to a URL (fire-and-forget) */\n navigateTo: context.navigateTo,\n\n /** Navigate to a URL with async/await */\n navigateToAsync: context.navigateToAsync,\n\n /** Push a new entry to history (alias for navigateTo) */\n push: context.push,\n\n /** Replace current history entry with new URL */\n replace: context.replace,\n\n /** Go back in history */\n back: context.back,\n\n /** Go forward in history */\n forward: context.forward,\n\n /** Refresh current page data */\n refresh: context.refresh,\n\n /** Prefetch a route for faster navigation */\n prefetch: context.prefetchRoute,\n prefetchRoute: context.prefetchRoute,\n\n // ============================================================================\n // Current Route State\n // ============================================================================\n\n /** Current page/view name */\n currentPage: context.currentPage,\n\n /** Current URL path */\n currentUrl: context.currentUrl,\n\n /** Current pathname (alias for currentUrl) */\n pathname: context.pathname,\n\n /** Dynamic route parameters */\n params: context.params,\n\n /** Parsed query string parameters */\n query: context.query,\n\n /** Navigation state passed via options */\n state: context.state,\n\n /** Previous URL before navigation */\n previousUrl: context.previousUrl,\n\n // ============================================================================\n // Authentication\n // ============================================================================\n\n /** CSRF token for form submissions */\n csrfToken: context.csrfToken,\n\n // ============================================================================\n // Navigation State\n // ============================================================================\n\n /** Whether navigation is in progress */\n isNavigating: context.isNavigating,\n\n /** Callback when navigation completes */\n onNavigate: context.onNavigate,\n };\n};\n\n/**\n * Return type for useRouter hook\n */\nexport type UseRouterReturn = ReturnType<typeof useRouter>;\n\nexport default useRouter;\n","import { useContext } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Runtime configuration structure\n */\nexport interface RuntimeConfig {\n /** Public config - accessible on both server and client */\n public: Record<string, any>;\n /** Private config - only accessible on server */\n private?: Record<string, any>;\n /** App metadata */\n app?: {\n name?: string;\n version?: string;\n env?: string;\n baseUrl?: string;\n };\n}\n\n// Default runtime config\nconst defaultConfig: RuntimeConfig = {\n public: {},\n private: {},\n app: {\n name: \"ArcanaJS App\",\n version: \"1.0.0\",\n env: process.env.NODE_ENV || \"development\",\n baseUrl: \"\",\n },\n};\n\n// Global runtime config\nlet runtimeConfig: RuntimeConfig = { ...defaultConfig };\n\n// Context for passing config from server\nexport const RuntimeConfigContext = createSingletonContext<RuntimeConfig>(\n \"RuntimeConfigContext\",\n defaultConfig\n);\n\n/**\n * Set runtime configuration (call on server startup)\n */\nexport function setRuntimeConfig(config: Partial<RuntimeConfig>): void {\n runtimeConfig = {\n public: { ...defaultConfig.public, ...config.public },\n private: { ...defaultConfig.private, ...config.private },\n app: { ...defaultConfig.app, ...config.app },\n };\n}\n\n/**\n * Get runtime configuration (server-side)\n */\nexport function getRuntimeConfig(): RuntimeConfig {\n return runtimeConfig;\n}\n\n/**\n * Get public runtime config (safe for client)\n */\nexport function getPublicRuntimeConfig(): RuntimeConfig {\n return {\n public: runtimeConfig.public,\n app: runtimeConfig.app,\n };\n}\n\n/**\n * useRuntimeConfig - Access runtime configuration\n *\n * Returns the runtime configuration object.\n * On the client, only public config is available.\n * On the server, full config including private values is accessible.\n *\n * @example\n * ```tsx\n * // In your component\n * const config = useRuntimeConfig();\n *\n * // Access public config (available on both server and client)\n * const apiUrl = config.public.apiUrl;\n *\n * // Access private config (server only)\n * if (typeof window === 'undefined') {\n * const apiKey = config.private?.apiKey;\n * }\n *\n * // Access app metadata\n * const appName = config.app?.name;\n * ```\n *\n * @example\n * ```typescript\n * // Server setup (in ArcanaJS config)\n * import { setRuntimeConfig } from 'arcanajs/client';\n *\n * setRuntimeConfig({\n * public: {\n * apiUrl: 'https://api.example.com',\n * },\n * private: {\n * apiKey: process.env.API_KEY,\n * },\n * });\n * ```\n */\nfunction useRuntimeConfig(): RuntimeConfig {\n const contextConfig = useContext(RuntimeConfigContext);\n\n // On client, strip private config\n if (typeof window !== \"undefined\") {\n return {\n public: contextConfig.public || runtimeConfig.public,\n app: contextConfig.app || runtimeConfig.app,\n };\n }\n\n // On server, return full config\n return {\n public: contextConfig.public || runtimeConfig.public,\n private: contextConfig.private || runtimeConfig.private,\n app: contextConfig.app || runtimeConfig.app,\n };\n}\n\nexport default useRuntimeConfig;\n","import React, { ReactNode, useState as reactUseState, useContext } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Shared state store for SSR hydration\n */\ninterface SharedStateStore {\n [key: string]: any;\n}\n\n// Global state store for SSR data transfer\nconst sharedStateStore: SharedStateStore = {};\n\n// Context to pass initial state from server to client\nexport const SharedStateContext = createSingletonContext<SharedStateStore>(\n \"SharedStateContext\",\n {}\n);\n\n/**\n * Provider component for shared state (used in SSR)\n */\nexport const SharedStateProvider: React.FC<{\n initialState?: SharedStateStore;\n children: ReactNode;\n}> = ({ initialState = {}, children }) => {\n return (\n <SharedStateContext.Provider value={initialState}>\n {children}\n </SharedStateContext.Provider>\n );\n};\n\n/**\n * useState - SSR-hydrated shared state hook\n *\n * Creates reactive state that can be shared across components and\n * persists across SSR hydration. Unlike React's useState, this state\n * is keyed and can be accessed from anywhere in the component tree.\n *\n * On the server, state is collected and serialized to the client.\n * On the client, state is hydrated from the server's initial values.\n *\n * @example\n * ```tsx\n * // Create or access shared state\n * const counter = useState<number>('counter', () => 0);\n * counter.value++; // Increment\n *\n * // In another component\n * const counter = useState<number>('counter', () => 0);\n * console.log(counter.value); // Same value!\n *\n * // Complex objects\n * const user = useState<User>('user', () => fetchUser());\n * ```\n */\nfunction useState<T>(\n key: string,\n init?: () => T\n): { value: T; set: (value: T | ((prev: T) => T)) => void } {\n const ssrState = useContext(SharedStateContext);\n\n // Get initial value from SSR state or initialize\n const getInitialValue = (): T => {\n // Check SSR hydrated state first\n if (key in ssrState) {\n return ssrState[key] as T;\n }\n\n // Check global store (for client-side access across components)\n if (key in sharedStateStore) {\n return sharedStateStore[key] as T;\n }\n\n // Initialize with factory function\n const initialValue = init ? init() : (undefined as T);\n sharedStateStore[key] = initialValue;\n return initialValue;\n };\n\n const [value, setValue] = reactUseState<T>(getInitialValue);\n\n // Custom setter that also updates the shared store\n const set = (newValue: T | ((prev: T) => T)) => {\n setValue((prev) => {\n const nextValue =\n typeof newValue === \"function\"\n ? (newValue as (prev: T) => T)(prev)\n : newValue;\n\n // Update shared store\n sharedStateStore[key] = nextValue;\n\n return nextValue;\n });\n };\n\n return {\n value,\n set,\n };\n}\n\n/**\n * Get all shared state for SSR serialization\n */\nexport function getSharedState(): SharedStateStore {\n return { ...sharedStateStore };\n}\n\n/**\n * Set shared state from server-side\n */\nexport function setSharedState(key: string, value: any): void {\n sharedStateStore[key] = value;\n}\n\n/**\n * Clear all shared state (for testing or cleanup)\n */\nexport function clearSharedState(): void {\n Object.keys(sharedStateStore).forEach((key) => {\n delete sharedStateStore[key];\n });\n}\n\nexport default useState;\n","import React, { createContext } from \"react\";\n\n/**\n * Creates a React Context that persists across multiple module loads (Webpack bundles vs Node require).\n * This is essential for SSR applications where the server bundle and dynamically loaded views\n * might reference different instances of the \"same\" context module.\n *\n * @param key A unique string key to identify this context globally\n * @param defaultValue The default value for the context\n * @returns A React Context instance (singleton)\n */\nexport function createSingletonContext<T>(\n key: string,\n defaultValue: T\n): React.Context<T> {\n const globalAny = globalThis as any;\n const symbolKey = Symbol.for(`ARCANAJS_CONTEXT_${key}`);\n\n if (!globalAny[symbolKey]) {\n globalAny[symbolKey] = createContext<T>(defaultValue);\n }\n\n return globalAny[symbolKey];\n}\n","/**\n * Universal Redirect Utility\n *\n * Works seamlessly in both SSR (Server-Side Rendering) and SPA (Single Page Application) contexts.\n *\n * @example\n * // In a page component\n * if (!user.isAuthenticated) {\n * redirect('/login');\n * }\n *\n * // Permanent redirect\n * permanentRedirect('/new-location');\n *\n * // With custom status\n * redirect('/dashboard', 307);\n */\n\nimport type { Response } from \"express\";\n\n/**\n * Redirect error class - thrown during SSR to signal redirect\n */\nexport class RedirectError extends Error {\n public readonly url: string;\n public readonly statusCode: number;\n public readonly isRedirect = true;\n\n constructor(url: string, statusCode: number = 302) {\n super(`Redirect to ${url}`);\n this.name = \"RedirectError\";\n this.url = url;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * SSR context for redirect handling\n */\ninterface SSRContext {\n response?: Response;\n isSSR: boolean;\n}\n\n// Global SSR context (set during server-side rendering)\nlet ssrContext: SSRContext | null = null;\n\n/**\n * Set SSR context for redirect handling\n * Called by the server during SSR rendering\n */\nexport function setSSRContext(ctx: SSRContext | null): void {\n ssrContext = ctx;\n}\n\n/**\n * Get current SSR context\n */\nexport function getSSRContext(): SSRContext | null {\n return ssrContext;\n}\n\n// Client-side navigation function (set by RouterContext)\nlet clientNavigate:\n | ((url: string, options?: { replace?: boolean }) => void)\n | null = null;\n\n/**\n * Set client-side navigation function\n * Called by ArcanaJSApp on initialization\n */\nexport function setClientNavigate(\n fn: ((url: string, options?: { replace?: boolean }) => void) | null\n): void {\n clientNavigate = fn;\n}\n\n/**\n * Redirect to a new URL\n *\n * Works in both SSR and SPA contexts:\n * - **SSR**: Sets response redirect and throws RedirectError to stop rendering\n * - **SPA**: Uses client-side navigation with history replacement\n *\n * @param url - The URL to redirect to\n * @param statusCode - HTTP status code (default: 302)\n *\n * @example\n * // Basic redirect\n * redirect('/login');\n *\n * // With status code\n * redirect('/dashboard', 307);\n *\n * // In a component\n * function ProtectedPage({ data }) {\n * if (!data.isAuthenticated) {\n * redirect('/login');\n * }\n * return <Dashboard />;\n * }\n */\nexport function redirect(url: string, statusCode: number = 302): never {\n // Check for SSR context first\n if (ssrContext?.isSSR && ssrContext.response) {\n // Server-side: use HTTP redirect\n ssrContext.response.redirect(statusCode, url);\n throw new RedirectError(url, statusCode);\n }\n\n // Client-side: use navigation\n if (typeof window !== \"undefined\") {\n if (clientNavigate) {\n // Use ArcanaJS navigation with replace\n clientNavigate(url, { replace: true });\n } else {\n // Fallback to window.location\n window.location.replace(url);\n }\n }\n\n // Throw redirect error to stop execution\n throw new RedirectError(url, statusCode);\n}\n\n/**\n * Permanent redirect (301)\n *\n * @param url - The URL to redirect to\n *\n * @example\n * permanentRedirect('/new-page');\n */\nexport function permanentRedirect(url: string): never {\n return redirect(url, 301);\n}\n\n/**\n * Temporary redirect (307 - preserves HTTP method)\n *\n * @param url - The URL to redirect to\n *\n * @example\n * temporaryRedirect('/maintenance');\n */\nexport function temporaryRedirect(url: string): never {\n return redirect(url, 307);\n}\n\n/**\n * Check if an error is a redirect error\n */\nexport function isRedirectError(error: unknown): error is RedirectError {\n return (\n error instanceof RedirectError ||\n (error !== null &&\n typeof error === \"object\" &&\n \"isRedirect\" in error &&\n (error as any).isRedirect === true)\n );\n}\n\n/**\n * Navigate without throwing (for conditional navigation)\n * Returns false if navigation was not possible\n *\n * @param url - The URL to navigate to\n * @param options - Navigation options\n *\n * @example\n * if (!navigateTo('/dashboard', { replace: true })) {\n * console.log('Navigation not available');\n * }\n */\nexport function navigateTo(\n url: string,\n options: { replace?: boolean } = {}\n): boolean {\n // SSR context\n if (ssrContext?.isSSR && ssrContext.response) {\n ssrContext.response.redirect(options.replace ? 301 : 302, url);\n return true;\n }\n\n // Client-side\n if (typeof window !== \"undefined\") {\n if (clientNavigate) {\n clientNavigate(url, options);\n return true;\n } else {\n if (options.replace) {\n window.location.replace(url);\n } else {\n window.location.href = url;\n }\n return true;\n }\n }\n\n return false;\n}\n","import Body from \"../components/Body\";\nimport Head from \"../components/Head\";\nimport Link from \"../components/Link\";\nimport Page from \"../components/Page\";\ninterface ErrorPageProps {\n message?: string;\n statusCode?: number;\n stack?: string;\n}\n\nexport default function ErrorPage({\n message = \"Something went wrong\",\n statusCode = 500,\n stack,\n}: ErrorPageProps) {\n const isDevelopment = process.env.NODE_ENV === \"development\";\n\n return (\n <Page>\n <Head>\n <title>{statusCode} - Server Error</title>\n <meta name=\"description\" content=\"An error occurred on the server\" />\n </Head>\n <Body>\n <div className=\"relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans\">\n {/* Animated Background */}\n <div className=\"fixed inset-0 z-0 overflow-hidden pointer-events-none\">\n <div className=\"absolute inset-0 grid-pattern opacity-30\"></div>\n <div className=\"absolute top-1/4 right-1/4 w-96 h-96 bg-red-600 rounded-full opacity-20 blur-3xl animate-glow\"></div>\n <div\n className=\"absolute bottom-1/4 left-1/4 w-96 h-96 bg-orange-600 rounded-full opacity-10 blur-3xl animate-glow\"\n style={{ animationDelay: \"2s\" }}\n ></div>\n <div className=\"absolute inset-0 hero-gradient\"></div>\n </div>\n\n <div className=\"relative z-10 max-w-2xl w-full text-center animate-scale-in\">\n <div className=\"glass-card rounded-3xl p-12 border border-white/10 shadow-2xl\">\n <div className=\"mb-8\">\n <div className=\"text-6xl mb-6 animate-float\">\n <span className=\"text-red-500 drop-shadow-lg filter\">⚠️</span>\n </div>\n <h1 className=\"text-8xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-red-500 to-orange-500 mb-4\">\n {statusCode}\n </h1>\n <h2 className=\"text-3xl font-bold text-white mb-4\">\n Server Error\n </h2>\n <p className=\"text-gray-400 text-lg leading-relaxed\">\n {message}\n </p>\n </div>\n\n <div className=\"flex flex-col sm:flex-row gap-4 justify-center mb-8\">\n <Link\n href=\"/\"\n className=\"btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-500 hover:to-orange-500 border-none shadow-red-900/20\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6\"\n />\n </svg>\n Go Home\n </Link>\n\n <button\n onClick={() => window.location.reload()}\n className=\"btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15\"\n />\n </svg>\n Try Again\n </button>\n </div>\n\n {isDevelopment && stack && (\n <div className=\"mt-8 text-left animate-slide-up\">\n <details className=\"bg-black/40 border border-white/10 rounded-xl overflow-hidden group\">\n <summary className=\"cursor-pointer font-medium text-gray-300 p-4 hover:bg-white/5 transition-colors flex items-center justify-between select-none\">\n <span>Stack Trace (Development Only)</span>\n <svg\n className=\"w-5 h-5 text-gray-500 group-open:rotate-180 transition-transform\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </summary>\n <pre className=\"text-xs text-red-300/80 p-4 overflow-x-auto whitespace-pre-wrap font-mono border-t border-white/5 bg-black/20\">\n {stack}\n </pre>\n </details>\n </div>\n )}\n </div>\n\n <div className=\"mt-8 text-gray-500 text-sm\">\n If this problem persists, please{\" \"}\n <Link\n href=\"/contact\"\n className=\"text-red-400 hover:text-red-300 underline transition-colors\"\n >\n contact support\n </Link>\n .\n </div>\n </div>\n </div>\n </Body>\n </Page>\n );\n}\n","import Body from \"../components/Body\";\nimport Head from \"../components/Head\";\nimport Link from \"../components/Link\";\nimport Page from \"../components/Page\";\ninterface NotFoundPageProps {\n url?: string;\n}\n\nexport default function NotFoundPage({ url }: NotFoundPageProps) {\n return (\n <Page>\n <Head>\n <title>404 - Page Not Found</title>\n <meta\n name=\"description\"\n content=\"The page you're looking for doesn't exist\"\n />\n </Head>\n <Body>\n <div className=\"relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans\">\n {/* Animated Background */}\n <div className=\"fixed inset-0 z-0 overflow-hidden pointer-events-none\">\n <div className=\"absolute inset-0 grid-pattern opacity-30\"></div>\n <div className=\"absolute top-1/4 left-1/4 w-96 h-96 bg-orange-500 rounded-full opacity-20 blur-3xl animate-glow\"></div>\n <div\n className=\"absolute bottom-1/4 right-1/4 w-96 h-96 bg-purple-500 rounded-full opacity-10 blur-3xl animate-glow\"\n style={{ animationDelay: \"2s\" }}\n ></div>\n <div className=\"absolute inset-0 hero-gradient\"></div>\n </div>\n\n <div className=\"relative z-10 max-w-lg w-full text-center animate-scale-in\">\n <div className=\"glass-card rounded-3xl p-12 border border-white/10 shadow-2xl\">\n <div className=\"mb-8\">\n <h1 className=\"text-9xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-white to-gray-500 mb-4 animate-float\">\n 404\n </h1>\n <h2 className=\"text-3xl font-bold text-white mb-4\">\n Page Not Found\n </h2>\n <p className=\"text-gray-400 text-lg leading-relaxed\">\n {url ? (\n <>\n The page <span className=\"text-orange-400\">\"{url}\"</span>{\" \"}\n you're looking for doesn't exist.\n </>\n ) : (\n \"The page you're looking for doesn't exist.\"\n )}\n </p>\n </div>\n\n <div className=\"flex flex-col sm:flex-row gap-4 justify-center\">\n <Link\n href=\"/\"\n className=\"btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6\"\n />\n </svg>\n Go Home\n </Link>\n\n <button\n onClick={() => window.history.back()}\n className=\"btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M10 19l-7-7m0 0l7-7m-7 7h18\"\n />\n </svg>\n Go Back\n </button>\n </div>\n </div>\n <div className=\"mt-8 text-gray-500 text-sm\">\n If you believe this is an error, please{\" \"}\n <Link\n href=\"/contact\"\n className=\"text-orange-400 hover:text-orange-300 underline transition-colors\"\n >\n contact support\n </Link>\n .\n </div>\n </div>\n </div>\n </Body>\n </Page>\n );\n}\n","/**\n * Professional Module Loader Utility\n *\n * This utility provides a centralized way to load modules dynamically at runtime,\n * bypassing Webpack bundling when necessary. It also handles TypeScript registration\n * for on-the-fly compilation.\n */\nexport class ModuleLoader {\n private static tsNodeRegistered = false;\n\n /**\n * Dynamically require a module at runtime.\n *\n * This method bypasses Webpack's static analysis and bundling, allowing\n * access to user-land modules, configuration files, and native Node.js modules\n * that shouldn't be bundled with the framework.\n *\n * @param id - The module identifier or path to require\n * @returns The required module\n */\n static require(id: string): any {\n // 1. Try module.require (Node environment)\n try {\n // Use eval to avoid Webpack bundling\n const r = eval(\"module.require\");\n if (r) {\n return r(id);\n }\n } catch (e) {\n // Ignore\n }\n\n // 2. Try to use createRequire from module (ESM support)\n try {\n // Use eval to hide require from webpack\n const r = eval(\"req\" + \"uire\");\n const { createRequire } = r(\"module\");\n if (createRequire) {\n const nativeRequire = createRequire(process.cwd() + \"/\");\n return nativeRequire(id);\n }\n } catch (e) {\n // Ignore\n }\n\n // 3. Fallback to process.mainModule (Legacy)\n try {\n const _global = global as any;\n const nativeRequire = _global[\"process\"]?.[\"mainModule\"]?.[\"require\"];\n if (nativeRequire) {\n return nativeRequire(id);\n }\n } catch (e) {\n // Ignore errors during lookup\n }\n\n // 4. Last resort: new Function(\"return require\")\n try {\n const r = new Function(\"return req\" + \"uire\")();\n return r(id);\n } catch (e) {\n // Ignore\n }\n\n throw new Error(`Could not require module '${id}'`);\n }\n /**\n * Registers ts-node for runtime TypeScript compilation.\n *\n * This is useful when the framework needs to load and execute TypeScript files\n * directly from the user's project (e.g., configuration, migrations).\n *\n * @returns true if registration was successful, false otherwise\n */\n static registerTsNode(): boolean {\n if (this.tsNodeRegistered) {\n return true;\n }\n\n // Try to register tsconfig-paths for alias support\n try {\n this.require(\"tsconfig-paths/register\");\n } catch (e) {\n // ignore tsconfig-paths failure\n }\n\n try {\n const tsNode = this.require(\"ts-node\");\n // Check if ts-node is already registered by checking the service\n if (!tsNode.register) {\n return false;\n }\n\n tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n moduleResolution: \"node\",\n experimentalDecorators: true,\n emitDecoratorMetadata: true,\n esModuleInterop: true,\n },\n });\n\n this.tsNodeRegistered = true;\n return true;\n } catch (e) {\n return false;\n }\n }\n}\n","module.exports = require(\"arcanajs-views\");","module.exports = require(\"compression\");","module.exports = require(\"cookie-parser\");","module.exports = require(\"crypto\");","module.exports = require(\"express\");","module.exports = require(\"fs\");","module.exports = require(\"helmet\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:path\");","module.exports = require(\"path\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/server\");","module.exports = require(\"react/jsx-dev-runtime\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/lib/index.server.ts\");\n",""],"names":[],"ignoreList":[],"sourceRoot":""}
1
+ {"version":3,"file":"arcanajs.js","mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACj4CA;AAAA;;AAuGA;AAAA;;;AA5GA;;;;;;;;;;;;;;AAKA;AAWA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAKA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AA/FA;AAHA;AACA;AAGA;AACA;AACA;AACA;AA4FA;AApGA;AAsGA;;;;;;;;;;;;;;;;;;;;;;;ACpEA;AAAA;;AAnBA;AAAA;;AASA;AAAA;;AApBA;AAAA;;;AAVA;AAIA;AACA;AAKA;AAIA;AACA;AACA;AAKA;AAGA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;;;;;;;;;;;;;;;;AC7BA;;;AAAA;;;AAbA;AACA;AAEA;;;;;;;;;;;;;;AAUA;AAUA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AAGA;AACA;AACA;AAIA;AACA;AAEA;AAKA;AAEA;AACA;AACA;AApFA;AACA;AACA;AACA;AACA;AAiFA;;;;;;;;;;;;;;;;ACjEA;;;AAAA;;;AArCA;AACA;AACA;AAKA;;;;;;;;;;;;;;;;;;;AA8BA;AAIA;;AAEA;AAEA;AAEA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AAEA;AACA;AAEA;;AAEA;AAMA;AAEA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAKA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;;AA1KA;AACA;;AA0KA;;;;;;;;;;;;;;;;;;;;;;;AC/LA;AAAA;;AAVA;AAAA;;AA6FA;AAAA;;AA1FA;AAAA;;AAAA;AAAA;;AAgCA;AAAA;;AAhCA;AAAA;;AAmDA;AAAA;;AACA;AAAA;;AApDA;AAAA;;AAQA;AAAA;;AACA;AAAA;;AACA;AAAA;;AAiDA;AAAA;;AACA;AAAA;;AAqBA;AAAA;;AARA;AAAA;;AACA;AAAA;;AAcA;AAAA;;AAlBA;AAAA;;AAmEA;AAAA;;AA1HA;AAAA;;AA0EA;AAAA;;AAxCA;AAAA;;AAjCA;AAAA;;AAkCA;AAAA;;AAyCA;AAAA;;AAZA;AAAA;;AACA;AAAA;;AArDA;AAAA;;AA4CA;AAAA;;AAtDA;AAAA;;AAWA;AAAA;;AAVA;AAAA;;AACA;AAAA;;AAUA;AAAA;;AA6BA;AAAA;;AA5BA;AAAA;;AACA;AAAA;;AA8BA;AAAA;;AA+BA;AAAA;;AAVA;AAAA;;AAjDA;AAAA;;AAuCA;AAAA;;AAqBA;AAAA;;AA3DA;AAAA;;;AA5CA;AAUA;AAWA;AASA;AAeA;AAkBA;AASA;AAaA;AAQA;AAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2CA;AAIA;AAAA;AAAA;AACA;AACA;;;;;;;;;;;;;;;;AChHA;;;AAAA;;;AAzCA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;AA6BA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAKA;AAEA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAGA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAIA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;AChBA;AAAA;;AAGA;AAAA;;AACA;AAAA;;AAFA;AAAA;;AAGA;AAAA;;AARA;AAAA;;;AA1HA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAEA;;AAEA;AAqCA;;AAEA;AAEA;AAEA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AAKA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AA7FA;AAbA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAGA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAGA;AACA;AACA;AA0EA;AAEA;;;;;;;;;;;;;;;;;;;ACtHA;;;AAFA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;ACIA;;;AAAA;;;AApCA;;;;;;AAGA;AAEA;;;;;AAKA;AAEA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;ACvEA;;;AAAA;;;AAAA;;;;;;;;;;;AAWA;;;;;;;;;;;;;;;;;;;;;;;AC+HA;AAAA;;AAwBA;AAAA;;AAwBA;AAAA;;AAuBA;AAAA;;AAAA;AAAA;;;AAvMA;;;;;;;AAOA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAEA;;;AAGA;AAKA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AAqBA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AASA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAKA;AAIA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AC3MA;;;AAFA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;AC5BA;;;AAAA;;;AAAA;AAKA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAMA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;ACgHA;AAAA;;AAiWA;AAAA;;AAxcA;AAAA;;AAgoBA;AAAA;;AACA;AAAA;;;AA/qBA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAcA;;AAEA;AAIA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AArBA;AA0BA;AAoBA;;;;;;AAMA;AAEA;AACA;AACA;AACA;AAEA;;;;;AAKA;AAEA;AAEA;AACA;AAEA;;;;;;;;AAQA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AAIA;AAEA;;AAEA;AAEA;AACA;AAzFA;AAPA;AACA;AACA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAgFA;AAKA;AAaA;;AAEA;AAEA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;;AAGA;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AAIA;AAEA;AAEA;AAIA;AACA;AAGA;AACA;AACA;AAKA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAOA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AAAA;AAGA;AACA;AAOA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAIA;AACA;AACA;AACA;AAEA;AAGA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AApVA;AANA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAiVA;AAKA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AAKA;AACA;AACA;AAEA;;;;;;AAMA;AAMA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;AAKA;AAEA;AACA;AAEA;;;;;AAKA;AAKA;AACA;AACA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;;;;;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AArLA;AACA;AAuLA;;;;;;;;;;;;;;;;ACnrBA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAOA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAvBA;AAFA;AAGA;AACA;AAsBA;;;;;;;;;;;;;;;;ACvBA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AASA;;AAEA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAlCA;AAHA;AACA;AAGA;AACA;AACA;AAgCA;;;;;;;;;;;;;;;;ACnCA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAoBA;;AAEA;AAEA;AACA;AAGA;AACA;AAEA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AAjJA;AATA;AACA;AACA;AACA;AACA;AAEA;AACA;AAOA;AACA;AACA;AACA;AA0IA;;;;;;;;;;;;;;;;AC/IA;;;AAAA;;;AAvBA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAcA;AAeA;;AAEA;AAMA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AAMA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AAEA;;AAEA;AAKA;AAEA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAOA;AACA;AAKA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AA5MA;AAHA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAoMA;;;;;;;;;;;;;;;;AC9NA;;;AAAA;;;AAPA;;;;;;;;;;;;;;AAOA;AAUA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAvFA;AAJA;AACA;AACA;AAGA;AACA;AACA;AAqFA;;;;;;;;;;;;;;;;AC5FA;;;AAAA;;;AAXA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;AAMA;AAOA;;AAEA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AAIA;AACA;AACA;AAEA;AACA;AACA;AAEA;;AAEA;AAMA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;AAEA;AAMA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAhIA;AAFA;AAGA;AACA;AA+HA;;;;;;;;;;;;;;;;ACTA;;;AAAA;;;;AAtIA;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiGA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAGA;AAGA;AAEA;;;;;;;;;;;;;;;;ACoIA;;;AAAA;;;AA1QA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuEA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAIA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AAEA;;AAEA;AAMA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAEA;AACA;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;;;;;;;;;;;;;;;;ACrCA;;;AAAA;;;;AArOA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA;AAgBA;AACA;AAOA;AACA;AAEA;AAEA;AACA;AAMA;AACA;AAAA;AAAA;AAAA;AAIA;AACA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AAOA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;ACvGA;;;AAAA;;;;AA9HA;AACA;;;;;;AAsBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2EA;AAUA;AACA;AAEA;AACA;AAAA;AAAA;;AACA;;AAEA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;AACA;AAAA;AAAA;;;;;;;;;;;;AAGA;;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;ACtHA;;;AAAA;;;AARA;AACA;;;;;;AAOA;;;;;;;;;;;;;;;;ACLA;;;AAAA;;;AAHA;AAGA;;;;;;;;;;;;;;;;;;;;;;;ACyCA;AAAA;;AAQA;AAAA;;AAYA;AAAA;;AAkDA;AAAA;;;;AAlHA;AACA;;;;;;AA2BA;;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AAQA;AAIA;AACA;AAAA;;;;;;AAEA;AAKA;;AAGA;AAEA;AACA;AACA;AACA;AAGA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAKA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;AClEA;AAAA;;AAKA;AAAA;;AAYA;AAAA;;AAyBA;AAAA;;;;AAtIA;AACA;;;;;;AA2FA;AAKA;AAIA;AACA;AAAA;;;;;;AAEA;AAKA;AAGA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AAKA;AAGA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;;;;;;;;;;ACtEA;;;AAAA;;;;AA1EA;AAKA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;AAMA;AAeA;AACA;AACA;AACA;AAIA;AACA;AACA;AAEA;AACA;AAIA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;AACA;AAEA;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAIA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AAIA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;;AAEA;AAGA;AACA;AACA;AAEA;AAEA;AACA;AACA;AAAA;AAAA;AACA;AAEA;AAEA;AACA;AAEA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;AAGA;;AAEA;AAEA;AACA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AAEA;;AAEA;AAGA;AAAA;AAAA;AAAA;AACA;AACA;AAAA;AAGA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;;AAEA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AAEA;AACA;AACA;AAEA;;;;;AAAA;AAMA;AACA;AACA;AAAA;AAAA;AAAA;;;;;;;;;;;AAGA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAGA;AACA;AACA;AAAA;;;;;AAAA;AAAA;;;;;;;AAGA;;;;;;;;;;;;;;;;;;;;;;;AC3hBA;AAAA;;AAcA;AAAA;;;;AA3BA;AACA;;;;;;AAYA;AAOA;AACA;AACA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;;;;;;;;ACSA;AAAA;;AA8CA;AAAA;;AAtCA;AAAA;;AAyJA;AAAA;;AA1HA;AAAA;;AARA;AAAA;;AAuBA;AAAA;;;AA1FA;AACA;AA+BA;AACA;AACA;AAEA;AAQA;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAKA;AACA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AAKA;AAKA;AACA;AAEA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA;AAQA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;AClMA;;;AAAA;;;AAHA;AACA;AAEA;;;;;;;;;;;;;;;;AC8HA;;;AAAA;;;AAjIA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAEA;AAEA;AACA;AACA;AAEA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AAGA;AACA;AACA;AAEA;AAGA;AACA;AACA;AAEA;AAGA;AAEA;AACA;AAOA;;;;;;;;;;;;;;;;;;;;;;;AC7FA;AAAA;;AA2FA;AAAA;;AAjEA;AAAA;;AAPA;AAAA;;AAXA;AAAA;;;AA5CA;AACA;AAmBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AAAA;AAAA;AAGA;AAQA;AACA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AAAA;AAAA;AAAA;AACA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsCA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;;;;;;;;ACjHA;AAAA;;AAQA;AAAA;;AAmGA;AAAA;;AAMA;AAAA;;AApBA;AAAA;;AAOA;AAAA;;;;AAlHA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA;AACA;AAGA;AAQA;AAIA;AACA;AACA;;;;;;AAGA;AAEA;;;;;;;;;;;;;;;;;;;;;;;AAuBA;AAKA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAEA;AACA;AACA;AACA;AAKA;AACA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAKA;AACA;AAAA;AAAA;AACA;AAKA;AACA;AACA;AAKA;AACA;AACA;AACA;AACA;AAEA;;;;;;;;;;;;;;;;ACpHA;;;AAAA;;;AAXA;AAWA;AAIA;AACA;AAEA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;ACvBA;;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;AAOA;AAAA;;AAmCA;AAAA;;AA8FA;AAAA;;AAsBA;AAAA;;AAzCA;AAAA;;AA/BA;AAAA;;AA/BA;AAAA;;AApBA;AAAA;;AA8FA;AAAA;;;;;;;;;;;;;;;;AA1HA;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AAUA;AACA;AAMA;AACA;AACA;AAKA;AACA;AACA;AAEA;AACA;AAQA;AAGA;AACA;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AAUA;AACA;AACA;AAUA;AACA;AACA;AAKA;AACA;AAOA;AAcA;AAIA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;;;;;;;;;;;;;;;;AC9LA;;;AAAA;;;;AAVA;AACA;AACA;AACA;;;;;;AAOA;AAKA;AAEA;;AAEA;;AACA;;AAAA;AAAA;;;;;;;AACA;AAAA;AAAA;;;;;;;;;;;;AAEA;AACA;AAAA;;AAEA;AAAA;;AACA;AAAA;;;;;;AACA;AAAA;;;;;;AACA;AACA;AACA;AAAA;AAAA;;;;;;AAEA;AAAA;;;;;;;;;;;;AAGA;AAAA;;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;AACA;AAAA;AAAA;;;;;;;;;;;AAEA;AAAA;AACA;;;;;;AAEA;AAAA;AAAA;;;;;;AAGA;AAAA;AACA;;;;;;;;;;;;AAIA;AAAA;;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;;;;;;;AAKA;AACA;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;;;;;;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;AAIA;AAAA;AACA;;;;;;;;;;;;;;;;;;;;;;;AAOA;AAAA;;AAAA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;;;;;ACjIA;;;AAAA;;;;AARA;AACA;AACA;AACA;;;;;;AAKA;AACA;;AAEA;;AACA;AAAA;;;;;;AACA;AACA;AACA;;;;;;;;;;;;AAGA;AACA;AAAA;;AAEA;AAAA;;AACA;AAAA;;;;;;AACA;AAAA;;;;;;AACA;AACA;AACA;AAAA;AAAA;;;;;;AAEA;AAAA;;;;;;;;;;;;AAGA;AAAA;;AACA;AAAA;;AACA;AAAA;;AACA;AAAA;AAAA;;;;;;AAGA;AAAA;AAAA;;;;;;AAGA;AAAA;AACA;;AACA;AACA;AAAA;;AAAA;AAAA;AAAA;;;;;;;AAAA;AAAA;;AAIA;;;;;;;;;;;;AAKA;AAAA;;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;AAIA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;;;;;;;;;;;AAEA;;;;;;;;;;;;;;;;;;;AAKA;AAAA;;AAAA;AACA;AACA;AACA;AACA;AACA;;;;;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;;;;;;;;;AC7GA;;;;;;AAMA;;;;AACA;;;AAAA;;;;;;;;;;;;;;;;AAAA;AAGA;;;;;;;;;AASA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;;;;;;;AAOA;AAEA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAtGA;;;;;;;;;;;;ACRA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;;;;;;ACAA;;;;;;ACAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AEvBA;AACA;AACA;AACA","sources":["webpack://arcanajs/./node_modules/reflect-metadata/Reflect.js","webpack://arcanajs/./src/lib/di/Container.ts","webpack://arcanajs/./src/lib/di/decorators/metadata.ts","webpack://arcanajs/./src/lib/di/providers/AutoRegisterProvider.ts","webpack://arcanajs/./src/lib/di/support/ClassScanner.ts","webpack://arcanajs/./src/lib/index.server.ts","webpack://arcanajs/./src/lib/server/ArcanaJSMiddleware.ts","webpack://arcanajs/./src/lib/server/ArcanaJSServer.ts","webpack://arcanajs/./src/lib/server/ControllerBinder.ts","webpack://arcanajs/./src/lib/server/CsrfMiddleware.ts","webpack://arcanajs/./src/lib/server/DefaultTemplate.ts","webpack://arcanajs/./src/lib/server/DynamicRouter.ts","webpack://arcanajs/./src/lib/server/MiddlewareBinder.ts","webpack://arcanajs/./src/lib/server/ResponseHandlerMiddleware.ts","webpack://arcanajs/./src/lib/server/Router.ts","webpack://arcanajs/./src/lib/server/ServiceProvider.ts","webpack://arcanajs/./src/lib/server/config/ConfigurationManager.ts","webpack://arcanajs/./src/lib/server/lifecycle/ServerLifecycle.ts","webpack://arcanajs/./src/lib/server/middleware/MiddlewareManager.ts","webpack://arcanajs/./src/lib/server/providers/ProviderManager.ts","webpack://arcanajs/./src/lib/server/views/ViewsResolver.ts","webpack://arcanajs/./src/lib/shared/components/Body.tsx","webpack://arcanajs/./src/lib/shared/components/Head.tsx","webpack://arcanajs/./src/lib/shared/components/Link.tsx","webpack://arcanajs/./src/lib/shared/components/Page.tsx","webpack://arcanajs/./src/lib/shared/context/HeadContext.tsx","webpack://arcanajs/./src/lib/shared/context/PageContext.tsx","webpack://arcanajs/./src/lib/shared/context/RequestContext.tsx","webpack://arcanajs/./src/lib/shared/context/RouterContext.tsx","webpack://arcanajs/./src/lib/shared/core/ArcanaJSApp.tsx","webpack://arcanajs/./src/lib/shared/core/PageProvider.tsx","webpack://arcanajs/./src/lib/shared/hooks/useError.ts","webpack://arcanajs/./src/lib/shared/hooks/useHead.ts","webpack://arcanajs/./src/lib/shared/hooks/useRouter.ts","webpack://arcanajs/./src/lib/shared/hooks/useRuntimeConfig.ts","webpack://arcanajs/./src/lib/shared/hooks/useState.tsx","webpack://arcanajs/./src/lib/shared/utils/createSingletonContext.ts","webpack://arcanajs/./src/lib/shared/utils/redirect.ts","webpack://arcanajs/./src/lib/shared/views/ErrorPage.tsx","webpack://arcanajs/./src/lib/shared/views/NotFoundPage.tsx","webpack://arcanajs/./src/utils/ModuleLoader.ts","webpack://arcanajs/external commonjs \"arcanajs-views\"","webpack://arcanajs/external commonjs \"compression\"","webpack://arcanajs/external commonjs \"cookie-parser\"","webpack://arcanajs/external node-commonjs \"crypto\"","webpack://arcanajs/external commonjs \"express\"","webpack://arcanajs/external node-commonjs \"fs\"","webpack://arcanajs/external commonjs \"helmet\"","webpack://arcanajs/external node-commonjs \"node:fs\"","webpack://arcanajs/external node-commonjs \"node:path\"","webpack://arcanajs/external node-commonjs \"path\"","webpack://arcanajs/external commonjs \"react\"","webpack://arcanajs/external commonjs \"react-dom/server\"","webpack://arcanajs/external commonjs \"react/jsx-dev-runtime\"","webpack://arcanajs/webpack/bootstrap","webpack://arcanajs/webpack/before-startup","webpack://arcanajs/webpack/startup","webpack://arcanajs/webpack/after-startup"],"sourcesContent":["/*! *****************************************************************************\nCopyright (C) Microsoft. All rights reserved.\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\nthis file except in compliance with the License. You may obtain a copy of the\nLicense at http://www.apache.org/licenses/LICENSE-2.0\n\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\nMERCHANTABLITY OR NON-INFRINGEMENT.\n\nSee the Apache Version 2.0 License for specific language governing permissions\nand limitations under the License.\n***************************************************************************** */\nvar Reflect;\n(function (Reflect) {\n // Metadata Proposal\n // https://rbuckton.github.io/reflect-metadata/\n (function (factory) {\n var root = typeof globalThis === \"object\" ? globalThis :\n typeof global === \"object\" ? global :\n typeof self === \"object\" ? self :\n typeof this === \"object\" ? this :\n sloppyModeThis();\n var exporter = makeExporter(Reflect);\n if (typeof root.Reflect !== \"undefined\") {\n exporter = makeExporter(root.Reflect, exporter);\n }\n factory(exporter, root);\n if (typeof root.Reflect === \"undefined\") {\n root.Reflect = Reflect;\n }\n function makeExporter(target, previous) {\n return function (key, value) {\n Object.defineProperty(target, key, { configurable: true, writable: true, value: value });\n if (previous)\n previous(key, value);\n };\n }\n function functionThis() {\n try {\n return Function(\"return this;\")();\n }\n catch (_) { }\n }\n function indirectEvalThis() {\n try {\n return (void 0, eval)(\"(function() { return this; })()\");\n }\n catch (_) { }\n }\n function sloppyModeThis() {\n return functionThis() || indirectEvalThis();\n }\n })(function (exporter, root) {\n var hasOwn = Object.prototype.hasOwnProperty;\n // feature test for Symbol support\n var supportsSymbol = typeof Symbol === \"function\";\n var toPrimitiveSymbol = supportsSymbol && typeof Symbol.toPrimitive !== \"undefined\" ? Symbol.toPrimitive : \"@@toPrimitive\";\n var iteratorSymbol = supportsSymbol && typeof Symbol.iterator !== \"undefined\" ? Symbol.iterator : \"@@iterator\";\n var supportsCreate = typeof Object.create === \"function\"; // feature test for Object.create support\n var supportsProto = { __proto__: [] } instanceof Array; // feature test for __proto__ support\n var downLevel = !supportsCreate && !supportsProto;\n var HashMap = {\n // create an object in dictionary mode (a.k.a. \"slow\" mode in v8)\n create: supportsCreate\n ? function () { return MakeDictionary(Object.create(null)); }\n : supportsProto\n ? function () { return MakeDictionary({ __proto__: null }); }\n : function () { return MakeDictionary({}); },\n has: downLevel\n ? function (map, key) { return hasOwn.call(map, key); }\n : function (map, key) { return key in map; },\n get: downLevel\n ? function (map, key) { return hasOwn.call(map, key) ? map[key] : undefined; }\n : function (map, key) { return map[key]; },\n };\n // Load global or shim versions of Map, Set, and WeakMap\n var functionPrototype = Object.getPrototypeOf(Function);\n var _Map = typeof Map === \"function\" && typeof Map.prototype.entries === \"function\" ? Map : CreateMapPolyfill();\n var _Set = typeof Set === \"function\" && typeof Set.prototype.entries === \"function\" ? Set : CreateSetPolyfill();\n var _WeakMap = typeof WeakMap === \"function\" ? WeakMap : CreateWeakMapPolyfill();\n var registrySymbol = supportsSymbol ? Symbol.for(\"@reflect-metadata:registry\") : undefined;\n var metadataRegistry = GetOrCreateMetadataRegistry();\n var metadataProvider = CreateMetadataProvider(metadataRegistry);\n /**\n * Applies a set of decorators to a property of a target object.\n * @param decorators An array of decorators.\n * @param target The target object.\n * @param propertyKey (Optional) The property key to decorate.\n * @param attributes (Optional) The property descriptor for the target key.\n * @remarks Decorators are applied in reverse order.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Example = Reflect.decorate(decoratorsArray, Example);\n *\n * // property (on constructor)\n * Reflect.decorate(decoratorsArray, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.decorate(decoratorsArray, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Object.defineProperty(Example, \"staticMethod\",\n * Reflect.decorate(decoratorsArray, Example, \"staticMethod\",\n * Object.getOwnPropertyDescriptor(Example, \"staticMethod\")));\n *\n * // method (on prototype)\n * Object.defineProperty(Example.prototype, \"method\",\n * Reflect.decorate(decoratorsArray, Example.prototype, \"method\",\n * Object.getOwnPropertyDescriptor(Example.prototype, \"method\")));\n *\n */\n function decorate(decorators, target, propertyKey, attributes) {\n if (!IsUndefined(propertyKey)) {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsObject(target))\n throw new TypeError();\n if (!IsObject(attributes) && !IsUndefined(attributes) && !IsNull(attributes))\n throw new TypeError();\n if (IsNull(attributes))\n attributes = undefined;\n propertyKey = ToPropertyKey(propertyKey);\n return DecorateProperty(decorators, target, propertyKey, attributes);\n }\n else {\n if (!IsArray(decorators))\n throw new TypeError();\n if (!IsConstructor(target))\n throw new TypeError();\n return DecorateConstructor(decorators, target);\n }\n }\n exporter(\"decorate\", decorate);\n // 4.1.2 Reflect.metadata(metadataKey, metadataValue)\n // https://rbuckton.github.io/reflect-metadata/#reflect.metadata\n /**\n * A default metadata decorator factory that can be used on a class, class member, or parameter.\n * @param metadataKey The key for the metadata entry.\n * @param metadataValue The value for the metadata entry.\n * @returns A decorator function.\n * @remarks\n * If `metadataKey` is already defined for the target and target key, the\n * metadataValue for that key will be overwritten.\n * @example\n *\n * // constructor\n * @Reflect.metadata(key, value)\n * class Example {\n * }\n *\n * // property (on constructor, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticProperty;\n * }\n *\n * // property (on prototype, TypeScript only)\n * class Example {\n * @Reflect.metadata(key, value)\n * property;\n * }\n *\n * // method (on constructor)\n * class Example {\n * @Reflect.metadata(key, value)\n * static staticMethod() { }\n * }\n *\n * // method (on prototype)\n * class Example {\n * @Reflect.metadata(key, value)\n * method() { }\n * }\n *\n */\n function metadata(metadataKey, metadataValue) {\n function decorator(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey) && !IsPropertyKey(propertyKey))\n throw new TypeError();\n OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n return decorator;\n }\n exporter(\"metadata\", metadata);\n /**\n * Define a unique metadata entry on the target.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param metadataValue A value that contains attached metadata.\n * @param target The target object on which to define metadata.\n * @param propertyKey (Optional) The property key for the target.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * Reflect.defineMetadata(\"custom:annotation\", options, Example);\n *\n * // property (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticProperty\");\n *\n * // property (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"property\");\n *\n * // method (on constructor)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example, \"staticMethod\");\n *\n * // method (on prototype)\n * Reflect.defineMetadata(\"custom:annotation\", options, Example.prototype, \"method\");\n *\n * // decorator factory as metadata-producing annotation.\n * function MyAnnotation(options): Decorator {\n * return (target, key?) => Reflect.defineMetadata(\"custom:annotation\", options, target, key);\n * }\n *\n */\n function defineMetadata(metadataKey, metadataValue, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryDefineOwnMetadata(metadataKey, metadataValue, target, propertyKey);\n }\n exporter(\"defineMetadata\", defineMetadata);\n /**\n * Gets a value indicating whether the target object or its prototype chain has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object or its prototype chain; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasMetadata\", hasMetadata);\n /**\n * Gets a value indicating whether the target object has the provided metadata key defined.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata key was defined on the target object; otherwise, `false`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.hasOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function hasOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryHasOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"hasOwnMetadata\", hasOwnMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object or its prototype chain.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getMetadata\", getMetadata);\n /**\n * Gets the metadata value for the provided metadata key on the target object.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns The metadata value for the metadata key if found; otherwise, `undefined`.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function getOwnMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryGetOwnMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"getOwnMetadata\", getOwnMetadata);\n /**\n * Gets the metadata keys defined on the target object or its prototype chain.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryMetadataKeys(target, propertyKey);\n }\n exporter(\"getMetadataKeys\", getMetadataKeys);\n /**\n * Gets the unique metadata keys defined on the target object.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns An array of unique metadata keys.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.getOwnMetadataKeys(Example);\n *\n * // property (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.getOwnMetadataKeys(Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.getOwnMetadataKeys(Example.prototype, \"method\");\n *\n */\n function getOwnMetadataKeys(target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n return OrdinaryOwnMetadataKeys(target, propertyKey);\n }\n exporter(\"getOwnMetadataKeys\", getOwnMetadataKeys);\n /**\n * Deletes the metadata entry from the target object with the provided key.\n * @param metadataKey A key used to store and retrieve metadata.\n * @param target The target object on which the metadata is defined.\n * @param propertyKey (Optional) The property key for the target.\n * @returns `true` if the metadata entry was found and deleted; otherwise, false.\n * @example\n *\n * class Example {\n * // property declarations are not part of ES6, though they are valid in TypeScript:\n * // static staticProperty;\n * // property;\n *\n * constructor(p) { }\n * static staticMethod(p) { }\n * method(p) { }\n * }\n *\n * // constructor\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example);\n *\n * // property (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticProperty\");\n *\n * // property (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"property\");\n *\n * // method (on constructor)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example, \"staticMethod\");\n *\n * // method (on prototype)\n * result = Reflect.deleteMetadata(\"custom:annotation\", Example.prototype, \"method\");\n *\n */\n function deleteMetadata(metadataKey, target, propertyKey) {\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n if (!IsObject(target))\n throw new TypeError();\n if (!IsUndefined(propertyKey))\n propertyKey = ToPropertyKey(propertyKey);\n var provider = GetMetadataProvider(target, propertyKey, /*Create*/ false);\n if (IsUndefined(provider))\n return false;\n return provider.OrdinaryDeleteMetadata(metadataKey, target, propertyKey);\n }\n exporter(\"deleteMetadata\", deleteMetadata);\n function DecorateConstructor(decorators, target) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsConstructor(decorated))\n throw new TypeError();\n target = decorated;\n }\n }\n return target;\n }\n function DecorateProperty(decorators, target, propertyKey, descriptor) {\n for (var i = decorators.length - 1; i >= 0; --i) {\n var decorator = decorators[i];\n var decorated = decorator(target, propertyKey, descriptor);\n if (!IsUndefined(decorated) && !IsNull(decorated)) {\n if (!IsObject(decorated))\n throw new TypeError();\n descriptor = decorated;\n }\n }\n return descriptor;\n }\n // 3.1.1.1 OrdinaryHasMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasmetadata\n function OrdinaryHasMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return true;\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryHasMetadata(MetadataKey, parent, P);\n return false;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ false);\n if (IsUndefined(provider))\n return false;\n return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey, O, P));\n }\n // 3.1.3.1 OrdinaryGetMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetmetadata\n function OrdinaryGetMetadata(MetadataKey, O, P) {\n var hasOwn = OrdinaryHasOwnMetadata(MetadataKey, O, P);\n if (hasOwn)\n return OrdinaryGetOwnMetadata(MetadataKey, O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (!IsNull(parent))\n return OrdinaryGetMetadata(MetadataKey, parent, P);\n return undefined;\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ false);\n if (IsUndefined(provider))\n return;\n return provider.OrdinaryGetOwnMetadata(MetadataKey, O, P);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var provider = GetMetadataProvider(O, P, /*Create*/ true);\n provider.OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P);\n }\n // 3.1.6.1 OrdinaryMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarymetadatakeys\n function OrdinaryMetadataKeys(O, P) {\n var ownKeys = OrdinaryOwnMetadataKeys(O, P);\n var parent = OrdinaryGetPrototypeOf(O);\n if (parent === null)\n return ownKeys;\n var parentKeys = OrdinaryMetadataKeys(parent, P);\n if (parentKeys.length <= 0)\n return ownKeys;\n if (ownKeys.length <= 0)\n return parentKeys;\n var set = new _Set();\n var keys = [];\n for (var _i = 0, ownKeys_1 = ownKeys; _i < ownKeys_1.length; _i++) {\n var key = ownKeys_1[_i];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n for (var _a = 0, parentKeys_1 = parentKeys; _a < parentKeys_1.length; _a++) {\n var key = parentKeys_1[_a];\n var hasKey = set.has(key);\n if (!hasKey) {\n set.add(key);\n keys.push(key);\n }\n }\n return keys;\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var provider = GetMetadataProvider(O, P, /*create*/ false);\n if (!provider) {\n return [];\n }\n return provider.OrdinaryOwnMetadataKeys(O, P);\n }\n // 6 ECMAScript Data Types and Values\n // https://tc39.github.io/ecma262/#sec-ecmascript-data-types-and-values\n function Type(x) {\n if (x === null)\n return 1 /* Null */;\n switch (typeof x) {\n case \"undefined\": return 0 /* Undefined */;\n case \"boolean\": return 2 /* Boolean */;\n case \"string\": return 3 /* String */;\n case \"symbol\": return 4 /* Symbol */;\n case \"number\": return 5 /* Number */;\n case \"object\": return x === null ? 1 /* Null */ : 6 /* Object */;\n default: return 6 /* Object */;\n }\n }\n // 6.1.1 The Undefined Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-undefined-type\n function IsUndefined(x) {\n return x === undefined;\n }\n // 6.1.2 The Null Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-null-type\n function IsNull(x) {\n return x === null;\n }\n // 6.1.5 The Symbol Type\n // https://tc39.github.io/ecma262/#sec-ecmascript-language-types-symbol-type\n function IsSymbol(x) {\n return typeof x === \"symbol\";\n }\n // 6.1.7 The Object Type\n // https://tc39.github.io/ecma262/#sec-object-type\n function IsObject(x) {\n return typeof x === \"object\" ? x !== null : typeof x === \"function\";\n }\n // 7.1 Type Conversion\n // https://tc39.github.io/ecma262/#sec-type-conversion\n // 7.1.1 ToPrimitive(input [, PreferredType])\n // https://tc39.github.io/ecma262/#sec-toprimitive\n function ToPrimitive(input, PreferredType) {\n switch (Type(input)) {\n case 0 /* Undefined */: return input;\n case 1 /* Null */: return input;\n case 2 /* Boolean */: return input;\n case 3 /* String */: return input;\n case 4 /* Symbol */: return input;\n case 5 /* Number */: return input;\n }\n var hint = PreferredType === 3 /* String */ ? \"string\" : PreferredType === 5 /* Number */ ? \"number\" : \"default\";\n var exoticToPrim = GetMethod(input, toPrimitiveSymbol);\n if (exoticToPrim !== undefined) {\n var result = exoticToPrim.call(input, hint);\n if (IsObject(result))\n throw new TypeError();\n return result;\n }\n return OrdinaryToPrimitive(input, hint === \"default\" ? \"number\" : hint);\n }\n // 7.1.1.1 OrdinaryToPrimitive(O, hint)\n // https://tc39.github.io/ecma262/#sec-ordinarytoprimitive\n function OrdinaryToPrimitive(O, hint) {\n if (hint === \"string\") {\n var toString_1 = O.toString;\n if (IsCallable(toString_1)) {\n var result = toString_1.call(O);\n if (!IsObject(result))\n return result;\n }\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n else {\n var valueOf = O.valueOf;\n if (IsCallable(valueOf)) {\n var result = valueOf.call(O);\n if (!IsObject(result))\n return result;\n }\n var toString_2 = O.toString;\n if (IsCallable(toString_2)) {\n var result = toString_2.call(O);\n if (!IsObject(result))\n return result;\n }\n }\n throw new TypeError();\n }\n // 7.1.2 ToBoolean(argument)\n // https://tc39.github.io/ecma262/2016/#sec-toboolean\n function ToBoolean(argument) {\n return !!argument;\n }\n // 7.1.12 ToString(argument)\n // https://tc39.github.io/ecma262/#sec-tostring\n function ToString(argument) {\n return \"\" + argument;\n }\n // 7.1.14 ToPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-topropertykey\n function ToPropertyKey(argument) {\n var key = ToPrimitive(argument, 3 /* String */);\n if (IsSymbol(key))\n return key;\n return ToString(key);\n }\n // 7.2 Testing and Comparison Operations\n // https://tc39.github.io/ecma262/#sec-testing-and-comparison-operations\n // 7.2.2 IsArray(argument)\n // https://tc39.github.io/ecma262/#sec-isarray\n function IsArray(argument) {\n return Array.isArray\n ? Array.isArray(argument)\n : argument instanceof Object\n ? argument instanceof Array\n : Object.prototype.toString.call(argument) === \"[object Array]\";\n }\n // 7.2.3 IsCallable(argument)\n // https://tc39.github.io/ecma262/#sec-iscallable\n function IsCallable(argument) {\n // NOTE: This is an approximation as we cannot check for [[Call]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.4 IsConstructor(argument)\n // https://tc39.github.io/ecma262/#sec-isconstructor\n function IsConstructor(argument) {\n // NOTE: This is an approximation as we cannot check for [[Construct]] internal method.\n return typeof argument === \"function\";\n }\n // 7.2.7 IsPropertyKey(argument)\n // https://tc39.github.io/ecma262/#sec-ispropertykey\n function IsPropertyKey(argument) {\n switch (Type(argument)) {\n case 3 /* String */: return true;\n case 4 /* Symbol */: return true;\n default: return false;\n }\n }\n function SameValueZero(x, y) {\n return x === y || x !== x && y !== y;\n }\n // 7.3 Operations on Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-objects\n // 7.3.9 GetMethod(V, P)\n // https://tc39.github.io/ecma262/#sec-getmethod\n function GetMethod(V, P) {\n var func = V[P];\n if (func === undefined || func === null)\n return undefined;\n if (!IsCallable(func))\n throw new TypeError();\n return func;\n }\n // 7.4 Operations on Iterator Objects\n // https://tc39.github.io/ecma262/#sec-operations-on-iterator-objects\n function GetIterator(obj) {\n var method = GetMethod(obj, iteratorSymbol);\n if (!IsCallable(method))\n throw new TypeError(); // from Call\n var iterator = method.call(obj);\n if (!IsObject(iterator))\n throw new TypeError();\n return iterator;\n }\n // 7.4.4 IteratorValue(iterResult)\n // https://tc39.github.io/ecma262/2016/#sec-iteratorvalue\n function IteratorValue(iterResult) {\n return iterResult.value;\n }\n // 7.4.5 IteratorStep(iterator)\n // https://tc39.github.io/ecma262/#sec-iteratorstep\n function IteratorStep(iterator) {\n var result = iterator.next();\n return result.done ? false : result;\n }\n // 7.4.6 IteratorClose(iterator, completion)\n // https://tc39.github.io/ecma262/#sec-iteratorclose\n function IteratorClose(iterator) {\n var f = iterator[\"return\"];\n if (f)\n f.call(iterator);\n }\n // 9.1 Ordinary Object Internal Methods and Internal Slots\n // https://tc39.github.io/ecma262/#sec-ordinary-object-internal-methods-and-internal-slots\n // 9.1.1.1 OrdinaryGetPrototypeOf(O)\n // https://tc39.github.io/ecma262/#sec-ordinarygetprototypeof\n function OrdinaryGetPrototypeOf(O) {\n var proto = Object.getPrototypeOf(O);\n if (typeof O !== \"function\" || O === functionPrototype)\n return proto;\n // TypeScript doesn't set __proto__ in ES5, as it's non-standard.\n // Try to determine the superclass constructor. Compatible implementations\n // must either set __proto__ on a subclass constructor to the superclass constructor,\n // or ensure each class has a valid `constructor` property on its prototype that\n // points back to the constructor.\n // If this is not the same as Function.[[Prototype]], then this is definately inherited.\n // This is the case when in ES6 or when using __proto__ in a compatible browser.\n if (proto !== functionPrototype)\n return proto;\n // If the super prototype is Object.prototype, null, or undefined, then we cannot determine the heritage.\n var prototype = O.prototype;\n var prototypeProto = prototype && Object.getPrototypeOf(prototype);\n if (prototypeProto == null || prototypeProto === Object.prototype)\n return proto;\n // If the constructor was not a function, then we cannot determine the heritage.\n var constructor = prototypeProto.constructor;\n if (typeof constructor !== \"function\")\n return proto;\n // If we have some kind of self-reference, then we cannot determine the heritage.\n if (constructor === O)\n return proto;\n // we have a pretty good guess at the heritage.\n return constructor;\n }\n // Global metadata registry\n // - Allows `import \"reflect-metadata\"` and `import \"reflect-metadata/no-conflict\"` to interoperate.\n // - Uses isolated metadata if `Reflect` is frozen before the registry can be installed.\n /**\n * Creates a registry used to allow multiple `reflect-metadata` providers.\n */\n function CreateMetadataRegistry() {\n var fallback;\n if (!IsUndefined(registrySymbol) &&\n typeof root.Reflect !== \"undefined\" &&\n !(registrySymbol in root.Reflect) &&\n typeof root.Reflect.defineMetadata === \"function\") {\n // interoperate with older version of `reflect-metadata` that did not support a registry.\n fallback = CreateFallbackProvider(root.Reflect);\n }\n var first;\n var second;\n var rest;\n var targetProviderMap = new _WeakMap();\n var registry = {\n registerProvider: registerProvider,\n getProvider: getProvider,\n setProvider: setProvider,\n };\n return registry;\n function registerProvider(provider) {\n if (!Object.isExtensible(registry)) {\n throw new Error(\"Cannot add provider to a frozen registry.\");\n }\n switch (true) {\n case fallback === provider: break;\n case IsUndefined(first):\n first = provider;\n break;\n case first === provider: break;\n case IsUndefined(second):\n second = provider;\n break;\n case second === provider: break;\n default:\n if (rest === undefined)\n rest = new _Set();\n rest.add(provider);\n break;\n }\n }\n function getProviderNoCache(O, P) {\n if (!IsUndefined(first)) {\n if (first.isProviderFor(O, P))\n return first;\n if (!IsUndefined(second)) {\n if (second.isProviderFor(O, P))\n return first;\n if (!IsUndefined(rest)) {\n var iterator = GetIterator(rest);\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n return undefined;\n }\n var provider = IteratorValue(next);\n if (provider.isProviderFor(O, P)) {\n IteratorClose(iterator);\n return provider;\n }\n }\n }\n }\n }\n if (!IsUndefined(fallback) && fallback.isProviderFor(O, P)) {\n return fallback;\n }\n return undefined;\n }\n function getProvider(O, P) {\n var providerMap = targetProviderMap.get(O);\n var provider;\n if (!IsUndefined(providerMap)) {\n provider = providerMap.get(P);\n }\n if (!IsUndefined(provider)) {\n return provider;\n }\n provider = getProviderNoCache(O, P);\n if (!IsUndefined(provider)) {\n if (IsUndefined(providerMap)) {\n providerMap = new _Map();\n targetProviderMap.set(O, providerMap);\n }\n providerMap.set(P, provider);\n }\n return provider;\n }\n function hasProvider(provider) {\n if (IsUndefined(provider))\n throw new TypeError();\n return first === provider || second === provider || !IsUndefined(rest) && rest.has(provider);\n }\n function setProvider(O, P, provider) {\n if (!hasProvider(provider)) {\n throw new Error(\"Metadata provider not registered.\");\n }\n var existingProvider = getProvider(O, P);\n if (existingProvider !== provider) {\n if (!IsUndefined(existingProvider)) {\n return false;\n }\n var providerMap = targetProviderMap.get(O);\n if (IsUndefined(providerMap)) {\n providerMap = new _Map();\n targetProviderMap.set(O, providerMap);\n }\n providerMap.set(P, provider);\n }\n return true;\n }\n }\n /**\n * Gets or creates the shared registry of metadata providers.\n */\n function GetOrCreateMetadataRegistry() {\n var metadataRegistry;\n if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {\n metadataRegistry = root.Reflect[registrySymbol];\n }\n if (IsUndefined(metadataRegistry)) {\n metadataRegistry = CreateMetadataRegistry();\n }\n if (!IsUndefined(registrySymbol) && IsObject(root.Reflect) && Object.isExtensible(root.Reflect)) {\n Object.defineProperty(root.Reflect, registrySymbol, {\n enumerable: false,\n configurable: false,\n writable: false,\n value: metadataRegistry\n });\n }\n return metadataRegistry;\n }\n function CreateMetadataProvider(registry) {\n // [[Metadata]] internal slot\n // https://rbuckton.github.io/reflect-metadata/#ordinary-object-internal-methods-and-internal-slots\n var metadata = new _WeakMap();\n var provider = {\n isProviderFor: function (O, P) {\n var targetMetadata = metadata.get(O);\n if (IsUndefined(targetMetadata))\n return false;\n return targetMetadata.has(P);\n },\n OrdinaryDefineOwnMetadata: OrdinaryDefineOwnMetadata,\n OrdinaryHasOwnMetadata: OrdinaryHasOwnMetadata,\n OrdinaryGetOwnMetadata: OrdinaryGetOwnMetadata,\n OrdinaryOwnMetadataKeys: OrdinaryOwnMetadataKeys,\n OrdinaryDeleteMetadata: OrdinaryDeleteMetadata,\n };\n metadataRegistry.registerProvider(provider);\n return provider;\n function GetOrCreateMetadataMap(O, P, Create) {\n var targetMetadata = metadata.get(O);\n var createdTargetMetadata = false;\n if (IsUndefined(targetMetadata)) {\n if (!Create)\n return undefined;\n targetMetadata = new _Map();\n metadata.set(O, targetMetadata);\n createdTargetMetadata = true;\n }\n var metadataMap = targetMetadata.get(P);\n if (IsUndefined(metadataMap)) {\n if (!Create)\n return undefined;\n metadataMap = new _Map();\n targetMetadata.set(P, metadataMap);\n if (!registry.setProvider(O, P, provider)) {\n targetMetadata.delete(P);\n if (createdTargetMetadata) {\n metadata.delete(O);\n }\n throw new Error(\"Wrong provider for target.\");\n }\n }\n return metadataMap;\n }\n // 3.1.2.1 OrdinaryHasOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryhasownmetadata\n function OrdinaryHasOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n return ToBoolean(metadataMap.has(MetadataKey));\n }\n // 3.1.4.1 OrdinaryGetOwnMetadata(MetadataKey, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarygetownmetadata\n function OrdinaryGetOwnMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return undefined;\n return metadataMap.get(MetadataKey);\n }\n // 3.1.5.1 OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinarydefineownmetadata\n function OrdinaryDefineOwnMetadata(MetadataKey, MetadataValue, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ true);\n metadataMap.set(MetadataKey, MetadataValue);\n }\n // 3.1.7.1 OrdinaryOwnMetadataKeys(O, P)\n // https://rbuckton.github.io/reflect-metadata/#ordinaryownmetadatakeys\n function OrdinaryOwnMetadataKeys(O, P) {\n var keys = [];\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return keys;\n var keysObj = metadataMap.keys();\n var iterator = GetIterator(keysObj);\n var k = 0;\n while (true) {\n var next = IteratorStep(iterator);\n if (!next) {\n keys.length = k;\n return keys;\n }\n var nextValue = IteratorValue(next);\n try {\n keys[k] = nextValue;\n }\n catch (e) {\n try {\n IteratorClose(iterator);\n }\n finally {\n throw e;\n }\n }\n k++;\n }\n }\n function OrdinaryDeleteMetadata(MetadataKey, O, P) {\n var metadataMap = GetOrCreateMetadataMap(O, P, /*Create*/ false);\n if (IsUndefined(metadataMap))\n return false;\n if (!metadataMap.delete(MetadataKey))\n return false;\n if (metadataMap.size === 0) {\n var targetMetadata = metadata.get(O);\n if (!IsUndefined(targetMetadata)) {\n targetMetadata.delete(P);\n if (targetMetadata.size === 0) {\n metadata.delete(targetMetadata);\n }\n }\n }\n return true;\n }\n }\n function CreateFallbackProvider(reflect) {\n var defineMetadata = reflect.defineMetadata, hasOwnMetadata = reflect.hasOwnMetadata, getOwnMetadata = reflect.getOwnMetadata, getOwnMetadataKeys = reflect.getOwnMetadataKeys, deleteMetadata = reflect.deleteMetadata;\n var metadataOwner = new _WeakMap();\n var provider = {\n isProviderFor: function (O, P) {\n var metadataPropertySet = metadataOwner.get(O);\n if (!IsUndefined(metadataPropertySet) && metadataPropertySet.has(P)) {\n return true;\n }\n if (getOwnMetadataKeys(O, P).length) {\n if (IsUndefined(metadataPropertySet)) {\n metadataPropertySet = new _Set();\n metadataOwner.set(O, metadataPropertySet);\n }\n metadataPropertySet.add(P);\n return true;\n }\n return false;\n },\n OrdinaryDefineOwnMetadata: defineMetadata,\n OrdinaryHasOwnMetadata: hasOwnMetadata,\n OrdinaryGetOwnMetadata: getOwnMetadata,\n OrdinaryOwnMetadataKeys: getOwnMetadataKeys,\n OrdinaryDeleteMetadata: deleteMetadata,\n };\n return provider;\n }\n /**\n * Gets the metadata provider for an object. If the object has no metadata provider and this is for a create operation,\n * then this module's metadata provider is assigned to the object.\n */\n function GetMetadataProvider(O, P, Create) {\n var registeredProvider = metadataRegistry.getProvider(O, P);\n if (!IsUndefined(registeredProvider)) {\n return registeredProvider;\n }\n if (Create) {\n if (metadataRegistry.setProvider(O, P, metadataProvider)) {\n return metadataProvider;\n }\n throw new Error(\"Illegal state.\");\n }\n return undefined;\n }\n // naive Map shim\n function CreateMapPolyfill() {\n var cacheSentinel = {};\n var arraySentinel = [];\n var MapIterator = /** @class */ (function () {\n function MapIterator(keys, values, selector) {\n this._index = 0;\n this._keys = keys;\n this._values = values;\n this._selector = selector;\n }\n MapIterator.prototype[\"@@iterator\"] = function () { return this; };\n MapIterator.prototype[iteratorSymbol] = function () { return this; };\n MapIterator.prototype.next = function () {\n var index = this._index;\n if (index >= 0 && index < this._keys.length) {\n var result = this._selector(this._keys[index], this._values[index]);\n if (index + 1 >= this._keys.length) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n else {\n this._index++;\n }\n return { value: result, done: false };\n }\n return { value: undefined, done: true };\n };\n MapIterator.prototype.throw = function (error) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n throw error;\n };\n MapIterator.prototype.return = function (value) {\n if (this._index >= 0) {\n this._index = -1;\n this._keys = arraySentinel;\n this._values = arraySentinel;\n }\n return { value: value, done: true };\n };\n return MapIterator;\n }());\n var Map = /** @class */ (function () {\n function Map() {\n this._keys = [];\n this._values = [];\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n Object.defineProperty(Map.prototype, \"size\", {\n get: function () { return this._keys.length; },\n enumerable: true,\n configurable: true\n });\n Map.prototype.has = function (key) { return this._find(key, /*insert*/ false) >= 0; };\n Map.prototype.get = function (key) {\n var index = this._find(key, /*insert*/ false);\n return index >= 0 ? this._values[index] : undefined;\n };\n Map.prototype.set = function (key, value) {\n var index = this._find(key, /*insert*/ true);\n this._values[index] = value;\n return this;\n };\n Map.prototype.delete = function (key) {\n var index = this._find(key, /*insert*/ false);\n if (index >= 0) {\n var size = this._keys.length;\n for (var i = index + 1; i < size; i++) {\n this._keys[i - 1] = this._keys[i];\n this._values[i - 1] = this._values[i];\n }\n this._keys.length--;\n this._values.length--;\n if (SameValueZero(key, this._cacheKey)) {\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n }\n return true;\n }\n return false;\n };\n Map.prototype.clear = function () {\n this._keys.length = 0;\n this._values.length = 0;\n this._cacheKey = cacheSentinel;\n this._cacheIndex = -2;\n };\n Map.prototype.keys = function () { return new MapIterator(this._keys, this._values, getKey); };\n Map.prototype.values = function () { return new MapIterator(this._keys, this._values, getValue); };\n Map.prototype.entries = function () { return new MapIterator(this._keys, this._values, getEntry); };\n Map.prototype[\"@@iterator\"] = function () { return this.entries(); };\n Map.prototype[iteratorSymbol] = function () { return this.entries(); };\n Map.prototype._find = function (key, insert) {\n if (!SameValueZero(this._cacheKey, key)) {\n this._cacheIndex = -1;\n for (var i = 0; i < this._keys.length; i++) {\n if (SameValueZero(this._keys[i], key)) {\n this._cacheIndex = i;\n break;\n }\n }\n }\n if (this._cacheIndex < 0 && insert) {\n this._cacheIndex = this._keys.length;\n this._keys.push(key);\n this._values.push(undefined);\n }\n return this._cacheIndex;\n };\n return Map;\n }());\n return Map;\n function getKey(key, _) {\n return key;\n }\n function getValue(_, value) {\n return value;\n }\n function getEntry(key, value) {\n return [key, value];\n }\n }\n // naive Set shim\n function CreateSetPolyfill() {\n var Set = /** @class */ (function () {\n function Set() {\n this._map = new _Map();\n }\n Object.defineProperty(Set.prototype, \"size\", {\n get: function () { return this._map.size; },\n enumerable: true,\n configurable: true\n });\n Set.prototype.has = function (value) { return this._map.has(value); };\n Set.prototype.add = function (value) { return this._map.set(value, value), this; };\n Set.prototype.delete = function (value) { return this._map.delete(value); };\n Set.prototype.clear = function () { this._map.clear(); };\n Set.prototype.keys = function () { return this._map.keys(); };\n Set.prototype.values = function () { return this._map.keys(); };\n Set.prototype.entries = function () { return this._map.entries(); };\n Set.prototype[\"@@iterator\"] = function () { return this.keys(); };\n Set.prototype[iteratorSymbol] = function () { return this.keys(); };\n return Set;\n }());\n return Set;\n }\n // naive WeakMap shim\n function CreateWeakMapPolyfill() {\n var UUID_SIZE = 16;\n var keys = HashMap.create();\n var rootKey = CreateUniqueKey();\n return /** @class */ (function () {\n function WeakMap() {\n this._key = CreateUniqueKey();\n }\n WeakMap.prototype.has = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.has(table, this._key) : false;\n };\n WeakMap.prototype.get = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? HashMap.get(table, this._key) : undefined;\n };\n WeakMap.prototype.set = function (target, value) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ true);\n table[this._key] = value;\n return this;\n };\n WeakMap.prototype.delete = function (target) {\n var table = GetOrCreateWeakMapTable(target, /*create*/ false);\n return table !== undefined ? delete table[this._key] : false;\n };\n WeakMap.prototype.clear = function () {\n // NOTE: not a real clear, just makes the previous data unreachable\n this._key = CreateUniqueKey();\n };\n return WeakMap;\n }());\n function CreateUniqueKey() {\n var key;\n do\n key = \"@@WeakMap@@\" + CreateUUID();\n while (HashMap.has(keys, key));\n keys[key] = true;\n return key;\n }\n function GetOrCreateWeakMapTable(target, create) {\n if (!hasOwn.call(target, rootKey)) {\n if (!create)\n return undefined;\n Object.defineProperty(target, rootKey, { value: HashMap.create() });\n }\n return target[rootKey];\n }\n function FillRandomBytes(buffer, size) {\n for (var i = 0; i < size; ++i)\n buffer[i] = Math.random() * 0xff | 0;\n return buffer;\n }\n function GenRandomBytes(size) {\n if (typeof Uint8Array === \"function\") {\n var array = new Uint8Array(size);\n if (typeof crypto !== \"undefined\") {\n crypto.getRandomValues(array);\n }\n else if (typeof msCrypto !== \"undefined\") {\n msCrypto.getRandomValues(array);\n }\n else {\n FillRandomBytes(array, size);\n }\n return array;\n }\n return FillRandomBytes(new Array(size), size);\n }\n function CreateUUID() {\n var data = GenRandomBytes(UUID_SIZE);\n // mark as random - RFC 4122 § 4.4\n data[6] = data[6] & 0x4f | 0x40;\n data[8] = data[8] & 0xbf | 0x80;\n var result = \"\";\n for (var offset = 0; offset < UUID_SIZE; ++offset) {\n var byte = data[offset];\n if (offset === 4 || offset === 6 || offset === 8)\n result += \"-\";\n if (byte < 16)\n result += \"0\";\n result += byte.toString(16).toLowerCase();\n }\n return result;\n }\n }\n // uses a heuristic used by v8 and chakra to force an object into dictionary mode.\n function MakeDictionary(obj) {\n obj.__ = undefined;\n delete obj.__;\n return obj;\n }\n });\n})(Reflect || (Reflect = {}));\n","import \"reflect-metadata\";\n\nexport type ClassConstructor<T = any> = new (...args: any[]) => T;\nexport type FactoryFunction<T = any> = (container: Container) => T;\n\nexport class Container {\n private static instance: Container;\n private bindings: Map<string | ClassConstructor, FactoryFunction> = new Map();\n private singletons: Map<string | ClassConstructor, any> = new Map();\n\n constructor() {\n if (!Container.instance) {\n Container.instance = this;\n }\n }\n\n /**\n * Get the global container instance\n */\n public static getInstance(): Container {\n if (!Container.instance) {\n Container.instance = new Container();\n }\n return Container.instance;\n }\n\n /**\n * Bind a class or factory to the container\n */\n public bind<T>(\n key: string | ClassConstructor<T>,\n value: ClassConstructor<T> | FactoryFunction<T>\n ): void {\n if (this.isConstructor(value)) {\n this.bindings.set(key, () => this.build(value));\n } else {\n this.bindings.set(key, value as FactoryFunction<T>);\n }\n }\n\n /**\n * Bind a singleton to the container\n */\n public singleton<T>(\n key: string | ClassConstructor<T>,\n value: ClassConstructor<T> | FactoryFunction<T>\n ): void {\n const factory = this.isConstructor(value)\n ? () => this.build(value)\n : (value as FactoryFunction<T>);\n\n this.bindings.set(key, () => {\n if (!this.singletons.has(key)) {\n this.singletons.set(key, factory(this));\n }\n return this.singletons.get(key);\n });\n }\n\n /**\n * Resolve a dependency from the container\n */\n public make<T>(key: string | ClassConstructor<T>): T {\n if (this.bindings.has(key)) {\n return this.bindings.get(key)!(this);\n }\n\n // If it's a class and not bound, try to build it directly\n if (this.isConstructor(key)) {\n return this.build(key);\n }\n\n throw new Error(`Service not found: ${key.toString()}`);\n }\n\n /**\n * Check if a service is registered in the container\n */\n public has(key: string | ClassConstructor): boolean {\n return this.bindings.has(key);\n }\n\n /**\n * Alias for make() - resolve a dependency from the container\n */\n public resolve<T>(key: string | ClassConstructor<T>): T {\n return this.make(key);\n }\n\n /**\n * Instantiate a class, resolving its dependencies\n */\n private build<T>(target: ClassConstructor<T>): T {\n // Get constructor parameters using reflect-metadata\n const params = Reflect.getMetadata(\"design:paramtypes\", target) || [];\n\n const injections = params.map((param: any) => {\n return this.make(param);\n });\n\n return new target(...injections);\n }\n\n private isConstructor(obj: any): obj is ClassConstructor {\n return !!obj.prototype && !!obj.prototype.constructor.name;\n }\n}\n\nexport const container = Container.getInstance();\n","import \"reflect-metadata\";\nimport { ClassConstructor } from \"../Container\";\nimport { InjectableMetadata } from \"./types\";\n\nconst INJECTABLE_METADATA_KEY = \"arcanajs:injectable\";\nconst globalInjectables: InjectableMetadata[] = [];\n\n/**\n * Set injectable metadata for a class\n */\nexport function setInjectableMetadata(\n target: ClassConstructor,\n metadata: InjectableMetadata\n): void {\n Reflect.defineMetadata(INJECTABLE_METADATA_KEY, metadata, target);\n globalInjectables.push(metadata);\n}\n\n/**\n * Get injectable metadata for a class\n */\nexport function getInjectableMetadata(\n target: ClassConstructor\n): InjectableMetadata | undefined {\n return Reflect.getMetadata(INJECTABLE_METADATA_KEY, target);\n}\n\n/**\n * Check if a class is injectable\n */\nexport function isInjectable(target: any): boolean {\n if (!target || typeof target !== \"function\") {\n return false;\n }\n return Reflect.hasMetadata(INJECTABLE_METADATA_KEY, target);\n}\n\n/**\n * Get all registered injectable classes\n */\nexport function getAllInjectables(): InjectableMetadata[] {\n return globalInjectables;\n}\n","import { ServiceProvider } from \"../../server/ServiceProvider\";\nimport { getAllInjectables } from \"../decorators/metadata\";\nimport { AutoDiscoveryConfig } from \"../decorators/types\";\nimport { ClassScanner } from \"../support/ClassScanner\";\n\nexport interface AutoRegisterConfig extends AutoDiscoveryConfig {\n directories: string[];\n}\n\n/**\n * Service provider that automatically discovers and registers\n * classes decorated with @Injectable, @Service, @Repository, or @Controller\n */\nexport class AutoRegisterProvider extends ServiceProvider {\n private config: AutoRegisterConfig;\n private scanner: ClassScanner;\n\n constructor(app: any, config: AutoRegisterConfig) {\n super(app);\n this.config = config;\n this.scanner = new ClassScanner();\n }\n\n async register(): Promise<void> {\n if (!this.config.enabled) {\n return;\n }\n\n const debug = this.config.debug || false;\n\n if (debug) {\n console.log(\"[AutoRegisterProvider] Starting auto-discovery...\");\n }\n\n // First, try to get injectables from the global registry\n // (in case they were already imported elsewhere)\n let injectables = getAllInjectables();\n\n // If directories are specified, scan them for additional injectables\n if (this.config.directories && this.config.directories.length > 0) {\n const discovered = await this.scanner.scan({\n directories: this.config.directories,\n include: this.config.include,\n exclude: this.config.exclude,\n debug,\n });\n\n // Merge with existing injectables (avoid duplicates)\n const existingTargets = new Set(injectables.map((i) => i.target));\n for (const injectable of discovered) {\n if (!existingTargets.has(injectable.target)) {\n injectables.push(injectable);\n }\n }\n }\n\n if (injectables.length === 0) {\n if (debug) {\n console.warn(\n \"[AutoRegisterProvider] No injectable classes found. Make sure your classes are decorated with @Injectable, @Service, @Repository, or @Controller.\"\n );\n }\n return;\n }\n\n // Register all discovered injectables\n let registeredCount = 0;\n for (const injectable of injectables) {\n try {\n const key = injectable.key || injectable.target;\n\n if (injectable.scope === \"singleton\") {\n this.app.container.singleton(key, injectable.target);\n } else {\n this.app.container.bind(key, injectable.target);\n }\n\n registeredCount++;\n\n if (debug) {\n console.log(\n `[AutoRegisterProvider] Registered ${injectable.target.name} as ${injectable.scope}`\n );\n }\n } catch (error) {\n console.error(\n `[AutoRegisterProvider] Failed to register ${injectable.target.name}:`,\n error\n );\n }\n }\n\n console.log(\n `✓ Auto-registered ${registeredCount} injectable class${\n registeredCount !== 1 ? \"es\" : \"\"\n }`\n );\n }\n\n async boot(): Promise<void> {\n // Nothing to do on boot\n }\n}\n","import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { ModuleLoader } from \"../../../utils/ModuleLoader\";\nimport { ClassConstructor } from \"../../di/Container\";\nimport {\n getInjectableMetadata,\n isInjectable,\n} from \"../../di/decorators/metadata\";\nimport { InjectableMetadata } from \"../../di/decorators/types\";\n\nexport interface ScanOptions {\n /**\n * Directories to scan\n */\n directories: string[];\n\n /**\n * File patterns to include (glob patterns)\n * @default ['**\\/*.ts', '**\\/*.js']\n */\n include?: string[];\n\n /**\n * File patterns to exclude (glob patterns)\n * @default ['**\\/*.test.ts', '**\\/*.spec.ts', '**\\/node_modules/**']\n */\n exclude?: string[];\n\n /**\n * Enable debug logging\n */\n debug?: boolean;\n}\n\n/**\n * Scans directories for classes decorated with @Injectable and related decorators\n */\nexport class ClassScanner {\n private readonly scannedFiles = new Set<string>();\n private tsSupportRegistered = false;\n\n /**\n * Scan directories and return all injectable classes\n */\n async scan(options: ScanOptions): Promise<InjectableMetadata[]> {\n const {\n directories,\n include = [\"**/*.ts\", \"**/*.js\"],\n exclude = [\"**/*.test.ts\", \"**/*.spec.ts\", \"**/node_modules/**\"],\n debug = false,\n } = options;\n\n const injectables: InjectableMetadata[] = [];\n const root = process.cwd();\n\n for (const dir of directories) {\n const absoluteDir = path.isAbsolute(dir) ? dir : path.resolve(root, dir);\n\n if (!fs.existsSync(absoluteDir)) {\n if (debug) {\n console.warn(`[ClassScanner] Directory not found: ${absoluteDir}`);\n }\n continue;\n }\n\n if (debug) {\n console.log(`[ClassScanner] Scanning directory: ${absoluteDir}`);\n }\n\n const files = await this.scanDirectory(absoluteDir, include, exclude);\n\n for (const file of files) {\n if (this.scannedFiles.has(file)) continue;\n this.scannedFiles.add(file);\n\n try {\n const discovered = await this.scanFile(file, debug);\n injectables.push(...discovered);\n } catch (error) {\n if (debug) {\n console.error(`[ClassScanner] Error scanning file ${file}:`, error);\n }\n }\n }\n }\n\n if (debug) {\n console.log(\n `[ClassScanner] Found ${injectables.length} injectable classes`\n );\n }\n\n return injectables;\n }\n\n /**\n * Recursively scan a directory for files\n */\n private async scanDirectory(\n dir: string,\n include: string[],\n exclude: string[]\n ): Promise<string[]> {\n const files: string[] = [];\n\n const traverse = (currentDir: string) => {\n const entries = fs.readdirSync(currentDir, { withFileTypes: true });\n\n for (const entry of entries) {\n const fullPath = path.join(currentDir, entry.name);\n\n // Check exclude patterns\n if (this.matchesPatterns(fullPath, exclude)) {\n continue;\n }\n\n if (entry.isDirectory()) {\n traverse(fullPath);\n } else if (entry.isFile()) {\n // Check include patterns\n if (this.matchesPatterns(fullPath, include)) {\n files.push(fullPath);\n }\n }\n }\n };\n\n traverse(dir);\n return files;\n }\n\n /**\n * Scan a single file for injectable classes\n */\n private async scanFile(\n filePath: string,\n debug: boolean\n ): Promise<InjectableMetadata[]> {\n const injectables: InjectableMetadata[] = [];\n\n // Register ts-node if needed for TypeScript files\n if (filePath.endsWith(\".ts\") && !filePath.endsWith(\".d.ts\")) {\n this.registerTsSupport(filePath, debug);\n }\n\n try {\n // Dynamic import to load the module\n const moduleExports = ModuleLoader.require(filePath);\n\n // Check all exports for injectable classes\n for (const key of Object.keys(moduleExports)) {\n const exported = moduleExports[key];\n\n if (isInjectable(exported)) {\n const metadata = getInjectableMetadata(exported as ClassConstructor);\n if (metadata) {\n injectables.push(metadata);\n if (debug) {\n console.log(\n `[ClassScanner] Found injectable: ${exported.name} (${metadata.scope})`\n );\n }\n }\n }\n }\n } catch (error) {\n // Silently skip files that can't be imported\n if (debug) {\n console.warn(`[ClassScanner] Could not import ${filePath}:`, error);\n }\n }\n\n return injectables;\n }\n\n /**\n * Register ts-node once so Node can import TS files.\n */\n private registerTsSupport(filePath: string, debug: boolean) {\n if (this.tsSupportRegistered) return;\n this.tsSupportRegistered = ModuleLoader.registerTsNode();\n }\n\n /**\n * Check if a path matches any of the given patterns\n */\n private matchesPatterns(filePath: string, patterns: string[]): boolean {\n return patterns.some((pattern) => {\n // Simple glob matching (supports ** and *)\n const regexPattern = this.buildRegexPattern(pattern);\n\n const regex = new RegExp(regexPattern);\n return regex.test(filePath);\n });\n }\n\n private buildRegexPattern(pattern: string): string {\n const escapedDots = pattern.split(\".\").join(String.raw`\\.`);\n const withPlaceholder = escapedDots.split(\"**\").join(\"__DOUBLE_STAR__\");\n const singleStars = withPlaceholder.split(\"*\").join(\"[^/]*\");\n return singleStars.split(\"__DOUBLE_STAR__\").join(\".*\");\n }\n\n /**\n * Clear the scanned files cache\n */\n clear(): void {\n this.scannedFiles.clear();\n }\n}\n","import { Express } from \"express\";\nimport ArcanaJSServer, { ArcanaJSConfig } from \"./server/ArcanaJSServer\";\n\n// ============================================================================\n// Server Core Exports\n// ============================================================================\n\n// Server\nexport { default as ArcanaJSServer } from \"./server/ArcanaJSServer\";\nexport type { ArcanaJSConfig } from \"./server/ArcanaJSServer\";\n\nexport { Express, NextFunction, Request, Response } from \"express\";\n\n// ============================================================================\n// Routing Exports\n// ============================================================================\n\nexport {\n ArcanaJSRouter,\n default as Route,\n RouteBuilder,\n RouteRegistry,\n} from \"./server/Router\";\n\n// Dynamic router utilities\nexport {\n createDynamicRouter,\n generateViewUrl,\n getViewRoutes,\n matchPattern,\n matchRoute,\n} from \"./server/DynamicRouter\";\n\n// ============================================================================\n// Universal Redirect (SSR + SPA)\n// ============================================================================\n\nexport {\n getSSRContext,\n isRedirectError,\n navigateTo,\n permanentRedirect,\n redirect,\n RedirectError,\n setSSRContext,\n temporaryRedirect,\n} from \"./shared/utils/redirect\";\n\n// ============================================================================\n// Middleware Exports\n// ============================================================================\n\nexport type { Middleware } from \"./validation/http/Middleware\";\n\n// ============================================================================\n// SSR Context & Utilities (for server-side rendering)\n// ============================================================================\n\n// Request context for SSR\nexport {\n createRequestContext,\n getClientRequestContext,\n RequestContext,\n RequestContextProvider,\n} from \"./shared/context/RequestContext\";\nexport type { RequestContextType } from \"./shared/context/RequestContext\";\n\n// Router context for SSR\nexport {\n parseQueryString,\n RouterContext,\n RouterProvider,\n serializeQueryString,\n} from \"./shared/context/RouterContext\";\nexport type {\n NavigateOptions,\n RouterContextType,\n} from \"./shared/context/RouterContext\";\n\n// Shared state for SSR\nexport {\n clearSharedState,\n getSharedState,\n setSharedState,\n SharedStateContext,\n SharedStateProvider,\n} from \"./shared/hooks/useState\";\n\n// Runtime config\nexport {\n getPublicRuntimeConfig,\n getRuntimeConfig,\n RuntimeConfigContext,\n setRuntimeConfig,\n} from \"./shared/hooks/useRuntimeConfig\";\nexport type { RuntimeConfig } from \"./shared/hooks/useRuntimeConfig\";\n\n// Error handling\nexport {\n clearGlobalError,\n createError,\n ErrorContext,\n getGlobalError,\n setGlobalError,\n showError,\n} from \"./shared/hooks/useError\";\nexport type { ArcanaError } from \"./shared/hooks/useError\";\n\n// ============================================================================\n// Server Factory Function\n// ============================================================================\n\n/**\n * Create an ArcanaJS server with the given Express app\n *\n * @param app - Express application instance\n * @param config - Optional ArcanaJS configuration\n * @returns ArcanaJSServer instance\n *\n * @example\n * ```typescript\n * import express from 'express';\n * import { createArcanaServer, Route } from 'arcanajs/server';\n *\n * const app = express();\n *\n * // Define routes with professional features\n * Route.get('/users/:id', [UserController, 'show'])\n * .name('user.show')\n * .whereNumber('id');\n *\n * // Redirects (SSR + SPA compatible)\n * Route.redirect('/old-path', '/new-path');\n *\n * // Generate URL from route name\n * const url = Route.urlFor('user.show', { id: 1 }); // '/users/1'\n *\n * // List all routes\n * Route.printRoutes();\n *\n * const server = createArcanaServer(app, {\n * port: 3000,\n * viewsDir: 'src/resources/views',\n * });\n *\n * server.start();\n * ```\n */\nexport function createArcanaServer(\n app: Express,\n config?: Partial<ArcanaJSConfig>\n): ArcanaJSServer {\n const server = new ArcanaJSServer({ ...config });\n return server;\n}\n","import { NextFunction, Request, Response } from \"express\";\nimport fs from \"fs\";\nimport React from \"react\";\nimport { renderToString } from \"react-dom/server\";\nimport { HeadContext, HeadManager } from \"../shared/context/HeadContext\";\nimport { ArcanaJSApp } from \"../shared/core/ArcanaJSApp\";\nimport { defaultHtmlTemplate } from \"./DefaultTemplate\";\n\nconst DEFAULT_HTML_TEMPLATE = defaultHtmlTemplate;\n\n// Extend Express Response interface\ndeclare global {\n namespace Express {\n interface Response {\n /**\n * Renders a React page using ArcanaJS SSR.\n *\n * @param page - The name of the page component to render.\n * @param data - Initial data to pass to the page component (default: {}).\n * @param params - Route parameters (default: {}).\n * @returns The Express Response object.\n */\n renderPage(\n page: string,\n data?: any,\n params?: Record<string, string>\n ): Response;\n }\n }\n}\n\ninterface ArcanaJSOptions {\n views: Record<string, React.FC<any>>;\n indexFile?: string;\n layout?: React.FC<any>;\n}\n\n// Helper to prevent XSS in initial data\nconst safeStringify = (obj: any) => {\n return JSON.stringify(obj).replace(/</g, \"\\\\u003c\");\n};\n\nexport const createArcanaJSMiddleware = (options: ArcanaJSOptions) => {\n const { views, indexFile, layout } = options;\n let cachedIndexHtml: string | null = null;\n\n const getIndexHtml = (\n callback: (err: NodeJS.ErrnoException | null, data: string) => void\n ) => {\n if (process.env.NODE_ENV === \"production\" && cachedIndexHtml) {\n return callback(null, cachedIndexHtml);\n }\n\n if (indexFile && fs.existsSync(indexFile)) {\n fs.readFile(indexFile, \"utf8\", (err, htmlData) => {\n if (!err && process.env.NODE_ENV === \"production\") {\n cachedIndexHtml = htmlData;\n }\n callback(err, htmlData);\n });\n } else {\n if (process.env.NODE_ENV === \"production\") {\n cachedIndexHtml = DEFAULT_HTML_TEMPLATE;\n }\n callback(null, DEFAULT_HTML_TEMPLATE);\n }\n };\n\n return (req: Request, res: Response, next: NextFunction) => {\n res.renderPage = (\n page: string,\n data: any = {},\n params: Record<string, string> = {}\n ) => {\n const csrfToken = res.locals.csrfToken;\n\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n return res.json({ page, data, params, csrfToken });\n }\n try {\n const headTags: React.ReactNode[] = [];\n const headManager: HeadManager = {\n tags: headTags,\n push: (nodes) => headTags.push(nodes),\n };\n\n const appHtml = renderToString(\n React.createElement(\n HeadContext.Provider,\n { value: headManager },\n React.createElement(ArcanaJSApp, {\n initialPage: page,\n initialData: data,\n initialParams: params,\n initialUrl: req.path,\n csrfToken: csrfToken,\n views: views,\n layout: layout,\n })\n )\n );\n\n const headHtml = renderToString(\n React.createElement(React.Fragment, null, ...headTags)\n );\n\n getIndexHtml((err, htmlData) => {\n if (err) {\n console.error(\"Error reading index.html\", err);\n return res.status(500).send(\"Server Error\");\n }\n\n const scriptContent = safeStringify({\n page,\n data,\n params,\n csrfToken,\n });\n const nonce = res.locals.nonce || \"\";\n const scriptTag = `<script id=\"__ARCANAJS_DATA__\" type=\"application/json\" nonce=\"${nonce}\">${scriptContent}</script>`;\n\n // Inject HMR port for the client (script is auto-injected by webpack)\n const hmrPortScript = process.env.ARCANAJS_HMR_PORT\n ? `<script nonce=\"${nonce}\">window.__ARCANAJS_HMR_PORT__ = ${process.env.ARCANAJS_HMR_PORT};</script>`\n : \"\";\n\n const html = htmlData\n .replace(\"<!--HEAD_CONTENT-->\", headHtml)\n .replace(\"<!--APP_CONTENT-->\", appHtml)\n .replace(\"<!--ARCANAJS_DATA_SCRIPT-->\", scriptTag + hmrPortScript);\n\n res.send(html);\n });\n } catch (error) {\n console.error(\"SSR Error:\", error);\n return res.status(500).send(\"Internal Server Error\");\n }\n return res;\n };\n next();\n };\n};\n","import express, { Express } from \"express\";\nimport { Container } from \"../di/Container\";\nimport { ConfigurationManager } from \"./config/ConfigurationManager\";\nimport { ArcanaJSConfig, ResolvedViews } from \"./config/types\";\nimport { ServerLifecycle } from \"./lifecycle/ServerLifecycle\";\nimport { MiddlewareManager } from \"./middleware/MiddlewareManager\";\nimport { ProviderManager } from \"./providers/ProviderManager\";\nimport { ViewsResolver } from \"./views/ViewsResolver\";\n\n/**\n * Main ArcanaJS Server class - orchestrates all components\n */\nclass ArcanaJSServer {\n public app: Express;\n public container: Container;\n\n private config: ArcanaJSConfig;\n private configManager: ConfigurationManager;\n private providerManager: ProviderManager;\n private middlewareManager: MiddlewareManager;\n private viewsResolver: ViewsResolver;\n private lifecycle: ServerLifecycle;\n\n private resolvedViews!: ResolvedViews;\n private initialized = false;\n\n constructor(config: ArcanaJSConfig) {\n this.config = config;\n this.app = express();\n this.container = Container.getInstance();\n\n // Initialize managers\n this.configManager = new ConfigurationManager(this.container, config);\n this.providerManager = new ProviderManager(this, config);\n this.middlewareManager = new MiddlewareManager(this.app, config);\n this.viewsResolver = new ViewsResolver(config);\n this.lifecycle = new ServerLifecycle(\n this.app,\n config.autoHandleSignals !== false,\n {\n onShutdown: () => this.providerManager.shutdown(),\n }\n );\n\n // Setup middleware immediately\n this.setupMiddleware();\n }\n\n /**\n * Initialize async components (config, providers)\n */\n private async initializeAsync(): Promise<void> {\n if (this.initialized) return;\n\n await this.configManager.load();\n await this.providerManager.register();\n await this.providerManager.boot();\n\n this.initialized = true;\n }\n\n /**\n * Setup all middleware and routes\n */\n private setupMiddleware(): void {\n // Resolve views\n this.resolvedViews = this.viewsResolver.resolve();\n\n // Setup middleware with resolved views and routes\n this.middlewareManager.setup(\n this.resolvedViews,\n this.config.routes,\n this.config.apiRoutes\n );\n }\n\n /**\n * Start the server\n */\n public async start(): Promise<void> {\n await this.initializeAsync();\n\n const port = this.config.port || process.env.PORT || 3000;\n await this.lifecycle.start(port);\n }\n\n /**\n * Stop the server\n */\n public async stop(): Promise<void> {\n await this.lifecycle.stop();\n }\n\n /**\n * Get the resolved views\n */\n public getViews(): ResolvedViews {\n return this.resolvedViews;\n }\n\n /**\n * Get the configuration manager\n */\n public getConfigManager(): ConfigurationManager {\n return this.configManager;\n }\n\n /**\n * Get the provider manager\n */\n public getProviderManager(): ProviderManager {\n return this.providerManager;\n }\n\n /**\n * Check if server is running\n */\n public isRunning(): boolean {\n return this.lifecycle.isRunning();\n }\n}\n\nexport default ArcanaJSServer;\n\n// Re-export types and managers for external use\nexport { ConfigurationManager } from \"./config/ConfigurationManager\";\nexport type { ArcanaJSConfig, ResolvedViews } from \"./config/types\";\nexport { ServerLifecycle } from \"./lifecycle/ServerLifecycle\";\nexport { MiddlewareManager } from \"./middleware/MiddlewareManager\";\nexport { ProviderManager } from \"./providers/ProviderManager\";\nexport { ViewsResolver } from \"./views/ViewsResolver\";\n","import { NextFunction, Request, Response } from \"express\";\n\nimport { container } from \"../di/Container\";\n\nexport default class ControllerBinder {\n static handle(controller: any, method: string) {\n // Instantiate the controller once (Singleton pattern) for performance\n // This assumes controllers are stateless, which is best practice.\n let instance: any;\n try {\n instance = container.make(controller);\n } catch (e) {\n // Fallback if controller is not a class or fails to instantiate\n console.warn(`Failed to instantiate controller ${controller.name}`, e);\n instance = controller;\n }\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n // Call the method\n if (typeof instance[method] === \"function\") {\n await instance[method](req, res, next);\n } else {\n throw new Error(\n `Method ${method} not found on controller ${controller.name}`\n );\n }\n } catch (error) {\n next(error);\n }\n };\n }\n}\n","import crypto from \"crypto\";\nimport { NextFunction, Request, Response } from \"express\";\n\nconst CSRF_COOKIE_NAME = \"_csrf\";\n\n/**\n * Timing-safe CSRF token comparison to prevent timing attacks\n * This ensures that token validation takes constant time regardless of where\n * the tokens differ, preventing attackers from using timing analysis to\n * guess valid tokens character by character.\n */\nfunction isValidCsrfToken(providedToken: string, expectedToken: string): boolean {\n // Ensure both tokens are the same length to prevent timing attacks\n // If lengths differ, we still perform a comparison to maintain constant time\n if (providedToken.length !== expectedToken.length) {\n // Create a dummy token of the same length as expected for constant-time comparison\n const dummyToken = \"0\".repeat(expectedToken.length);\n crypto.timingSafeEqual(\n Buffer.from(dummyToken),\n Buffer.from(expectedToken)\n );\n return false;\n }\n\n try {\n // Perform constant-time comparison of the tokens\n return crypto.timingSafeEqual(\n Buffer.from(providedToken),\n Buffer.from(expectedToken)\n );\n } catch (error) {\n // If buffer conversion fails, tokens are invalid\n return false;\n }\n}\n\nexport const createCsrfMiddleware = () => {\n return (req: Request, res: Response, next: NextFunction) => {\n // 1. Generate or retrieve token\n let token = req.cookies[CSRF_COOKIE_NAME];\n\n if (!token) {\n token = crypto.randomBytes(32).toString(\"hex\");\n res.cookie(CSRF_COOKIE_NAME, token, {\n httpOnly: true,\n secure: process.env.NODE_ENV === \"production\",\n sameSite: \"strict\",\n });\n }\n\n // 2. Expose token to the response locals (for injection into the view)\n res.locals.csrfToken = token;\n\n // 3. Verify token on state-changing methods\n const method = req.method.toUpperCase();\n if ([\"POST\", \"PUT\", \"DELETE\", \"PATCH\"].includes(method)) {\n const headerToken = req.headers[\"x-csrf-token\"];\n\n // Validate token exists and is a string\n if (!headerToken || typeof headerToken !== \"string\") {\n return res.status(403).json({ error: \"Invalid CSRF Token\" });\n }\n\n // Use timing-safe comparison to prevent timing attacks\n if (!isValidCsrfToken(headerToken, token)) {\n return res.status(403).json({ error: \"Invalid CSRF Token\" });\n }\n }\n\n next();\n };\n};\n","export const defaultHtmlTemplate = `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <!--HEAD_CONTENT-->\n </head>\n <body>\n <div id=\"root\"><!--APP_CONTENT--></div>\n <!--ARCANAJS_DATA_SCRIPT-->\n </body>\n</html>`;\n","import { NextFunction, Request, Response } from \"express\";\n\n/**\n * Represents matched parameters from dynamic routing\n */\ninterface RouteMatch {\n viewName: string;\n params: Record<string, string>;\n}\n\n/**\n * Match a request path against view patterns\n * Supports:\n * - Exact matches: 'users' matches '/users'\n * - Dynamic segments: 'users/[id]' matches '/users/123'\n * - Catch-all segments: 'docs/[...slug]' matches '/docs/a/b/c'\n * - Optional catch-all: 'docs/[[...slug]]' matches '/docs' and '/docs/a/b/c'\n */\nfunction matchRoute(\n views: Record<string, any>,\n path: string\n): RouteMatch | null {\n // Handle root path\n if (path === \"\") {\n path = \"index\";\n }\n\n // 1. Try exact match first\n if (views[path]) {\n return { viewName: path, params: {} };\n }\n\n // 2. Try dynamic and catch-all matches\n for (const viewName of Object.keys(views)) {\n const match = matchPattern(viewName, path);\n if (match) {\n return { viewName, params: match };\n }\n }\n\n return null;\n}\n\n/**\n * Match a single pattern against a path\n * Returns params object if matched, null otherwise\n */\nfunction matchPattern(\n pattern: string,\n path: string\n): Record<string, string> | null {\n const patternParts = pattern.split(\"/\");\n const pathParts = path.split(\"/\");\n const params: Record<string, string> = {};\n\n let patternIndex = 0;\n let pathIndex = 0;\n\n while (patternIndex < patternParts.length) {\n const patternPart = patternParts[patternIndex];\n\n // Optional catch-all: [[...param]]\n if (patternPart.startsWith(\"[[...\") && patternPart.endsWith(\"]]\")) {\n const paramName = patternPart.slice(5, -2);\n\n // Match remaining path parts (can be empty)\n if (pathIndex < pathParts.length) {\n params[paramName] = pathParts.slice(pathIndex).join(\"/\");\n } else {\n params[paramName] = \"\";\n }\n\n return params;\n }\n\n // Required catch-all: [...param]\n if (patternPart.startsWith(\"[...\") && patternPart.endsWith(\"]\")) {\n const paramName = patternPart.slice(4, -1);\n\n // Must have at least one segment\n if (pathIndex >= pathParts.length) {\n return null;\n }\n\n // Match remaining path parts\n params[paramName] = pathParts.slice(pathIndex).join(\"/\");\n return params;\n }\n\n // Dynamic segment: [param]\n if (patternPart.startsWith(\"[\") && patternPart.endsWith(\"]\")) {\n if (pathIndex >= pathParts.length) {\n return null; // No corresponding path part\n }\n\n const paramName = patternPart.slice(1, -1);\n params[paramName] = pathParts[pathIndex];\n patternIndex++;\n pathIndex++;\n continue;\n }\n\n // Static segment - must match exactly\n if (pathIndex >= pathParts.length || patternPart !== pathParts[pathIndex]) {\n return null;\n }\n\n patternIndex++;\n pathIndex++;\n }\n\n // Path must be fully consumed unless pattern ends with catch-all\n if (pathIndex !== pathParts.length) {\n return null;\n }\n\n return params;\n}\n\n/**\n * Create dynamic router middleware for views\n *\n * Supports file-based routing patterns:\n * - `/users` → 'users' view\n * - `/users/123` → 'users/[id]' view with params.id = '123'\n * - `/docs/a/b/c` → 'docs/[...slug]' view with params.slug = 'a/b/c'\n * - `/docs` or `/docs/x` → 'docs/[[...slug]]' view (optional catch-all)\n *\n * @example\n * // Views structure:\n * {\n * 'index': IndexPage,\n * 'users': UsersPage,\n * 'users/[id]': UserDetailPage,\n * 'docs/[...slug]': DocsPage,\n * 'blog/[[...slug]]': BlogPage,\n * }\n */\nexport const createDynamicRouter = (views: Record<string, any>) => {\n return (req: Request, res: Response, next: NextFunction) => {\n // Remove leading slash\n const path = req.path.substring(1);\n\n // Try to match the route\n const match = matchRoute(views, path);\n\n if (match) {\n return res.renderPage(match.viewName, {}, match.params);\n }\n\n // If not found, pass to the next middleware (usually 404 handler)\n next();\n };\n};\n\n/**\n * Utility to generate a URL from a view name and params\n *\n * @example\n * generateViewUrl('users/[id]', { id: '123' }); // '/users/123'\n * generateViewUrl('docs/[...slug]', { slug: 'api/auth' }); // '/docs/api/auth'\n */\nexport function generateViewUrl(\n viewName: string,\n params: Record<string, string> = {}\n): string {\n let url = viewName;\n\n // Replace dynamic segments with params\n for (const [key, value] of Object.entries(params)) {\n // Match catch-all patterns\n url = url.replace(`[...${key}]`, value);\n url = url.replace(`[[...${key}]]`, value);\n // Match dynamic segments\n url = url.replace(`[${key}]`, value);\n }\n\n // Handle empty optional catch-all\n url = url.replace(/\\/\\[\\[\\.\\.\\..*?\\]\\]/g, \"\");\n\n return `/${url}`;\n}\n\n/**\n * Get all routes from views with their patterns\n */\nexport function getViewRoutes(views: Record<string, any>): Array<{\n pattern: string;\n type: \"static\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\";\n}> {\n return Object.keys(views).map((viewName) => {\n let type: \"static\" | \"dynamic\" | \"catch-all\" | \"optional-catch-all\" =\n \"static\";\n\n if (viewName.includes(\"[[...\")) {\n type = \"optional-catch-all\";\n } else if (viewName.includes(\"[...\")) {\n type = \"catch-all\";\n } else if (viewName.includes(\"[\")) {\n type = \"dynamic\";\n }\n\n return {\n pattern: `/${viewName}`,\n type,\n };\n });\n}\n\nexport { matchPattern, matchRoute };\n","import { NextFunction, Request, Response } from \"express\";\n\nimport { container } from \"../di/Container\";\n\nexport default class MiddlewareBinder {\n static handle(middleware: any, method: string = \"handle\") {\n // Instantiate the middleware once (Singleton pattern) for performance\n let instance: any;\n try {\n instance = container.make(middleware);\n } catch (e) {\n // Fallback if middleware is not a class or fails to instantiate\n instance = middleware;\n }\n\n return async (req: Request, res: Response, next: NextFunction) => {\n try {\n // Call the method\n if (typeof instance[method] === \"function\") {\n await instance[method](req, res, next);\n } else {\n throw new Error(\n `Method ${method} not found on middleware ${middleware.name}`\n );\n }\n } catch (error) {\n next(error);\n }\n };\n }\n}\n","import type { NextFunction, Request, Response } from \"express\";\n\nexport const responseHandler = (\n req: Request,\n res: Response,\n next: NextFunction\n) => {\n res.success = (\n data: string | object | null = {},\n message: string = \"Success\",\n status: number = 200\n ) => {\n return res.status(status).json({\n success: true,\n message,\n data,\n error: null,\n });\n };\n\n res.error = (\n message: string = \"Error\",\n status: number = 500,\n error: string | object | null | undefined | unknown = null,\n data: string | object | null = null\n ) => {\n const errorResponse: string | object | null = error\n ? typeof error === \"object\" && error !== null\n ? error instanceof Error\n ? error.toString()\n : error\n : error.toString()\n : null;\n\n return res.status(status).json({\n success: false,\n message,\n data,\n error: errorResponse,\n });\n };\n\n next();\n};\n","import express, {\n Router as ExpressRouter,\n NextFunction,\n Request,\n RequestHandler,\n Response,\n} from \"express\";\nimport ControllerBinder from \"./ControllerBinder\";\nimport MiddlewareBinder from \"./MiddlewareBinder\";\n\n/**\n * Route definition for internal storage\n */\ninterface RouteDefinition {\n method: string;\n path: string;\n name?: string;\n constraints: Record<string, RegExp>;\n middlewares: RequestHandler[];\n action: any;\n}\n\n/**\n * Named routes registry for reverse routing\n */\nclass RouteRegistry {\n private static routes: Map<string, RouteDefinition> = new Map();\n\n static register(name: string, route: RouteDefinition): void {\n this.routes.set(name, route);\n }\n\n static get(name: string): RouteDefinition | undefined {\n return this.routes.get(name);\n }\n\n static has(name: string): boolean {\n return this.routes.has(name);\n }\n\n static all(): Map<string, RouteDefinition> {\n return this.routes;\n }\n\n static clear(): void {\n this.routes.clear();\n }\n}\n\n/**\n * Route builder for chaining route configuration\n */\nexport class RouteBuilder {\n private routeName?: string;\n private routeConstraints: Record<string, RegExp> = {};\n private registerFn: (\n name?: string,\n constraints?: Record<string, RegExp>\n ) => void;\n\n constructor(\n registerFn: (name?: string, constraints?: Record<string, RegExp>) => void\n ) {\n this.registerFn = registerFn;\n // Auto-register without name if not chained\n setTimeout(() => {\n if (!this.routeName) {\n this.registerFn(undefined, this.routeConstraints);\n }\n }, 0);\n }\n\n /**\n * Assign a name to the route for reverse routing\n *\n * @example\n * Route.get('/users/:id', handler).name('user.show');\n * // Later: Route.urlFor('user.show', { id: 1 }) => '/users/1'\n */\n name(routeName: string): this {\n this.routeName = routeName;\n this.registerFn(routeName, this.routeConstraints);\n return this;\n }\n\n /**\n * Add parameter constraints to the route\n *\n * @example\n * Route.get('/users/:id', handler).where('id', /^\\d+$/);\n */\n where(param: string, pattern: RegExp | string): this {\n this.routeConstraints[param] =\n typeof pattern === \"string\" ? new RegExp(pattern) : pattern;\n return this;\n }\n\n /**\n * Add multiple constraints at once\n *\n * @example\n * Route.get('/posts/:year/:month', handler).whereAll({\n * year: /^\\d{4}$/,\n * month: /^\\d{2}$/\n * });\n */\n whereAll(constraints: Record<string, RegExp | string>): this {\n for (const [param, pattern] of Object.entries(constraints)) {\n this.where(param, pattern);\n }\n return this;\n }\n\n /**\n * Constraint: parameter must be numeric\n */\n whereNumber(param: string): this {\n return this.where(param, /^\\d+$/);\n }\n\n /**\n * Constraint: parameter must be alphabetic\n */\n whereAlpha(param: string): this {\n return this.where(param, /^[a-zA-Z]+$/);\n }\n\n /**\n * Constraint: parameter must be alphanumeric\n */\n whereAlphaNumeric(param: string): this {\n return this.where(param, /^[a-zA-Z0-9]+$/);\n }\n\n /**\n * Constraint: parameter must be a UUID\n */\n whereUuid(param: string): this {\n return this.where(\n param,\n /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i\n );\n }\n\n /**\n * Constraint: parameter must be a slug\n */\n whereSlug(param: string): this {\n return this.where(param, /^[a-z0-9]+(?:-[a-z0-9]+)*$/);\n }\n}\n\n/**\n * Provides Routing syntax for defining routes with prefixes, middlewares, and groups for ArcanaJS Framework\n */\nexport class ArcanaJSRouter {\n private router: ExpressRouter;\n private middlewareStack: RequestHandler[];\n private prefixStack: string[];\n private isApiMode: boolean = false;\n private registeredRoutes: RouteDefinition[] = [];\n\n constructor() {\n this.router = express.Router();\n this.middlewareStack = [];\n this.prefixStack = [];\n }\n\n /**\n * Add middleware to the current stack\n */\n middleware(...middleware: any[]): ArcanaJSRouter {\n const newRouter = this._clone();\n const resolvedMiddlewares = middleware.map((m) =>\n this._resolveMiddleware(m)\n );\n newRouter.middlewareStack = [\n ...this.middlewareStack,\n ...resolvedMiddlewares,\n ];\n return newRouter;\n }\n\n /**\n * Add prefix to the current stack\n */\n prefix(prefix: string): ArcanaJSRouter {\n const newRouter = this._clone();\n newRouter.prefixStack = [\n ...this.prefixStack,\n prefix.replace(/^\\/|\\/$/g, \"\"),\n ];\n return newRouter;\n }\n\n /**\n * Mark routes as API-only (JSON responses, no HTML)\n */\n api(): ArcanaJSRouter {\n const newRouter = this._clone();\n newRouter.isApiMode = true;\n return newRouter;\n }\n\n /**\n * Create a route group\n */\n group(callback: (router: ArcanaJSRouter) => void): ArcanaJSRouter {\n callback(this);\n return this;\n }\n\n /**\n * Define a GET route\n */\n get(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"get\", path, action, middlewares);\n }\n\n /**\n * Define a POST route\n */\n post(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"post\", path, action, middlewares);\n }\n\n /**\n * Define a PUT route\n */\n put(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"put\", path, action, middlewares);\n }\n\n /**\n * Define a DELETE route\n */\n delete(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"delete\", path, action, middlewares);\n }\n\n /**\n * Define a PATCH route\n */\n patch(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"patch\", path, action, middlewares);\n }\n\n /**\n * Define an OPTIONS route\n */\n options(path: string, ...args: any[]): RouteBuilder {\n const action = args.pop();\n const middlewares = args;\n return this._addRoute(\"options\", path, action, middlewares);\n }\n\n /**\n * Define a resource route\n * Registers index, create, store, show, edit, update, destroy routes\n */\n resource(\n path: string,\n controller: any,\n options?: { only?: string[]; except?: string[] }\n ): ArcanaJSRouter {\n const resourceName = path.replace(/^\\//, \"\").replace(/\\//g, \".\");\n const actions = [\n \"index\",\n \"create\",\n \"store\",\n \"show\",\n \"edit\",\n \"update\",\n \"destroy\",\n ];\n\n const shouldInclude = (action: string) => {\n if (options?.only) return options.only.includes(action);\n if (options?.except) return !options.except.includes(action);\n return true;\n };\n\n if (shouldInclude(\"index\"))\n this.get(path, controller, \"index\").name(`${resourceName}.index`);\n if (shouldInclude(\"create\"))\n this.get(`${path}/create`, controller, \"create\").name(\n `${resourceName}.create`\n );\n if (shouldInclude(\"store\"))\n this.post(path, controller, \"store\").name(`${resourceName}.store`);\n if (shouldInclude(\"show\"))\n this.get(`${path}/:id`, controller, \"show\").name(`${resourceName}.show`);\n if (shouldInclude(\"edit\"))\n this.get(`${path}/:id/edit`, controller, \"edit\").name(\n `${resourceName}.edit`\n );\n if (shouldInclude(\"update\")) {\n this.put(`${path}/:id`, controller, \"update\").name(\n `${resourceName}.update`\n );\n this.patch(`${path}/:id`, controller, \"update\");\n }\n if (shouldInclude(\"destroy\"))\n this.delete(`${path}/:id`, controller, \"destroy\").name(\n `${resourceName}.destroy`\n );\n\n return this;\n }\n\n /**\n * Get the underlying Express router\n */\n getRouter(): ExpressRouter {\n return this.router;\n }\n\n /**\n * Get all registered routes\n */\n getRoutes(): RouteDefinition[] {\n return this.registeredRoutes;\n }\n\n /**\n * Clone the current router instance\n */\n private _clone(): ArcanaJSRouter {\n const newRouter = new ArcanaJSRouter();\n newRouter.router = this.router;\n newRouter.middlewareStack = [...this.middlewareStack];\n newRouter.prefixStack = [...this.prefixStack];\n newRouter.isApiMode = this.isApiMode;\n newRouter.registeredRoutes = this.registeredRoutes;\n return newRouter;\n }\n\n /**\n * Add a route to the router\n */\n private _addRoute(\n method: \"get\" | \"post\" | \"put\" | \"delete\" | \"patch\" | \"options\",\n path: string,\n action: any,\n routeMiddlewares: any[] = []\n ): RouteBuilder {\n const fullPath = this._buildPath(path);\n const handler = this._buildHandler(action);\n const flatMiddlewares = routeMiddlewares.flat(Infinity);\n const resolvedMiddlewares = flatMiddlewares.map((m) =>\n this._resolveMiddleware(m)\n );\n\n // API mode middleware\n const apiMiddleware: RequestHandler[] = this.isApiMode\n ? [\n (_req: Request, res: Response, next: NextFunction) => {\n res.setHeader(\"Content-Type\", \"application/json\");\n next();\n },\n ]\n : [];\n\n const middlewares = [\n ...apiMiddleware,\n ...this.middlewareStack,\n ...resolvedMiddlewares,\n ];\n\n // Create route definition\n const routeDef: RouteDefinition = {\n method: method.toUpperCase(),\n path: fullPath,\n constraints: {},\n middlewares,\n action,\n };\n\n // Create builder that will register the route\n let registered = false;\n const builder = new RouteBuilder((name, constraints) => {\n if (registered) return;\n registered = true;\n\n routeDef.name = name;\n routeDef.constraints = constraints || {};\n\n // Add constraint validation middleware if there are constraints\n const constraintMiddleware: RequestHandler[] =\n Object.keys(routeDef.constraints).length > 0\n ? [this._createConstraintMiddleware(routeDef.constraints)]\n : [];\n\n // Register with Express\n this.router[method](\n fullPath,\n ...constraintMiddleware,\n ...middlewares,\n handler\n );\n\n // Store route definition\n this.registeredRoutes.push(routeDef);\n\n // Register named route\n if (name) {\n RouteRegistry.register(name, routeDef);\n }\n });\n\n return builder;\n }\n\n /**\n * Create middleware for parameter constraint validation\n */\n private _createConstraintMiddleware(\n constraints: Record<string, RegExp>\n ): RequestHandler {\n return (req: Request, res: Response, next: NextFunction) => {\n for (const [param, pattern] of Object.entries(constraints)) {\n const value = req.params[param];\n if (value && !pattern.test(value)) {\n return res.status(404).json({\n error: \"Not Found\",\n message: `Parameter '${param}' does not match required pattern`,\n });\n }\n }\n next();\n };\n }\n\n /**\n * Resolve middleware to RequestHandler\n */\n private _resolveMiddleware(middleware: any): RequestHandler {\n if (typeof middleware === \"function\" && !middleware.prototype?.handle) {\n // It's a standard express middleware function\n return middleware;\n }\n\n if (Array.isArray(middleware) && middleware.length === 2) {\n // It's [MiddlewareClass, 'method']\n const [middlewareClass, method] = middleware;\n return MiddlewareBinder.handle(middlewareClass, method);\n }\n\n if (\n typeof middleware === \"function\" ||\n (typeof middleware === \"object\" && middleware !== null)\n ) {\n // It's a Middleware Class (constructor) or instance\n // Default to 'handle' method\n return MiddlewareBinder.handle(middleware, \"handle\");\n }\n\n throw new Error(\n \"Invalid middleware. Must be a function, [Class, 'method'], or Class.\"\n );\n }\n\n /**\n * Build the full path with prefixes\n */\n private _buildPath(path: string): string {\n const cleanPath = path.replace(/^\\//, \"\");\n const prefixes = this.prefixStack.filter((p) => p !== \"\");\n\n if (prefixes.length === 0) {\n return `/${cleanPath}`;\n }\n\n return `/${prefixes.join(\"/\")}/${cleanPath}`.replace(/\\/+/g, \"/\");\n }\n\n /**\n * Build the route handler\n */\n private _buildHandler(action: any): RequestHandler {\n if (typeof action === \"function\") {\n return action;\n }\n\n if (Array.isArray(action) && action.length === 2) {\n const [controller, method] = action;\n return ControllerBinder.handle(controller, method);\n }\n\n throw new Error(\n 'Action must be a function or array [Controller, \"method\"]'\n );\n }\n}\n\n/**\n * Static Route class for ArcanaJS Routing\n */\nexport class Route {\n private static _router = new ArcanaJSRouter();\n private static _allRoutes: RouteDefinition[] = [];\n\n static middleware(...middleware: any[]): typeof Route {\n this._router = this._router.middleware(...middleware);\n return this;\n }\n\n static prefix(prefix: string): typeof Route {\n this._router = this._router.prefix(prefix);\n return this;\n }\n\n /**\n * Mark following routes as API-only (JSON responses)\n */\n static api(): typeof Route {\n this._router = this._router.api();\n return this;\n }\n\n static group(callback: (router: ArcanaJSRouter) => void): typeof Route {\n this._router.group(callback);\n return this;\n }\n\n static get(path: string, ...args: any[]): RouteBuilder {\n return this._router.get(path, ...args);\n }\n\n static post(path: string, ...args: any[]): RouteBuilder {\n return this._router.post(path, ...args);\n }\n\n static put(path: string, ...args: any[]): RouteBuilder {\n return this._router.put(path, ...args);\n }\n\n static delete(path: string, ...args: any[]): RouteBuilder {\n return this._router.delete(path, ...args);\n }\n\n static patch(path: string, ...args: any[]): RouteBuilder {\n return this._router.patch(path, ...args);\n }\n\n static options(path: string, ...args: any[]): RouteBuilder {\n return this._router.options(path, ...args);\n }\n\n static resource(\n path: string,\n controller: any,\n options?: { only?: string[]; except?: string[] }\n ): typeof Route {\n this._router.resource(path, controller, options);\n return this;\n }\n\n /**\n * Define a redirect route\n *\n * @example\n * Route.redirect('/old-path', '/new-path');\n * Route.redirect('/legacy', '/modern', 301);\n */\n static redirect(\n from: string,\n to: string,\n status: number = 302\n ): typeof Route {\n this._router.get(from, (req: Request, res: Response) => {\n // Check if this is an ArcanaJS SPA request\n const isArcanaRequest = req.headers[\"x-arcanajs-request\"] === \"true\";\n\n if (isArcanaRequest) {\n // For SPA navigation, return JSON with redirect info\n res.json({\n redirect: true,\n url: to,\n status,\n });\n } else {\n // For SSR/traditional navigation, use HTTP redirect\n res.redirect(status, to);\n }\n });\n return this;\n }\n\n /**\n * Define a permanent redirect (301)\n *\n * @example\n * Route.permanentRedirect('/old', '/new');\n */\n static permanentRedirect(from: string, to: string): typeof Route {\n return this.redirect(from, to, 301);\n }\n\n /**\n * Generate URL for a named route\n *\n * @example\n * Route.urlFor('user.show', { id: 1 }); // => '/users/1'\n */\n static urlFor(\n name: string,\n params: Record<string, string | number> = {}\n ): string {\n const route = RouteRegistry.get(name);\n if (!route) {\n throw new Error(\n `Route '${name}' not found. Make sure to define routes with .name('${name}')`\n );\n }\n\n let url = route.path;\n\n // Replace named parameters\n for (const [key, value] of Object.entries(params)) {\n url = url.replace(`:${key}`, String(value));\n }\n\n // Check for any remaining unresolved parameters\n const unresolvedParams = url.match(/:([a-zA-Z_][a-zA-Z0-9_]*)/g);\n if (unresolvedParams) {\n throw new Error(\n `Missing required parameters: ${unresolvedParams.join(\", \")}`\n );\n }\n\n return url;\n }\n\n /**\n * Check if a named route exists\n */\n static hasRoute(name: string): boolean {\n return RouteRegistry.has(name);\n }\n\n /**\n * List all registered routes\n *\n * @example\n * const routes = Route.list();\n * console.table(routes);\n */\n static list(): Array<{ method: string; path: string; name?: string }> {\n return this._allRoutes.map((r) => ({\n method: r.method,\n path: r.path,\n name: r.name,\n }));\n }\n\n /**\n * Print all routes to console in a formatted table\n */\n static printRoutes(): void {\n const routes = this.list();\n console.log(\"\\n📍 Registered Routes:\\n\");\n console.log(\"─\".repeat(60));\n console.log(\"METHOD\".padEnd(10) + \"PATH\".padEnd(35) + \"NAME\");\n console.log(\"─\".repeat(60));\n for (const route of routes) {\n console.log(\n route.method.padEnd(10) + route.path.padEnd(35) + (route.name || \"-\")\n );\n }\n console.log(\"─\".repeat(60));\n console.log(`Total: ${routes.length} routes\\n`);\n }\n\n static getRouter(): ExpressRouter {\n const router = this._router.getRouter();\n this._allRoutes = [...this._allRoutes, ...this._router.getRoutes()];\n this._router = new ArcanaJSRouter(); // Reset for next use\n return router;\n }\n}\n\nexport { RouteRegistry };\nexport default Route;\n","import { IApplication } from \"./types/IApplication\";\n\nexport abstract class ServiceProvider {\n protected app: IApplication;\n\n constructor(app: IApplication) {\n this.app = app;\n }\n\n /**\n * Register any application services.\n */\n register(): void {\n //\n }\n\n /**\n * Bootstrap any application services.\n */\n boot(): void {\n //\n }\n\n /**\n * Shutdown any application services.\n */\n async shutdown(): Promise<void> {\n //\n }\n}\n","import { Container } from \"../../di/Container\";\nimport { ArcanaJSConfig } from \"./types\";\n\n/**\n * Manages configuration loading and registration in the DI container\n */\nexport class ConfigurationManager {\n private container: Container;\n private config: ArcanaJSConfig;\n\n constructor(container: Container, config: ArcanaJSConfig) {\n this.container = container;\n this.config = config;\n }\n\n /**\n * Load and register all configurations in the container\n */\n public async load(): Promise<void> {\n if (this.config.auth) {\n this.container.singleton(\"AuthConfig\", () => this.config.auth);\n }\n\n if (this.config.mail) {\n this.container.singleton(\"MailConfig\", () => this.config.mail);\n }\n\n if (this.config.database) {\n this.container.singleton(\"DatabaseConfig\", () => this.config.database);\n }\n }\n\n /**\n * Get a specific configuration value\n */\n public get<T>(key: keyof ArcanaJSConfig): T | undefined {\n return this.config[key] as T | undefined;\n }\n\n /**\n * Get the full configuration object\n */\n public getAll(): ArcanaJSConfig {\n return this.config;\n }\n}\n","import { Express } from \"express\";\nimport http from \"http\";\n\nexport interface LifecycleHandlers {\n onShutdown: () => Promise<void>;\n}\n\n/**\n * Manages server lifecycle (start, stop, signal handling)\n */\nexport class ServerLifecycle {\n private app: Express;\n private serverInstance?: http.Server;\n private isShuttingDown = false;\n private autoHandleSignals: boolean;\n private handlers: LifecycleHandlers;\n\n private _sigintHandler?: () => void;\n private _sigtermHandler?: () => void;\n\n constructor(\n app: Express,\n autoHandleSignals: boolean,\n handlers: LifecycleHandlers\n ) {\n this.app = app;\n this.autoHandleSignals = autoHandleSignals;\n this.handlers = handlers;\n }\n\n /**\n * Start the HTTP server\n */\n public async start(port: number | string): Promise<void> {\n if (this.serverInstance) {\n console.warn(\n \"Server is already running. Call stop() before starting again.\"\n );\n return;\n }\n\n this.serverInstance = this.app.listen(port, () => {\n console.log(`✓ Server is running on http://localhost:${port}`);\n });\n\n this.setupServerErrorHandler(port);\n\n if (this.autoHandleSignals) {\n this.setupSignalHandlers();\n }\n }\n\n /**\n * Setup server error handler\n */\n private setupServerErrorHandler(port: number | string): void {\n this.serverInstance!.on(\"error\", (error: any) => {\n if (error.code === \"EADDRINUSE\") {\n console.error(`✗ Port ${port} is already in use`);\n process.exit(1);\n } else {\n console.error(\"✗ Server error:\", error);\n }\n });\n }\n\n /**\n * Setup process signal handlers for graceful shutdown\n */\n private setupSignalHandlers(): void {\n const shutdown = async (signal: string) => {\n if (this.isShuttingDown) return;\n this.isShuttingDown = true;\n console.log(`\\n⚠ Received ${signal}, shutting down gracefully...`);\n\n // Force exit after 5s if graceful shutdown hangs (reduced from 10s for dev mode)\n const forceExit = setTimeout(() => {\n console.error(\"✗ Shutdown timed out, forcing exit\");\n process.exit(1);\n }, 5000);\n forceExit.unref();\n\n try {\n await this.stop();\n clearTimeout(forceExit);\n console.log(\"✓ Shutdown complete\");\n process.exit(0);\n } catch (err) {\n clearTimeout(forceExit);\n console.error(\"✗ Error during shutdown:\", err);\n process.exit(1);\n }\n };\n\n this._sigintHandler = () => shutdown(\"SIGINT\");\n this._sigtermHandler = () => shutdown(\"SIGTERM\");\n\n process.on(\"SIGINT\", this._sigintHandler);\n process.on(\"SIGTERM\", this._sigtermHandler);\n\n console.log(\"✓ Signal handlers registered (Ctrl+C to stop)\");\n }\n\n /**\n * Stop the HTTP server\n */\n public async stop(): Promise<void> {\n if (this.isShuttingDown && !this.serverInstance) return;\n this.isShuttingDown = true;\n\n // Close HTTP server\n if (this.serverInstance) {\n console.log(\"⏳ Stopping HTTP server...\");\n await new Promise<void>((resolve, reject) => {\n this.serverInstance!.close((err) => {\n if (err) {\n console.error(\"✗ Error closing HTTP server:\", err);\n return reject(err);\n }\n resolve();\n });\n });\n this.serverInstance = undefined;\n console.log(\"✓ HTTP server stopped\");\n } else {\n console.log(\"ℹ HTTP server is not running\");\n }\n\n // Call shutdown handler for providers, etc.\n await this.handlers.onShutdown();\n\n // Remove signal handlers\n this.removeSignalHandlers();\n }\n\n /**\n * Remove registered signal handlers\n */\n private removeSignalHandlers(): void {\n try {\n if (this._sigintHandler) {\n process.removeListener(\"SIGINT\", this._sigintHandler);\n this._sigintHandler = undefined;\n }\n if (this._sigtermHandler) {\n process.removeListener(\"SIGTERM\", this._sigtermHandler);\n this._sigtermHandler = undefined;\n }\n } catch (err) {\n // Ignore errors while removing listeners\n }\n }\n\n /**\n * Check if server is currently running\n */\n public isRunning(): boolean {\n return !!this.serverInstance;\n }\n\n /**\n * Get the HTTP server instance\n */\n public getServerInstance(): http.Server | undefined {\n return this.serverInstance;\n }\n}\n","import compression from \"compression\";\nimport cookieParser from \"cookie-parser\";\nimport express, { Express, RequestHandler } from \"express\";\nimport helmet from \"helmet\";\nimport path from \"path\";\nimport React from \"react\";\nimport { createArcanaJSMiddleware } from \"../ArcanaJSMiddleware\";\nimport { createCsrfMiddleware } from \"../CsrfMiddleware\";\nimport { createDynamicRouter } from \"../DynamicRouter\";\nimport { responseHandler } from \"../ResponseHandlerMiddleware\";\nimport { ArcanaJSConfig, ResolvedViews } from \"../config/types\";\n\nexport interface MiddlewareConfig {\n staticDir: string;\n distDir: string;\n indexFile: string;\n layout?: React.FC<any>;\n apiBase: string;\n}\n\n/**\n * Manages Express middleware setup and configuration\n */\nexport class MiddlewareManager {\n private app: Express;\n private config: MiddlewareConfig;\n\n constructor(app: Express, config: ArcanaJSConfig) {\n this.app = app;\n this.config = {\n staticDir: config.staticDir || \"public\",\n distDir: config.distDir || \".arcanajs/client\",\n indexFile: config.indexFile || \".arcanajs/client/index.html\",\n layout: config.layout,\n apiBase: config.apiBase || \"/api\",\n };\n }\n\n /**\n * Setup all middleware in the correct order\n */\n public setup(\n views: ResolvedViews,\n routes?: RequestHandler | RequestHandler[],\n apiRoutes?: RequestHandler | RequestHandler[]\n ): void {\n const root = process.cwd();\n\n this.setupNonceGeneration();\n this.setupSecurityHeaders();\n this.setupParsers();\n this.setupStaticFiles(root);\n this.setupCompression();\n this.setupArcanaJSMiddleware(views, root);\n this.mountRoutes(apiRoutes, this.config.apiBase);\n this.mountRoutes(routes);\n this.setupDynamicRouter(views);\n this.setupErrorHandlers();\n }\n\n /**\n * Generate nonce for CSP\n */\n private setupNonceGeneration(): void {\n this.app.use(\n (\n req: express.Request,\n res: express.Response,\n next: express.NextFunction\n ) => {\n const nonce = require(\"crypto\").randomBytes(16).toString(\"base64\");\n res.locals.nonce = nonce;\n next();\n }\n );\n }\n\n /**\n * Setup security headers with Helmet\n */\n private setupSecurityHeaders(): void {\n const isDevelopment = process.env.NODE_ENV === \"development\";\n\n this.app.use(\n helmet({\n contentSecurityPolicy: {\n directives: {\n ...helmet.contentSecurityPolicy.getDefaultDirectives(),\n \"style-src\": [\"'self'\", \"'unsafe-inline'\"],\n \"script-src\": [\n \"'self'\",\n (req, res) => `'nonce-${(res as express.Response).locals.nonce}'`,\n ],\n \"connect-src\": isDevelopment\n ? [\"'self'\", \"ws://localhost:*\", \"wss://localhost:*\"]\n : [\"'self'\"],\n },\n },\n })\n );\n }\n\n /**\n * Setup body parsers and cookie parser\n */\n private setupParsers(): void {\n this.app.use(cookieParser());\n this.app.use(express.json());\n this.app.use(express.urlencoded({ extended: true }));\n this.app.use(createCsrfMiddleware());\n this.app.use(responseHandler);\n }\n\n /**\n * Setup static file serving\n */\n private setupStaticFiles(root: string): void {\n const isProduction = process.env.NODE_ENV === \"production\";\n const staticOptions = { index: false, maxAge: isProduction ? \"1y\" : \"0\" };\n\n const staticPaths = [\n path.resolve(root, this.config.distDir),\n path.resolve(root, this.config.staticDir),\n ].filter((p, i, a) => a.indexOf(p) === i);\n\n for (const p of staticPaths) {\n this.app.use(express.static(p, staticOptions));\n }\n }\n\n /**\n * Setup response compression\n */\n private setupCompression(): void {\n this.app.use(compression());\n }\n\n /**\n * Setup ArcanaJS specific middleware\n */\n private setupArcanaJSMiddleware(views: ResolvedViews, root: string): void {\n this.app.use(\n createArcanaJSMiddleware({\n views,\n indexFile: path.resolve(root, this.config.indexFile),\n layout: this.config.layout,\n })\n );\n }\n\n /**\n * Mount routes (API or web)\n */\n private mountRoutes(\n target: RequestHandler | RequestHandler[] | undefined,\n base?: string\n ): void {\n if (!target) return;\n\n const items = Array.isArray(target) ? target : [target];\n for (const r of items) {\n if (!r) continue;\n try {\n if (typeof (r as any).getRouter === \"function\") {\n this.app.use(base || \"/\", (r as any).getRouter());\n } else {\n this.app.use(base || \"/\", r as RequestHandler);\n }\n if (base) {\n console.log(`API routes mounted at ${base}`);\n }\n } catch (err) {\n console.error(\n `Error mounting routes${base ? ` at ${base}` : \"\"}:`,\n err\n );\n }\n }\n }\n\n /**\n * Setup dynamic router for views\n */\n private setupDynamicRouter(views: ResolvedViews): void {\n this.app.use(createDynamicRouter(views));\n }\n\n /**\n * Setup 404 and error handlers\n */\n private setupErrorHandlers(): void {\n // 404 handler\n this.app.use((req: express.Request, res: express.Response) => {\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n res.status(404).json({\n page: \"NotFoundPage\",\n data: { url: req.url },\n params: {},\n csrfToken: res.locals.csrfToken,\n });\n } else {\n res.status(404).renderPage(\"NotFoundPage\", { url: req.url });\n }\n });\n\n // Error handler\n this.app.use(\n (\n err: any,\n req: express.Request,\n res: express.Response,\n next: express.NextFunction\n ) => {\n console.error(err);\n const message =\n process.env.NODE_ENV === \"production\"\n ? \"Internal Server Error\"\n : err.message;\n\n if (req.get(\"X-ArcanaJS-Request\") || req.query.format === \"json\") {\n res.status(500).json({\n page: \"ErrorPage\",\n data: { message },\n params: {},\n csrfToken: res.locals.csrfToken,\n });\n } else {\n res.status(500).renderPage(\"ErrorPage\", { message });\n }\n }\n );\n }\n}\n","import {\n AutoRegisterConfig,\n AutoRegisterProvider,\n} from \"../../di/providers/AutoRegisterProvider\";\nimport { ServiceProvider } from \"../ServiceProvider\";\nimport { ArcanaJSConfig } from \"../config/types\";\n\n/**\n * Manages service providers lifecycle (registration, boot, shutdown)\n */\nexport class ProviderManager {\n private providers: ServiceProvider[] = [];\n private app: any;\n private config: ArcanaJSConfig;\n\n constructor(app: any, config: ArcanaJSConfig) {\n this.app = app;\n this.config = config;\n }\n\n /**\n * Register all service providers\n */\n public async register(): Promise<void> {\n // Auto-discovery provider\n if (this.config.autoDiscovery && this.config.autoDiscovery.enabled) {\n await this.registerAutoDiscoveryProvider();\n }\n\n // Custom providers\n if (this.config.providers) {\n await this.registerCustomProviders();\n }\n }\n\n /**\n * Register auto-discovery provider with ArcanaJS structure\n */\n private async registerAutoDiscoveryProvider(): Promise<void> {\n const directories = [\n \"src/app/Http/Controllers\",\n \"src/app/Services\",\n \"src/app/Repositories\",\n ];\n\n const config: AutoRegisterConfig = {\n ...this.config.autoDiscovery!,\n directories,\n };\n\n const provider = new AutoRegisterProvider(this.app, config);\n await provider.register();\n this.providers.push(provider);\n }\n\n /**\n * Register custom service providers\n */\n private async registerCustomProviders(): Promise<void> {\n for (const ProviderClass of this.config.providers!) {\n const provider = new ProviderClass(this.app);\n await provider.register();\n this.providers.push(provider);\n }\n }\n\n /**\n * Boot all registered providers\n */\n public async boot(): Promise<void> {\n for (const provider of this.providers) {\n await provider.boot();\n }\n }\n\n /**\n * Shutdown all providers gracefully\n */\n public async shutdown(): Promise<void> {\n if (this.providers.length === 0) return;\n\n console.log(\"⏳ Shutting down providers...\");\n for (const provider of this.providers) {\n if (provider.shutdown) {\n try {\n await provider.shutdown();\n console.log(`✓ ${provider.constructor.name} shut down`);\n } catch (err) {\n console.error(\n `✗ Error shutting down provider ${provider.constructor.name}:`,\n err\n );\n }\n }\n }\n }\n\n /**\n * Get all registered providers\n */\n public getProviders(): ServiceProvider[] {\n return this.providers;\n }\n}\n","import fs from \"fs\";\nimport path from \"path\";\nimport React from \"react\";\nimport { ModuleLoader } from \"../../../utils/ModuleLoader\";\nimport ErrorPage from \"../../shared/views/ErrorPage\";\nimport NotFoundPage from \"../../shared/views/NotFoundPage\";\nimport { ArcanaJSConfig, ResolvedViews } from \"../config/types\";\n\n/**\n * Resolves and loads view components from various sources\n */\nexport class ViewsResolver {\n private config: ArcanaJSConfig;\n\n constructor(config: ArcanaJSConfig) {\n this.config = config;\n }\n\n /**\n * Resolve views from all possible sources in priority order\n */\n public resolve(): ResolvedViews {\n let resolvedViews = this.config.views;\n\n // Try loading from context\n if (!resolvedViews && this.config.viewsContext) {\n resolvedViews = this.loadFromContext(this.config.viewsContext);\n }\n\n // Try loading from alias\n if (!resolvedViews) {\n resolvedViews = this.loadFromAlias();\n }\n\n // Try discovering views\n if (!resolvedViews) {\n resolvedViews = this.discoverViews();\n }\n\n // Warn if no views found\n if (!resolvedViews || Object.keys(resolvedViews).length === 0) {\n console.warn(\"No views found. Please check your views directory.\");\n resolvedViews = {} as Record<string, React.FC<any>>;\n }\n\n // Add default pages\n return {\n ...resolvedViews,\n NotFoundPage: resolvedViews.NotFoundPage || NotFoundPage,\n ErrorPage: resolvedViews.ErrorPage || ErrorPage,\n } as ResolvedViews;\n }\n\n /**\n * Load views from a webpack context\n */\n private loadFromContext(context: any): Record<string, React.FC<any>> {\n const views: Record<string, React.FC<any>> = {};\n context.keys().forEach((key: string) => {\n const viewName = key.replace(/^\\.\\/(.*)\\.tsx$/, \"$1\");\n views[viewName] = context(key).default;\n });\n return views;\n }\n\n /**\n * Load views from webpack alias\n */\n private loadFromAlias(): Record<string, React.FC<any>> | undefined {\n try {\n // @ts-ignore - This alias is injected by Webpack\n const injectedViews = require(\"arcanajs-views\");\n if (injectedViews) {\n return this.loadFromContext(injectedViews);\n }\n } catch (e) {\n // Alias not available\n }\n return undefined;\n }\n\n /**\n * Discover views by scanning the views directory\n */\n private discoverViews(): Record<string, React.FC<any>> {\n const views: Record<string, React.FC<any>> = {};\n const viewsDir = this.config.viewsDir\n ? path.resolve(process.cwd(), this.config.viewsDir)\n : path.resolve(process.cwd(), \"src/resources/views\");\n\n if (!fs.existsSync(viewsDir)) {\n return views;\n }\n\n this.traverseDirectory(viewsDir, viewsDir, views);\n return views;\n }\n\n /**\n * Recursively traverse a directory to find view files\n */\n private traverseDirectory(\n dir: string,\n baseDir: string,\n views: Record<string, React.FC<any>>\n ): void {\n const files = fs.readdirSync(dir);\n\n files.forEach((file) => {\n const fullPath = path.join(dir, file);\n const stat = fs.statSync(fullPath);\n\n if (stat.isDirectory()) {\n this.traverseDirectory(fullPath, baseDir, views);\n } else if (file.endsWith(\".tsx\") || file.endsWith(\".jsx\")) {\n this.loadViewFile(fullPath, baseDir, views);\n }\n });\n }\n\n /**\n * Load a single view file\n */\n private loadViewFile(\n fullPath: string,\n baseDir: string,\n views: Record<string, React.FC<any>>\n ): void {\n const relativePath = path.relative(baseDir, fullPath);\n const viewName = relativePath.replace(/\\.(tsx|jsx)$/, \"\");\n\n try {\n // Register ts-node if needed for TypeScript files\n if (fullPath.endsWith(\".tsx\") || fullPath.endsWith(\".ts\")) {\n ModuleLoader.registerTsNode();\n }\n\n const pageModule = ModuleLoader.require(fullPath);\n views[viewName] = pageModule.default || pageModule;\n } catch (error) {\n console.error(`Failed to load view ${viewName}:`, error);\n }\n }\n}\n","import React from \"react\";\n\n/**\n * BodyProps - Props for the Body component\n */\nexport interface BodyProps {\n /** Body content */\n children: React.ReactNode;\n /** Additional CSS class for the body wrapper */\n className?: string;\n /** Body ID for styling/testing */\n id?: string;\n /** Inline styles */\n style?: React.CSSProperties;\n /** Reference to the body element */\n ref?: React.Ref<HTMLDivElement>;\n}\n\n/**\n * Body - Page content wrapper component for ArcanaJS\n *\n * Use this component to wrap your page content. It provides semantic\n * structure and separation from the Head component.\n *\n * ## Why Use Body?\n *\n * 1. **Semantic Structure** - Clearly separates meta (Head) from content (Body)\n * 2. **Styling Hook** - Easy to apply global page styles\n * 3. **Layout Support** - Works with layouts for consistent page structure\n * 4. **SSR-Ready** - Consistent rendering between server and client\n *\n * @example\n * ```tsx\n * // Basic usage with Page and Head\n * import { Page, Head, Body } from 'arcanajs/client';\n *\n * export default function HomePage() {\n * return (\n * <Page>\n * <Head>\n * <title>Home</title>\n * </Head>\n * <Body>\n * <header>...</header>\n * <main>...</main>\n * <footer>...</footer>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With styling\n * import { Page, Body } from 'arcanajs/client';\n *\n * export default function DarkPage() {\n * return (\n * <Page title=\"Dark Mode\">\n * <Body className=\"bg-gray-900 text-white min-h-screen\">\n * <div className=\"container mx-auto py-8\">\n * <h1>Welcome to the dark side</h1>\n * </div>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Full page structure\n * import { Page, Head, Body, usePage, Link } from 'arcanajs/client';\n *\n * interface PageData {\n * posts: Array<{ id: string; title: string }>;\n * }\n *\n * export default function BlogPage() {\n * const { posts } = usePage<PageData>();\n *\n * return (\n * <Page>\n * <Head>\n * <title>Blog</title>\n * <meta name=\"description\" content=\"Latest articles\" />\n * </Head>\n * <Body className=\"min-h-screen flex flex-col\">\n * <header className=\"border-b p-4\">\n * <nav>\n * <Link href=\"/\">Home</Link>\n * <Link href=\"/blog\">Blog</Link>\n * </nav>\n * </header>\n *\n * <main className=\"flex-1 p-4\">\n * <h1>Latest Posts</h1>\n * <ul>\n * {posts.map(post => (\n * <li key={post.id}>\n * <Link href={`/blog/${post.id}`}>{post.title}</Link>\n * </li>\n * ))}\n * </ul>\n * </main>\n *\n * <footer className=\"border-t p-4 text-center\">\n * © 2025 My Blog\n * </footer>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n */\nconst Body = React.forwardRef<HTMLDivElement, BodyProps>(\n ({ children, className, id, style }, ref) => {\n return (\n <div\n ref={ref}\n className={className}\n id={id}\n style={style}\n data-arcanajs-body\n >\n {children}\n </div>\n );\n }\n);\n\nBody.displayName = \"Body\";\n\nexport default Body;\n","import React, { useEffect, useRef } from \"react\";\nimport { useHead } from \"../hooks/useHead\";\n\n/**\n * HeadProps - Props for the Head component\n */\nexport interface HeadProps {\n /** Child elements (title, meta, link, script, style) */\n children: React.ReactNode;\n}\n\n/**\n * Common meta tag definitions for convenience\n */\nexport interface MetaDefinition {\n /** Standard name attribute */\n name?: string;\n /** Open Graph / Twitter property */\n property?: string;\n /** HTTP equiv */\n httpEquiv?: string;\n /** Content value */\n content: string;\n /** Charset (for charset meta) */\n charset?: string;\n}\n\n/**\n * Head - Document head management component for ArcanaJS\n *\n * Use this component to manage document head elements like title,\n * meta tags, links, and scripts. Works seamlessly with SSR.\n *\n * ## Supported Elements\n *\n * - `<title>` - Page title\n * - `<meta>` - Meta tags (SEO, Open Graph, Twitter)\n * - `<link>` - Stylesheets, preload, canonical\n * - `<script>` - External scripts, JSON-LD\n * - `<style>` - Inline styles (use sparingly)\n *\n * @example\n * ```tsx\n * // Basic SEO tags\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <title>My Awesome Page</title>\n * <meta name=\"description\" content=\"Page description for SEO\" />\n * <meta name=\"keywords\" content=\"react, arcanajs, framework\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // Social media / Open Graph\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <title>Share This!</title>\n * <meta property=\"og:title\" content=\"Share This!\" />\n * <meta property=\"og:description\" content=\"Check out this page\" />\n * <meta property=\"og:image\" content=\"https://example.com/og.jpg\" />\n * <meta property=\"og:url\" content=\"https://example.com/page\" />\n * <meta name=\"twitter:card\" content=\"summary_large_image\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // Preloading resources\n * import { Head } from 'arcanajs/client';\n *\n * <Head>\n * <link rel=\"preload\" href=\"/fonts/Inter.woff2\" as=\"font\" crossOrigin=\"\" />\n * <link rel=\"preconnect\" href=\"https://api.example.com\" />\n * <link rel=\"canonical\" href=\"https://example.com/page\" />\n * </Head>\n * ```\n *\n * @example\n * ```tsx\n * // JSON-LD structured data\n * import { Head } from 'arcanajs/client';\n *\n * const structuredData = {\n * \"@context\": \"https://schema.org\",\n * \"@type\": \"Article\",\n * \"headline\": \"My Article\",\n * };\n *\n * <Head>\n * <script\n * type=\"application/ld+json\"\n * dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }}\n * />\n * </Head>\n * ```\n */\nconst Head: React.FC<HeadProps> = ({ children }) => {\n const headManager = useHead();\n const processedRef = useRef(false);\n\n // Server-side: Push tags to context\n if (typeof window === \"undefined\" && headManager && !processedRef.current) {\n processedRef.current = true;\n React.Children.forEach(children, (child) => {\n if (React.isValidElement(child)) {\n headManager.push(\n React.cloneElement(child as React.ReactElement<any>, {\n \"data-arcanajs-head\": \"true\",\n })\n );\n }\n });\n }\n\n // Client-side: Update DOM\n useEffect(() => {\n const managedElements: HTMLElement[] = [];\n\n React.Children.forEach(children, (child) => {\n if (!React.isValidElement(child)) return;\n\n const reactElement = child as React.ReactElement<any>;\n const tagType = reactElement.type;\n\n // Handle title\n if (tagType === \"title\") {\n const newTitle = reactElement.props.children;\n if (typeof newTitle === \"string\") {\n document.title = newTitle;\n }\n return;\n }\n\n // Handle meta tags\n if (tagType === \"meta\") {\n const props = reactElement.props;\n const element = createOrUpdateElement(\"meta\", props, {\n identifiers: [\"name\", \"property\", \"http-equiv\", \"charset\"],\n });\n if (element) managedElements.push(element);\n return;\n }\n\n // Handle link tags\n if (tagType === \"link\") {\n const props = reactElement.props;\n const element = createOrUpdateElement(\"link\", props, {\n identifiers: [\"rel\", \"href\"],\n });\n if (element) managedElements.push(element);\n return;\n }\n\n // Handle script tags\n if (tagType === \"script\") {\n const props = reactElement.props;\n const script = document.createElement(\"script\");\n\n Object.keys(props).forEach((key) => {\n if (key === \"dangerouslySetInnerHTML\") {\n script.innerHTML = props[key].__html;\n } else if (key === \"children\") {\n script.innerHTML = typeof props[key] === \"string\" ? props[key] : \"\";\n } else if (key !== \"key\" && key !== \"ref\") {\n script.setAttribute(\n key === \"className\" ? \"class\" : key,\n props[key]\n );\n }\n });\n\n script.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(script);\n managedElements.push(script);\n return;\n }\n\n // Handle style tags\n if (tagType === \"style\") {\n const props = reactElement.props;\n const style = document.createElement(\"style\");\n\n if (props.dangerouslySetInnerHTML) {\n style.innerHTML = props.dangerouslySetInnerHTML.__html;\n } else if (props.children) {\n style.innerHTML =\n typeof props.children === \"string\" ? props.children : \"\";\n }\n\n style.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(style);\n managedElements.push(style);\n return;\n }\n });\n\n return () => {\n // Cleanup managed elements on unmount\n managedElements.forEach((el) => {\n if (el.parentNode) {\n el.remove();\n }\n });\n };\n }, [children]);\n\n return null;\n};\n\n/**\n * Helper to create or update head elements\n */\nfunction createOrUpdateElement(\n tagName: string,\n props: Record<string, any>,\n options: { identifiers: string[] }\n): HTMLElement | null {\n let selector = tagName;\n let hasIdentifier = false;\n\n // Build selector from identifiers\n for (const id of options.identifiers) {\n const propName = id === \"http-equiv\" ? \"httpEquiv\" : id;\n if (props[propName]) {\n selector += `[${id}=\"${props[propName]}\"]`;\n hasIdentifier = true;\n }\n }\n\n if (!hasIdentifier && tagName !== \"link\") {\n return null; // Skip elements without identifiers (except links which can be unique by href)\n }\n\n // Try to find existing element\n let element =\n document.querySelector(selector + '[data-arcanajs-head=\"true\"]') ||\n document.querySelector(selector);\n\n if (element) {\n // Update existing element\n Object.keys(props).forEach((key) => {\n if (key !== \"key\" && key !== \"ref\" && key !== \"children\") {\n const attrName = key === \"className\" ? \"class\" : key;\n element!.setAttribute(attrName, props[key]);\n }\n });\n element.setAttribute(\"data-arcanajs-head\", \"true\");\n } else {\n // Create new element\n element = document.createElement(tagName);\n Object.keys(props).forEach((key) => {\n if (key !== \"key\" && key !== \"ref\" && key !== \"children\") {\n const attrName = key === \"className\" ? \"class\" : key;\n element!.setAttribute(attrName, props[key]);\n }\n });\n element.setAttribute(\"data-arcanajs-head\", \"true\");\n document.head.appendChild(element);\n }\n\n return element as HTMLElement;\n}\n\nexport default Head;\n","import React, { useCallback, useEffect, useRef } from \"react\";\nimport useRouter from \"../hooks/useRouter\";\n\n/**\n * Prefetch strategy for Link component\n */\nexport type PrefetchStrategy = \"hover\" | \"visible\" | \"mount\" | false;\n\nexport interface LinkProps\n extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n href: string;\n /**\n * Prefetch strategy:\n * - 'hover': Prefetch on mouse hover (default when prefetch=true)\n * - 'visible': Prefetch when link enters viewport (Intersection Observer)\n * - 'mount': Prefetch immediately on component mount\n * - false: Disable prefetching\n */\n prefetch?: boolean | PrefetchStrategy;\n /** Replace current history entry instead of pushing */\n replace?: boolean;\n /** Scroll to top after navigation (default: true) */\n scroll?: boolean;\n /** State to pass through navigation */\n state?: any;\n /**\n * Shallow navigation - update URL without re-fetching data\n * Useful for updating query params without full navigation\n */\n shallow?: boolean;\n /**\n * Active class name when this link matches current URL\n * If provided, adds this class when link is active\n */\n activeClassName?: string;\n /**\n * Require exact match for active class (default: true)\n * If false, matches if current URL starts with href\n */\n exact?: boolean;\n}\n\n/**\n * Link - Professional navigation link component\n *\n * Features:\n * - Client-side navigation with ArcanaJS router\n * - Smart prefetching with multiple strategies (hover, visible, mount)\n * - Intersection Observer for viewport-based prefetching\n * - External link detection and handling\n * - Async/await navigation support\n * - Active link styling support\n * - State passing through navigation\n * - Shallow navigation for query updates\n *\n * @example\n * ```tsx\n * // Basic usage\n * <Link href=\"/about\">About</Link>\n *\n * // Prefetch on hover (default when prefetch=true)\n * <Link href=\"/products\" prefetch>Products</Link>\n *\n * // Prefetch when visible in viewport\n * <Link href=\"/blog\" prefetch=\"visible\">Blog</Link>\n *\n * // With replace instead of push\n * <Link href=\"/login\" replace>Login</Link>\n *\n * // Pass state through navigation\n * <Link href=\"/checkout\" state={{ from: 'cart' }}>Checkout</Link>\n *\n * // Active link styling\n * <Link href=\"/dashboard\" activeClassName=\"is-active\">Dashboard</Link>\n *\n * // Shallow navigation (for query params)\n * <Link href=\"/products?sort=price\" shallow>Sort by Price</Link>\n * ```\n */\nconst Link: React.FC<LinkProps> = ({\n href,\n children,\n prefetch = false,\n replace = false,\n scroll = true,\n state,\n shallow = false,\n activeClassName,\n exact = true,\n className = \"\",\n onClick,\n onMouseEnter,\n ...props\n}) => {\n const router = useRouter();\n const {\n push,\n replace: routerReplace,\n prefetch: prefetchRoute,\n currentUrl,\n isNavigating,\n } = router;\n const linkRef = useRef<HTMLAnchorElement>(null);\n const prefetchedRef = useRef(false);\n\n const isExternal = /^https?:\\/\\//.test(href);\n\n // Determine if link is active\n const isActive =\n !isExternal &&\n (exact\n ? currentUrl === href || currentUrl === href.split(\"?\")[0]\n : currentUrl.startsWith(href.split(\"?\")[0]));\n\n // Combine classNames\n const combinedClassName = [className, isActive && activeClassName]\n .filter(Boolean)\n .join(\" \");\n\n // Determine prefetch strategy\n const prefetchStrategy: PrefetchStrategy =\n prefetch === true ? \"hover\" : prefetch === false ? false : prefetch;\n\n // Prefetch handler\n const doPrefetch = useCallback(() => {\n if (prefetchedRef.current || isExternal || !prefetchRoute) return;\n prefetchedRef.current = true;\n prefetchRoute(href).catch(() => {\n prefetchedRef.current = false;\n });\n }, [href, isExternal, prefetchRoute]);\n\n // Intersection Observer for 'visible' strategy\n useEffect(() => {\n if (prefetchStrategy !== \"visible\" || typeof window === \"undefined\") return;\n\n const element = linkRef.current;\n if (!element) return;\n\n if (!(\"IntersectionObserver\" in window)) {\n const timeoutId = setTimeout(doPrefetch, 1000);\n return () => clearTimeout(timeoutId);\n }\n\n const observer = new IntersectionObserver(\n (entries) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n doPrefetch();\n observer.disconnect();\n }\n });\n },\n {\n root: null,\n rootMargin: \"100px\",\n threshold: 0,\n }\n );\n\n observer.observe(element);\n\n return () => {\n observer.disconnect();\n };\n }, [prefetchStrategy, doPrefetch]);\n\n // Mount prefetch for 'mount' strategy\n useEffect(() => {\n if (prefetchStrategy !== \"mount\" || typeof window === \"undefined\") return;\n\n const timeoutId = setTimeout(doPrefetch, 100);\n return () => clearTimeout(timeoutId);\n }, [prefetchStrategy, doPrefetch]);\n\n const handleClick = async (e: React.MouseEvent<HTMLAnchorElement>) => {\n onClick?.(e);\n\n // Don't handle if default prevented or modifier keys pressed\n if (\n e.defaultPrevented ||\n e.metaKey ||\n e.ctrlKey ||\n e.shiftKey ||\n e.altKey\n ) {\n return;\n }\n\n e.preventDefault();\n\n if (isExternal) {\n window.open(href, \"_blank\", \"noopener,noreferrer\");\n } else {\n const options = { scroll, state, shallow };\n\n if (replace) {\n routerReplace(href, options);\n } else {\n push(href, options);\n }\n }\n };\n\n const handleMouseEnter = (e: React.MouseEvent<HTMLAnchorElement>) => {\n onMouseEnter?.(e);\n\n if (prefetchStrategy === \"hover\" && !isExternal) {\n doPrefetch();\n }\n };\n\n return (\n <a\n ref={linkRef}\n href={href}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n target={isExternal ? \"_blank\" : undefined}\n rel={isExternal ? \"noopener noreferrer\" : undefined}\n className={combinedClassName || undefined}\n aria-current={isActive ? \"page\" : undefined}\n {...props}\n >\n {children}\n </a>\n );\n};\n\nexport default Link;\n","import React from \"react\";\nimport Head from \"./Head\";\n\n/**\n * PageProps - Props for the Page component\n */\nexport interface PageProps {\n /** Page content */\n children: React.ReactNode;\n /** Page title (shorthand for <Head><title>...</title></Head>) */\n title?: string;\n /** Page description (shorthand for meta description) */\n description?: string;\n /** Open Graph image URL */\n ogImage?: string;\n /** Canonical URL */\n canonical?: string;\n /** Additional CSS class for the page wrapper */\n className?: string;\n /** Page ID for styling/testing */\n id?: string;\n}\n\n/**\n * Page - Developer-facing page wrapper component for ArcanaJS\n *\n * Use this component as the root of your page views. It provides a clean\n * structure for organizing page meta tags and content.\n *\n * ## Page Structure\n *\n * ArcanaJS pages follow a simple pattern:\n * - `<Page>` - Root wrapper (this component)\n * - `<Head>` - Meta tags, title, links\n * - `<Body>` - Page content\n *\n * @example\n * ```tsx\n * // Basic usage\n * import { Page, Head, Body } from 'arcanajs/client';\n *\n * export default function HomePage() {\n * return (\n * <Page>\n * <Head>\n * <title>My Page</title>\n * <meta name=\"description\" content=\"Page description\" />\n * </Head>\n * <Body>\n * <h1>Welcome!</h1>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With shorthand props\n * import { Page, Body } from 'arcanajs/client';\n *\n * export default function AboutPage() {\n * return (\n * <Page\n * title=\"About Us\"\n * description=\"Learn more about our company\"\n * ogImage=\"/images/about-og.jpg\"\n * >\n * <Body>\n * <h1>About Us</h1>\n * <p>Our story...</p>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // With usePage hook for server data\n * import { Page, Head, Body, usePage } from 'arcanajs/client';\n *\n * interface PageData {\n * user: { name: string };\n * }\n *\n * export default function ProfilePage() {\n * const { user } = usePage<PageData>();\n *\n * return (\n * <Page title={`${user.name}'s Profile`}>\n * <Body>\n * <h1>{user.name}</h1>\n * </Body>\n * </Page>\n * );\n * }\n * ```\n */\nconst Page: React.FC<PageProps> = ({\n children,\n title,\n description,\n ogImage,\n canonical,\n className,\n id,\n}) => {\n // Check if Head is provided in children, if not and we have meta props, create one\n const hasHeadProps = !!(title || description || ogImage || canonical);\n\n return (\n <div className={className} id={id} data-arcanajs-page>\n {hasHeadProps && (\n <Head>\n {title && <title>{title}</title>}\n {description && <meta name=\"description\" content={description} />}\n {ogImage && <meta property=\"og:image\" content={ogImage} />}\n {canonical && <link rel=\"canonical\" href={canonical} />}\n </Head>\n )}\n {children}\n </div>\n );\n};\n\nexport default Page;\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\nexport interface HeadManager {\n tags: React.ReactNode[];\n push: (tags: React.ReactNode) => void;\n}\n\nexport const HeadContext = createSingletonContext<HeadManager | null>(\n \"HeadContext\",\n null\n);\n","import { createSingletonContext } from \"../utils/createSingletonContext\";\n\n// PageContext holds the page data (may be null before hydration).\nexport const PageContext = createSingletonContext<any | null>(\n \"PageContext\",\n null\n);\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Request context data structure\n * Contains SSR-specific information from the incoming request\n */\nexport interface RequestContextType {\n /** Request headers */\n headers: Record<string, string | undefined>;\n /** Request cookies */\n cookies: Record<string, string | undefined>;\n /** Request URL */\n url: string;\n /** Request path */\n path: string;\n /** Query parameters */\n query: Record<string, string | string[] | undefined>;\n /** Request method */\n method: string;\n /** Client IP address */\n ip?: string;\n /** User agent */\n userAgent?: string;\n /** Whether this is an SSR request */\n isSSR: boolean;\n}\n\n/**\n * Default request context (client-side)\n */\nconst defaultRequestContext: RequestContextType = {\n headers: {},\n cookies: {},\n url: typeof window !== \"undefined\" ? window.location.href : \"\",\n path: typeof window !== \"undefined\" ? window.location.pathname : \"\",\n query: {},\n method: \"GET\",\n isSSR: false,\n};\n\n/**\n * Request context for SSR\n */\nexport const RequestContext = createSingletonContext<RequestContextType | null>(\n \"RequestContext\",\n null\n);\n\n/**\n * Request context provider for SSR\n */\nexport const RequestContextProvider: React.FC<{\n value: RequestContextType;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return (\n <RequestContext.Provider value={value}>{children}</RequestContext.Provider>\n );\n};\n\n/**\n * Create request context from Express request\n */\nexport function createRequestContext(\n req: any // Express Request\n): RequestContextType {\n const headers: Record<string, string | undefined> = {};\n\n // Copy headers (lowercase keys)\n if (req.headers) {\n for (const [key, value] of Object.entries(req.headers)) {\n headers[key.toLowerCase()] = Array.isArray(value)\n ? value.join(\", \")\n : (value as string);\n }\n }\n\n // Parse cookies\n const cookies: Record<string, string | undefined> = {};\n if (req.cookies) {\n Object.assign(cookies, req.cookies);\n } else if (headers.cookie) {\n // Parse cookie header manually\n headers.cookie.split(\";\").forEach((cookie) => {\n const [key, ...valueParts] = cookie.trim().split(\"=\");\n if (key) {\n cookies[key] = valueParts.join(\"=\");\n }\n });\n }\n\n // Parse query\n const query: Record<string, string | string[] | undefined> = {};\n if (req.query) {\n Object.assign(query, req.query);\n }\n\n return {\n headers,\n cookies,\n url: req.url || req.originalUrl || \"\",\n path: req.path || \"\",\n query,\n method: req.method || \"GET\",\n ip: req.ip || req.headers?.[\"x-forwarded-for\"] || req.socket?.remoteAddress,\n userAgent: headers[\"user-agent\"],\n isSSR: true,\n };\n}\n\n/**\n * Get request context on client (returns default values)\n */\nexport function getClientRequestContext(): RequestContextType {\n if (typeof window === \"undefined\") {\n return defaultRequestContext;\n }\n\n // Parse cookies from document.cookie\n const cookies: Record<string, string | undefined> = {};\n document.cookie.split(\";\").forEach((cookie) => {\n const [key, ...valueParts] = cookie.trim().split(\"=\");\n if (key) {\n try {\n cookies[key] = decodeURIComponent(valueParts.join(\"=\"));\n } catch {\n cookies[key] = valueParts.join(\"=\");\n }\n }\n });\n\n // Parse query from URL\n const query: Record<string, string | string[] | undefined> = {};\n const searchParams = new URLSearchParams(window.location.search);\n searchParams.forEach((value, key) => {\n const existing = query[key];\n if (existing === undefined) {\n query[key] = value;\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n query[key] = [existing, value];\n }\n });\n\n return {\n headers: {\n \"user-agent\": navigator.userAgent,\n },\n cookies,\n url: window.location.href,\n path: window.location.pathname,\n query,\n method: \"GET\",\n userAgent: navigator.userAgent,\n isSSR: false,\n };\n}\n","import React from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Navigation options for programmatic navigation\n */\nexport interface NavigateOptions {\n /** Replace current history entry instead of pushing */\n replace?: boolean;\n /** State to pass to the destination */\n state?: any;\n /** Scroll to top after navigation (default: true) */\n scroll?: boolean;\n /** Shallow navigation - update URL without re-fetching data */\n shallow?: boolean;\n}\n\n/**\n * Router context type with full navigation capabilities\n */\nexport interface RouterContextType {\n // ============================================================================\n // Navigation Methods\n // ============================================================================\n\n /** Navigate to a URL (fire-and-forget) */\n navigateTo: (url: string, options?: NavigateOptions) => void;\n\n /** Navigate to a URL (returns promise) */\n navigateToAsync?: (url: string, options?: NavigateOptions) => Promise<void>;\n\n /** Navigate using push (alias for navigateTo) */\n push: (url: string, options?: NavigateOptions) => void;\n\n /** Replace current history entry with new URL */\n replace: (url: string, options?: NavigateOptions) => void;\n\n /** Go back in history */\n back: () => void;\n\n /** Go forward in history */\n forward: () => void;\n\n /** Refresh current page data */\n refresh: () => Promise<void>;\n\n /** Prefetch a route for faster navigation */\n prefetchRoute?: (url: string) => Promise<void>;\n\n // ============================================================================\n // Current Route State\n // ============================================================================\n\n /** Current page name */\n currentPage: string;\n\n /** Current URL path */\n currentUrl: string;\n\n /** Alias for currentUrl */\n pathname: string;\n\n /** Route parameters (dynamic segments) */\n params: Record<string, string>;\n\n /** Parsed query string parameters */\n query: Record<string, string | string[]>;\n\n /** Navigation state passed via options */\n state?: any;\n\n // ============================================================================\n // Authentication & Security\n // ============================================================================\n\n /** CSRF token for form submissions */\n csrfToken?: string;\n\n // ============================================================================\n // Navigation Events & State\n // ============================================================================\n\n /** Whether navigation is in progress */\n isNavigating: boolean;\n\n /** Callback when navigation completes */\n onNavigate?: (url: string) => void;\n\n /** Previous URL before navigation */\n previousUrl?: string;\n}\n\nexport const RouterContext = createSingletonContext<RouterContextType | null>(\n \"RouterContext\",\n null\n);\n\nexport const RouterProvider: React.FC<{\n value: RouterContextType;\n children: React.ReactNode;\n}> = ({ value, children }) => {\n return (\n <RouterContext.Provider value={value}>{children}</RouterContext.Provider>\n );\n};\n\n/**\n * Parse query string into object\n */\nexport function parseQueryString(\n search: string\n): Record<string, string | string[]> {\n const query: Record<string, string | string[]> = {};\n\n if (typeof window === \"undefined\") return query;\n\n const params = new URLSearchParams(search);\n params.forEach((value, key) => {\n const existing = query[key];\n if (existing === undefined) {\n query[key] = value;\n } else if (Array.isArray(existing)) {\n existing.push(value);\n } else {\n query[key] = [existing, value];\n }\n });\n\n return query;\n}\n\n/**\n * Serialize query object to string\n */\nexport function serializeQueryString(\n query: Record<string, string | string[] | undefined>\n): string {\n const params = new URLSearchParams();\n\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n value.forEach((v) => params.append(key, v));\n } else {\n params.set(key, value);\n }\n }\n\n const str = params.toString();\n return str ? `?${str}` : \"\";\n}\n","import React, {\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport {\n NavigateOptions,\n parseQueryString,\n RouterProvider,\n} from \"../context/RouterContext\";\nimport { isRedirectError, setClientNavigate } from \"../utils/redirect\";\nimport PageProvider from \"./PageProvider\";\n\n/**\n * Scroll restoration behavior\n */\nexport type ScrollRestoration = \"auto\" | \"manual\" | \"none\";\n\n/**\n * Navigation guard callback\n * Return false to prevent navigation\n */\nexport type BeforeNavigateCallback = (\n to: string,\n from: string\n) => boolean | Promise<boolean>;\n\n/**\n * After navigation callback\n */\nexport type AfterNavigateCallback = (to: string, from: string) => void;\n\nexport interface ArcanaJSAppProps<\n TData = any,\n TParams extends Record<string, string> = Record<string, string>\n> {\n initialPage: string;\n initialData: TData;\n initialParams?: TParams;\n initialUrl?: string;\n csrfToken?: string;\n views: Record<\n string,\n React.ComponentType<{\n data: TData;\n navigateTo: (url: string) => Promise<void>;\n params: TParams;\n }>\n >;\n layout?: React.FC<{ children: React.ReactNode }>;\n onNavigate?: (url: string) => void;\n /** Maximum number of entries to keep in the navigation cache */\n cacheLimit?: number;\n\n // ============================================================================\n // New Pro Features\n // ============================================================================\n\n /**\n * Scroll restoration behavior\n * - 'auto': Restore scroll position on back/forward, scroll to top on new navigation\n * - 'manual': User controls scroll behavior\n * - 'none': No automatic scroll handling\n */\n scrollRestoration?: ScrollRestoration;\n\n /**\n * Navigation guard - called before navigation\n * Return false to prevent navigation\n */\n beforeNavigate?: BeforeNavigateCallback;\n\n /**\n * Callback after navigation completes\n */\n afterNavigate?: AfterNavigateCallback;\n}\n\nexport const ArcanaJSApp = <\n TData = any,\n TParams extends Record<string, string> = Record<string, string>\n>(\n props: ArcanaJSAppProps<TData, TParams>\n) => {\n const {\n initialPage,\n initialData,\n initialParams = {} as TParams,\n initialUrl,\n csrfToken,\n views,\n layout: Layout,\n onNavigate,\n cacheLimit = 50,\n scrollRestoration = \"auto\",\n beforeNavigate,\n afterNavigate,\n } = props;\n\n const [page, setPage] = useState<string>(initialPage);\n const [data, setData] = useState<TData>(initialData);\n const [params, setParams] = useState<TParams>(initialParams);\n const [url, setUrl] = useState<string>(\n initialUrl ||\n (typeof window !== \"undefined\" ? window.location.pathname : \"/\")\n );\n const [isNavigating, setIsNavigating] = useState(false);\n const [navigationState, setNavigationState] = useState<any>(undefined);\n const [previousUrl, setPreviousUrl] = useState<string | undefined>(undefined);\n\n // Navigation cache to store previously visited pages (LRU via Map ordering)\n const navigationCache = useRef(\n new Map<string, { page: string; data: TData; params: TParams }>()\n );\n\n // Scroll position storage for scroll restoration\n const scrollPositions = useRef(new Map<string, { x: number; y: number }>());\n\n // Track prefetch in-flight to avoid duplicate requests\n const prefetchInFlight = useRef(new Set<string>());\n\n // Abort controller for in-flight navigation fetch\n const currentAbort = useRef<AbortController | null>(null);\n\n // Save scroll position before navigation\n const saveScrollPosition = useCallback(() => {\n if (typeof window !== \"undefined\" && scrollRestoration !== \"none\") {\n scrollPositions.current.set(url, {\n x: window.scrollX,\n y: window.scrollY,\n });\n }\n }, [url, scrollRestoration]);\n\n // Restore scroll position or scroll to top\n const handleScroll = useCallback(\n (targetUrl: string, isRestore: boolean, options?: NavigateOptions) => {\n if (typeof window === \"undefined\" || scrollRestoration === \"none\") return;\n if (options?.scroll === false) return;\n\n setTimeout(() => {\n if (isRestore && scrollRestoration === \"auto\") {\n const saved = scrollPositions.current.get(targetUrl);\n if (saved) {\n window.scrollTo({\n left: saved.x,\n top: saved.y,\n behavior: \"instant\",\n });\n return;\n }\n }\n\n if (scrollRestoration === \"auto\") {\n try {\n window.scrollTo({ top: 0, behavior: \"smooth\" });\n } catch {\n window.scrollTo(0, 0);\n }\n }\n }, 0);\n },\n [scrollRestoration]\n );\n\n // Core navigation function\n const navigateTo = useCallback(\n async (newUrl: string, options: NavigateOptions = {}): Promise<void> => {\n const {\n replace = false,\n state,\n shallow = false,\n scroll = true,\n } = options;\n\n // Run before navigation guard\n if (beforeNavigate) {\n try {\n const shouldProceed = await beforeNavigate(newUrl, url);\n if (!shouldProceed) {\n return;\n }\n } catch (error) {\n console.error(\"beforeNavigate error:\", error);\n return;\n }\n }\n\n // Save current scroll position\n saveScrollPosition();\n\n // Store previous URL\n setPreviousUrl(url);\n\n // Shallow navigation - just update URL without fetching\n if (shallow) {\n setUrl(newUrl);\n setNavigationState(state);\n\n if (replace) {\n window.history.replaceState(\n { page, data, params, state },\n \"\",\n newUrl\n );\n } else {\n window.history.pushState({ page, data, params, state }, \"\", newUrl);\n }\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n return;\n }\n\n // Check cache first for instant navigation\n const map = navigationCache.current;\n if (map.has(newUrl)) {\n const cached = map.get(newUrl)!;\n setPage(cached.page);\n setData(cached.data);\n setParams(cached.params || ({} as TParams));\n setUrl(newUrl);\n setNavigationState(state);\n\n const historyState = { ...cached, state };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n\n handleScroll(newUrl, false, { scroll });\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n return;\n }\n\n setIsNavigating(true);\n\n // Abort previous request\n currentAbort.current?.abort();\n const controller = new AbortController();\n currentAbort.current = controller;\n\n try {\n const response = await fetch(newUrl, {\n headers: { \"X-ArcanaJS-Request\": \"true\" },\n cache: \"no-store\",\n signal: controller.signal,\n });\n\n if (!response.ok) {\n if (response.status === 404) {\n setPage(\"NotFoundPage\");\n setUrl(newUrl);\n const historyState = { page: \"NotFoundPage\", data: {} };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n return;\n }\n throw new Error(\n `Navigation failed: ${response.status} ${response.statusText}`\n );\n }\n\n const contentType = response.headers.get(\"content-type\") || \"\";\n if (!contentType.includes(\"application/json\")) {\n window.location.href = newUrl;\n return;\n }\n\n const json = await response.json();\n\n // Handle redirect response from server\n if (json.redirect) {\n await navigateTo(json.url, { replace: true });\n return;\n }\n\n const payload = {\n page: json.page as string,\n data: json.data as TData,\n params: (json.params || {}) as TParams,\n };\n setCache(newUrl, payload);\n\n const historyState = { ...payload, state };\n if (replace) {\n window.history.replaceState(historyState, \"\", newUrl);\n } else {\n window.history.pushState(historyState, \"\", newUrl);\n }\n\n setPage(payload.page);\n setData(payload.data);\n setParams(payload.params || ({} as TParams));\n setUrl(newUrl);\n setNavigationState(state);\n\n handleScroll(newUrl, false, { scroll });\n\n if (afterNavigate) afterNavigate(newUrl, url);\n if (onNavigate) onNavigate(newUrl);\n } catch (err: any) {\n if (err?.name === \"AbortError\") return;\n if (isRedirectError(err)) return;\n console.error(\"Navigation failed\", err);\n throw err;\n } finally {\n if (currentAbort.current === controller) currentAbort.current = null;\n setIsNavigating(false);\n }\n },\n [\n url,\n page,\n data,\n params,\n onNavigate,\n beforeNavigate,\n afterNavigate,\n saveScrollPosition,\n handleScroll,\n ]\n );\n\n // Set client navigate for universal redirect\n useEffect(() => {\n setClientNavigate((targetUrl, options) => {\n void navigateTo(targetUrl, { replace: options?.replace });\n });\n\n return () => {\n setClientNavigate(null);\n };\n }, [navigateTo]);\n\n // Initialize history state and popstate handler\n useEffect(() => {\n if (typeof window !== \"undefined\" && !window.history.state) {\n window.history.replaceState(\n { page: initialPage, data: initialData, params: initialParams },\n \"\",\n window.location.href\n );\n }\n\n const handlePopState = (event: PopStateEvent) => {\n if (event.state) {\n saveScrollPosition();\n setPage(event.state.page);\n setData(event.state.data);\n setParams(event.state.params || ({} as TParams));\n setNavigationState(event.state.state);\n const newUrl = window.location.pathname;\n setPreviousUrl(url);\n setUrl(newUrl);\n\n handleScroll(newUrl, true);\n\n if (afterNavigate) afterNavigate(newUrl, url);\n } else {\n const path = window.location.pathname;\n void navigateTo(path).catch(() => {\n window.location.reload();\n });\n }\n };\n\n window.addEventListener(\"popstate\", handlePopState);\n return () => {\n window.removeEventListener(\"popstate\", handlePopState);\n currentAbort.current?.abort();\n };\n }, []);\n\n const setCache = useCallback(\n (key: string, value: { page: string; data: TData; params: TParams }) => {\n const map = navigationCache.current;\n if (map.has(key)) map.delete(key);\n map.set(key, value);\n if (map.size > cacheLimit) {\n const firstKey = map.keys().next().value;\n if (firstKey !== undefined) map.delete(firstKey);\n }\n },\n [cacheLimit]\n );\n\n /**\n * Prefetch a route to warm the navigation cache\n */\n const prefetchRoute = useCallback(\n async (prefetchUrl: string): Promise<void> => {\n if (navigationCache.current.has(prefetchUrl)) return;\n if (prefetchInFlight.current.has(prefetchUrl)) return;\n if (/^https?:\\/\\//.test(prefetchUrl)) return;\n\n prefetchInFlight.current.add(prefetchUrl);\n\n try {\n const response = await fetch(prefetchUrl, {\n headers: { \"X-ArcanaJS-Request\": \"true\" },\n });\n\n if (!response.ok) return;\n\n const contentType = response.headers.get(\"content-type\") || \"\";\n if (!contentType.includes(\"application/json\")) return;\n\n const json = await response.json();\n\n const payload = {\n page: json.page as string,\n data: json.data as TData,\n params: (json.params || {}) as TParams,\n };\n\n setCache(prefetchUrl, payload);\n } catch {\n // Silently ignore prefetch errors\n } finally {\n prefetchInFlight.current.delete(prefetchUrl);\n }\n },\n [setCache]\n );\n\n /**\n * Refresh current page data\n */\n const refresh = useCallback(async (): Promise<void> => {\n // Clear cache for current URL\n navigationCache.current.delete(url);\n // Re-navigate to current URL with replace\n await navigateTo(url, { replace: true, scroll: false });\n }, [url, navigateTo]);\n\n /**\n * Replace current history entry\n */\n const replace = useCallback(\n (newUrl: string, options: Omit<NavigateOptions, \"replace\"> = {}) => {\n void navigateTo(newUrl, { ...options, replace: true });\n },\n [navigateTo]\n );\n\n /**\n * Go back in history\n */\n const back = useCallback(() => {\n if (typeof window !== \"undefined\") {\n window.history.back();\n }\n }, []);\n\n /**\n * Go forward in history\n */\n const forward = useCallback(() => {\n if (typeof window !== \"undefined\") {\n window.history.forward();\n }\n }, []);\n\n // Parse current query string\n const query = useMemo(() => {\n if (typeof window === \"undefined\") return {};\n return parseQueryString(window.location.search);\n }, [url]);\n\n // Memoize renderPage to prevent unnecessary re-renders\n const content = useMemo(() => {\n const Component = (views[page] ||\n views[\"NotFoundPage\"] ||\n (() => <div>404 Not Found</div>)) as React.ComponentType<{\n data: TData;\n navigateTo: (url: string) => Promise<void>;\n params: TParams;\n }>;\n\n return (\n <PageProvider data={data}>\n <Component data={data} navigateTo={navigateTo} params={params} />\n </PageProvider>\n );\n }, [page, data, params, views, navigateTo]);\n\n // Memoize router context value\n const routerValue = useMemo(\n () => ({\n // Navigation methods\n navigateTo: (targetUrl: string, options?: NavigateOptions) => {\n void navigateTo(targetUrl, options);\n },\n navigateToAsync: navigateTo,\n push: (targetUrl: string, options?: NavigateOptions) => {\n void navigateTo(targetUrl, options);\n },\n replace,\n back,\n forward,\n refresh,\n prefetchRoute,\n\n // Current route state\n currentPage: page,\n currentUrl: url,\n pathname: url,\n params,\n query,\n state: navigationState,\n\n // Authentication\n csrfToken,\n\n // Navigation state\n isNavigating,\n onNavigate,\n previousUrl,\n }),\n [\n navigateTo,\n replace,\n back,\n forward,\n refresh,\n prefetchRoute,\n page,\n url,\n params,\n query,\n navigationState,\n csrfToken,\n isNavigating,\n onNavigate,\n previousUrl,\n ]\n );\n\n return (\n <RouterProvider value={routerValue}>\n {Layout ? <Layout>{content}</Layout> : <>{content}</>}\n </RouterProvider>\n );\n};\n","import React from \"react\";\nimport { PageContext } from \"../context/PageContext\";\n\n/**\n * PageProvider - Internal framework component for ArcanaJS\n *\n * This is an INTERNAL component used by the ArcanaJS framework to provide\n * page data context. Developers should NOT use this directly.\n *\n * Use the `Page` component instead for creating pages.\n *\n * @internal\n */\nexport const PageProvider = <T,>({\n data,\n children,\n}: {\n data?: T;\n children: React.ReactNode;\n}) => {\n return (\n <PageContext.Provider value={data as unknown}>\n {children}\n </PageContext.Provider>\n );\n};\n\nexport default PageProvider;\n","import { useCallback, useContext, useState } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Error structure for ArcanaJS\n */\nexport interface ArcanaError {\n /** HTTP status code */\n statusCode: number;\n /** Error message */\n message: string;\n /** Unique error identifier */\n name?: string;\n /** Stack trace (dev only) */\n stack?: string;\n /** Original error */\n cause?: Error;\n /** Whether this is a fatal error */\n fatal?: boolean;\n /** Data associated with the error */\n data?: any;\n}\n\n/**\n * Error context for global error state\n */\ninterface ErrorContextType {\n error: ArcanaError | null;\n setError: (error: ArcanaError | null) => void;\n clearError: () => void;\n}\n\n// Global error state\nlet globalError: ArcanaError | null = null;\nconst errorListeners: Array<(error: ArcanaError | null) => void> = [];\n\nexport const ErrorContext = createSingletonContext<ErrorContextType | null>(\n \"ErrorContext\",\n null\n);\n\n/**\n * Create error from various inputs\n */\nexport function createError(options: {\n statusCode?: number;\n message: string;\n name?: string;\n fatal?: boolean;\n cause?: Error;\n data?: any;\n}): ArcanaError {\n return {\n statusCode: options.statusCode || 500,\n message: options.message,\n name: options.name || \"ArcanaError\",\n fatal: options.fatal ?? false,\n cause: options.cause,\n data: options.data,\n stack:\n process.env.NODE_ENV === \"development\" ? options.cause?.stack : undefined,\n };\n}\n\n/**\n * Set global error (for server-side or non-React contexts)\n */\nexport function setGlobalError(error: ArcanaError | null): void {\n globalError = error;\n errorListeners.forEach((listener) => listener(error));\n}\n\n/**\n * Get global error\n */\nexport function getGlobalError(): ArcanaError | null {\n return globalError;\n}\n\n/**\n * Clear global error\n */\nexport function clearGlobalError(): void {\n globalError = null;\n errorListeners.forEach((listener) => listener(null));\n}\n\n/**\n * Show error page (throws error for error boundary)\n */\nexport function showError(options: {\n statusCode?: number;\n message: string;\n fatal?: boolean;\n}): never {\n const error = createError(options);\n setGlobalError(error);\n\n // Throw to trigger error boundary\n throw new Error(error.message);\n}\n\n/**\n * useError - Error handling hook\n *\n * Provides access to the global error state and methods\n * to create/clear errors. Works with ArcanaJS error pages.\n *\n * @example\n * ```tsx\n * // Check for errors\n * const { error, clearError } = useError();\n *\n * if (error) {\n * return (\n * <div>\n * <h1>Error {error.statusCode}</h1>\n * <p>{error.message}</p>\n * <button onClick={clearError}>Try Again</button>\n * </div>\n * );\n * }\n *\n * // Create an error\n * const { setError } = useError();\n *\n * const handleNotFound = () => {\n * setError({\n * statusCode: 404,\n * message: 'Resource not found',\n * });\n * };\n *\n * // Throw a fatal error\n * import { showError } from 'arcanajs/client';\n *\n * if (!user) {\n * showError({\n * statusCode: 401,\n * message: 'Authentication required',\n * fatal: true,\n * });\n * }\n * ```\n */\nfunction useError(): {\n error: ArcanaError | null;\n setError: (\n error: Partial<ArcanaError> & { message: string; statusCode?: number }\n ) => void;\n clearError: () => void;\n} {\n const context = useContext(ErrorContext);\n\n // Use context if available (within ErrorProvider)\n if (context) {\n return {\n error: context.error,\n setError: (err) => context.setError(createError(err)),\n clearError: context.clearError,\n };\n }\n\n // Fallback to global state\n const [error, setLocalError] = useState<ArcanaError | null>(globalError);\n\n // Subscribe to global error changes\n useState(() => {\n const listener = (err: ArcanaError | null) => setLocalError(err);\n errorListeners.push(listener);\n return () => {\n const index = errorListeners.indexOf(listener);\n if (index > -1) errorListeners.splice(index, 1);\n };\n });\n\n const setError = useCallback(\n (err: Partial<ArcanaError> & { message: string; statusCode?: number }) => {\n const arcanaError = createError(err);\n setGlobalError(arcanaError);\n setLocalError(arcanaError);\n },\n []\n );\n\n const clearError = useCallback(() => {\n clearGlobalError();\n setLocalError(null);\n }, []);\n\n return {\n error,\n setError,\n clearError,\n };\n}\n\nexport default useError;\n","import { useContext } from \"react\";\nimport { HeadContext } from \"../context/HeadContext\";\n\nexport const useHead = () => useContext(HeadContext);\n","import { useContext } from \"react\";\nimport { RouterContext } from \"../context/RouterContext\";\n\n/**\n * useRouter - Professional routing hook for ArcanaJS\n *\n * Provides complete navigation methods and current route state.\n * Works in both SSR and client-side contexts.\n *\n * @example\n * ```tsx\n * const router = useRouter();\n *\n * // Push navigation\n * router.push('/dashboard');\n *\n * // Replace current entry\n * router.replace('/settings');\n *\n * // Navigation with options\n * router.push('/page', { scroll: false, state: { from: 'home' } });\n *\n * // Go back/forward\n * router.back();\n * router.forward();\n *\n * // Refresh current page data\n * await router.refresh();\n *\n * // Prefetch a route\n * router.prefetch('/about');\n *\n * // Access route info\n * console.log(router.pathname); // '/users/123'\n * console.log(router.params); // { id: '123' }\n * console.log(router.query); // { sort: 'asc' }\n * console.log(router.state); // { from: 'home' }\n *\n * // Check navigation state\n * if (router.isNavigating) {\n * return <Spinner />;\n * }\n * ```\n */\nconst useRouter = () => {\n const context = useContext(RouterContext);\n if (!context) {\n throw new Error(\"useRouter must be used within an ArcanaJSApp\");\n }\n\n return {\n // ============================================================================\n // Navigation Methods\n // ============================================================================\n\n /** Navigate to a URL (fire-and-forget) */\n navigateTo: context.navigateTo,\n\n /** Navigate to a URL with async/await */\n navigateToAsync: context.navigateToAsync,\n\n /** Push a new entry to history (alias for navigateTo) */\n push: context.push,\n\n /** Replace current history entry with new URL */\n replace: context.replace,\n\n /** Go back in history */\n back: context.back,\n\n /** Go forward in history */\n forward: context.forward,\n\n /** Refresh current page data */\n refresh: context.refresh,\n\n /** Prefetch a route for faster navigation */\n prefetch: context.prefetchRoute,\n prefetchRoute: context.prefetchRoute,\n\n // ============================================================================\n // Current Route State\n // ============================================================================\n\n /** Current page/view name */\n currentPage: context.currentPage,\n\n /** Current URL path */\n currentUrl: context.currentUrl,\n\n /** Current pathname (alias for currentUrl) */\n pathname: context.pathname,\n\n /** Dynamic route parameters */\n params: context.params,\n\n /** Parsed query string parameters */\n query: context.query,\n\n /** Navigation state passed via options */\n state: context.state,\n\n /** Previous URL before navigation */\n previousUrl: context.previousUrl,\n\n // ============================================================================\n // Authentication\n // ============================================================================\n\n /** CSRF token for form submissions */\n csrfToken: context.csrfToken,\n\n // ============================================================================\n // Navigation State\n // ============================================================================\n\n /** Whether navigation is in progress */\n isNavigating: context.isNavigating,\n\n /** Callback when navigation completes */\n onNavigate: context.onNavigate,\n };\n};\n\n/**\n * Return type for useRouter hook\n */\nexport type UseRouterReturn = ReturnType<typeof useRouter>;\n\nexport default useRouter;\n","import { useContext } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Runtime configuration structure\n */\nexport interface RuntimeConfig {\n /** Public config - accessible on both server and client */\n public: Record<string, any>;\n /** Private config - only accessible on server */\n private?: Record<string, any>;\n /** App metadata */\n app?: {\n name?: string;\n version?: string;\n env?: string;\n baseUrl?: string;\n };\n}\n\n// Default runtime config\nconst defaultConfig: RuntimeConfig = {\n public: {},\n private: {},\n app: {\n name: \"ArcanaJS App\",\n version: \"1.0.0\",\n env: process.env.NODE_ENV || \"development\",\n baseUrl: \"\",\n },\n};\n\n// Global runtime config\nlet runtimeConfig: RuntimeConfig = { ...defaultConfig };\n\n// Context for passing config from server\nexport const RuntimeConfigContext = createSingletonContext<RuntimeConfig>(\n \"RuntimeConfigContext\",\n defaultConfig\n);\n\n/**\n * Set runtime configuration (call on server startup)\n */\nexport function setRuntimeConfig(config: Partial<RuntimeConfig>): void {\n runtimeConfig = {\n public: { ...defaultConfig.public, ...config.public },\n private: { ...defaultConfig.private, ...config.private },\n app: { ...defaultConfig.app, ...config.app },\n };\n}\n\n/**\n * Get runtime configuration (server-side)\n */\nexport function getRuntimeConfig(): RuntimeConfig {\n return runtimeConfig;\n}\n\n/**\n * Get public runtime config (safe for client)\n */\nexport function getPublicRuntimeConfig(): RuntimeConfig {\n return {\n public: runtimeConfig.public,\n app: runtimeConfig.app,\n };\n}\n\n/**\n * useRuntimeConfig - Access runtime configuration\n *\n * Returns the runtime configuration object.\n * On the client, only public config is available.\n * On the server, full config including private values is accessible.\n *\n * @example\n * ```tsx\n * // In your component\n * const config = useRuntimeConfig();\n *\n * // Access public config (available on both server and client)\n * const apiUrl = config.public.apiUrl;\n *\n * // Access private config (server only)\n * if (typeof window === 'undefined') {\n * const apiKey = config.private?.apiKey;\n * }\n *\n * // Access app metadata\n * const appName = config.app?.name;\n * ```\n *\n * @example\n * ```typescript\n * // Server setup (in ArcanaJS config)\n * import { setRuntimeConfig } from 'arcanajs/client';\n *\n * setRuntimeConfig({\n * public: {\n * apiUrl: 'https://api.example.com',\n * },\n * private: {\n * apiKey: process.env.API_KEY,\n * },\n * });\n * ```\n */\nfunction useRuntimeConfig(): RuntimeConfig {\n const contextConfig = useContext(RuntimeConfigContext);\n\n // On client, strip private config\n if (typeof window !== \"undefined\") {\n return {\n public: contextConfig.public || runtimeConfig.public,\n app: contextConfig.app || runtimeConfig.app,\n };\n }\n\n // On server, return full config\n return {\n public: contextConfig.public || runtimeConfig.public,\n private: contextConfig.private || runtimeConfig.private,\n app: contextConfig.app || runtimeConfig.app,\n };\n}\n\nexport default useRuntimeConfig;\n","import React, { ReactNode, useState as reactUseState, useContext } from \"react\";\nimport { createSingletonContext } from \"../utils/createSingletonContext\";\n\n/**\n * Shared state store for SSR hydration\n */\ninterface SharedStateStore {\n [key: string]: any;\n}\n\n// Global state store for SSR data transfer\nconst sharedStateStore: SharedStateStore = {};\n\n// Context to pass initial state from server to client\nexport const SharedStateContext = createSingletonContext<SharedStateStore>(\n \"SharedStateContext\",\n {}\n);\n\n/**\n * Provider component for shared state (used in SSR)\n */\nexport const SharedStateProvider: React.FC<{\n initialState?: SharedStateStore;\n children: ReactNode;\n}> = ({ initialState = {}, children }) => {\n return (\n <SharedStateContext.Provider value={initialState}>\n {children}\n </SharedStateContext.Provider>\n );\n};\n\n/**\n * useState - SSR-hydrated shared state hook\n *\n * Creates reactive state that can be shared across components and\n * persists across SSR hydration. Unlike React's useState, this state\n * is keyed and can be accessed from anywhere in the component tree.\n *\n * On the server, state is collected and serialized to the client.\n * On the client, state is hydrated from the server's initial values.\n *\n * @example\n * ```tsx\n * // Create or access shared state\n * const counter = useState<number>('counter', () => 0);\n * counter.value++; // Increment\n *\n * // In another component\n * const counter = useState<number>('counter', () => 0);\n * console.log(counter.value); // Same value!\n *\n * // Complex objects\n * const user = useState<User>('user', () => fetchUser());\n * ```\n */\nfunction useState<T>(\n key: string,\n init?: () => T\n): { value: T; set: (value: T | ((prev: T) => T)) => void } {\n const ssrState = useContext(SharedStateContext);\n\n // Get initial value from SSR state or initialize\n const getInitialValue = (): T => {\n // Check SSR hydrated state first\n if (key in ssrState) {\n return ssrState[key] as T;\n }\n\n // Check global store (for client-side access across components)\n if (key in sharedStateStore) {\n return sharedStateStore[key] as T;\n }\n\n // Initialize with factory function\n const initialValue = init ? init() : (undefined as T);\n sharedStateStore[key] = initialValue;\n return initialValue;\n };\n\n const [value, setValue] = reactUseState<T>(getInitialValue);\n\n // Custom setter that also updates the shared store\n const set = (newValue: T | ((prev: T) => T)) => {\n setValue((prev) => {\n const nextValue =\n typeof newValue === \"function\"\n ? (newValue as (prev: T) => T)(prev)\n : newValue;\n\n // Update shared store\n sharedStateStore[key] = nextValue;\n\n return nextValue;\n });\n };\n\n return {\n value,\n set,\n };\n}\n\n/**\n * Get all shared state for SSR serialization\n */\nexport function getSharedState(): SharedStateStore {\n return { ...sharedStateStore };\n}\n\n/**\n * Set shared state from server-side\n */\nexport function setSharedState(key: string, value: any): void {\n sharedStateStore[key] = value;\n}\n\n/**\n * Clear all shared state (for testing or cleanup)\n */\nexport function clearSharedState(): void {\n Object.keys(sharedStateStore).forEach((key) => {\n delete sharedStateStore[key];\n });\n}\n\nexport default useState;\n","import React, { createContext } from \"react\";\n\n/**\n * Creates a React Context that persists across multiple module loads (Webpack bundles vs Node require).\n * This is essential for SSR applications where the server bundle and dynamically loaded views\n * might reference different instances of the \"same\" context module.\n *\n * @param key A unique string key to identify this context globally\n * @param defaultValue The default value for the context\n * @returns A React Context instance (singleton)\n */\nexport function createSingletonContext<T>(\n key: string,\n defaultValue: T\n): React.Context<T> {\n const globalAny = globalThis as any;\n const symbolKey = Symbol.for(`ARCANAJS_CONTEXT_${key}`);\n\n if (!globalAny[symbolKey]) {\n globalAny[symbolKey] = createContext<T>(defaultValue);\n }\n\n return globalAny[symbolKey];\n}\n","/**\n * Universal Redirect Utility\n *\n * Works seamlessly in both SSR (Server-Side Rendering) and SPA (Single Page Application) contexts.\n *\n * @example\n * // In a page component\n * if (!user.isAuthenticated) {\n * redirect('/login');\n * }\n *\n * // Permanent redirect\n * permanentRedirect('/new-location');\n *\n * // With custom status\n * redirect('/dashboard', 307);\n */\n\nimport type { Response } from \"express\";\n\n/**\n * Redirect error class - thrown during SSR to signal redirect\n */\nexport class RedirectError extends Error {\n public readonly url: string;\n public readonly statusCode: number;\n public readonly isRedirect = true;\n\n constructor(url: string, statusCode: number = 302) {\n super(`Redirect to ${url}`);\n this.name = \"RedirectError\";\n this.url = url;\n this.statusCode = statusCode;\n }\n}\n\n/**\n * SSR context for redirect handling\n */\ninterface SSRContext {\n response?: Response;\n isSSR: boolean;\n}\n\n// Global SSR context (set during server-side rendering)\nlet ssrContext: SSRContext | null = null;\n\n/**\n * Set SSR context for redirect handling\n * Called by the server during SSR rendering\n */\nexport function setSSRContext(ctx: SSRContext | null): void {\n ssrContext = ctx;\n}\n\n/**\n * Get current SSR context\n */\nexport function getSSRContext(): SSRContext | null {\n return ssrContext;\n}\n\n// Client-side navigation function (set by RouterContext)\nlet clientNavigate:\n | ((url: string, options?: { replace?: boolean }) => void)\n | null = null;\n\n/**\n * Set client-side navigation function\n * Called by ArcanaJSApp on initialization\n */\nexport function setClientNavigate(\n fn: ((url: string, options?: { replace?: boolean }) => void) | null\n): void {\n clientNavigate = fn;\n}\n\n/**\n * Redirect to a new URL\n *\n * Works in both SSR and SPA contexts:\n * - **SSR**: Sets response redirect and throws RedirectError to stop rendering\n * - **SPA**: Uses client-side navigation with history replacement\n *\n * @param url - The URL to redirect to\n * @param statusCode - HTTP status code (default: 302)\n *\n * @example\n * // Basic redirect\n * redirect('/login');\n *\n * // With status code\n * redirect('/dashboard', 307);\n *\n * // In a component\n * function ProtectedPage({ data }) {\n * if (!data.isAuthenticated) {\n * redirect('/login');\n * }\n * return <Dashboard />;\n * }\n */\nexport function redirect(url: string, statusCode: number = 302): never {\n // Check for SSR context first\n if (ssrContext?.isSSR && ssrContext.response) {\n // Server-side: use HTTP redirect\n ssrContext.response.redirect(statusCode, url);\n throw new RedirectError(url, statusCode);\n }\n\n // Client-side: use navigation\n if (typeof window !== \"undefined\") {\n if (clientNavigate) {\n // Use ArcanaJS navigation with replace\n clientNavigate(url, { replace: true });\n } else {\n // Fallback to window.location\n window.location.replace(url);\n }\n }\n\n // Throw redirect error to stop execution\n throw new RedirectError(url, statusCode);\n}\n\n/**\n * Permanent redirect (301)\n *\n * @param url - The URL to redirect to\n *\n * @example\n * permanentRedirect('/new-page');\n */\nexport function permanentRedirect(url: string): never {\n return redirect(url, 301);\n}\n\n/**\n * Temporary redirect (307 - preserves HTTP method)\n *\n * @param url - The URL to redirect to\n *\n * @example\n * temporaryRedirect('/maintenance');\n */\nexport function temporaryRedirect(url: string): never {\n return redirect(url, 307);\n}\n\n/**\n * Check if an error is a redirect error\n */\nexport function isRedirectError(error: unknown): error is RedirectError {\n return (\n error instanceof RedirectError ||\n (error !== null &&\n typeof error === \"object\" &&\n \"isRedirect\" in error &&\n (error as any).isRedirect === true)\n );\n}\n\n/**\n * Navigate without throwing (for conditional navigation)\n * Returns false if navigation was not possible\n *\n * @param url - The URL to navigate to\n * @param options - Navigation options\n *\n * @example\n * if (!navigateTo('/dashboard', { replace: true })) {\n * console.log('Navigation not available');\n * }\n */\nexport function navigateTo(\n url: string,\n options: { replace?: boolean } = {}\n): boolean {\n // SSR context\n if (ssrContext?.isSSR && ssrContext.response) {\n ssrContext.response.redirect(options.replace ? 301 : 302, url);\n return true;\n }\n\n // Client-side\n if (typeof window !== \"undefined\") {\n if (clientNavigate) {\n clientNavigate(url, options);\n return true;\n } else {\n if (options.replace) {\n window.location.replace(url);\n } else {\n window.location.href = url;\n }\n return true;\n }\n }\n\n return false;\n}\n","import Body from \"../components/Body\";\nimport Head from \"../components/Head\";\nimport Link from \"../components/Link\";\nimport Page from \"../components/Page\";\ninterface ErrorPageProps {\n message?: string;\n statusCode?: number;\n stack?: string;\n}\n\nexport default function ErrorPage({\n message = \"Something went wrong\",\n statusCode = 500,\n stack,\n}: ErrorPageProps) {\n const isDevelopment = process.env.NODE_ENV === \"development\";\n\n return (\n <Page>\n <Head>\n <title>{statusCode} - Server Error</title>\n <meta name=\"description\" content=\"An error occurred on the server\" />\n </Head>\n <Body>\n <div className=\"relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans\">\n {/* Animated Background */}\n <div className=\"fixed inset-0 z-0 overflow-hidden pointer-events-none\">\n <div className=\"absolute inset-0 grid-pattern opacity-30\"></div>\n <div className=\"absolute top-1/4 right-1/4 w-96 h-96 bg-red-600 rounded-full opacity-20 blur-3xl animate-glow\"></div>\n <div\n className=\"absolute bottom-1/4 left-1/4 w-96 h-96 bg-orange-600 rounded-full opacity-10 blur-3xl animate-glow\"\n style={{ animationDelay: \"2s\" }}\n ></div>\n <div className=\"absolute inset-0 hero-gradient\"></div>\n </div>\n\n <div className=\"relative z-10 max-w-2xl w-full text-center animate-scale-in\">\n <div className=\"glass-card rounded-3xl p-12 border border-white/10 shadow-2xl\">\n <div className=\"mb-8\">\n <div className=\"text-6xl mb-6 animate-float\">\n <span className=\"text-red-500 drop-shadow-lg filter\">⚠️</span>\n </div>\n <h1 className=\"text-8xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-red-500 to-orange-500 mb-4\">\n {statusCode}\n </h1>\n <h2 className=\"text-3xl font-bold text-white mb-4\">\n Server Error\n </h2>\n <p className=\"text-gray-400 text-lg leading-relaxed\">\n {message}\n </p>\n </div>\n\n <div className=\"flex flex-col sm:flex-row gap-4 justify-center mb-8\">\n <Link\n href=\"/\"\n className=\"btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto bg-gradient-to-r from-red-600 to-orange-600 hover:from-red-500 hover:to-orange-500 border-none shadow-red-900/20\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6\"\n />\n </svg>\n Go Home\n </Link>\n\n <button\n onClick={() => window.location.reload()}\n className=\"btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15\"\n />\n </svg>\n Try Again\n </button>\n </div>\n\n {isDevelopment && stack && (\n <div className=\"mt-8 text-left animate-slide-up\">\n <details className=\"bg-black/40 border border-white/10 rounded-xl overflow-hidden group\">\n <summary className=\"cursor-pointer font-medium text-gray-300 p-4 hover:bg-white/5 transition-colors flex items-center justify-between select-none\">\n <span>Stack Trace (Development Only)</span>\n <svg\n className=\"w-5 h-5 text-gray-500 group-open:rotate-180 transition-transform\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M19 9l-7 7-7-7\"\n />\n </svg>\n </summary>\n <pre className=\"text-xs text-red-300/80 p-4 overflow-x-auto whitespace-pre-wrap font-mono border-t border-white/5 bg-black/20\">\n {stack}\n </pre>\n </details>\n </div>\n )}\n </div>\n\n <div className=\"mt-8 text-gray-500 text-sm\">\n If this problem persists, please{\" \"}\n <Link\n href=\"/contact\"\n className=\"text-red-400 hover:text-red-300 underline transition-colors\"\n >\n contact support\n </Link>\n .\n </div>\n </div>\n </div>\n </Body>\n </Page>\n );\n}\n","import Body from \"../components/Body\";\nimport Head from \"../components/Head\";\nimport Link from \"../components/Link\";\nimport Page from \"../components/Page\";\ninterface NotFoundPageProps {\n url?: string;\n}\n\nexport default function NotFoundPage({ url }: NotFoundPageProps) {\n return (\n <Page>\n <Head>\n <title>404 - Page Not Found</title>\n <meta\n name=\"description\"\n content=\"The page you're looking for doesn't exist\"\n />\n </Head>\n <Body>\n <div className=\"relative min-h-screen overflow-hidden bg-black text-white flex flex-col justify-center items-center px-4 font-sans\">\n {/* Animated Background */}\n <div className=\"fixed inset-0 z-0 overflow-hidden pointer-events-none\">\n <div className=\"absolute inset-0 grid-pattern opacity-30\"></div>\n <div className=\"absolute top-1/4 left-1/4 w-96 h-96 bg-orange-500 rounded-full opacity-20 blur-3xl animate-glow\"></div>\n <div\n className=\"absolute bottom-1/4 right-1/4 w-96 h-96 bg-purple-500 rounded-full opacity-10 blur-3xl animate-glow\"\n style={{ animationDelay: \"2s\" }}\n ></div>\n <div className=\"absolute inset-0 hero-gradient\"></div>\n </div>\n\n <div className=\"relative z-10 max-w-lg w-full text-center animate-scale-in\">\n <div className=\"glass-card rounded-3xl p-12 border border-white/10 shadow-2xl\">\n <div className=\"mb-8\">\n <h1 className=\"text-9xl font-bold text-transparent bg-clip-text bg-gradient-to-br from-white to-gray-500 mb-4 animate-float\">\n 404\n </h1>\n <h2 className=\"text-3xl font-bold text-white mb-4\">\n Page Not Found\n </h2>\n <p className=\"text-gray-400 text-lg leading-relaxed\">\n {url ? (\n <>\n The page <span className=\"text-orange-400\">\"{url}\"</span>{\" \"}\n you're looking for doesn't exist.\n </>\n ) : (\n \"The page you're looking for doesn't exist.\"\n )}\n </p>\n </div>\n\n <div className=\"flex flex-col sm:flex-row gap-4 justify-center\">\n <Link\n href=\"/\"\n className=\"btn-primary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6\"\n />\n </svg>\n Go Home\n </Link>\n\n <button\n onClick={() => window.history.back()}\n className=\"btn-secondary px-8 py-3.5 text-white font-semibold rounded-xl inline-flex items-center justify-center gap-2 w-full sm:w-auto\"\n >\n <svg\n className=\"w-5 h-5\"\n fill=\"none\"\n stroke=\"currentColor\"\n viewBox=\"0 0 24 24\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M10 19l-7-7m0 0l7-7m-7 7h18\"\n />\n </svg>\n Go Back\n </button>\n </div>\n </div>\n <div className=\"mt-8 text-gray-500 text-sm\">\n If you believe this is an error, please{\" \"}\n <Link\n href=\"/contact\"\n className=\"text-orange-400 hover:text-orange-300 underline transition-colors\"\n >\n contact support\n </Link>\n .\n </div>\n </div>\n </div>\n </Body>\n </Page>\n );\n}\n","/**\n * Professional Module Loader Utility\n *\n * This utility provides a centralized way to load modules dynamically at runtime,\n * bypassing Webpack bundling when necessary. It also handles TypeScript registration\n * for on-the-fly compilation.\n */\nexport class ModuleLoader {\n private static tsNodeRegistered = false;\n\n /**\n * Dynamically require a module at runtime.\n *\n * This method bypasses Webpack's static analysis and bundling, allowing\n * access to user-land modules, configuration files, and native Node.js modules\n * that shouldn't be bundled with the framework.\n *\n * @param id - The module identifier or path to require\n * @returns The required module\n */\n static require(id: string): any {\n // 1. Try module.require (Node environment)\n try {\n // Use eval to avoid Webpack bundling\n const r = eval(\"module.require\");\n if (r) {\n return r(id);\n }\n } catch (e) {\n // Ignore\n }\n\n // 2. Try to use createRequire from module (ESM support)\n try {\n // Use eval to hide require from webpack\n const r = eval(\"req\" + \"uire\");\n const { createRequire } = r(\"module\");\n if (createRequire) {\n const nativeRequire = createRequire(process.cwd() + \"/\");\n return nativeRequire(id);\n }\n } catch (e) {\n // Ignore\n }\n\n // 3. Fallback to process.mainModule (Legacy)\n try {\n const _global = global as any;\n const nativeRequire = _global[\"process\"]?.[\"mainModule\"]?.[\"require\"];\n if (nativeRequire) {\n return nativeRequire(id);\n }\n } catch (e) {\n // Ignore errors during lookup\n }\n\n // 4. Last resort: new Function(\"return require\")\n try {\n const r = new Function(\"return req\" + \"uire\")();\n return r(id);\n } catch (e) {\n // Ignore\n }\n\n throw new Error(`Could not require module '${id}'`);\n }\n /**\n * Registers ts-node for runtime TypeScript compilation.\n *\n * This is useful when the framework needs to load and execute TypeScript files\n * directly from the user's project (e.g., configuration, migrations).\n *\n * @returns true if registration was successful, false otherwise\n */\n static registerTsNode(): boolean {\n if (this.tsNodeRegistered) {\n return true;\n }\n\n // Try to register tsconfig-paths for alias support\n try {\n this.require(\"tsconfig-paths/register\");\n } catch (e) {\n // ignore tsconfig-paths failure\n }\n\n try {\n const tsNode = this.require(\"ts-node\");\n // Check if ts-node is already registered by checking the service\n if (!tsNode.register) {\n return false;\n }\n\n tsNode.register({\n transpileOnly: true,\n compilerOptions: {\n module: \"commonjs\",\n moduleResolution: \"node\",\n experimentalDecorators: true,\n emitDecoratorMetadata: true,\n esModuleInterop: true,\n },\n });\n\n this.tsNodeRegistered = true;\n return true;\n } catch (e) {\n return false;\n }\n }\n}\n","module.exports = require(\"arcanajs-views\");","module.exports = require(\"compression\");","module.exports = require(\"cookie-parser\");","module.exports = require(\"crypto\");","module.exports = require(\"express\");","module.exports = require(\"fs\");","module.exports = require(\"helmet\");","module.exports = require(\"node:fs\");","module.exports = require(\"node:path\");","module.exports = require(\"path\");","module.exports = require(\"react\");","module.exports = require(\"react-dom/server\");","module.exports = require(\"react/jsx-dev-runtime\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/lib/index.server.ts\");\n",""],"names":[],"ignoreList":[],"sourceRoot":""}