snice 7.0.2 → 7.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/.agents/skills/snice/SKILL.md +4 -0
  2. package/.agents/skills/snice/references/core-kitchen-sink.ts +39 -1
  3. package/README.md +59 -14
  4. package/adapters/react/SniceProvider.js +2 -2
  5. package/adapters/react/SniceRouter.js +2 -2
  6. package/adapters/react/matchRoute.js +2 -2
  7. package/adapters/react/useRequestHandler.js +2 -2
  8. package/bin/analyzer-contracts.js +6 -1
  9. package/bin/postinstall.js +59 -0
  10. package/bin/project-analyzer.js +466 -5
  11. package/bin/snice.js +3 -0
  12. package/dist/app-context.d.ts +11 -0
  13. package/dist/cdn/accordion/snice-accordion.js +2 -2
  14. package/dist/cdn/action-bar/snice-action-bar.js +2 -2
  15. package/dist/cdn/activity-feed/snice-activity-feed.js +2 -2
  16. package/dist/cdn/alert/snice-alert.js +2 -2
  17. package/dist/cdn/app-tiles/snice-app-tiles.js +2 -2
  18. package/dist/cdn/approval-flow/snice-approval-flow.js +2 -2
  19. package/dist/cdn/audio-recorder/snice-audio-recorder.js +2 -2
  20. package/dist/cdn/availability/snice-availability.js +2 -2
  21. package/dist/cdn/avatar/snice-avatar.js +2 -2
  22. package/dist/cdn/avatar-group/snice-avatar-group.js +2 -2
  23. package/dist/cdn/badge/snice-badge.js +2 -2
  24. package/dist/cdn/banner/snice-banner.js +2 -2
  25. package/dist/cdn/binpack/snice-binpack.js +2 -2
  26. package/dist/cdn/book/snice-book.js +2 -2
  27. package/dist/cdn/booking/snice-booking.js +2 -2
  28. package/dist/cdn/breadcrumbs/snice-breadcrumbs.js +2 -2
  29. package/dist/cdn/button/snice-button.js +2 -2
  30. package/dist/cdn/calendar/snice-calendar.js +2 -2
  31. package/dist/cdn/camera/snice-camera.js +2 -2
  32. package/dist/cdn/camera-annotate/snice-camera-annotate.js +2 -2
  33. package/dist/cdn/candlestick/snice-candlestick.js +2 -2
  34. package/dist/cdn/card/snice-card.js +2 -2
  35. package/dist/cdn/carousel/snice-carousel.js +2 -2
  36. package/dist/cdn/cart/snice-cart.js +2 -2
  37. package/dist/cdn/chart/snice-chart.js +2 -2
  38. package/dist/cdn/chat/snice-chat.js +2 -2
  39. package/dist/cdn/checkbox/snice-checkbox.js +2 -2
  40. package/dist/cdn/chip/snice-chip.js +2 -2
  41. package/dist/cdn/code-block/snice-code-block.js +2 -2
  42. package/dist/cdn/color-display/snice-color-display.js +2 -2
  43. package/dist/cdn/color-picker/snice-color-picker.js +2 -2
  44. package/dist/cdn/command-palette/snice-command-palette.js +2 -2
  45. package/dist/cdn/comments/snice-comments.js +2 -2
  46. package/dist/cdn/countdown/snice-countdown.js +2 -2
  47. package/dist/cdn/cropper/snice-cropper.js +2 -2
  48. package/dist/cdn/data-card/snice-data-card.js +2 -2
  49. package/dist/cdn/date-picker/snice-date-picker.js +2 -2
  50. package/dist/cdn/date-range-picker/snice-date-range-picker.js +2 -2
  51. package/dist/cdn/date-time-picker/snice-date-time-picker.js +2 -2
  52. package/dist/cdn/diff/snice-diff.js +2 -2
  53. package/dist/cdn/divider/snice-divider.js +2 -2
  54. package/dist/cdn/doc/snice-doc.js +2 -2
  55. package/dist/cdn/draw/snice-draw.js +2 -2
  56. package/dist/cdn/drawer/snice-drawer.js +2 -2
  57. package/dist/cdn/empty-state/snice-empty-state.js +2 -2
  58. package/dist/cdn/estimate/snice-estimate.js +2 -2
  59. package/dist/cdn/file-gallery/snice-file-gallery.js +2 -2
  60. package/dist/cdn/file-upload/snice-file-upload.js +2 -2
  61. package/dist/cdn/flip-card/snice-flip-card.js +2 -2
  62. package/dist/cdn/flow/snice-flow.js +2 -2
  63. package/dist/cdn/form-layout/snice-form-layout.js +2 -2
  64. package/dist/cdn/funnel/snice-funnel.js +2 -2
  65. package/dist/cdn/gantt/snice-gantt.js +2 -2
  66. package/dist/cdn/gauge/snice-gauge.js +2 -2
  67. package/dist/cdn/grid/snice-grid.js +2 -2
  68. package/dist/cdn/heatmap/snice-heatmap.js +2 -2
  69. package/dist/cdn/image/snice-image.js +2 -2
  70. package/dist/cdn/input/snice-input.js +2 -2
  71. package/dist/cdn/invoice/snice-invoice.js +2 -2
  72. package/dist/cdn/kanban/snice-kanban.js +2 -2
  73. package/dist/cdn/key-value/snice-key-value.js +2 -2
  74. package/dist/cdn/kpi/snice-kpi.js +2 -2
  75. package/dist/cdn/layout/README.md +17 -2
  76. package/dist/cdn/layout/snice-layout.js +1656 -11
  77. package/dist/cdn/layout/snice-layout.js.map +1 -1
  78. package/dist/cdn/layout/snice-layout.min.js +379 -2
  79. package/dist/cdn/layout/snice-layout.min.js.map +1 -1
  80. package/dist/cdn/leaderboard/snice-leaderboard.js +2 -2
  81. package/dist/cdn/link/snice-link.js +2 -2
  82. package/dist/cdn/link-preview/snice-link-preview.js +2 -2
  83. package/dist/cdn/list/snice-list.js +2 -2
  84. package/dist/cdn/location/snice-location.js +2 -2
  85. package/dist/cdn/login/snice-login.js +2 -2
  86. package/dist/cdn/map/snice-map.js +2 -2
  87. package/dist/cdn/markdown/snice-markdown.js +2 -2
  88. package/dist/cdn/masonry/snice-masonry.js +2 -2
  89. package/dist/cdn/menu/snice-menu.js +2 -2
  90. package/dist/cdn/message-strip/snice-message-strip.js +2 -2
  91. package/dist/cdn/modal/snice-modal.js +2 -2
  92. package/dist/cdn/music-player/snice-music-player.js +2 -2
  93. package/dist/cdn/nav/snice-nav.js +2 -2
  94. package/dist/cdn/network-graph/snice-network-graph.js +2 -2
  95. package/dist/cdn/notification-center/snice-notification-center.js +2 -2
  96. package/dist/cdn/order-tracker/snice-order-tracker.js +2 -2
  97. package/dist/cdn/org-chart/snice-org-chart.js +2 -2
  98. package/dist/cdn/pagination/snice-pagination.js +2 -2
  99. package/dist/cdn/paint/snice-paint.js +2 -2
  100. package/dist/cdn/pdf-viewer/snice-pdf-viewer.js +2 -2
  101. package/dist/cdn/permission-matrix/snice-permission-matrix.js +2 -2
  102. package/dist/cdn/podcast-player/snice-podcast-player.js +2 -2
  103. package/dist/cdn/popover/snice-popover.js +2 -2
  104. package/dist/cdn/pricing-table/snice-pricing-table.js +2 -2
  105. package/dist/cdn/product-card/snice-product-card.js +2 -2
  106. package/dist/cdn/progress/snice-progress.js +2 -2
  107. package/dist/cdn/progress-ring/snice-progress-ring.js +2 -2
  108. package/dist/cdn/qr-code/snice-qr-code.js +2 -2
  109. package/dist/cdn/qr-reader/snice-qr-reader.js +2 -2
  110. package/dist/cdn/radio/snice-radio.js +2 -2
  111. package/dist/cdn/range-slider/snice-range-slider.js +2 -2
  112. package/dist/cdn/rating/snice-rating.js +2 -2
  113. package/dist/cdn/receipt/snice-receipt.js +2 -2
  114. package/dist/cdn/recipe/snice-recipe.js +3 -3
  115. package/dist/cdn/recipe/snice-recipe.js.map +1 -1
  116. package/dist/cdn/recipe/snice-recipe.min.js +1 -1
  117. package/dist/cdn/recipe/snice-recipe.min.js.map +1 -1
  118. package/dist/cdn/runtime/README.md +2 -2
  119. package/dist/cdn/runtime/snice-runtime.esm.js +3725 -3336
  120. package/dist/cdn/runtime/snice-runtime.esm.js.map +1 -1
  121. package/dist/cdn/runtime/snice-runtime.esm.min.js +1 -1
  122. package/dist/cdn/runtime/snice-runtime.esm.min.js.map +1 -1
  123. package/dist/cdn/runtime/snice-runtime.js +3727 -3335
  124. package/dist/cdn/runtime/snice-runtime.js.map +1 -1
  125. package/dist/cdn/runtime/snice-runtime.min.js +1 -1
  126. package/dist/cdn/runtime/snice-runtime.min.js.map +1 -1
  127. package/dist/cdn/sankey/snice-sankey.js +2 -2
  128. package/dist/cdn/segmented-control/snice-segmented-control.js +2 -2
  129. package/dist/cdn/select/snice-select.js +2 -2
  130. package/dist/cdn/skeleton/snice-skeleton.js +2 -2
  131. package/dist/cdn/slider/snice-slider.js +2 -2
  132. package/dist/cdn/sortable/snice-sortable.js +2 -2
  133. package/dist/cdn/sparkline/snice-sparkline.js +2 -2
  134. package/dist/cdn/spinner/snice-spinner.js +2 -2
  135. package/dist/cdn/split-button/snice-split-button.js +2 -2
  136. package/dist/cdn/split-pane/snice-split-pane.js +2 -2
  137. package/dist/cdn/spotlight/snice-spotlight.js +2 -2
  138. package/dist/cdn/stat-group/snice-stat-group.js +2 -2
  139. package/dist/cdn/step-input/snice-step-input.js +2 -2
  140. package/dist/cdn/stepper/snice-stepper.js +2 -2
  141. package/dist/cdn/switch/snice-switch.js +2 -2
  142. package/dist/cdn/table/README.md +6 -2
  143. package/dist/cdn/table/snice-table.esm.js +366 -56
  144. package/dist/cdn/table/snice-table.esm.js.map +1 -1
  145. package/dist/cdn/table/snice-table.esm.min.js +107 -46
  146. package/dist/cdn/table/snice-table.esm.min.js.map +1 -1
  147. package/dist/cdn/table/snice-table.js +367 -59
  148. package/dist/cdn/table/snice-table.js.map +1 -1
  149. package/dist/cdn/table/snice-table.min.js +155 -94
  150. package/dist/cdn/table/snice-table.min.js.map +1 -1
  151. package/dist/cdn/tabs/snice-tabs.js +2 -2
  152. package/dist/cdn/tag/snice-tag.js +2 -2
  153. package/dist/cdn/tag-input/snice-tag-input.js +2 -2
  154. package/dist/cdn/terminal/snice-terminal.js +3 -2
  155. package/dist/cdn/terminal/snice-terminal.js.map +1 -1
  156. package/dist/cdn/terminal/snice-terminal.min.js +1 -0
  157. package/dist/cdn/terminal/snice-terminal.min.js.map +1 -1
  158. package/dist/cdn/testimonial/snice-testimonial.js +2 -2
  159. package/dist/cdn/textarea/snice-textarea.js +2 -2
  160. package/dist/cdn/time-picker/snice-time-picker.js +2 -2
  161. package/dist/cdn/time-range-picker/snice-time-range-picker.js +2 -2
  162. package/dist/cdn/timeline/snice-timeline.js +2 -2
  163. package/dist/cdn/timer/snice-timer.js +2 -2
  164. package/dist/cdn/toast/snice-toast.js +2 -2
  165. package/dist/cdn/tooltip/snice-tooltip.js +2 -2
  166. package/dist/cdn/tree/snice-tree.js +2 -2
  167. package/dist/cdn/treemap/snice-treemap.js +2 -2
  168. package/dist/cdn/user-card/snice-user-card.js +2 -2
  169. package/dist/cdn/video-player/README.md +1 -1
  170. package/dist/cdn/video-player/snice-video-player.js +3 -2
  171. package/dist/cdn/video-player/snice-video-player.js.map +1 -1
  172. package/dist/cdn/video-player/snice-video-player.min.js +1 -0
  173. package/dist/cdn/video-player/snice-video-player.min.js.map +1 -1
  174. package/dist/cdn/virtual-scroller/snice-virtual-scroller.js +2 -2
  175. package/dist/cdn/waterfall/snice-waterfall.js +2 -2
  176. package/dist/cdn/weather/snice-weather.js +2 -2
  177. package/dist/cdn/work-order/snice-work-order.js +2 -2
  178. package/dist/components/recipe/snice-recipe.js +1 -1
  179. package/dist/components/recipe/snice-recipe.js.map +1 -1
  180. package/dist/components/table/snice-table.d.ts +1 -0
  181. package/dist/components/table/snice-table.js +18 -2
  182. package/dist/components/table/snice-table.js.map +1 -1
  183. package/dist/components/table/table-tree-data.js +1 -0
  184. package/dist/components/table/table-tree-data.js.map +1 -1
  185. package/dist/components/terminal/snice-terminal.js +1 -0
  186. package/dist/components/terminal/snice-terminal.js.map +1 -1
  187. package/dist/components/video-player/snice-video-player.js +1 -0
  188. package/dist/components/video-player/snice-video-player.js.map +1 -1
  189. package/dist/context-provider.d.ts +16 -0
  190. package/dist/daemon-target.d.ts +10 -0
  191. package/dist/daemon.d.ts +10 -0
  192. package/dist/index.cjs +3721 -3329
  193. package/dist/index.cjs.map +1 -1
  194. package/dist/index.d.ts +3 -0
  195. package/dist/index.esm.js +3719 -3330
  196. package/dist/index.esm.js.map +1 -1
  197. package/dist/index.iife.js +3721 -3329
  198. package/dist/index.iife.js.map +1 -1
  199. package/dist/keyboard-filter.d.ts +25 -0
  200. package/dist/on.d.ts +1 -1
  201. package/dist/parts.d.ts +0 -17
  202. package/dist/react/SniceProvider.js +2 -2
  203. package/dist/react/SniceRouter.js +2 -2
  204. package/dist/react/index.js +2 -2
  205. package/dist/react/matchRoute.js +2 -2
  206. package/dist/react/useRequestHandler.js +2 -2
  207. package/dist/request-response.d.ts +9 -1
  208. package/dist/symbols.cjs +11 -2
  209. package/dist/symbols.cjs.map +1 -1
  210. package/dist/symbols.d.ts +3 -0
  211. package/dist/symbols.esm.js +9 -3
  212. package/dist/symbols.esm.js.map +1 -1
  213. package/dist/testing.d.ts +1 -1
  214. package/dist/transitions.cjs +2 -2
  215. package/dist/transitions.esm.js +2 -2
  216. package/dist/types/app-context.d.ts +9 -58
  217. package/dist/types/daemon.d.ts +8 -0
  218. package/dist/types/dispatch-options.d.ts +2 -0
  219. package/dist/types/index.d.ts +1 -0
  220. package/dist/types/on-options.d.ts +5 -0
  221. package/dist/types/request-options.d.ts +2 -0
  222. package/dist/types/respond-options.d.ts +2 -0
  223. package/docs/ai/DEVELOPMENT.md +15 -1
  224. package/docs/ai/README.md +5 -1
  225. package/docs/ai/api.md +13 -4
  226. package/docs/ai/architecture.md +50 -1
  227. package/docs/ai/cli.md +9 -0
  228. package/docs/ai/components/avatar.md +8 -8
  229. package/docs/ai/components/breadcrumbs.md +2 -1
  230. package/docs/ai/components/button.md +2 -7
  231. package/docs/ai/components/calendar.md +1 -1
  232. package/docs/ai/components/camera.md +1 -1
  233. package/docs/ai/components/chart.md +3 -1
  234. package/docs/ai/components/code-block.md +2 -2
  235. package/docs/ai/components/date-picker.md +5 -19
  236. package/docs/ai/components/date-range-picker.md +4 -12
  237. package/docs/ai/components/draw.md +5 -5
  238. package/docs/ai/components/drawer.md +4 -4
  239. package/docs/ai/components/form-layout.md +2 -0
  240. package/docs/ai/components/icons.md +7 -16
  241. package/docs/ai/components/key-value.md +3 -22
  242. package/docs/ai/components/layout.md +8 -12
  243. package/docs/ai/components/leaderboard.md +2 -2
  244. package/docs/ai/components/link-preview.md +4 -3
  245. package/docs/ai/components/login.md +11 -0
  246. package/docs/ai/components/markdown.md +7 -0
  247. package/docs/ai/components/masonry.md +6 -0
  248. package/docs/ai/components/menu.md +1 -1
  249. package/docs/ai/components/modal.md +7 -0
  250. package/docs/ai/components/notification-center.md +5 -4
  251. package/docs/ai/components/radio.md +7 -0
  252. package/docs/ai/components/rating.md +3 -3
  253. package/docs/ai/components/select.md +4 -13
  254. package/docs/ai/components/spotlight.md +2 -0
  255. package/docs/ai/components/table.md +1 -4
  256. package/docs/ai/components/tag-input.md +6 -0
  257. package/docs/ai/components/terminal.md +6 -0
  258. package/docs/ai/components/tooltip.md +10 -16
  259. package/docs/ai/components/tree.md +2 -2
  260. package/docs/ai/components/video-player.md +5 -0
  261. package/docs/ai/components/waterfall.md +7 -0
  262. package/docs/ai/daemons.md +80 -0
  263. package/docs/ai/decorators.md +6 -4
  264. package/docs/ai/events.md +35 -0
  265. package/docs/ai/patterns.md +45 -1
  266. package/docs/ai/request-response.md +26 -9
  267. package/docs/ai/routing.md +16 -1
  268. package/docs/cli.md +7 -0
  269. package/docs/components/breadcrumbs.md +2 -1
  270. package/docs/components/calendar.md +1 -1
  271. package/docs/components/camera.md +1 -1
  272. package/docs/components/chart.md +1 -1
  273. package/docs/components/code-block.md +13 -4
  274. package/docs/components/color-picker.md +6 -5
  275. package/docs/components/date-time-picker.md +14 -0
  276. package/docs/components/diff.md +2 -1
  277. package/docs/components/draw.md +5 -5
  278. package/docs/components/drawer.md +4 -4
  279. package/docs/components/input.md +1 -0
  280. package/docs/components/layout.md +20 -22
  281. package/docs/components/leaderboard.md +10 -3
  282. package/docs/components/link-preview.md +11 -9
  283. package/docs/components/login.md +4 -0
  284. package/docs/components/menu.md +1 -1
  285. package/docs/components/modal.md +1 -0
  286. package/docs/components/nav.md +1 -0
  287. package/docs/components/network-graph.md +1 -0
  288. package/docs/components/notification-center.md +2 -1
  289. package/docs/components/product-card.md +1 -0
  290. package/docs/components/qr-reader.md +1 -0
  291. package/docs/components/rating.md +4 -4
  292. package/docs/components/select.md +1 -0
  293. package/docs/components/spotlight.md +2 -0
  294. package/docs/components/tabs.md +1 -0
  295. package/docs/components/terminal.md +3 -0
  296. package/docs/components/textarea.md +1 -1
  297. package/docs/components/time-picker.md +14 -0
  298. package/docs/components/tooltip.md +2 -0
  299. package/docs/components/tree.md +2 -2
  300. package/docs/daemons.md +200 -0
  301. package/docs/events.md +92 -2
  302. package/docs/request-response.md +20 -13
  303. package/docs/routing.md +25 -1
  304. package/package.json +6 -4
