snice 1.14.3 → 2.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 (185) hide show
  1. package/bin/templates/base/tsconfig.json +5 -4
  2. package/components/accordion/demo.html +403 -0
  3. package/components/accordion/snice-accordion-item.css +85 -0
  4. package/components/accordion/snice-accordion-item.ts +226 -0
  5. package/components/accordion/snice-accordion.css +31 -0
  6. package/components/accordion/snice-accordion.ts +182 -0
  7. package/components/accordion/snice-accordion.types.ts +32 -0
  8. package/components/alert/demo.html +445 -0
  9. package/components/alert/snice-alert.css +195 -0
  10. package/components/alert/snice-alert.ts +141 -0
  11. package/components/alert/snice-alert.types.ts +12 -0
  12. package/components/avatar/demo.html +598 -0
  13. package/components/avatar/snice-avatar.css +131 -0
  14. package/components/avatar/snice-avatar.ts +136 -0
  15. package/components/avatar/snice-avatar.types.ts +13 -0
  16. package/components/badge/demo.html +523 -0
  17. package/components/badge/snice-badge.css +161 -0
  18. package/components/badge/snice-badge.ts +117 -0
  19. package/components/badge/snice-badge.types.ts +16 -0
  20. package/components/breadcrumbs/demo.html +404 -0
  21. package/components/breadcrumbs/snice-breadcrumbs.css +133 -0
  22. package/components/breadcrumbs/snice-breadcrumbs.ts +191 -0
  23. package/components/breadcrumbs/snice-breadcrumbs.types.ts +26 -0
  24. package/components/breadcrumbs/snice-crumb.ts +26 -0
  25. package/components/button/demo.html +42 -0
  26. package/components/button/snice-button.css +230 -0
  27. package/components/button/snice-button.ts +169 -0
  28. package/components/button/snice-button.types.ts +25 -0
  29. package/components/card/demo.html +525 -0
  30. package/components/card/snice-card.css +140 -0
  31. package/components/card/snice-card.ts +102 -0
  32. package/components/card/snice-card.types.ts +10 -0
  33. package/components/checkbox/demo.html +253 -0
  34. package/components/checkbox/snice-checkbox.css +164 -0
  35. package/components/checkbox/snice-checkbox.ts +223 -0
  36. package/components/checkbox/snice-checkbox.types.ts +22 -0
  37. package/components/chip/demo.html +383 -0
  38. package/components/chip/snice-chip.css +195 -0
  39. package/components/chip/snice-chip.ts +139 -0
  40. package/components/chip/snice-chip.types.ts +15 -0
  41. package/components/date-picker/README.md +233 -0
  42. package/components/date-picker/demo.html +191 -0
  43. package/components/date-picker/snice-date-picker.css +330 -0
  44. package/components/date-picker/snice-date-picker.ts +777 -0
  45. package/components/date-picker/snice-date-picker.types.ts +83 -0
  46. package/components/divider/demo.html +233 -0
  47. package/components/divider/snice-divider.css +155 -0
  48. package/components/divider/snice-divider.ts +69 -0
  49. package/components/divider/snice-divider.types.ts +15 -0
  50. package/components/drawer/demo.html +328 -0
  51. package/components/drawer/snice-drawer.css +476 -0
  52. package/components/drawer/snice-drawer.ts +287 -0
  53. package/components/drawer/snice-drawer.types.ts +17 -0
  54. package/components/global.d.ts +14 -0
  55. package/components/input/demo.html +303 -0
  56. package/components/input/snice-input.css +257 -0
  57. package/components/input/snice-input.ts +442 -0
  58. package/components/input/snice-input.types.ts +59 -0
  59. package/components/input/test.html +77 -0
  60. package/components/layout/README.md +260 -0
  61. package/components/layout/demo.html +538 -0
  62. package/components/layout/snice-layout-blog.css +129 -0
  63. package/components/layout/snice-layout-blog.ts +48 -0
  64. package/components/layout/snice-layout-card.css +104 -0
  65. package/components/layout/snice-layout-card.ts +35 -0
  66. package/components/layout/snice-layout-centered.css +51 -0
  67. package/components/layout/snice-layout-centered.ts +22 -0
  68. package/components/layout/snice-layout-dashboard.css +98 -0
  69. package/components/layout/snice-layout-dashboard.ts +45 -0
  70. package/components/layout/snice-layout-fullscreen.css +72 -0
  71. package/components/layout/snice-layout-fullscreen.ts +34 -0
  72. package/components/layout/snice-layout-landing.css +92 -0
  73. package/components/layout/snice-layout-landing.ts +47 -0
  74. package/components/layout/snice-layout-minimal.css +16 -0
  75. package/components/layout/snice-layout-minimal.ts +19 -0
  76. package/components/layout/snice-layout-sidebar.css +117 -0
  77. package/components/layout/snice-layout-sidebar.ts +48 -0
  78. package/components/layout/snice-layout-split.css +103 -0
  79. package/components/layout/snice-layout-split.ts +29 -0
  80. package/components/layout/snice-layout.css +72 -0
  81. package/components/layout/snice-layout.ts +35 -0
  82. package/components/layout/snice-layout.types.ts +5 -0
  83. package/components/login/demo-auth-controller.ts +185 -0
  84. package/components/login/demo.html +470 -0
  85. package/components/login/snice-login.css +204 -0
  86. package/components/login/snice-login.ts +337 -0
  87. package/components/login/snice-login.types.ts +34 -0
  88. package/components/modal/demo.html +291 -0
  89. package/components/modal/snice-modal.css +203 -0
  90. package/components/modal/snice-modal.ts +233 -0
  91. package/components/modal/snice-modal.types.ts +21 -0
  92. package/components/pagination/demo.html +395 -0
  93. package/components/pagination/snice-pagination.ts +333 -0
  94. package/components/pagination/snice-pagination.types.ts +21 -0
  95. package/components/progress/demo.html +510 -0
  96. package/components/progress/snice-progress.css +267 -0
  97. package/components/progress/snice-progress.ts +247 -0
  98. package/components/progress/snice-progress.types.ts +19 -0
  99. package/components/radio/demo.html +287 -0
  100. package/components/radio/snice-radio.css +171 -0
  101. package/components/radio/snice-radio.ts +218 -0
  102. package/components/radio/snice-radio.types.ts +21 -0
  103. package/components/select/demo.html +511 -0
  104. package/components/select/snice-option.ts +52 -0
  105. package/components/select/snice-option.types.ts +14 -0
  106. package/components/select/snice-select.css +392 -0
  107. package/components/select/snice-select.ts +796 -0
  108. package/components/select/snice-select.types.ts +55 -0
  109. package/components/skeleton/demo.html +514 -0
  110. package/components/skeleton/snice-skeleton.css +109 -0
  111. package/components/skeleton/snice-skeleton.ts +126 -0
  112. package/components/skeleton/snice-skeleton.types.ts +11 -0
  113. package/components/switch/demo.html +284 -0
  114. package/components/switch/snice-switch.css +221 -0
  115. package/components/switch/snice-switch.ts +229 -0
  116. package/components/switch/snice-switch.types.ts +23 -0
  117. package/components/symbols.ts +23 -0
  118. package/components/table/demo-table-controller.ts +100 -0
  119. package/components/table/demo.html +480 -0
  120. package/components/table/snice-cell-boolean.ts +112 -0
  121. package/components/table/snice-cell-date.ts +210 -0
  122. package/components/table/snice-cell-duration.ts +91 -0
  123. package/components/table/snice-cell-filesize.ts +90 -0
  124. package/components/table/snice-cell-number.ts +165 -0
  125. package/components/table/snice-cell-progress.ts +83 -0
  126. package/components/table/snice-cell-rating.ts +82 -0
  127. package/components/table/snice-cell-sparkline.ts +253 -0
  128. package/components/table/snice-cell-text.ts +125 -0
  129. package/components/table/snice-cell.css +296 -0
  130. package/components/table/snice-cell.ts +473 -0
  131. package/components/table/snice-column.ts +353 -0
  132. package/components/table/snice-header.css +243 -0
  133. package/components/table/snice-header.ts +261 -0
  134. package/components/table/snice-progress.ts +66 -0
  135. package/components/table/snice-rating.ts +45 -0
  136. package/components/table/snice-row.css +255 -0
  137. package/components/table/snice-row.ts +331 -0
  138. package/components/table/snice-table.css +241 -0
  139. package/components/table/snice-table.ts +737 -0
  140. package/components/table/snice-table.types.ts +158 -0
  141. package/components/tabs/demo.html +487 -0
  142. package/components/tabs/snice-tab-panel.css +264 -0
  143. package/components/tabs/snice-tab-panel.ts +47 -0
  144. package/components/tabs/snice-tab.css +96 -0
  145. package/components/tabs/snice-tab.ts +65 -0
  146. package/components/tabs/snice-tabs.css +189 -0
  147. package/components/tabs/snice-tabs.ts +332 -0
  148. package/components/tabs/snice-tabs.types.ts +28 -0
  149. package/components/theme/theme.css +234 -0
  150. package/components/toast/demo.html +329 -0
  151. package/components/toast/snice-toast-container.ts +256 -0
  152. package/components/toast/snice-toast.css +213 -0
  153. package/components/toast/snice-toast.ts +276 -0
  154. package/components/toast/snice-toast.types.ts +35 -0
  155. package/components/tooltip/demo.html +350 -0
  156. package/components/tooltip/snice-tooltip-portal.css +79 -0
  157. package/components/tooltip/snice-tooltip.css +117 -0
  158. package/components/tooltip/snice-tooltip.ts +612 -0
  159. package/components/tooltip/snice-tooltip.types.ts +32 -0
  160. package/components/transitions.ts +94 -0
  161. package/components/tsconfig.json +18 -0
  162. package/dist/index.cjs +441 -329
  163. package/dist/index.cjs.map +1 -1
  164. package/dist/index.cjs.min.map +1 -1
  165. package/dist/index.esm.js +441 -329
  166. package/dist/index.esm.js.map +1 -1
  167. package/dist/index.esm.min.js +3 -3
  168. package/dist/index.esm.min.js.map +1 -1
  169. package/dist/index.iife.js +441 -329
  170. package/dist/index.iife.js.map +1 -1
  171. package/dist/index.iife.min.js +3 -3
  172. package/dist/index.iife.min.js.map +1 -1
  173. package/dist/symbols.esm.js +1 -1
  174. package/dist/transitions.esm.js +1 -1
  175. package/dist/types/controller.d.ts +1 -1
  176. package/dist/types/element.d.ts +10 -10
  177. package/dist/types/events.d.ts +2 -2
  178. package/dist/types/index.d.ts +1 -1
  179. package/dist/types/observe.d.ts +1 -1
  180. package/dist/types/request-response.d.ts +2 -3
  181. package/dist/types/router.d.ts +1 -1
  182. package/package.json +9 -3
  183. package/dist/index.cjs.min +0 -15
  184. package/dist/symbols.cjs +0 -103
  185. package/dist/transitions.cjs +0 -219