@@ -1,2 +1,2 @@
1
- globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const e=globalThis.snice;function t(e){return Symbol.for(`snice:${e}`)}const n=t("is-controller-class"),o=t("is-controller-instance"),r=t("is-element-class"),s=t("channel-handlers"),i=t("ready-promise"),a=t("ready-resolve"),c=t("rendered-promise"),l=t("rendered-resolve"),h=t("pending-reconnect-render"),u=t("render-depth"),d=t("render-root"),f=t("element-options"),m=t("controller"),p=t("initialized"),y=t("controller-key"),g=t("controller-name"),b=t("controller-id"),w=t("controller-operations"),v=t("native-controller"),E=t("direct-controller"),N=t("pending-controller-binding"),S=t("cleanup"),A=t("properties"),_=t("property-values"),T=t("property-defaults"),C=t("property-wrappers"),O=t("pre-init-property-values"),x=t("pre-upgrade-property-bindings"),k=t("properties-initialized"),$=t("property-watchers"),L=t("explicitly-set-properties"),P=t("router-context"),j=t("page-transition"),M=t("created-at"),R=t("ready-handlers"),I=t("dispose-handlers"),D=t("reconnect-handlers"),V=t("moved-handlers"),q=t("adopted-handlers"),B=t("observers"),F=t("setting-from-property"),W=t("moved-timers"),z=t("adopted-timers"),U=t("dispatch-timers"),H=t("render-method"),K=t("render-options"),G=t("render-instance"),Q=t("render-timers"),J=t("render-callbacks"),X=t("styles-method"),Y=t("styles-applied"),Z=t("parent-styles-methods"),ee=t("snice-element-base"),te=t("context-handler"),ne=t("navigation-context-instance"),oe=t("registered-elements"),re=t("is-updating"),se=t("context-register"),ie=t("context-unregister"),ae=t("context-notify-element"),ce=t("context-timer"),le=t("context-called"),he=t("context-update"),ue=t("context-methods"),de=t("watch-methods"),fe=t("observe-methods"),me=t("on-methods"),pe=t("respond-methods"),ye=t("ready-methods"),ge=t("dispose-methods"),be=t("reconnect-methods"),we=t("moved-methods"),ve=t("adopted-methods"),Ee=t("controller-abort"),Ne=t("controller-attached"),Se=t("property-definers");class Ae{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(Ae.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${Ae.SEPARATOR}" (U+FF0C)`);return e}if("number"==typeof e||"boolean"==typeof e)return String(e);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof e)}).join(Ae.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(Ae.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var _e,Te,Ce,Oe;!function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(_e||(_e={}));const xe=Symbol.for("snice:registered-elements-set");let ke=0;class $e{constructor(e={},t=[],n="",o={},r){if(this[Te]=new WeakMap,this[Ce]=new Set,this[Oe]=!1,this.id=ke++,this.application=e,this.navigation={placards:t,route:n,params:o},r&&"function"==typeof r.create)this.fetch=r.create(this);else{if("function"!=typeof fetch)throw new Error("No fetch implementation available");this.fetch=fetch.bind(this)}}[(Te=oe,Ce=xe,Oe=re,se)](e,t){const n=this[oe];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[xe].add(e)}[ie](e,t){const n=this[oe];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[xe].delete(e)}[he](e,t,n,o){this.application=e,this.navigation.placards=t,this.navigation.route=n,this.navigation.params=o,this.notify()}update(){this.notify()}notify(){if(this[re])return;this[re]=!0;const e=this[xe],t=this[oe];for(const n of e){const e=t.get(n);if(e)for(const t of e)if("function"==typeof n[t])try{n[t](this)}catch(e){console.error(`Error calling @context method ${t}:`,e)}}this[re]=!1}[ae](e){const t=this[oe].get(e);if(t)for(const n of t)"function"==typeof e[n]&&e[n](this)}}function Le(e){if(null!=e)return"string"==typeof e?String:"number"==typeof e?Number:"boolean"==typeof e?Boolean:e instanceof Date?Date:"bigint"==typeof e?BigInt:Array.isArray(e)?Array:void 0}function Pe(e,t,n,o){const r=t.type||Le(o);if(t.converter?.fromAttribute)return t.converter.fromAttribute(e,r);switch(r){case Boolean:return null!==e&&"false"!==e;case Number:return null!==e?Number(e):null;case String:return e;case Date:return e?new Date(e):null;case BigInt:return e&&e.endsWith("n")?BigInt(e.slice(0,-1)):e?BigInt(e):null;case Ae:return Ae.parse(e);case Array:try{return e?JSON.parse(e):[]}catch{return[]}case Object:try{return e?JSON.parse(e):{}}catch{return{}}default:return"number"==typeof n&&null!==e?Number(e):e}}function je(e,t){return e!==t&&(e==e||t==t)}function Me(e,t){return"string"==typeof e.attribute?e.attribute.toLowerCase():!0===e.attribute||"kebab"===e.attributeNaming?t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase():t.toLowerCase()}function Re(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Ie(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function De(e,t={}){let n;try{n=String(e??"")}catch{return!1}if(!n||/[\u0000-\u001f\u007f]/.test(n))return!1;const o=n.trim();if(!o)return!1;const r=t.allowed??["http:","https:","mailto:","tel:"];try{const e=new URL(o,"http://__snice-relative.invalid/"),t=/^[a-z][a-z\d+.-]*:/i.test(o),n=/^[\\/]{2}/.test(o);return!t&&!n||r.some(t=>"string"==typeof t&&t.toLowerCase()===e.protocol)}catch{return!1}}function Ve(e){const t=String(e).trim(),n=parseFloat(t);let o;return o=isNaN(n)?0:/ms$/i.test(t)?n:/s$/i.test(t)?1e3*n:/m$/i.test(t)?6e4*n:/h$/i.test(t)?36e5*n:n,{milliseconds:()=>o,seconds:()=>o/1e3,minutes:()=>o/6e4}}function qe(e,t){return e[t]||(e[t]=new Set),e[t]}function Be(e,t){return e[t]||(e[t]={}),e[t]}function Fe(e,t,n,o,r){const s=t[$];if(!s)return;const i=[n],a=t[A]?.get(n),c=a&&"string"==typeof a.attribute?a.attribute:null;c&&c!==n&&i.push(c);for(const t of i)if(s.has(t))for(const i of s.get(t))try{i.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('${t}') method ${i.methodName}:`,e)}if(s.has("*"))for(const t of s.get("*"))try{t.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('*') method ${t.methodName}:`,e)}}function We(e,t){let n=null;return function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)}}function ze(e,t){let n=0,o=null;return function(...r){const s=Date.now(),i=t-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,e.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,e.apply(this,r)},i))}}function Ue(e,t){if(null==t)return e;if("global"===t)return"undefined"!=typeof document?document:null;if("function"==typeof t)try{return t.call(e)||null}catch{return null}return"string"==typeof t?e.closest?.(t)||null:t&&"function"==typeof t.addEventListener?t:null}function He(e,t,n){if(null==e||!1===e||t?.type===Ae&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Le(n)){case Boolean:return"true";case Date:return e instanceof Date?e.toISOString():String(e);case BigInt:return"bigint"==typeof e?e.toString()+"n":String(e);case Ae:return Array.isArray(e)?Ae.serialize(e):String(e);case Array:return Array.isArray(e)?JSON.stringify(e):String(e);case Object:return"object"==typeof e&&null!==e?JSON.stringify(e):String(e);default:return String(e)}}const Ke=new WeakSet,Ge=new Map;function Qe(e,t,n){let o,r;return"string"==typeof t?(o=t,r=n):(o=void 0,r=t),function(t,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,fe)||(n[fe]=new Set),n[fe].has(t))return;if(n[fe].add(t),!Object.prototype.hasOwnProperty.call(n,B)){const e=n[B];n[B]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[B].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}}function Je(e,t){const n=e.constructor[B];if(n&&Array.isArray(n)&&0!==n.length){e[S]?e[S].observers||(e[S].observers=[]):e[S]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?ze(n,o.options.throttle):n;switch(o.type){case"intersection":Xe(e,t,o,r);break;case"resize":Ye(e,t,o,r);break;case"media":Ze(e,0,o,r);break;case"mutation":et(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function Xe(e,t,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");const s=new IntersectionObserver(e=>{for(const t of e)try{!1===o(t)&&s&&s.unobserve(t.target)}catch(e){console.error(`Error in intersection observer ${n.methodName}:`,e)}},r),i=n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t];i.forEach(e=>s.observe(e)),e[S].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function Ye(e,t,n,o){const r=n.options?.box||"content-box";if("undefined"==typeof ResizeObserver)return void console.warn("ResizeObserver is not available in this environment");const s=new ResizeObserver(e=>{for(const t of e)try{o(t)}catch(e){console.error(`Error in resize observer ${n.methodName}:`,e)}});(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t]).forEach(e=>{s.observe(e,{box:r})}),e[S].observers.push(()=>{s.disconnect()})}function Ze(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Ge.get(r);if(!s)try{s=window.matchMedia(r),Ge.set(r,s)}catch(e){return void console.error(`Invalid media query: ${r}`,e)}const i=e=>{try{o(e.matches)}catch(e){console.error(`Error in media query observer ${n.methodName}:`,e)}};i(s);const a=e=>i(e);s.addEventListener?(s.addEventListener("change",a),e[S].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[S].observers.push(()=>{s.removeListener(a)}))}function et(e,t,n,r){const s=n.target.split(":"),i=s[0]||"childList",a=s[1],c={};switch(i){case"childList":c.childList=!0;break;case"attributes":c.attributes=!0,a&&(c.attributeFilter=[a]);break;default:return void(/^[.#[]/.test(i)?console.warn(`@observe: "mutation:${i}" — "${i}" looks like a selector. Selectors are the second argument — did you mean @observe('mutation:childList', '${i}')?`):console.warn(`Unknown mutation type: ${i} (expected childList or attributes)`))}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=!(!n.options?.maxDepth||!n.options.subtree),h=new MutationObserver(e=>{try{if(!l)return void r(e);const o=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<o;)n=n.parentNode,t++;return t<o});i.length>0&&r(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),u=!0===e[o];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):u&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{h.observe(e,c)}),e[S].observers.push(()=>{h.disconnect()})}function tt(e){if(e[S]?.observers){for(const t of e[S].observers)t();e[S].observers=[]}}function nt(e,t){return function(n,r){let s,i,a=0;const c=[];return async function(...r){const l=async()=>{const s=t?.timeout??12e4,i=t?.discoveryTimeout??50,a=n.apply(this,r),{value:c,done:l}=await a.next();if(l)return c;let h,u;const d=new Promise((e,t)=>{h=e,u=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${i}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},i)}),b=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:h,reject:u}}});(!0===this[o]&&this.element?this.element:this).dispatchEvent(b);try{await g;const t=setTimeout(()=>{u(new Error(`Request "${e}" timed out after ${s}ms`))},s),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(s),s=setTimeout(async()=>{try{e(await l())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return l();const h=Date.now(),u=t.throttle-(h-a);if(u<=0){clearTimeout(i),i=null,a=h;const e=c.splice(0),t=l();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(i?(e,t)=>{c.push({resolve:e,reject:t})}:(e,t)=>{c.push({resolve:e,reject:t}),i=setTimeout(async()=>{a=Date.now(),i=null;const e=c.splice(0);try{const t=await l();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},u)})}}}function ot(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,pe)||(o[pe]=new Set),!o[pe].has(n)){if(o[pe].add(n),!Object.prototype.hasOwnProperty.call(o,s)){const e=o[s];o[s]=e?[...e]:[]}o[s].push({channelName:e,methodName:r,method:n,options:t})}})}}function rt(e,t){const n=e.constructor[s];if(n){e[S]||(e[S]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const h=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),u=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(h(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};t.addEventListener(r,u),e[S].channels.push(()=>{t.removeEventListener(r,u)})}}}function st(e){if(e[S]?.channels){for(const t of e[S].channels)t();e[S].channels=[]}}const it=Symbol.for("snice:html-result"),at=Symbol.for("snice:css-result"),ct=new WeakMap;function lt(e,...t){return{_$litType$:it,strings:e,values:t}}function ht(e,...t){return{_$litType$:it,strings:e,values:t,svg:!0}}function ut(e,...t){const n=0===t.length?ct.get(e):void 0;if(n)return n;let o=e[0];for(let n=0;n<t.length;n++){const r=t[n];o+=(ft(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:at,cssText:o};if("undefined"!=typeof CSSStyleSheet&&"undefined"!=typeof Document&&"adoptedStyleSheets"in Document.prototype)try{const e=new CSSStyleSheet;e.replaceSync(o),r.styleSheet=e}catch(e){}return 0===t.length&&ct.set(e,r),r}function dt(e){return e&&e._$litType$===it}function ft(e){return e&&e._$litType$===at}const mt=Symbol.for("snice:nothing"),pt=Symbol.for("snice:unsafe-html");function yt(e){return{_$litType$:pt,html:e}}function gt(e){return e&&e._$litType$===pt}const bt=Symbol.for("snice:repeat-result");function wt(e,t){if(!t||"function"!=typeof t.key||"function"!=typeof t.render)throw new TypeError("snice: repeat() requires { key, render }.");const n=null==e?[]:Array.from(e),o=n.map(t.key),r=new Set;for(const e of o){if(r.has(e))throw new Error(`snice: repeat() received duplicate key ${String(e)}.`);r.add(e)}return{_$repeat$:bt,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}}const vt=new WeakSet;function Et(e){return e[d]||e.shadowRoot||null}function Nt(e){const t=Et(e);if(t)return t;const n=e.constructor[f];let o;if(o="light"===n?.renderRoot||!1===n?.shadow?e:"function"==typeof e.createRenderRoot?e.createRenderRoot():e.attachShadow({mode:"string"==typeof n?.shadow?n.shadow:"open",delegatesFocus:n?.delegatesFocus}),o!==e&&!(o instanceof ShadowRoot))throw new TypeError("snice: createRenderRoot() must return the host element or a ShadowRoot.");return e[d]=o,vt.add(e),o}function St(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&vt.has(n))return n;n=n.parentNode}return null}const At=`snice$${Math.random().toFixed(9).slice(2)}$`,_t="?"+At,Tt=`\x3c!--${_t}--\x3e`,Ct=new RegExp(At.replace(/\$/g,"\\$"),"g"),Ot=new WeakMap,xt=Symbol("not-committed");function kt(e,t){const n=e.localName;if(!n?.includes("-"))return;const o=e.ownerDocument?.defaultView?.customElements??globalThis.customElements;if(o?.get(n))return;const r=e;r[x]||(r[x]=new Set),r[x].add(t)}const $t=Symbol.for("snice:no-change"),Lt=Symbol.for("snice:live");function Pt(e){return{_$liveMarker$:Lt,value:e}}const jt=e=>null===e||"object"!=typeof e&&"function"!=typeof e,Mt=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class Rt{constructor(e,t,n){this.parts=[],this.keyIndex=-1,this.element=t;const o=document.createTreeWalker(t.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let r=0;const s=[];let i;for(;null!==(i=o.nextNode());)if(i.nodeType===Node.ELEMENT_NODE){const e=i,t=e.tagName.toLowerCase(),o=e.parentElement?.tagName.toLowerCase();if(("else"===t||"else-if"===t)&&"if"!==o)throw new Error(`snice: <${t}> must be a direct child of <if>.`);if(("when"===t||"default"===t)&&"case"!==o)throw new Error(`snice: <${t}> must be a direct child of <case>.`);if("if"===t){const t=e.getAttribute("value");if(!t||!t.includes(At))throw new Error("snice: <if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-if",index:r++,element:e});continue}if("case"===t){const t=e.getAttribute("value");if(!t||!t.includes(At))throw new Error("snice: <case> requires a value expression.");for(const t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("when"!==e&&"default"!==e)throw new Error("snice: <case> may contain only direct <when> and <default> branches.")}else if(t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()||t.nodeType===Node.COMMENT_NODE&&t.data.includes(At))throw new Error("snice: content inside <case> must be nested in a <when> or <default> branch.");e.removeAttribute("value"),this.parts.push({type:"conditional-case",index:r++,element:e});continue}if("else-if"===t){const t=e.getAttribute("value");if(!t||!t.includes(At))throw new Error("snice: <else-if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-else-if",index:r++,element:e});continue}if("when"===t){const t=e.getAttribute("value");t&&t.includes(At)&&(e.removeAttribute("value"),this.parts.push({type:"conditional-when",index:r++,element:e}));continue}if(e.hasAttributes()){const t=e.attributes,o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i.value;if(a.includes(At)){o.push(i);const t=n[r]||i.name,s=a.split(At),c=s.length-1;if(/^@@?|^[.?]/.test(t)||t.startsWith("...")||t.startsWith("class:")||t.startsWith("style:")){const e=s.some(e=>""!==e);(c>1||e)&&console.warn(`snice: binding "${t}" takes a single expression; static text and extra interpolations are ignored. Use a plain attribute for string interpolation.`)}if(t.startsWith("...")){const n=t.slice(3).toLowerCase();if(!["props","properties","attrs","attributes","events"].includes(n))throw new Error(`snice: unknown spread binding "${t}". Use ...props, ...attrs, or ...events.`);this.parts.push({type:"spread",index:r,name:n,element:e}),r+=c}else if(t.startsWith("class:")){if(!t.slice(6))throw new Error("snice: class: binding requires a class name.");this.parts.push({type:"class",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("style:")){if(!t.slice(6))throw new Error("snice: style: binding requires a CSS property name.");this.parts.push({type:"style",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("@@")){if(!t.slice(2).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("@")){if(!t.slice(1).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith(".")){if(!t.slice(1))throw new Error("snice: property binding requires a property name.");this.parts.push({type:"property",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("?")){if(!t.slice(1))throw new Error("snice: boolean binding requires an attribute name.");this.parts.push({type:"boolean-attribute",index:r,name:t.slice(1),element:e}),r+=c}else"controller"===i.name&&2===s.length&&""===s[0]&&""===s[1]?(this.parts.push({type:"controller",index:r,element:e}),r+=c):(this.parts.push({type:"attribute",index:r,name:i.name,element:e,attrStrings:s}),r+=c)}}for(const t of o)e.removeAttribute(t.name)}}else if(i.nodeType===Node.COMMENT_NODE){const e=i;if(e.data===_t){const t=e.parentNode,n=document.createComment("");t.insertBefore(n,e.nextSibling),this.parts.push({type:"node",index:r++,startNode:e,endNode:n})}else if(e.data.includes(At)){const t=e.data.split(Ct);this.parts.push({type:"comment",index:r,startNode:e,attrStrings:t}),r+=t.length-1}}else if(i.nodeType===Node.TEXT_NODE){const e=i,t=e.data;if(t.includes(At)){const n=e.parentNode,o=t.split(Ct),i=o.length-1;for(let t=0;t<i;t++){n.insertBefore(document.createTextNode(o[t]),e);const s=document.createComment(""),i=document.createComment("");n.insertBefore(s,e),n.insertBefore(i,e),this.parts.push({type:"node",index:r++,startNode:s,endNode:i})}""!==o[i]?e.data=o[i]:s.push(e)}}for(const e of s)e.parentNode?.removeChild(e);for(const e of this.parts)if("attribute"===e.type&&"key"===e.name){this.keyIndex=e.index;break}}}function It(e){const{strings:t}=e,n=Ot.get(t);if(n)return n;const o=[],r=[];let s=!1,i=!1,a=!1,c="",l="";for(let e=0;e<t.length;e++){const n=t[e];if(o.push(n),e<t.length-1){for(let e=0;e<n.length;e++){const t=n[e];if(a)"-"===t&&n.startsWith("--\x3e",e)&&(a=!1,e+=2);else if(s){if(i)t===c&&(i=!1,c="");else if(">"===t)s=!1;else if('"'===t||"'"===t)i=!0,c=t;else if("="===t){let t=e-1;for(;t>=0&&/[\w\-\.@\?/:\+~|]/.test(n[t]);)t--;l=n.substring(t+1,e).trim()}}else"<"===t&&(n.startsWith("\x3c!--",e)?(a=!0,e+=3):/[A-Za-z!/?]/.test(n[e+1]||"")&&(s=!0))}if(a)r.push(""),o.push(At);else if(i)r.push(l),o.push(At);else if(s){const e=n.trimEnd();if(e.endsWith("=")){let t=e.length-2;for(;t>=0&&/[\w\-\.@\?\/:\+~|]/.test(e[t]);)t--;l=e.substring(t+1,e.length-1).trim(),r.push(l),o.push(At)}else{if(!n.match(/<(if|else-if|case|when)\s*$/))throw new Error("snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding.");l="value",r.push("value"),o.push(`value="${At}"`)}}else r.push(""),o.push(Tt)}}const h=o.join(""),u=document.createElement("template");if(e.svg){u.innerHTML=`<svg>${h}</svg>`;const e=u.content.firstElementChild;for(;e.firstChild;)u.content.insertBefore(e.firstChild,e);u.content.removeChild(e)}else u.innerHTML=h;const d=new Rt(e,u,r);return Ot.set(t,d),d}function Dt(e){if(!dt(e))return;const t=It(e);return-1===t.keyIndex?void 0:e.values[t.keyIndex]}class Vt{constructor(e){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.template=It(e),this.strings=e.strings}isSameTemplate(e){return this.strings===e}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new Bt(e,r);break;case"attribute":const i=n.get(t.element);o=new Ft(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new Kt(a,t.name);break;case"boolean-attribute":const c=n.get(t.element);o=new Qt(c,t.name);break;case"event":const l=n.get(t.element);o=new Jt(l,t.name);break;case"class":const h=n.get(t.element);o=new zt(h,t.name);break;case"style":const u=n.get(t.element);o=new Ut(u,t.name);break;case"spread":const d=n.get(t.element);o=new Ht(d,t.name);break;case"controller":const f=n.get(t.element);o=new Gt(f);break;case"conditional-if":const m=n.get(t.element);o=new on(m);break;case"conditional-else-if":const p=n.get(t.element);o=new sn(p);break;case"conditional-case":const y=n.get(t.element);o=new an(y,s);break;case"conditional-when":const g=n.get(t.element);o=new ln(g);break;case"comment":const b=n.get(t.startNode);o=new Wt(b,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof on||o instanceof sn||o instanceof an||o instanceof ln?this.conditionalParts.push({part:o,index:t.index}):this.regularParts.push({part:o,index:t.index})}}return this.fragment}render(e){const t=this.renderFragment();return this.update(e),t}update(e){for(const{part:t,index:n}of this.conditionalParts)t.commit(e[n]);const t=new Set;for(const{part:e}of this.conditionalParts){const n=e instanceof sn||e instanceof ln?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof on||n instanceof an)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof Ft&&void 0!==t.strings||t instanceof Wt?t.commit(e,n):t.commit(e[n]);let n;for(const e of this.parts)try{e.isConnected?e.reconnected():e.disconnected()}catch(e){n??=e}if(n)throw n}clear(){let e;for(const t of this.parts)try{t.destroy()}catch(t){e??=t}if(e)throw e}disconnected(e=!1){let t;for(const n of this.parts)try{n.disconnected(e)}catch(e){t??=e}if(t)throw t}reconnected(){let e;for(const t of this.parts)try{t.reconnected()}catch(t){e??=t}if(e)throw e}}class qt{get isConnected(){return this.element?.isConnected??!1}disconnected(e=!1){}reconnected(){}destroy(){let e;try{this.clear()}catch(t){e=t}if(e)throw e}}class Bt extends qt{constructor(e,t){super(),this.type="node",this._committedValue=xt,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t}commit(e){if(e!==$t)if((e=>!!e&&"function"==typeof e.then)(e)||Mt(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==mt&&null!=e&&""!==e)jt(e)?e!==this._committedValue&&this._commitText(e):dt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===bt}(e)?0===e.values.length?this.commit(e.empty??mt):this._commitIterable(e.values,e.keys):gt(e)?this._commitUnsafeHTML(e):void 0===e.nodeType?(e=>Array.isArray(e)||"function"==typeof e?.[Symbol.iterator])(e)?this._commitIterable(e):this._commitText(e):this._commitNode(e);else{if(this._committedValue!==mt){const e=this._clear();if(this._committedValue=mt,e)throw e}this._committedValue=mt}}_commitText(e){if(this._committedValue!==xt&&this._committedValue!==mt&&jt(this._committedValue)&&!Array.isArray(this._committedValue)){const t=this.startNode.nextSibling;if(t&&t.nodeType===Node.TEXT_NODE)return t.data=String(e),void(this._committedValue=e)}const t=this._clear();if(this._insertBefore(document.createTextNode(String(e))),this._committedValue=e,t)throw t}_commitTemplateResult(e){const t=this._committedValue;if(t instanceof Vt){const n=Ot.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new Vt(e),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(Dt);if(o.length!==n.length)throw new Error("snice: keyed iterable produced a different number of keys and values.");const r=o.filter(e=>void 0!==e);if(r.length>0&&r.length!==o.length&&console.warn("snice: a list mixes keyed and unkeyed items. Identity falls back to position; use repeat(items, { key, render }) for deterministic updates."),r.length>0&&new Set(r).size!==r.length)throw new Error("snice: a keyed list contains duplicate keys.");let s;Array.isArray(this._committedValue)&&this._committedValue[0]instanceof Bt||(s=this._clear(),this._committedValue=[],this._itemKeys=null);const i=n.length>0&&o.every(e=>void 0!==e),a=this._itemKeys;if(i&&a&&this._committedValue.length>0&&(a.length!==o.length||!o.every((e,t)=>e===a[t]))){if(s??=this._reconcileKeyed(n,o,this._committedValue,a),this._itemKeys=o,s)throw s;return}const c=this._committedValue;let l=0;for(const e of n){let t;if(l>=c.length){const e=document.createComment(""),n=document.createComment("");this._insertBefore(e),this._insertBefore(n),t=new Bt(e,n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new Bt(e,o),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(gt(t)&&t.html===e.html)return;const n=this._clear(),o=document.createElement("template");if(o.innerHTML=e.html,this._insertBefore(o.content),this._committedValue=e,n)throw n}_commitAsync(e){if(e===this._asyncSource)return;this._cancelAsync(!1),this._asyncSource=e,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1;const t=this._clear();if(this._committedValue=mt,this._startAsyncSource(),t)throw t}_startAsyncSource(e=!1){const t=this._asyncSource;if(!t||this._asyncRunning||this._asyncCompleted||!e&&!this.isConnected)return;this._asyncRunning=!0,this._asyncStarted=!0,this._asyncPaused=!1;const n=++this._asyncVersion;if(Mt(t)){try{this._asyncIterator=t[Symbol.asyncIterator]()}catch(e){return this._asyncRunning=!1,this._asyncCompleted=!0,void console.error("snice: async iterable template value failed:",e)}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",e)}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",e)}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",e))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=mt,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=mt,n}_disposeCommitted(e){let t;if(e instanceof Vt)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof Bt)try{n.destroy()}catch(e){t??=e}if(t)throw t}clear(){this._cancelAsync(!0);const e=this._clear();if(e)throw e}get isConnected(){return this.startNode.isConnected}disconnected(e=!1){let t;if(this._committedValue instanceof Vt)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof Bt)try{n.disconnected(e)}catch(e){t??=e}if(this._asyncSource&&this._asyncRunning&&(this._cancelAsync(!1),this._asyncPaused=!0),t)throw t}reconnected(){let e;if(this._committedValue instanceof Vt)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof Bt)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class Ft extends qt{constructor(e,t,n){super(),this.type="attribute",this._committedValue=xt,this.lastValues=null,this.lastValueIndex=0,this.element=e,this.name=t,n&&(n.length>2||""!==n[0]||""!==n[1])?(this._committedValue=new Array(n.length-1).fill(xt),this.strings=n):this._committedValue=xt}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===$t)return;if(o=!jt(e)||e!==this._committedValue&&e!==$t,!o)return;this._committedValue=e,n=e}else{const r=e;this.lastValues=[...r],this.lastValueIndex=t;const s=this._committedValue;n=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let i=r[t+e];i===$t&&(i=s[e],i===xt&&(i="")),o=o||!jt(i)||i!==s[e],i===mt?n=mt:n!==mt&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===mt?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class Wt extends qt{constructor(e,t){super(),this.type="node",this.lastValues=null,this.lastValueIndex=0,this.node=e,this.strings=t,this._committedValues=new Array(t.length-1).fill(xt)}commit(e,t=0){const n=e;this.lastValues=[...n],this.lastValueIndex=t;let o=!1,r=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let s=n[t+e];s===$t&&(s=this._committedValues[e],s===xt&&(s="")),o=o||!jt(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===mt?"":s??"")+this.strings[e+1]}if(o){if(r.includes("--")||r.endsWith("-"))throw new Error('snice: comment expressions cannot produce "--" or end with "-".');this.node.data=r}}clear(){}}class zt extends qt{constructor(e,t){super(),this.type="class",this.committed=xt,this.element=e,this.name=t}commit(e){if(e===$t)return;const t=e!==mt&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=xt}}class Ut extends qt{constructor(e,t){super(),this.type="style",this.committed=xt,this.element=e,this.name=t}commit(e){if(e===$t||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===mt||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=xt}}class Ht extends qt{constructor(e,t){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t}commit(e){if(e===$t)return;if(e!==mt&&null!=e||(e={}),"object"!=typeof e||Array.isArray(e))throw new TypeError(`snice: ...${this.name} expects an object.`);const t=e;"events"===this.name?this.commitEvents(t):"props"===this.name||"properties"===this.name?this.commitProperties(t):this.commitAttributes(t),this.committed={...t}}commitProperties(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||(kt(this.element,t),this.element[t]=void 0);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(kt(this.element,t),this.element[t]=n===mt?void 0:n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===mt||null==n||!1===n?this.element.removeAttribute(t):this.element.setAttribute(t,!0===n?"":String(n)))}commitEvents(e){!function(e,t){const n=new Set;for(const[o,r]of Object.entries(e)){const e=o.startsWith("@")?o.slice(1):o;if(!e)throw new TypeError(`snice: ${t} contains an empty event name.`);if(n.has(e))throw new TypeError(`snice: ${t} contains duplicate event name "${e}".`);if(n.add(e),r!==mt&&null!=r&&!1!==r&&"function"!=typeof r&&(!r||"object"!=typeof r||"function"!=typeof r.handleEvent))throw new TypeError(`snice: ${t} event "${e}" expects a function, EventListenerObject, or null.`)}}(e,`...${this.name}`);for(const[t,n]of this.consumedOnce){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n)||this.consumedOnce.delete(t)}for(const[t,n]of this.listeners){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n.value)||(this.element.removeEventListener(t,n.listener,n.options),this.listeners.delete(t))}for(const[t,n]of Object.entries(e)){const e=this.eventName(t);if(this.listeners.has(e))continue;const o=!!n&&"object"==typeof n&&"function"==typeof n.handleEvent;if(n===mt||null==n||!1===n)continue;if(this.consumedOnce.has(e)&&Object.is(this.consumedOnce.get(e),n))continue;this.consumedOnce.delete(e);const r=o?n:void 0,s=t=>{r?.once&&this.consumedOnce.set(e,n),o?n.handleEvent(t):n.call(this.resolveHost(),t)};this.element.addEventListener(e,s,r),this.listeners.set(e,{value:n,listener:s,options:r})}}eventName(e){return e.startsWith("@")?e.slice(1):e}resolveHost(){return St(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class Kt extends qt{constructor(e,t){super(),this.type="property",this._committedValue=xt,this.element=e,this.name=t}commit(e){if(e!==$t){if(function(e){return e&&e._$liveMarker$===Lt}(e)){if((e=e.value)===$t)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,kt(this.element,this.name),this.element[this.name]=e===mt?void 0:e}}clear(){this._committedValue=xt}}class Gt extends qt{constructor(e){super(),this.type="controller",this._committedValue=xt,this.element=e}commit(e){if(e===$t)return;const t=null==e||!1===e||""===e||e===mt?null:e,n=this._committedValue===xt,o=n?null:this._committedValue;if(!n&&t===o)return;this._committedValue=t;const s=this.element;"function"==typeof o&&"function"!=typeof t&&(void 0!==s[N]?delete s[N]:s[r]?s.controller=null:this._detach()),"function"==typeof t?(this.element.hasAttribute("controller")&&this.element.removeAttribute("controller"),this.isConnected?this._apply(t):this.element.localName.includes("-")&&!s[r]&&(s[N]=t)):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[r]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[N]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){vn(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){En(this.element).catch(e=>{console.error("Failed to detach controller:",e)})}disconnected(e=!1){if("function"!=typeof this._committedValue)return;const t=this.element;void 0===t[N]&&(t[r]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[N]&&delete e[N];const t=this._committedValue;this._committedValue=xt,"function"==typeof t&&(e[r]||this._detach())}}class Qt extends qt{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=xt,this.element=e,this.name=t}commit(e){if(e===$t)return;const t=!!e&&e!==mt;t!==this._committedValue&&(this._committedValue=t,t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name))}clear(){this.element.removeAttribute(this.name),this._committedValue=xt}}class Jt extends qt{constructor(e,t){super(),this.type="event",this.listener=null,this.listenerOptions=void 0,this.value=void 0,this.keyFilter=null,this.host=null,this.modifiers=new Set,this.once=!1,this.onceConsumed=!1,this.element=e;const[n,...o]=t.split("|"),r={preventdefault:"prevent",stoppropagation:"stop",stopimmediatepropagation:"immediate"},s=new Set(["prevent","stop","immediate","once","capture","passive","self"]);for(const e of o){const n=r[e.toLowerCase()]||e.toLowerCase();if(!s.has(n))throw new Error(`snice: unknown event modifier "${e}" in @${t}. Supported modifiers: prevent, stop, immediate, once, capture, passive, self.`);this.modifiers.add(n)}if(this.modifiers.has("passive")&&this.modifiers.has("prevent"))throw new Error(`snice: @${t} cannot combine passive and prevent.`);const i=["keydown","keyup","keypress"].includes(n.split(".")[0].split(":")[0]),a=i?n.indexOf("."):-1,c=i?n.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c);if(l>0){const e=n.substring(0,l),t=n.substring(l+1);this.eventName=e,this.keyFilter=Zt(t)}else this.eventName=n,Yt(n)}commit(e){if(e===$t)return;e===mt&&(e=null);const t=!!e&&"object"==typeof e&&"function"==typeof e.handleEvent;if(null!=e&&!1!==e&&"function"!=typeof e&&!t)throw new TypeError(`snice: @${this.eventName} expects a function, EventListenerObject, or null.`);if(t&&this.modifiers.has("prevent")&&e.passive)throw new Error(`snice: @${this.eventName} cannot combine a passive listener object with prevent.`);if(e!==this.value||null==e){if(this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0),null==e||!1===e)return this.value=e,void(this.onceConsumed=!1);this.onceConsumed=!1;try{this.attachListener(e,t),this.value=e}catch(e){throw this.value=void 0,e}}}attachListener(e,t){const n=this.keyFilter,o=r=>{this.modifiers.has("self")&&r.target!==this.element||n&&!tn(r,n)||(this.once&&(this.onceConsumed=!0,this.element.removeEventListener(this.eventName,o,s),this.listener=null,this.listenerOptions=void 0),this.modifiers.has("prevent")&&r.preventDefault(),this.modifiers.has("immediate")?r.stopImmediatePropagation():this.modifiers.has("stop")&&r.stopPropagation(),t?e.handleEvent(r):(this.host||(this.host=St(this.element)),e.call(this.host||this.element,r)))},r=t?e:{};this.once=this.modifiers.has("once")||!!r.once;const s={capture:this.modifiers.has("capture")||r.capture,passive:this.modifiers.has("passive")||r.passive,signal:r.signal};this.element.addEventListener(this.eventName,o,s),this.listener=o,this.listenerOptions=s}clear(){this.detachListener(),this.value=void 0,this.host=null,this.onceConsumed=!1}detachListener(){this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0)}disconnected(e=!1){e||this.detachListener(),this.host=null}reconnected(){this.listener||this.onceConsumed||null==this.value||!1===this.value||this.attachListener(this.value,"object"==typeof this.value)}}const Xt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function Yt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();Xt.has(n)&&console.warn(`snice: "@${e}" is not a valid modifier — once/preventDefault/stopPropagation/capture are @on() options, not template modifiers. This registers a listener for event "${e}", which never fires.`)}function Zt(e){const t=e.startsWith("~");t&&(e=e.substring(1));const n=e.split("+"),o={key:"",anyModifiers:t};for(const e of n){const t=e.toLowerCase();"ctrl"===t||"control"===t?o.ctrl=!0:"alt"===t?o.alt=!0:"shift"===t?o.shift=!0:"meta"===t||"cmd"===t||"command"===t?o.meta=!0:o.key=en(e)}return o}function en(e){return{esc:"Escape",escape:"Escape",enter:"Enter",return:"Enter",space:" ",spacebar:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",delete:"Delete",del:"Delete",backspace:"Backspace",tab:"Tab",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"}[e.toLowerCase()]||e}function tn(e,t){return e.key===t.key&&(!!t.anyModifiers||(t.ctrl?e.ctrlKey:!e.ctrlKey)&&(t.alt?e.altKey:!e.altKey)&&(t.shift?e.shiftKey:!e.shiftKey)&&(t.meta?e.metaKey:!e.metaKey))}const nn=Symbol("not-set");class on extends qt{constructor(e){super(),this.type="node",this.conditions=[nn],this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const t=e.parentNode;this.startNode=document.createComment("if"),this.endNode=document.createComment("/if"),t.insertBefore(this.startNode,e),t.insertBefore(this.endNode,e.nextSibling);const n=document.createDocumentFragment();this.branches.push(n);let o=!1,r=n;for(const t of Array.from(e.childNodes)){const e=t.nodeType===Node.ELEMENT_NODE?t.tagName.toLowerCase():"";if("else-if"===e||"else"===e){o=!0;const n=t,s=document.createDocumentFragment();for(;n.firstChild;)s.appendChild(n.firstChild);const i=this.branches.push(s)-1;if(r=s,"else-if"===e){if(-1!==this.defaultBranch)throw new Error("snice: <else> must be the final branch inside <if>.");this.conditions[i]=nn,rn.set(n,{coordinator:this,index:i})}else{if(-1!==this.defaultBranch)throw new Error("snice: <if> may contain only one <else> branch.");this.defaultBranch=i}n.remove();continue}o?t.nodeType!==Node.TEXT_NODE||t.textContent?.trim()?r.appendChild(t):t.remove():n.appendChild(t)}t.removeChild(e)}commit(e){e!==$t&&(this.conditions[0]=e)}setAlternative(e,t){t!==$t&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==nn&&this.conditions[t]!==mt&&Boolean(this.conditions[t])){e=t;break}-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e],this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch];let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const rn=new WeakMap;class sn extends qt{constructor(e){super(),this.type="node";const t=rn.get(e);if(!t)throw new Error("snice: <else-if> must be a direct child of <if>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setAlternative(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}class an extends qt{constructor(e,t){super(),this.type="node",this.value=nn,this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const n=e.parentNode;this.startNode=document.createComment("case"),this.endNode=document.createComment("/case"),n.insertBefore(this.startNode,e),n.insertBefore(this.endNode,e.nextSibling);for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();if("when"===e){const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);const o=t.has(n),r=this.branches.push({fragment:e,dynamic:o,expected:o?nn:n.getAttribute("value")??""})-1;o&&cn.set(n,{coordinator:this,index:r})}else if("default"===e){if(-1!==this.defaultBranch)throw new Error("snice: <case> may contain only one <default> branch.");const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);this.defaultBranch=this.branches.push({fragment:e,dynamic:!1,expected:nn})-1}}n.removeChild(e)}commit(e){e!==$t&&(this.value=e)}setExpected(e,t){t!==$t&&(this.branches[e].expected=t)}flush(){let e=this.branches.findIndex((e,t)=>t!==this.defaultBranch&&(e.dynamic?Object.is(this.value,e.expected):String(this.value)===e.expected));-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].fragment.hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e].fragment,this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch].fragment;let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const cn=new WeakMap;class ln extends qt{constructor(e){super(),this.type="node";const t=cn.get(e);if(!t)throw new Error("snice: dynamic <when> must be a direct child of <case>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setExpected(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}const hn=t("on-handlers");function un(e,t,n){let o=null,r={};return"string"==typeof t?(o=t,r=n||{}):t&&"object"==typeof t?r=t:null===t&&n&&(r=n),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}`;if(Object.prototype.hasOwnProperty.call(n,me)||(n[me]=new Set),!n[me].has(a)){if(n[me].add(a),!Object.prototype.hasOwnProperty.call(n,hn)){const e=n[hn];n[hn]=e?[...e]:[]}for(const e of i)n[hn].push({eventName:e,selector:o,methodName:s,method:t,options:r})}}),t}}function dn(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const fn=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function mn(e,t){const n=e.constructor[hn];if(n&&Array.isArray(n)&&0!==n.length){e[S]?e[S].events?e[S].events.length>0&&pn(e):e[S].events=[]:e[S]={events:[],channels:[],observers:[]};for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),a=i?o.eventName.indexOf("."):-1,c=i?o.eventName.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c),h=l>0?o.eventName.substring(0,l):o.eventName,u=l>0?o.eventName.substring(l+1):null;l<=0&&Yt(o.eventName),s.debounce&&s.debounce>0?r=We(r,s.debounce):s.throttle&&s.throttle>0&&(r=dn(r,s.throttle));let d=null;u&&["keydown","keyup","keypress"].includes(h)&&(d=Zt(u));const f=(e=>d?t=>{tn(t,d)&&e(t)}:e)(r),m=void 0!==s.scope;let p=null;if(!m||(p=Ue(t,s.scope),p))if(o.selector){const n=m?p:t.shadowRoot||t,r=e=>{const t=e.target;if(t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)){s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},i=fn.has(h),a={capture:void 0!==s.capture?s.capture:i,once:s.once||!1,passive:s.passive||!1};n.addEventListener(h,r,a),e[S].events.push({target:n,eventName:h,handler:r,options:a})}else{const n=m?null:t.shadowRoot,r=Symbol(),i=e=>{if(!e[r]){e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};if(m){p.addEventListener(h,i,a),e[S].events.push({target:p,eventName:h,handler:i,options:a});continue}n&&(n.addEventListener(h,i,a),e[S].events.push({target:n,eventName:h,handler:i,options:a})),t.addEventListener(h,i,a),e[S].events.push({target:t,eventName:h,handler:i,options:a})}else console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`)}}}function pn(e){if(e[S]?.events){for(const{target:t,eventName:n,handler:o,options:r}of e[S].events)t.removeEventListener(n,o,r);e[S].events=[]}}class yn{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(e,t){this.cleanupFns.set(e,t)}unregister(e){this.cleanupFns.delete(e)}async cleanup(){await Promise.all(this.pendingOperations);for(const e of this.cleanupFns.values())try{await e()}catch(e){console.error("Error during cleanup:",e)}this.cleanupFns.clear()}async runOperation(e){const t=e(),n=t.then(()=>{},()=>{});this.pendingOperations.add(n);try{const e=await t;return this.pendingOperations.delete(n),e}catch(e){throw this.pendingOperations.delete(n),e}}}function gn(t){return function(o,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(t,o),o.prototype[n]=!0;const i=e.pendingControllerAttachments.get(t);return i&&(e.pendingControllerAttachments.delete(t),queueMicrotask(()=>{for(const e of i){const n=e[v];(void 0===n?e[m]:n)===t&&vn(e,t).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${t}":`,e)})}})),o}}function bn(t,n){if(e.controllerRegistry.has(n))return void queueMicrotask(()=>{const e=t[v];(void 0===e?t[m]:e)===n&&vn(t,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=e.pendingControllerAttachments.get(n);o||(o=new Set,e.pendingControllerAttachments.set(n,o)),o.add(t),queueMicrotask(()=>{e.pendingControllerAttachments.get(n)?.has(t)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function wn(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}async function vn(t,r){if("string"!=typeof r){if("function"!=typeof r)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof r}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=r)||!0!==s.prototype?.[n])throw new Error(`Controller class "${wn(r)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=wn(r),a=t[y],c=t[v];if("string"==typeof r&&void 0!==c&&c!==r)return;if(t[g]===r&&a)return;let l;if(a&&await En(t),"string"==typeof r){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(r),!l)throw new Error(`Controller "${r}" not found in registry`)}else l=r,t[E]=!0,delete t[v];const h=new l;e.controllerIdCounter+=1;const u=e.controllerIdCounter,d=new yn;h[o]=!0,h[b]=u,h.element=t;const f=t[P];void 0!==f&&(h[P]=f),t[y]=h,t[g]=r,t[w]=d;const m=new AbortController;t[Ee]=m;try{await Promise.race([t.ready,new Promise((e,t)=>{const n=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",t(e)};if(m.signal.aborted)return n();m.signal.addEventListener("abort",n,{once:!0});const o=setTimeout(()=>t(new Error(`attachController("${i}"): element did not become ready within 30000ms (did you forget to appendChild it?)`)),3e4);m.signal.addEventListener("abort",()=>clearTimeout(o),{once:!0})})])}catch(e){throw t[y]===h&&(delete t[y],delete t[g],delete t[w],"string"!=typeof r&&delete t[E]),e}finally{t[Ee]===m&&delete t[Ee]}h[Ne]=!0,await d.runOperation(async()=>{await h.attach(t)}),Je(h,t),rt(h,t),mn(h,t),t.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:h}}))}async function En(e){const t=e[Ee];t&&t.abort();const n=e[y],o=e[g],r=e[w];n&&(delete e[y],delete e[g],delete e[w],"function"==typeof o&&delete e[E],n[Ne]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),n.element=null,tt(n),st(n),pn(n),r&&await r.cleanup(),delete n[P],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:wn(o),controller:n}}))))}function Nn(e){return e[y]}function Sn(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[r])return;if(e[E])return;const t=e.getAttribute("controller"),n=e[v];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[v],delete e[g],void En(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[v]=t,e.ready||(e.ready=Promise.resolve()),n&&En(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),vn(e,t).catch(n=>{"ControllerAttachAborted"!==n?.name?n?.message!==`Controller "${t}" not found in registry`?console.error(`Failed to attach controller "${t}" to native element:`,n):bn(e,t):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}globalThis.sniceNativeControllersInitialized=!0;const t=new MutationObserver(t=>{for(const n of t)"attributes"===n.type&&"controller"===n.attributeName?e(n.target):"childList"===n.type&&n.addedNodes.forEach(t=>{t instanceof HTMLElement&&(e(t),t.querySelectorAll("[controller]").forEach(e))})});function n(){document.querySelectorAll("[controller]").forEach(e),t.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(),globalThis.sniceNativeControllerObserver=t}const An=t("context-handlers");function _n(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,ue)||(n[ue]=new Set),!n[ue].has(t)){if(n[ue].add(t),!Object.prototype.hasOwnProperty.call(n,An)){const e=n[An];n[An]=e?[...e]:[]}n[An].push({methodName:o,method:t,options:e})}}),t}}function Tn(e){const t=e.constructor[An];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[te];if(n){e[ne]=n;for(const o of t){const{methodName:t,method:r,options:s}=o,i=`__wrapped_${t}`;e[i]=function(n){const o=e[le]||(e[le]=new Set);if(s.once&&o.has(t))return;const a=()=>{if(r.call(e,n),s.once){o.add(t);const n=e[ne];n&&"function"==typeof n[ie]&&n[ie](e,i)}},c=e[ce]||(e[ce]={}),l=t;if(s.debounce)return clearTimeout(c[l]?.timeout),void(c[l]={timeout:setTimeout(a,s.debounce)});if(s.throttle){const e=Date.now();return void(e-(c[l]?.lastCall||0)>=s.throttle&&(c[l]={lastCall:e},a()))}a()},"function"==typeof n[se]&&n[se](e,i)}}}let Cn=!1;function On(e){Cn=e}function xn(e){e[l]||(e[c]=new Promise(t=>{e[l]=t}))}function kn(e){const t=e[l];t&&(e[l]=null,t())}const $n=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?Mn(e,t):(this.pending.add(e),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush())))}flush(){const e=Array.from(this.pending);this.pending.clear(),this.scheduled=!1;for(const t of e)t.isConnected?Mn(t,t[K]||{}):t[h]=!0}remove(e){this.pending.delete(e)}};function Ln(e){return Object.prototype.hasOwnProperty.call(e,G)}function Pn(e){const t=e[J];if(!t||0===t.length)return;const n=[...t];e[J]=[],n.forEach(e=>e())}const jn=50;function Mn(e,t,n){const o=arguments.length>=3,r=e[H];if(!r)return void kn(e);if(t.once&&Ln(e))return void kn(e);const s=e[u]??0;if(s>=jn){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${jn}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void kn(e)}e[u]=s+1;try{const s=o?n:r.call(e),i=Nt(e);if(!1===t.differential){if("string"!=typeof s)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=s;const n=e[G];n?.clear();const o=Array.from(i.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return i.appendChild(t.content),e[G]=null,void Pn(e)}if(!dt(s))return void console.warn("Render method must return html`` template result");let a=e[G];if(a&&a.isSameTemplate(s.strings))return a.update(s.values),void Pn(e);const c=new Vt(s),l=c.renderFragment();try{c.update(s.values)}catch(e){throw c.clear(),e}const h=document.createDocumentFragment();for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||h.appendChild(e);i.appendChild(l);try{e.isConnected&&c.reconnected()}catch(e){try{c.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw i.appendChild(h),e}let u;e[G]=c;try{a?.clear()}catch(e){u=e}if(Pn(e),u)throw u}catch(e){if(Cn)throw e;console.error("Error rendering element:",e)}finally{e[u]=s,kn(e)}}function Rn(e,t=!1){const n=e[K]||{};if(n.once&&Ln(e))e.isConnected&&In(e);else if(xn(e),t)Mn(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[Q]||(e[Q]={}),clearTimeout(e[Q].debounce),void(e[Q].debounce=setTimeout(()=>{e[Q].debounce=null,$n.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[Q]||(e[Q]={lastThrottle:0});const t=e[Q],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void $n.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),$n.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}$n.schedule(e,n)}}function In(e){const t=e[G];t?.reconnected()}function Dn(e={}){return function(t,n){return n.addInitializer(function(){this[H]=t,this[K]=e}),function(...n){const o=t.apply(this,n);return Mn(this,{...this[K]||e,once:!1},o),o}}}function Vn(){return function(e,t){return t.addInitializer(function(){this[X]&&!this[Z]?this[Z]=[this[X]]:this[X]&&this[Z]&&this[Z].push(this[X]),this[X]=e}),e}}function qn(e,t){return function(n,o){return function(...r){this[U]||(this[U]=new Map);const s=`${e}_${o.name}`;this[U].has(s)||this[U].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[U].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:!0,composed:!0,...t,detail:n});if(void 0!==t?.scope){const n=Ue(this,t.scope);return n?void n.dispatchEvent(o):void console.warn(`[snice/@dispatch] scope did not resolve for "${e}" — event not dispatched.`)}this.dispatchEvent(o)},l=e=>{if(t?.debounce)return clearTimeout(i.debounceTimeout),void(i.debounceTimeout=setTimeout(()=>c(e),t.debounce));if(!t?.throttle)return void c(e);const n=Date.now(),o=t.throttle-(n-i.throttleLastCall);if(o<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=n,void c(e);i.latestDetail=e,i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,c(e)},o))};return a instanceof Promise?a.then(e=>(l(e),e)):(l(a),a)}}}const Bn=t("debounce-timers"),Fn=t("throttle-timers"),Wn=t("once-called"),zn=t("memoize-cache");function Un(e=300,t={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=t;return function(t,s){const i=s.name;return function(...s){this[Bn]||(this[Bn]={});const a=this[Bn],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),h=!a[c],u=h?l:a[c].startTime,d=void 0!==r&&l-u>=r;if(n&&h){const e=t.apply(this,s);return a[c]={timeout:null,startTime:u,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:u,lastArgs:s}}}}function Hn(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[Fn]||(this[Fn]={});const i=this[Fn],a=s,c=Date.now();if(!i[a])return n&&t.apply(this,r),i[a]={lastInvoke:c,timeout:null,lastArgs:r},void(o&&!n&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),delete i[a]},e)));const l=c-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),l>=e)return t.apply(this,r),void(i[a].lastInvoke=c);o&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},e-l))}}}function Kn(e=!0){let t,n=!1;return function(o,r){const s=r.name;return function(...r){return e?(this[Wn]||(this[Wn]={}),this[Wn][s]||(this[Wn][s]={called:!0,result:o.apply(this,r)}),this[Wn][s].result):(n||(n=!0,t=o.apply(this,r)),t)}}}function Gn(e={}){const{keyGenerator:t=(...e)=>JSON.stringify(e),maxSize:n=100,ttl:o}=e;return function(e,r){const s=r.name;return function(...r){this[zn]||(this[zn]={}),this[zn][s]||(this[zn][s]=new Map);const i=this[zn][s],a=t(...r);if(i.has(a)){const e=i.get(a);if(!(void 0!==o&&Date.now()-e.timestamp>o))return e.value;i.delete(a)}const c=e.apply(this,r);if(i.set(a,{value:c,timestamp:Date.now()}),i.size>n){const e=i.keys().next().value;i.delete(e)}return c}}}function Qn(e){if(e[Bn]){for(const t in e[Bn])e[Bn][t]?.timeout&&clearTimeout(e[Bn][t].timeout);e[Bn]={}}}function Jn(e){if(e[Fn]){for(const t in e[Fn])e[Fn][t]?.timeout&&clearTimeout(e[Fn][t].timeout);e[Fn]={}}}function Xn(e,t){e[zn]&&(t?delete e[zn][t]:e[zn]={})}function Yn(e,t){e[Wn]&&(t?delete e[Wn][t]:e[Wn]={})}function Zn(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.configurable?{locked:!1,value:void 0}:"value"in n&&!1===n.writable?{locked:!0,value:n.value}:"value"in n||void 0!==n.get?{locked:!1,value:void 0}:{locked:!0,value:void 0}}function eo(e){e.prototype[r]=!0;const t=e.prototype.connectedCallback,n=e.prototype.disconnectedCallback,o=e.prototype.attributeChangedCallback,s=e.observedAttributes||[];s.includes("controller")||s.push("controller");const u=e[A];if(u)for(const[e,t]of u){if(!1===t.attribute)continue;const n=Me(t,e);s.includes(n)||s.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>s,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[i]||(this[i]=new Promise(e=>{this[a]=e})),this[i]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[l]?this[c]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[m]},set(e){const t=this[m];if(this[m]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void vn(this,e).catch(n=>{"ControllerAttachAborted"!==n?.name?"string"!=typeof e||n?.message!==`Controller "${e}" not found in registry`?console.error(`Failed to attach controller "${t}":`,n):bn(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&En(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[i]||(this[i]=new Promise(e=>{this[a]=e})),this[p]){try{In(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}mn(this,this),rt(this,this),Tn(this);try{Je(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[D];if(n)for(const e of n)try{const t=e.method.call(this);t&&"function"==typeof t.then&&t.catch(t=>{console.error(`Error in @reconnect handler ${e.methodName}:`,t)})}catch(t){console.error(`Error in @reconnect handler ${e.methodName}:`,t)}return void(this[H]&&this[h]&&(this[h]=!1,Rn(this)))}this[k]=!0;const n=e[A];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=Me(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);qe(this,L).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=Pe(o,t)}if(this[O]){for(const[e,t]of Array.from(this[O].entries())){const o=n?.get(e),r=Me(o||{},e);this[O].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[O]}if(void 0!==this[N]){const e=this[N];if(delete this[N],!this[m]){this[m]=e;const t=e?.name||"(anonymous controller class)";vn(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[m]){const e=this.getAttribute("controller");e&&(this.controller=e)}!function(e){const t=e[X],n=[],o=[];let r=e.constructor;for(;r&&r!==HTMLElement&&r!==Function.prototype;)o.unshift(r),r=Object.getPrototypeOf(r);for(const e of o){if(!Object.prototype.hasOwnProperty.call(e,"styles"))continue;const t=e.styles,o=Array.isArray(t)?t:[t];for(const e of o)ft(e)?n.push(e):console.warn("Static styles must be a css`` result or an array of css`` results")}if((t||0!==n.length)&&!e[Y]){e[Y]=!0;try{const o=[...n],r=e[Z];if(r)for(const t of r){const n=t.call(e);ft(n)&&o.push(n)}if(t){const n=t.call(e);if(!ft(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=Nt(e),i=Array.from(s.childNodes).filter(e=>e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style"));if(i.length===o.length&&i.every((e,t)=>e.textContent===o[t].cssText))return;for(const e of i)e.remove();if(s instanceof ShadowRoot&&o.every(e=>!!e.styleSheet)&&"adoptedStyleSheets"in s)try{return void(s.adoptedStyleSheets=o.map(e=>e.styleSheet))}catch{}for(const e of o){const t=document.createElement("style");t.setAttribute("data-snice-style",""),t.textContent=e.cssText,s.appendChild(t)}}catch(e){console.error("Error applying styles:",e)}}}(this),mn(this,this),rt(this,this),Tn(this),this[p]=!0,function(e,t){if(Ke.has(t))return;Ke.add(t);const n=t[$];if(!n||0===n.size)return;const o=t[A],r=new Set(["*"]);if(o)for(const[e,t]of o)r.add(e),"string"==typeof t?.attribute&&r.add(t.attribute);for(const t of n.keys()){if(r.has(t))continue;const n=e.tagName?e.tagName.toLowerCase():"element",s=o?[...o.keys()].join(", "):"(none)";console.warn(`@watch('${t}') on <${n}> matches no @property — it will never fire. Known properties: ${s}.`)}}(this,e),function(e,t){const n=t[$],o=t[A];if(n&&o)for(const[t,r]of o){const o=[t],s=r&&"string"==typeof r.attribute?r.attribute:null;s&&s!==t&&o.push(s),o.push("*");for(const r of o)if(n.has(r))for(const o of n.get(r))if(o.immediate)try{o.method.call(e,void 0,e[t],t)}catch(e){console.error(`Error in @watch('${r}') method ${o.methodName}:`,e)}}}(this,e),t&&t.call(this);const o=e[R];if(await new Promise(e=>queueMicrotask(e)),this.isConnected){this[H]&&Rn(this,!0);try{Je(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),this.isConnected){if(o)for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t)}this[a]&&(this[a](),this[a]=null)}else this[a]&&(this[a](),this[a]=null)}else this[a]&&(this[a](),this[a]=null)},e.prototype.disconnectedCallback=async function(){try{!function(e){const t=e[G];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[I];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[m]&&En(this).catch(e=>{console.error("Failed to detach controller:",e)}),pn(this),st(this),function(e){const t=e.constructor[An];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[ce];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[ce]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[ne];o&&"function"==typeof o[ie]&&o[ie](e),delete e[ne],delete e[le]}(this),tt(this),Qn(this),Jn(this),function(e){const t=e[Q];if(!t)return!1;let n=!1;return t.debounce&&(clearTimeout(t.debounce),t.debounce=null,n=!0),t.throttleTimer&&(clearTimeout(t.throttleTimer),t.throttleTimer=null,n=!0),n}(this)&&(this[h]=!0),function(e){const t=e[U];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0}(this),bo(this,W),bo(this,z)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t)return void(this.controller=r);const s=e[A];if(s)for(const[n,o]of s){if(Me(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[F]?.has(t.toLowerCase()))break;const s=this[_]?.[n],i=this[T]?.[n];let a=null===r?o.type!==Boolean&&i:Pe(r,o,s,i);const c=this[C]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):je(a,s)))break;qe(this,L).add(n),Be(this,_)[n]=a,this[p]&&Fe(this,e,n,s,a),this[H]&&this[p]&&Rn(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[V];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @moved handler ${e.methodName}:`,t)}},e.prototype.adoptedCallback=async function(){const t=e[q];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function to(e,t,n,o){if(function(e){let t=Object.getPrototypeOf(e);const n=[];for(;t&&t!==HTMLElement&&t!==Function.prototype;)n.push(t),t=Object.getPrototypeOf(t);n.reverse();for(const t of n){if(t[A]){e[A]||(e[A]=new Map);for(const[n,o]of t[A])e[A].has(n)||e[A].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[A]){t[A]||(t[A]=new Map);for(const[e,o]of n.metadata[A])t[A].set(e,o)}else if(ro.length>0){t[A]||(t[A]=new Map);const e=ro.pop();for(const[n,o]of e)t[A].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[f]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};return Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[f]=i,!0===t.prototype[ee]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,H)&&"function"==typeof t.prototype.render&&(t.prototype[H]=t.prototype.render,t.prototype[K]=t.renderOptions||{}),eo(t),customElements.get(e)?(globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),t)}function no(e,t){if(void 0!==t?.renderRoot&&"shadow"!==t.renderRoot&&"light"!==t.renderRoot)throw new TypeError('snice: @element renderRoot must be "shadow" or "light".');if(void 0!==t?.shadow&&!1!==t.shadow&&"open"!==t.shadow&&"closed"!==t.shadow)throw new TypeError('snice: @element shadow must be "open", "closed", or false.');return function(n,o){return to(e,n,o,t)}}function oo(e){return function(t,n){return to(e,t,n)}}const ro=[],so=new WeakMap;function io(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[A]||(n.metadata[A]=new Map),n.metadata[A].set(o,e||{})):(0===ro.length&&ro.push(new Map),ro[ro.length-1].set(o,e||{})),function(t){const n=this[x],r=!0===n?.delete(o);0===n?.size&&delete this[x];const s=Object.prototype.hasOwnProperty.call(this,o),i=s&&(r||!function(e,t,n){const o=e?.ownerDocument;if(!o?.createElement)return!1;let r=so.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);so.set(o,r)}return r.has(t)&&Object.is(r.get(t),n)}(this,o,this[o])),a=i?this[o]:t;s&&delete this[o];const c=this.constructor;c[A]||(c[A]=new Map);const l={...e};l.type||void 0===t||(l.type=Le(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[A].set(o,l),Be(this,T)[o]=t;const h=()=>{if(!this[k])return;const e=this[_]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=Me(l,o),r=He(e,l,t),s=n.toLowerCase();qe(this,F).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[F].delete(s)}}this[p]&&(Fe(this,this.constructor,o,e,e),this[H]&&Rn(this))},u=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=Zn(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("set"===n)c=(n,o)=>{n=r(n),o=r(o);const s=e.has(n),a=e.get(n);return e.set(n,o),s&&Object.is(a,o)||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("get"===n)c=t=>s(e.get(r(t)));else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach((e,o)=>t.call(n,s(e),s(o),i));else if("values"===n)c=function*(){for(const t of e.values())yield s(t)};else if("keys"===n)c=function*(){for(const t of e.keys())yield s(t)};else if("entries"===n||n===Symbol.iterator)c=function*(){for(const[t,n]of e.entries())yield[s(t),s(n)]};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(e instanceof Set){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=Zn(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("add"===n)c=n=>{n=r(n);const o=e.has(n);return e.add(n),o||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach(e=>{const o=s(e);t.call(n,o,o,i)});else if("values"===n||"keys"===n||n===Symbol.iterator)c=function*(){for(const t of e.values())yield s(t)};else if("entries"===n)c=function*(){for(const t of e.values()){const e=s(t);yield[e,e]}};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(!Array.isArray(e)&&!function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;const i=new Proxy(e,{get(e,t,n){const o=Zn(e,t);return o.locked?o.value:s(Reflect.get(e,t,n))},set(e,n,o,s){const i=Reflect.get(e,n,s);o=r(o);const a=Reflect.set(e,n,o);return a&&!Object.is(i,o)&&t(),a},deleteProperty(e,n){const o=Object.prototype.hasOwnProperty.call(e,n),r=Reflect.deleteProperty(e,n);return r&&o&&t(),r},defineProperty(e,n,o){const s=Reflect.getOwnPropertyDescriptor(e,n),i="value"in o?{...o,value:r(o.value)}:o,a=Reflect.defineProperty(e,n,i),c=a?Reflect.getOwnPropertyDescriptor(e,n):s;return a&&!function(e,t){if(!e||!t)return e===t;const n="value"in e||"writable"in e;return n===("value"in t||"writable"in t)&&e.configurable===t.configurable&&e.enumerable===t.enumerable&&(!n||e.writable===t.writable&&Object.is(e.value,t.value))&&(n||e.get===t.get&&e.set===t.set)}(s,c)&&t(),a}});return n.set(e,i),o.set(i,e),i};return s(e)}(e,()=>{this[_]?.[o]===t&&h()}),t};Be(this,C)[o]=u;const d=this.constructor.prototype;let f=d[Se];f&&Object.prototype.hasOwnProperty.call(d,Se)||(f=new Map(f),d[Se]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[O]?.has(o)?this[O].get(o):this[_]&&o in this[_]?this[_][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):je(e,t)))return;const n=(this[C]?.[o]||(e=>e))(e);if(!this[k])return this[O]||(this[O]=new Map),void this[O].set(o,n);if(Be(this,_)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=Me(l,o),t=He(n,l,this[T]?.[o]);qe(this,L).add(o);const r=e.toLowerCase();qe(this,F).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[F].delete(r)}}this[p]&&(Fe(this,this.constructor,o,t,n),this[H]&&Rn(this))},configurable:!0,enumerable:!0}));const y=u(t);return Be(this,_)[o]=y,Be(this,T)[o]=y,i?a:y}}}function ao(e={}){return io({...e,attribute:!1,reflect:!1})}function co(e){return!0===e[o]&&e.element?e.element:e}function lo(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=co(this);let n=null;const o=t instanceof HTMLElement?Et(t):null;return s&&o?n=o.querySelector(e):s&&t.shadowRoot&&(n=t.shadowRoot.querySelector(e)),!n&&r&&(n=t.querySelector(e)),n||null},set(){},configurable:!0,enumerable:!0}),t}}}function ho(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=co(this),n=new Set,o=t instanceof HTMLElement?Et(t):null;if(s&&o)for(const t of o.querySelectorAll(e))n.add(t);else if(s&&t.shadowRoot)for(const o of t.shadowRoot.querySelectorAll(e))n.add(o);if(r)for(const o of t.querySelectorAll(e))n.add(o);return[...n]},set(){},configurable:!0,enumerable:!0}),t}}}function uo(...e){const t=e.filter(e=>"string"==typeof e),n=e.find(e=>"object"==typeof e&&null!==e),o=!1!==n?.immediate;return function(e,n){const r=n.name;n.addInitializer(function(){const n=this.constructor;Object.prototype.hasOwnProperty.call(n,de)||(n[de]=new Map);let s=n[de].get(e);if(s||(s=new Set,n[de].set(e,s)),!Object.prototype.hasOwnProperty.call(n,$)){const e=n[$],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[$]=t}for(const i of t)s.has(i)||(s.add(i),n[$].has(i)||n[$].set(i,[]),n[$].get(i).push({methodName:r,method:e,immediate:o}))})}}function fo(){return function(e,t){const n=t.name;return function(e){return Object.hasOwn(this.constructor.prototype,n)||Object.defineProperty(this.constructor.prototype,n,{get(){if(void 0!==this[P])return this[P];let e=!0===this[o]&&this.element?this.element:this;if(!e||!e.dispatchEvent)return;e.getRootNode&&e.getRootNode()instanceof ShadowRoot&&(e=e.getRootNode().host);const t={target:this};return e.dispatchEvent(new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t})),void 0!==t.context?(this[P]=t.context,t.context):void 0},set(){},configurable:!0,enumerable:!0}),e}}}function mo(e,t,n,o,r){const s=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,t)||(o[t]=new Set),!o[t].has(n)){if(o[t].add(n),!Object.prototype.hasOwnProperty.call(o,e)){const t=o[e];o[e]=t?[...t]:[]}o[e].push({methodName:s,method:n,...r})}})}function po(){return function(e,t){mo(R,ye,e,t)}}function yo(){return function(e,t){mo(I,ge,e,t)}}function go(){return function(e,t){mo(D,be,e,t)}}function bo(e,t){const n=e[t];if(n)for(const e of n.values())e.debounceTimer&&clearTimeout(e.debounceTimer),e.throttleTimer&&clearTimeout(e.throttleTimer),e.debounceTimer=null,e.throttleTimer=null,e.lastThrottleCall=0}function wo(e,t,n){return function(o={}){return function(r,s){mo(e,n,r,s,{options:o});const i=s.name;return function(...e){this[t]||(this[t]=new Map),this[t].has(i)||this[t].set(i,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const n=this[t].get(i),s=(...e)=>r.apply(this,e),a=(...e)=>{try{const t=r.apply(this,e);t&&"function"==typeof t.then&&t.catch(e=>console.error(`Error in deferred lifecycle handler ${i}:`,e))}catch(e){console.error(`Error in deferred lifecycle handler ${i}:`,e)}};if(o.debounce>0)return clearTimeout(n.debounceTimer),void(n.debounceTimer=setTimeout(()=>a(...e),o.debounce));if(o.throttle>0){const t=Date.now();return 0===n.lastThrottleCall||t-n.lastThrottleCall>=o.throttle?(n.lastThrottleCall=t,s(...e)):void(n.throttleTimer||(n.throttleTimer=setTimeout(()=>{n.throttleTimer=null,n.lastThrottleCall=Date.now(),a(...e)},o.throttle-(t-n.lastThrottleCall))))}return s(...e)}}}}const vo=wo(V,W,we),Eo=wo(q,z,ve);class No extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[f];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return Rn(this),this.rendered}renderNow(){return function(e){xn(e),Mn(e,{...e[K]||{},once:!1})}(this),this.rendered}}Object.defineProperty(No.prototype,ee,{value:!0});class So{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:h}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=h}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function Ao(e){const t=e.split("/").filter(Boolean);let n=t.length;for(const e of t)e.startsWith("*")?n+=-2:e.startsWith(":")?n+=3:n+=10;return n}function _o(e){const t={};return e.split(";").forEach(e=>{const n=e.indexOf(":");if(-1===n)return;const o=e.slice(0,n).trim(),r=e.slice(n+1).trim();o&&r&&(t[o]=r)}),t}function To(e,t,n,o){if(e.style.position="absolute",e.style.width="100%",t)return e.style.height="100%",void(e.style.transition=`opacity ${n}ms ease-in-out`);e.style.top="0",e.style.left="0",e.style.transition=`${o} ${n}ms ease-in-out`}var Co;function Oo(e){const t=e.window??window,n=e.document??document,o=[];let r,s,i,a=!1,c=[],l=null,h=null;const u=e.context||{},d=new $e(u,[],"",{},e.fetcher);function f(e){if(!l||!h)return null;const t=e.querySelectorAll(l);for(const e of t)if(e[M]===h)return e;return null}function m(e,t,n,c,l,h){switch(o.push({route:new So(e),tag:t,transition:n,guards:c,layout:l,placard:h}),a=!1,e){case"/404":r=t;break;case"/403":s=t;break;case"/":i=t}}function p(){const e=new Set;c=o.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(u):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function y(e,t,n){d[he](u,c,t,n)}function g(){switch(e.type){case"hash":return t.location.hash.slice(1);case"pushstate":return t.location.pathname}}function b(e){let t;if(s)t=n.createElement(s),t[P]=u;else{const e=n.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),l=null,h=null}async function w(e,t,o,r){if(!e)return!0;const s=Array.isArray(e)?e:[e];let i=null,a=null;a=setTimeout(()=>{r&&r()||(i=function(){const e=n.createElement("div");return e.setAttribute("data-snice-loading",""),e.innerHTML='\n <style>@keyframes snice-spin{to{transform:rotate(360deg)}}</style>\n <div style="display:flex;align-items:center;justify-content:center;height:100%;min-height:200px">\n <div style="width:32px;height:32px;border:3px solid rgba(128,128,128,0.3);border-top-color:rgba(128,128,128,0.8);border-radius:50%;animation:snice-spin 0.6s linear infinite"></div>\n </div>',e}(),o.appendChild(i))},50);try{for(const e of s)if(!await e(u,t))return r&&r()||b(o),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function v(t,o,r,s,i,a,d){const m=!1===(p=s)?null:p||(e.layout?e.layout:null);var p;const{element:g,needsNewLayout:b}=function(e){if(e===l)return{element:null,needsNewLayout:!1};if(l=e,e){const t=Date.now();h=t;const o=n.createElement(e);return o[P]=u,o[M]=t,{element:o,needsNewLayout:!0}}return h=null,{element:null,needsNewLayout:!0}}(m),w=r||e.transition;if(null!==g||null!==f(t)){if(await async function(e,t,n,o,r,s,i,a){const l=o||f(e);if(!l)return;!function(e,t,n){"function"==typeof e.update&&e.update(u,c,t,n)}(l,s,i);const h=l.querySelector('[slot="page"]');if(n&&h){if(t.setAttribute("slot","page"),await S(l,h,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(l))}else a&&a()||(l.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),l.appendChild(t),r&&(e.innerHTML="",e.appendChild(l)))}(t,o,w,g,b,i,a,d),d&&d())return;y(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await S(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(t,o,w,d),d&&d()||y(0,i,a)}let E=0;async function N(s){const a=n.querySelector(e.target);if(!a)throw new Error(`Target element not found: ${e.target}`);const c=++E,l=()=>c!==E;if(p(),t.scrollTo(0,0),(""===s?.trim()||"/"===s)&&i){const e=o.find(e=>e.route.match("/"));if(!await w(e?.guards,{},a,l))return;if(l())return;const{element:r,transition:c,layout:h}=function(){const e=n.createElement(i);e[P]=u;const r=t.customElements.get(i),s=r?.[j],a=o.find(e=>e.route.match("/"));return{element:e,transition:s,layout:a?.layout}}();return void await v(a,r,c,h,s,{},l)}if(!s)return;const h=await async function(e,t,r){for(const s of o){const o=s.route.match(e);if(!1===o)continue;if(!await w(s.guards,o,t,r))return{result:Co.GUARDS_FAILED};const i=n.createElement(s.tag);i[P]=u,i[te]=d;const a=o;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:Co.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:Co.NOT_FOUND}}(s,a,l);if(l())return;if(h.result===Co.GUARDS_FAILED)return;if(h.result===Co.SUCCESS){const{element:e,transition:t,layout:n,routeParams:o={}}=h;return void await v(a,e,t,n,s,o,l)}const{element:f,transition:m,layout:y}=function(){if(r){const e=n.createElement(r);e[P]=u;const o=t.customElements.get(r),s=o?.[j];return{element:e,transition:s,layout:void 0}}const e=n.createElement("div");return e.className="default-404",e.innerHTML="<h1>404</h1><p>Page not found</p>",{element:e,transition:void 0,layout:void 0}}();await v(a,f,m,y,s,{},l)}async function S(e,t,n,o,r=E){return async function(e,t,n,o={},r=()=>!1){const s=o.outDuration??300,i=o.inDuration??300,a=o.mode||"sequential",c=o.out?_o(o.out):{opacity:"0"},l={opacity:"0"},h=o.in?_o(o.in):{opacity:"1"},u=e.style,d=e.tagName.includes("-")&&e.shadowRoot,f=Symbol.for("snice:transition-original-position"),m=Symbol.for("snice:transition-count"),p=e;d||(f in p||(p[f]=u.position,p[m]=0),p[m]++,u.position="relative");const y=()=>{d||(p[m]--,p[m]<=0&&(u.position=p[f],delete p[f],delete p[m]))},g=t.hasAttribute("slot")||n.hasAttribute("slot");switch(To(t,g,s,"all"),To(n,g,i,"all"),Object.assign(n.style,l),e.appendChild(n),a){case _e.SIMULTANEOUS:Object.assign(t.style,c),Object.assign(n.style,h),await new Promise(e=>setTimeout(e,Math.max(s,i)));break;case _e.SEQUENTIAL:if(Object.assign(t.style,c),await new Promise(e=>setTimeout(e,s)),r())return n.parentNode===e&&n.remove(),void y();Object.assign(n.style,h),await new Promise(e=>setTimeout(e,i))}if(r())return n.parentNode===e&&n.remove(),void y();t.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(n,g),Object.keys({...l,...h}).forEach(e=>{n.style[e]=""}),y()}(e,t,n,o,()=>r!==E)}return{page:function(e){return function(n,o){if(o?.metadata&&o.metadata[A]){n[A]||(n[A]=new Map);for(const[e,t]of o.metadata[A])n[A].set(e,t)}eo(n),n[j]=e.transition;const r=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){this[te]=d,r?.call(this)};const s=n.prototype.disconnectedCallback;return n.prototype.disconnectedCallback=function(){s?.call(this),delete this[P],delete this[te]},t.customElements.get(e.tag)||t.customElements.define(e.tag,n),e.routes.forEach(t=>m(t,e.tag,e.transition,e.guards,e.layout,e.placard)),n}},initialize:function(){if(!n.querySelector(e.target))throw new Error(`Target element not found: ${e.target}`);!a&&(o.sort((e,t)=>Ao(t.route.spec)-Ao(e.route.spec)),a=!0),p(),function(){const o=()=>{n.querySelector(e.target)&&N(g())};switch(e.type){case"hash":t.addEventListener("hashchange",o);break;case"pushstate":t.addEventListener("popstate",o)}}(),N(g())},navigate:N,register:m}}function xo(e,t,n){const o=[];for(const[r,s]of Object.entries(t)){const t=`@request/${r}`,i=e=>{const t=e,{discovery:o,data:i,payload:a}=t.detail;n?.passive||(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()),o.resolve(),Promise.resolve().then(()=>s(a)).then(e=>i.resolve(e)).catch(e=>{i.reject(e),console.error(`createRequestHandler: error in "${r}" handler:`,e)})};e.addEventListener(t,i),o.push(()=>e.removeEventListener(t,i))}return()=>{for(const e of o)e();o.length=0}}function ko(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t}function $o(e){const t=[];for(const n of Object.keys(e)){const o=e[n];if(null==o||!1===o)continue;const r=n.startsWith("--")?n:n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());t.push(`${r}: ${o}`)}return t.join("; ")}!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(Co||(Co={}));let Lo=!1;function Po(e){Lo=e}async function jo(e,t=500){if(customElements.get(e))return;let n=null;Lo||(n=setTimeout(()=>{console.warn(`Custom element <${e}> is taking longer than ${t}ms to register. This may indicate a missing import or circular dependency. Set DISABLE_ELEMENT_READY_WARNINGS=true to disable this warning.`)},t));try{await customElements.whenDefined(e)}finally{n&&clearTimeout(n)}}async function Mo(e,t=500){const n=e.tagName.toLowerCase();await jo(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}async function Ro(e,t=500){const n=[];e instanceof Element&&(e.tagName.includes("-")&&n.push(e),e.shadowRoot)&&e.shadowRoot.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),e instanceof DocumentFragment&&e.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),await Promise.all(n.map(e=>Mo(e,t)))}async function*Io(e){for(;;)await new Promise(t=>{e[J]||(e[J]=[]),e[J].push(t)}),yield}let Do=0,Vo=null;const qo=Symbol.for("snice:body-scroll-lock");function Bo(){0===Do&&(Vo=document.body.style.overflow,document.body.style.overflow="hidden"),Do++}function Fo(){0!==Do&&(Do--,0===Do&&(document.body.style.overflow=Vo??"",Vo=null))}function Wo(){return Do}globalThis[qo]={clear(){Do=0,Vo=null}};class zo{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(e,t){"request"!==e?this.responseMiddlewares.push(t):this.requestMiddlewares.push(t)}create(e){const t=this.requestMiddlewares,n=this.responseMiddlewares;return async function(e,o){const r=new Request(e,o);let s=0;const i=async()=>{if(s<t.length)return t[s++].call(this,r,i);const e=await fetch(r);let o=0;const a=async()=>o<n.length?n[o++].call(this,e,a):e;return a()};return i()}.bind(e)}}var Uo;"undefined"!=typeof document&&Sn(),globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Uo||(Uo={}));export{$e as Context,zo as ContextAwareFetcher,o as IS_CONTROLLER_INSTANCE,Oo as Router,Ae as SimpleArray,No as SniceElement,_e as TransitionMode,Eo as adopted,eo as applyElementFunctionality,vn as attachController,ko as classMap,Qn as clearDebounceTimers,Xn as clearMemoizeCache,Jn as clearThrottleTimers,_n as context,fo as contextProperty,gn as controller,xo as createRequestHandler,ut as css,Un as debounce,En as detachController,qn as dispatch,yo as dispose,no as element,Ie as escapeAttr,Re as escapeHtml,Wo as getBodyScrollLockCount,Nn as getController,t as getSymbol,lt as html,De as isSafeUrl,oo as layout,Pt as live,Bo as lockBodyScroll,Gn as memoize,vo as moved,$t as noChange,mt as nothing,Qe as observe,un as on,Kn as once,Ve as parseDuration,io as property,lo as query,ho as queryAll,po as ready,go as reconnect,Dn as render,wt as repeat,nt as request,Yn as resetOnce,ot as respond,Po as setDisableElementReadyWarnings,On as setStrictRenderErrors,ao as state,$o as styleMap,Vn as styles,ht as svg,Hn as throttle,Io as trackRenders,Fo as unlockBodyScroll,yt as unsafeHTML,Sn as useNativeElementControllers,Ro as waitForAllCustomElements,jo as waitForElementDefined,Mo as waitForElementReady,uo as watch};
1
+ globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map;const e=globalThis.snice;function t(e){return Symbol.for(`snice:${e}`)}const n=t("is-controller-class"),o=t("is-controller-instance"),r=t("is-daemon-class"),s=t("is-daemon-instance"),i=t("is-element-class"),a=t("channel-handlers"),c=t("daemon-state"),l=t("ready-promise"),h=t("ready-resolve"),u=t("rendered-promise"),d=t("rendered-resolve"),f=t("pending-reconnect-render"),m=t("render-depth"),p=t("render-root"),y=t("element-options"),g=t("controller"),v=t("initialized"),b=t("controller-key"),w=t("controller-name"),E=t("controller-id"),N=t("controller-operations"),A=t("native-controller"),T=t("direct-controller"),S=t("pending-controller-binding"),_=t("cleanup"),x=t("properties"),C=t("property-values"),O=t("property-defaults"),k=t("property-wrappers"),$=t("pre-init-property-values"),L=t("pre-upgrade-property-bindings"),P=t("properties-initialized"),j=t("property-watchers"),M=t("explicitly-set-properties"),R=t("router-context"),I=t("page-transition"),D=t("created-at"),V=t("ready-handlers"),q=t("dispose-handlers"),B=t("reconnect-handlers"),F=t("moved-handlers"),W=t("adopted-handlers"),z=t("observers"),U=t("setting-from-property"),H=t("moved-timers"),K=t("adopted-timers"),G=t("dispatch-timers"),Q=t("render-method"),J=t("render-options"),X=t("render-instance"),Y=t("render-timers"),Z=t("render-callbacks"),ee=t("styles-method"),te=t("styles-applied"),ne=t("parent-styles-methods"),oe=t("snice-element-base"),re=t("context-handler"),se=t("navigation-context-instance"),ie=t("registered-elements"),ae=t("is-updating"),ce=t("context-register"),le=t("context-unregister"),he=t("context-notify-element"),ue=t("context-timer"),de=t("context-called"),fe=t("context-update"),me=t("context-methods"),pe=t("watch-methods"),ye=t("observe-methods"),ge=t("on-methods"),ve=t("respond-methods"),be=t("ready-methods"),we=t("dispose-methods"),Ee=t("reconnect-methods"),Ne=t("moved-methods"),Ae=t("adopted-methods"),Te=t("controller-abort"),Se=t("controller-attached"),_e=t("property-definers");class xe{static{this.SEPARATOR=","}static serialize(e){return Array.isArray(e)?e.map(e=>{if("string"==typeof e){if(e.includes(xe.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${xe.SEPARATOR}" (U+FF0C)`);return e}if("number"==typeof e||"boolean"==typeof e)return String(e);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof e)}).join(xe.SEPARATOR):""}static parse(e){return null==e||""===e?[]:e.split(xe.SEPARATOR).map(e=>{if(/^-?\d+\.?\d*$/.test(e)){const t=Number(e);if(!isNaN(t))return t}return"true"===e||"false"!==e&&e})}}var Ce,Oe,ke,$e;!function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(Ce||(Ce={}));const Le=Symbol.for("snice:registered-elements-set");let Pe=0;class je{constructor(e={},t=[],n="",o={},r){if(this[Oe]=new WeakMap,this[ke]=new Set,this[$e]=!1,this.id=Pe++,this.application=e,this.navigation={placards:t,route:n,params:o},r&&"function"==typeof r.create)this.fetch=r.create(this);else{if("function"!=typeof fetch)throw new Error("No fetch implementation available");this.fetch=fetch.bind(this)}}[(Oe=ie,ke=Le,$e=ae,ce)](e,t){const n=this[ie];let o=n.get(e);o||(o=new Set,n.set(e,o)),o.add(t),this[Le].add(e)}[le](e,t){const n=this[ie];if(void 0!==t){const o=n.get(e);if(!o)return;if(o.delete(t),o.size>0)return}n.delete(e),this[Le].delete(e)}[fe](e,t,n,o){this.application=e,this.navigation.placards=t,this.navigation.route=n,this.navigation.params=o,this.notify()}update(){this.notify()}notify(){if(this[ae])return;this[ae]=!0;const e=this[Le],t=this[ie];for(const n of e){const e=t.get(n);if(e)for(const t of e)if("function"==typeof n[t])try{n[t](this)}catch(e){console.error(`Error calling @context method ${t}:`,e)}}this[ae]=!1}[he](e){const t=this[ie].get(e);if(t)for(const n of t)"function"==typeof e[n]&&e[n](this)}}function Me(e){if(null!=e)return"string"==typeof e?String:"number"==typeof e?Number:"boolean"==typeof e?Boolean:e instanceof Date?Date:"bigint"==typeof e?BigInt:Array.isArray(e)?Array:void 0}function Re(e,t,n,o){const r=t.type||Me(o);if(t.converter?.fromAttribute)return t.converter.fromAttribute(e,r);switch(r){case Boolean:return null!==e&&"false"!==e;case Number:return null!==e?Number(e):null;case String:return e;case Date:return e?new Date(e):null;case BigInt:return e&&e.endsWith("n")?BigInt(e.slice(0,-1)):e?BigInt(e):null;case xe:return xe.parse(e);case Array:try{return e?JSON.parse(e):[]}catch{return[]}case Object:try{return e?JSON.parse(e):{}}catch{return{}}default:return"number"==typeof n&&null!==e?Number(e):e}}function Ie(e,t){return e!==t&&(e==e||t==t)}function De(e,t){return"string"==typeof e.attribute?e.attribute.toLowerCase():!0===e.attribute||"kebab"===e.attributeNaming?t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase():t.toLowerCase()}function Ve(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function qe(e){return String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Be(e,t={}){let n;try{n=String(e??"")}catch{return!1}if(!n||/[\u0000-\u001f\u007f]/.test(n))return!1;const o=n.trim();if(!o)return!1;const r=t.allowed??["http:","https:","mailto:","tel:"];try{const e=new URL(o,"http://__snice-relative.invalid/"),t=/^[a-z][a-z\d+.-]*:/i.test(o),n=/^[\\/]{2}/.test(o);return!t&&!n||r.some(t=>"string"==typeof t&&t.toLowerCase()===e.protocol)}catch{return!1}}function Fe(e){const t=String(e).trim(),n=parseFloat(t);let o;return o=isNaN(n)?0:/ms$/i.test(t)?n:/s$/i.test(t)?1e3*n:/m$/i.test(t)?6e4*n:/h$/i.test(t)?36e5*n:n,{milliseconds:()=>o,seconds:()=>o/1e3,minutes:()=>o/6e4}}function We(e,t){return e[t]||(e[t]=new Set),e[t]}function ze(e,t){return e[t]||(e[t]={}),e[t]}function Ue(e,t,n,o,r){const s=t[j];if(!s)return;const i=[n],a=t[x]?.get(n),c=a&&"string"==typeof a.attribute?a.attribute:null;c&&c!==n&&i.push(c);for(const t of i)if(s.has(t))for(const i of s.get(t))try{i.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('${t}') method ${i.methodName}:`,e)}if(s.has("*"))for(const t of s.get("*"))try{t.method.call(e,o,r,n)}catch(e){console.error(`Error in @watch('*') method ${t.methodName}:`,e)}}function He(e,t){let n=null;return function(...o){null!==n&&clearTimeout(n),n=setTimeout(()=>{e.apply(this,o),n=null},t)}}function Ke(e,t){let n=0,o=null;return function(...r){const s=Date.now(),i=t-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,e.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,e.apply(this,r)},i))}}function Ge(e,t){if(null==t)return e;if("global"===t)return"undefined"!=typeof document?document:null;if("function"==typeof t)try{return t.call(e)||null}catch{return null}return"string"==typeof t?e.closest?.(t)||null:t&&"function"==typeof t.addEventListener?t:null}function Qe(e,t,n){if(null==e||!1===e||t?.type===xe&&Array.isArray(e)&&0===e.length)return null;if(t.converter?.toAttribute)return t.converter.toAttribute(e,t.type);switch(t.type||Me(n)){case Boolean:return"true";case Date:return e instanceof Date?e.toISOString():String(e);case BigInt:return"bigint"==typeof e?e.toString()+"n":String(e);case xe:return Array.isArray(e)?xe.serialize(e):String(e);case Array:return Array.isArray(e)?JSON.stringify(e):String(e);case Object:return"object"==typeof e&&null!==e?JSON.stringify(e):String(e);default:return String(e)}}const Je=new WeakSet,Xe=new Map;function Ye(e,t,n){let o,r;return"string"==typeof t?(o=t,r=n):(o=void 0,r=t),function(t,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,ye)||(n[ye]=new Set),n[ye].has(t))return;if(n[ye].add(t),!Object.prototype.hasOwnProperty.call(n,z)){const e=n[z];n[z]=e?[...e]:[]}const i=Array.isArray(e)?e:[e];for(const e of i){const[i,...a]=e.split(":"),c=a.join(":");n[z].push({type:i,target:c,selector:o,methodName:s,method:t,options:r})}})}}function Ze(e,t){const n=e.constructor[z];if(n&&Array.isArray(n)&&0!==n.length){e[_]?e[_].observers||(e[_].observers=[]):e[_]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(e),r=o.options?.throttle?Ke(n,o.options.throttle):n;switch(o.type){case"intersection":et(e,t,o,r);break;case"resize":tt(e,t,o,r);break;case"media":nt(e,0,o,r);break;case"mutation":ot(e,t,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function et(e,t,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");const s=new IntersectionObserver(e=>{for(const t of e)try{!1===o(t)&&s&&s.unobserve(t.target)}catch(e){console.error(`Error in intersection observer ${n.methodName}:`,e)}},r),i=n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t];i.forEach(e=>s.observe(e)),e[_].observers.push(()=>{i.forEach(e=>s.unobserve(e)),0===s.takeRecords().length&&s.disconnect()})}function tt(e,t,n,o){const r=n.options?.box||"content-box";if("undefined"==typeof ResizeObserver)return void console.warn("ResizeObserver is not available in this environment");const s=new ResizeObserver(e=>{for(const t of e)try{o(t)}catch(e){console.error(`Error in resize observer ${n.methodName}:`,e)}});(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):[t]).forEach(e=>{s.observe(e,{box:r})}),e[_].observers.push(()=>{s.disconnect()})}function nt(e,t,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=Xe.get(r);if(!s)try{s=window.matchMedia(r),Xe.set(r,s)}catch(e){return void console.error(`Invalid media query: ${r}`,e)}const i=e=>{try{o(e.matches)}catch(e){console.error(`Error in media query observer ${n.methodName}:`,e)}};i(s);const a=e=>i(e);s.addEventListener?(s.addEventListener("change",a),e[_].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),e[_].observers.push(()=>{s.removeListener(a)}))}function ot(e,t,n,r){const s=n.target.split(":"),i=s[0]||"childList",a=s[1],c={};switch(i){case"childList":c.childList=!0;break;case"attributes":c.attributes=!0,a&&(c.attributeFilter=[a]);break;default:return void(/^[.#[]/.test(i)?console.warn(`@observe: "mutation:${i}" — "${i}" looks like a selector. Selectors are the second argument — did you mean @observe('mutation:childList', '${i}')?`):console.warn(`Unknown mutation type: ${i} (expected childList or attributes)`))}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=!(!n.options?.maxDepth||!n.options.subtree),h=new MutationObserver(e=>{try{if(!l)return void r(e);const o=n.options.maxDepth,s=t.shadowRoot||t,i=e.filter(e=>{let t=0,n=e.target;for(;n&&n!==s&&t<o;)n=n.parentNode,t++;return t<o});i.length>0&&r(i)}catch(e){console.error(`Error in mutation observer ${n.methodName}:`,e)}}),u=!0===e[o];(n.selector?Array.from(t.shadowRoot?.querySelectorAll(n.selector)||[]):u&&t.shadowRoot?[t.shadowRoot]:[t]).forEach(e=>{h.observe(e,c)}),e[_].observers.push(()=>{h.disconnect()})}function rt(e){if(e[_]?.observers){for(const t of e[_].observers)t();e[_].observers=[]}}const st="@context/request",it=new WeakMap;function at(e){if(!e||"object"!=typeof e&&"function"!=typeof e)return;const t=function(e){return!e||"object"!=typeof e&&"function"!=typeof e?null:!0===e[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:"function"==typeof e.dispatchEvent?e:null}(e);if(t){const e={};if(t.dispatchEvent(new CustomEvent(st,{bubbles:!0,composed:!0,cancelable:!0,detail:e})),void 0!==e.context)return e.context}const n=e;return void 0!==n[R]?n[R]:!0===n[o]&&void 0!==n.element?.[R]?n.element[R]:void 0}function ct(e){return!!e&&("object"==typeof e||"function"==typeof e)&&!0===e[r]}function lt(e){if(!ct(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");let t=e[c];if(!t){t={target:new EventTarget,bindings:0,active:!1};try{Object.defineProperty(e,c,{value:t,configurable:!0}),Object.defineProperty(e,s,{value:!0,configurable:!0})}catch{throw new TypeError("@daemon instances must remain extensible until they are provided to an app context.")}}return t}function ht(e,t){if("string"!=typeof t||!t.trim())throw new TypeError("Daemon addresses must be non-empty strings.");const n=at(e);if(!n)throw new Error(`[snice] ${function(e){const t=e;return!0===t?.[o]?"controller":ct(t)?"@daemon instance":"element"}(e)} cannot resolve daemon "${t}" because no app context is provided.`);const r=n.daemons?.[t];if(!r)throw new Error(`[snice] app context does not provide daemon "${t}".`);if(!ct(r))throw new TypeError(`[snice] app context entry "${t}" is not an instance of an @daemon class.`);const s=lt(r);if(!s.active)throw new Error(`[snice] daemon "${t}" is not active because its app context has not been provided.`);return s.target}function ut(e){return ct(e)?function(e){return lt(e).target}(e):!0===e?.[o]?e.element&&"function"==typeof e.element.dispatchEvent?e.element:null:e&&"function"==typeof e.dispatchEvent?e:null}function dt(e,t){return function(n,o){let r,s,i=0;const a=[];return async function(...o){const c=async()=>{const r=t?.timeout??12e4,s=t?.discoveryTimeout??50,i=void 0!==t?.daemon?ht(this,t.daemon):ut(this);if(!i)throw new TypeError(`@request('${e}') requires an element, attached controller, or provided @daemon instance.`);const a=n.apply(this,o),{value:c,done:l}=await a.next();if(l)return c;let h,u;const d=new Promise((e,t)=>{h=e,u=t});let f,m,p,y=!1;const g=new Promise((t,n)=>{f=t,m=n,p=setTimeout(()=>{n(new Error(`Request "${e}" found no @respond('${e}') handler within ${s}ms — attach a responding controller/element, or pass { optional: true } to resolve undefined when unhandled.`))},s)}),v=new CustomEvent(`@request/${e}`,{bubbles:void 0===t?.bubbles||t.bubbles,cancelable:t?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{y=!0,clearTimeout(p),f()},reject:m},data:{resolve:h,reject:u}}});i.dispatchEvent(v);try{await g;const t=setTimeout(()=>{u(new Error(`Request "${e}" timed out after ${r}ms`))},r),n=await d;clearTimeout(t);const{value:o}=await a.next(n);return o}catch(e){if(t?.optional&&!y){const{value:e}=await a.next(void 0);return e}const{value:n}=await a.throw(e);return n}};if(t?.debounce)return new Promise((e,n)=>{clearTimeout(r),r=setTimeout(async()=>{try{e(await c())}catch(e){n(e)}},t.debounce)});if(!t?.throttle)return c();const l=Date.now(),h=t.throttle-(l-i);if(h<=0){clearTimeout(s),s=null,i=l;const e=a.splice(0),t=c();return e.length&&t.then(t=>{for(const n of e)n.resolve(t)},t=>{for(const n of e)n.reject(t)}),t}return new Promise(s?(e,t)=>{a.push({resolve:e,reject:t})}:(e,t)=>{a.push({resolve:e,reject:t}),s=setTimeout(async()=>{i=Date.now(),s=null;const e=a.splice(0);try{const t=await c();for(const n of e)n.resolve(t)}catch(t){for(const n of e)n.reject(t)}},h)})}}}function ft(e,t){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,ve)||(o[ve]=new Set),!o[ve].has(n)){if(o[ve].add(n),!Object.prototype.hasOwnProperty.call(o,a)){const e=o[a];o[a]=e?[...e]:[]}o[a].push({channelName:e,methodName:r,method:n,options:t})}})}}function mt(e,t){const n=e.constructor[a];if(n){e[_]||(e[_]={events:[],channels:[]});for(const o of n){const n=o.method.bind(e),r=`@request/${o.channelName}`;let s,i,a=0;const c=[];let l=null;const h=(e=>o.options?.debounce?(...t)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{n(await e(...t))}catch(e){r(e)}},o.options.debounce)}):o.options?.throttle?(...t)=>{const n=Date.now(),r=o.options.throttle-(n-a);if(r<=0){clearTimeout(i),i=null,a=n;const o=c.splice(0);l=null;const r=e(...t);return o.length&&Promise.resolve(r).then(e=>{for(const t of o)t.resolve(e)},e=>{for(const t of o)t.reject(e)}),r}return l=t,new Promise((n,o)=>{c.push({resolve:n,reject:o}),i||(i=setTimeout(async()=>{a=Date.now(),i=null;const n=c.splice(0),o=l??t;l=null;try{const t=await e(...o);for(const e of n)e.resolve(t)}catch(e){for(const t of n)t.reject(e)}},r))})}:e)(n),u=e=>{const{data:t,discovery:n,payload:r}=e.detail;e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation(),n.resolve(),Promise.resolve(h(r)).then(e=>{t.resolve(e)}).catch(e=>{t.reject(e),console.error(`Error in response handler ${o.methodName}:`,e)})};let d=t;if(void 0!==o.options?.daemon)try{d=ht(e,o.options.daemon)}catch(e){console.warn(`[snice/@respond] ${e.message} Responder "${o.channelName}" skipped.`);continue}d.addEventListener(r,u),e[_].channels.push(()=>{d.removeEventListener(r,u)})}}}function pt(e){if(e[_]?.channels){for(const t of e[_].channels)t();e[_].channels=[]}}const yt=new Set(["once","prevent","preventdefault","stop","stoppropagation","capture","passive"]);function gt(e){const t=e.lastIndexOf(".");if(t<0)return;const n=e.slice(t+1).toLowerCase();yt.has(n)&&console.warn(`snice: "@${e}" is not a valid modifier — once/preventDefault/stopPropagation/capture are @on() options, not template modifiers. This registers a listener for event "${e}", which never fires.`)}function vt(e){const t=e.startsWith("~");t&&(e=e.substring(1));const n=e.split("+"),o={key:"",anyModifiers:t};for(const e of n){const t=e.toLowerCase();"ctrl"===t||"control"===t?o.ctrl=!0:"alt"===t?o.alt=!0:"shift"===t?o.shift=!0:"meta"===t||"cmd"===t||"command"===t?o.meta=!0:o.key=bt(e)}return o}function bt(e){return{esc:"Escape",escape:"Escape",enter:"Enter",return:"Enter",space:" ",spacebar:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",delete:"Delete",del:"Delete",backspace:"Backspace",tab:"Tab",home:"Home",end:"End",pageup:"PageUp",pagedown:"PageDown"}[e.toLowerCase()]||e}function wt(e,t){return e.key===t.key&&(!!t.anyModifiers||(t.ctrl?e.ctrlKey:!e.ctrlKey)&&(t.alt?e.altKey:!e.altKey)&&(t.shift?e.shiftKey:!e.shiftKey)&&(t.meta?e.metaKey:!e.metaKey))}const Et=t("on-handlers");function Nt(e,t,n){let o=null,r={};return"string"==typeof t?(o=t,r=n||{}):t&&"object"==typeof t?r=t:null===t&&n&&(r=n),function(t,n){const s=n.name;return n.addInitializer(function(){const n=this.constructor,i=Array.isArray(e)?e:[e],a=`${s}::${i.join(",")}::${o??""}::daemon:${r.daemon??""}`;if(Object.prototype.hasOwnProperty.call(n,ge)||(n[ge]=new Set),!n[ge].has(a)){if(n[ge].add(a),!Object.prototype.hasOwnProperty.call(n,Et)){const e=n[Et];n[Et]=e?[...e]:[]}for(const e of i)n[Et].push({eventName:e,selector:o,methodName:s,method:t,options:r})}}),t}}function At(e,t){let n=0;return function(...o){const r=Date.now();r-n>=t&&(n=r,e.apply(this,o))}}const Tt=new Set(["scroll","focus","blur","load","unload","error","resize","abort","mouseenter","mouseleave","pointerenter","pointerleave"]);function St(e,t){const n=e.constructor[Et];if(n&&Array.isArray(n)&&0!==n.length){e[_]?e[_].events?e[_].events.length>0&&_t(e):e[_].events=[]:e[_]={events:[],channels:[],observers:[]};for(const o of n){const n=e[o.methodName];let r=n?n.bind(e):o.method.bind(e);const s=o.options||{},i=["keydown","keyup","keypress"].includes(o.eventName.split(".")[0].split(":")[0]),a=i?o.eventName.indexOf("."):-1,c=i?o.eventName.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c),h=l>0?o.eventName.substring(0,l):o.eventName,u=l>0?o.eventName.substring(l+1):null;l<=0&&gt(o.eventName),s.debounce&&s.debounce>0?r=He(r,s.debounce):s.throttle&&s.throttle>0&&(r=At(r,s.throttle));let d=null;u&&["keydown","keyup","keypress"].includes(h)&&(d=vt(u));const f=(e=>d?t=>{wt(t,d)&&e(t)}:e)(r),m=void 0!==s.scope,p=void 0!==s.daemon;if(m&&p){console.warn(`[snice/@on] "${o.eventName}" cannot use both scope and daemon — listener skipped.`);continue}if((p||ct(e))&&o.selector){console.warn(`[snice/@on] "${o.eventName}" cannot delegate "${o.selector}" on a daemon target — listener skipped.`);continue}const y=m||p;let g=null;if(p)try{g=ht(e,s.daemon)}catch(e){console.warn(`[snice/@on] ${e.message} Listener "${o.eventName}" skipped.`);continue}else if(m&&(g=Ge(t,s.scope),!g)){console.warn(`[snice/@on] scope did not resolve for "${o.eventName}" on ${o.methodName} — listener skipped.`);continue}if(o.selector){const n=y?g:t.shadowRoot||t,r=e=>{const t=e.target;if(t.matches&&t.matches(o.selector)&&t||t.closest&&t.closest(o.selector)){s.preventDefault&&e.preventDefault(),s.stopPropagation&&(e.stopPropagation(),e.stopImmediatePropagation());try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},i=Tt.has(h),a={capture:void 0!==s.capture?s.capture:i,once:s.once||!1,passive:s.passive||!1};n.addEventListener(h,r,a),e[_].events.push({target:n,eventName:h,handler:r,options:a})}else{const n=y?null:t.shadowRoot,r=Symbol(),i=e=>{if(!e[r]){e[r]=!0,s.preventDefault&&e.preventDefault(),s.stopPropagation&&e.stopPropagation();try{f(e)}catch(e){console.error(`Error in event handler ${o.methodName}:`,e)}}},a={capture:s.capture||!1,once:s.once||!1,passive:s.passive||!1};if(y){g.addEventListener(h,i,a),e[_].events.push({target:g,eventName:h,handler:i,options:a});continue}n&&(n.addEventListener(h,i,a),e[_].events.push({target:n,eventName:h,handler:i,options:a})),t.addEventListener(h,i,a),e[_].events.push({target:t,eventName:h,handler:i,options:a})}}}}function _t(e){if(e[_]?.events){for(const{target:t,eventName:n,handler:o,options:r}of e[_].events)t.removeEventListener(n,o,r);e[_].events=[]}}class xt{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(e,t){this.cleanupFns.set(e,t)}unregister(e){this.cleanupFns.delete(e)}async cleanup(){await Promise.all(this.pendingOperations);for(const e of this.cleanupFns.values())try{await e()}catch(e){console.error("Error during cleanup:",e)}this.cleanupFns.clear()}async runOperation(e){const t=e(),n=t.then(()=>{},()=>{});this.pendingOperations.add(n);try{const e=await t;return this.pendingOperations.delete(n),e}catch(e){throw this.pendingOperations.delete(n),e}}}function Ct(t){return function(o,r){const s=globalThis.snice?.controllerRegistry;if(!s)throw new Error("Snice global registry not initialized");s.set(t,o),o.prototype[n]=!0;const i=e.pendingControllerAttachments.get(t);return i&&(e.pendingControllerAttachments.delete(t),queueMicrotask(()=>{for(const e of i){const n=e[A];(void 0===n?e[g]:n)===t&&$t(e,t).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${t}":`,e)})}})),o}}function Ot(t,n){if(e.controllerRegistry.has(n))return void queueMicrotask(()=>{const e=t[A];(void 0===e?t[g]:e)===n&&$t(t,n).catch(e=>{"ControllerAttachAborted"!==e?.name&&console.error(`Failed to attach controller "${n}":`,e)})});let o=e.pendingControllerAttachments.get(n);o||(o=new Set,e.pendingControllerAttachments.set(n,o)),o.add(t),queueMicrotask(()=>{e.pendingControllerAttachments.get(n)?.has(t)&&console.error(`Failed to attach controller "${n}":`,new Error(`Controller "${n}" not found in registry`))})}function kt(e){return"string"==typeof e?e:e?.name||"(anonymous controller class)"}async function $t(t,r){if("string"!=typeof r){if("function"!=typeof r)throw new Error(`attachController: expected a controller name or a controller class, got ${typeof r}. Controller instances are not supported — pass the class itself.`);if("function"!=typeof(s=r)||!0!==s.prototype?.[n])throw new Error(`Controller class "${kt(r)}" must be decorated with @controller('name') before it can be attached.`)}var s;const i=kt(r),a=t[b],c=t[A];if("string"==typeof r&&void 0!==c&&c!==r)return;if(t[w]===r&&a)return;let l;if(a&&await Lt(t),"string"==typeof r){const e=globalThis.snice?.controllerRegistry;if(!e)throw new Error("Snice global registry not initialized");if(l=e.get(r),!l)throw new Error(`Controller "${r}" not found in registry`)}else l=r,t[T]=!0,delete t[A];const h=new l;e.controllerIdCounter+=1;const u=e.controllerIdCounter,d=new xt;h[o]=!0,h[E]=u,h.element=t;const f=t[R];void 0!==f&&(h[R]=f),t[b]=h,t[w]=r,t[N]=d;const m=new AbortController;t[Te]=m;try{await Promise.race([t.ready,new Promise((e,t)=>{const n=()=>{const e=new Error(`attachController("${i}"): aborted before element was ready (likely detached or never connected)`);e.name="ControllerAttachAborted",t(e)};if(m.signal.aborted)return n();m.signal.addEventListener("abort",n,{once:!0});const o=setTimeout(()=>t(new Error(`attachController("${i}"): element did not become ready within 30000ms (did you forget to appendChild it?)`)),3e4);m.signal.addEventListener("abort",()=>clearTimeout(o),{once:!0})})])}catch(e){throw t[b]===h&&(delete t[b],delete t[w],delete t[N],"string"!=typeof r&&delete t[T]),e}finally{t[Te]===m&&delete t[Te]}h[Se]=!0,await d.runOperation(async()=>{await h.attach(t)}),Ze(h,t),mt(h,t),St(h,t),t.dispatchEvent(new CustomEvent("controller-attached",{detail:{name:i,controller:h}}))}async function Lt(e){const t=e[Te];t&&t.abort();const n=e[b],o=e[w],r=e[N];n&&(delete e[b],delete e[w],delete e[N],"function"==typeof o&&delete e[T],n[Se]&&(r?await r.runOperation(async()=>{await n.detach(e)}):await n.detach(e),n.element=null,rt(n),pt(n),_t(n),r&&await r.cleanup(),delete n[R],e.dispatchEvent(new CustomEvent("controller-detached",{detail:{name:void 0===o?void 0:kt(o),controller:n}}))))}function Pt(e){return e[b]}function jt(){if(globalThis.sniceNativeControllersInitialized)return;function e(e){if(!(e instanceof HTMLElement))return;if(!e.tagName||e.tagName.includes("-"))return;if(e[i])return;if(e[T])return;const t=e.getAttribute("controller"),n=e[A];if(t!==n&&(t||void 0!==n)){if(!t)return delete e[A],delete e[w],void Lt(e).catch(e=>{console.error("Failed to detach controller from native element:",e)});e[A]=t,e.ready||(e.ready=Promise.resolve()),n&&Lt(e).catch(e=>{console.error("Failed to detach old controller from native element:",e)}),$t(e,t).catch(n=>{"ControllerAttachAborted"!==n?.name?n?.message!==`Controller "${t}" not found in registry`?console.error(`Failed to attach controller "${t}" to native element:`,n):Ot(e,t):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}globalThis.sniceNativeControllersInitialized=!0;const t=new MutationObserver(t=>{for(const n of t)"attributes"===n.type&&"controller"===n.attributeName?e(n.target):"childList"===n.type&&n.addedNodes.forEach(t=>{t instanceof HTMLElement&&(e(t),t.querySelectorAll("[controller]").forEach(e))})});function n(){document.querySelectorAll("[controller]").forEach(e),t.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",n):n(),globalThis.sniceNativeControllerObserver=t}const Mt=t("context-handlers");function Rt(e={}){return function(t,n){const o=n.name;return n.addInitializer(function(){const n=this.constructor;if(Object.prototype.hasOwnProperty.call(n,me)||(n[me]=new Set),!n[me].has(t)){if(n[me].add(t),!Object.prototype.hasOwnProperty.call(n,Mt)){const e=n[Mt];n[Mt]=e?[...e]:[]}n[Mt].push({methodName:o,method:t,options:e})}}),t}}function It(e){const t=e.constructor[Mt];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[re];if(n){e[se]=n;for(const o of t){const{methodName:t,method:r,options:s}=o,i=`__wrapped_${t}`;e[i]=function(n){const o=e[de]||(e[de]=new Set);if(s.once&&o.has(t))return;const a=()=>{if(r.call(e,n),s.once){o.add(t);const n=e[se];n&&"function"==typeof n[le]&&n[le](e,i)}},c=e[ue]||(e[ue]={}),l=t;if(s.debounce)return clearTimeout(c[l]?.timeout),void(c[l]={timeout:setTimeout(a,s.debounce)});if(s.throttle){const e=Date.now();return void(e-(c[l]?.lastCall||0)>=s.throttle&&(c[l]={lastCall:e},a()))}a()},"function"==typeof n[ce]&&n[ce](e,i)}}}const Dt=Symbol.for("snice:html-result"),Vt=Symbol.for("snice:css-result"),qt=new WeakMap;function Bt(e,...t){return{_$litType$:Dt,strings:e,values:t}}function Ft(e,...t){return{_$litType$:Dt,strings:e,values:t,svg:!0}}function Wt(e,...t){const n=0===t.length?qt.get(e):void 0;if(n)return n;let o=e[0];for(let n=0;n<t.length;n++){const r=t[n];o+=(Ut(r)?r.cssText:String(r))+e[n+1]}const r={_$litType$:Vt,cssText:o};if("undefined"!=typeof CSSStyleSheet&&"undefined"!=typeof Document&&"adoptedStyleSheets"in Document.prototype)try{const e=new CSSStyleSheet;e.replaceSync(o),r.styleSheet=e}catch(e){}return 0===t.length&&qt.set(e,r),r}function zt(e){return e&&e._$litType$===Dt}function Ut(e){return e&&e._$litType$===Vt}const Ht=Symbol.for("snice:nothing"),Kt=Symbol.for("snice:unsafe-html");function Gt(e){return{_$litType$:Kt,html:e}}function Qt(e){return e&&e._$litType$===Kt}const Jt=Symbol.for("snice:repeat-result");function Xt(e,t){if(!t||"function"!=typeof t.key||"function"!=typeof t.render)throw new TypeError("snice: repeat() requires { key, render }.");const n=null==e?[]:Array.from(e),o=n.map(t.key),r=new Set;for(const e of o){if(r.has(e))throw new Error(`snice: repeat() received duplicate key ${String(e)}.`);r.add(e)}return{_$repeat$:Jt,items:n,keys:o,values:n.map(t.render),empty:0===n.length?"function"==typeof t.empty?t.empty():t.empty:void 0}}const Yt=new WeakSet;function Zt(e){return e[p]||e.shadowRoot||null}function en(e){const t=Zt(e);if(t)return t;const n=e.constructor[y];let o;if(o="light"===n?.renderRoot||!1===n?.shadow?e:"function"==typeof e.createRenderRoot?e.createRenderRoot():e.attachShadow({mode:"string"==typeof n?.shadow?n.shadow:"open",delegatesFocus:n?.delegatesFocus}),o!==e&&!(o instanceof ShadowRoot))throw new TypeError("snice: createRenderRoot() must return the host element or a ShadowRoot.");return e[p]=o,Yt.add(e),o}function tn(e){const t=e.getRootNode();if(t instanceof ShadowRoot)return t.host;let n=e;for(;n;){if(n instanceof HTMLElement&&Yt.has(n))return n;n=n.parentNode}return null}const nn=`snice$${Math.random().toFixed(9).slice(2)}$`,on="?"+nn,rn=`\x3c!--${on}--\x3e`,sn=new RegExp(nn.replace(/\$/g,"\\$"),"g"),an=new WeakMap,cn=Symbol("not-committed");function ln(e,t){const n=e.localName;if(!n?.includes("-"))return;const o=e.ownerDocument?.defaultView?.customElements??globalThis.customElements;if(o?.get(n))return;const r=e;r[L]||(r[L]=new Set),r[L].add(t)}const hn=Symbol.for("snice:no-change"),un=Symbol.for("snice:live");function dn(e){return{_$liveMarker$:un,value:e}}const fn=e=>null===e||"object"!=typeof e&&"function"!=typeof e,mn=e=>!!e&&"function"==typeof e[Symbol.asyncIterator];class pn{constructor(e,t,n){this.parts=[],this.keyIndex=-1,this.element=t;const o=document.createTreeWalker(t.content,NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_COMMENT|NodeFilter.SHOW_TEXT);let r=0;const s=[];let i;for(;null!==(i=o.nextNode());)if(i.nodeType===Node.ELEMENT_NODE){const e=i,t=e.tagName.toLowerCase(),o=e.parentElement?.tagName.toLowerCase();if(("else"===t||"else-if"===t)&&"if"!==o)throw new Error(`snice: <${t}> must be a direct child of <if>.`);if(("when"===t||"default"===t)&&"case"!==o)throw new Error(`snice: <${t}> must be a direct child of <case>.`);if("if"===t){const t=e.getAttribute("value");if(!t||!t.includes(nn))throw new Error("snice: <if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-if",index:r++,element:e});continue}if("case"===t){const t=e.getAttribute("value");if(!t||!t.includes(nn))throw new Error("snice: <case> requires a value expression.");for(const t of Array.from(e.childNodes))if(t.nodeType===Node.ELEMENT_NODE){const e=t.tagName.toLowerCase();if("when"!==e&&"default"!==e)throw new Error("snice: <case> may contain only direct <when> and <default> branches.")}else if(t.nodeType===Node.TEXT_NODE&&t.textContent?.trim()||t.nodeType===Node.COMMENT_NODE&&t.data.includes(nn))throw new Error("snice: content inside <case> must be nested in a <when> or <default> branch.");e.removeAttribute("value"),this.parts.push({type:"conditional-case",index:r++,element:e});continue}if("else-if"===t){const t=e.getAttribute("value");if(!t||!t.includes(nn))throw new Error("snice: <else-if> requires a condition expression.");e.removeAttribute("value"),this.parts.push({type:"conditional-else-if",index:r++,element:e});continue}if("when"===t){const t=e.getAttribute("value");t&&t.includes(nn)&&(e.removeAttribute("value"),this.parts.push({type:"conditional-when",index:r++,element:e}));continue}if(e.hasAttributes()){const t=e.attributes,o=[];for(let s=0;s<t.length;s++){const i=t[s],a=i.value;if(a.includes(nn)){o.push(i);const t=n[r]||i.name,s=a.split(nn),c=s.length-1;if(/^@@?|^[.?]/.test(t)||t.startsWith("...")||t.startsWith("class:")||t.startsWith("style:")){const e=s.some(e=>""!==e);(c>1||e)&&console.warn(`snice: binding "${t}" takes a single expression; static text and extra interpolations are ignored. Use a plain attribute for string interpolation.`)}if(t.startsWith("...")){const n=t.slice(3).toLowerCase();if(!["props","properties","attrs","attributes","events"].includes(n))throw new Error(`snice: unknown spread binding "${t}". Use ...props, ...attrs, or ...events.`);this.parts.push({type:"spread",index:r,name:n,element:e}),r+=c}else if(t.startsWith("class:")){if(!t.slice(6))throw new Error("snice: class: binding requires a class name.");this.parts.push({type:"class",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("style:")){if(!t.slice(6))throw new Error("snice: style: binding requires a CSS property name.");this.parts.push({type:"style",index:r,name:t.slice(6),element:e}),r+=c}else if(t.startsWith("@@")){if(!t.slice(2).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("@")){if(!t.slice(1).split("|")[0])throw new Error("snice: event binding requires an event name.");this.parts.push({type:"event",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith(".")){if(!t.slice(1))throw new Error("snice: property binding requires a property name.");this.parts.push({type:"property",index:r,name:t.slice(1),element:e}),r+=c}else if(t.startsWith("?")){if(!t.slice(1))throw new Error("snice: boolean binding requires an attribute name.");this.parts.push({type:"boolean-attribute",index:r,name:t.slice(1),element:e}),r+=c}else"controller"===i.name&&2===s.length&&""===s[0]&&""===s[1]?(this.parts.push({type:"controller",index:r,element:e}),r+=c):(this.parts.push({type:"attribute",index:r,name:i.name,element:e,attrStrings:s}),r+=c)}}for(const t of o)e.removeAttribute(t.name)}}else if(i.nodeType===Node.COMMENT_NODE){const e=i;if(e.data===on){const t=e.parentNode,n=document.createComment("");t.insertBefore(n,e.nextSibling),this.parts.push({type:"node",index:r++,startNode:e,endNode:n})}else if(e.data.includes(nn)){const t=e.data.split(sn);this.parts.push({type:"comment",index:r,startNode:e,attrStrings:t}),r+=t.length-1}}else if(i.nodeType===Node.TEXT_NODE){const e=i,t=e.data;if(t.includes(nn)){const n=e.parentNode,o=t.split(sn),i=o.length-1;for(let t=0;t<i;t++){n.insertBefore(document.createTextNode(o[t]),e);const s=document.createComment(""),i=document.createComment("");n.insertBefore(s,e),n.insertBefore(i,e),this.parts.push({type:"node",index:r++,startNode:s,endNode:i})}""!==o[i]?e.data=o[i]:s.push(e)}}for(const e of s)e.parentNode?.removeChild(e);for(const e of this.parts)if("attribute"===e.type&&"key"===e.name){this.keyIndex=e.index;break}}}function yn(e){const{strings:t}=e,n=an.get(t);if(n)return n;const o=[],r=[];let s=!1,i=!1,a=!1,c="",l="";for(let e=0;e<t.length;e++){const n=t[e];if(o.push(n),e<t.length-1){for(let e=0;e<n.length;e++){const t=n[e];if(a)"-"===t&&n.startsWith("--\x3e",e)&&(a=!1,e+=2);else if(s){if(i)t===c&&(i=!1,c="");else if(">"===t)s=!1;else if('"'===t||"'"===t)i=!0,c=t;else if("="===t){let t=e-1;for(;t>=0&&/[\w\-\.@\?/:\+~|]/.test(n[t]);)t--;l=n.substring(t+1,e).trim()}}else"<"===t&&(n.startsWith("\x3c!--",e)?(a=!0,e+=3):/[A-Za-z!/?]/.test(n[e+1]||"")&&(s=!0))}if(a)r.push(""),o.push(nn);else if(i)r.push(l),o.push(nn);else if(s){const e=n.trimEnd();if(e.endsWith("=")){let t=e.length-2;for(;t>=0&&/[\w\-\.@\?\/:\+~|]/.test(e[t]);)t--;l=e.substring(t+1,e.length-1).trim(),r.push(l),o.push(nn)}else{if(!n.match(/<(if|else-if|case|when)\s*$/))throw new Error("snice: expressions directly in opening tags are not supported; use an explicit attribute, property, event, class, style, or named spread binding.");l="value",r.push("value"),o.push(`value="${nn}"`)}}else r.push(""),o.push(rn)}}const h=o.join(""),u=document.createElement("template");if(e.svg){u.innerHTML=`<svg>${h}</svg>`;const e=u.content.firstElementChild;for(;e.firstChild;)u.content.insertBefore(e.firstChild,e);u.content.removeChild(e)}else u.innerHTML=h;const d=new pn(e,u,r);return an.set(t,d),d}function gn(e){if(!zt(e))return;const t=yn(e);return-1===t.keyIndex?void 0:e.values[t.keyIndex]}class vn{constructor(e){this.parts=[],this.fragment=null,this.conditionalParts=[],this.regularParts=[],this.template=yn(e),this.strings=e.strings}isSameTemplate(e){return this.strings===e}renderFragment(){if(!this.fragment){this.fragment=this.template.element.content.cloneNode(!0);const e=document.createTreeWalker(this.template.element.content,NodeFilter.SHOW_ALL),t=document.createTreeWalker(this.fragment,NodeFilter.SHOW_ALL),n=new Map;let o=e.currentNode,r=t.currentNode;for(;o&&r;)n.set(o,r),o=e.nextNode(),r=t.nextNode();const s=new Set;for(const e of this.template.parts)"conditional-when"===e.type&&s.add(n.get(e.element));for(let e=0;e<this.template.parts.length;e++){const t=this.template.parts[e];let o;switch(t.type){case"node":const e=n.get(t.startNode),r=n.get(t.endNode);o=new wn(e,r);break;case"attribute":const i=n.get(t.element);o=new En(i,t.name,t.attrStrings);break;case"property":const a=n.get(t.element);o=new _n(a,t.name);break;case"boolean-attribute":const c=n.get(t.element);o=new Cn(c,t.name);break;case"event":const l=n.get(t.element);o=new On(l,t.name);break;case"class":const h=n.get(t.element);o=new An(h,t.name);break;case"style":const u=n.get(t.element);o=new Tn(u,t.name);break;case"spread":const d=n.get(t.element);o=new Sn(d,t.name);break;case"controller":const f=n.get(t.element);o=new xn(f);break;case"conditional-if":const m=n.get(t.element);o=new $n(m);break;case"conditional-else-if":const p=n.get(t.element);o=new Pn(p);break;case"conditional-case":const y=n.get(t.element);o=new jn(y,s);break;case"conditional-when":const g=n.get(t.element);o=new Rn(g);break;case"comment":const v=n.get(t.startNode);o=new Nn(v,t.attrStrings);break;default:throw new Error(`Unknown part type: ${t.type}`)}this.parts.push(o),o instanceof $n||o instanceof Pn||o instanceof jn||o instanceof Rn?this.conditionalParts.push({part:o,index:t.index}):this.regularParts.push({part:o,index:t.index})}}return this.fragment}render(e){const t=this.renderFragment();return this.update(e),t}update(e){for(const{part:t,index:n}of this.conditionalParts)t.commit(e[n]);const t=new Set;for(const{part:e}of this.conditionalParts){const n=e instanceof Pn||e instanceof Rn?e.coordinator:e;t.has(n)||(t.add(n),(n instanceof $n||n instanceof jn)&&n.flush())}for(const{part:t,index:n}of this.regularParts)t instanceof En&&void 0!==t.strings||t instanceof Nn?t.commit(e,n):t.commit(e[n]);let n;for(const e of this.parts)try{e.isConnected?e.reconnected():e.disconnected()}catch(e){n??=e}if(n)throw n}clear(){let e;for(const t of this.parts)try{t.destroy()}catch(t){e??=t}if(e)throw e}disconnected(e=!1){let t;for(const n of this.parts)try{n.disconnected(e)}catch(e){t??=e}if(t)throw t}reconnected(){let e;for(const t of this.parts)try{t.reconnected()}catch(t){e??=t}if(e)throw e}}class bn{get isConnected(){return this.element?.isConnected??!1}disconnected(e=!1){}reconnected(){}destroy(){let e;try{this.clear()}catch(t){e=t}if(e)throw e}}class wn extends bn{constructor(e,t){super(),this.type="node",this._committedValue=cn,this._itemKeys=null,this._asyncSource=null,this._asyncVersion=0,this._asyncIterator=null,this._asyncRunning=!1,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1,this._committingAsyncValue=!1,this.startNode=e,this.endNode=t}commit(e){if(e!==hn)if((e=>!!e&&"function"==typeof e.then)(e)||mn(e))this._commitAsync(e);else if(!this._committingAsyncValue&&this._asyncSource&&this._cancelAsync(!0),e!==Ht&&null!=e&&""!==e)fn(e)?e!==this._committedValue&&this._commitText(e):zt(e)?this._commitTemplateResult(e):function(e){return!!e&&e._$repeat$===Jt}(e)?0===e.values.length?this.commit(e.empty??Ht):this._commitIterable(e.values,e.keys):Qt(e)?this._commitUnsafeHTML(e):void 0===e.nodeType?(e=>Array.isArray(e)||"function"==typeof e?.[Symbol.iterator])(e)?this._commitIterable(e):this._commitText(e):this._commitNode(e);else{if(this._committedValue!==Ht){const e=this._clear();if(this._committedValue=Ht,e)throw e}this._committedValue=Ht}}_commitText(e){if(this._committedValue!==cn&&this._committedValue!==Ht&&fn(this._committedValue)&&!Array.isArray(this._committedValue)){const t=this.startNode.nextSibling;if(t&&t.nodeType===Node.TEXT_NODE)return t.data=String(e),void(this._committedValue=e)}const t=this._clear();if(this._insertBefore(document.createTextNode(String(e))),this._committedValue=e,t)throw t}_commitTemplateResult(e){const t=this._committedValue;if(t instanceof vn){const n=an.get(e.strings);if(n&&t.template===n)return void t.update(e.values)}const n=new vn(e),o=n.renderFragment();try{n.update(e.values)}catch(e){throw n.clear(),e}const r=this._committedValue,s=this._itemKeys,i=this.endNode.ownerDocument.createDocumentFragment();let a=this.startNode.nextSibling;for(;a&&a!==this.endNode;){const e=a.nextSibling;i.appendChild(a),a=e}this._insertBefore(o),this._committedValue=n,this._itemKeys=null;try{this.isConnected&&n.reconnected()}catch(e){try{n.clear()}catch(e){console.error("snice: failed to clean up a rejected nested template:",e)}let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const e=t.nextSibling;t.remove(),t=e}throw this._insertBefore(i),this._committedValue=r,this._itemKeys=s,e}this._disposeCommitted(r)}_commitIterable(e,t){const n=Array.isArray(e)?e:Array.from(e),o=t?Array.from(t):n.map(gn);if(o.length!==n.length)throw new Error("snice: keyed iterable produced a different number of keys and values.");const r=o.filter(e=>void 0!==e);if(r.length>0&&r.length!==o.length&&console.warn("snice: a list mixes keyed and unkeyed items. Identity falls back to position; use repeat(items, { key, render }) for deterministic updates."),r.length>0&&new Set(r).size!==r.length)throw new Error("snice: a keyed list contains duplicate keys.");let s;Array.isArray(this._committedValue)&&this._committedValue[0]instanceof wn||(s=this._clear(),this._committedValue=[],this._itemKeys=null);const i=n.length>0&&o.every(e=>void 0!==e),a=this._itemKeys;if(i&&a&&this._committedValue.length>0&&(a.length!==o.length||!o.every((e,t)=>e===a[t]))){if(s??=this._reconcileKeyed(n,o,this._committedValue,a),this._itemKeys=o,s)throw s;return}const c=this._committedValue;let l=0;for(const e of n){let t;if(l>=c.length){const e=document.createComment(""),n=document.createComment("");this._insertBefore(e),this._insertBefore(n),t=new wn(e,n),c.push(t)}else t=c[l];t.commit(e),l++}if(l<c.length){for(let e=l;e<c.length;e++){const t=c[e];try{t.destroy()}catch(e){s??=e}t.startNode.remove(),t.endNode.remove()}c.length=l}if(this._itemKeys=i?o:null,s)throw s}_reconcileKeyed(e,t,n,o){const r=this.endNode.parentNode;let s;const i=new Map;for(let e=0;e<n.length;e++)i.has(o[e])||i.set(o[e],n[e]);const a=new Set,c=new Array(e.length).fill(null);for(let n=0;n<e.length;n++){const e=i.get(t[n]);e&&!a.has(e)&&(a.add(e),c[n]=e)}for(const e of n)if(!a.has(e)){try{e.destroy()}catch(e){s??=e}e.startNode.remove(),e.endNode.remove()}let l=this.startNode.nextSibling;for(let t=0;t<c.length;t++){let n=c[t];if(n)if(n.startNode===l)l=n.endNode.nextSibling;else{const e=document.createDocumentFragment();let t=n.startNode;const o=n.endNode.nextSibling;for(;t&&t!==o;){const n=t.nextSibling;e.appendChild(t),t=n}r.insertBefore(e,l)}else{const e=document.createComment(""),o=document.createComment("");r.insertBefore(e,l),r.insertBefore(o,l),n=new wn(e,o),c[t]=n}n.commit(e[t])}return this._committedValue=c,s}_commitNode(e){if(this._committedValue!==e){const t=this._clear();if(this._insertBefore(e),this._committedValue=e,t)throw t}}_commitUnsafeHTML(e){const t=this._committedValue;if(Qt(t)&&t.html===e.html)return;const n=this._clear(),o=document.createElement("template");if(o.innerHTML=e.html,this._insertBefore(o.content),this._committedValue=e,n)throw n}_commitAsync(e){if(e===this._asyncSource)return;this._cancelAsync(!1),this._asyncSource=e,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1;const t=this._clear();if(this._committedValue=Ht,this._startAsyncSource(),t)throw t}_startAsyncSource(e=!1){const t=this._asyncSource;if(!t||this._asyncRunning||this._asyncCompleted||!e&&!this.isConnected)return;this._asyncRunning=!0,this._asyncStarted=!0,this._asyncPaused=!1;const n=++this._asyncVersion;if(mn(t)){try{this._asyncIterator=t[Symbol.asyncIterator]()}catch(e){return this._asyncRunning=!1,this._asyncCompleted=!0,void console.error("snice: async iterable template value failed:",e)}(async()=>{try{for(;this._asyncIterator;){const e=await this._asyncIterator.next();if(e.done||n!==this._asyncVersion)break;this._commitAsyncValue(e.value)}}catch(e){n===this._asyncVersion&&console.error("snice: async iterable template value failed:",e)}finally{n===this._asyncVersion&&(this._asyncIterator=null,this._asyncRunning=!1,this._asyncCompleted=!0)}})()}else Promise.resolve(t).then(e=>{if(n===this._asyncVersion){this._asyncRunning=!1,this._asyncCompleted=!0;try{this._commitAsyncValue(e)}catch(e){console.error("snice: promise template value failed:",e)}}},e=>{n===this._asyncVersion&&(this._asyncRunning=!1,this._asyncCompleted=!0,console.error("snice: promise template value failed:",e))})}_commitAsyncValue(e){this._committingAsyncValue=!0;try{this.commit(e)}finally{this._committingAsyncValue=!1}}_cancelAsync(e){this._asyncVersion++;const t=this._asyncIterator;if(this._asyncIterator=null,this._asyncRunning=!1,e&&(this._asyncSource=null,this._asyncStarted=!1,this._asyncCompleted=!1,this._asyncPaused=!1),t?.return)try{Promise.resolve(t.return()).catch(()=>{})}catch{}}_insertBefore(e){this.endNode.parentNode?.insertBefore(e,this.endNode)}_clear(){const e=this.startNode.parentNode,t=this._committedValue;let n;try{this._disposeCommitted(t)}catch(e){n=e}if(!e)return this._committedValue=Ht,n;let o=this.startNode.nextSibling;for(;o&&o!==this.endNode;){const t=o.nextSibling;e.removeChild(o),o=t}return this._committedValue=Ht,n}_disposeCommitted(e){let t;if(e instanceof vn)try{e.clear()}catch(e){t=e}else if(Array.isArray(e))for(const n of e)if(n instanceof wn)try{n.destroy()}catch(e){t??=e}if(t)throw t}clear(){this._cancelAsync(!0);const e=this._clear();if(e)throw e}get isConnected(){return this.startNode.isConnected}disconnected(e=!1){let t;if(this._committedValue instanceof vn)try{this._committedValue.disconnected(e)}catch(e){t??=e}else if(Array.isArray(this._committedValue))for(const n of this._committedValue)if(n instanceof wn)try{n.disconnected(e)}catch(e){t??=e}if(this._asyncSource&&this._asyncRunning&&(this._cancelAsync(!1),this._asyncPaused=!0),t)throw t}reconnected(){let e;if(this._committedValue instanceof vn)try{this._committedValue.reconnected()}catch(t){e??=t}else if(Array.isArray(this._committedValue))for(const t of this._committedValue)if(t instanceof wn)try{t.reconnected()}catch(t){e??=t}if(!this._asyncSource||this._asyncStarted&&!this._asyncPaused||this._startAsyncSource(!0),e)throw e}}class En extends bn{constructor(e,t,n){super(),this.type="attribute",this._committedValue=cn,this.lastValues=null,this.lastValueIndex=0,this.element=e,this.name=t,n&&(n.length>2||""!==n[0]||""!==n[1])?(this._committedValue=new Array(n.length-1).fill(cn),this.strings=n):this._committedValue=cn}commit(e,t=0){let n,o=!1;if(void 0===this.strings){if(e===hn)return;if(o=!fn(e)||e!==this._committedValue&&e!==hn,!o)return;this._committedValue=e,n=e}else{const r=e;this.lastValues=[...r],this.lastValueIndex=t;const s=this._committedValue;n=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let i=r[t+e];i===hn&&(i=s[e],i===cn&&(i="")),o=o||!fn(i)||i!==s[e],i===Ht?n=Ht:n!==Ht&&(n=n+(i??"")+this.strings[e+1]),s[e]=i}if(!o)return}this._commitValue(n)}_commitValue(e){e===Ht?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,String(e??""))}clear(){this.element.removeAttribute(this.name)}}class Nn extends bn{constructor(e,t){super(),this.type="node",this.lastValues=null,this.lastValueIndex=0,this.node=e,this.strings=t,this._committedValues=new Array(t.length-1).fill(cn)}commit(e,t=0){const n=e;this.lastValues=[...n],this.lastValueIndex=t;let o=!1,r=this.strings[0];for(let e=0;e<this.strings.length-1;e++){let s=n[t+e];s===hn&&(s=this._committedValues[e],s===cn&&(s="")),o=o||!fn(s)||s!==this._committedValues[e],this._committedValues[e]=s,r+=String(s===Ht?"":s??"")+this.strings[e+1]}if(o){if(r.includes("--")||r.endsWith("-"))throw new Error('snice: comment expressions cannot produce "--" or end with "-".');this.node.data=r}}clear(){}}class An extends bn{constructor(e,t){super(),this.type="class",this.committed=cn,this.element=e,this.name=t}commit(e){if(e===hn)return;const t=e!==Ht&&Boolean(e);t!==this.committed&&(this.committed=t,this.element.classList.toggle(this.name,t))}clear(){this.element.classList.remove(this.name),this.committed=cn}}class Tn extends bn{constructor(e,t){super(),this.type="style",this.committed=cn,this.element=e,this.name=t}commit(e){if(e===hn||Object.is(e,this.committed))return;this.committed=e;const t=this.element.style;e===Ht||null==e||!1===e?t.removeProperty(this.name):t.setProperty(this.name,String(e))}clear(){this.element.style.removeProperty(this.name),this.committed=cn}}class Sn extends bn{constructor(e,t){super(),this.type="spread",this.committed={},this.listeners=new Map,this.consumedOnce=new Map,this.element=e,this.name=t}commit(e){if(e===hn)return;if(e!==Ht&&null!=e||(e={}),"object"!=typeof e||Array.isArray(e))throw new TypeError(`snice: ...${this.name} expects an object.`);const t=e;"events"===this.name?this.commitEvents(t):"props"===this.name||"properties"===this.name?this.commitProperties(t):this.commitAttributes(t),this.committed={...t}}commitProperties(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||(ln(this.element,t),this.element[t]=void 0);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(ln(this.element,t),this.element[t]=n===Ht?void 0:n)}commitAttributes(e){for(const t of Object.keys(this.committed))Object.prototype.hasOwnProperty.call(e,t)||this.element.removeAttribute(t);for(const[t,n]of Object.entries(e))Object.is(this.committed[t],n)||(n===Ht||null==n||!1===n?this.element.removeAttribute(t):this.element.setAttribute(t,!0===n?"":String(n)))}commitEvents(e){!function(e,t){const n=new Set;for(const[o,r]of Object.entries(e)){const e=o.startsWith("@")?o.slice(1):o;if(!e)throw new TypeError(`snice: ${t} contains an empty event name.`);if(n.has(e))throw new TypeError(`snice: ${t} contains duplicate event name "${e}".`);if(n.add(e),r!==Ht&&null!=r&&!1!==r&&"function"!=typeof r&&(!r||"object"!=typeof r||"function"!=typeof r.handleEvent))throw new TypeError(`snice: ${t} event "${e}" expects a function, EventListenerObject, or null.`)}}(e,`...${this.name}`);for(const[t,n]of this.consumedOnce){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n)||this.consumedOnce.delete(t)}for(const[t,n]of this.listeners){const o=Object.keys(e).find(e=>this.eventName(e)===t);o&&Object.is(e[o],n.value)||(this.element.removeEventListener(t,n.listener,n.options),this.listeners.delete(t))}for(const[t,n]of Object.entries(e)){const e=this.eventName(t);if(this.listeners.has(e))continue;const o=!!n&&"object"==typeof n&&"function"==typeof n.handleEvent;if(n===Ht||null==n||!1===n)continue;if(this.consumedOnce.has(e)&&Object.is(this.consumedOnce.get(e),n))continue;this.consumedOnce.delete(e);const r=o?n:void 0,s=t=>{r?.once&&this.consumedOnce.set(e,n),o?n.handleEvent(t):n.call(this.resolveHost(),t)};this.element.addEventListener(e,s,r),this.listeners.set(e,{value:n,listener:s,options:r})}}eventName(e){return e.startsWith("@")?e.slice(1):e}resolveHost(){return tn(this.element)||this.element}clear(){if("events"===this.name){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear(),this.consumedOnce.clear()}else if("props"!==this.name&&"properties"!==this.name)for(const e of Object.keys(this.committed))this.element.removeAttribute(e);this.committed={}}disconnected(e=!1){"events"!==this.name||e||this.detachListeners()}reconnected(){"events"===this.name&&0===this.listeners.size&&this.commitEvents(this.committed)}detachListeners(){for(const[e,t]of this.listeners)this.element.removeEventListener(e,t.listener,t.options);this.listeners.clear()}}class _n extends bn{constructor(e,t){super(),this.type="property",this._committedValue=cn,this.element=e,this.name=t}commit(e){if(e!==hn){if(function(e){return e&&e._$liveMarker$===un}(e)){if((e=e.value)===hn)return;if(e===this.element[this.name])return void(this._committedValue=e)}else if(e===this._committedValue)return;this._committedValue=e,ln(this.element,this.name),this.element[this.name]=e===Ht?void 0:e}}clear(){this._committedValue=cn}}class xn extends bn{constructor(e){super(),this.type="controller",this._committedValue=cn,this.element=e}commit(e){if(e===hn)return;const t=null==e||!1===e||""===e||e===Ht?null:e,n=this._committedValue===cn,o=n?null:this._committedValue;if(!n&&t===o)return;this._committedValue=t;const r=this.element;"function"==typeof o&&"function"!=typeof t&&(void 0!==r[S]?delete r[S]:r[i]?r.controller=null:this._detach()),"function"==typeof t?(this.element.hasAttribute("controller")&&this.element.removeAttribute("controller"),this.isConnected?this._apply(t):this.element.localName.includes("-")&&!r[i]&&(r[S]=t)):"string"==typeof t?this.element.setAttribute("controller",t):"string"==typeof o&&this.element.removeAttribute("controller")}_apply(e){const t=this.element;t[i]?t.controller!==e?t.controller=e:this._attach(e):this.element.localName.includes("-")?t[S]=e:(t.ready||(t.ready=Promise.resolve()),this._attach(e))}_attach(e){$t(this.element,e).catch(t=>{"ControllerAttachAborted"!==t?.name&&console.error(`Failed to attach controller "${e?.name||e}":`,t)})}_detach(){Lt(this.element).catch(e=>{console.error("Failed to detach controller:",e)})}disconnected(e=!1){if("function"!=typeof this._committedValue)return;const t=this.element;void 0===t[S]&&(t[i]||this._detach())}reconnected(){const e=this._committedValue;"function"==typeof e&&this._apply(e)}clear(){const e=this.element;void 0!==e[S]&&delete e[S];const t=this._committedValue;this._committedValue=cn,"function"==typeof t&&(e[i]||this._detach())}}class Cn extends bn{constructor(e,t){super(),this.type="boolean-attribute",this._committedValue=cn,this.element=e,this.name=t}commit(e){if(e===hn)return;const t=!!e&&e!==Ht;t!==this._committedValue&&(this._committedValue=t,t?this.element.setAttribute(this.name,""):this.element.removeAttribute(this.name))}clear(){this.element.removeAttribute(this.name),this._committedValue=cn}}class On extends bn{constructor(e,t){super(),this.type="event",this.listener=null,this.listenerOptions=void 0,this.value=void 0,this.keyFilter=null,this.host=null,this.modifiers=new Set,this.once=!1,this.onceConsumed=!1,this.element=e;const[n,...o]=t.split("|"),r={preventdefault:"prevent",stoppropagation:"stop",stopimmediatepropagation:"immediate"},s=new Set(["prevent","stop","immediate","once","capture","passive","self"]);for(const e of o){const n=r[e.toLowerCase()]||e.toLowerCase();if(!s.has(n))throw new Error(`snice: unknown event modifier "${e}" in @${t}. Supported modifiers: prevent, stop, immediate, once, capture, passive, self.`);this.modifiers.add(n)}if(this.modifiers.has("passive")&&this.modifiers.has("prevent"))throw new Error(`snice: @${t} cannot combine passive and prevent.`);const i=["keydown","keyup","keypress"].includes(n.split(".")[0].split(":")[0]),a=i?n.indexOf("."):-1,c=i?n.indexOf(":"):-1,l=a>0&&c>0?Math.min(a,c):Math.max(a,c);if(l>0){const e=n.substring(0,l),t=n.substring(l+1);this.eventName=e,this.keyFilter=vt(t)}else this.eventName=n,gt(n)}commit(e){if(e===hn)return;e===Ht&&(e=null);const t=!!e&&"object"==typeof e&&"function"==typeof e.handleEvent;if(null!=e&&!1!==e&&"function"!=typeof e&&!t)throw new TypeError(`snice: @${this.eventName} expects a function, EventListenerObject, or null.`);if(t&&this.modifiers.has("prevent")&&e.passive)throw new Error(`snice: @${this.eventName} cannot combine a passive listener object with prevent.`);if(e!==this.value||null==e){if(this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0),null==e||!1===e)return this.value=e,void(this.onceConsumed=!1);this.onceConsumed=!1;try{this.attachListener(e,t),this.value=e}catch(e){throw this.value=void 0,e}}}attachListener(e,t){const n=this.keyFilter,o=r=>{this.modifiers.has("self")&&r.target!==this.element||n&&!wt(r,n)||(this.once&&(this.onceConsumed=!0,this.element.removeEventListener(this.eventName,o,s),this.listener=null,this.listenerOptions=void 0),this.modifiers.has("prevent")&&r.preventDefault(),this.modifiers.has("immediate")?r.stopImmediatePropagation():this.modifiers.has("stop")&&r.stopPropagation(),t?e.handleEvent(r):(this.host||(this.host=tn(this.element)),e.call(this.host||this.element,r)))},r=t?e:{};this.once=this.modifiers.has("once")||!!r.once;const s={capture:this.modifiers.has("capture")||r.capture,passive:this.modifiers.has("passive")||r.passive,signal:r.signal};this.element.addEventListener(this.eventName,o,s),this.listener=o,this.listenerOptions=s}clear(){this.detachListener(),this.value=void 0,this.host=null,this.onceConsumed=!1}detachListener(){this.listener&&(this.element.removeEventListener(this.eventName,this.listener,this.listenerOptions),this.listener=null,this.listenerOptions=void 0)}disconnected(e=!1){e||this.detachListener(),this.host=null}reconnected(){this.listener||this.onceConsumed||null==this.value||!1===this.value||this.attachListener(this.value,"object"==typeof this.value)}}const kn=Symbol("not-set");class $n extends bn{constructor(e){super(),this.type="node",this.conditions=[kn],this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const t=e.parentNode;this.startNode=document.createComment("if"),this.endNode=document.createComment("/if"),t.insertBefore(this.startNode,e),t.insertBefore(this.endNode,e.nextSibling);const n=document.createDocumentFragment();this.branches.push(n);let o=!1,r=n;for(const t of Array.from(e.childNodes)){const e=t.nodeType===Node.ELEMENT_NODE?t.tagName.toLowerCase():"";if("else-if"===e||"else"===e){o=!0;const n=t,s=document.createDocumentFragment();for(;n.firstChild;)s.appendChild(n.firstChild);const i=this.branches.push(s)-1;if(r=s,"else-if"===e){if(-1!==this.defaultBranch)throw new Error("snice: <else> must be the final branch inside <if>.");this.conditions[i]=kn,Ln.set(n,{coordinator:this,index:i})}else{if(-1!==this.defaultBranch)throw new Error("snice: <if> may contain only one <else> branch.");this.defaultBranch=i}n.remove();continue}o?t.nodeType!==Node.TEXT_NODE||t.textContent?.trim()?r.appendChild(t):t.remove():n.appendChild(t)}t.removeChild(e)}commit(e){e!==hn&&(this.conditions[0]=e)}setAlternative(e,t){t!==hn&&(this.conditions[e]=t)}flush(){let e=-1;for(let t=0;t<this.conditions.length;t++)if(this.conditions[t]!==kn&&this.conditions[t]!==Ht&&Boolean(this.conditions[t])){e=t;break}-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e],this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch];let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const Ln=new WeakMap;class Pn extends bn{constructor(e){super(),this.type="node";const t=Ln.get(e);if(!t)throw new Error("snice: <else-if> must be a direct child of <if>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setAlternative(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}class jn extends bn{constructor(e,t){super(),this.type="node",this.value=kn,this.branches=[],this.defaultBranch=-1,this.currentBranch=-1;const n=e.parentNode;this.startNode=document.createComment("case"),this.endNode=document.createComment("/case"),n.insertBefore(this.startNode,e),n.insertBefore(this.endNode,e.nextSibling);for(const n of Array.from(e.children)){const e=n.tagName.toLowerCase();if("when"===e){const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);const o=t.has(n),r=this.branches.push({fragment:e,dynamic:o,expected:o?kn:n.getAttribute("value")??""})-1;o&&Mn.set(n,{coordinator:this,index:r})}else if("default"===e){if(-1!==this.defaultBranch)throw new Error("snice: <case> may contain only one <default> branch.");const e=document.createDocumentFragment();for(;n.firstChild;)e.appendChild(n.firstChild);this.defaultBranch=this.branches.push({fragment:e,dynamic:!1,expected:kn})-1}}n.removeChild(e)}commit(e){e!==hn&&(this.value=e)}setExpected(e,t){t!==hn&&(this.branches[e].expected=t)}flush(){let e=this.branches.findIndex((e,t)=>t!==this.defaultBranch&&(e.dynamic?Object.is(this.value,e.expected):String(this.value)===e.expected));-1===e&&(e=this.defaultBranch),e!==this.currentBranch&&(this.collectCurrent(),this.currentBranch=e,-1!==e&&this.branches[e].fragment.hasChildNodes()&&this.startNode.parentNode?.insertBefore(this.branches[e].fragment,this.endNode))}collectCurrent(){if(-1===this.currentBranch)return;const e=this.branches[this.currentBranch].fragment;let t=this.startNode.nextSibling;for(;t&&t!==this.endNode;){const n=t.nextSibling;e.appendChild(t),t=n}}clear(){this.collectCurrent(),this.currentBranch=-1}get isConnected(){return this.startNode.isConnected}}const Mn=new WeakMap;class Rn extends bn{constructor(e){super(),this.type="node";const t=Mn.get(e);if(!t)throw new Error("snice: dynamic <when> must be a direct child of <case>.");this.coordinator=t.coordinator,this.index=t.index}commit(e){this.coordinator.setExpected(this.index,e)}clear(){}get isConnected(){return this.coordinator.isConnected}}let In=!1;function Dn(e){In=e}function Vn(e){e[d]||(e[u]=new Promise(t=>{e[d]=t}))}function qn(e){const t=e[d];t&&(e[d]=null,t())}const Bn=new class{constructor(){this.pending=new Set,this.scheduled=!1}schedule(e,t){t.sync?Un(e,t):(this.pending.add(e),this.scheduled||(this.scheduled=!0,queueMicrotask(()=>this.flush())))}flush(){const e=Array.from(this.pending);this.pending.clear(),this.scheduled=!1;for(const t of e)t.isConnected?Un(t,t[J]||{}):t[f]=!0}remove(e){this.pending.delete(e)}};function Fn(e){return Object.prototype.hasOwnProperty.call(e,X)}function Wn(e){const t=e[Z];if(!t||0===t.length)return;const n=[...t];e[Z]=[],n.forEach(e=>e())}const zn=50;function Un(e,t,n){const o=arguments.length>=3,r=e[Q];if(!r)return void qn(e);if(t.once&&Fn(e))return void qn(e);const s=e[m]??0;if(s>=zn){const t=e.tagName?e.tagName.toLowerCase():"element";return console.error(`snice: maximum render depth (${zn}) exceeded for <${t}>. render() is mutating an observed property, causing an infinite render loop.`),void qn(e)}e[m]=s+1;try{const s=o?n:r.call(e),i=en(e);if(!1===t.differential){if("string"!=typeof s)return void console.warn("Render method with differential: false must return a string");const t=document.createElement("template");t.innerHTML=s;const n=e[X];n?.clear();const o=Array.from(i.childNodes).filter(e=>!(e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")));for(const e of o)e.remove();return i.appendChild(t.content),e[X]=null,void Wn(e)}if(!zt(s))return void console.warn("Render method must return html`` template result");let a=e[X];if(a&&a.isSameTemplate(s.strings))return a.update(s.values),void Wn(e);const c=new vn(s),l=c.renderFragment();try{c.update(s.values)}catch(e){throw c.clear(),e}const h=document.createDocumentFragment();for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||h.appendChild(e);i.appendChild(l);try{e.isConnected&&c.reconnected()}catch(e){try{c.clear()}catch(e){console.error("snice: failed to clean up a rejected render tree:",e)}for(const e of Array.from(i.childNodes))e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style")||e.remove();throw i.appendChild(h),e}let u;e[X]=c;try{a?.clear()}catch(e){u=e}if(Wn(e),u)throw u}catch(e){if(In)throw e;console.error("Error rendering element:",e)}finally{e[m]=s,qn(e)}}function Hn(e,t=!1){const n=e[J]||{};if(n.once&&Fn(e))e.isConnected&&Kn(e);else if(Vn(e),t)Un(e,n);else{if(void 0!==n.debounce&&n.debounce>0)return e[Y]||(e[Y]={}),clearTimeout(e[Y].debounce),void(e[Y].debounce=setTimeout(()=>{e[Y].debounce=null,Bn.schedule(e,n)},n.debounce));if(void 0!==n.throttle&&n.throttle>0){e[Y]||(e[Y]={lastThrottle:0});const t=e[Y],o=Date.now();return 0===t.lastThrottle||o-t.lastThrottle>=n.throttle?(t.lastThrottle=o,void Bn.schedule(e,n)):void(t.throttleTimer||(t.throttleTimer=setTimeout(()=>{t.throttleTimer=null,t.lastThrottle=Date.now(),Bn.schedule(e,n)},n.throttle-(o-t.lastThrottle))))}Bn.schedule(e,n)}}function Kn(e){const t=e[X];t?.reconnected()}function Gn(e={}){return function(t,n){return n.addInitializer(function(){this[Q]=t,this[J]=e}),function(...n){const o=t.apply(this,n);return Un(this,{...this[J]||e,once:!1},o),o}}}function Qn(){return function(e,t){return t.addInitializer(function(){this[ee]&&!this[ne]?this[ne]=[this[ee]]:this[ee]&&this[ne]&&this[ne].push(this[ee]),this[ee]=e}),e}}function Jn(e,t){return function(n,o){return function(...r){this[G]||(this[G]=new Map);const s=`${e}_${o.name}`;this[G].has(s)||this[G].set(s,{debounceTimeout:null,throttleLastCall:0,throttleTimeout:null});const i=this[G].get(s),a=n.apply(this,r),c=n=>{if(void 0===n&&!1===t?.dispatchOnUndefined)return;const o=new CustomEvent(e,{bubbles:t?.bubbles??!0,cancelable:t?.cancelable??!1,composed:t?.composed??!0,detail:n});if(void 0!==t?.scope&&void 0!==t?.daemon)throw new TypeError(`@dispatch('${e}') cannot use both scope and daemon.`);if(void 0!==t?.daemon)return void ht(this,t.daemon).dispatchEvent(o);if(void 0!==t?.scope){const n=Ge(this,t.scope);return n?void n.dispatchEvent(o):void console.warn(`[snice/@dispatch] scope did not resolve for "${e}" — event not dispatched.`)}const r=ut(this);if(!r)throw new TypeError(`@dispatch('${e}') requires an element, attached controller, or provided @daemon instance.`);r.dispatchEvent(o)},l=e=>{if(t?.debounce)return clearTimeout(i.debounceTimeout),void(i.debounceTimeout=setTimeout(()=>c(e),t.debounce));if(!t?.throttle)return void c(e);const n=Date.now(),o=t.throttle-(n-i.throttleLastCall);if(o<=0)return clearTimeout(i.throttleTimeout),i.throttleLastCall=n,void c(e);i.latestDetail=e,i.throttleTimeout||(i.throttleTimeout=setTimeout(()=>{i.throttleLastCall=Date.now(),i.throttleTimeout=null;const e=i.latestDetail;i.latestDetail=void 0,c(e)},o))};return a instanceof Promise?a.then(e=>(l(e),e)):(l(a),a)}}}function Xn(e){const t=e[G];if(t)for(const e of t.values())e.debounceTimeout&&clearTimeout(e.debounceTimeout),e.throttleTimeout&&clearTimeout(e.throttleTimeout),e.debounceTimeout=null,e.throttleTimeout=null,e.throttleLastCall=0,e.latestDetail=void 0}const Yn=t("debounce-timers"),Zn=t("throttle-timers"),eo=t("once-called"),to=t("memoize-cache");function no(e=300,t={}){const{leading:n=!1,trailing:o=!0,maxWait:r}=t;return function(t,s){const i=s.name;return function(...s){this[Yn]||(this[Yn]={});const a=this[Yn],c=i;a[c]&&clearTimeout(a[c].timeout);const l=Date.now(),h=!a[c],u=h?l:a[c].startTime,d=void 0!==r&&l-u>=r;if(n&&h){const e=t.apply(this,s);return a[c]={timeout:null,startTime:u,lastArgs:s},e}const f=setTimeout(()=>{(o||d)&&t.apply(this,a[c].lastArgs),delete a[c]},d?0:e);a[c]={timeout:f,startTime:u,lastArgs:s}}}}function oo(e=300,t={}){const{leading:n=!0,trailing:o=!0}=t;return function(t,r){const s=r.name;return function(...r){this[Zn]||(this[Zn]={});const i=this[Zn],a=s,c=Date.now();if(!i[a])return n&&t.apply(this,r),i[a]={lastInvoke:c,timeout:null,lastArgs:r},void(o&&!n&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),delete i[a]},e)));const l=c-i[a].lastInvoke;if(i[a].lastArgs=r,i[a].timeout&&clearTimeout(i[a].timeout),l>=e)return t.apply(this,r),void(i[a].lastInvoke=c);o&&(i[a].timeout=setTimeout(()=>{t.apply(this,i[a].lastArgs),i[a].lastInvoke=Date.now(),i[a].timeout=null},e-l))}}}function ro(e=!0){let t,n=!1;return function(o,r){const s=r.name;return function(...r){return e?(this[eo]||(this[eo]={}),this[eo][s]||(this[eo][s]={called:!0,result:o.apply(this,r)}),this[eo][s].result):(n||(n=!0,t=o.apply(this,r)),t)}}}function so(e={}){const{keyGenerator:t=(...e)=>JSON.stringify(e),maxSize:n=100,ttl:o}=e;return function(e,r){const s=r.name;return function(...r){this[to]||(this[to]={}),this[to][s]||(this[to][s]=new Map);const i=this[to][s],a=t(...r);if(i.has(a)){const e=i.get(a);if(!(void 0!==o&&Date.now()-e.timestamp>o))return e.value;i.delete(a)}const c=e.apply(this,r);if(i.set(a,{value:c,timestamp:Date.now()}),i.size>n){const e=i.keys().next().value;i.delete(e)}return c}}}function io(e){if(e[Yn]){for(const t in e[Yn])e[Yn][t]?.timeout&&clearTimeout(e[Yn][t].timeout);e[Yn]={}}}function ao(e){if(e[Zn]){for(const t in e[Zn])e[Zn][t]?.timeout&&clearTimeout(e[Zn][t].timeout);e[Zn]={}}}function co(e,t){e[to]&&(t?delete e[to][t]:e[to]={})}function lo(e,t){e[eo]&&(t?delete e[eo][t]:e[eo]={})}function ho(e,t){const n=Reflect.getOwnPropertyDescriptor(e,t);return!n||n.configurable?{locked:!1,value:void 0}:"value"in n&&!1===n.writable?{locked:!0,value:n.value}:"value"in n||void 0!==n.get?{locked:!1,value:void 0}:{locked:!0,value:void 0}}function uo(e){e.prototype[i]=!0;const t=e.prototype.connectedCallback,n=e.prototype.disconnectedCallback,o=e.prototype.attributeChangedCallback,r=e.observedAttributes||[];r.includes("controller")||r.push("controller");const s=e[x];if(s)for(const[e,t]of s){if(!1===t.attribute)continue;const n=De(t,e);r.includes(n)||r.push(n)}Object.defineProperty(e,"observedAttributes",{get:()=>r,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get(){return this[l]||(this[l]=new Promise(e=>{this[h]=e})),this[l]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendered",{get(){return this[d]?this[u]:Promise.resolve()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"controller",{get(){return this[g]},set(e){const t=this[g];if(this[g]=e,e!==t){if(e){const t="string"==typeof e?e:e.name||"(anonymous controller class)";return void $t(this,e).catch(n=>{"ControllerAttachAborted"!==n?.name?"string"!=typeof e||n?.message!==`Controller "${e}" not found in registry`?console.error(`Failed to attach controller "${t}":`,n):Ot(this,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}t&&Lt(this).catch(e=>{console.error("Failed to detach controller:",e)})}},enumerable:!0,configurable:!0}),e.prototype.connectedCallback=async function(){if(this[l]||(this[l]=new Promise(e=>{this[h]=e})),this[v]){try{Kn(this)}catch(e){console.error(`Error reconnecting the render tree for ${this.tagName}:`,e)}St(this,this),mt(this,this),It(this);try{Ze(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName} on reconnection:`,e)}t&&t.call(this);const n=e[B];if(n)for(const e of n)try{const t=e.method.call(this);t&&"function"==typeof t.then&&t.catch(t=>{console.error(`Error in @reconnect handler ${e.methodName}:`,t)})}catch(t){console.error(`Error in @reconnect handler ${e.methodName}:`,t)}return void(this[Q]&&this[f]&&(this[f]=!1,Hn(this)))}this[P]=!0;const n=e[x];if(n)for(const[e,t]of n){if(!1===t.attribute)continue;const n=De(t,e);if(!this.hasAttribute(n))continue;const o=this.getAttribute(n);We(this,M).add(e),t.type===Boolean&&""===o&&this.setAttribute(n,"true"),this[e]=Re(o,t)}if(this[$]){for(const[e,t]of Array.from(this[$].entries())){const o=n?.get(e),r=De(o||{},e);this[$].delete(e),this.hasAttribute(r)||(this[e]=t)}delete this[$]}if(void 0!==this[S]){const e=this[S];if(delete this[S],!this[g]){this[g]=e;const t=e?.name||"(anonymous controller class)";$t(this,e).catch(e=>{"ControllerAttachAborted"!==e?.name?console.error(`Failed to attach controller "${t}":`,e):console.debug(`Controller "${t}" attach aborted (element detached before ready)`)})}}if(this.hasAttribute("controller")&&!this[g]){const e=this.getAttribute("controller");e&&(this.controller=e)}!function(e){const t=e[ee],n=[],o=[];let r=e.constructor;for(;r&&r!==HTMLElement&&r!==Function.prototype;)o.unshift(r),r=Object.getPrototypeOf(r);for(const e of o){if(!Object.prototype.hasOwnProperty.call(e,"styles"))continue;const t=e.styles,o=Array.isArray(t)?t:[t];for(const e of o)Ut(e)?n.push(e):console.warn("Static styles must be a css`` result or an array of css`` results")}if((t||0!==n.length)&&!e[te]){e[te]=!0;try{const o=[...n],r=e[ne];if(r)for(const t of r){const n=t.call(e);Ut(n)&&o.push(n)}if(t){const n=t.call(e);if(!Ut(n))return void console.warn("Styles method must return css`` template result");o.push(n)}const s=en(e),i=Array.from(s.childNodes).filter(e=>e.nodeType===Node.ELEMENT_NODE&&"STYLE"===e.tagName&&e.hasAttribute("data-snice-style"));if(i.length===o.length&&i.every((e,t)=>e.textContent===o[t].cssText))return;for(const e of i)e.remove();if(s instanceof ShadowRoot&&o.every(e=>!!e.styleSheet)&&"adoptedStyleSheets"in s)try{return void(s.adoptedStyleSheets=o.map(e=>e.styleSheet))}catch{}for(const e of o){const t=document.createElement("style");t.setAttribute("data-snice-style",""),t.textContent=e.cssText,s.appendChild(t)}}catch(e){console.error("Error applying styles:",e)}}}(this),St(this,this),mt(this,this),It(this),this[v]=!0,function(e,t){if(Je.has(t))return;Je.add(t);const n=t[j];if(!n||0===n.size)return;const o=t[x],r=new Set(["*"]);if(o)for(const[e,t]of o)r.add(e),"string"==typeof t?.attribute&&r.add(t.attribute);for(const t of n.keys()){if(r.has(t))continue;const n=e.tagName?e.tagName.toLowerCase():"element",s=o?[...o.keys()].join(", "):"(none)";console.warn(`@watch('${t}') on <${n}> matches no @property — it will never fire. Known properties: ${s}.`)}}(this,e),function(e,t){const n=t[j],o=t[x];if(n&&o)for(const[t,r]of o){const o=[t],s=r&&"string"==typeof r.attribute?r.attribute:null;s&&s!==t&&o.push(s),o.push("*");for(const r of o)if(n.has(r))for(const o of n.get(r))if(o.immediate)try{o.method.call(e,void 0,e[t],t)}catch(e){console.error(`Error in @watch('${r}') method ${o.methodName}:`,e)}}}(this,e),t&&t.call(this);const o=e[V];if(await new Promise(e=>queueMicrotask(e)),this.isConnected){this[Q]&&Hn(this,!0);try{Ze(this,this)}catch(e){console.error(`Error setting up observers for ${this.tagName}:`,e)}if(await new Promise(e=>queueMicrotask(e)),this.isConnected){if(o)for(const e of o)try{await e.method.call(this)}catch(t){console.error(`Error in @ready handler ${e.methodName}:`,t)}this[h]&&(this[h](),this[h]=null)}else this[h]&&(this[h](),this[h]=null)}else this[h]&&(this[h](),this[h]=null)},e.prototype.disconnectedCallback=async function(){try{!function(e){const t=e[X];t?.disconnected(!0)}(this)}catch(e){console.error(`Error disconnecting the render tree for ${this.tagName}:`,e)}const t=e[q];if(t)for(const e of t)try{await e.method.call(this)}catch(t){console.error(`Error in @dispose handler ${e.methodName}:`,t)}n&&n.call(this),this[g]&&Lt(this).catch(e=>{console.error("Failed to detach controller:",e)}),_t(this),pt(this),function(e){const t=e.constructor[Mt];if(!t||!Array.isArray(t)||0===t.length)return;const n=e[ue];if(n&&"object"==typeof n){for(const e of Object.keys(n))n[e]?.timeout&&clearTimeout(n[e].timeout);delete e[ue]}for(const n of t)delete e[`__wrapped_${n.methodName}`];const o=e[se];o&&"function"==typeof o[le]&&o[le](e),delete e[se],delete e[de]}(this),rt(this),io(this),ao(this),function(e){const t=e[Y];if(!t)return!1;let n=!1;return t.debounce&&(clearTimeout(t.debounce),t.debounce=null,n=!0),t.throttleTimer&&(clearTimeout(t.throttleTimer),t.throttleTimer=null,n=!0),n}(this)&&(this[f]=!0),Xn(this),Oo(this,H),Oo(this,K)},e.prototype.attributeChangedCallback=function(t,n,r){if(o?.call(this,t,n,r),"controller"===t)return void(this.controller=r);const s=e[x];if(s)for(const[n,o]of s){if(De(o,n).toLowerCase()!==t.toLowerCase())continue;if(this[U]?.has(t.toLowerCase()))break;const s=this[C]?.[n],i=this[O]?.[n];let a=null===r?o.type!==Boolean&&i:Re(r,o,s,i);const c=this[k]?.[n];if(c&&(a=c(a)),!(o?.hasChanged?o.hasChanged(a,s):Ie(a,s)))break;We(this,M).add(n),ze(this,C)[n]=a,this[v]&&Ue(this,e,n,s,a),this[Q]&&this[v]&&Hn(this);break}},e.prototype.connectedMoveCallback=async function(){const t=e[F];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @moved handler ${e.methodName}:`,t)}},e.prototype.adoptedCallback=async function(){const t=e[W];if(t)for(const e of t)try{await this[e.methodName]()}catch(t){console.error(`Error in @adopted handler ${e.methodName}:`,t)}}}function fo(e,t,n,o){if(function(e){let t=Object.getPrototypeOf(e);const n=[];for(;t&&t!==HTMLElement&&t!==Function.prototype;)n.push(t),t=Object.getPrototypeOf(t);n.reverse();for(const t of n){if(t[x]){e[x]||(e[x]=new Map);for(const[n,o]of t[x])e[x].has(n)||e[x].set(n,o)}t.formAssociated&&!e.formAssociated&&(e.formAssociated=!0)}}(t),n.metadata&&n.metadata[x]){t[x]||(t[x]=new Map);for(const[e,o]of n.metadata[x])t[x].set(e,o)}else if(yo.length>0){t[x]||(t[x]=new Map);const e=yo.pop();for(const[n,o]of e)t[x].set(n,o)}o?.formAssociated&&(t.formAssociated=!0);const r={...Object.getPrototypeOf(t)?.[y]||{}},s=o||{};if("light"===s.renderRoot&&"string"==typeof s.shadow||"shadow"===s.renderRoot&&!1===s.shadow)throw new TypeError("snice: @element renderRoot and shadow options select conflicting render roots.");const i={...r,...s};return Object.prototype.hasOwnProperty.call(s,"shadow")?i.renderRoot=!1===s.shadow?"light":"shadow":Object.prototype.hasOwnProperty.call(s,"renderRoot")&&("light"===s.renderRoot?i.shadow=!1:!1===i.shadow&&(i.shadow="open")),t[y]=i,!0===t.prototype[oe]&&Object.prototype.hasOwnProperty.call(t.prototype,"render")&&!Object.prototype.hasOwnProperty.call(t.prototype,Q)&&"function"==typeof t.prototype.render&&(t.prototype[Q]=t.prototype.render,t.prototype[J]=t.renderOptions||{}),uo(t),customElements.get(e)?(globalThis.SNICE_DEBUG&&console.warn(`[snice] "${e}" is already registered. Skipping.`),t):(customElements.define(e,t),t)}function mo(e,t){if(void 0!==t?.renderRoot&&"shadow"!==t.renderRoot&&"light"!==t.renderRoot)throw new TypeError('snice: @element renderRoot must be "shadow" or "light".');if(void 0!==t?.shadow&&!1!==t.shadow&&"open"!==t.shadow&&"closed"!==t.shadow)throw new TypeError('snice: @element shadow must be "open", "closed", or false.');return function(n,o){return fo(e,n,o,t)}}function po(e){return function(t,n){return fo(e,t,n)}}const yo=[],go=new WeakMap;function vo(e){return function(t,n){const o=n.name;return n.metadata?(n.metadata[x]||(n.metadata[x]=new Map),n.metadata[x].set(o,e||{})):(0===yo.length&&yo.push(new Map),yo[yo.length-1].set(o,e||{})),function(t){const n=this[L],r=!0===n?.delete(o);0===n?.size&&delete this[L];const s=Object.prototype.hasOwnProperty.call(this,o),i=s&&(r||!function(e,t,n){const o=e?.ownerDocument;if(!o?.createElement)return!1;let r=go.get(o);if(!r){const e=o.createElement("div");r=new Map;for(const t of Reflect.ownKeys(e))r.set(t,e[t]);go.set(o,r)}return r.has(t)&&Object.is(r.get(t),n)}(this,o,this[o])),a=i?this[o]:t;s&&delete this[o];const c=this.constructor;c[x]||(c[x]=new Map);const l={...e};l.type||void 0===t||(l.type=Me(t)),l.attributeNaming||"kebab"!==c.propertyAttributeNaming||(l.attributeNaming="kebab"),c[x].set(o,l),ze(this,O)[o]=t;const h=()=>{if(!this[P])return;const e=this[C]?.[o];if(!1!==l.attribute&&!1!==l.reflect){const n=De(l,o),r=Qe(e,l,t),s=n.toLowerCase();We(this,U).add(s);try{null===r?this.removeAttribute?.(n):this.setAttribute?.(n,r)}finally{this[U].delete(s)}}this[v]&&(Ue(this,this.constructor,o,e,e),this[Q]&&Hn(this))},u=e=>{if(!l.deep)return e;let t;return t=function(e,t){if(!e||"object"!=typeof e)return e;const n=new WeakMap,o=new WeakMap,r=e=>e&&"object"==typeof e&&o.get(e)||e,s=e=>{if(!e||"object"!=typeof e)return e;if(n.has(e))return n.get(e);if(e instanceof Map){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=ho(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("set"===n)c=(n,o)=>{n=r(n),o=r(o);const s=e.has(n),a=e.get(n);return e.set(n,o),s&&Object.is(a,o)||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("get"===n)c=t=>s(e.get(r(t)));else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach((e,o)=>t.call(n,s(e),s(o),i));else if("values"===n)c=function*(){for(const t of e.values())yield s(t)};else if("keys"===n)c=function*(){for(const t of e.keys())yield s(t)};else if("entries"===n||n===Symbol.iterator)c=function*(){for(const[t,n]of e.entries())yield[s(t),s(n)]};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(e instanceof Set){let i;const a=new Map;return i=new Proxy(e,{get(e,n){const o=ho(e,n);if(o.locked)return o.value;if(a.has(n))return a.get(n);let c;if("add"===n)c=n=>{n=r(n);const o=e.has(n);return e.add(n),o||t(),i};else if("delete"===n)c=n=>{n=r(n);const o=e.delete(n);return o&&t(),o};else if("clear"===n)c=()=>{0!==e.size&&(e.clear(),t())};else if("has"===n)c=t=>e.has(r(t));else if("forEach"===n)c=(t,n)=>e.forEach(e=>{const o=s(e);t.call(n,o,o,i)});else if("values"===n||"keys"===n||n===Symbol.iterator)c=function*(){for(const t of e.values())yield s(t)};else if("entries"===n)c=function*(){for(const t of e.values()){const e=s(t);yield[e,e]}};else{const t=Reflect.get(e,n,e);if("function"!=typeof t)return t;if("constructor"===n)return t;c=t.bind(e)}return a.set(n,c),c}}),n.set(e,i),o.set(i,e),i}if(!Array.isArray(e)&&!function(e){const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t}(e))return e;const i=new Proxy(e,{get(e,t,n){const o=ho(e,t);return o.locked?o.value:s(Reflect.get(e,t,n))},set(e,n,o,s){const i=Reflect.get(e,n,s);o=r(o);const a=Reflect.set(e,n,o);return a&&!Object.is(i,o)&&t(),a},deleteProperty(e,n){const o=Object.prototype.hasOwnProperty.call(e,n),r=Reflect.deleteProperty(e,n);return r&&o&&t(),r},defineProperty(e,n,o){const s=Reflect.getOwnPropertyDescriptor(e,n),i="value"in o?{...o,value:r(o.value)}:o,a=Reflect.defineProperty(e,n,i),c=a?Reflect.getOwnPropertyDescriptor(e,n):s;return a&&!function(e,t){if(!e||!t)return e===t;const n="value"in e||"writable"in e;return n===("value"in t||"writable"in t)&&e.configurable===t.configurable&&e.enumerable===t.enumerable&&(!n||e.writable===t.writable&&Object.is(e.value,t.value))&&(n||e.get===t.get&&e.set===t.set)}(s,c)&&t(),a}});return n.set(e,i),o.set(i,e),i};return s(e)}(e,()=>{this[C]?.[o]===t&&h()}),t};ze(this,k)[o]=u;const d=this.constructor.prototype;let f=d[_e];f&&Object.prototype.hasOwnProperty.call(d,_e)||(f=new Map(f),d[_e]=f);const m=f.get(o);m&&m===e||(f.set(o,e),Object.defineProperty(this.constructor.prototype,o,{get(){return this[$]?.has(o)?this[$].get(o):this[C]&&o in this[C]?this[C][o]:t},set(e){const t=this[o];if(!(l.hasChanged?l.hasChanged(e,t):Ie(e,t)))return;const n=(this[k]?.[o]||(e=>e))(e);if(!this[P])return this[$]||(this[$]=new Map),void this[$].set(o,n);if(ze(this,C)[o]=n,!1!==l.attribute&&!1!==l.reflect){const e=De(l,o),t=Qe(n,l,this[O]?.[o]);We(this,M).add(o);const r=e.toLowerCase();We(this,U).add(r);try{null===t?this.removeAttribute?.(e):this.setAttribute?.(e,t)}finally{this[U].delete(r)}}this[v]&&(Ue(this,this.constructor,o,t,n),this[Q]&&Hn(this))},configurable:!0,enumerable:!0}));const p=u(t);return ze(this,C)[o]=p,ze(this,O)[o]=p,i?a:p}}}function bo(e={}){return vo({...e,attribute:!1,reflect:!1})}function wo(e){return!0===e[o]&&e.element?e.element:e}function Eo(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=wo(this);let n=null;const o=t instanceof HTMLElement?Zt(t):null;return s&&o?n=o.querySelector(e):s&&t.shadowRoot&&(n=t.shadowRoot.querySelector(e)),!n&&r&&(n=t.querySelector(e)),n||null},set(){},configurable:!0,enumerable:!0}),t}}}function No(e,t={}){return function(n,o){const{light:r=!1,shadow:s=!0}=t,i=o.name;return function(t){return Object.hasOwn(this.constructor.prototype,i)||Object.defineProperty(this.constructor.prototype,i,{get(){const t=wo(this),n=new Set,o=t instanceof HTMLElement?Zt(t):null;if(s&&o)for(const t of o.querySelectorAll(e))n.add(t);else if(s&&t.shadowRoot)for(const o of t.shadowRoot.querySelectorAll(e))n.add(o);if(r)for(const o of t.querySelectorAll(e))n.add(o);return[...n]},set(){},configurable:!0,enumerable:!0}),t}}}function Ao(...e){const t=e.filter(e=>"string"==typeof e),n=e.find(e=>"object"==typeof e&&null!==e),o=!1!==n?.immediate;return function(e,n){const r=n.name;n.addInitializer(function(){const n=this.constructor;Object.prototype.hasOwnProperty.call(n,pe)||(n[pe]=new Map);let s=n[pe].get(e);if(s||(s=new Set,n[pe].set(e,s)),!Object.prototype.hasOwnProperty.call(n,j)){const e=n[j],t=new Map;if(e)for(const[n,o]of e)t.set(n,[...o]);n[j]=t}for(const i of t)s.has(i)||(s.add(i),n[j].has(i)||n[j].set(i,[]),n[j].get(i).push({methodName:r,method:e,immediate:o}))})}}function To(){return function(e,t){const n=t.name;return function(e){return Object.hasOwn(this.constructor.prototype,n)||Object.defineProperty(this.constructor.prototype,n,{get(){if(void 0!==this[R])return this[R];const e=at(this);return void 0!==e?e:void 0},set(){},configurable:!0,enumerable:!0}),e}}}function So(e,t,n,o,r){const s=o.name;o.addInitializer(function(){const o=this.constructor;if(Object.prototype.hasOwnProperty.call(o,t)||(o[t]=new Set),!o[t].has(n)){if(o[t].add(n),!Object.prototype.hasOwnProperty.call(o,e)){const t=o[e];o[e]=t?[...t]:[]}o[e].push({methodName:s,method:n,...r})}})}function _o(){return function(e,t){So(V,be,e,t)}}function xo(){return function(e,t){So(q,we,e,t)}}function Co(){return function(e,t){So(B,Ee,e,t)}}function Oo(e,t){const n=e[t];if(n)for(const e of n.values())e.debounceTimer&&clearTimeout(e.debounceTimer),e.throttleTimer&&clearTimeout(e.throttleTimer),e.debounceTimer=null,e.throttleTimer=null,e.lastThrottleCall=0}function ko(e,t,n){return function(o={}){return function(r,s){So(e,n,r,s,{options:o});const i=s.name;return function(...e){this[t]||(this[t]=new Map),this[t].has(i)||this[t].set(i,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const n=this[t].get(i),s=(...e)=>r.apply(this,e),a=(...e)=>{try{const t=r.apply(this,e);t&&"function"==typeof t.then&&t.catch(e=>console.error(`Error in deferred lifecycle handler ${i}:`,e))}catch(e){console.error(`Error in deferred lifecycle handler ${i}:`,e)}};if(o.debounce>0)return clearTimeout(n.debounceTimer),void(n.debounceTimer=setTimeout(()=>a(...e),o.debounce));if(o.throttle>0){const t=Date.now();return 0===n.lastThrottleCall||t-n.lastThrottleCall>=o.throttle?(n.lastThrottleCall=t,s(...e)):void(n.throttleTimer||(n.throttleTimer=setTimeout(()=>{n.throttleTimer=null,n.lastThrottleCall=Date.now(),a(...e)},o.throttle-(t-n.lastThrottleCall))))}return s(...e)}}}}const $o=ko(F,H,Ne),Lo=ko(W,K,Ae);class Po extends HTMLElement{static{this.propertyAttributeNaming="kebab"}createRenderRoot(){const e=this.constructor[y];return this.attachShadow({mode:"string"==typeof e?.shadow?e.shadow:"open",delegatesFocus:e?.delegatesFocus})}invalidate(){return Hn(this),this.rendered}renderNow(){return function(e){Vn(e),Un(e,{...e[J]||{},once:!1})}(this),this.rendered}}Object.defineProperty(Po.prototype,oe,{value:!0});class jo{constructor(e){this.parsed=this.parsePattern(e)}get spec(){return this.parsed.template}parsePattern(e){let t=e,n="",o=!1;const r=e.indexOf("?");return-1!==r&&(t=e.slice(0,r),n=e.slice(r+1),t.endsWith("(")&&n.endsWith(")")&&(o=!0,t=t.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(t),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:e}}parseSegments(e){const t=[];let n=0;for(;n<e.length;)switch(e[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(e,n);t.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(e,n+1);t.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(e,n+1);t.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:h}=this.parseLiteral(e,n);l&&t.push({type:"literal",value:l}),n=h}return t}parseOptionalGroup(e,t){let n=1,o=t+1;for(;o<e.length&&n>0;)"("===e[o]&&n++,")"===e[o]&&n--,o++;const r=e.slice(t+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(e,t){let n=t;for(;n<e.length&&/[\w-]/.test(e[n]);)n++;return{name:e.slice(t,n),endIndex:n}}parseLiteral(e,t){let n=t;for(;n<e.length&&!"(:*(".includes(e[n]);)n++;return{value:e.slice(t,n),endIndex:n}}parseQuerySegments(e){let t=e;t.startsWith("(")&&t.endsWith(")")&&(t=t.slice(1,-1));const n=[];let o=0;for(;o<t.length;)if(":"===t[o]){const{name:e,endIndex:r}=this.parseIdentifier(t,o+1);n.push({type:"param",name:e}),o=r}else{const{value:e,endIndex:r}=this.parseQueryLiteral(t,o);e&&n.push({type:"literal",value:e}),o=r}return n}parseQueryLiteral(e,t){let n=t;for(;n<e.length&&":"!==e[n];)n++;return{value:e.slice(t,n),endIndex:n}}getAllParamNames(){const e=new Set,t=n=>{for(const o of n)switch(o.type){case"param":case"splat":e.add(o.name);break;case"optional":t(o.segments)}};return t(this.parsed.pathSegments),t(this.parsed.querySegments),Array.from(e)}canMatchRemainingSegments(e,t,n){let o=t;for(const t of n)if("literal"===t.type){const n=e.indexOf(t.value,o);if(-1===n)return!1;o=n+t.value.length}return!0}match(e){const[t,n]=e.split("?"),o=this.matchPath(t,this.parsed.pathSegments);if(!1===o)return!1;const r=this.matchQuery(n||"",this.parsed.querySegments);if(!1===r)return!1;const s=this.getAllParamNames(),i={};for(const e of s)i[e]=void 0;return Object.assign(i,o,r),i}matchPath(e,t){const n={};let o=0;for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1),a=this.matchSegment(e,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<e.length)&&n}matchSegment(e,t,n,o=[]){switch(n.type){case"literal":return e.slice(t,t+n.value.length)===n.value&&{params:{},nextIndex:t+n.value.length};case"param":{let r=t;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=e.indexOf(s.value,t);if(-1===n)return!1;r=n}else for(;r<e.length&&!a.includes(e[r]);)r++;if(r===t)return!1;try{i=decodeURIComponent(e.slice(t,r))}catch(n){i=e.slice(t,r)}return!(r<e.length&&"?"===e[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=e.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=e.indexOf(".",t);-1!==n&&(r=n)}else{const n=e.lastIndexOf(s.value);-1!==n&&n>=t&&(r=n)}break;case"param":let n=-1;for(let o=e.length-1;o>=t;o--)if("/"===e[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=e.length-1;n>t;n--)if("/"===e[n]){o=n+1;break}if(-1!==o)r=o;else{const n=e.slice(t).split("/").filter(e=>e);r=n.length>1?t+n.slice(0,-1).join("/").length+1:t}break;case"optional":const i=e=>{for(const t of e){if("literal"===t.type)return t.value;if("optional"===t.type){const e=i(t.segments);if(e)return e}}return null},a=i(s.segments);if(a){const n=e.lastIndexOf(a);-1!==n&&n>=t&&(r=n)}}const i=e.indexOf("?",t);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(e.slice(t,r))}catch(n){a=e.slice(t,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=t,s={},i=!0;for(let t=0;t<n.segments.length;t++){const o=n.segments[t],a=n.segments.slice(t+1),c=this.matchSegment(e,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}return i&&this.canMatchRemainingSegments(e,r,o)?{params:s,nextIndex:r}:{params:{},nextIndex:t}}default:return!1}}findNextLiteral(e){for(const t of e){if("literal"===t.type)return t;if("optional"===t.type){const e=this.findNextLiteral(t.segments);if(e)return e}}return null}matchQuery(e,t){if(0===t.length)return{};const n={};let o=0;for(const r of t)switch(r.type){case"literal":if(e.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let t,s=o;for(;s<e.length&&"&"!==e[s];)s++;if(s===o)return!1;try{t=decodeURIComponent(e.slice(o,s))}catch(n){t=e.slice(o,s)}n[r.name]=t,o=s;break}}return n}reverse(e={}){const t=this.reverseSegments(this.parsed.pathSegments,e);if(!1===t)return!1;let n=t;if(this.parsed.querySegments.length>0){const t=this.reverseSegments(this.parsed.querySegments,e);if(!this.parsed.queryOptional&&!1===t)return!1;t&&""!==t&&(n+="?"+t)}return n}reverseSegments(e,t,n=!1){let o="";for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in t))return!1;o+=String(t[s.name]);break;case"optional":if(this.hasAllParams(s.segments,t,n)||this.hasLaterOptionalGroupNeedingParams(i,t,s.segments)){const e=this.reverseSegments(s.segments,t,!0);if(!1===e)return!1;o+=e}}}return o}hasLaterOptionalGroupNeedingParams(e,t,n){for(const o of e)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,t))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(e){for(const t of e)if("param"===t.type||"splat"===t.type)return!1;return!0}hasAllParams(e,t,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of e)switch(n.type){case"param":case"splat":i=!1,n.name in t&&void 0!==t[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of e)"optional"===n.type&&this.hasAllParams(n.segments,t,a)&&(r=!0);return!(!o||s)||!(!r||s)||!(!i||!n)}hasOnlyOptionalMissingParams(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(!(n.name in t))return!1}return!0}hasAnyParamInSegments(e,t){for(const n of e)switch(n.type){case"param":case"splat":if(n.name in t)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,t))return!0}return!1}}function Mo(e){const t=e.split("/").filter(Boolean);let n=t.length;for(const e of t)e.startsWith("*")?n+=-2:e.startsWith(":")?n+=3:n+=10;return n}function Ro(e){const t={};return e.split(";").forEach(e=>{const n=e.indexOf(":");if(-1===n)return;const o=e.slice(0,n).trim(),r=e.slice(n+1).trim();o&&r&&(t[o]=r)}),t}function Io(e,t,n,o){if(e.style.position="absolute",e.style.width="100%",t)return e.style.height="100%",void(e.style.transition=`opacity ${n}ms ease-in-out`);e.style.top="0",e.style.left="0",e.style.transition=`${o} ${n}ms ease-in-out`}function Do(e,t){Object.defineProperty(e.prototype,r,{value:!0,configurable:!0})}function Vo(e){if(!ct(e))throw new TypeError("Application contexts may provide only instances of @daemon classes.");const t=lt(e);if(0===t.bindings){t.active=!0;try{St(e,t.target),mt(e,t.target)}catch(n){throw pt(e),_t(e),t.active=!1,n}}t.bindings+=1;let n=!1;return()=>{n||(n=!0,t.bindings=Math.max(0,t.bindings-1),0===t.bindings&&(pt(e),_t(e),Xn(e),t.active=!1,t.target=new EventTarget))}}function qo(e,t){const n=function(e,t){if(!e||"function"!=typeof e.addEventListener||"function"!=typeof e.removeEventListener)throw new TypeError("provideContext() requires an EventTarget root.");if(!t||"object"!=typeof t)throw new TypeError("provideContext() requires an application context object.");if(it.has(e))throw new Error("This root already provides an application context. Release it before providing another.");const n=e=>{const n=e;n.detail&&void 0===n.detail.context&&(n.detail.context=t,n.preventDefault(),n.stopPropagation())};e.addEventListener(st,n),it.set(e,{listener:n});let o=!1;return()=>{if(o)return;o=!0;const t=it.get(e);t?.listener===n&&(e.removeEventListener(st,n),it.delete(e))}}(e,t);let o;try{o=function(e){const t=e.daemons;if(void 0===t)return()=>{};if(!t||"object"!=typeof t||Array.isArray(t))throw new TypeError("AppContext.daemons must be a readonly record of named @daemon instances.");const n=[],o=new Set;try{for(const[e,r]of Object.entries(t)){if(!e.trim())throw new TypeError("AppContext.daemons keys must be non-empty strings.");if(!r||"object"!=typeof r)throw new TypeError(`AppContext.daemons["${e}"] must be an instance of an @daemon class.`);o.has(r)||(o.add(r),n.push(Vo(r)))}}catch(e){for(const e of n.reverse())e();throw e}return()=>{for(const e of n.reverse())e()}}(t)}catch(e){throw n(),e}let r=!1;return()=>{r||(r=!0,n(),o?.())}}const Bo=new WeakMap;var Fo;function Wo(e){const t=e.window??window,n=e.document??document,o=[];let r,s,i,a=!1,c=[],l=null,h=null;const u=e.context||{};let d=null,f=null;const m=new je(u,[],"",{},e.fetcher);function p(e){if(d===e&&f&&Bo.get(e)===f)return;f?.(),Bo.get(e)?.();const t=qo(e,u);let n=!1;const o=()=>{n||(n=!0,t(),Bo.get(e)===o&&Bo.delete(e))};f=o,d=e,Bo.set(e,o)}function y(e){if(!l||!h)return null;const t=e.querySelectorAll(l);for(const e of t)if(e[D]===h)return e;return null}function g(e,t,n,c,l,h){switch(o.push({route:new jo(e),tag:t,transition:n,guards:c,layout:l,placard:h}),a=!1,e){case"/404":r=t;break;case"/403":s=t;break;case"/":i=t}}function v(){const e=new Set;c=o.filter(e=>e.placard).map(e=>{const t=e.placard;return"function"==typeof t?t(u):t}).filter(t=>!e.has(t.name)&&(e.add(t.name),!0))}function b(e,t,n){m[fe](u,c,t,n)}function w(){switch(e.type){case"hash":return t.location.hash.slice(1);case"pushstate":return`${t.location.pathname}${t.location.search}`}}function E(e){let t;if(s)t=n.createElement(s),t[R]=u;else{const e=n.createElement("div");e.className="default-403",e.innerHTML="<h1>403</h1><p>Unauthorized</p>",t=e}e.innerHTML="",e.appendChild(t),l=null,h=null}async function N(e,t,o,r){if(!e)return!0;const s=Array.isArray(e)?e:[e];let i=null,a=null;a=setTimeout(()=>{r&&r()||(i=function(){const e=n.createElement("div");return e.setAttribute("data-snice-loading",""),e.innerHTML='\n <style>@keyframes snice-spin{to{transform:rotate(360deg)}}</style>\n <div style="display:flex;align-items:center;justify-content:center;height:100%;min-height:200px">\n <div style="width:32px;height:32px;border:3px solid rgba(128,128,128,0.3);border-top-color:rgba(128,128,128,0.8);border-radius:50%;animation:snice-spin 0.6s linear infinite"></div>\n </div>',e}(),o.appendChild(i))},50);try{for(const e of s)if(!await e(u,t))return r&&r()||E(o),!1;return!0}finally{a&&clearTimeout(a),i&&i.remove()}}async function A(t,o,r,s,i,a,d){const f=!1===(m=s)?null:m||(e.layout?e.layout:null);var m;const{element:p,needsNewLayout:g}=function(e){if(e===l)return{element:null,needsNewLayout:!1};if(l=e,e){const t=Date.now();h=t;const o=n.createElement(e);return o[R]=u,o[D]=t,{element:o,needsNewLayout:!0}}return h=null,{element:null,needsNewLayout:!0}}(f),v=r||e.transition;if(null!==p||null!==y(t)){if(await async function(e,t,n,o,r,s,i,a){const l=o||y(e);if(!l)return;!function(e,t,n){"function"==typeof e.update&&e.update(u,c,t,n)}(l,s,i);const h=l.querySelector('[slot="page"]');if(n&&h){if(t.setAttribute("slot","page"),await _(l,h,t,n),a&&a())return;r&&(e.innerHTML="",e.appendChild(l))}else a&&a()||(l.querySelectorAll('[slot="page"]').forEach(e=>e.remove()),t.setAttribute("slot","page"),l.appendChild(t),r&&(e.innerHTML="",e.appendChild(l)))}(t,o,v,p,g,i,a,d),d&&d())return;b(0,i,a)}else await async function(e,t,n,o){const r=e.children[0];n&&r?await _(e,r,t,n):o&&o()||(e.innerHTML="",e.appendChild(t))}(t,o,v,d),d&&d()||b(0,i,a)}let T=0;async function S(s){const a=n.querySelector(e.target);if(!a)throw new Error(`Target element not found: ${e.target}`);p(a);const c=++T,l=()=>c!==T;if(v(),t.scrollTo(0,0),(""===s?.trim()||"/"===s)&&i){const e=o.find(e=>e.route.match("/"));if(!await N(e?.guards,{},a,l))return;if(l())return;const{element:r,transition:c,layout:h}=function(){const e=n.createElement(i);e[R]=u;const r=t.customElements.get(i),s=r?.[I],a=o.find(e=>e.route.match("/"));return{element:e,transition:s,layout:a?.layout}}();return void await A(a,r,c,h,s,{},l)}if(!s)return;const h=await async function(e,t,r){for(const s of o){const o=s.route.match(e);if(!1===o)continue;if(!await N(s.guards,o,t,r))return{result:Fo.GUARDS_FAILED};const i=n.createElement(s.tag);i[R]=u,i[re]=m;const a=o;return Object.keys(a).forEach(e=>i.setAttribute(e,a[e])),{result:Fo.SUCCESS,element:i,transition:s.transition,layout:s.layout,routeParams:a}}return{result:Fo.NOT_FOUND}}(s,a,l);if(l())return;if(h.result===Fo.GUARDS_FAILED)return;if(h.result===Fo.SUCCESS){const{element:e,transition:t,layout:n,routeParams:o={}}=h;return void await A(a,e,t,n,s,o,l)}const{element:d,transition:f,layout:y}=function(){if(r){const e=n.createElement(r);e[R]=u;const o=t.customElements.get(r),s=o?.[I];return{element:e,transition:s,layout:void 0}}const e=n.createElement("div");return e.className="default-404",e.innerHTML="<h1>404</h1><p>Page not found</p>",{element:e,transition:void 0,layout:void 0}}();await A(a,d,f,y,s,{},l)}async function _(e,t,n,o,r=T){return async function(e,t,n,o={},r=()=>!1){const s=o.outDuration??300,i=o.inDuration??300,a=o.mode||"sequential",c=o.out?Ro(o.out):{opacity:"0"},l={opacity:"0"},h=o.in?Ro(o.in):{opacity:"1"},u=e.style,d=e.tagName.includes("-")&&e.shadowRoot,f=Symbol.for("snice:transition-original-position"),m=Symbol.for("snice:transition-count"),p=e;d||(f in p||(p[f]=u.position,p[m]=0),p[m]++,u.position="relative");const y=()=>{d||(p[m]--,p[m]<=0&&(u.position=p[f],delete p[f],delete p[m]))},g=t.hasAttribute("slot")||n.hasAttribute("slot");switch(Io(t,g,s,"all"),Io(n,g,i,"all"),Object.assign(n.style,l),e.appendChild(n),a){case Ce.SIMULTANEOUS:Object.assign(t.style,c),Object.assign(n.style,h),await new Promise(e=>setTimeout(e,Math.max(s,i)));break;case Ce.SEQUENTIAL:if(Object.assign(t.style,c),await new Promise(e=>setTimeout(e,s)),r())return n.parentNode===e&&n.remove(),void y();Object.assign(n.style,h),await new Promise(e=>setTimeout(e,i))}if(r())return n.parentNode===e&&n.remove(),void y();t.remove(),function(e,t){e.style.position="",e.style.width="",e.style.transition="",t?e.style.height="":(e.style.top="",e.style.left="")}(n,g),Object.keys({...l,...h}).forEach(e=>{n.style[e]=""}),y()}(e,t,n,o,()=>r!==T)}return{page:function(e){return function(n,o){if(o?.metadata&&o.metadata[x]){n[x]||(n[x]=new Map);for(const[e,t]of o.metadata[x])n[x].set(e,t)}uo(n),n[I]=e.transition;const r=n.prototype.connectedCallback;n.prototype.connectedCallback=function(){this[re]=m,r?.call(this)};const s=n.prototype.disconnectedCallback;return n.prototype.disconnectedCallback=function(){s?.call(this),delete this[R],delete this[re]},t.customElements.get(e.tag)||t.customElements.define(e.tag,n),e.routes.forEach(t=>g(t,e.tag,e.transition,e.guards,e.layout,e.placard)),n}},initialize:function(){const r=n.querySelector(e.target);if(!r)throw new Error(`Target element not found: ${e.target}`);p(r),!a&&(o.sort((e,t)=>Mo(t.route.spec)-Mo(e.route.spec)),a=!0),v(),function(){const o=()=>{const t=n.querySelector(e.target);if(t&&(d!==t||!f||Bo.get(t)===f))return d!==t&&it.has(t)?(f?.(),f=null,void(d=null)):void S(w())};switch(e.type){case"hash":t.addEventListener("hashchange",o);break;case"pushstate":t.addEventListener("popstate",o)}}(),S(w())},navigate:async function(n){const o=function(e){const t=e.trim().replace(/^#/,"");return t?t.startsWith("/")?t:`/${t}`:"/"}(n);!function(n){switch(e.type){case"hash":{const e=`#${n}`;t.location.hash!==e&&t.history.pushState(null,"",e);break}case"pushstate":`${t.location.pathname}${t.location.search}`!==n&&t.history.pushState(null,"",n)}}(o),await S(o)},register:g}}function zo(e,t,n){const o=[];for(const[r,s]of Object.entries(t)){const t=`@request/${r}`,i=e=>{const t=e,{discovery:o,data:i,payload:a}=t.detail;n?.passive||(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()),o.resolve(),Promise.resolve().then(()=>s(a)).then(e=>i.resolve(e)).catch(e=>{i.reject(e),console.error(`createRequestHandler: error in "${r}" handler:`,e)})};e.addEventListener(t,i),o.push(()=>e.removeEventListener(t,i))}return()=>{for(const e of o)e();o.length=0}}function Uo(e){let t="";for(const n of Object.keys(e))e[n]&&(t+=(t?" ":"")+n);return t}function Ho(e){const t=[];for(const n of Object.keys(e)){const o=e[n];if(null==o||!1===o)continue;const r=n.startsWith("--")?n:n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase());t.push(`${r}: ${o}`)}return t.join("; ")}!function(e){e.SUCCESS="success",e.GUARDS_FAILED="guards-failed",e.NOT_FOUND="not-found"}(Fo||(Fo={}));let Ko=!1;function Go(e){Ko=e}async function Qo(e,t=500){if(customElements.get(e))return;let n=null;Ko||(n=setTimeout(()=>{console.warn(`Custom element <${e}> is taking longer than ${t}ms to register. This may indicate a missing import or circular dependency. Set DISABLE_ELEMENT_READY_WARNINGS=true to disable this warning.`)},t));try{await customElements.whenDefined(e)}finally{n&&clearTimeout(n)}}async function Jo(e,t=500){const n=e.tagName.toLowerCase();await Qo(n,t),"ready"in e&&"function"==typeof e.ready?.then&&await e.ready}async function Xo(e,t=500){const n=[];e instanceof Element&&(e.tagName.includes("-")&&n.push(e),e.shadowRoot)&&e.shadowRoot.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),e instanceof DocumentFragment&&e.querySelectorAll("*").forEach(e=>{e.tagName.includes("-")&&n.push(e)}),await Promise.all(n.map(e=>Jo(e,t)))}async function*Yo(e){for(;;)await new Promise(t=>{e[Z]||(e[Z]=[]),e[Z].push(t)}),yield}let Zo=0,er=null;const tr=Symbol.for("snice:body-scroll-lock");function nr(){0===Zo&&(er=document.body.style.overflow,document.body.style.overflow="hidden"),Zo++}function or(){0!==Zo&&(Zo--,0===Zo&&(document.body.style.overflow=er??"",er=null))}function rr(){return Zo}globalThis[tr]={clear(){Zo=0,er=null}};class sr{constructor(){this.requestMiddlewares=[],this.responseMiddlewares=[]}use(e,t){"request"!==e?this.responseMiddlewares.push(t):this.requestMiddlewares.push(t)}create(e){const t=this.requestMiddlewares,n=this.responseMiddlewares;return async function(e,o){const r=new Request(e,o);let s=0;const i=async()=>{if(s<t.length)return t[s++].call(this,r,i);const e=await fetch(r);let o=0;const a=async()=>o<n.length?n[o++].call(this,e,a):e;return a()};return i()}.bind(e)}}var ir;"undefined"!=typeof document&&jt(),globalThis.snice||(globalThis.snice={controllerRegistry:new Map,pendingControllerAttachments:new Map,controllerIdCounter:0}),globalThis.snice.pendingControllerAttachments??=new Map,function(e){e.SEQUENTIAL="sequential",e.SIMULTANEOUS="simultaneous"}(ir||(ir={}));export{je as Context,sr as ContextAwareFetcher,o as IS_CONTROLLER_INSTANCE,Wo as Router,xe as SimpleArray,Po as SniceElement,Ce as TransitionMode,Lo as adopted,uo as applyElementFunctionality,$t as attachController,Uo as classMap,io as clearDebounceTimers,co as clearMemoizeCache,ao as clearThrottleTimers,Rt as context,To as contextProperty,Ct as controller,zo as createRequestHandler,Wt as css,Do as daemon,no as debounce,Lt as detachController,Jn as dispatch,xo as dispose,mo as element,qe as escapeAttr,Ve as escapeHtml,rr as getBodyScrollLockCount,at as getContext,Pt as getController,t as getSymbol,Bt as html,Be as isSafeUrl,po as layout,dn as live,nr as lockBodyScroll,so as memoize,$o as moved,hn as noChange,Ht as nothing,Ye as observe,Nt as on,ro as once,Fe as parseDuration,vo as property,qo as provideContext,Eo as query,No as queryAll,_o as ready,Co as reconnect,Gn as render,Xt as repeat,dt as request,lo as resetOnce,ft as respond,Go as setDisableElementReadyWarnings,Dn as setStrictRenderErrors,bo as state,Ho as styleMap,Qn as styles,Ft as svg,oo as throttle,Yo as trackRenders,or as unlockBodyScroll,Gt as unsafeHTML,jt as useNativeElementControllers,Xo as waitForAllCustomElements,Qo as waitForElementDefined,Jo as waitForElementReady,Ao as watch};
2
2
  //# sourceMappingURL=snice-runtime.esm.min.js.map