@@ -1,14 +1,14 @@
1
1
  /*!
2
- * snice v1.14.2
2
+ * snice v1.14.3
3
3
  * Imperative TypeScript framework for building vanilla web components with decorators, routing, and controllers. No virtual DOM, no build complexity.
4
4
  * (c) 2024
5
5
  * Released under the MIT License.
6
6
  */
7
- const t=(globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map}),globalThis.snice);function e(e){return t.symbols.has(e)||t.symbols.set(e,Symbol(e)),t.symbols.get(e)}const n=e("is-controller-class"),o=e("is-controller-instance"),r=e("is-element-class"),s=e("channel-handlers"),i=e("ready-promise"),a=e("ready-resolve"),l=e("controller"),c=e("on-handlers"),u=e("controller-key"),h=e("controller-name"),d=e("controller-id"),f=e("controller-operations"),p=e("native-controller"),m=e("cleanup"),y=e("properties"),g=e("property-values"),b=e("properties-initialized"),v=e("property-watchers"),w=e("explicitly-set-properties"),E=e("router-context");e("current-page-marker");const S=e("context-request-handler"),A=e("page-transition"),O=e("created-at"),T=e("ready-handlers"),N=e("dispose-handlers"),P=e("observers"),L=e("parts"),x=e("part-timers");function C(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n,s){e[c]||(e[c]=[]);const i=Array.isArray(t)?t:[t];for(const t of i)e[c].push({eventName:t,selector:o,methodName:n,method:s.value,options:r});return s}}function k(t,e){const n=t.constructor.prototype[c];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=o.options||{},[s,i]=o.eventName.split(":"),a=t=>!i||"keydown"!==s&&"keyup"!==s&&"keypress"!==s?t:e=>{const n=e,o=t=>"Space"===t?" ":t;if(i.startsWith("~")){const r=o(i.slice(1));return void(n.key===r&&t(e))}if(i.includes("+")){const r=i.split("+"),s=o(r[r.length-1]),a=r.slice(0,-1);if(n.key!==s)return;const l=new Set(a.map(t=>t.toLowerCase())),c=l.has("ctrl"),u=l.has("shift"),h=l.has("alt"),d=l.has("meta")||l.has("cmd");n.ctrlKey===c&&n.shiftKey===u&&n.altKey===h&&n.metaKey===d&&t(e)}else{const r=o(i);n.key!==r||n.ctrlKey||n.shiftKey||n.altKey||n.metaKey||t(e)}},l=(t=>{if(r.debounce){let e;return function(...n){clearTimeout(e),e=setTimeout(()=>t.apply(this,n),r.debounce)}}if(r.throttle){let e,n=0;return function(...o){const s=Date.now(),i=r.throttle-(s-n);i<=0?(clearTimeout(e),n=s,t.apply(this,o)):e||(e=setTimeout(()=>{n=Date.now(),e=null,t.apply(this,o)},i))}}return t})(n),c=a(t=>{try{return r.preventDefault&&t.preventDefault(),r.stopPropagation&&t.stopPropagation(),l(t)}catch(t){console.error(`Error in event handler ${o.methodName}:`,t)}});if(o.selector){const n=e.shadowRoot||e,i=t=>{const e=t.target;let n=!1;if(e.matches&&e.matches(o.selector))n=!0;else if(e.closest){e.closest(o.selector)&&(n=!0)}n&&(r.preventDefault&&t.preventDefault(),r.stopPropagation&&(t.stopPropagation(),t.stopImmediatePropagation()),c(t))},a={capture:r.capture||!1,once:r.once||!1,passive:r.passive||!1};n.addEventListener(s,i,a),t[m].events.push(()=>{n.removeEventListener(s,i,a)})}else{const n={capture:r.capture||!1,once:r.once||!1,passive:r.passive||!1};e.addEventListener(s,c,n),t[m].events.push(()=>{e.removeEventListener(s,c,n)})}}}}function I(t){if(t[m]?.events){for(const e of t[m].events)e();t[m].events=[]}}function R(t,e){return function(n,o,r){const s=r.value;let i,a,l=0;return r.value=function(...n){const o=s.apply(this,n),r=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},c=t=>{if(e?.debounce)clearTimeout(i),i=setTimeout(()=>r(t),e.debounce);else if(e?.throttle){const n=Date.now(),o=e.throttle-(n-l);o<=0?(clearTimeout(a),l=n,r(t)):a||(a=setTimeout(()=>{l=Date.now(),a=null,r(t)},o))}else r(t)};return o instanceof Promise?o.then(t=>(c(t),t)):(c(o),o)},r}}const $=new Map,q=new WeakMap;function D(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n,s){e[P]||(e[P]=[]);const i=Array.isArray(t)?t:[t];for(const t of i){const[i,...a]=t.split(":");e[P].push({type:i,target:a.join(":"),selector:o,methodName:n,method:s.value,options:r})}return s}}function M(t,e){const n=t.constructor.prototype[P];if(n&&Array.isArray(n)&&0!==n.length){t[m]?t[m].observers||(t[m].observers=[]):t[m]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(t),r=o.options?.throttle?H(n,o.options.throttle):n;switch(o.type){case"intersection":j(t,e,o,r);break;case"resize":F(t,e,o,r);break;case"media":U(t,e,o,r);break;case"mutation":z(t,e,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function j(t,e,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null},s=JSON.stringify(r),i=t=>{for(const e of t)try{!1===o(e)&&a&&a.unobserve(e.target)}catch(t){console.error(`Error in intersection observer ${n.methodName}:`,t)}};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");let a=q.get({instance:t,options:s});a||(a=new IntersectionObserver(i,r),q.set({instance:t,options:s},a));const l=n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e];l.forEach(t=>a.observe(t)),t[m].observers.push(()=>{l.forEach(t=>a.unobserve(t)),0===a.takeRecords().length&&a.disconnect()})}function F(t,e,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(t=>{for(const e of t)try{o(e)}catch(t){console.error(`Error in resize observer ${n.methodName}:`,t)}});(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e]).forEach(t=>{s.observe(t,{box:r})}),t[m].observers.push(()=>{s.disconnect()})}function U(t,e,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=$.get(r);if(!s)try{s=window.matchMedia(r),$.set(r,s)}catch(t){return void console.error(`Invalid media query: ${r}`,t)}const i=t=>{try{o(t.matches)}catch(t){console.error(`Error in media query observer ${n.methodName}:`,t)}};i(s);const a=t=>i(t);s.addEventListener?(s.addEventListener("change",a),t[m].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),t[m].observers.push(()=>{s.removeListener(a)}))}function z(t,e,n,r){const s=n.target.split(":"),i=s[0]||"childList",a=s[1],l={};switch(i){case"childList":l.childList=!0;break;case"attributes":l.attributes=!0,a&&(l.attributeFilter=[a]);break;default:return void console.warn(`Unknown mutation type: ${i}`)}n.options?.subtree&&(l.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const c=new MutationObserver(t=>{try{if(n.options?.maxDepth&&n.options.subtree){const o=n.options.maxDepth,s=t.filter(t=>{let n=0,r=t.target;const s=e.shadowRoot||e;for(;r&&r!==s&&n<o;)r=r.parentNode,n++;return n<o});s.length>0&&r(s)}else r(t)}catch(t){console.error(`Error in mutation observer ${n.methodName}:`,t)}}),u=!0===t[o];(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):u&&e.shadowRoot?[e.shadowRoot]:[e]).forEach(t=>{c.observe(t,l)}),t[m].observers.push(()=>{c.disconnect()})}function H(t,e){let n=0,o=null;return function(...r){const s=Date.now(),i=e-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,t.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,t.apply(this,r)},i))}}function B(t){if(t[m]?.observers){for(const e of t[m].observers)e();t[m].observers=[]}}function G(t,e){return function(n,r,s){const i=s.value;let a,l,c=0;return s.value=async function(...n){const r=async()=>{const r=e?.timeout??12e4,s=e?.discoveryTimeout??50,a=i.apply(this,n),{value:l,done:c}=await a.next();if(c)return l;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let f,p,m;const y=new Promise((e,n)=>{f=e,p=n,m=setTimeout(()=>{n(new Error(`Request "${t}" timed out after ${s}ms - no handler found`))},s)}),g=new CustomEvent(`@request/${t}`,{bubbles:void 0===e?.bubbles||e.bubbles,cancelable:e?.cancelable||!1,composed:!0,detail:{payload:l,discovery:{resolve:()=>{clearTimeout(m),f()},reject:p},data:{resolve:u,reject:h}}});(!0===this[o]&&this.element?this.element:this).dispatchEvent(g);try{await y;const e=setTimeout(()=>{h(new Error(`Request "${t}" timed out after ${r}ms`))},r),n=await d;clearTimeout(e);const{value:o}=await a.next(n);return o}catch(t){try{await a.throw(t)}catch(t){throw t}}};if(e?.debounce)return new Promise((t,n)=>{clearTimeout(a),a=setTimeout(async()=>{try{const e=await r();t(e)}catch(t){n(t)}},e.debounce)});if(e?.throttle){const t=Date.now(),n=e.throttle-(t-c);return n<=0?(clearTimeout(l),c=t,r()):l?Promise.resolve():new Promise((t,e)=>{l=setTimeout(async()=>{c=Date.now(),l=null;try{const e=await r();t(e)}catch(t){e(t)}},n)})}return r()},s}}function K(t,e){return function(n,o,r){const i=r.value;return n[s]||(n[s]=[]),n[s].push({channelName:t,methodName:o,method:i,options:e}),r}}function W(t,e){const n=t.constructor.prototype[s];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=`@request/${o.channelName}`;let s,i,a=0;const l=(t=>o.options?.debounce?(...e)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{const o=await t(...e);n(o)}catch(t){r(t)}},o.options.debounce)}):o.options?.throttle?(...e)=>{const n=Date.now(),r=o.options.throttle-(n-a);return r<=0?(clearTimeout(i),a=n,t(...e)):i?Promise.resolve(void 0):new Promise((n,o)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const o=await t(...e);n(o)}catch(t){o(t)}},r)})}:t)(n),c=t=>{const{data:e,discovery:n,payload:r}=t.detail;t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),n.resolve(),Promise.resolve(l(r)).then(t=>{e.resolve(t)}).catch(t=>{e.reject(t),console.error(`Error in response handler ${o.methodName}:`,t)})};e.addEventListener(r,c),t[m].channels.push(()=>{e.removeEventListener(r,c)})}}}function Q(t){if(t[m]?.channels){for(const e of t[m].channels)e();t[m].channels=[]}}class _{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(t,e){this.cleanupFns.set(t,e)}unregister(t){this.cleanupFns.delete(t)}async cleanup(){await Promise.all(this.pendingOperations);for(const t of this.cleanupFns.values())try{await t()}catch(t){console.error("Error during cleanup:",t)}this.cleanupFns.clear()}async runOperation(t){const e=t(),n=e.then(()=>{},()=>{});this.pendingOperations.add(n);try{const t=await e;return this.pendingOperations.delete(n),t}catch(t){throw this.pendingOperations.delete(n),t}}}function J(e){return function(o){return t.controllerRegistry.set(e,o),o.prototype[n]=!0,o}}async function V(e,n){const r=e[u],s=e[h],i=e[p];if(void 0!==i&&i!==n)return;if(s===n&&r)return;r&&await X(e);const a=t.controllerRegistry.get(n);if(!a)throw new Error(`Controller "${n}" not found in registry`);const l=new a;t.controllerIdCounter+=1;const c=t.controllerIdCounter,m=new _;l[o]=!0,l[d]=c,l.element=e;const y=e[E];void 0!==y&&(l[E]=y),e[u]=l,e[h]=n,e[f]=m,await e.ready,await m.runOperation(async()=>{await l.attach(e)}),k(l,e),M(l,e),W(l,e),e.dispatchEvent(new CustomEvent("@snice/controller-attached",{detail:{name:n,controller:l}}))}async function X(t){const e=t[u],n=t[h],o=t[f];e&&(o?await o.runOperation(async()=>{await e.detach(t)}):await e.detach(t),e.element=null,I(e),B(e),Q(e),o&&await o.cleanup(),delete e[E],delete t[u],delete t[h],delete t[f],t.dispatchEvent(new CustomEvent("@snice/controller-detached",{detail:{name:n,controller:e}})))}function Y(t){return t[u]}function Z(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[r])return;const e=t.getAttribute("controller"),n=t[p];e&&e!==n?(t[p]=e,t.ready||(t.ready=Promise.resolve()),n&&X(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),V(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[p],delete t[h],X(t).catch(t=>{console.error("Failed to detach controller from native element:",t)}))}globalThis.sniceNativeControllersInitialized=!0;const e=new MutationObserver(e=>{for(const n of e)"attributes"===n.type&&"controller"===n.attributeName?t(n.target):"childList"===n.type&&n.addedNodes.forEach(e=>{e instanceof HTMLElement&&(t(e),e.querySelectorAll('[controller]:not([class*="-"])').forEach(t))})});"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}):(document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})),globalThis.sniceNativeControllerObserver=e}function tt(){const t=globalThis.sniceNativeControllerObserver;t&&(t.disconnect(),delete globalThis.sniceNativeControllerObserver,delete globalThis.sniceNativeControllersInitialized)}function et(t){t.prototype[r]=!0;const e=t.prototype.connectedCallback,n=t.prototype.disconnectedCallback,o=t.prototype.attributeChangedCallback,s=t.observedAttributes||[];s.includes("controller")||s.push("controller");const c=t[y];if(c)for(const[t,e]of c){const n="string"==typeof e.attribute?e.attribute:t.toLowerCase();s.includes(n)||s.push(n)}Object.defineProperty(t,"observedAttributes",{get:()=>s,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get(){return this[i]||(this[i]=new Promise(t=>{this[a]=t})),this[i]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controller",{get(){return this[l]},set(t){const e=this[l];this[l]=t,t!==e&&t?V(this,t).catch(e=>{console.error(`Failed to attach controller "${t}":`,e)}):!t&&e&&X(this).catch(t=>{console.error("Failed to detach controller:",t)})},enumerable:!0,configurable:!0}),t.prototype.connectedCallback=async function(){this[i]||(this[i]=new Promise(t=>{this[a]=t}));try{const n=t[y];if(n)for(const[t,e]of n)if(this.hasAttribute(t)){const n=this.getAttribute(t);switch(this[w]||(this[w]=new Set),this[w].add(t),e.type){case Boolean:this[t]=null!==n&&"false"!==n;break;case Number:this[t]=Number(n);break;case String:this[t]=n;break;case Date:this[t]=n?new Date(n):null;break;case BigInt:n&&n.endsWith("n")?this[t]=BigInt(n.slice(0,-1)):this[t]=n?BigInt(n):null;break;case at:this[t]=at.parse(n);break;default:this[t]=n}}if(this[b]=!0,n&&this[w])for(const[t,e]of n)if(e.reflect&&this[w].has(t)&&t in this[g]){const n=this[g][t],o="string"==typeof e.attribute?e.attribute:t.toLowerCase();if(null!=n&&!1!==n&&(e.type!==at||!Array.isArray(n)||0!==n.length)){let t;t=n instanceof Date?n.toISOString():"bigint"==typeof n?n.toString()+"n":e.type===at&&Array.isArray(n)?at.serialize(n):String(n),this.setAttribute(o,t)}}I(this),this.shadowRoot||this.attachShadow({mode:"open"});let o="";if(this.html)try{const t=this.html(),e=t instanceof Promise?await t:t;void 0!==e&&(o+=e)}catch(t){console.error(`Error in html() method for ${this.tagName}:`,t)}if(this.css)try{const t=this.css(),e=t instanceof Promise?await t:t;if(e){o+=`<style data-component-css>${Array.isArray(e)?e.join("\n"):e}</style>`}}catch(t){console.error(`Error in css() method for ${this.tagName}:`,t)}o&&(this.shadowRoot.innerHTML=o);const r=t[L];if(r&&this.shadowRoot)for(const[t,e]of r)try{const n=this.shadowRoot.querySelector(`[part="${t}"]`);if(n){const t=e.method.call(this),o=t instanceof Promise?await t:t;void 0!==o&&(n.innerHTML=o)}}catch(e){console.error(`Error rendering @part('${t}') in ${this.tagName}:`,e)}e&&e.call(this);const s=this.getAttribute("controller");s&&(this.controller=s),k(this,this),W(this,this);try{M(this,this)}catch(t){console.error(`Error setting up observers for ${this.tagName}:`,t)}const i=t[T];if(i)for(const t of i)try{await t.method.call(this)}catch(e){console.error(`Error in @ready handler ${t.methodName}:`,e)}}finally{this[a]&&(this[a](),this[a]=null)}},t.prototype.disconnectedCallback=async function(){const e=t[N];if(e)for(const t of e)try{await t.method.call(this)}catch(e){console.error(`Error in @dispose handler ${t.methodName}:`,e)}n&&n.call(this),this[l]&&X(this).catch(t=>{console.error("Failed to detach controller:",t)}),I(this),Q(this),B(this)},t.prototype.attributeChangedCallback=function(e,n,r){if(o?.call(this,e,n,r),"controller"===e)this.controller=r;else{const n=t[y];if(n)for(const[o,s]of n){if(("string"==typeof s.attribute?s.attribute:o.toLowerCase())===e){const e=this[g]?.[o];let n;if(n=s.type===Boolean?null!==r&&"false"!==r:s.type===Number?Number(r):s.type===Date?r?new Date(r):null:s.type===BigInt?r&&r.endsWith("n")?BigInt(r.slice(0,-1)):r?BigInt(r):null:s.type===at?at.parse(r):"number"==typeof e&&null!==r?Number(r):r,e!==n){this[w]||(this[w]=new Set),this[w].add(o),this[g]||(this[g]={}),this[g][o]=n;const r=t[v];if(r){if(r.has(o)){const t=r.get(o);for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(r.has("*")){const t=r.get("*");for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}}break}}}}}function nt(t){return function(e){et(e),customElements.define(t,e)}}function ot(t){return function(e){et(e),customElements.define(t,e)}}function rt(t){return function(e,n){const o=e.constructor;t?.reflect&&t?.type===Array&&console.warn(`⚠️ Property '${n}' uses reflect:true with Array type.`),t?.reflect&&t?.type===Object&&console.warn(`⚠️ Property '${n}' uses reflect:true with Object type.`),o[y]||(o[y]=new Map),o[y].set(n,t||{});const r={get(){return this[g]||(this[g]={}),this[g][n]},set(e){this[g]||(this[g]={}),this[w]||(this[w]=new Set);const r=this[g][n];if(r===e)return;const s=void 0===r&&!this[b];if((void 0!==r||s&&null!=e)&&this[w].add(n),this[g][n]=e,t?.reflect&&this.setAttribute&&this[b]&&this[w].has(n)){const o="string"==typeof t.attribute?t.attribute:n.toLowerCase();if(null==e||!1===e||t?.type===at&&Array.isArray(e)&&0===e.length)this.removeAttribute(o);else{let n;n=e instanceof Date?e.toISOString():"bigint"==typeof e?e.toString()+"n":t?.type===at&&Array.isArray(e)?at.serialize(e):String(e),this.setAttribute(o,n)}}const i=o[v];if(i){if(i.has(n)){const t=i.get(n);for(const o of t)try{o.method.call(this,r,e,n)}catch(t){console.error(`Error in @watch('${n}') method ${o.methodName}:`,t)}}if(i.has("*")){const t=i.get("*");for(const o of t)try{o.method.call(this,r,e,n)}catch(t){console.error(`Error in @watch('*') method ${o.methodName}:`,t)}}}this.requestUpdate&&this.requestUpdate(n,r)},enumerable:!0,configurable:!0};Object.defineProperty(e,n,r)}}function st(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e;Object.defineProperty(n,r,{get(){const e=!0===this[o]&&this.element?this.element:this;let n=null;return i&&e.shadowRoot&&(n=e.shadowRoot.querySelector(t)),!n&&s&&(n=e.querySelector(t)),n||null},enumerable:!0,configurable:!0})}}function it(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e;Object.defineProperty(n,r,{get(){const e=!0===this[o]&&this.element?this.element:this,n=[];if(i&&e.shadowRoot){const o=e.shadowRoot.querySelectorAll(t);n.push(...o)}if(s){const o=e.querySelectorAll(t);n.push(...o)}return n},enumerable:!0,configurable:!0})}}class at{static serialize(t){return Array.isArray(t)?t.map(t=>{if("string"==typeof t){if(t.includes(at.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${at.SEPARATOR}" (U+FF0C)`);return t}if("number"==typeof t||"boolean"==typeof t)return String(t);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof t)}).join(at.SEPARATOR):""}static parse(t){return null==t||""===t?[]:t.split(at.SEPARATOR).map(t=>{if(/^-?\d+\.?\d*$/.test(t)){const e=Number(t);if(!isNaN(e))return e}return"true"===t||"false"!==t&&t})}}function lt(...t){return function(e,n,o){const r=e.constructor;r[v]||(r[v]=new Map);for(const e of t)r[v].has(e)||r[v].set(e,[]),r[v].get(e).push({methodName:n,method:o.value});return o}}function ct(){return function(t,e){Object.defineProperty(t,e,{get(){if(void 0!==this[E])return this[E];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[o]&&this.element?this.element:this;if(n&&n.dispatchEvent){if(n.getRootNode&&n.getRootNode()instanceof ShadowRoot){const t=n.getRootNode();n=t.host}return n.dispatchEvent(e),void 0!==t.context?(this[E]=t.context,t.context):void 0}},enumerable:!0,configurable:!0})}}function ut(){return function(t,e,n){const o=t.constructor;return o[T]||(o[T]=[]),o[T].push({methodName:e,method:n.value}),n}}function ht(){return function(t,e,n){const o=t.constructor;return o[N]||(o[N]=[]),o[N].push({methodName:e,method:n.value}),n}}function dt(t,e={}){return function(n,o,r){const s=n.constructor;r||(r=Object.getOwnPropertyDescriptor(n,o)||{value:n[o],writable:!0,enumerable:!0,configurable:!0});const i=r.value;return s[L]||(s[L]=new Map),s[L].set(t,{methodName:o,method:i}),r.value=async function(...n){this[x]||(this[x]=new Map),this[x].has(t)||this[x].set(t,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const o=this[x].get(t),r=async()=>{const e=i.apply(this,n),o=e instanceof Promise?await e:e;if(this.shadowRoot&&void 0!==o){const e=this.shadowRoot.querySelector(`[part="${t}"]`);e&&(e.innerHTML=o)}return o};if(void 0!==e.debounce&&e.debounce>0)return o.debounceTimer&&clearTimeout(o.debounceTimer),new Promise(t=>{o.debounceTimer=setTimeout(async()=>{const e=await r();t(e)},e.debounce)});if(void 0!==e.throttle&&e.throttle>0){const t=Date.now();if(0===o.lastThrottleCall||t-o.lastThrottleCall>=e.throttle)return o.lastThrottleCall=t,await r();if(!o.throttleTimer){const n=e.throttle-(t-o.lastThrottleCall);o.throttleTimer=setTimeout(async()=>{o.throttleTimer=null,o.lastThrottleCall=Date.now(),await r()},n)}return}return await r()},r}}
7
+ const t=(globalThis.snice||(globalThis.snice={controllerRegistry:new Map,controllerIdCounter:0,symbols:new Map}),globalThis.snice);function e(e){return t.symbols.has(e)||t.symbols.set(e,Symbol(e)),t.symbols.get(e)}const n=e("is-controller-class"),o=e("is-controller-instance"),r=e("is-element-class"),s=e("channel-handlers"),i=e("ready-promise"),a=e("ready-resolve"),c=e("controller"),l=e("on-handlers"),u=e("controller-key"),h=e("controller-name"),d=e("controller-id"),p=e("controller-operations"),f=e("native-controller"),m=e("cleanup"),y=e("properties"),g=e("property-values"),b=e("properties-initialized"),w=e("property-watchers"),v=e("explicitly-set-properties"),E=e("router-context");e("current-page-marker");const S=e("context-request-handler"),T=e("page-transition"),A=e("created-at"),O=e("ready-handlers"),N=e("dispose-handlers"),P=e("observers"),C=e("parts"),I=e("part-timers");function L(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[l]||(n.prototype[l]=[]);const i=Array.isArray(t)?t:[t];for(const t of i)n.prototype[l].push({eventName:t,selector:o,methodName:s,method:e,options:r})})}}function x(t,e){const n=t.constructor.prototype[l];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=o.options||{},[s,i]=o.eventName.split(":"),a=t=>!i||"keydown"!==s&&"keyup"!==s&&"keypress"!==s?t:e=>{const n=e,o=t=>"Space"===t?" ":t;if(i.startsWith("~")){const r=o(i.slice(1));return void(n.key===r&&t(e))}if(i.includes("+")){const r=i.split("+"),s=o(r[r.length-1]),a=r.slice(0,-1);if(n.key!==s)return;const c=new Set(a.map(t=>t.toLowerCase())),l=c.has("ctrl"),u=c.has("shift"),h=c.has("alt"),d=c.has("meta")||c.has("cmd");n.ctrlKey===l&&n.shiftKey===u&&n.altKey===h&&n.metaKey===d&&t(e)}else{const r=o(i);n.key!==r||n.ctrlKey||n.shiftKey||n.altKey||n.metaKey||t(e)}},c=(t=>{if(r.debounce){let e;return function(...n){clearTimeout(e),e=setTimeout(()=>t.apply(this,n),r.debounce)}}if(r.throttle){let e,n=0;return function(...o){const s=Date.now(),i=r.throttle-(s-n);i<=0?(clearTimeout(e),n=s,t.apply(this,o)):e||(e=setTimeout(()=>{n=Date.now(),e=null,t.apply(this,o)},i))}}return t})(n),l=a(t=>{try{return r.preventDefault&&t.preventDefault(),r.stopPropagation&&t.stopPropagation(),c(t)}catch(t){console.error(`Error in event handler ${o.methodName}:`,t)}});if(o.selector){const n=e.shadowRoot||e,i=t=>{const e=t.target;let n=!1;if(e.matches&&e.matches(o.selector))n=!0;else if(e.closest){e.closest(o.selector)&&(n=!0)}n&&(r.preventDefault&&t.preventDefault(),r.stopPropagation&&(t.stopPropagation(),t.stopImmediatePropagation()),l(t))},a={capture:r.capture||!1,once:r.once||!1,passive:r.passive||!1};n.addEventListener(s,i,a),t[m].events.push(()=>{n.removeEventListener(s,i,a)})}else{const n={capture:r.capture||!1,once:r.once||!1,passive:r.passive||!1};e.addEventListener(s,l,n),t[m].events.push(()=>{e.removeEventListener(s,l,n)})}}}}function k(t){if(t[m]?.events){for(const e of t[m].events)e();t[m].events=[]}}function R(t,e){return function(n,o){let r,s,i=0;return function(...o){const a=n.apply(this,o),c=n=>{if(void 0===n&&!1===e?.dispatchOnUndefined)return;const o=new CustomEvent(t,{bubbles:!0,composed:!0,...e,detail:n});this.dispatchEvent(o)},l=t=>{if(e?.debounce)clearTimeout(r),r=setTimeout(()=>c(t),e.debounce);else if(e?.throttle){const n=Date.now(),o=e.throttle-(n-i);o<=0?(clearTimeout(s),i=n,c(t)):s||(s=setTimeout(()=>{i=Date.now(),s=null,c(t)},o))}else c(t)};return a instanceof Promise?a.then(t=>(l(t),t)):(l(a),a)}}}const $=new Map,q=new WeakMap;function D(t,e,n){let o,r;return"string"==typeof e?(o=e,r=n):(o=void 0,r=e),function(e,n){const s=n.name;n.addInitializer(function(){const n=this.constructor;n.prototype[P]||(n.prototype[P]=[]);const i=Array.isArray(t)?t:[t];for(const t of i){const[i,...a]=t.split(":");n.prototype[P].push({type:i,target:a.join(":"),selector:o,methodName:s,method:e,options:r})}})}}function M(t,e){const n=t.constructor.prototype[P];if(n&&Array.isArray(n)&&0!==n.length){t[m]?t[m].observers||(t[m].observers=[]):t[m]={events:[],channels:[],observers:[]};for(const o of n){const n=o.method.bind(t),r=o.options?.throttle?H(n,o.options.throttle):n;switch(o.type){case"intersection":j(t,e,o,r);break;case"resize":z(t,e,o,r);break;case"media":F(t,e,o,r);break;case"mutation":U(t,e,o,r);break;default:console.warn(`Unknown observer type: ${o.type}`)}}}}function j(t,e,n,o){const r={threshold:n.options?.threshold??0,rootMargin:n.options?.rootMargin??"0px",root:n.options?.root??null},s=JSON.stringify(r),i=t=>{for(const e of t)try{!1===o(e)&&a&&a.unobserve(e.target)}catch(t){console.error(`Error in intersection observer ${n.methodName}:`,t)}};if("undefined"==typeof IntersectionObserver)return void console.warn("IntersectionObserver is not available in this environment");let a=q.get({instance:t,options:s});a||(a=new IntersectionObserver(i,r),q.set({instance:t,options:s},a));const c=n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e];c.forEach(t=>a.observe(t)),t[m].observers.push(()=>{c.forEach(t=>a.unobserve(t)),0===a.takeRecords().length&&a.disconnect()})}function z(t,e,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(t=>{for(const e of t)try{o(e)}catch(t){console.error(`Error in resize observer ${n.methodName}:`,t)}});(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):[e]).forEach(t=>{s.observe(t,{box:r})}),t[m].observers.push(()=>{s.disconnect()})}function F(t,e,n,o){const r=n.target;if(!r)return void console.warn("Media query observer requires a query string");let s=$.get(r);if(!s)try{s=window.matchMedia(r),$.set(r,s)}catch(t){return void console.error(`Invalid media query: ${r}`,t)}const i=t=>{try{o(t.matches)}catch(t){console.error(`Error in media query observer ${n.methodName}:`,t)}};i(s);const a=t=>i(t);s.addEventListener?(s.addEventListener("change",a),t[m].observers.push(()=>{s.removeEventListener("change",a)})):(s.addListener(a),t[m].observers.push(()=>{s.removeListener(a)}))}function U(t,e,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 console.warn(`Unknown mutation type: ${i}`)}n.options?.subtree&&(c.subtree=!0,n.options.maxDepth&&console.warn("maxDepth is set but requires custom implementation"));const l=new MutationObserver(t=>{try{if(n.options?.maxDepth&&n.options.subtree){const o=n.options.maxDepth,s=t.filter(t=>{let n=0,r=t.target;const s=e.shadowRoot||e;for(;r&&r!==s&&n<o;)r=r.parentNode,n++;return n<o});s.length>0&&r(s)}else r(t)}catch(t){console.error(`Error in mutation observer ${n.methodName}:`,t)}}),u=!0===t[o];(n.selector?Array.from(e.shadowRoot?.querySelectorAll(n.selector)||[]):u&&e.shadowRoot?[e.shadowRoot]:[e]).forEach(t=>{l.observe(t,c)}),t[m].observers.push(()=>{l.disconnect()})}function H(t,e){let n=0,o=null;return function(...r){const s=Date.now(),i=e-(s-n);if(i<=0)return o&&(clearTimeout(o),o=null),n=s,t.apply(this,r);o||(o=setTimeout(()=>{n=Date.now(),o=null,t.apply(this,r)},i))}}function B(t){if(t[m]?.observers){for(const e of t[m].observers)e();t[m].observers=[]}}function G(t,e){return function(n,r){let s,i,a=0;return async function(...r){const c=async()=>{const s=e?.timeout??12e4,i=e?.discoveryTimeout??50,a=n.apply(this,r),{value:c,done:l}=await a.next();if(l)return c;let u,h;const d=new Promise((t,e)=>{u=t,h=e});let p,f,m;const y=new Promise((e,n)=>{p=e,f=n,m=setTimeout(()=>{n(new Error(`Request "${t}" timed out after ${i}ms - no handler found`))},i)}),g=new CustomEvent(`@request/${t}`,{bubbles:void 0===e?.bubbles||e.bubbles,cancelable:e?.cancelable||!1,composed:!0,detail:{payload:c,discovery:{resolve:()=>{clearTimeout(m),p()},reject:f},data:{resolve:u,reject:h}}});(!0===this[o]&&this.element?this.element:this).dispatchEvent(g);try{await y;const e=setTimeout(()=>{h(new Error(`Request "${t}" timed out after ${s}ms`))},s),n=await d;clearTimeout(e);const{value:o}=await a.next(n);return o}catch(t){try{await a.throw(t)}catch(t){throw t}}};if(e?.debounce)return new Promise((t,n)=>{clearTimeout(s),s=setTimeout(async()=>{try{const e=await c();t(e)}catch(t){n(t)}},e.debounce)});if(e?.throttle){const t=Date.now(),n=e.throttle-(t-a);return n<=0?(clearTimeout(i),a=t,c()):i?Promise.resolve():new Promise((t,e)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const e=await c();t(e)}catch(t){e(t)}},n)})}return c()}}}function K(t,e){return function(n,o){const r=o.name;o.addInitializer(function(){const o=this.constructor;o.prototype[s]||(o.prototype[s]=[]),o.prototype[s].push({channelName:t,methodName:r,method:n,options:e})})}}function W(t,e){const n=t.constructor.prototype[s];if(n){t[m]||(t[m]={events:[],channels:[]});for(const o of n){const n=o.method.bind(t),r=`@request/${o.channelName}`;let s,i,a=0;const c=(t=>o.options?.debounce?(...e)=>new Promise((n,r)=>{clearTimeout(s),s=setTimeout(async()=>{try{const o=await t(...e);n(o)}catch(t){r(t)}},o.options.debounce)}):o.options?.throttle?(...e)=>{const n=Date.now(),r=o.options.throttle-(n-a);return r<=0?(clearTimeout(i),a=n,t(...e)):i?Promise.resolve(void 0):new Promise((n,o)=>{i=setTimeout(async()=>{a=Date.now(),i=null;try{const o=await t(...e);n(o)}catch(t){o(t)}},r)})}:t)(n),l=t=>{const{data:e,discovery:n,payload:r}=t.detail;t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation(),n.resolve(),Promise.resolve(c(r)).then(t=>{e.resolve(t)}).catch(t=>{e.reject(t),console.error(`Error in response handler ${o.methodName}:`,t)})};e.addEventListener(r,l),t[m].channels.push(()=>{e.removeEventListener(r,l)})}}}function Q(t){if(t[m]?.channels){for(const e of t[m].channels)e();t[m].channels=[]}}class _{constructor(){this.cleanupFns=new Map,this.pendingOperations=new Set}register(t,e){this.cleanupFns.set(t,e)}unregister(t){this.cleanupFns.delete(t)}async cleanup(){await Promise.all(this.pendingOperations);for(const t of this.cleanupFns.values())try{await t()}catch(t){console.error("Error during cleanup:",t)}this.cleanupFns.clear()}async runOperation(t){const e=t(),n=e.then(()=>{},()=>{});this.pendingOperations.add(n);try{const t=await e;return this.pendingOperations.delete(n),t}catch(t){throw this.pendingOperations.delete(n),t}}}function J(e){return function(o,r){return t.controllerRegistry.set(e,o),o.prototype[n]=!0,o}}async function V(e,n){const r=e[u],s=e[h],i=e[f];if(void 0!==i&&i!==n)return;if(s===n&&r)return;r&&await X(e);const a=t.controllerRegistry.get(n);if(!a)throw new Error(`Controller "${n}" not found in registry`);const c=new a;t.controllerIdCounter+=1;const l=t.controllerIdCounter,m=new _;c[o]=!0,c[d]=l,c.element=e;const y=e[E];void 0!==y&&(c[E]=y),e[u]=c,e[h]=n,e[p]=m,await e.ready,await m.runOperation(async()=>{await c.attach(e)}),x(c,e),M(c,e),W(c,e),e.dispatchEvent(new CustomEvent("@snice/controller-attached",{detail:{name:n,controller:c}}))}async function X(t){const e=t[u],n=t[h],o=t[p];e&&(o?await o.runOperation(async()=>{await e.detach(t)}):await e.detach(t),e.element=null,k(e),B(e),Q(e),o&&await o.cleanup(),delete e[E],delete t[u],delete t[h],delete t[p],t.dispatchEvent(new CustomEvent("@snice/controller-detached",{detail:{name:n,controller:e}})))}function Y(t){return t[u]}function Z(){if(globalThis.sniceNativeControllersInitialized)return;function t(t){if(!(t instanceof HTMLElement))return;if(t.tagName.includes("-"))return;if(t[r])return;const e=t.getAttribute("controller"),n=t[f];e&&e!==n?(t[f]=e,t.ready||(t.ready=Promise.resolve()),n&&X(t).catch(t=>{console.error("Failed to detach old controller from native element:",t)}),V(t,e).catch(t=>{console.error(`Failed to attach controller "${e}" to native element:`,t)})):!e&&n&&(delete t[f],delete t[h],X(t).catch(t=>{console.error("Failed to detach controller from native element:",t)}))}globalThis.sniceNativeControllersInitialized=!0;const e=new MutationObserver(e=>{for(const n of e)"attributes"===n.type&&"controller"===n.attributeName?t(n.target):"childList"===n.type&&n.addedNodes.forEach(e=>{e instanceof HTMLElement&&(t(e),e.querySelectorAll('[controller]:not([class*="-"])').forEach(t))})});"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})}):(document.querySelectorAll('[controller]:not([class*="-"])').forEach(t),e.observe(document.body,{attributes:!0,attributeFilter:["controller"],childList:!0,subtree:!0})),globalThis.sniceNativeControllerObserver=e}function tt(){const t=globalThis.sniceNativeControllerObserver;t&&(t.disconnect(),delete globalThis.sniceNativeControllerObserver,delete globalThis.sniceNativeControllersInitialized)}function et(t){t.prototype[r]=!0;const e=t.prototype.connectedCallback,n=t.prototype.disconnectedCallback,o=t.prototype.attributeChangedCallback,s=t.observedAttributes||[];s.includes("controller")||s.push("controller");const l=t[y];if(l)for(const[t,e]of l){const n="string"==typeof e.attribute?e.attribute:t.toLowerCase();s.includes(n)||s.push(n)}Object.defineProperty(t,"observedAttributes",{get:()=>s,configurable:!0}),Object.defineProperty(t.prototype,"ready",{get(){return this[i]||(this[i]=new Promise(t=>{this[a]=t})),this[i]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"controller",{get(){return this[c]},set(t){const e=this[c];this[c]=t,t!==e&&t?V(this,t).catch(e=>{console.error(`Failed to attach controller "${t}":`,e)}):!t&&e&&X(this).catch(t=>{console.error("Failed to detach controller:",t)})},enumerable:!0,configurable:!0}),t.prototype.connectedCallback=async function(){this[i]||(this[i]=new Promise(t=>{this[a]=t}));try{const n=t[y];if(n)for(const[t,e]of n)if(this.hasAttribute(t)){const n=this.getAttribute(t);switch(this[v]||(this[v]=new Set),this[v].add(t),e.type){case Boolean:this[t]=null!==n&&"false"!==n;break;case Number:this[t]=Number(n);break;case String:this[t]=n;break;case Date:this[t]=n?new Date(n):null;break;case BigInt:n&&n.endsWith("n")?this[t]=BigInt(n.slice(0,-1)):this[t]=n?BigInt(n):null;break;case at:this[t]=at.parse(n);break;default:this[t]=n}}if(this[b]=!0,n)for(const[t,e]of n){const n=this[v]&&this[v].has(t),o=t in this[g];if(e.reflect&&o&&(n||void 0!==this[g][t])){const n=this[g][t],o="string"==typeof e.attribute?e.attribute:t.toLowerCase();if(null!=n&&!1!==n&&(e.type!==at||!Array.isArray(n)||0!==n.length)){let t;t=n instanceof Date?n.toISOString():"bigint"==typeof n?n.toString()+"n":e.type===at&&Array.isArray(n)?at.serialize(n):String(n),this.setAttribute(o,t)}}}k(this),this.shadowRoot||this.attachShadow({mode:"open"});let o="";if(this.html)try{const t=this.html(),e=t instanceof Promise?await t:t;void 0!==e&&(o+=e)}catch(t){console.error(`Error in html() method for ${this.tagName}:`,t)}if(this.css)try{const t=this.css(),e=t instanceof Promise?await t:t;if(e){o+=`<style data-component-css>${Array.isArray(e)?e.join("\n"):e}</style>`}}catch(t){console.error(`Error in css() method for ${this.tagName}:`,t)}o&&(this.shadowRoot.innerHTML=o);const r=t[C];if(r&&this.shadowRoot)for(const[t,e]of r)try{const n=this.shadowRoot.querySelector(`[part="${t}"]`);if(n){const t=e.method.call(this),o=t instanceof Promise?await t:t;void 0!==o&&(n.innerHTML=o)}}catch(e){console.error(`Error rendering @part('${t}') in ${this.tagName}:`,e)}e&&e.call(this);const s=this.getAttribute("controller");s&&(this.controller=s),x(this,this),W(this,this);try{M(this,this)}catch(t){console.error(`Error setting up observers for ${this.tagName}:`,t)}const i=t[O];if(i)for(const t of i)try{await t.method.call(this)}catch(e){console.error(`Error in @ready handler ${t.methodName}:`,e)}}finally{this[a]&&(this[a](),this[a]=null)}},t.prototype.disconnectedCallback=async function(){const e=t[N];if(e)for(const t of e)try{await t.method.call(this)}catch(e){console.error(`Error in @dispose handler ${t.methodName}:`,e)}n&&n.call(this),this[c]&&X(this).catch(t=>{console.error("Failed to detach controller:",t)}),k(this),Q(this),B(this)},t.prototype.attributeChangedCallback=function(e,n,r){if(o?.call(this,e,n,r),"controller"===e)this.controller=r;else{const n=t[y];if(n)for(const[o,s]of n){if(("string"==typeof s.attribute?s.attribute:o.toLowerCase())===e){const e=this[g]?.[o];let n;if(n=s.type===Boolean?null!==r&&"false"!==r:s.type===Number?Number(r):s.type===Date?r?new Date(r):null:s.type===BigInt?r&&r.endsWith("n")?BigInt(r.slice(0,-1)):r?BigInt(r):null:s.type===at?at.parse(r):"number"==typeof e&&null!==r?Number(r):r,e!==n){this[v]||(this[v]=new Set),this[v].add(o),this[g]||(this[g]={}),this[g][o]=n;const r=t[w];if(r){if(r.has(o)){const t=r.get(o);for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(r.has("*")){const t=r.get("*");for(const r of t)try{r.method.call(this,e,n,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}}break}}}}}function nt(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return et(e),customElements.define(t,e),e}}function ot(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}return et(e),customElements.define(t,e),e}}function rt(t){return function(e,n){const o=n.name;return n.metadata||(n.metadata={}),n.metadata[y]||(n.metadata[y]=new Map),n.metadata[y].set(o,t||{}),t?.reflect&&t?.type===Array&&console.warn(`⚠️ Property '${o}' uses reflect:true with Array type.`),t?.reflect&&t?.type===Object&&console.warn(`⚠️ Property '${o}' uses reflect:true with Object type.`),n.addInitializer(function(){}),function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,o)){const e={get(){return this[g]||(this[g]={}),this[g][o]},set(e){this[g]||(this[g]={}),this[v]||(this[v]=new Set);const n=this[g][o];if(n===e)return;const r=void 0===n&&!this[b];if((void 0!==n||r&&null!=e)&&this[v].add(o),this[g][o]=e,t?.reflect&&this.setAttribute&&this[b]&&this[v].has(o)){const n="string"==typeof t.attribute?t.attribute:o.toLowerCase();if(null==e||!1===e||t?.type===at&&Array.isArray(e)&&0===e.length)this.removeAttribute(n);else{let o;o=e instanceof Date?e.toISOString():"bigint"==typeof e?e.toString()+"n":t?.type===at&&Array.isArray(e)?at.serialize(e):String(e),this.setAttribute(n,o)}}const s=this.constructor[w];if(s){if(s.has(o)){const t=s.get(o);for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('${o}') method ${r.methodName}:`,t)}}if(s.has("*")){const t=s.get("*");for(const r of t)try{r.method.call(this,n,e,o)}catch(t){console.error(`Error in @watch('*') method ${r.methodName}:`,t)}}}this.requestUpdate&&this.requestUpdate(o,n)},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,o,e)}return this[g]||(this[g]={}),this[g][o]=e,e}}}function st(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this;let n=null;return i&&e.shadowRoot&&(n=e.shadowRoot.querySelector(t)),!n&&s&&(n=e.querySelector(t)),n||null},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}function it(t,e={}){return function(n,r){const{light:s=!1,shadow:i=!0}=e,a=r.name;return function(e){if(!Object.hasOwnProperty.call(this.constructor.prototype,a)){const e={get(){const e=!0===this[o]&&this.element?this.element:this,n=[];if(i&&e.shadowRoot){const o=e.shadowRoot.querySelectorAll(t);n.push(...o)}if(s){const o=e.querySelectorAll(t);n.push(...o)}return n},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,a,e)}return e}}}class at{static{this.SEPARATOR=","}static serialize(t){return Array.isArray(t)?t.map(t=>{if("string"==typeof t){if(t.includes(at.SEPARATOR))throw new Error(`SimpleArray strings cannot contain the character "${at.SEPARATOR}" (U+FF0C)`);return t}if("number"==typeof t||"boolean"==typeof t)return String(t);throw new Error("SimpleArray only supports string, number, and boolean types. Got: "+typeof t)}).join(at.SEPARATOR):""}static parse(t){return null==t||""===t?[]:t.split(at.SEPARATOR).map(t=>{if(/^-?\d+\.?\d*$/.test(t)){const e=Number(t);if(!isNaN(e))return e}return"true"===t||"false"!==t&&t})}}function ct(...t){return function(e,n){const o=n.name;n.addInitializer(function(){const n=this.constructor;n[w]||(n[w]=new Map);for(const r of t)n[w].has(r)||n[w].set(r,[]),n[w].get(r).push({methodName:o,method:e})})}}function lt(){return function(t,e){const n=e.name;return function(t){if(!Object.hasOwnProperty.call(this.constructor.prototype,n)){const t={get(){if(void 0!==this[E])return this[E];const t={target:this},e=new CustomEvent("@context/request",{bubbles:!0,cancelable:!0,detail:t});let n=!0===this[o]&&this.element?this.element:this;if(n&&n.dispatchEvent){if(n.getRootNode&&n.getRootNode()instanceof ShadowRoot){const t=n.getRootNode();n=t.host}return n.dispatchEvent(e),void 0!==t.context?(this[E]=t.context,t.context):void 0}},set(){},configurable:!0,enumerable:!0};Object.defineProperty(this.constructor.prototype,n,t)}return t}}}function ut(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[O]||(e[O]=[]),e[O].push({methodName:n,method:t})})}}function ht(){return function(t,e){const n=e.name;e.addInitializer(function(){const e=this.constructor;e[N]||(e[N]=[]),e[N].push({methodName:n,method:t})})}}function dt(t,e={}){return function(n,o){const r=o.name;return o.addInitializer(function(){const e=this.constructor;e[C]||(e[C]=new Map),e[C].set(t,{methodName:r,method:n})}),function(...o){this[I]||(this[I]=new Map),this[I].has(t)||this[I].set(t,{throttleTimer:null,debounceTimer:null,lastThrottleCall:0});const r=this[I].get(t),s=n.apply(this,o),i=e=>{if(this.shadowRoot&&void 0!==e){const n=this.shadowRoot.querySelector(`[part="${t}"]`);n&&(n.innerHTML=e)}};if(s instanceof Promise){if(void 0!==e.debounce&&e.debounce>0)return r.debounceTimer&&clearTimeout(r.debounceTimer),r.debounceTimer=setTimeout(async()=>{const t=await s;i(t)},e.debounce),s;if(void 0!==e.throttle&&e.throttle>0){const t=Date.now();if(0===r.lastThrottleCall||t-r.lastThrottleCall>=e.throttle)return r.lastThrottleCall=t,s.then(t=>(i(t),t));if(!r.throttleTimer){const n=e.throttle-(t-r.lastThrottleCall);r.throttleTimer=setTimeout(async()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now();const t=await s;i(t)},n)}return s}return s.then(t=>(i(t),t))}if(void 0!==e.debounce&&e.debounce>0)return r.debounceTimer&&clearTimeout(r.debounceTimer),r.debounceTimer=setTimeout(()=>{i(s)},e.debounce),s;if(void 0!==e.throttle&&e.throttle>0){const t=Date.now();if(0===r.lastThrottleCall||t-r.lastThrottleCall>=e.throttle)r.lastThrottleCall=t,i(s);else if(!r.throttleTimer){const n=e.throttle-(t-r.lastThrottleCall);r.throttleTimer=setTimeout(()=>{r.throttleTimer=null,r.lastThrottleCall=Date.now(),i(s)},n)}return s}return i(s),s}}}
8
8
  /*!
9
9
  * pica-route v1.1.2
10
10
  * A pure URL pattern matching library compatible with route-parser API
11
11
  * (c) 2024
12
12
  * Released under the MIT License.
13
- */at.SEPARATOR=",";class ft{constructor(t){this.parsed=this.parsePattern(t)}get spec(){return this.parsed.template}parsePattern(t){let e=t,n="",o=!1;const r=t.indexOf("?");return-1!==r&&(e=t.slice(0,r),n=t.slice(r+1),e.endsWith("(")&&n.endsWith(")")&&(o=!0,e=e.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(e),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:t}}parseSegments(t){const e=[];let n=0;for(;n<t.length;){switch(t[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(t,n);e.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(t,n+1);e.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:l}=this.parseIdentifier(t,n+1);e.push({type:"splat",name:a}),n=l;break;default:const{value:c,endIndex:u}=this.parseLiteral(t,n);c&&e.push({type:"literal",value:c}),n=u}}return e}parseOptionalGroup(t,e){let n=1,o=e+1;for(;o<t.length&&n>0;)"("===t[o]&&n++,")"===t[o]&&n--,o++;const r=t.slice(e+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(t,e){let n=e;for(;n<t.length&&/[\w-]/.test(t[n]);)n++;return{name:t.slice(e,n),endIndex:n}}parseLiteral(t,e){let n=e;for(;n<t.length&&!"(:*(".includes(t[n]);)n++;return{value:t.slice(e,n),endIndex:n}}parseQuerySegments(t){let e=t;e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1));const n=[];let o=0;for(;o<e.length;)if(":"===e[o]){const{name:t,endIndex:r}=this.parseIdentifier(e,o+1);n.push({type:"param",name:t}),o=r}else{const{value:t,endIndex:r}=this.parseQueryLiteral(e,o);t&&n.push({type:"literal",value:t}),o=r}return n}parseQueryLiteral(t,e){let n=e;for(;n<t.length&&":"!==t[n];)n++;return{value:t.slice(e,n),endIndex:n}}getAllParamNames(){const t=new Set,e=n=>{for(const o of n)switch(o.type){case"param":case"splat":t.add(o.name);break;case"optional":e(o.segments)}};return e(this.parsed.pathSegments),e(this.parsed.querySegments),Array.from(t)}canMatchRemainingSegments(t,e,n){let o=e;for(const e of n)if("literal"===e.type){const n=t.indexOf(e.value,o);if(-1===n)return!1;o=n+e.value.length}return!0}match(t){const[e,n]=t.split("?"),o=this.matchPath(e,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 t of s)i[t]=void 0;return Object.assign(i,o,r),i}matchPath(t,e){const n={};let o=0;for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1),a=this.matchSegment(t,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<t.length)&&n}matchSegment(t,e,n,o=[]){switch(n.type){case"literal":return t.slice(e,e+n.value.length)===n.value&&{params:{},nextIndex:e+n.value.length};case"param":{let r=e;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=s.value,o=t.indexOf(n,e);if(-1===o)return!1;r=o}else for(;r<t.length&&!a.includes(t[r]);)r++;if(r===e)return!1;try{i=decodeURIComponent(t.slice(e,r))}catch(n){i=t.slice(e,r)}return!(r<t.length&&"?"===t[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=t.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=t.indexOf(".",e);-1!==n&&(r=n)}else{const n=t.lastIndexOf(s.value);-1!==n&&n>=e&&(r=n)}break;case"param":let n=-1;for(let o=t.length-1;o>=e;o--)if("/"===t[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=t.length-1;n>e;n--)if("/"===t[n]){o=n+1;break}if(-1!==o)r=o;else{const n=t.slice(e).split("/").filter(t=>t);r=n.length>1?e+n.slice(0,-1).join("/").length+1:e}break;case"optional":const i=t=>{for(const e of t){if("literal"===e.type)return e.value;if("optional"===e.type){const t=i(e.segments);if(t)return t}}return null},a=i(s.segments);if(a){const n=t.lastIndexOf(a);-1!==n&&n>=e&&(r=n)}}const i=t.indexOf("?",e);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(t.slice(e,r))}catch(n){a=t.slice(e,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=e,s={},i=!0;for(let e=0;e<n.segments.length;e++){const o=n.segments[e],a=n.segments.slice(e+1),l=this.matchSegment(t,r,o,a);if(!1===l){i=!1;break}Object.assign(s,l.params),r=l.nextIndex}if(i){if(this.canMatchRemainingSegments(t,r,o))return{params:s,nextIndex:r}}return{params:{},nextIndex:e}}default:return!1}}findNextLiteral(t){for(const e of t){if("literal"===e.type)return e;if("optional"===e.type){const t=this.findNextLiteral(e.segments);if(t)return t}}return null}matchQuery(t,e){if(0===e.length)return{};const n={};let o=0;for(const r of e)switch(r.type){case"literal":if(t.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let e,s=o;for(;s<t.length&&"&"!==t[s];)s++;if(s===o)return!1;try{e=decodeURIComponent(t.slice(o,s))}catch(n){e=t.slice(o,s)}n[r.name]=e,o=s;break}}return n}reverse(t={}){const e=this.reverseSegments(this.parsed.pathSegments,t);if(!1===e)return!1;let n=e;if(this.parsed.querySegments.length>0){const e=this.reverseSegments(this.parsed.querySegments,t);if(!this.parsed.queryOptional&&!1===e)return!1;e&&""!==e&&(n+="?"+e)}return n}reverseSegments(t,e,n=!1){let o="";for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in e))return!1;o+=String(e[s.name]);break;case"optional":if(this.hasAllParams(s.segments,e,n)||this.hasLaterOptionalGroupNeedingParams(i,e,s.segments)){const t=this.reverseSegments(s.segments,e,!0);if(!1===t)return!1;o+=t}}}return o}hasLaterOptionalGroupNeedingParams(t,e,n){for(const o of t)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,e))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(t){for(const e of t)if("param"===e.type||"splat"===e.type)return!1;return!0}hasAllParams(t,e,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of t)switch(n.type){case"param":case"splat":i=!1,n.name in e&&void 0!==e[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of t)if("optional"===n.type){this.hasAllParams(n.segments,e,a)&&(r=!0)}return!(!o||s)||(!(!r||s)||!(!i||!n))}hasOnlyOptionalMissingParams(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(!(n.name in e))return!1}return!0}hasAnyParamInSegments(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(n.name in e)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,e))return!0}return!1}}function pt(t){const e={};return t.split(";").forEach(t=>{const[n,o]=t.split(":").map(t=>t.trim());n&&o&&(e[n]=o)}),e}var mt;function yt(t){const e=[];let n,o,r,s=!1,i=null,a=null;const l=t.context||{};function c(t){if(!i||!a)return null;const e=t.querySelectorAll(i);for(const t of e){if(t[O]===a)return t}return null}function u(t,i,a,l,c){e.push({route:new ft(t),tag:i,transition:a,guards:l,layout:c}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function h(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}async function d(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[E]=l),!n){const t=document.createElement("div");t.className="default-403",t.innerHTML="<h1>403</h1><p>Unauthorized</p>",e=t}t.innerHTML="",t.appendChild(e),i=null,a=null}async function f(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!await t(l,e))return await d(n),!1}return!0}function p(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function m(t){if(!(t!==i))return{element:null,needsNewLayout:!1};i=t;if(!!t){const e=Date.now();a=e;const n=document.createElement(t);return n[E]=l,n[O]=e,{element:n,needsNewLayout:!0}}return a=null,{element:null,needsNewLayout:!0}}async function y(t,e,n,o,r){const s=o||c(t);if(!s)return;const i=s.querySelector('[slot="page"]');if(!(!n||!i))return e.setAttribute("slot","page"),await v(s,i,e,n),void(r&&(t.innerHTML="",t.appendChild(s)));s.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),s.appendChild(e),r&&(t.innerHTML="",t.appendChild(s))}async function g(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await v(t,o,e,n)}async function b(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);window.scrollTo(0,0);if((""===o.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!await f(n?.guards,{},s))return;const{element:o,transition:i,layout:a}=function(){const t=document.createElement(r);t[E]=l;const n=customElements.get(r),o=n?.[A],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=p(a),{element:h,needsNewLayout:d}=m(u),b=i||t.transition;return null!==h||null!==c(s)?void await y(s,o,b,h,d):void await g(s,o,b)}const i=await async function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!await f(o.guards,e,n))return{result:mt.GUARDS_FAILED};const r=document.createElement(o.tag);r[E]=l;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:mt.SUCCESS,element:r,transition:o.transition,layout:o.layout}}return{result:mt.NOT_FOUND}}(o,s);if(i.result===mt.GUARDS_FAILED)return;if(i.result===mt.SUCCESS){const{element:e,transition:n,layout:o}=i,r=p(o),{element:a,needsNewLayout:l}=m(r),u=n||t.transition;return null!==a||null!==c(s)?void await y(s,e,u,a,l):void await g(s,e,u)}const{element:a,transition:u,layout:h}=function(){if(n){const t=document.createElement(n);t[E]=l;const e=customElements.get(n),o=e?.[A];return{element:t,transition:o,layout:void 0}}const t=document.createElement("div");return t.className="default-404",t.innerHTML="<h1>404</h1><p>Page not found</p>",{element:t,transition:void 0,layout:void 0}}(),d=p(h),{element:b,needsNewLayout:v}=m(d),w=u||t.transition;null!==b||null!==c(s)?await y(s,a,w,b,v):await g(s,a,w)}async function v(t,e,n,o){return async function(t,e,n,o={}){const r=o.outDuration||300,s=o.inDuration||300,i=o.mode||"sequential",a=o.out?pt(o.out):{opacity:"0"},l={opacity:"0"},c=o.in?pt(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const f=e.hasAttribute("slot")||n.hasAttribute("slot");f?(e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.transition=`opacity ${r}ms ease-in-out`,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.transition=`opacity ${s}ms ease-in-out`):(e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.transition=`all ${r}ms ease-in-out`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%"),Object.assign(n.style,l),n.style.transition=`all ${s}ms ease-in-out`,t.appendChild(n),n.offsetHeight,"simultaneous"===i?(Object.assign(e.style,a),Object.assign(n.style,c),await new Promise(t=>setTimeout(t,Math.max(r,s)))):(Object.assign(e.style,a),await new Promise(t=>setTimeout(t,r)),Object.assign(n.style,c),await new Promise(t=>setTimeout(t,s))),e.remove(),f?(n.style.position="",n.style.width="",n.style.height="",n.style.transition=""):(n.style.position="",n.style.top="",n.style.left="",n.style.width="",n.style.transition=""),Object.keys({...l,...c}).forEach(t=>{n.style[t]=""}),d||(u.position=h)}(t,e,n,o)}return{page:function(t){return function(e){et(e),e[A]=t.transition;const n=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){n?.call(this);const t=t=>{void 0!==this[E]&&(t.detail.context=this[E],t.stopPropagation())};this.addEventListener("@context/request",t),this[S]=t};const o=e.prototype.disconnectedCallback;e.prototype.disconnectedCallback=function(){o?.call(this);const t=this[S];t&&(this.removeEventListener("@context/request",t),delete this[S]),delete this[E]},customElements.define(t.tag,e),t.routes.forEach(e=>u(e,t.tag,t.transition,t.guards,t.layout))}},initialize:function(){if(!!!document.querySelector(t.target))throw new Error(`Target element not found: ${t.target}`);!s&&(e.sort((t,e)=>e.route.spec.length-t.route.spec.length),s=!0),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&b(h())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&b(h())})}(),b(h())},navigate:b,register:u,context:l}}!function(t){t.SUCCESS="success",t.GUARDS_FAILED="guards-failed",t.NOT_FOUND="not-found"}(mt||(mt={}));export{o as IS_CONTROLLER_INSTANCE,yt as Router,at as SimpleArray,et as applyElementFunctionality,V as attachController,tt as cleanupNativeElementControllers,ct as context,J as controller,X as detachController,R as dispatch,ht as dispose,nt as element,Y as getController,e as getSymbol,ot as layout,D as observe,C as on,dt as part,rt as property,st as query,it as queryAll,ut as ready,G as request,K as respond,Z as useNativeElementControllers,lt as watch};
13
+ */class pt{constructor(t){this.parsed=this.parsePattern(t)}get spec(){return this.parsed.template}parsePattern(t){let e=t,n="",o=!1;const r=t.indexOf("?");return-1!==r&&(e=t.slice(0,r),n=t.slice(r+1),e.endsWith("(")&&n.endsWith(")")&&(o=!0,e=e.slice(0,-1),n=n.slice(0,-1))),{pathSegments:this.parseSegments(e),querySegments:n?this.parseQuerySegments(n):[],queryOptional:o,template:t}}parseSegments(t){const e=[];let n=0;for(;n<t.length;){switch(t[n]){case"(":const{segments:o,endIndex:r}=this.parseOptionalGroup(t,n);e.push({type:"optional",segments:o}),n=r+1;break;case":":const{name:s,endIndex:i}=this.parseIdentifier(t,n+1);e.push({type:"param",name:s}),n=i;break;case"*":const{name:a,endIndex:c}=this.parseIdentifier(t,n+1);e.push({type:"splat",name:a}),n=c;break;default:const{value:l,endIndex:u}=this.parseLiteral(t,n);l&&e.push({type:"literal",value:l}),n=u}}return e}parseOptionalGroup(t,e){let n=1,o=e+1;for(;o<t.length&&n>0;)"("===t[o]&&n++,")"===t[o]&&n--,o++;const r=t.slice(e+1,o-1);return{segments:this.parseSegments(r),endIndex:o-1}}parseIdentifier(t,e){let n=e;for(;n<t.length&&/[\w-]/.test(t[n]);)n++;return{name:t.slice(e,n),endIndex:n}}parseLiteral(t,e){let n=e;for(;n<t.length&&!"(:*(".includes(t[n]);)n++;return{value:t.slice(e,n),endIndex:n}}parseQuerySegments(t){let e=t;e.startsWith("(")&&e.endsWith(")")&&(e=e.slice(1,-1));const n=[];let o=0;for(;o<e.length;)if(":"===e[o]){const{name:t,endIndex:r}=this.parseIdentifier(e,o+1);n.push({type:"param",name:t}),o=r}else{const{value:t,endIndex:r}=this.parseQueryLiteral(e,o);t&&n.push({type:"literal",value:t}),o=r}return n}parseQueryLiteral(t,e){let n=e;for(;n<t.length&&":"!==t[n];)n++;return{value:t.slice(e,n),endIndex:n}}getAllParamNames(){const t=new Set,e=n=>{for(const o of n)switch(o.type){case"param":case"splat":t.add(o.name);break;case"optional":e(o.segments)}};return e(this.parsed.pathSegments),e(this.parsed.querySegments),Array.from(t)}canMatchRemainingSegments(t,e,n){let o=e;for(const e of n)if("literal"===e.type){const n=t.indexOf(e.value,o);if(-1===n)return!1;o=n+e.value.length}return!0}match(t){const[e,n]=t.split("?"),o=this.matchPath(e,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 t of s)i[t]=void 0;return Object.assign(i,o,r),i}matchPath(t,e){const n={};let o=0;for(let r=0;r<e.length;r++){const s=e[r],i=e.slice(r+1),a=this.matchSegment(t,o,s,i);if(!1===a)return!1;Object.assign(n,a.params),o=a.nextIndex}return!(o<t.length)&&n}matchSegment(t,e,n,o=[]){switch(n.type){case"literal":return t.slice(e,e+n.value.length)===n.value&&{params:{},nextIndex:e+n.value.length};case"param":{let r=e;const s=o[0];let i,a=["/","?"];if(s&&"literal"===s.type){const n=s.value,o=t.indexOf(n,e);if(-1===o)return!1;r=o}else for(;r<t.length&&!a.includes(t[r]);)r++;if(r===e)return!1;try{i=decodeURIComponent(t.slice(e,r))}catch(n){i=t.slice(e,r)}return!(r<t.length&&"?"===t[r]&&o.length>0)&&{params:{[n.name]:i},nextIndex:r}}case"splat":{let r=t.length;const s=o[0];if(s)switch(s.type){case"literal":if("."===s.value){const n=t.indexOf(".",e);-1!==n&&(r=n)}else{const n=t.lastIndexOf(s.value);-1!==n&&n>=e&&(r=n)}break;case"param":let n=-1;for(let o=t.length-1;o>=e;o--)if("/"===t[o]){n=o;break}-1!==n&&(r=n);break;case"splat":let o=-1;for(let n=t.length-1;n>e;n--)if("/"===t[n]){o=n+1;break}if(-1!==o)r=o;else{const n=t.slice(e).split("/").filter(t=>t);r=n.length>1?e+n.slice(0,-1).join("/").length+1:e}break;case"optional":const i=t=>{for(const e of t){if("literal"===e.type)return e.value;if("optional"===e.type){const t=i(e.segments);if(t)return t}}return null},a=i(s.segments);if(a){const n=t.lastIndexOf(a);-1!==n&&n>=e&&(r=n)}}const i=t.indexOf("?",e);let a;-1!==i&&i<r&&(r=i);try{a=decodeURIComponent(t.slice(e,r))}catch(n){a=t.slice(e,r)}return{params:{[n.name]:a},nextIndex:r}}case"optional":{let r=e,s={},i=!0;for(let e=0;e<n.segments.length;e++){const o=n.segments[e],a=n.segments.slice(e+1),c=this.matchSegment(t,r,o,a);if(!1===c){i=!1;break}Object.assign(s,c.params),r=c.nextIndex}if(i){if(this.canMatchRemainingSegments(t,r,o))return{params:s,nextIndex:r}}return{params:{},nextIndex:e}}default:return!1}}findNextLiteral(t){for(const e of t){if("literal"===e.type)return e;if("optional"===e.type){const t=this.findNextLiteral(e.segments);if(t)return t}}return null}matchQuery(t,e){if(0===e.length)return{};const n={};let o=0;for(const r of e)switch(r.type){case"literal":if(t.slice(o,o+r.value.length)!==r.value)return!1;o+=r.value.length;break;case"param":{let e,s=o;for(;s<t.length&&"&"!==t[s];)s++;if(s===o)return!1;try{e=decodeURIComponent(t.slice(o,s))}catch(n){e=t.slice(o,s)}n[r.name]=e,o=s;break}}return n}reverse(t={}){const e=this.reverseSegments(this.parsed.pathSegments,t);if(!1===e)return!1;let n=e;if(this.parsed.querySegments.length>0){const e=this.reverseSegments(this.parsed.querySegments,t);if(!this.parsed.queryOptional&&!1===e)return!1;e&&""!==e&&(n+="?"+e)}return n}reverseSegments(t,e,n=!1){let o="";for(let r=0;r<t.length;r++){const s=t[r],i=t.slice(r+1);switch(s.type){case"literal":o+=s.value;break;case"param":case"splat":if(!(s.name in e))return!1;o+=String(e[s.name]);break;case"optional":if(this.hasAllParams(s.segments,e,n)||this.hasLaterOptionalGroupNeedingParams(i,e,s.segments)){const t=this.reverseSegments(s.segments,e,!0);if(!1===t)return!1;o+=t}}}return o}hasLaterOptionalGroupNeedingParams(t,e,n){for(const o of t)if("optional"===o.type&&this.hasAnyParamInSegments(o.segments,e))return this.hasOnlyLiteralsAndOptionals(n);return!1}hasOnlyLiteralsAndOptionals(t){for(const e of t)if("param"===e.type||"splat"===e.type)return!1;return!0}hasAllParams(t,e,n=!1){let o=!1,r=!1,s=!1,i=!0;for(const n of t)switch(n.type){case"param":case"splat":i=!1,n.name in e&&void 0!==e[n.name]?o=!0:s=!0}const a=n||o&&!s;for(const n of t)if("optional"===n.type){this.hasAllParams(n.segments,e,a)&&(r=!0)}return!(!o||s)||(!(!r||s)||!(!i||!n))}hasOnlyOptionalMissingParams(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(!(n.name in e))return!1}return!0}hasAnyParamInSegments(t,e){for(const n of t)switch(n.type){case"param":case"splat":if(n.name in e)return!0;break;case"optional":if(this.hasAnyParamInSegments(n.segments,e))return!0}return!1}}function ft(t){const e={};return t.split(";").forEach(t=>{const[n,o]=t.split(":").map(t=>t.trim());n&&o&&(e[n]=o)}),e}var mt;function yt(t){const e=[];let n,o,r,s=!1,i=null,a=null;const c=t.context||{};function l(t){if(!i||!a)return null;const e=t.querySelectorAll(i);for(const t of e){if(t[A]===a)return t}return null}function u(t,i,a,c,l){e.push({route:new pt(t),tag:i,transition:a,guards:c,layout:l}),s=!1,"/404"===t&&(n=i),"/403"===t&&(o=i),"/"===t&&(r=i)}function h(){switch(t.type){case"hash":return window.location.hash.slice(1);case"pushstate":return window.location.pathname}}async function d(t){let e;const n=!!o;if(n&&(e=document.createElement(o),e[E]=c),!n){const t=document.createElement("div");t.className="default-403",t.innerHTML="<h1>403</h1><p>Unauthorized</p>",e=t}t.innerHTML="",t.appendChild(e),i=null,a=null}async function p(t,e,n){if(!!!t)return!0;const o=Array.isArray(t)?t:[t];for(const t of o){if(!await t(c,e))return await d(n),!1}return!0}function f(e){if(!1===e)return null;if(!!e)return e;return!!t.layout?t.layout:null}function m(t){if(!(t!==i))return{element:null,needsNewLayout:!1};i=t;if(!!t){const e=Date.now();a=e;const n=document.createElement(t);return n[E]=c,n[A]=e,{element:n,needsNewLayout:!0}}return a=null,{element:null,needsNewLayout:!0}}async function g(t,e,n,o,r){const s=o||l(t);if(!s)return;const i=s.querySelector('[slot="page"]');if(!(!n||!i))return e.setAttribute("slot","page"),await v(s,i,e,n),void(r&&(t.innerHTML="",t.appendChild(s)));s.querySelectorAll('[slot="page"]').forEach(t=>t.remove()),e.setAttribute("slot","page"),s.appendChild(e),r&&(t.innerHTML="",t.appendChild(s))}async function b(t,e,n){const o=t.children[0];!n||!o?(t.innerHTML="",t.appendChild(e)):await v(t,o,e,n)}async function w(o){const s=document.querySelector(t.target);if(!s)throw new Error(`Target element not found: ${t.target}`);window.scrollTo(0,0);if((""===o.trim()||"/"===o)&&!!r){const n=e.find(t=>t.route.match("/"));if(!await p(n?.guards,{},s))return;const{element:o,transition:i,layout:a}=function(){const t=document.createElement(r);t[E]=c;const n=customElements.get(r),o=n?.[T],s=e.find(t=>t.route.match("/"));return{element:t,transition:o,layout:s?.layout}}(),u=f(a),{element:h,needsNewLayout:d}=m(u),y=i||t.transition;return null!==h||null!==l(s)?void await g(s,o,y,h,d):void await b(s,o,y)}const i=await async function(t,n){for(const o of e){const e=o.route.match(t);if(!1===e)continue;if(!await p(o.guards,e,n))return{result:mt.GUARDS_FAILED};const r=document.createElement(o.tag);r[E]=c;const s=e;return Object.keys(s).forEach(t=>r.setAttribute(t,s[t])),{result:mt.SUCCESS,element:r,transition:o.transition,layout:o.layout}}return{result:mt.NOT_FOUND}}(o,s);if(i.result===mt.GUARDS_FAILED)return;if(i.result===mt.SUCCESS){const{element:e,transition:n,layout:o}=i,r=f(o),{element:a,needsNewLayout:c}=m(r),u=n||t.transition;return null!==a||null!==l(s)?void await g(s,e,u,a,c):void await b(s,e,u)}const{element:a,transition:u,layout:h}=function(){if(n){const t=document.createElement(n);t[E]=c;const e=customElements.get(n),o=e?.[T];return{element:t,transition:o,layout:void 0}}const t=document.createElement("div");return t.className="default-404",t.innerHTML="<h1>404</h1><p>Page not found</p>",{element:t,transition:void 0,layout:void 0}}(),d=f(h),{element:y,needsNewLayout:w}=m(d),v=u||t.transition;null!==y||null!==l(s)?await g(s,a,v,y,w):await b(s,a,v)}async function v(t,e,n,o){return async function(t,e,n,o={}){const r=o.outDuration||300,s=o.inDuration||300,i=o.mode||"sequential",a=o.out?ft(o.out):{opacity:"0"},c={opacity:"0"},l=o.in?ft(o.in):{opacity:"1"},u=t.style,h=u.position,d=t.tagName.includes("-")&&t.shadowRoot;d||(u.position="relative");const p=e.hasAttribute("slot")||n.hasAttribute("slot");p?(e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.transition=`opacity ${r}ms ease-in-out`,n.style.position="absolute",n.style.width="100%",n.style.height="100%",n.style.transition=`opacity ${s}ms ease-in-out`):(e.style.position="absolute",e.style.top="0",e.style.left="0",e.style.width="100%",e.style.transition=`all ${r}ms ease-in-out`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.width="100%"),Object.assign(n.style,c),n.style.transition=`all ${s}ms ease-in-out`,t.appendChild(n),n.offsetHeight,"simultaneous"===i?(Object.assign(e.style,a),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,Math.max(r,s)))):(Object.assign(e.style,a),await new Promise(t=>setTimeout(t,r)),Object.assign(n.style,l),await new Promise(t=>setTimeout(t,s))),e.remove(),p?(n.style.position="",n.style.width="",n.style.height="",n.style.transition=""):(n.style.position="",n.style.top="",n.style.left="",n.style.width="",n.style.transition=""),Object.keys({...c,...l}).forEach(t=>{n.style[t]=""}),d||(u.position=h)}(t,e,n,o)}return{page:function(t){return function(e,n){if(n.metadata&&n.metadata[y]){e[y]||(e[y]=new Map);for(const[t,o]of n.metadata[y])e[y].set(t,o)}et(e),e[T]=t.transition;const o=e.prototype.connectedCallback;e.prototype.connectedCallback=function(){o?.call(this);const t=t=>{void 0!==this[E]&&(t.detail.context=this[E],t.stopPropagation())};this.addEventListener("@context/request",t),this[S]=t};const r=e.prototype.disconnectedCallback;return e.prototype.disconnectedCallback=function(){r?.call(this);const t=this[S];t&&(this.removeEventListener("@context/request",t),delete this[S]),delete this[E]},customElements.define(t.tag,e),t.routes.forEach(e=>u(e,t.tag,t.transition,t.guards,t.layout)),e}},initialize:function(){if(!!!document.querySelector(t.target))throw new Error(`Target element not found: ${t.target}`);!s&&(e.sort((t,e)=>e.route.spec.length-t.route.spec.length),s=!0),function(){const e="hash"===t.type,n="pushstate"===t.type;e&&window.addEventListener("hashchange",()=>{document.querySelector(t.target)&&w(h())}),n&&window.addEventListener("popstate",()=>{document.querySelector(t.target)&&w(h())})}(),w(h())},navigate:w,register:u,context:c}}!function(t){t.SUCCESS="success",t.GUARDS_FAILED="guards-failed",t.NOT_FOUND="not-found"}(mt||(mt={}));export{o as IS_CONTROLLER_INSTANCE,yt as Router,at as SimpleArray,et as applyElementFunctionality,V as attachController,tt as cleanupNativeElementControllers,lt as context,J as controller,X as detachController,R as dispatch,ht as dispose,nt as element,Y as getController,e as getSymbol,ot as layout,D as observe,L as on,dt as part,rt as property,st as query,it as queryAll,ut as ready,G as request,K as respond,Z as useNativeElementControllers,ct as watch};
14
14
  //# sourceMappingURL=index.esm.min.js.map