vanilla-jui 1.4.1 → 1.4.2

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 (44) hide show
  1. package/dist/index.d.ts +7 -14
  2. package/dist/index.js +1 -1
  3. package/dist/index.umd.js +1 -1
  4. package/dist/style.css +1 -1
  5. package/package.json +1 -1
  6. package/src/components/accordion.ts +7 -10
  7. package/src/components/drop.ts +5 -15
  8. package/src/components/parabola.ts +2 -2
  9. package/src/components/tabs.ts +5 -25
  10. package/src/components/theme.ts +25 -22
  11. package/src/components/toast.ts +34 -19
  12. package/src/components/tooltip.ts +3 -9
  13. package/src/core/Component.ts +1 -1
  14. package/src/css/accordion.css +1 -1
  15. package/src/css/components.css +1 -0
  16. package/src/css/content.css +147 -151
  17. package/src/css/drop.css +1 -1
  18. package/src/css/editor.css +16 -0
  19. package/src/css/form.css +27 -14
  20. package/src/css/icon.css +3 -3
  21. package/src/css/index.css +2 -2
  22. package/src/css/layout.css +2 -2
  23. package/src/css/loading.css +77 -29
  24. package/src/css/menu.css +29 -32
  25. package/src/css/pagination.css +4 -4
  26. package/src/css/status.css +2 -1
  27. package/src/css/table.css +20 -20
  28. package/src/css/tabs.css +2 -2
  29. package/src/css/theme-palette.css +10 -17
  30. package/src/css/themes/default/accordion.css +4 -4
  31. package/src/css/themes/default/avatar.css +17 -1
  32. package/src/css/themes/default/content.css +59 -0
  33. package/src/css/themes/default/editor.css +10 -0
  34. package/src/css/themes/default/index.css +8 -1
  35. package/src/css/themes/default/loading.css +16 -16
  36. package/src/css/themes/default/menu.css +15 -0
  37. package/src/css/themes/default/pagination.css +8 -0
  38. package/src/css/themes/default/table.css +18 -0
  39. package/src/css/themes/default/tabs.css +2 -2
  40. package/src/css/themes/default/theme-palette.css +12 -0
  41. package/src/css/themes/default/toolbar.css +34 -0
  42. package/src/css/toast.css +11 -9
  43. package/src/css/toolbar.css +29 -48
  44. package/src/locales/index.ts +3 -3
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vanilla-signal"),require("vanilla-signal-i18n")):typeof define==`function`&&define.amd?define([`exports`,`vanilla-signal`,`vanilla-signal-i18n`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.jui={},e.vanillaSignal,e.vanillaSignalI18n))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(){if(typeof window>`u`||typeof navigator>`u`)return!1;if(navigator.userAgentData&&typeof navigator.userAgentData.mobile==`boolean`)return navigator.userAgentData.mobile;let e=navigator.userAgent||navigator.vendor||window.opera||``,t=/Android|iPhone|iPad|iPod|Mobile|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e),n=/iPad|Android(?!.*Mobile)|Tablet/i.test(e);if(t&&!n){if(/iPhone|iPod|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e))return!0;if(/Android/i.test(e)){let e=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window;return Math.min(window.screen.width,window.screen.height)<=768||e}}if(/Macintosh|MacIntel/i.test(e)){let e=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window,t=Math.min(window.screen.width,window.screen.height);return e&&t<=768}return!1}async function i(e){if(typeof window>`u`||typeof document>`u`)return Promise.resolve(!1);let t=String(e);if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(t),!0}catch{return a(t)}return a(t)}function a(e){let t=null;try{return t=document.createElement(`textarea`),t.value=e,t.setAttribute(`readonly`,``),t.style.position=`absolute`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length),document.execCommand(`copy`)}catch{return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}}let o=(()=>{let e=new Map;return{get(t,n){return e.has(t)||e.set(t,n()),e.get(t)},destroy(t){let n=e.get(t);n&&(typeof n.destroy==`function`&&n.destroy(),e.delete(t))},destroyAll(){for(let t of e.values())typeof t.destroy==`function`&&t.destroy();e.clear()}}})(),s=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c=e=>Array.from(new Set(e.filter(Boolean))),l={timers:{},start(e,t,n){this.timers[e]&&clearTimeout(this.timers[e]),this.timers[e]=setTimeout(()=>{n(),delete this.timers[e]},t)},cancel(e){this.timers[e]&&(clearTimeout(this.timers[e]),delete this.timers[e])}},u=e=>e===null?`null`:Array.isArray(e)?`array`:typeof HTMLElement<`u`&&e instanceof HTMLElement?`HTMLElement`:typeof Node<`u`&&e instanceof Node?`Node`:typeof e,d=e=>typeof e==`function`&&s(e,`prototype`)&&e.prototype!==null&&typeof e.prototype==`object`&&s(e.prototype,`constructor`)&&e.prototype.constructor===e,f=e=>typeof e==`function`&&/^class\s/.test(Function.prototype.toString.call(e));function p(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function m(e){return Array.isArray(e)?e.slice():p(e)?{...e}:e}function h(e={}){return typeof e==`string`||Array.isArray(e)?{type:e}:!e||typeof e!=`object`?{}:e}function ee(e,t,n=[]){let r=Array.isArray(n)?n:n?[n]:[];for(let n of r){let r,i;if(typeof n==`function`)r=n,i=`does not satisfy the required condition.`;else if(n&&typeof n.test==`function`)r=n.test,i=n.message||`condition failed.`;else throw Error(`Validator: Condition must be a function or { test, message }.`);if(!r(t))throw Error(`Validator: ${e} ${i}`)}}function te(e,t){return e?`${e}.${t}`:t}function g(e,t,n={},r=``){let i=h(n),a=te(r,e),o=s(i,`types`)?i.types:i.type;if(i.required&&t==null)throw Error(`Validator: ${a} is required.`);if(o!==void 0){let e=Array.isArray(o)?o:[o],n=u(t);if(!e.some(e=>e===n)){let t=e.join(`, `);throw Error(`Validator: ${a} expects ${t}, but got ${n}.`)}ee(a,t,i.conditions)}else ee(a,t,i.conditions);if(Array.isArray(i.enum)&&!i.enum.includes(t))throw Error(`Validator: ${a} expects one of ${i.enum.join(`, `)}.`);if(typeof i.validate==`function`&&!i.validate(t))throw Error(`Validator: ${a} ${i.message||`does not satisfy the required condition.`}`);return t}function _(e={},t={},n=`Options`){let r=e??{};if(typeof r!=`object`||Array.isArray(r))throw Error(`${n} expects object.`);let i=r,a={...i},o=Object.entries(t||{});for(let[e,t]of o){let n=h(t);a[e]=s(r,e)?r[e]:ie(n)}for(let[e,n]of o){let r=h(n);typeof r.normalize==`function`&&(a[e]=r.normalize(a[e],{key:e,input:i,options:a,schema:t}))}for(let[e,t]of o)g(e,a[e],t,n);return a}function ne(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto.getRandomValues!=`function`)throw Error(`Your browser is too old to support secure login.`);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20,32)].join(`-`)}function v(e=8){if(!Number.isInteger(e)||e<1||e>87381)throw Error(`Length must be an integer between 1 and 87381`);let t=Math.ceil(e*3/4),n=new Uint8Array(t);crypto.getRandomValues(n);let r=``;for(let e of n)r+=String.fromCharCode(e);return btoa(r).substring(0,e).replace(/\+/g,`-`).replace(/\//g,`_`)}function re(e,t=0,n={}){if(typeof e!=`function`)throw TypeError(`Expected a function`);let r=Number(t)||0,i=n&&typeof n==`object`?n:{},a=!!i.leading,o=!s(i,`trailing`)||!!i.trailing,c=s(i,`maxWait`),l=c?Math.max(Number(i.maxWait)||0,r):0,u,d,f,p,m=0;function h(t){let n=u;return n?(u=void 0,m=t,d=Reflect.apply(e,n.receiver,n.args),d):d}function ee(e){return m=e,f=setTimeout(_,r),a?h(e):d}function te(e){let t=e-(p||0),n=e-m,i=r-t;return c?Math.min(i,l-n):i}function g(e){let t=e-(p||0),n=e-m;return p===void 0||t>=r||t<0||c&&n>=l}function _(){let e=Date.now();if(g(e))return ne(e);f=setTimeout(_,te(e))}function ne(e){return f=void 0,o&&u?h(e):(u=void 0,d)}function v(){f!==void 0&&clearTimeout(f),m=0,p=void 0,f=void 0,u=void 0}function re(){return f===void 0?d:ne(Date.now())}function y(...e){let t=Date.now(),n=g(t);if(u={receiver:this,args:e},p=t,n){if(f===void 0)return ee(p);if(c)return f=setTimeout(_,r),h(p)}return f===void 0&&(f=setTimeout(_,r)),d}return y.cancel=v,y.flush=re,y}function y(e,t=0,n={}){if(typeof e!=`function`)throw TypeError(`Expected a function`);let r=n&&typeof n==`object`?n:{};return re(e,t,{leading:!s(r,`leading`)||!!r.leading,trailing:!s(r,`trailing`)||!!r.trailing,maxWait:t})}function ie(e){if(!s(e,`default`))return;let t=e.default;return m(e.factory&&typeof t==`function`?t():t)}var ae={info:`<path d="M12 22C6.47715 22 2 17.5228 2 12 2 6.47715 6.47715 2 12 2 17.5228 2 22 6.47715 22 12 22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 10.5V15H14V17H10V15H11V12.5H10V10.5H13ZM13.5 8C13.5 8.82843 12.8284 9.5 12 9.5 11.1716 9.5 10.5 8.82843 10.5 8 10.5 7.17157 11.1716 6.5 12 6.5 12.8284 6.5 13.5 7.17157 13.5 8Z"></path>`,success:`<path d="M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM17.4571 9.45711L16.0429 8.04289L11 13.0858L8.20711 10.2929L6.79289 11.7071L11 15.9142L17.4571 9.45711Z"></path>`,warning:`<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM11 7H13V13H11V7Z"></path>`,error:`<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 10.5858L14.8284 7.75736L16.2426 9.17157L13.4142 12L16.2426 14.8284L14.8284 16.2426L12 13.4142L9.17157 16.2426L7.75736 14.8284L10.5858 12L7.75736 9.17157L9.17157 7.75736L12 10.5858Z"></path>`,"arrow-left":`<path d="M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z"></path>`,"arrow-right":`<path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path>`,"arrow-up":`<path d="M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z"></path>`,"arrow-down":`<path d="M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"></path>`,more:`<path d="M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z"></path>`,close:`<path d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"></path>`,loader:`<path d="M12 3C16.9706 3 21 7.02944 21 12H19C19 8.13401 15.866 5 12 5V3Z"></path>`,menu:`<path d="M3 4H21V6H3V4ZM3 11H21V13H3V11ZM3 18H21V20H3V18Z"></path>`,palette:`<path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C17.5222 2 22 5.97778 22 10.8889C22 13.9556 19.5111 16.4444 16.4444 16.4444H14.4778C13.5556 16.4444 12.8111 17.1889 12.8111 18.1111C12.8111 18.5333 12.9778 18.9222 13.2333 19.2111C13.5 19.5111 13.6667 19.9 13.6667 20.3333C13.6667 21.2556 12.9 22 12 22C6.47778 22 2 17.5222 2 12C2 6.47778 6.47778 2 12 2ZM10.8111 18.1111C10.8111 16.0843 12.451 14.4444 14.4778 14.4444H16.4444C18.4065 14.4444 20 12.851 20 10.8889C20 7.1392 16.4677 4 12 4C7.58235 4 4 7.58235 4 12C4 16.19 7.2226 19.6285 11.324 19.9718C10.9948 19.4168 10.8111 18.7761 10.8111 18.1111ZM7.5 12C6.67157 12 6 11.3284 6 10.5C6 9.67157 6.67157 9 7.5 9C8.32843 9 9 9.67157 9 10.5C9 11.3284 8.32843 12 7.5 12ZM16.5 12C15.6716 12 15 11.3284 15 10.5C15 9.67157 15.6716 9 16.5 9C17.3284 9 18 9.67157 18 10.5C18 11.3284 17.3284 12 16.5 12ZM12 9C11.1716 9 10.5 8.32843 10.5 7.5C10.5 6.67157 11.1716 6 12 6C12.8284 6 13.5 6.67157 13.5 7.5C13.5 8.32843 12.8284 9 12 9Z"></path>`,message:`<path d="M2 8.99374C2 5.68349 4.67654 3 8.00066 3H15.9993C19.3134 3 22 5.69478 22 8.99374V21H8.00066C4.68659 21 2 18.3052 2 15.0063V8.99374ZM20 19V8.99374C20 6.79539 18.2049 5 15.9993 5H8.00066C5.78458 5 4 6.78458 4 8.99374V15.0063C4 17.2046 5.79512 19 8.00066 19H20ZM14 11H16V13H14V11ZM8 11H10V13H8V11Z"></path>`,chat:`<path d="M10 3H14C18.4183 3 22 6.58172 22 11C22 15.4183 18.4183 19 14 19V22.5C9 20.5 2 17.5 2 11C2 6.58172 5.58172 3 10 3ZM12 17H14C17.3137 17 20 14.3137 20 11C20 7.68629 17.3137 5 14 5H10C6.68629 5 4 7.68629 4 11C4 14.61 6.46208 16.9656 12 19.4798V17Z"></path>`,discuss:`<path d="M14 22.5L11.2 19H6C5.44772 19 5 18.5523 5 18V7.10256C5 6.55028 5.44772 6.10256 6 6.10256H22C22.5523 6.10256 23 6.55028 23 7.10256V18C23 18.5523 22.5523 19 22 19H16.8L14 22.5ZM15.8387 17H21V8.10256H7V17H11.2H12.1613L14 19.2984L15.8387 17ZM2 2H19V4H3V15H1V3C1 2.44772 1.44772 2 2 2Z"></path>`};let oe=`http://www.w3.org/2000/svg`,b=ae;function se(e){if(!(e in b))throw Error(`Icon "${e}" not found.`)}function ce(e){return se(e),`<svg xmlns="${oe}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">${b[e]}</svg>`}function le(e){return e!==null&&e.namespaceURI===oe}function x(e,t={}){let n=document.createElement(`template`);n.innerHTML=ce(e);let r=n.content.firstElementChild;if(!le(r))throw Error(`Icon "${e}" cannot be rendered.`);for(let[e,n]of Object.entries(t||{})){if(n==null||n===!1)continue;let t=e===`className`?`class`:e;r.setAttribute(t,n===!0?``:String(n))}return r}function ue(e){return ce(e)}let de=ue;function fe(){return{...b}}function pe(e){if(typeof e!=`object`||!e)throw Error(`Icons must be a valid object.`);for(let[t,n]of Object.entries(e)){if(typeof n!=`string`||!n.trim().startsWith(`<`))throw Error(`Invalid SVG path for icon "${t}".`);b[t]=n}}let me=[`node`,`element`,`array`];function he(e){return me.includes(e)}function S(e){return e instanceof Node}function C(e){return e instanceof Element}function ge(e){return typeof e==`string`||C(e)||S(e)||Array.isArray(e)}function _e(e){return e.find(C)||null}function ve(e,t=[]){for(let n of e){if(Array.isArray(n)){if(!ve(n,t))return null;continue}if(S(n)){t.push(n);continue}return null}return t}function w(e,t){if(typeof e==`function`)return w(e(t),t);let n=e;if(n==null||n===!1||n===!0)return[];if(Array.isArray(n))return n.flatMap(e=>w(e,t));if(S(n))return[n];if(typeof n==`string`){let e=document.createElement(`template`);return e.innerHTML=n,Array.from(e.content.childNodes)}return[document.createTextNode(String(n))]}function T(e){if(e===!1||e==null)return null;if(typeof e==`string`){let t=j(e);return t.length>0?t:null}if(Array.isArray(e)){let t=ve(e,[]);return t&&t.length>0?t:null}return S(e)?[e]:null}function ye(e){return C(e)||S(e)?e:typeof e==`string`?document.querySelector(e):Array.isArray(e)&&(T(e)||[])[0]||null}function E(e){if(!ge(e))return null;if(typeof e==`string`){let t=document.querySelector(e);return C(t)?t:null}if(Array.isArray(e)){let t=T(e);return Array.isArray(t)?_e(t):null}return C(e)?e:null}function be(e,t=`Component`,n=`element`){if(!he(n))throw Error(`${t}: expect must be one of 'node', 'element', 'array'.`);return ge(e)?n===`array`?T(e):n===`node`?ye(e):E(e):null}function D(e,t=`Component`,n=`element`){let r=be(e,t,n);if(r==null)throw Error(`${t}: container not found.`);return r}function O(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`function`||Array.isArray(e)||S(e)}function k(){return(0,t.jsx)(`div`,{"aria-live":`polite`,style:{display:`flex`,justifyContent:`center`,alignItems:`center`,position:`absolute`,width:`100%`,height:`100%`,backdropFilter:`blur(4px)`},children:x(`loader`,{width:24,className:`animate-spin`})})}function A(e,t=document){return t.querySelector(e)}function j(e,t=document){return Array.from(t.querySelectorAll(e))}function xe(e,t,n={}){if(typeof t!=`function`)throw TypeError(`lazyRender: renderCallback expects function.`);let{threshold:r=.1,rootMargin:i=`0px`,root:a=null,waitForDOM:o=!0}=n,s={threshold:r,rootMargin:i,root:a};if(!Ce(e))return console.warn(`lazyRender: target 必须是 CSS 选择器字符串或 DOM 元素`),Se;let c=Se,l=we(e);if(l&&document.body.contains(l))return c=Te(l,t,s),c;if(!o||typeof MutationObserver>`u`)return t(),c;let u=new MutationObserver(()=>{let n=we(e);!n||!document.body.contains(n)||(l=n,u.disconnect(),c=Te(l,t,s))});return u.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{u.disconnect(),c()}}function Se(){}function Ce(e){return typeof e==`string`||C(e)}function we(e){return typeof e==`string`?A(e):e}function Te(e,t,n){if(typeof window>`u`||window.IntersectionObserver===void 0)return t(),Se;let r=new window.IntersectionObserver(n=>{for(let i of n)if(i.isIntersecting){r.unobserve(e),r.disconnect(),t();break}},n);return r.observe(e),()=>{r.unobserve(e),r.disconnect()}}function Ee(e,t,n,r){let i=!0;return e.addEventListener(t,n,r),()=>{i&&(i=!1,e.removeEventListener(t,n,r))}}function M(){let e=new Map,t=t=>{let n=e.get(t);return n?(n(),e.delete(t),!0):!1};return{on(n,r,i,a,o){if(typeof n!=`string`||n.trim()===``)throw TypeError(`EventManager.on: key expects a non-empty string.`);if(t(n),r==null)return()=>{};let s=Ee(r,i,a,o);return e.set(n,s),s},off:t,clear(){for(let t of e.values())t();e.clear()},size(){return e.size}}}async function De(e,t,n={}){let r=new Headers(n.headers);return r.has(`Content-Type`)||r.set(`Content-Type`,`application/json`),(await fetch(e,{...n,method:`POST`,headers:r,body:JSON.stringify(t)})).json()}let Oe=typeof window<`u`?`${window.location.origin}/wp-json`:``;function N(e){if(typeof document>`u`)return null;let t=ke(e),n=document.cookie.match(RegExp(`(?:^|;\\s*)`+t+`=([^;]*)`));return n?decodeURIComponent(n[1]):null}function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ae(e,t,n=3600*24){if(typeof document>`u`)return!1;let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/; SameSite=Lax`;if(n>0){let e=new Date(Date.now()+n*1e3).toUTCString();r+=`; expires=${e}`}return location.protocol===`https:`&&(r+=`; Secure`),document.cookie=r,N(e)===t}function je(e){return typeof document>`u`?!0:(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`,!N(e))}function Me(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var P=class e{constructor(e={}){this.props=e||{},this.dom={root:null},this.plugins=new Map,this.cleanup={events:M(),plugins:new Map},this._listeners={init:[],beforeUpdate:[],afterUpdate:[],destroy:[]},this.state=(0,t.createDeepStore)({}),this.runtime={destroyed:!1},this.installGlobalPlugins()}get root(){return this.dom?.root||null}set root(e){this.dom||(this.dom={root:null}),this.dom.root=e}use(e,t){if(!e)return this;let n=typeof e==`function`?e(this,t):e.install?.(this,t);return this.cleanup.plugins.set(e,n),this}on(e,t){return!this._listeners[e]||typeof t!=`function`||this._listeners[e].push(t),this}off(e,t){return this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter(e=>e!==t)),this}installGlobalPlugins(){for(let t of e.globalPlugins.values())this.use(t)}static useGlobal(t,n){!t||!n||e.globalPlugins.set(t,n)}emit(e,...t){let n=this._listeners[e];if(!n)return this;for(let e of n)try{e(...t)}catch{}return this}init(e={}){if(this.runtime.destroyed)throw Error(`Component.init: instance destroyed`);return Me(e)&&(this.props=Object.assign({},this.props,e)),typeof this.onInit==`function`&&this.onInit(this.props),this.emit(`init`,this.props),this}setState(e={},n){if(this.runtime.destroyed)throw Error(`Component.setState: instance destroyed`);let r=typeof e==`string`&&arguments.length>1?{[e]:n}:e;if(!Me(r))throw Error(`Component.setState: expects a plain object patch.`);return(0,t.flushSync)(()=>{for(let[e,t]of Object.entries(r)){if(!this.state)return;this.state[e]=t}}),this}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);return Me(e)&&(this.props=Object.assign({},this.props,e)),this.emit(`beforeUpdate`,e,{force:t}),typeof this.onUpdate==`function`&&this.onUpdate(e,{force:t}),this.emit(`afterUpdate`,e,{force:t}),this}destroy(){if(!this.runtime.destroyed){this.runtime={destroyed:!0},typeof this.onDestroy==`function`&&this.onDestroy(),this.emit(`destroy`);for(let e of this.cleanup.plugins.values())try{typeof e==`function`?e():e&&typeof e.destroy==`function`&&e.destroy()}catch{}this.cleanup.plugins.clear(),this.cleanup.events.clear(),this.dom={root:null},this.state=null}}};P.globalPlugins=new Map;var Ne={en:{b:`Back`,t:`Customize`,d:`Customize your UI experience.`,sm:`Small`,md:`Medium`,lg:`Large`},zh:{b:`返回`,t:`自定义主题`,d:`自定义您的UI体验。`,Theme:`主题`,Radius:`圆角`,Shadow:`阴影`,Font:`字号`,Mode:`模式`,Gray:`灰色`,Olive:`橄榄绿`,Tomato:`番茄红`,Ruby:`红宝石`,Pink:`粉红`,Violet:`紫罗兰`,Indigo:`靛蓝`,Blue:`蓝色`,Teal:`青色`,Grass:`草绿`,Mint:`薄荷绿`,Lime:`酸橙绿`,Yellow:`黄色`,Orange:`橙色`,Gold:`金色`,None:`无`,sm:`小`,md:`中`,lg:`大`,XL:`更大`,Round:`圆角`,Light:`浅色`,Dark:`深色`,Auto:`自动`}};let Pe={panel:`j-theme-palette`,closeWrap:`theme-palette-close`,closeButton:`j-button is-text`,title:`theme-palette-title`,description:`theme-palette-description`,container:`palette-container`,item:`palette-item`,itemTitle:`item-title`,items:`items`,button:`j-button is-default`,active:`is-active`,prefix:`el-prefix`,swatch:`item-hex`,buttonText:`button-text`},Fe={mode:`dark`,theme:`indigo`,radius:`sm`,shadow:`sm`,font:`sm`,key:`ui-theme`,className:Pe},Ie={theme:`j-theme-`,radius:`j-radius-`,shadow:`j-shadow-`,font:`j-font-`};function Le(e){return{...Pe,...e}}function Re(e={}){return{...Fe,...e,className:Le(e.className)}}function ze(e){return e===`mode`||e===`theme`||e===`radius`||e===`shadow`||e===`font`}function Be(...e){return e.filter(Boolean).join(` `)}var Ve=class{constructor(e={}){this.props=(0,t.createDeepStore)(Re(e)),this.languages=Ne,this.cleanup=null,this.runtime={destroyed:!1},this.init()}init(){this.cleanup={bindings:new Set,events:M()},this.loadConfig(),this.bindEvent()}translate(e){return(0,n.t)(e,this.languages)}loadConfig(){try{let e=N(this.props.key);if(!e?.trim())return;let t=JSON.parse(e);Object.assign(this.props,t,{className:Le({...this.props.className,...t.className})})}catch{}}saveConfig(){let{mode:e,theme:t,radius:n,shadow:r,font:i}=this.props,a=e===`auto`?this.scheme():e;Ae(this.props.key,JSON.stringify({mode:e,theme:t,radius:n,shadow:r,font:i,render:a}))}scheme(){return window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}bindActiveButtons(e){let n=(0,t.createRoot)(n=>{let r=j(`[data-theme-group]`,e);for(let e of r){let n=e.dataset.themeGroup;if(!ze(n))continue;let r=j(`[data-theme-button]`,e);for(let e of r){let r=()=>e.dataset.themeValue===String(this.props[n]);(0,t.bindClass)(e,this.props.className.active,r),(0,t.bindAttr)(e,`aria-selected`,()=>r()?`true`:null)}}return n});this.cleanup?.bindings.add(n)}bindEvent(){this.cleanup?.events.on(`palette`,document.body,`click`,e=>{if(!(e.target instanceof Element))return;let n=e.target.closest(`[data-theme-button]`);if(!n)return;let r=n.closest(`[data-theme-group]`),i=r?.dataset.themeGroup,a=n.dataset.themeValue;if(!r||!ze(i)||!a||n.classList.contains(this.props.className.active))return;let o=this.props[i];(0,t.flushSync)(()=>{this.props[i]=a});let s=document.documentElement;if(i===`mode`){let e=a===`auto`?this.scheme():a;s.classList.remove(`light`,`dark`,o),s.classList.add(e)}else{let e=Ie[i],t=Array.from(s.classList).filter(t=>t.startsWith(e));t.length&&s.classList.remove(...t),s.classList.add(`${e}${a}`)}this.saveConfig()})}unbindEvent(){this.cleanup?.events.clear()}createPanel(e=null,n=null){let r=this.props.className,i=n||this.defaultPanelConfig(),a=(0,t.jsx)(`div`,{className:e||r.panel,"data-theme-palette":`root`,children:[(0,t.jsx)(`div`,{className:r.closeWrap,"data-theme-close-wrap":``,style:{display:`flex`,justifyContent:`center`},children:(0,t.jsx)(`button`,{className:r.closeButton,"data-action":`close`,children:this.translate(`b`)})}),(0,t.jsx)(`h3`,{className:r.title,"data-theme-title":``,children:this.translate(`t`)}),(0,t.jsx)(`p`,{className:r.description,"data-theme-description":``,style:{marginTop:0,fontSize:`var(--text-sm, 0.875rem)`},children:this.translate(`d`)}),(0,t.jsx)(`div`,{className:r.container,"data-theme-container":``,children:i.map(e=>(0,t.jsx)(`div`,{className:r.item,"data-palette":e.type,"data-theme-group":e.type,children:[(0,t.jsx)(`div`,{className:r.itemTitle,"data-theme-group-title":e.type,children:e.title}),(0,t.jsx)(`div`,{className:r.items,"data-theme-items":e.type,children:e.buttons.map(([n,i])=>{let a=String(this.props[e.type])===String(n);return(0,t.jsx)(`button`,{className:Be(r.button,a&&r.active),"data-palette":n,"data-theme-button":e.type,"data-theme-value":n,"aria-selected":a?`true`:null,children:[e.type===`theme`?(0,t.jsx)(`span`,{className:Be(r.prefix,r.swatch),"data-theme-swatch":n,style:{backgroundColor:`var(--ui-${n})`}}):null,(0,t.jsx)(`span`,{className:r.buttonText,"data-theme-button-text":n,children:i})]})})})]}))})]});return this.bindActiveButtons(a),a}setConfig(e){(0,t.flushSync)(()=>{Object.assign(this.props,e,{className:Le({...this.props.className,...e.className})})}),this.saveConfig()}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this.unbindEvent(),this.cleanup?.bindings.forEach(e=>e()),this.cleanup?.bindings.clear(),this.cleanup=null)}defaultPanelConfig(){return[{title:this.translate(`Theme`),type:`theme`,buttons:[[`gray`,this.translate(`Gray`)],[`olive`,this.translate(`Olive`)],[`tomato`,this.translate(`Tomato`)],[`ruby`,this.translate(`Ruby`)],[`pink`,this.translate(`Pink`)],[`violet`,this.translate(`Violet`)],[`indigo`,this.translate(`Indigo`)],[`blue`,this.translate(`Blue`)],[`teal`,this.translate(`Teal`)],[`grass`,this.translate(`Grass`)],[`mint`,this.translate(`Mint`)],[`lime`,this.translate(`Lime`)],[`yellow`,this.translate(`Yellow`)],[`orange`,this.translate(`Orange`)],[`gold`,this.translate(`Gold`)]]},{title:this.translate(`Radius`),type:`radius`,buttons:[[`none`,this.translate(`None`)],[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)],[`lg`,this.translate(`lg`)],[`xl`,this.translate(`XL`)],[`round`,this.translate(`Round`)]]},{title:this.translate(`Shadow`),type:`shadow`,buttons:[[`none`,this.translate(`None`)],[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)],[`lg`,this.translate(`lg`)]]},{title:this.translate(`Font`),type:`font`,buttons:[[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)]]},{title:this.translate(`Mode`),type:`mode`,buttons:[[`light`,this.translate(`Light`)],[`dark`,this.translate(`Dark`)],[`auto`,this.translate(`Auto`)]]}]}};let He={container:`j-toast-container`,toast:`j-toast`,icon:`toast-icon`,message:`toast-message`,shown:`is-shown`,hidden:`is-hidden`,lite:`j-toast-lite`,action:`is-action`,actions:`toast-actions`,button:`j-button is-sm`,cancelButton:`is-ghost`,actionButton:`is-outline`,info:`is-info`,success:`is-success`,warning:`is-warning`,error:`is-error`,primary:`is-primary`},Ue={type:`string`,enum:[`info`,`success`,`warning`,`error`,`primary`]},We={type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},Ge={type:`number`,validate:e=>typeof e==`number`&&e>0,message:`expects a number greater than 0.`};function Ke(e){return{...He,...e}}function F(...e){return e.filter(Boolean).join(` `)}var I=class e{static configure(t={}){return e.options={className:Ke(t.className)},e.options}static resolveClassNames(t){return Ke({...e.options.className,...t?.className})}static show(n=``,r=3e3,i=`info`,a={}){g(`message`,n,`string`,`Toast.show`),g(`duration`,r,We,`Toast.show`),g(`type`,i,Ue,`Toast.show`);let o=e.resolveClassNames(a),s=e.getOrCreateContainer(o),c=v(),l=(0,t.jsx)(`div`,{className:F(o.toast,o[i]),"data-toast":c,children:[(0,t.jsx)(`span`,{className:o.icon,"data-toast-icon":c,children:x(i===`primary`?`info`:i)}),(0,t.jsx)(`span`,{className:o.message,"data-toast-message":c,children:n})]});e.classNames.set(l,o),s.appendChild(l),e.setTimer(c,`show`,()=>l.classList.add(o.shown),10),r>0&&e.setTimer(c,`hide`,()=>e.hide(l),r);let u=Ee(l,`click`,()=>e.hide(l));return e.disposers.set(l,u),l}static success(t=``,n=3e3,r={}){return e.show(t,n,`success`,r)}static info(t=``,n=3e3,r={}){return e.show(t,n,`info`,r)}static primary(t=``,n=3e3,r={}){return e.show(t,n,`primary`,r)}static warning(t=``,n=3e3,r={}){return e.show(t,n,`warning`,r)}static error(t=``,n=3e3,r={}){return e.show(t,n,`error`,r)}static hide(t){if(!t)return;let n=e.classNames.get(t)||e.options.className;e.disposers.get(t)?.(),e.disposers.delete(t),t.classList.remove(n.shown),t.classList.add(n.hidden);let r=t.dataset.toast||v();e.setTimer(r,`remove`,()=>{t.remove();let e=A(`[data-toast-container]`);e&&e.children.length===0&&e.remove()},300)}static lite(n=``,r=2e3,i={}){g(`message`,n,`string`,`Toast.lite`),g(`duration`,r,Ge,`Toast.lite`);let a=e.resolveClassNames(i);A(`[data-toast-lite]`)?.remove();let o=v(),s=(0,t.jsx)(`div`,{className:a.lite,"data-toast":o,"data-toast-lite":``,children:n});return e.classNames.set(s,a),document.body.appendChild(s),e.setTimer(o,`show`,()=>s.classList.add(a.shown),10),e.setTimer(o,`hide`,()=>{s.classList.remove(a.shown),s.classList.add(a.hidden),e.setTimer(o,`remove`,()=>s.remove(),300)},r),s}static action(n=``,r={}){g(`message`,n,`string`,`Toast.action`);let i=e.resolveClassNames(r),a=e.getOrCreateContainer(i),o=v(),s=(0,t.jsx)(`div`,{className:F(i.toast,i.action),"data-toast":o,"data-toast-action":``,children:[(0,t.jsx)(`div`,{className:i.message,"data-toast-message":o,children:n}),(0,t.jsx)(`div`,{className:i.actions,"data-toast-actions":o,children:[(0,t.jsx)(`button`,{className:F(i.button,i.cancelButton),children:r.text?.cancel||`cancel`,"data-action":`cancel`,onClick:()=>e.hide(s)}),(0,t.jsx)(`button`,{className:F(i.button,i.actionButton),children:r.text?.action||`action`,"data-action":`toast-action`,onClick:async()=>{await r.onAction?.(),e.hide(s)}})]})]});return e.classNames.set(s,i),a.appendChild(s),e.setTimer(o,`show`,()=>{s.classList.add(i.shown),A(`[data-action="toast-action"]`,s)?.focus()},10),s}static getOrCreateContainer(e){let n=A(`[data-toast-container]`);return n?n.className=e.container:(n=(0,t.jsx)(`div`,{className:e.container,"data-toast-container":``}),document.body.appendChild(n)),n}static setTimer(t,n,r,i){let a=`${t}-${n}`;return e.timers.add(a),l.start(a,i,()=>{e.timers.delete(a),r()}),a}static clearAll(){for(let t of e.timers)l.cancel(t);e.timers.clear();for(let t of e.disposers.values())t();e.disposers.clear(),A(`[data-toast-container]`)?.remove(),A(`[data-toast-lite]`)?.remove()}static destroyAll(){e.clearAll()}};I.timers=new Set,I.disposers=new Map,I.classNames=new WeakMap,I.options={className:He};let qe={rules:{default:{},type:`object`},messages:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]}};function Je(e){let t=_(e,qe,`Validator.options`);return{rules:t.rules,messages:t.messages,onSubmit:t.onSubmit}}function L(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Ye(e){if(!e)return null;if(e instanceof Element)return L(e)?e:null;for(let t of Array.from(e))if(t instanceof Element&&L(t))return t;return null}function Xe(){return{valid:!0,message:``,destroyed:!1}}function Ze(e){return e.closest(`[data-form-control]`)||e.parentElement}function Qe(e){return Array.from(e.selectedOptions).map(e=>e.value.trim())}function R(e){return e instanceof HTMLInputElement&&e.type===`file`}function z(e){return!!e.files&&e.files.length>0}var $e=class{constructor(e,t={},n=!1){this.options=Je(t),this.root=this.resolveRoot(e),this.runtime=Xe(),this.cleanup={events:M()},this.validateOptions(n),n&&this.bindEvents()}resolveRoot(e){let t=E(e);if(!(t instanceof HTMLFormElement))throw Error(`Validator.element expects a form element.`);return t}validateOptions(e){g(`bindEvents`,e,`boolean`,`Validator`)}bindEvents(){this.unbindEvents(),!(!this.root||!this.cleanup)&&(this.cleanup.events.on(`submit`,this.root,`submit`,e=>{e.preventDefault(),this.validate()}),this.cleanup.events.on(`reset`,this.root,`reset`,()=>{this.reset({native:!1})}))}unbindEvents(){this.cleanup?.events.clear()}validate(){if(!this.root||!this.options)return!1;this.runtime.valid=!0,this.runtime.message=``;for(let e of Array.from(this.root.elements))if(!(!L(e)||!e.name)&&this.options.rules[e.name]&&(this.runtime.valid=this.validateRule(e,e.name),!this.runtime.valid))break;return this.runtime.valid&&this.options.onSubmit&&this.options.onSubmit(this),this.runtime.valid}validateRule(e,t){if(!this.options)return!1;let n=this.options.rules[t];if(!n)return!0;if(this.hasNativeValidationRule(e))return this.runtime.valid;for(let r of Object.keys(n)){let i=n[r],a=``;switch(r){case`required`:this.runtime.valid=this.validateRequired(e,i);break;case`minLength`:this.runtime.valid=this.validateMinLength(e,i);break;case`maxLength`:this.runtime.valid=this.validateMaxLength(e,i);break;case`equalTo`:this.runtime.valid=this.validateEqualTo(e,i);break;case`email`:this.runtime.valid=this.validateEmail(e);break;case`checked`:this.runtime.valid=this.validateCheck(e,i);break;case`selected`:this.runtime.valid=this.validateSelected(e,i);break;case`multiple`:this.runtime.valid=this.validateMultiple(e,i);break;case`min`:this.runtime.valid=this.validateSelectMin(e,i);break;case`max`:this.runtime.valid=this.validateSelectMax(e,i);break;case`noSpace`:this.runtime.valid=this.validateNoSpace(e,i);break;case`noChinese`:this.runtime.valid=!/[\u4e00-\u9fa5]/.test(e.value);break;case`noSpecial`:this.runtime.valid=!/[@#$%^&*]+/g.test(e.value);break;case`pattern`:this.runtime.valid=this.validatePattern(e,i);break;case`file`:this.runtime.valid=this.validateFile(e,i);break;case`minSize`:this.runtime.valid=this.validateMinSize(e,i);break;case`maxSize`:this.runtime.valid=this.validateMaxSize(e,i);break;case`accept`:this.runtime.valid=this.validateAccept(e,i);break;case`validate`:{let t=this.validateCustom(e,i);this.runtime.valid=t===!0,a=typeof t==`string`?t:``;break}}if(!this.runtime.valid){this.showError(e,t,r,a);break}this.showSuccess(e)}return this.runtime.valid}hasNativeValidationRule(e){return e.hasAttribute(`required`)||e.hasAttribute(`minlength`)||e.hasAttribute(`maxlength`)||e.hasAttribute(`pattern`)||e.hasAttribute(`min`)||e.hasAttribute(`max`)||e.hasAttribute(`step`)}validateRequired(e,t){return t===!0?e instanceof HTMLSelectElement?Qe(e).some(e=>e.length>0):e.value.trim().length>=1:!0}validateMinLength(e,t){return typeof t!=`number`||e.value.length>=t}validateMaxLength(e,t){return typeof t!=`number`||e.value.length<=t}validateEmail(e){return/^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(e.value)}validateEqualTo(e,t){if(!this.root||typeof t!=`string`)return!0;let n=Ye(this.root.elements.namedItem(t));if(!n)throw Error(`Validator: target element "${t}" not found.`);return e.value===n.value}validateCheck(e,t){if(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)throw Error(`Validator: element expects a checkbox input, but ${e.tagName.toLowerCase()} given.`);return e.checked===t}validateSelected(e,t){if(!(e instanceof HTMLSelectElement))throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t!==!0||Qe(e).some(e=>e.length>0)}validateMultiple(e,t){if(!(e instanceof HTMLSelectElement))throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t!==!0||e.selectedOptions.length>0}validateSelectMin(e,t){return!(e instanceof HTMLSelectElement)||typeof t!=`number`||e.selectedOptions.length>=t}validateSelectMax(e,t){return!(e instanceof HTMLSelectElement)||typeof t!=`number`||e.selectedOptions.length<=t}validateNoSpace(e,t){return!/\s/.test(e.value)||t!==!0}validatePattern(e,t){return typeof t==`string`||t instanceof RegExp?new RegExp(t).test(e.value):!0}validateFile(e,t){return!R(e)||t!==!0||z(e)}validateMinSize(e,t){return!R(e)||!z(e)||typeof t!=`number`||e.files[0].size>=t}validateMaxSize(e,t){return!R(e)||!z(e)||typeof t!=`number`||e.files[0].size<=t}validateAccept(e,t){if(!R(e)||!z(e)||typeof t!=`string`)return!0;let n=e.files[0];return t.split(`,`).map(e=>e.trim().toLowerCase()).some(e=>e.startsWith(`.`)?n.name.toLowerCase().endsWith(e):e.endsWith(`/*`)?n.type.startsWith(e.replace(`/*`,`/`)):n.type===e)}validateCustom(e,t){if(typeof t!=`function`)return!0;let n=t(e,this);return typeof n==`string`?n:!!n}showError(e,n,r,i=``){(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)&&(e.classList.remove(`is-valid`),e.classList.add(`is-invalid`));let a=i||this.options?.messages[n]?.[r]||``;if(!a)return;this.runtime.message=a;let o=Ze(e);if(!o)return;let s=j(`[data-validator-help]`,o).find(e=>e.dataset.validatorHelp===n)||null;s||(s=(0,t.jsx)(`div`,{className:`help-block is-invalid`,"data-validator-help":n}),o.appendChild(s)),s.textContent=a}showSuccess(e){let t=Ze(e);if(t)for(let n of j(`[data-validator-help]`,t))n.dataset.validatorHelp===e.name&&n.remove();(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)&&(e.classList.remove(`is-invalid`),e.classList.add(`is-valid`))}reset({native:e=!0}={}){if(this.root){e&&this.root.reset();for(let e of Array.from(this.root.elements))L(e)&&(e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`));for(let e of j(`[data-validator-help]`,this.root))e.remove();this.runtime.valid=!0,this.runtime.message=``}}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this.unbindEvents(),this.reset({native:!1}),this.root=null,this.options=null,this.runtime.valid=!1,this.runtime.message=``,this.cleanup?.events.clear(),this.cleanup=null)}};function et(e,t={},n=!1){return new $e(e,t,n)}let tt={form:`j-form`,vertical:`is-vertical`,horizontal:`is-horizontal`,itemVertical:`is-item-vertical`,itemHorizontal:`is-item-horizontal`,item:`form-item`,label:`item-label`,required:`is-required`,control:`form-control`,helpInvalid:`is-invalid`,buttons:`form-buttons`,button:`j-button`,input:`j-input`,textarea:`j-textarea`,select:`j-select`,radio:`j-radio`,checkbox:`j-checkbox`,choiceVertical:`is-vertical`,choiceHorizontal:`is-horizontal`,choiceGroup:`is-group`,radioLabel:`radio-label`,radioText:`radio-text`,switch:`j-switch`,switchDefault:`is-default`,switchSizeMd:`is-md`,switchSlider:`switch-slider`},nt=[{type:`submit`,text:`Submit`,theme:`primary`,action:`submit`},{type:`reset`,text:`Reset`,theme:`ghost`,action:`reset`}],rt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():v():e??v()},vertical:{default:!0,type:`boolean`},itemVertical:{default:!0,type:`boolean`},style:{default:``,types:[`string`,`object`,`null`]},fields:{default:[],type:`array`},buttons:{default:nt,types:[`boolean`,`array`],normalize:e=>e===!1?[]:e===!0?B(nt):Array.isArray(e)?B(e):e},className:{default:tt,type:`object`,normalize:e=>ut(e)},validator:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]},onReset:{default:null,types:[`function`,`null`]}},it={validate:e=>p(e),message:`expects a props object.`};function at(e){return Array.isArray(e)?e.map(e=>e&&typeof e==`object`?{...e}:e):[]}function ot(e){return Array.isArray(e)?e.map(e=>({...e,options:at(e.options)})):[]}function B(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function st(e){return e&&typeof e==`object`?e:{value:e,text:String(e)}}function V(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):e.name}function ct(e,t){return O(e)?w(e,t):null}function lt(e,t){return e.name?!!e.required||!!t?.[e.name]?.required:!!e.required}function H(...e){return e.filter(Boolean).join(` `)}function ut(e){return{...tt,...p(e)?e:{}}}function dt(e,t){if(e.removeAttribute(`style`),t){if(typeof t==`string`){e.style.cssText=t;return}if(p(t))for(let[n,r]of Object.entries(t)){if(r==null||typeof r!=`string`&&typeof r!=`number`)continue;let t=n.startsWith(`--`)?n:n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(t,String(r))}}}function ft(e){let t=p(e)?e:{};return{...t,rules:p(t.rules)?t.rules:{},messages:p(t.messages)?t.messages:{}}}function pt(e){let t=_(e,rt,`Form.props`);return{...t,id:String(t.id),vertical:!!t.vertical,itemVertical:!!t.itemVertical,style:t.style,fields:ot(t.fields),buttons:B(t.buttons),className:ut(t.className),validator:ft(t.validator),onSubmit:t.onSubmit,onReset:t.onReset}}var mt=class extends P{constructor(e={},n=!1){let r=pt(e);super(r),this.dom.container=n,this.dom.fields=new Map,this.validator=null,this.cleanup.view=null,this.cache={initial:this.cloneProps(r),fieldIds:new Map},this.state=(0,t.createDeepStore)({...this.cloneProps(r),submitting:!1,data:null})}get root(){return this.dom?.root||null}set root(e){this.dom.root=e}onInit(){this.dom.container!==!1&&this.dom.container!=null&&typeof this.dom.container!=`string`&&this.mount(this.dom.container)}build(e=this.dom.container){if(this.runtime.destroyed)throw Error(`Form.build: instance destroyed`);return this.cleanup.view?this:(this.dom.container=e===!1?document.createDocumentFragment():D(e,`Form.container`),this.init(this.props),this)}mount(e=this.dom.container){return this.cleanup.view||!e||(this.cleanup.view=(0,t.createRoot)(n=>((0,t.onCleanup)((0,t.render)(()=>this.view(),e)),n))),this}view(){let e=this.state.className;return(0,t.jsx)(`form`,{className:()=>H(this.state.className.form,this.state.vertical?e.vertical:e.horizontal,this.state.itemVertical?e.itemVertical:e.itemHorizontal),id:()=>this.state.id,style:()=>this.state.style,"data-form":`root`,"data-form-layout":()=>this.state.vertical?`vertical`:`horizontal`,"data-form-item-layout":()=>this.state.itemVertical?`vertical`:`horizontal`,ref:e=>{let t=this.root!==e;this.root=e,dt(e,this.state.style),(t||!this.validator)&&this.syncValidator()},onSubmit:e=>this.handleSubmit(e),onReset:e=>this.handleReset(e),children:()=>[...this.state.fields.map((e,t)=>this.fieldView(e,t)),this.buttonsView()]})}fieldView(e,n){let r=this.resolveFieldId(e,n),i=e.type===`hidden`,a=this.state.className;return(0,t.jsx)(`div`,{className:a.item,"data-form-item":e.name||String(n),style:{display:i?`none`:``},children:[this.labelView(e,r),(0,t.jsx)(`div`,{className:a.control,"data-form-control":e.name||String(n),children:[this.controlView(e,r,n),e.help?(0,t.jsx)(`div`,{className:`help-block`,"data-form-help":e.name||String(n),children:e.help}):null]})]})}labelView(e,n){if(e.label===!1||e.label===void 0)return null;let r=this.state.className;return(0,t.jsx)(`label`,{className:H(r.label,lt(e,this.state.validator?.rules)?r.required:``),"data-form-label":e.name||n,for:n,children:e.label})}controlView(e,t,n){switch(e.type){case`textarea`:return this.textareaView(e,t);case`select`:return this.selectView(e,t);case`radio`:return this.choiceGroupView(e,t,`radio`);case`checkbox`:return Array.isArray(e.options)?this.choiceGroupView(e,t,`checkbox`):this.inputView(e,t);case`switch`:return this.switchView(e,t);case`custom`:return ct(e.content,{form:this,field:e,index:n});default:return this.inputView(e,t)}}inputView(e,n){let r=e.type||`text`;return(0,t.jsx)(`input`,{...this.controlProps(e,n,{type:r,className:e.className||this.state.className.input,autocomplete:e.autocomplete||this.autoComplete(r),value:e.value??``}),checked:e.checked===void 0?void 0:!!e.checked})}textareaView(e,n){return(0,t.jsx)(`textarea`,this.controlProps(e,n,{className:e.className||this.state.className.textarea,autocomplete:e.autocomplete,value:e.value??``}))}selectView(e,n){let r=e.value;return(0,t.jsx)(`select`,this.controlProps(e,n,{className:e.className||this.state.className.select,autocomplete:e.autocomplete||`off`,multiple:!!e.multiple,children:(e.options||[]).map(e=>{let n=st(e);return(0,t.jsx)(`option`,{value:n.value??``,disabled:!!n.disabled,selected:this.isSelected(r,n.value),children:n.text??n.label??n.value??``})})}))}choiceGroupView(e,n,r){let i=e.vertical?`vertical`:`horizontal`,a=this.state.className;return(0,t.jsx)(`div`,{className:H(r===`radio`?a.radio:a.checkbox,i===`vertical`?a.choiceVertical:a.choiceHorizontal,e.group?a.choiceGroup:``,e.size?`is-${e.size}`:``),"data-form-choice-group":e.name||n,"data-choice-type":r,"data-choice-layout":i,children:(e.options||[]).map((i,o)=>{let s=st(i),c=`${n}_${o}`;return(0,t.jsx)(`label`,{className:r===`radio`?a.radioLabel:``,"data-form-choice":e.name||n,for:c,children:[(0,t.jsx)(`input`,{type:r,id:c,name:e.name,value:s.value??``,checked:r===`radio`?this.isSelected(e.value,s.value):this.isChecked(e.value,s.value,s.checked),disabled:!!s.disabled||!!e.disabled,required:!!e.required}),(0,t.jsx)(`span`,{className:r===`radio`?a.radioText:``,"data-form-choice-text":``,children:s.text??s.label??s.value??``})]})})})}switchView(e,n){let r=this.state.className;return(0,t.jsx)(`label`,{className:H(r.switch,e.variant?`is-${e.variant}`:r.switchDefault,e.size?`is-${e.size}`:r.switchSizeMd),"data-form-switch":e.name||n,for:n,children:[(0,t.jsx)(`input`,{type:`checkbox`,id:n,name:e.name,value:e.value??`on`,checked:!!e.checked,disabled:!!e.disabled,required:!!e.required}),(0,t.jsx)(`span`,{className:r.switchSlider,"data-form-switch-slider":``})]})}buttonsView(){if(!this.state.buttons.length)return null;let e=this.state.className;return(0,t.jsx)(`div`,{className:e.buttons,"data-form-buttons":``,children:this.state.buttons.map(n=>(0,t.jsx)(`button`,{type:n.type||`button`,className:H(e.button,n.theme?`is-${n.theme}`:``,n.className||``),"data-action":n.action||n.type||`button`,disabled:()=>!!this.state.submitting||!!n.disabled,children:n.text??n.label??``}))})}controlProps(e,t,n){return{...n,name:e.name,id:t,placeholder:e.placeholder||``,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly,"data-form-field":e.name||t,ref:t=>{e.name&&this.dom.fields.set(e.name,t)}}}resolveFieldId(e,t){if(e.id)return e.id;let n=e.name||t;return this.cache.fieldIds.has(n)||this.cache.fieldIds.set(n,`${this.state.id}_field_${t}`),this.cache.fieldIds.get(n)||`${this.state.id}_field_${t}`}syncValidator(){if(!this.root)return;let e={...this.state.validator,onSubmit:null};if(this.validator?.root===this.root){this.validator.options=e;return}this.validator?.destroy(),this.validator=new $e(this.root,e,!1)}validate(){return!this.validator||this.validator.validate()}reset(){return this.validator?.reset(),(0,t.flushSync)(()=>{this.state.data=null}),this}async handleSubmit(e){if(e.preventDefault(),this.state.submitting||!this.validate())return;let n=this.collectData();(0,t.flushSync)(()=>{this.state.submitting=!0,this.state.data=n});try{await Promise.resolve(this.state.onSubmit?.(n,this))}finally{this.runtime.destroyed||(0,t.flushSync)(()=>{this.state.submitting=!1})}}handleReset(e){this.resetValidationState(),(0,t.flushSync)(()=>{this.state.data=null}),this.state.onReset?.(e,this)}resetValidationState(){if(this.root){for(let e of Array.from(this.root.elements))e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`);for(let e of j(`[data-form-help], [data-validator-help]`,this.root))(e.dataset.validatorHelp||e.classList.contains(`is-invalid`))&&e.remove()}}collectData(){return this.root?this.collectFormData(this.root):{}}collectFormData(e){let t={},n=new FormData(e);for(let[e,r]of n.entries())s(t,e)?t[e]=Array.isArray(t[e])?[...t[e],r]:[t[e],r]:t[e]=r;return t}requestSubmit(){if(!this.root)return this;if(typeof this.root.requestSubmit==`function`)return this.root.requestSubmit(),this;let e=new Event(`submit`,{bubbles:!0,cancelable:!0});return this.root.dispatchEvent(e),this}update(e={},n={}){let r=e||{};g(`props`,r,it,`Form.update`);let i=pt(Object.assign({},this.props,r));return this.props=this.cloneProps(i),this.cache.fieldIds.clear(),super.update(i),(0,t.flushSync)(()=>{let e=this.cloneProps(i);for(let t of Object.keys(e))this.state[t]=e[t]}),this}setFields(e){return g(`fields`,e,`array`,`Form.setFields`),this.update({fields:e})}resetFields(){return this.setFields(this.cache.initial.fields)}cloneProps(e){return{...e,fields:ot(e.fields),buttons:B(e.buttons),className:ut(e.className),validator:ft(e.validator)}}autoComplete(e){switch(e){case`password`:return`current-password`;case`email`:return`email`;default:return`on`}}isSelected(e,t){return Array.isArray(e)?e.map(e=>V(e)).includes(V(t)):e==t}isChecked(e,t,n){return n===void 0?Array.isArray(e)?e.map(e=>V(e)).includes(V(t)):typeof e!=`string`&&typeof e!=`boolean`&&!(e instanceof File)?!1:e===!0||V(e)===V(t):!!n}onDestroy(){let e=this.cleanup.view;typeof e==`function`&&e(),this.cleanup.view=null,this.validator?.destroy(),this.validator=null}};function ht(e={},t=!1){return new mt(e,t)}let gt={toc:`j-toc`,list:`toc-list`,link:`toc-link`,active:`is-active`,levelPrefix:`is-level-`},_t={container:{default:null},target:{default:`.j-content`},headings:{default:`h2, h3`,type:`string`},offset:{default:80,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},className:{default:gt,type:`object`,normalize:e=>({...gt,...e&&typeof e==`object`?e:{}})},onUpdate:{default:null,types:[`function`,`null`]}};function vt(e){let t=_(e,_t,`Toc.props`);return{container:t.container,target:t.target,headings:t.headings,offset:t.offset,className:t.className,onUpdate:t.onUpdate}}function yt(e){let t=/^H([1-6])$/.exec(e.tagName);return t?Number(t[1]):1}function bt(e,t){return e.id||(e.id=`toc-${v()}-${t}`),{id:e.id,text:e.textContent||``,level:yt(e),element:e}}var xt=class extends P{constructor(e={}){let n=vt(e);super(n),this.dom.container=null,this.dom.target=null,this.dom.list=null,this.dom.headings=[],this.dom.links=[],this.runtime.built=!1,this.runtime.ticking=!1,this.state=(0,t.createDeepStore)({items:[],current:{index:-1,item:null}})}build(){if(this.runtime.destroyed)throw Error(`Toc.build: instance destroyed`);if(this.runtime.built)return this;this.init(this.props),this.dom.container=D(this.props.container,`Toc.container`),this.dom.target=D(this.props.target,`Toc.target`);let e=document.createElement(`nav`);return e.className=this.props.className.toc,e.dataset.toc=`root`,this.root=e,this.dom.list=document.createElement(`div`),this.dom.list.className=this.props.className.list,this.dom.list.dataset.tocList=`root`,e.appendChild(this.dom.list),this.dom.container.innerHTML=``,this.dom.container.appendChild(e),this.runtime.built=!0,this.refresh(),this}bindEvents(){this.dom.list&&(this.cleanup.events.on(`scroll`,window,`scroll`,()=>this.onScroll(),{passive:!0}),this.cleanup.events.on(`click`,this.dom.list,`click`,e=>this.onClick(e)))}onScroll(){this.runtime.ticking||(requestAnimationFrame(()=>{this.updateActive(),this.runtime.ticking=!1}),this.runtime.ticking=!0)}onClick(e){if(!(e.target instanceof Element)||!this.dom.list)return;let t=e.target.closest(`[data-toc-index]`);if(!t||!this.dom.list.contains(t))return;let n=Number(t.dataset.tocIndex),r=this.state?.items[n];r&&(e.preventDefault(),this.scrollToItem(r,{activeIndex:n,updateHash:!0}))}scrollToItem(e,{activeIndex:t=-1,updateHash:n=!1}={}){let r=window.scrollY||window.pageYOffset||0,i=Math.max(0,e.element.getBoundingClientRect().top+r-this.props.offset);window.scrollTo({top:i,behavior:`smooth`}),t>=0&&this.setActive(t),n&&window.history?.pushState&&window.history.pushState(null,``,`#${e.id}`)}linkClassName(e,t=!1){let n=[this.props.className.link,`${this.props.className.levelPrefix}${e.level}`];return t&&n.push(this.props.className.active),n.filter(Boolean).join(` `)}buildLink(e,n){return(0,t.jsx)(`a`,{className:this.linkClassName(e),href:`#${e.id}`,"data-toc-index":String(n),"data-toc-target":e.id,children:e.text})}updateActive(){if(!this.runtime.built)return;let e=-1,t=this.props.offset+1;for(let n=this.dom.headings.length-1;n>=0;n--)if(this.dom.headings[n].getBoundingClientRect().top<=t){e=n;break}this.setActive(e)}setActive(e){if(!this.state||e===this.state.current.index)return;let t=this.state.items[e]||null;this.setState({current:{index:e,item:t}});let n=this.state.items;this.dom.links.forEach((t,r)=>{let i=r===e;t.dataset.active=i?`1`:`0`,t.className=this.linkClassName(n[r],i)}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(t,e,this)}refresh(){if(this.runtime.destroyed||!this.runtime.built||!this.dom.target||!this.dom.list)return this;this.cleanup.events.clear(),this.dom.headings=j(this.props.headings,this.dom.target);let e=this.dom.headings.map(bt);this.dom.links=e.map((e,t)=>this.buildLink(e,t)),this.dom.list.innerHTML=``;for(let e of this.dom.links)this.dom.list.appendChild(e);return this.setState({items:e,current:{index:-1,item:null}}),this.bindEvents(),this.updateActive(),this}activate(e){return!this.runtime.built||!this.state||!Number.isInteger(e)||e<0||e>=this.dom.links.length||this.scrollToItem(this.state.items[e]),this}onDestroy(){this.cleanup.events.clear(),this.dom.container&&(this.dom.container.innerHTML=``),this.runtime.built=!1,this.runtime.ticking=!1,this.dom.container=null,this.dom.target=null,this.dom.list=null,this.dom.headings=[],this.dom.links=[]}};function St(e={}){return new xt(e)}let Ct={target:{default:null},parent:{default:null},max:{default:10,type:`number`,validate:e=>typeof e==`number`&&Number.isInteger(e)&&e>0,message:`expects a positive integer.`},top:{default:16,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},gap:{default:16,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},overflow:{default:`destroy`,type:`string`,enum:[`destroy`,`ignore`]},onUpdate:{default:null,types:[`function`,`null`]}};function wt(e){let t=_(e,Ct,`Sticky.props`);return{target:t.target,parent:t.parent,max:t.max,top:t.top,gap:t.gap,overflow:t.overflow,onUpdate:t.onUpdate}}function Tt(e){let t=e.filter(e=>e instanceof HTMLElement);return Array.from(new Set(t))}function Et(e){return e===!1||e==null?null:D(e,`Sticky.parent`,`element`)}function Dt(e,t){if(e===!1||e==null)return[];if(typeof e==`string`){if(!t)return Tt(D(e,`Sticky.target`,`array`));let n=Tt(j(e,t));if(n.length===0)throw Error(`Sticky.target: target not found.`);return n}let n=Tt(D(e,`Sticky.target`,`array`));if(!t)return n;let r=n.filter(e=>e===t||t.contains(e));if(r.length===0)throw Error(`Sticky.target: target not found in parent.`);return r}var Ot=class extends P{constructor(e={}){let n=wt(e);super(n),this.dom.parent=null,this.dom.targets=[],this.runtime.active=!1,this.runtime.built=!1,this.runtime.ignored=!1,this.runtime.items=[],this.state=(0,t.createDeepStore)({count:0,top:n.top,items:[]})}build(){if(this.runtime.destroyed)throw Error(`Sticky.build: instance destroyed`);return this.runtime.built||(this.init(this.props),this.dom.parent=Et(this.props.parent),this.dom.targets=Dt(this.props.target,this.dom.parent),this.dom.targets=this.resolveOverflow(this.dom.targets),this.runtime.built=!0,this.dom.targets.length===0)?this:(this.runtime.active=!0,this.captureItems(),this.apply(),this)}captureItems(){this.runtime.items=this.dom.targets.map(e=>({element:e,top:this.props.top,originalPosition:e.style.position,originalTop:e.style.top,originalZIndex:e.style.zIndex}))}resolveOverflow(e){let{max:t,overflow:n}=this.props;return e.length<=t?e:(this.runtime.ignored=n===`ignore`,n===`ignore`?[]:e.slice(-t))}apply(e=this.props.top){let t=e,n=[];for(let e of this.runtime.items)e.top=t,e.element.style.position=`sticky`,e.element.style.top=`${t}px`,n.push({element:e.element,top:t}),t+=e.element.offsetHeight+this.props.gap;return this.setState({count:this.runtime.items.length,top:this.runtime.items[0]?.top??this.props.top,items:n}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(this),t}restore(){for(let e of this.runtime.items)e.element.style.position=e.originalPosition,e.element.style.top=e.originalTop,e.element.style.zIndex=e.originalZIndex}refresh(){return this.runtime.destroyed||!this.runtime.built||!this.runtime.active||this.apply(),this}destroy(){this.runtime.destroyed||(this.restore(),super.destroy())}onDestroy(){this.runtime.active=!1,this.runtime.built=!1,this.runtime.items=[],this.dom.targets=[]}};function kt(e={}){return new Ot(e)}let U={root:`j-flow`,header:`flow-header`,title:`flow-title`,description:`flow-description`,steps:`flow-steps`,step:`flow-step`,active:`is-active`,complete:`is-complete`,stepButton:`flow-step-button`,stepIndex:`flow-step-index`,stepTitle:`flow-step-title`,body:`flow-body`,footer:`flow-footer`,button:`j-button`,buttonGhost:`is-ghost`,buttonPrimary:`is-primary`,reset:`flow-reset`,back:`flow-back`,next:`flow-next`};function At(e){return!!e&&typeof e==`object`&&typeof e.id==`string`}function jt(e){return e==null||e===!1||typeof e==`function`}function W(e){return p(e)?{...e}:{}}function Mt(e){return Array.isArray(e)?[...e]:[]}function Nt(e){return Array.isArray(e)?e.map(e=>{let t=e;return{...t,data:W(t.data),modal:typeof t.modal==`function`||t.modal==null?t.modal:W(t.modal),view:W(t.view)}}):[]}function Pt(e,t){return typeof e==`string`?{id:e}:p(e)&&typeof e.id==`string`?{id:e.id,data:p(e.data)||e.data==null?e.data:void 0}:{id:t}}function Ft(e){if(typeof e==`string`){let t=e.trim();return{...U,root:t?`${U.root} ${t}`:U.root}}return{...U,...p(e)?e:{}}}function G(...e){return e.filter(Boolean).join(` `)}let It={validate:At,message:`expects a step object with a string id.`},Lt={validate:O,message:`expects string, Node, array, function or null.`},Rt={validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty steps array.`},K={validate:e=>e==null||p(e),message:`expects an object or null.`},q={validate:jt,message:`expects function, false or null.`},zt={default:{},validate:p,message:`expects an object with text fields.`,normalize:e=>{let t=p(e)?e:{};return{...Object.fromEntries(Object.entries(t).filter(([,e])=>typeof e==`string`)),back:typeof t.back==`string`?t.back:`Back`,next:typeof t.next==`string`?t.next:`Next`,finish:typeof t.finish==`string`?t.finish:`Finish`,reset:typeof t.reset==`string`?t.reset:`Reset`}}},Bt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},steps:{default:[],...Rt},initial:{default:null,types:[`string`,`number`,`null`]},cache:{default:!0,type:`boolean`},linear:{default:!0,type:`boolean`},render:{default:!0,type:`boolean`},rollbackOnError:{default:!0,type:`boolean`},busyStrategy:{default:`ignore`,type:`string`,enum:[`ignore`,`throw`]},showHeader:{default:!0,type:`boolean`},showFooter:{default:!0,type:`boolean`},showSteps:{default:!0,type:`boolean`},showBack:{default:!0,type:`boolean`},showNext:{default:!0,type:`boolean`},showReset:{default:!1,type:`boolean`},text:zt,className:{default:U,types:[`object`,`string`],normalize:Ft},renderHeader:{default:null,...q},renderSteps:{default:null,...q},renderBody:{default:null,...q},renderFooter:{default:null,...q},onChange:{default:null,types:[`function`,`null`]},onNext:{default:null,types:[`function`,`null`]},onBack:{default:null,types:[`function`,`null`]},onFinish:{default:null,types:[`function`,`null`]},onError:{default:null,types:[`function`,`null`]},onBusy:{default:null,types:[`function`,`null`]}};function Vt(e){let t=_(e,Bt,`Flow.options`);return{id:t.id,steps:Nt(t.steps),initial:t.initial,cache:t.cache,linear:t.linear,render:t.render,rollbackOnError:t.rollbackOnError,busyStrategy:t.busyStrategy,showHeader:t.showHeader,showFooter:t.showFooter,showSteps:t.showSteps,showBack:t.showBack,showNext:t.showNext,showReset:t.showReset,text:t.text,className:t.className,renderHeader:t.renderHeader,renderSteps:t.renderSteps,renderBody:t.renderBody,renderFooter:t.renderFooter,onChange:t.onChange,onNext:t.onNext,onBack:t.onBack,onFinish:t.onFinish,onError:t.onError,onBusy:t.onBusy}}var Ht=class{constructor(e={}){this.options=Vt(e),this.steps=this.options.steps,this.validateSteps(this.steps),this.stepMap=new Map(this.steps.map((e,t)=>[e.id,t])),this.initialStepId=this.resolveInitialStepId(this.options.initial),this.initialData=this.createInitialStepData(),this.subscribers=new Set,this.renderDispose=null,this.cleanupTasks=new Set,this.nodes={},this.destroyed=!1,this.activeAction=null,this.actionController=null,this.root=null,this.state=(0,t.createDeepStore)({id:this.options.id,currentId:this.initialStepId,currentIndex:this.stepMap.get(this.initialStepId)??0,previousId:null,previousIndex:null,direction:null,history:[this.initialStepId],data:W(this.initialData.global),stepData:W(this.initialData.stepData),loading:!1,error:null,busyAction:null,version:0})}get currentStep(){return this.steps[this.state.currentIndex]}get currentData(){return this.getStepData(this.state.currentId)}get canBack(){return this.state.currentIndex>0&&!this.state.loading}get canNext(){return this.state.currentIndex<this.steps.length-1&&!this.state.loading}get isLast(){return this.state.currentIndex===this.steps.length-1}subscribe(e){if(this.assertActive(`subscribe`),typeof e!=`function`)throw Error(`Flow.subscribe: handler expects a function.`);return this.subscribers.add(e),e(this.snapshot(),this,null),()=>this.subscribers.delete(e)}snapshot(){let e=this.currentStep;return{id:this.state.id,currentId:this.state.currentId,currentIndex:this.state.currentIndex,previousId:this.state.previousId,previousIndex:this.state.previousIndex,direction:this.state.direction,history:[...this.state.history],data:W(this.state.data),stepData:W(this.state.stepData),currentData:this.currentData,currentStep:this.publicStep(e),canBack:this.canBack,canNext:this.canNext,isLast:this.isLast,loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error}}mount(e){if(this.assertActive(`mount`),!this.options.render)return this;let t=D(e,`Flow.mount.container`,`element`);return this.unmount(),this.root=this.buildRoot(),t.appendChild(this.root),this.mountView(),this}unmount(){return this.renderDispose?.(),this.renderDispose=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.nodes={},this}async next(e=null){return this.assertActive(`next`),g(`payload`,e,K,`Flow.next`),this.handleBusy(`next`)||this.runAction(`next`,async()=>{if(this.isLast)return this.finish(e,{internal:!0});let t=this.currentStep,n=this.steps[this.state.currentIndex+1]?.id,{id:r,data:i}=Pt(await this.runMoveHook(`next`,t,e,n),n);return this.goTo(r,i??e,{direction:`next`,internal:!0})})}async back(e=null){return this.assertActive(`back`),g(`payload`,e,K,`Flow.back`),this.handleBusy(`back`)||(this.canBack?this.runAction(`back`,async()=>{let t=this.currentStep,n=this.steps[this.state.currentIndex-1]?.id,{id:r,data:i}=Pt(await this.runMoveHook(`back`,t,e,n),n);return this.goTo(r,i??e,{direction:`back`,internal:!0})}):this.snapshot())}async goTo(e,t=null,n={}){return this.assertActive(`goTo`),g(`payload`,t,K,`Flow.goTo`),(n.internal?null:this.handleBusy(`goTo`))||this.runAction(`goTo`,async()=>{let r=this.resolveStepIndex(e),i=this.steps[r],a=this.currentStep;return!i||i.id===this.state.currentId?(t&&this.setStepData(this.state.currentId,t),this.snapshot()):(await this.transitionTo(i,{direction:n.direction||`go`,payload:t,fromStep:a}),this.snapshot())},{internal:n.internal})}setData(e){return this.assertActive(`setData`),g(`data`,e,K,`Flow.setData`),e?((0,t.flushSync)(()=>{Object.assign(this.state.data,e),this.state.version+=1}),this.emitChange(),this):this}setStepData(e,n,r={}){return this.assertActive(`setStepData`),g(`stepId`,e,{type:`string`},`Flow.setStepData`),g(`data`,n,K,`Flow.setStepData`),!n||!this.stepMap.has(e)?this:((0,t.flushSync)(()=>{this.state.stepData[e]={...W(this.state.stepData[e]),...n},this.options.cache&&Object.assign(this.state.data,n),this.state.version+=1}),r.silent||this.emitChange(),this)}getStepData(e){return W(this.state.stepData[e])}reset(){return this.assertActive(`reset`),(0,t.flushSync)(()=>{this.state.currentId=this.initialStepId,this.state.currentIndex=this.stepMap.get(this.initialStepId)??0,this.state.previousId=null,this.state.previousIndex=null,this.state.direction=null,this.state.history.splice(0,this.state.history.length,this.initialStepId),this.replaceObject(this.state.data,W(this.initialData.global)),this.replaceObject(this.state.stepData,W(this.initialData.stepData)),this.state.loading=!1,this.state.busyAction=null,this.state.error=null,this.state.version+=1}),this.emitChange(),this}async finish(e=null,t={}){return this.assertActive(`finish`),g(`payload`,e,K,`Flow.finish`),(t.internal?null:this.handleBusy(`finish`))||this.runAction(`finish`,async()=>(e&&this.setStepData(this.state.currentId,e),await this.callHook(this.options.onFinish,[this.snapshot(),this]),this.snapshot()),{internal:t.internal})}destroy(){if(!this.destroyed){this.destroyed=!0,this.abortActiveAction(),this.unmount();for(let e of Array.from(this.cleanupTasks))e();this.cleanupTasks.clear(),this.subscribers.clear(),this.steps=[],this.stepMap.clear(),this.activeAction=null,this.actionController=null}}resolveInitialStepId(e){if(typeof e==`number`){let t=this.steps[e];if(!t)throw Error(`Flow.options.initial index is out of range.`);return t.id}if(typeof e==`string`){if(!this.stepMap.has(e))throw Error(`Flow.options.initial step "${e}" does not exist.`);return e}return this.steps[0].id}validateSteps(e){let t=new Set;for(let[n,r]of e.entries()){if(g(String(n),r,It,`Flow.options.steps`),g(`content`,r.content??null,Lt,`Flow.options.steps.${n}`),t.has(r.id))throw Error(`Flow.options.steps: duplicated step id "${r.id}".`);t.add(r.id)}}resolveStepIndex(e){if(typeof e==`number`){if(!this.steps[e])throw Error(`Flow.goTo target is out of range.`);return e}if(typeof e==`string`){let t=this.stepMap.get(e);if(t==null)throw Error(`Flow.goTo target "${e}" does not exist.`);return t}throw Error(`Flow.goTo target expects string or number.`)}createInitialStepData(){let e={},t={};for(let n of this.steps)e[n.id]=W(n.data),Object.assign(t,e[n.id]);return{stepData:e,global:t}}async runMoveHook(e,t,n,r){let i=e===`back`?this.options.onBack:this.options.onNext,a=e===`back`?t.onBack:t.onNext,o=this.createContext({payload:n,targetId:r});if(typeof a==`function`){let e=await this.callHook(a,[o]);if(e!=null)return e}if(typeof i==`function`){let e=await this.callHook(i,[o]);if(e!=null)return e}return r}async transitionTo(e,{direction:n,payload:r,fromStep:i}){let a=this.snapshot(),o=this.captureState();try{r&&this.setStepData(i.id,r,{silent:!0}),await this.assertCanLeave(i,e,n),await this.assertCanEnter(e,i,n),typeof i.onLeave==`function`&&await this.callHook(i.onLeave,[this.createContext({direction:n,step:i,targetId:e.id})]);let o=this.state.currentId,s=this.state.currentIndex,c=this.stepMap.get(e.id)??0;(0,t.flushSync)(()=>{this.state.previousId=o,this.state.previousIndex=s,this.state.currentId=e.id,this.state.currentIndex=c,this.state.direction=n,n===`back`?this.state.history.pop():this.state.history.push(e.id),this.state.error=null,this.state.version+=1}),typeof e.onEnter==`function`&&await this.callHook(e.onEnter,[this.createContext({direction:n,fromId:o,step:e})]),this.emitChange(a)}catch(e){throw this.destroyed?e:(this.options.rollbackOnError&&this.restoreState(o,{keepLoading:!0}),this.handleError(e,a),e)}}async assertCanLeave(e,t,n){if(typeof e.canLeave==`function`&&await this.callHook(e.canLeave,[this.createContext({direction:n,targetId:t.id})])===!1)throw Error(`Flow: step "${e.id}" blocked leaving.`)}async assertCanEnter(e,t,n){if(typeof e.canEnter==`function`&&await this.callHook(e.canEnter,[this.createContext({direction:n,fromId:t.id})])===!1)throw Error(`Flow: step "${e.id}" blocked entering.`)}createContext(e={}){let t=e.step||this.currentStep,n=this.snapshot();return{...e,flow:this,step:t,state:this.state,signal:this.actionController?.signal||null,snapshot:n,data:W(this.state.data),currentData:this.getStepData(t.id),setData:e=>this.setData(e),setStepData:(e,t)=>this.setStepData(e,t),getStepData:e=>this.getStepData(e),next:e=>this.next(e),back:e=>this.back(e),goTo:(e,t,n)=>this.goTo(e,t,n),addCleanup:e=>this.addCleanup(e)}}async runAction(e,t,n={}){let r=!n.internal&&!this.state.loading;r&&(this.actionController=typeof AbortController<`u`?new AbortController:null,this.activeAction=e,this.setLoading(!0,e));try{return await t()}catch(e){if(this.destroyed)return null;throw this.state.error!==e&&this.handleError(e),e}finally{r&&!this.destroyed&&(this.setLoading(!1,null),this.activeAction=null,this.actionController=null)}}handleBusy(e){if(!this.state.loading)return null;let t=Error(`Flow: action "${e}" ignored while loading.`);if(t.code=`FLOW_BUSY`,typeof this.options.onBusy==`function`&&this.options.onBusy(e,this.snapshot(),this),this.options.busyStrategy===`throw`)throw t;return this.snapshot()}abortActiveAction(){this.actionController?.abort(),this.actionController=null,this.activeAction=null}async callHook(e,t){if(typeof e!=`function`)return;let n=await e(...t);if(this.destroyed)throw this.createAbortError();return n}createAbortError(){let e=Error(`Flow: active action was aborted.`);return e.code=`FLOW_ABORTED`,e}setLoading(e,n=this.state.busyAction){(0,t.flushSync)(()=>{this.state.loading=e,this.state.busyAction=e?n:null})}handleError(e,n=null){(0,t.flushSync)(()=>{this.state.error=e,this.state.version+=1}),typeof this.options.onError==`function`&&this.options.onError(e,this.snapshot(),this,n)}emitChange(e=null){let t=this.snapshot();for(let n of Array.from(this.subscribers))n(t,this,e);typeof this.options.onChange==`function`&&this.options.onChange(t,this,e)}replaceObject(e,t){for(let t of Object.keys(e))delete e[t];Object.assign(e,t)}captureState(){return{currentId:this.state.currentId,currentIndex:this.state.currentIndex,previousId:this.state.previousId,previousIndex:this.state.previousIndex,direction:this.state.direction,history:Mt(this.state.history),data:W(this.state.data),stepData:W(this.state.stepData),loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error,version:this.state.version}}restoreState(e,n={}){(0,t.flushSync)(()=>{this.state.currentId=e.currentId,this.state.currentIndex=e.currentIndex,this.state.previousId=e.previousId,this.state.previousIndex=e.previousIndex,this.state.direction=e.direction,this.state.history.splice(0,this.state.history.length,...e.history),this.replaceObject(this.state.data,e.data),this.replaceObject(this.state.stepData,e.stepData),this.state.loading=n.keepLoading?!0:e.loading,this.state.busyAction=e.busyAction,this.state.error=e.error,this.state.version=e.version+1})}addCleanup(e){if(typeof e!=`function`)throw Error(`Flow.addCleanup: cleanup expects a function.`);return this.destroyed?(e(),()=>{}):(this.cleanupTasks.add(e),()=>this.cleanupTasks.delete(e))}assertActive(e){if(this.destroyed)throw Error(`Flow.${e}: instance has been destroyed.`)}publicStep(e){if(!e)return null;let{onEnter:t,onLeave:n,onNext:r,onBack:i,canEnter:a,canLeave:o,...s}=e;return s}buildRoot(){return(0,t.jsx)(`div`,{className:this.options.className.root,id:this.options.id,role:`group`,"data-flow":`root`,"aria-busy":()=>this.state.loading?`true`:`false`,"aria-labelledby":`${this.options.id}-title`,ref:e=>{this.nodes.root=e}})}mountView(){this.renderDispose||!this.root||(this.renderDispose=(0,t.createRoot)(e=>((0,t.onCleanup)((0,t.render)(()=>this.view(),this.root)),e)))}view(){let e=this.snapshot();return[this.renderSlot(`renderHeader`,e,()=>this.options.showHeader?this.headerView(e):null),this.renderSlot(`renderSteps`,e,()=>this.options.showSteps?this.stepsView(e):null),this.renderSlot(`renderBody`,e,()=>this.bodyView(e)),this.renderSlot(`renderFooter`,e,()=>this.options.showFooter?this.footerView(e):null)]}renderSlot(e,t,n){let r=this.options[e];return r===!1?null:typeof r==`function`?r(this.createRenderContext(t,n)):n()}createRenderContext(e,t){return{flow:this,snapshot:e,state:this.state,steps:this.steps.map(e=>this.publicStep(e)),currentStep:e.currentStep,currentData:e.currentData,data:e.data,fallback:t,next:e=>this.next(e),back:e=>this.back(e),goTo:(e,t,n)=>this.goTo(e,t,n),reset:()=>this.reset()}}headerView(e){return(0,t.jsx)(`div`,{className:this.options.className.header,"data-flow-header":``,children:[(0,t.jsx)(`div`,{id:`${this.options.id}-title`,className:this.options.className.title,"data-flow-title":``,children:e.currentStep?.title||e.currentStep?.id||``}),e.currentStep?.description?(0,t.jsx)(`div`,{className:this.options.className.description,"data-flow-description":``,children:e.currentStep.description}):null]})}stepsView(e){return(0,t.jsx)(`ol`,{className:this.options.className.steps,"data-flow-steps":``,role:`list`,"aria-label":`Flow steps`,children:this.steps.map((n,r)=>(0,t.jsx)(`li`,{className:this.stepClass(r,e.currentIndex),"data-flow-step":n.id,"data-flow-step-index":String(r),"aria-current":r===e.currentIndex?`step`:void 0,children:[(0,t.jsx)(`button`,{type:`button`,className:this.options.className.stepButton,disabled:this.options.linear&&r>e.currentIndex,"aria-current":r===e.currentIndex?`step`:void 0,"aria-disabled":this.options.linear&&r>e.currentIndex?`true`:`false`,"aria-label":`${r+1}. ${n.title||n.id}`,"data-flow-step-action":`goTo`,onClick:()=>{r!==e.currentIndex&&this.goTo(r)},children:[(0,t.jsx)(`span`,{className:this.options.className.stepIndex,"data-flow-step-number":``,children:r+1}),(0,t.jsx)(`span`,{className:this.options.className.stepTitle,"data-flow-step-title":``,children:n.title||n.id})]})]}))})}bodyView(e){return(0,t.jsx)(`div`,{className:this.options.className.body,"data-flow-body":``,role:`region`,"aria-live":`polite`,"aria-busy":e.loading?`true`:`false`,children:this.contentView(this.currentStep.content)})}footerView(e){let n=G(this.options.className.button,this.options.className.buttonGhost),r=G(this.options.className.button,this.options.className.buttonPrimary);return(0,t.jsx)(`div`,{className:this.options.className.footer,"data-flow-footer":``,children:[this.options.showReset?(0,t.jsx)(`button`,{type:`button`,className:G(n,this.options.className.reset),"data-action":`reset`,onClick:()=>this.reset(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:this.options.text.reset}):null,this.options.showBack?(0,t.jsx)(`button`,{type:`button`,className:G(n,this.options.className.back),"data-action":`back`,onClick:()=>void this.back(),disabled:!e.canBack,"aria-disabled":e.canBack?`false`:`true`,children:this.options.text.back}):null,this.options.showNext?(0,t.jsx)(`button`,{type:`button`,className:G(r,this.options.className.next),"data-action":`next`,onClick:()=>void this.next(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:e.isLast?this.options.text.finish:this.options.text.next}):null]})}contentView(e){return typeof e==`function`?e(this.createContext()):e??``}stepClass(e,t=this.state.currentIndex){return G(this.options.className.step,e===t&&this.options.className.active,e<t&&this.options.className.complete)}};function Ut(e={}){return new Ht(e)}let Wt={color:`var(--primary, #3e63dd)`,size:`10px`},Gt={ball:`parabola-ball`},Kt={validate:e=>e==null||typeof e==`string`||Array.isArray(e)||S(e),message:`expects Element, Node, selector or JSX node.`},qt={ball:{default:Wt,type:`object`,normalize:e=>({...Wt,...e&&typeof e==`object`?e:{}}),validate:e=>!!e&&typeof e==`object`&&typeof e.color==`string`&&typeof e.size==`string`,message:`expects an object with two string properties: "color" and "size".`},className:{default:Gt,type:`object`,normalize:e=>({...Gt,...e&&typeof e==`object`?e:{}})},from:{default:null,...Kt},to:{default:null,...Kt},direction:{default:`center`,type:`string`,enum:[`center`,`top-right`,`top-left`,`bottom-right`,`bottom-left`]},showDelay:{default:0,type:`number`},hideDelay:{default:0,type:`number`},onShow:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function Jt(e){let t=_(e,qt,`Parabola.options`);return{ball:t.ball,className:t.className,from:t.from,to:t.to,direction:t.direction,showDelay:t.showDelay,hideDelay:t.hideDelay,onShow:t.onShow,onHidden:t.onHidden}}var Yt=class{constructor(e={}){this.options=Jt(e),this.hidden=!1,this._ball=null,this._animationId=null,this._fromEl=E(this.options.from),this._toEl=E(this.options.to),this.showTimerId=null,this.createBall()}createBall(){if(this.hidden||this._ball)return;let{color:e,size:n}=this.options.ball;this._ball=(0,t.jsx)(`div`,{className:this.options.className.ball,"data-parabola":`ball`,style:{backgroundColor:e,width:n,height:n,position:`fixed`,borderRadius:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,zIndex:`9999`,opacity:`1`}}),document.body.appendChild(this._ball)}calculatePath(){let e=this._fromEl?.getBoundingClientRect(),t=this._toEl?.getBoundingClientRect();if(!e||!t)return null;let{left:n,top:r,width:i,height:a}=e,{left:o,top:s,width:c,height:l}=t,u,d;switch(this.options.direction){case`top-left`:u=n+i*.2,d=r+a*.2;break;case`top-right`:u=n+i*.8,d=r+a*.2;break;case`bottom-left`:u=n+i*.2,d=r+a*.8;break;case`bottom-right`:u=n+i*.8,d=r+a*.8;break;default:u=n+i/2,d=r+a/2}let f=o+c/2,p=s+l/2;return{startX:u,startY:d,endX:f,endY:p}}easeOutCubic(e){return 1-(1-e)**3}animate(e,t,n,r,i=800){if(this.hidden||!this._ball)return;let a=performance.now(),o=n-e,s=r-t,c=n=>{if(this.hidden||!this._ball)return;let r=n-a,l=Math.min(r/i,1),u=this.easeOutCubic(l),d=e+o*u,f=t+-100*Math.sin(Math.PI*u)+s*u,p=1-l;this._ball.style.left=`${d}px`,this._ball.style.top=`${f}px`,this._ball.style.opacity=`${p}`,this._ball.style.transform=`translate(-50%, -50%) scale(${1-u*.3})`,l<1?this._animationId=requestAnimationFrame(c):this.destroy()};this._animationId=requestAnimationFrame(c)}show(){return this.hidden?Promise.resolve(!1):new Promise(e=>{this.showTimerId=setTimeout(()=>{if(this.showTimerId=null,this.hidden||!this._ball){e(!1);return}let t=this.calculatePath();if(!t){this.destroy(),e(!1);return}this._ball.style.left=`${t.startX}px`,this._ball.style.top=`${t.startY}px`,this.options.onShow?.(this),this.animate(t.startX,t.startY,t.endX,t.endY),e(!0)},this.options.showDelay)})}destroy(){this.hidden||(this._ball?.remove(),this.showTimerId&&(clearTimeout(this.showTimerId),this.showTimerId=null),this._animationId&&cancelAnimationFrame(this._animationId),this._ball=null,this._fromEl=null,this._toEl=null,this._animationId=null,this.hidden=!0,this.options.onHidden?.(this))}start(){return this.show()}};function Xt(e={}){return new Yt(e)}let Zt={root:`j-tabs`,top:`is-top`,bottom:`is-bottom`,left:`is-left`,right:`is-right`,wrap:`tab-wrap`,list:`tab-list`,tab:`tab-item`,panelWrap:`tab-panel`,panel:`panel-item`,active:`is-active`,disabled:`is-disabled`,dragging:`dragging`},Qt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},direction:{default:`top`,type:`string`,enum:[`top`,`bottom`,`left`,`right`]},active:{default:0,types:[`number`,`string`]},disabled:{default:[],types:[`number`,`string`,`array`]},onChange:{default:null,types:[`function`,`null`]},tabs:{default:[],type:`array`},className:{default:Zt,type:`object`,normalize:e=>({...Zt,...e&&typeof e==`object`?e:{}})},onAdd:{default:null,types:[`function`,`null`]},onRemove:{default:null,types:[`function`,`null`]}},$t={type:`object`,validate:e=>{let t=e;return!!t&&typeof t==`object`&&O(t.title)&&O(t.panel)},message:`expects an object with renderable title and panel: string, Node, array, function or null.`};function en(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function tn(e){return typeof e==`number`&&e>0?e:0}function nn(e){let t=_(e,Qt,`Tabs`);return{id:t.id,direction:t.direction,active:t.active,disabled:t.disabled,onChange:t.onChange,tabs:en(t.tabs),className:t.className,onAdd:t.onAdd,onRemove:t.onRemove}}function rn(...e){return e.filter(Boolean).join(` `)}var an=class extends P{constructor(e,n={}){let r=D(e,`Tabs`),i=nn(n);super(i),this.dom.container=r,this.dom.tabs=[],this.dom.panels=[],this.bindingsDispose=null,this.isDragging=!1,this.raf=0,this.resizeRaf=0,this.velocity=0,this.state=(0,t.createDeepStore)({current:{index:-1,name:null},disabled:this.parseDisabled(i.disabled),isVertical:i.direction===`left`||i.direction===`right`,draggable:!1,loading:!1}),this.runtime.cache={panels:new Map},this.runtime.panelLoadId=0;try{this.onInit(i)}catch(e){throw this.destroy(),e}}onInit(e){this.root=this.buildRoot(e),this.rebuildItems(),this.activateInternal(e.active,!1),this.bindEvents(),this.initDrag()}buildRoot(e){let{id:n,direction:r,className:i}=e,a=(0,t.jsx)(`nav`,{className:i.list,"data-tabs-list":``}),o=(0,t.jsx)(`div`,{className:i.wrap,"data-tabs-wrap":``,children:a}),s=(0,t.jsx)(`div`,{className:i.panelWrap,"data-tabs-panel-wrap":``});return(0,t.jsx)(`div`,{className:rn(i.root,i[r]),id:n,"data-tabs":`root`,"data-tabs-direction":r,children:[o,s]})}rebuildItems(){if(!this.root)return;let e=A(`[data-tabs-list]`,this.root),n=A(`[data-tabs-panel-wrap]`,this.root);if(!e||!n)return;e.textContent=``,n.textContent=``,this.dom.tabs=[],this.dom.panels=[];let r=document.createDocumentFragment(),i=document.createDocumentFragment();this.props.tabs.forEach((e,n)=>{let a=e.name||v(),o=(0,t.jsx)(`div`,{className:this.props.className.tab,"data-tabs-tab":a,role:`tab`,children:w(e.title,{tabs:this,item:e})});this.dom.tabs.push(o);let s=(0,t.jsx)(`div`,{className:this.props.className.panel,"data-tabs-panel":a,role:`tabpanel`});this.dom.panels.push(s),typeof e.panel!=`function`&&s.append(...w(e.panel,{tabs:this,item:e,index:n,name:a})),r.append(o),i.append(s)}),e.append(r),n.append(i),this.bindingsDispose?.(),this.bindingsDispose=(0,t.createRoot)(e=>(this.dom.tabs.forEach((e,n)=>{let r=e.dataset.tabsTab||``;(0,t.bindClass)(e,this.props.className.active,()=>this.state.current.index===n),(0,t.bindClass)(e,this.props.className.disabled,()=>this.state.disabled.names.includes(r)),(0,t.bindAttr)(e,`aria-selected`,()=>this.state.current.index===n),(0,t.bindAttr)(e,`aria-disabled`,()=>this.state.disabled.names.includes(r))}),this.dom.panels.forEach((e,n)=>{(0,t.bindClass)(e,this.props.className.active,()=>this.state.current.index===n),(0,t.bindAttr)(e,`aria-hidden`,()=>this.state.current.index!==n)}),e))}parseDisabled(e){if(e==null)return{names:[],indexes:[]};let t=e=>typeof e==`number`?this.props.tabs[e]?.name||null:typeof e==`string`?e:null,n=Array.isArray(e)?e.map(t).filter(e=>!!e):(()=>{let n=t(e);return n?[n]:[]})();return this.createDisabledState(n)}createDisabledState(e){let t=Array.from(new Set(e));return{names:t,indexes:t.map(e=>this.props.tabs.findIndex(t=>t.name===e)).filter(e=>e>=0)}}syncCurrent(e){this.state.current={index:e,name:e>=0&&e<this.dom.tabs.length&&this.dom.tabs[e]?.dataset.tabsTab||null}}getPanelKey(e,t){return e.name||this.dom.tabs[t]?.dataset.tabsTab||String(t)}getCachedPanel(e,t){if(!e.cache)return null;let n=this.getPanelKey(e,t),r=this.runtime.cache.panels.get(n);if(!r)return null;let i=tn(e.ttl);return i&&Date.now()-r.updatedAt>i?(this.runtime.cache.panels.delete(n),null):r}setCachedPanel(e,t,n){e.cache&&this.runtime.cache.panels.set(this.getPanelKey(e,t),{content:n,updatedAt:Date.now()})}renderPanelContent(e,t){let n=this.dom.panels[e],r=this.props.tabs[e];!n||!r||(n.textContent=``,n.append(...w(t,{tabs:this,item:r,index:e,name:this.dom.tabs[e]?.dataset.tabsTab||r.name||e})))}async loadPanel(e){let n=this.props.tabs[e],r=this.dom.panels[e];if(!n||!r||typeof n.panel!=`function`){this.runtime.panelLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1});return}let i=this.getCachedPanel(n,e);if(i){this.runtime.panelLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1}),this.renderPanelContent(e,i.content);return}let a=++this.runtime.panelLoadId;(0,t.flushSync)(()=>{this.state.loading=!0}),r.setAttribute(`aria-live`,`polite`),r.setAttribute(`aria-busy`,`true`),r.textContent=``,r.appendChild(k());try{let t=await Promise.resolve(n.panel({tabs:this,item:n,index:e,name:this.dom.tabs[e]?.dataset.tabsTab||n.name||e}));if(this.runtime.destroyed||a!==this.runtime.panelLoadId)return;this.setCachedPanel(n,e,t),this.renderPanelContent(e,t)}finally{!this.runtime.destroyed&&a===this.runtime.panelLoadId&&((0,t.flushSync)(()=>{this.state.loading=!1}),r.setAttribute(`aria-busy`,`false`))}}get activeIndex(){return this.state.current.index}get disabledNames(){return this.state.disabled.names}bindEvents(){if(this.unbindEvents(),!this.root)return;let e=A(`[data-tabs-list]`,this.root);e&&this.cleanup.events.on(`tabClick`,e,`click`,t=>{if(!(t.target instanceof Element))return;let n=t.target.closest(`[data-tabs-tab]`);if(!n||!e.contains(n))return;let r=n.dataset.tabsTab;r&&!this.state.disabled.names.includes(r)&&this.activate(r)})}unbindEvents(){this.cleanup.events.clear()}assertActive(e){if(this.runtime.destroyed)throw Error(`Tabs.${e}: instance has been destroyed.`)}getIndex(e){return typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tabsTab===e):-1}async activateInternal(e,n=!0){let r=this.getIndex(e),i=this.dom.tabs[r]?.dataset.tabsTab||``;if(!(r<0||r>=this.dom.tabs.length||this.state.disabled.names.includes(i)||this.state.current.index===r)&&((0,t.flushSync)(()=>{this.syncCurrent(r)}),await this.loadPanel(r),n&&this.props.onChange)){let e=this.dom.tabs[r],t=this.dom.panels[r];await Promise.resolve(this.props.onChange(r,e?.dataset.tabsTab||r,e,t))}}async activate(e){this.assertActive(`activate`),await this.activateInternal(e,!0)}build(){return this.assertActive(`build`),(0,t.insert)(this.dom.container,()=>this.root),this}render(){return this.build()}async add(e){this.assertActive(`add`),g(`tabConfig`,e,$t,`Tabs.add`),e.name=e.name||v(),this.props.tabs=[...en(this.props.tabs),e],this.runtime.cache.panels.clear(),this.rebuildItems(),this.syncActiveNames(this.resolveActiveIndex(this.props.active)),this.bindEvents(),this.refreshDrag();let{onAdd:t}=this.props;if(t){let n=this.props.tabs.length-1;await Promise.resolve(t(n,e,this.dom.tabs[n],this.dom.panels[n]))}}async delete(e){if(this.assertActive(`delete`),this.props.tabs.length<=1)return;let n=this.getIndex(e);if(n<0||n>=this.props.tabs.length)return;let r=this.props.tabs[n].name,{onRemove:i}=this.props;this.props.tabs=this.props.tabs.filter((e,t)=>t!==n),r&&this.runtime.cache.panels.delete(r),this.state.current.index>=this.props.tabs.length?(0,t.flushSync)(()=>{this.syncCurrent(this.props.tabs.length-1)}):this.state.current.index>n&&(0,t.flushSync)(()=>{this.syncCurrent(this.state.current.index-1)}),this.rebuildItems(),this.bindEvents(),await this.loadPanel(this.state.current.index),this.refreshDrag(),i&&await Promise.resolve(i(n,r))}disable(e){this.assertActive(`disable`);let n=typeof e==`number`?this.dom.tabs[e]?.dataset.tabsTab:e;n&&!this.state.disabled.names.includes(n)&&(0,t.flushSync)(()=>{this.state.disabled=this.createDisabledState([...this.state.disabled.names,n])})}enable(e){this.assertActive(`enable`);let n=typeof e==`number`?this.dom.tabs[e]?.dataset.tabsTab:e;n&&(0,t.flushSync)(()=>{this.state.disabled=this.createDisabledState(this.state.disabled.names.filter(e=>e!==n))})}resolveActiveIndex(e){return e==null?-1:typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tabsTab===e):0}syncActiveNames(e){(0,t.flushSync)(()=>{this.syncCurrent(e)})}async reInit(e={}){this.assertActive(`reInit`),Object.assign(this.props,nn({...this.props,...e,className:{...this.props.className,...e.className}})),(0,t.flushSync)(()=>{this.state.disabled=this.parseDisabled(this.props.disabled)}),this.rebuildItems(),this.syncActiveNames(this.resolveActiveIndex(this.props.active)),this.bindEvents(),await this.loadPanel(this.state.current.index),this.refreshDrag()}get dragContainer(){return this.root?A(`[data-tabs-wrap]`,this.root):null}get dragInner(){return this.root?A(`[data-tabs-list]`,this.root):null}initDrag(){let{direction:e}=this.props,n=this.dragContainer,r=this.dragInner;if(!n||!r)return;let i=e===`left`||e===`right`,a=i?r.scrollHeight>n.clientHeight+5:r.scrollWidth>n.clientWidth+5;if((0,t.flushSync)(()=>{this.state.isVertical=i,this.state.draggable=a}),!a){this.removeDragEvents();return}this.bindDragEvents(),this.cleanup.events.on(`resize`,window,`resize`,()=>{cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>{this.refreshDrag()})})}bindDragEvents(){this.removeDragEvents();let e=this.dragContainer,t=this.dragInner;if(!e||!t)return;let n=this.state.isVertical,r=0,i=0,a=0,o=!1,s=e=>{if(`touches`in e){let t=e.touches[0]||e.changedTouches[0];return n?t.pageY:t.pageX}return n?e.pageY:e.pageX},c=o=>{!(o instanceof MouseEvent)&&!(o instanceof TouchEvent)||(this.isDragging=!0,t.classList.add(this.props.className.dragging),r=s(o),a=r,i=n?e.scrollTop:e.scrollLeft,this.velocity=0,cancelAnimationFrame(this.raf))},l=t=>{if(!this.isDragging||!(t instanceof MouseEvent)&&!(t instanceof TouchEvent))return;t.preventDefault();let c=s(t),l=r-c;this.velocity=a-c,a=c,o||(o=!0,requestAnimationFrame(()=>{o=!1,n?e.scrollTop=i+l:e.scrollLeft=i+l}))},u=()=>{this.isDragging&&(this.isDragging=!1,t.classList.remove(this.props.className.dragging),this.startInertiaScroll())};this.cleanup.events.on(`drag:mousedown`,t,`mousedown`,c),this.cleanup.events.on(`drag:touchstart`,t,`touchstart`,c,{passive:!0}),this.cleanup.events.on(`drag:mousemove`,window,`mousemove`,l,{passive:!1}),this.cleanup.events.on(`drag:touchmove`,window,`touchmove`,l,{passive:!1}),this.cleanup.events.on(`drag:mouseup`,window,`mouseup`,u),this.cleanup.events.on(`drag:touchend`,window,`touchend`,u)}startInertiaScroll(){let e=this.dragContainer;if(!e)return;let t=this.velocity,n=this.state.isVertical,r=performance.now(),i=a=>{let o=a-r;r=a,t*=.92,!(Math.abs(t)<.3)&&(n?e.scrollTop+=t*o*.05:e.scrollLeft+=t*o*.05,this.raf=requestAnimationFrame(i))};this.raf=requestAnimationFrame(i)}removeDragEvents(){this.cleanup.events.off(`drag:mousedown`),this.cleanup.events.off(`drag:touchstart`),this.cleanup.events.off(`drag:mousemove`),this.cleanup.events.off(`drag:touchmove`),this.cleanup.events.off(`drag:mouseup`),this.cleanup.events.off(`drag:touchend`)}refreshDrag(){this.initDrag()}onDestroy(){this.unbindEvents(),this.removeDragEvents(),this.bindingsDispose?.(),this.bindingsDispose=null,cancelAnimationFrame(this.raf),cancelAnimationFrame(this.resizeRaf),this.cleanup.events.off(`resize`),this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function on(e,t={}){return new an(e,t)}let sn={root:`j-accordion`,header:`accordion-header`,title:`header-title`,arrow:`header-arrow`,panel:`accordion-panel`,content:`panel-content`,active:`is-active`},cn={type:`array`,validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty array.`},ln={types:[`number`,`string`,`array`,`null`],validate:e=>e==null?!0:Array.isArray(e)?e.every(e=>typeof e==`number`||typeof e==`string`):typeof e==`number`?Number.isInteger(e)&&e>=0:typeof e==`string`&&e.trim().length>0,message:`expects a positive number, string, array or null.`},un={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},active:{default:0,...ln},collapsible:{default:!1,type:`boolean`},multiple:{default:!1,type:`boolean`},className:{default:sn,type:`object`,normalize:e=>({...sn,...e&&typeof e==`object`?e:{}})},onChange:{default:null,types:[`function`,`null`]},items:{default:[],type:`array`}};function dn(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function fn(e){let t=_(e,un,`Accordion`);return{id:t.id,active:t.active,collapsible:t.collapsible,multiple:t.multiple,className:t.className,items:dn(t.items),onChange:t.onChange}}function pn(e){return g(`items`,e,cn,`Accordion`),e.map(e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Accordion: item expects an object.`);if(e.name!=null&&typeof e.name!=`string`)throw Error(`Accordion: item name expects a string.`);if(!O(e.title))throw Error(`Accordion: item title expects string, Node, array, function or null.`);if(!O(e.content))throw Error(`Accordion: item content expects string, Node, array, function or null.`);return{...e,name:e.name||v()}})}var mn=class extends P{constructor(e,n={}){let r=D(e,`Accordion`),i=fn(n);super(i),this.dom.container=r,this.dom.headers=[],this.dom.panels=[],this.bindingsDispose=null,this.state=(0,t.createDeepStore)({activeNames:[],current:{index:null,name:null}});try{this.onInit(i)}catch(e){throw this.destroy(),e}}onInit(e){this.root=this.buildRoot(e),this.buildItems(e),this.syncActiveNames(this.resolveActiveNames(e.active)),this.bindEvents()}buildRoot(e){return(0,t.jsx)(`div`,{className:e.className.root,id:e.id,"data-accordion":`root`})}buildItems(e){let n=pn(e.items),r=document.createDocumentFragment();this.dom.headers=[],this.dom.panels=[],n.forEach((n,i)=>{let a=n.name||v(),o=`${e.id}_header_${i}`,s=`${e.id}_panel_${i}`,c=(0,t.jsx)(`div`,{className:e.className.header,"data-accordion-header":a,id:o,role:`button`,tabindex:`0`,"aria-controls":s,children:[(0,t.jsx)(`span`,{className:e.className.title,"data-accordion-title":a,children:this.contentView(n,i,`title`)}),(0,t.jsx)(`span`,{className:e.className.arrow,"data-accordion-arrow":a,"aria-hidden":`true`,children:x(`arrow-down`)})]}),l=(0,t.jsx)(`div`,{className:e.className.panel,"data-accordion-panel":a,id:s,role:`region`,"aria-labelledby":o,children:(0,t.jsx)(`div`,{className:e.className.content,"data-accordion-content":a,children:this.contentView(n,i,`content`)})});this.dom.headers.push(c),this.dom.panels.push(l),r.append(c,l)}),this.root?.append(r),this.bindingsDispose?.(),this.bindingsDispose=(0,t.createRoot)(e=>(this.dom.headers.forEach(e=>{let n=e.dataset.accordionHeader||``;(0,t.bindClass)(e,this.props.className.active,()=>this.state.activeNames.includes(n)),(0,t.bindAttr)(e,`aria-expanded`,()=>this.state.activeNames.includes(n))}),this.dom.panels.forEach((e,n)=>{let r=this.dom.headers[n]?.dataset.accordionHeader||``;(0,t.bindClass)(e,this.props.className.active,()=>this.state.activeNames.includes(r)),(0,t.bindAttr)(e,`aria-hidden`,()=>this.state.activeNames.includes(r)?`false`:`true`),(0,t.bindAttr)(e,`hidden`,()=>!this.state.activeNames.includes(r))}),e))}contentView(e,t,n){return w(n===`title`?e.title:e.content,{accordion:this,item:e,index:t,type:n,active:!1})}resolveActiveNames(e){if(e==null)return[];let t=Array.isArray(e)?e:[e],n=[];for(let e of t){let t=this.getIndex(e);if(!(t<0||t>=this.dom.headers.length)&&(n.push(this.dom.headers[t].dataset.accordionHeader||String(t)),!this.props.multiple))break}return Array.from(new Set(n))}syncActiveNames(e){let n=e[0]||null,r=n?this.getIndex(n):null;(0,t.flushSync)(()=>{this.state.activeNames=e,this.state.current={index:r,name:n}})}bindEvents(){this.unbindEvents(),this.root&&(this.cleanup.events.on(`click`,this.root,`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-accordion-header]`);!t||!this.root?.contains(t)||this.active(t.dataset.accordionHeader)}),this.cleanup.events.on(`keydown`,this.root,`keydown`,e=>{if(!(e instanceof KeyboardEvent)||e.key!==`Enter`&&e.key!==` `||!(e.target instanceof Element))return;let t=e.target.closest(`[data-accordion-header]`);!t||!this.root?.contains(t)||(e.preventDefault(),this.active(t.dataset.accordionHeader))}))}unbindEvents(){this.cleanup.events.clear()}isActive(e){return this.state.activeNames.includes(e)}assertActive(e){if(this.runtime.destroyed)throw Error(`Accordion.${e}: instance has been destroyed.`)}async activateItem(e,t=!0){let n=this.getIndex(e);if(n<0||n>=this.dom.headers.length)return;let r=this.dom.headers[n],i=this.dom.panels[n],a=r.dataset.accordionHeader||String(n),o=this.isActive(a);if(o&&!this.props.multiple&&!this.props.collapsible)return;let s;s=this.props.multiple?o?this.state.activeNames.filter(e=>e!==a):[...this.state.activeNames,a]:o?this.props.collapsible?[]:this.state.activeNames:[a],this.syncActiveNames(s),t&&this.props.onChange&&await Promise.resolve(this.props.onChange(n,a,r,i,this))}getIndex(e){return typeof e==`number`?e:typeof e==`string`?this.dom.headers.findIndex(t=>t.dataset.accordionHeader===e):-1}async active(e){this.assertActive(`active`),await this.activateItem(e,!0)}build(){return this.assertActive(`build`),(0,t.insert)(this.dom.container,()=>this.root),this}render(){return this.build()}setItems(e,t=0){return this.assertActive(`setItems`),g(`items`,e,cn,`Accordion.setItems`),g(`active`,t,ln,`Accordion.setItems`),this.props.items=dn(pn(e)),this.props.active=t,this.root&&(this.root.textContent=``),this.buildItems(this.props),this.syncActiveNames(this.resolveActiveNames(t)),this.bindEvents(),this}onDestroy(){this.unbindEvents(),this.bindingsDispose?.(),this.bindingsDispose=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function hn(e,t={}){return new mn(e,t)}let gn={root:`j-drop`,container:`drop-container`,active:`is-active`},_n={name:{default:null,types:[`string`,`null`]},mode:{default:`click`,type:`string`,enum:[`hover`,`click`]},position:{default:`auto`,type:`string`,enum:[`auto`,`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`left`,`right`]},offset:{default:10,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},content:{default:``,validate:O,message:`expects string, Node, array, function or null.`},className:{default:gn,type:`object`,normalize:e=>({...gn,...e&&typeof e==`object`?e:{}})},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},containerClassName:{default:null,types:[`string`,`null`]},delay:{default:0,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`},onShown:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function vn(e){let t=_(e,_n,`Drop`);return{name:t.name,mode:t.mode,position:t.position,offset:t.offset,content:t.content,className:t.className,id:t.id,containerClassName:t.containerClassName,delay:t.delay,hoverIntent:t.hoverIntent,onShown:t.onShown,onHidden:t.onHidden}}function yn(...e){return e.filter(Boolean).join(` `)}function bn(e){return typeof e==`number`&&e>=0?{show:e,hide:e}:typeof e==`object`&&e?{show:Number(e.show)||0,hide:Number(e.hide)||0}:{show:0,hide:0}}var xn=class{constructor(e,t={}){this.target=E(e),this.props=vn(t),this.root=null,this.isVisible=!1,this.cleanup=null,this.delayShow=0,this.delayHide=0,this.timer={show:null,hide:null},this.hoverIntentData={x:0,y:0,lastMoveTime:0},this.lastX=0,this.lastY=0,this.init(this.props)}init(e){this.cleanup={events:M()};let t=bn(e.delay);this.delayShow=t.show,this.delayHide=t.hide,this.buildDrop(e),this.bindEvents(e)}buildDrop(e){let{className:n,content:r,id:i,name:a,containerClassName:o}=e,s=S(r)&&r.nodeType===Node.ELEMENT_NODE?r:(0,t.jsx)(`div`,{className:yn(n.container,o),"data-drop-container":a||i,children:w(r,this)});this.root=(0,t.jsx)(`div`,{className:n.root,id:i,"data-drop":a||v(),children:s})}bindEvents(e){let{mode:t,hoverIntent:n}=e;this.unbindEvents(),!(!this.target||!this.cleanup)&&(t===`hover`?n?(this.cleanup.events.on(`target:enter`,this.target,`mouseenter`,()=>this.startHoverIntent()),this.cleanup.events.on(`target:leave`,this.target,`mouseleave`,()=>this.cancelHoverIntent())):(this.cleanup.events.on(`target:enter`,this.target,`mouseenter`,()=>this.show()),this.cleanup.events.on(`target:leave`,this.target,`mouseleave`,()=>this.hide())):(this.cleanup.events.on(`target:click`,this.target,`click`,()=>this.toggle()),this.cleanup.events.on(`document:click`,document,`click`,e=>this.docClick(e))))}bindRootEvents(){!this.root||this.props?.mode!==`hover`||!this.cleanup||(this.cleanup.events.on(`root:enter`,this.root,`mouseenter`,()=>this.show()),this.cleanup.events.on(`root:leave`,this.root,`mouseleave`,()=>this.hide()))}unbindRootEvents(){this.cleanup?.events.off(`root:enter`),this.cleanup?.events.off(`root:leave`)}unbindEvents(){this.cleanup?.events.clear()}startHoverIntent(){this.cleanup&&(this.cleanup.events.on(`document:mousemove`,document,`mousemove`,e=>this.onMouseMove(e)),this.timer.show&&clearTimeout(this.timer.show),this.timer.show=setTimeout(()=>{let e=Date.now()-this.hoverIntentData.lastMoveTime;Math.abs(this.hoverIntentData.x-this.lastX)+Math.abs(this.hoverIntentData.y-this.lastY)<5||e>100?(this.show(),this.cleanup?.events.off(`document:mousemove`)):this.startHoverIntent()},this.delayShow))}cancelHoverIntent(){this.timer.show&&clearTimeout(this.timer.show),this.cleanup?.events.off(`document:mousemove`),this.hide()}onMouseMove(e){e instanceof MouseEvent&&(this.lastX=e.clientX,this.lastY=e.clientY,this.hoverIntentData.lastMoveTime=Date.now(),this.hoverIntentData.x=e.clientX,this.hoverIntentData.y=e.clientY)}setPosition(){if(!this.target||!this.root||!this.props)return;let e=this.target.getBoundingClientRect(),t=this.root,{offset:n,position:r}=this.props;t.style.visibility=`hidden`,t.style.display=`block`;let i=t.getBoundingClientRect(),a=0,o=0,s=r;switch(s===`auto`&&(s=window.innerHeight-e.bottom>i.height+n?`top-center`:`bottom-center`),s){case`top-left`:a=e.top-i.height-n,o=e.left;break;case`top-center`:a=e.top-i.height-n,o=e.left+e.width/2-i.width/2;break;case`top-right`:a=e.top-i.height-n,o=e.right-i.width;break;case`bottom-left`:a=e.bottom+n,o=e.left;break;case`bottom-center`:a=e.bottom+n,o=e.left+e.width/2-i.width/2;break;case`bottom-right`:a=e.bottom+n,o=e.right-i.width;break;case`left`:a=e.top+e.height/2-i.height/2,o=e.left-i.width-n;break;case`right`:a=e.top+e.height/2-i.height/2,o=e.right+n;break;default:break}a=Math.max(8,Math.min(a,window.innerHeight-i.height-8)),o=Math.max(8,Math.min(o,window.innerWidth-i.width-8)),t.style.top=`${a+window.scrollY}px`,t.style.left=`${o+window.scrollX}px`,t.style.visibility=``,t.style.display=``}docClick(e){e.target instanceof Node&&(!this.root||!this.target||!this.root.contains(e.target)&&!this.target.contains(e.target)&&this.hide())}exec(e){!this.root||!this.props||(e?(this.root.parentNode||document.body.appendChild(this.root),this.bindRootEvents(),this.setPosition()):(this.unbindRootEvents(),this.root.style.top=``,this.root.style.left=``,this.root.remove()),this.root.classList.toggle(this.props.className.active,e),this.isVisible=e)}show(e=!0){this.timer.hide&&clearTimeout(this.timer.hide),!this.isVisible&&(e&&this.delayShow>0?(this.timer.show&&clearTimeout(this.timer.show),this.timer.show=setTimeout(()=>this.exec(!0),this.delayShow)):this.exec(!0),this.props?.onShown?.(this))}hide(e=!0){this.timer.show&&clearTimeout(this.timer.show),this.isVisible&&(e&&this.delayHide>0?(this.timer.hide&&clearTimeout(this.timer.hide),this.timer.hide=setTimeout(()=>this.exec(!1),this.delayHide)):this.exec(!1),this.props?.onHidden?.(this))}toggle(){this.isVisible?this.hide():this.show()}destroy(){this.props&&(this.timer.show&&clearTimeout(this.timer.show),this.timer.hide&&clearTimeout(this.timer.hide),this.unbindEvents(),this.root?.remove(),this.props=null,this.root=null,this.target=null,this.timer={show:null,hide:null},this.cleanup?.events.clear(),this.cleanup=null,this.isVisible=!1)}};function Sn(e,t={}){return new xn(e,t)}let Cn={root:`j-tooltip`,message:`tooltip-message`},wn={name:{default:null,types:[`string`,`null`]},mode:{default:`hover`,type:`string`,enum:[`hover`,`click`]},position:{default:`auto`,type:`string`,enum:[`auto`,`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`left`,`right`]},offset:{default:8,type:`number`},message:{default:``,type:`string`,normalize:e=>typeof e==`string`?e.trim():e,validate:e=>typeof e==`string`&&e.length>0,message:`expects a non-empty string.`},className:{default:Cn,type:`object`,normalize:e=>({...Cn,...e&&typeof e==`object`?e:{}})},dropClassName:{default:{},type:`object`},id:{default:null,types:[`string`,`null`]},delay:{default:100,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`},onShown:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function Tn(e){let t=_(e,wn,`Tooltip.props`);return{name:t.name,mode:t.mode,position:t.position,offset:t.offset,message:t.message,className:t.className,dropClassName:t.dropClassName,id:t.id,delay:t.delay,hoverIntent:t.hoverIntent,onShown:t.onShown,onHidden:t.onHidden}}var En=class{constructor(e,t={}){let n=Tn(t);this.props=n,this.drop=new xn(e,{name:n.name,mode:n.mode,position:n.position,offset:n.offset,id:n.id,delay:n.delay,hoverIntent:n.hoverIntent,onShown:n.onShown,onHidden:n.onHidden,className:n.dropClassName,content:this.buildContent(n)})}buildContent(e){return(0,t.jsx)(`div`,{className:e.className.root,"data-tooltip":e.name||e.id||``,children:(0,t.jsx)(`div`,{className:e.className.message,"data-tooltip-message":``,children:e.message})})}show(e=!0){this.drop?.show(e)}hide(e=!0){this.drop?.hide(e)}toggle(){this.drop?.toggle()}destroy(){this.drop?.destroy(),this.drop=null,this.props=null}};function Dn(e,t={}){return new En(e,t)}let On={root:`j-offcanvas`,overlay:`j-offcanvas-overlay`,content:`offcanvas-content`,active:`is-active`,top:`is-top`,right:`is-right`,bottom:`is-bottom`,left:`is-left`,slide:`is-slide`,none:`is-none`},kn={content:{default:``,validate:O,message:`expects string, Node, array, function or null.`},overlay:{default:!0,type:`boolean`},filter:{default:!0,type:`boolean`},cache:{default:!1,type:`boolean`},ttl:{default:0,type:`number`},direction:{default:`left`,type:`string`,enum:[`top`,`right`,`bottom`,`left`]},animation:{default:`slide`,type:`string`,enum:[`slide`,`none`]},bgClose:{default:!0,type:`boolean`},escClose:{default:!0,type:`boolean`},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},className:{default:On,type:`object`,normalize:e=>({...On,...e&&typeof e==`object`?e:{}})},onShow:{default:null,types:[`function`,`null`]},onShown:{default:null,types:[`function`,`null`]},onHide:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function An(e){return e>0?e:0}function jn(e){let t=_(e,kn,`Offcanvas`);return{content:t.content,overlay:t.overlay,filter:t.filter,cache:t.cache,ttl:t.ttl,direction:t.direction,animation:t.animation,bgClose:t.bgClose,escClose:t.escClose,id:t.id,className:t.className,onShow:t.onShow,onShown:t.onShown,onHide:t.onHide,onHidden:t.onHidden}}function Mn(...e){return e.filter(Boolean).join(` `)}var Nn=class extends P{constructor(e={}){let n=jn(e);super(n),this.dom.content=null,this._overlay=null,this.runtime.cache={content:null,hasContent:!1,updatedAt:0},this.runtime.contentLoadId=0,this.state=(0,t.createDeepStore)({visible:!1,loading:!1}),this.onInit(n)}onInit(e){e.overlay&&(this._overlay=this.buildOverlay(e)),this.root=this.buildRoot(e)}buildOverlay(e){return(0,t.jsx)(`div`,{className:e.className.overlay,"data-offcanvas-overlay":e.id,style:e.filter?{backdropFilter:`blur(2px)`}:{}})}buildRoot(e){let n=(0,t.jsx)(`div`,{className:e.className.content,"data-offcanvas-content":e.id});return this.dom.content=n,typeof e.content!=`function`&&n.append(...w(e.content,this)),(0,t.jsx)(`div`,{className:Mn(e.className.root,e.className[e.direction],e.className[e.animation]),id:e.id,"data-offcanvas":`root`,"data-offcanvas-direction":e.direction,"data-offcanvas-animation":e.animation,children:n})}isCacheValid(){if(!this.props.cache||!this.runtime.cache.hasContent)return!1;let e=An(this.props.ttl);return!e||Date.now()-this.runtime.cache.updatedAt<=e}renderContent(e){this.dom.content&&(this.dom.content.textContent=``,this.dom.content.append(...w(e,this)))}async loadContent(){let{content:e,cache:n}=this.props;if(typeof e!=`function`){this.runtime.contentLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1});return}if(this.isCacheValid()){this.runtime.contentLoadId+=1,this.renderContent(this.runtime.cache.content),(0,t.flushSync)(()=>{this.state.loading=!1});return}let r=++this.runtime.contentLoadId;(0,t.flushSync)(()=>{this.state.loading=!0}),this.dom.content&&(this.dom.content.textContent=``,this.dom.content.appendChild(k()));try{let t=await Promise.resolve(e(this));if(this.runtime.destroyed||r!==this.runtime.contentLoadId)return;n&&(this.runtime.cache.content=t,this.runtime.cache.hasContent=!0,this.runtime.cache.updatedAt=Date.now()),this.renderContent(t)}finally{!this.runtime.destroyed&&r===this.runtime.contentLoadId&&(0,t.flushSync)(()=>{this.state.loading=!1})}}bindEvents(){this.unbindEvents();let{bgClose:e,escClose:t}=this.props;this._overlay&&e&&this.cleanup.events.on(`overlay`,this._overlay,`click`,()=>{this.hide()}),t&&this.cleanup.events.on(`esc`,document,`keydown`,e=>{e instanceof KeyboardEvent&&e.key===`Escape`&&this.state.visible&&this.hide()}),this.dom.root&&this.cleanup.events.on(`close`,this.dom.root,`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-action]`)?.dataset.action;(t===`close`||t===`cancel`)&&this.hide()})}unbindEvents(){this.cleanup?.events.clear()}renderPanel(){let{overlay:e,id:t,className:n}=this.props,r=document.body;e&&this._overlay&&r.appendChild(this._overlay),this.dom.root&&r.appendChild(this.dom.root),r.style.overflow=`hidden`,l.start(`oc-show-${t}`,10,()=>{this.dom.root&&(this._overlay?.classList.add(n.active),this.dom.root.classList.add(n.active))})}removePanel(){let{id:e,className:t}=this.props,n=document.body;this._overlay?.classList.remove(t.active),this.dom.root?.classList.remove(t.active),l.start(`oc-remove-${e}`,100,()=>{this._overlay?.remove(),this.dom.root?.remove(),n.style.overflow=``})}async show(){if(this.runtime.destroyed||this.state.visible)return;let{onShow:e,onShown:n,id:r}=this.props;e&&await Promise.resolve(e(this)),this.renderPanel(),this.bindEvents(),(0,t.flushSync)(()=>{this.state.visible=!0}),await this.loadContent(),l.start(`oc-shown-${r}`,300,()=>{this.runtime.destroyed||n?.(this)})}async hide(){if(this.runtime.destroyed||!this.state.visible)return;let{onHide:e,onHidden:n}=this.props;e&&await Promise.resolve(e(this)),this.runtime.contentLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1}),this.unbindEvents(),this.removePanel(),(0,t.flushSync)(()=>{this.state.visible=!1}),n?.(this)}onDestroy(){let{id:e,className:t}=this.props;l.cancel(`oc-show-${e}`),l.cancel(`oc-remove-${e}`),l.cancel(`oc-shown-${e}`),this.state.visible&&this.unbindEvents(),this.dom.root?.classList.remove(t.active),this.dom.root?.remove(),this._overlay?.remove();let n=document.body;n.style.overflow=``,this._overlay=null}};function Pn(e={}){return new Nn(e)}let Fn={layout:`j-popup-layout`,modal:`j-modal`,fullscreen:`is-fullscreen`,header:`modal-header`,body:`modal-body`,footer:`modal-footer`,title:`modal-title`,close:`modal-close`,cancel:`modal-cancel`,confirm:`modal-confirm`,button:`j-button`,buttonIcon:`is-icon`,buttonGhost:`is-ghost`,buttonPrimary:`is-primary`,buttonSmall:`is-sm`,formContainer:`modal-form-container`};function J(e){return Array.isArray(e)?e.map(e=>({...e,options:Array.isArray(e.options)?e.options.map(e=>e&&typeof e==`object`?{...e}:e):e.options})):[]}function In(e){return{...e,fields:Array.isArray(e.fields)?J(e.fields):null,text:{...e.text},className:{...e.className}}}function Ln(e){return p(e)}function Rn(e){return e==null||typeof e==`object`&&typeof e.next==`function`&&typeof e.back==`function`&&typeof e.snapshot==`function`}function zn(e,t){return!Array.isArray(e)||!p(t)?e?J(e):null:e.map(e=>{if(!e?.name||!s(t,e.name))return{...e};let n=t[e.name];if(e.type===`checkbox`||e.type===`radio`){let t=e.value??`on`,r=Array.isArray(n)?n.map(String).includes(String(t)):n===!0||String(n)===String(t);return{...e,checked:r}}return{...e,value:Array.isArray(n)?n.map(String):n}})}function Bn(e){let t=p(e?.text)?e.text:{};return{title:typeof t.title==`string`?t.title:`Tip`,confirm:typeof t.confirm==`string`?t.confirm:`Confirm`,cancel:typeof t.cancel==`string`?t.cancel:`Cancel`}}function Vn(e){return{...e,fields:Array.isArray(e.fields)?J(e.fields):null,text:Bn(e),loading:!1,submitting:!1,visible:!1,data:null,extraData:null}}function Hn(e,t){return!t||typeof t!=`object`?e:Object.assign(e,t)}function Un(e){return p(e)?{...e}:{}}function Y(...e){return e.filter(Boolean).join(` `)}function Wn(e){return typeof e==`string`||typeof e==`number`?String(e):``}let Gn={validate:O,message:`expects string, number, Node, array, function or null.`},Kn={default:{},validate:e=>p(e),message:`expects an object with text fields.`,normalize:e=>{let t=p(e)?e:{};return{...t,title:typeof t.title==`string`?t.title:`Tip`,confirm:typeof t.confirm==`string`?t.confirm:`Confirm`,cancel:typeof t.cancel==`string`?t.cancel:`Cancel`}}},qn={types:[`array`,`null`]},X={content:{default:``,...Gn},position:{default:`center`,type:`string`},showCancel:{default:!0,type:`boolean`},showClose:{default:!0,type:`boolean`},fullscreen:{default:!1,type:`boolean`},flow:{default:null,validate:Rn,message:`expects a Flow instance or null.`},text:Kn,onShow:{default:null,types:[`function`,`null`]},onShown:{default:null,types:[`function`,`null`]},onHide:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]},onConfirm:{default:null,types:[`function`,`null`]},onSubmit:{default:null,types:[`function`,`null`]},onCancel:{default:null,types:[`function`,`null`]},fields:{default:null,...qn},header:{default:!0,type:`boolean`},footer:{default:!0,type:`boolean`},style:{default:null,types:[`string`,`null`,`object`]},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},escClose:{default:!1,type:`boolean`},bgClose:{default:!1,type:`boolean`},lazy:{default:!1,type:`boolean`},className:{default:Fn,type:`object`,normalize:e=>({...Fn,...e&&typeof e==`object`?e:{}})}},Jn={...X,loading:{default:!1,type:`boolean`},submitting:{default:!1,type:`boolean`},visible:{default:!1,type:`boolean`},data:{default:null,types:[`object`,`null`]},extraData:{default:null,types:[`object`,`null`]}},Yn=new Set([`id`,`lazy`]),Xn={validate:e=>!!e&&typeof e==`object`&&!Array.isArray(e),message:`expects an object.`},Zn={validate:Ln,message:`expects a props object.`};function Z(e){let t=_(e,X,`Modal`);return{content:t.content,position:t.position,showCancel:t.showCancel,showClose:t.showClose,fullscreen:t.fullscreen,flow:t.flow,text:t.text,onShow:t.onShow,onShown:t.onShown,onHide:t.onHide,onHidden:t.onHidden,onConfirm:t.onConfirm,onSubmit:t.onSubmit,onCancel:t.onCancel,fields:Array.isArray(t.fields)?J(t.fields):null,header:t.header,footer:t.footer,style:t.style,id:t.id,escClose:t.escClose,bgClose:t.bgClose,lazy:t.lazy,className:t.className}}let Q=0,Qn=``;var $n=class extends P{constructor(e={}){let n=Z(e);super(n),this.dom.modal=null,this.dom.header=null,this.dom.body=null,this.dom.footer=null,this.dom.form=null,this.dom.formContainer=null,this.cleanup.visibility=null,this.cleanup.view=null,this.cleanup.hideTimer=null,this.runtime.scrollLocked=!1,this.runtime.visibleApplied=!1,this.cache={initial:In(this.props),fieldIds:new Map,baseStyle:``,previousActiveElement:null,formId:`${this.props.id}_form`},this.state=(0,t.createDeepStore)(Vn(this.props)),this.init(n)}onInit(){this.bindReactiveVisibility(),this.state.lazy||this.buildRoot()}buildRoot(){if(this.root instanceof HTMLElement)return this.root;let{id:e,className:n}=this.state,r=(0,t.jsx)(`div`,{className:()=>Y(this.state.className.layout,`is-${this.state.position}`),role:`dialog`,"data-modal":`root`,"data-modal-position":()=>this.state.position,"aria-modal":`true`,"aria-labelledby":()=>this.state.header?`${e}_title`:null,"aria-label":()=>this.state.header?null:this.state.text?.title||`Modal`,children:(0,t.jsx)(`div`,{className:()=>Y(this.state.className.modal,this.state.fullscreen&&this.state.className.fullscreen),id:e,role:`document`,"data-modal-dialog":e,ref:e=>{this.dom.modal=e,this.applyStyle(e,this.state.style)},children:[(0,t.jsx)(`div`,{className:n.header,"data-modal-header":e,style:()=>({display:this.state.header?``:`none`}),ref:e=>{this.dom.header=e}}),(0,t.jsx)(`div`,{className:n.body,"data-modal-body":e,ref:e=>{this.dom.body=e}}),(0,t.jsx)(`div`,{className:n.footer,"data-modal-footer":e,style:()=>({display:this.state.footer?``:`none`}),ref:e=>{this.dom.footer=e}})]})});return this.root=r,this.mountView(),r}mountView(){this.cleanup.view||!this.dom.body||(this.cleanup.view=(0,t.createRoot)(e=>(this.dom.header&&(0,t.onCleanup)((0,t.render)(()=>this.headerView(),this.dom.header)),this.dom.body&&(0,t.render)(()=>this.bodyView(),this.dom.body),this.dom.footer&&(0,t.onCleanup)((0,t.render)(()=>this.footerView(),this.dom.footer)),this.bindReactiveLoading(),this.bindReactiveStyle(),e)))}headerView(){return()=>this.state.header?[(0,t.jsx)(`div`,{className:this.state.className.title,id:`${this.state.id}_title`,"data-modal-title":this.state.id,children:()=>this.state.text?.title}),this.state.showClose?(0,t.jsx)(`button`,{type:`button`,className:Y(this.state.className.button,this.state.className.buttonIcon,this.state.className.buttonGhost,this.state.className.buttonSmall,this.state.className.close),"data-action":`close`,"aria-label":`close`,children:x(`close`)}):null]:null}footerView(){return()=>this.state.footer?[this.state.showCancel?(0,t.jsx)(`button`,{type:`button`,className:Y(this.state.className.button,this.state.className.buttonGhost,this.state.className.cancel),"data-action":`close`,"aria-label":`close`,disabled:()=>this.isBusy(),children:()=>this.state.text?.cancel}):null,(0,t.jsx)(`button`,{type:()=>this.isFormMode()?`submit`:`button`,form:()=>this.isFormMode()?this.cache.formId:null,className:Y(this.state.className.button,this.state.className.buttonPrimary,this.state.className.confirm),"data-action":()=>this.isFormMode()?`submit`:`confirm`,disabled:()=>this.isBusy(),children:()=>this.state.text?.confirm})]:null}bodyView(){return this.isFormMode()?this.formView():(this.destroyForm(),this.contentView(this.state.content))}formView(){return(0,t.jsx)(`div`,{className:this.state.className.formContainer,"data-modal-form-container":this.state.id,ref:e=>{this.mountForm(e)}})}mountForm(e){if(!e)return;this.dom.formContainer=e;let t=this.createFormProps();if(this.dom.form){this.dom.form.update(t);return}this.dom.form=new mt(t,e).build()}createFormProps(){return{id:this.cache.formId,fields:this.state.fields||[],buttons:!1,onSubmit:e=>this.handleFormSubmit(e)}}destroyForm(){this.dom.form?.destroy(),this.dom.form=null,this.dom.formContainer=null}contentView(e){return w(e,this)}bindReactiveLoading(){let e=null;(0,t.createEffect)(()=>{this.state.loading&&!e?(e=k(),this.dom.modal?.appendChild(e)):!this.state.loading&&e&&(e.remove(),e=null)}),(0,t.onCleanup)(()=>{e?.remove(),e=null})}bindReactiveStyle(){(0,t.createEffect)(()=>{let e=this.state.style;this.dom.modal&&this.applyStyle(this.dom.modal,e)})}isFormMode(){return Array.isArray(this.state.fields)}isBusy(){return!!(this.state.loading||this.state.submitting)}validatePropsPatch(e,t=`Modal.update`){g(`props`,e,Zn,t);for(let n of Object.keys(e)){if(!s(X,n))throw Error(`Validator: ${t}.${n} is not a supported modal prop.`);if(Yn.has(n))throw Error(`Modal.update: "${n}" cannot be updated after initialization.`);g(n,e[n],X[n],t)}}applyProps(e,{validate:n=!0,force:r=!1}={}){if(n&&this.validatePropsPatch(e),!e||Object.keys(e).length===0)return this;let i=s(e,`fields`);if(s(e,`content`)&&!i&&this.isFormMode()&&!r)throw Error(`Modal.update: Cannot update content when fields are defined.`);let a=Z({...this.props,...e,text:s(e,`text`)?{...this.props.text,...e.text}:this.props.text,className:s(e,`className`)?{...this.props.className,...e.className}:this.props.className});this.props=a,super.update(e,{force:r}),this.props=a;let o={};i&&(this.cache.fieldIds?.clear(),o.fields=Array.isArray(e.fields)?J(e.fields):null);for(let[t,n]of Object.entries(e))t!==`fields`&&t!==`text`&&t!==`className`&&(o[t]=n);return s(e,`text`)&&(o.text=Bn(a)),s(e,`className`)&&(o.className=a.className),(0,t.flushSync)(()=>{for(let[e,t]of Object.entries(o))this.state[e]=t}),s(e,`style`)&&this.dom.modal&&this.applyStyle(this.dom.modal,this.state.style),this.state.visible&&(s(e,`bgClose`)||s(e,`escClose`))&&this.bindEvents(this.root),this.dom.form&&i&&this.dom.form.update(this.createFormProps()),this}applyStyle(e,t){if(e.removeAttribute(`style`),!t){this.cache.baseStyle=``;return}if(typeof t==`string`){e.style.cssText=t,this.cache.baseStyle=e.getAttribute(`style`)||``;return}Object.entries(t).forEach(([t,n])=>{if(n==null)return;let r=t.startsWith(`--`)?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(r,String(n))}),this.cache.baseStyle=e.getAttribute(`style`)||``}bindReactiveVisibility(){this.cleanup.visibility=(0,t.createRoot)(e=>((0,t.createEffect)(()=>{let e=!!this.state.visible;(0,t.untrack)(()=>this.applyVisibility(e))}),e))}applyVisibility(e){if(e!==this.runtime.visibleApplied){if(e){this.showFromState();return}this.hideFromState()}}showFromState(){if(this.runtime.destroyed)throw Error(`Modal: The current instance has been destroyed.`);this.root||this.buildRoot(),this.cancelHideTimer(),this.resetAnimationStyles();let{onShow:e,onShown:t}=this.state;e?.(this),this.cache.previousActiveElement=document.activeElement instanceof HTMLElement?document.activeElement:null,this.root&&!this.root.parentNode&&document.body.appendChild(this.root),this.lockScroll(),this.runtime.visibleApplied=!0,this.bindEvents(this.root),this.focusFirst(),t?.(this)}hideFromState(){if(!this.runtime.visibleApplied||!this.root)return;let{onHide:e,onHidden:n}=this.state;e?.(this),this.runtime.visibleApplied=!1,this.clearEvents(),(0,t.flushSync)(()=>{this.state.loading=!1,this.state.extraData=null,this.state.data=null}),this.dom.modal&&(this.dom.modal.style.transition=`opacity 300ms ease-out, transform 300ms ease-out`,this.dom.modal.style.opacity=`0`,this.dom.modal.style.transform=`scale(0.3)`),this.cancelHideTimer(),this.cleanup.hideTimer=setTimeout(()=>this.finishHide(n),300)}bindEvents(e){this.clearEvents(),this.bindOverlayCloseEvent(e),this.bindDocumentKeyEvent(),this.bindInsideEvent()}bindOverlayCloseEvent(e){e&&this.cleanup.events.on(`bg`,e,`click`,t=>{this.state.bgClose&&t.target===e&&this.hide()})}bindDocumentKeyEvent(){this.cleanup.events.on(`keydown`,document,`keydown`,e=>{if(!(!this.state.visible||!(e instanceof KeyboardEvent))){if(e.key===`Escape`&&this.state.escClose){e.preventDefault(),this.hide();return}e.key===`Tab`&&this.trapFocus(e)}})}bindInsideEvent(){this.dom.modal&&this.cleanup.events.on(`inside`,this.dom.modal,`click`,e=>{let t=(e.target instanceof Element?e.target:null)?.closest(`[data-action]`);if(!t||!this.dom.modal?.contains(t))return;let n=t.dataset.action;if(n===`cancel`||n===`close`){this.handleCancel();return}if(n===`submit`){this.requestSubmit();return}if(n===`back`){this.handleBack();return}if(n===`next`){this.handleNext();return}if(n===`confirm`){if(this.isFormMode()){this.requestSubmit();return}this.handleConfirm()}})}clearEvents(){this.cleanup.events.clear()}requestSubmit(){if(!this.dom.form){this.handleConfirm();return}this.dom.form.requestSubmit()}async handleFormSubmit(e){if(this.isBusy())return;let n=Hn(e,this.state.extraData);(0,t.flushSync)(()=>{this.state.data=n}),await this.handleSubmit(n)}async handleNext(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`next`)}async handleBack(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`back`)}hasFlow(){return Rn(this.state.flow)&&!!this.state.flow}async moveFlow(e){if(!this.hasFlow())return;let n=this.createFlowPayload();if(n!==!1){(0,t.flushSync)(()=>{this.state.submitting=!0});try{let t=await Promise.resolve(this.state.flow[e](n));this.syncFlowView(this.state.flow,t)}catch(t){console.error(`Modal.flow.${e} error:`,t),this.syncFlowView(this.state.flow)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}createFlowPayload(){if(!this.isFormMode())return null;let e=this.dom.form;if(!e)return this.state.data||null;if(!e.validate())return!1;let n=Hn(e.collectData(),this.state.extraData);return(0,t.flushSync)(()=>{this.state.data=n}),this.state.data}resolveFlowModalView(e,t,n){let r=n?.modal??n?.view;if(typeof r==`function`){let i=r({flow:e,snapshot:t,step:n,modal:this,data:t?.data??null,currentData:t?.currentData??null});return p(i)?i:{}}return Un(r)}syncFlowView(e,t=null){if(!e||!this.state)return;let n=e.snapshot()||t,r=e.currentStep||n?.currentStep||t?.currentStep,i=this.resolveFlowModalView(e,n,r),a=p(i.text)?i.text:{},o={...(!s(i,`text`)||!s(a,`title`))&&r?.title!=null?{text:{...a,title:Wn(r.title)}}:{},...!s(i,`content`)&&!s(i,`fields`)?{content:r?.content??null}:{},...i};Array.isArray(o.fields)&&(o.fields=zn(o.fields,n?.currentData)),!s(o,`fields`)&&s(o,`content`)&&(o.fields=null),this.update(o)}async handleConfirm(){if(!this.isBusy()){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onConfirm?.(this)),this.hide()}catch(e){console.error(`Modal.onConfirm error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}async handleCancel(){if(!this.isBusy()){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onCancel?.(this)),this.hide()}catch(e){console.error(`Modal.onCancel error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}async handleSubmit(e){if(this.state.onSubmit){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onSubmit(e,this)),this.state.extraData=null}catch(e){console.error(`Modal.onSubmit error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}trapFocus(e){if(!this.dom.modal)return;let t=Array.from(j(`a[href], button:not([disabled]):not([data-action=close]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,this.dom.modal)).filter(e=>e.offsetParent!==null||e===document.activeElement);if(t.length===0){e.preventDefault(),this.dom.modal.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}focusFirst(){if(!this.dom.modal)return;let e=A(`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]):not([data-action=close]), [tabindex]:not([tabindex="-1"])`,this.dom.form?.root||this.dom.modal);e?e.focus():(this.dom.modal.setAttribute(`tabindex`,`-1`),this.dom.modal.focus())}lockScroll(){this.runtime.scrollLocked||(Q===0&&(Qn=document.body.style.overflow,document.body.style.overflow=`hidden`),Q+=1,this.runtime.scrollLocked=!0)}unlockScroll(){this.runtime.scrollLocked&&(Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow=Qn,Qn=``),this.runtime.scrollLocked=!1)}cancelHideTimer(){this.cleanup.hideTimer&&(clearTimeout(this.cleanup.hideTimer),this.cleanup.hideTimer=null)}resetAnimationStyles(){this.dom.modal&&(this.cache.baseStyle?this.dom.modal.setAttribute(`style`,this.cache.baseStyle):this.dom.modal.removeAttribute(`style`))}finishHide(e){this.cleanup.hideTimer=null,this.root?.remove(),this.resetAnimationStyles(),this.unlockScroll(),this.restoreFocus(),e?.(this)}restoreFocus(){let e=this.cache.previousActiveElement;this.cache.previousActiveElement=null,e&&typeof e.focus==`function`&&document.contains(e)&&e.focus()}assertActive(e){if(this.runtime.destroyed)throw Error(`Modal.${e}: The current instance has been destroyed.`)}validateStatePatch(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Modal.setState: expects a plain object patch.`);for(let t of Object.keys(e)){if(!s(Jn,t))throw Error(`Modal.setState: "${t}" is not a supported state key.`);if(Yn.has(t))throw Error(`Modal.setState: "${t}" cannot be updated after initialization.`);g(t,e[t],Jn[t],`Modal.setState`)}}setState(e={}){return this.assertActive(`setState`),this.validateStatePatch(e),(0,t.flushSync)(()=>{for(let[t,n]of Object.entries(e))t===`fields`&&this.cache.fieldIds?.clear(),this.state[t]=t===`fields`&&Array.isArray(n)?J(n):n}),this}show(){return this.assertActive(`show`),(0,t.flushSync)(()=>{this.state.visible=!0}),this}hide(){return this.assertActive(`hide`),(0,t.flushSync)(()=>{this.state.visible=!1}),this}setFields(e,t=!1){return g(`data`,e,qn,`Modal.setFields`),this.applyProps({fields:e},{validate:!1,force:t}),this}addFields(e){return g(`data`,e,Xn,`Modal.addFields`),(0,t.flushSync)(()=>{this.state.extraData=e}),this}setContent(e,t=!1){if(g(`content`,e,Gn,`Modal.setContent`),this.isFormMode()&&!t)throw Error(`Modal.setContent: Cannot setContent when fields are defined.`);return this.applyProps({content:e},{validate:!1,force:t}),this}update(e={},t=!1){let n=typeof t==`boolean`?t:!!t.force;return this.applyProps(e||{},{validate:!0,force:n})}reset(){if(this.cache.fieldIds?.clear(),!this.cache.initial)return this;let e={...In(this.cache.initial)};return delete e.id,delete e.lazy,this.props=Z(e),this.applyProps(e,{validate:!1}),(0,t.flushSync)(()=>{this.state.data=null,this.state.extraData=null}),this}resetContent(){return this.setContent(this.cache.initial?.content??``)}resetFields(){return this.setFields(Array.isArray(this.cache.initial?.fields)?J(this.cache.initial.fields):null)}onDestroy(){let e=!!this.runtime.visibleApplied,t=this.state?.onHide,n=this.state?.onHidden;e&&t?.(this),this.cancelHideTimer(),this.clearEvents(),this.destroyForm(),this.unlockScroll(),this.cleanup.visibility?.(),this.cleanup.visibility=null,this.cleanup.view?.(),this.cleanup.view=null,this.root?.remove(),e&&n?.(this),this.cache={initial:null,fieldIds:null,baseStyle:``,previousActiveElement:null,formId:``}}destroy(){return this.runtime.destroyed||super.destroy(),this}};function er(e={}){return new $n(e)}let tr={root:`j-pagination`,list:`pagination`,item:`item`,more:`more`,button:`j-button`,buttonIcon:`is-icon`,buttonGhost:`is-ghost`,active:`is-active`,loading:`animate-spin`},nr={type:`object`,required:!0,validate:e=>{let t=e;return!!t&&Number.isInteger(t.size)&&Number(t.size)>0&&Number.isInteger(t.current)&&Number(t.current)>0},message:`expects { size, current } with positive integers.`},rr={type:`object`,required:!0,validate:e=>{let t=e;return!!t&&Number.isInteger(t.sibling)&&Number(t.sibling)>=0&&Number.isInteger(t.boundary)&&Number(t.boundary)>=0},message:`expects { sibling, boundary } with integers greater than or equal 0.`},ir={total:{default:0,type:`number`,validate:e=>Number.isFinite(e)&&Number(e)>=0,message:`expects a non-negative finite number.`},page:{default:()=>({size:10,current:1}),factory:!0,...nr},count:{default:()=>({sibling:1,boundary:1}),factory:!0,...rr},lock:{default:!0,type:`boolean`},onChange:{default:null,types:[`function`,`null`]},className:{default:tr,type:`object`,normalize:e=>({...tr,...e&&typeof e==`object`?e:{}})}};function ar(e,t,n){return Math.min(Math.max(e,t),n)}function or(e={}){let t=_(e,ir,`Pagination.props`);return{...t,page:{...t.page},count:{...t.count},className:{...t.className}}}function sr(e){return{type:`more`,key:e}}function cr(e){return{type:`page`,key:`page-${e}`,page:e}}function lr(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function ur(e,t,n){if(t<=0)return[];let r=Math.max(0,n.boundary),i=Math.max(0,n.sibling);if(t<=r*2+i*2+3)return lr(1,t).map(cr);let a=new Set;for(let e=1;e<=Math.min(r,t);e++)a.add(e);for(let n=Math.max(1,e-i);n<=Math.min(t,e+i);n++)a.add(n);for(let e=Math.max(1,t-r+1);e<=t;e++)a.add(e);let o=Array.from(a).sort((e,t)=>e-t),s=[];for(let e of o){let t=s[s.length-1];t?.type===`page`&&e-t.page>1&&(e-t.page===2?s.push(cr(t.page+1)):s.push(sr(`more-${t.page}-${e}`))),s.push(cr(e))}return s}var dr=class extends P{constructor(e,n={}){let r=D(e,`Pagination.container`),i=or(n);super(i);let a=this._getPageCount(i.total,i.page.size),o=ar(i.page.current,1,a);this.dom.container=r,this.dom.list=null,this.dom.prev=null,this.dom.next=null,this.dom.pageNodes=[],this.dom.items=[],this.runtime.built=!1,this.runtime.itemsKey=``,this.runtime.changeId=0,this.state=(0,t.createDeepStore)({total:i.total,page:{size:i.page.size,current:o},count:{sibling:i.count.sibling,boundary:i.count.boundary},pageCount:a,locked:!1}),this.props.page.current=o}build(){if(this._assertActive(`build`),this.runtime.built)return this;this.init(this.props),this.root=(0,t.jsx)(`div`,{className:this.props.className.root,role:`navigation`,"aria-label":`Pagination`,"data-pagination":`root`,children:(0,t.jsx)(`ul`,{className:this.props.className.list,"data-pagination-list":``,"aria-live":`polite`})}),this.dom.list=A(`[data-pagination-list]`,this.root),this.dom.prev=this._buildControlItem(`prev`),this.dom.next=this._buildControlItem(`next`),this.dom.list?.append(this.dom.prev,this.dom.next);let e=this.dom.container;return e?(e.textContent=``,e.appendChild(this.root),this.runtime.built=!0,this._bindControlState(),this._bindPageItems(),this._bindEvents(),this):this}go(e){if(this._assertActive(`go`),g(`page`,e,{type:`number`,validate:Number.isInteger,message:`expects an integer.`},`Pagination.go`),this._isLocked())return this;let n=ar(e,1,this.state.pageCount);if(n===this.state.page.current)return this;let r=this.props.lock&&typeof this.props.onChange==`function`,i=r?++this.runtime.changeId:this.runtime.changeId;if((0,t.flushSync)(()=>{this.state.page.current=n,r&&(this.state.locked=!0)}),this.props.page.current=n,typeof this.props.onChange==`function`){let e;try{e=this.props.onChange(n,this)}catch(e){throw r&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1}),e}if(r&&e&&typeof e.then==`function`){let n=()=>{!this.runtime.destroyed&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1})};Promise.resolve(e).then(n,n)}else r&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1})}return this}update(e={}){this._assertActive(`update`),g(`newProps`,e,{type:`object`},`Pagination.update`);let n=or({total:e.total??this.props.total,lock:s(e,`lock`)?e.lock:this.props.lock,onChange:s(e,`onChange`)?e.onChange:this.props.onChange,className:{...this.props.className,...e.className},page:{...this.props.page,...e.page},count:{...this.props.count,...e.count}}),r=this._getPageCount(n.total,n.page.size);return n.page.current=ar(n.page.current,1,r),this.props=n,(0,t.flushSync)(()=>{this.state.total=n.total,this.state.page.size=n.page.size,this.state.page.current=n.page.current,this.state.count.sibling=n.count.sibling,this.state.count.boundary=n.count.boundary,this.state.pageCount=r,n.lock||(this.state.locked=!1)}),this}_getPageCount(e,t){return Math.max(1,Math.ceil(e/t))}_getPageItems(){return ur(this.state.page.current,this.state.pageCount,this.state.count)}_getItemsKey(){return[this.state.page.current,this._isLocked()?`locked`:`unlocked`,...this._getPageItems().map(e=>e.key)].join(`|`)}_isLocked(){return this.props.lock&&this.state.locked}_isPrevDisabled(){return this._isLocked()||this.state.page.current<=1}_isNextDisabled(){return this._isLocked()||this.state.page.current>=this.state.pageCount}_buttonClass(...e){let{button:t,buttonIcon:n,buttonGhost:r}=this.props.className;return[t,n,r,...e].filter(Boolean).join(` `)}_buildControlItem(e){return(0,t.jsx)(`li`,{className:this.props.className.item,"data-pagination-control":e,children:(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,"data-page-action":e,children:x(e===`prev`?`arrow-left`:`arrow-right`)})})}_buildPageItem(e){let n=this._isLocked();return e.type===`more`?(0,t.jsx)(`li`,{className:[this.props.className.item,this.props.className.more].filter(Boolean).join(` `),"data-pagination-more":e.key,"aria-hidden":`true`,children:(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,disabled:n,children:x(`more`)})}):(0,t.jsx)(`li`,{className:this.props.className.item,"data-pagination-item":String(e.page),children:e.page===this.state.page.current?(0,t.jsx)(`span`,{className:[this.props.className.button,this.props.className.buttonIcon,this.props.className.active].filter(Boolean).join(` `),"data-current-page":String(e.page),"aria-current":`page`,"aria-label":`Page ${e.page}, current page`,children:n?(0,t.jsx)(`i`,{className:this.props.className.loading,children:x(`loader`)}):String(e.page)}):(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,"data-page":String(e.page),"aria-label":`Go to page ${e.page}`,"aria-disabled":n?`true`:null,disabled:n,tabindex:n?`-1`:null,children:String(e.page)})})}_bindControlState(){this.cleanup.controls?.(),this.cleanup.controls=(0,t.createRoot)(e=>{let n=this.dom.prev?A(`[data-page-action]`,this.dom.prev):null,r=this.dom.next?A(`[data-page-action]`,this.dom.next):null;return n&&((0,t.bindAttr)(n,`disabled`,()=>this._isPrevDisabled()),(0,t.bindAttr)(n,`aria-disabled`,()=>this._isPrevDisabled()?`true`:`false`),(0,t.bindAttr)(n,`tabindex`,()=>this._isPrevDisabled()?`-1`:null),(0,t.bindAttr)(n,`aria-label`,()=>`Go to previous page`)),r&&((0,t.bindAttr)(r,`disabled`,()=>this._isNextDisabled()),(0,t.bindAttr)(r,`aria-disabled`,()=>this._isNextDisabled()?`true`:`false`),(0,t.bindAttr)(r,`tabindex`,()=>this._isNextDisabled()?`-1`:null),(0,t.bindAttr)(r,`aria-label`,()=>`Go to next page`)),e})}_bindPageItems(){this.cleanup.itemsEffect?.dispose(),this.cleanup.itemsEffect=(0,t.createEffect)(()=>{let e=this._getItemsKey();e!==this.runtime.itemsKey&&(this.runtime.itemsKey=e,this._renderPageItems())})}_renderPageItems(){if(this.dom.items=[],!this.dom.list||!this.dom.next)return;let e=this._getPageItems().map(e=>this._buildPageItem(e));for(let e of this.dom.pageNodes)e.remove();this.dom.pageNodes=e;for(let t of e)this.dom.list.insertBefore(t,this.dom.next)}_bindEvents(){let e=this.root;e&&this.cleanup.events.on(`click`,e,`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-page], [data-page-action]`);if(!r||!e.contains(r))return;t.preventDefault();let i=r.dataset.pageAction;if(i===`prev`&&!this._isPrevDisabled()){this.go(this.state.page.current-1);return}if(i===`next`&&!this._isNextDisabled()){this.go(this.state.page.current+1);return}r.dataset.page&&this.go(Number(r.dataset.page))})}_assertActive(e){if(this.runtime.destroyed)throw Error(`Pagination.${e}: instance has been destroyed.`)}onDestroy(){this.cleanup.events.clear(),this.cleanup.controls?.(),this.cleanup.itemsEffect?.dispose(),this.cleanup.controls=null,this.cleanup.itemsEffect=null,this.dom.container&&(this.dom.container.textContent=``),this.runtime.built=!1,this.runtime.itemsKey=``,this.runtime.changeId=0,this.dom.container=null,this.dom.list=null,this.dom.prev=null,this.dom.next=null,this.dom.pageNodes=[],this.dom.items=[]}};function fr(e,t={}){return new dr(e,t)}let pr={root:`j-swiper`,wrapper:`swiper-wrapper`,slide:`swiper-slide`,image:`swiper-image`,title:`swiper-slide-title`,pagination:`swiper-pagination`,paginationHorizontal:`is-horizontal`,paginationClickable:`is-clickable`,paginationBulletGroup:`is-bullet`,indicator:`swiper-pagination-indicator`,bullet:`swiper-pagination-bullet`,navigation:`swiper-navigation`,prev:`is-prev`,next:`is-next`,active:`is-active`,disabled:`is-disabled`,loading:`loading`,loaded:`loaded`,error:`error`},mr={data:{default:null,validate:e=>e==null||Array.isArray(e),message:`expects an array or null.`},loop:{default:!0,type:`boolean`},autoplay:{default:!0,type:`boolean`},delay:{default:3e3,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},lazyload:{default:!0,type:`boolean`},pagination:{default:!0,type:`boolean`},navigation:{default:!0,type:`boolean`},speed:{default:300,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},touchRatio:{default:1,type:`number`,validate:e=>Number(e)>0,message:`expects a number greater than 0.`},touchAngle:{default:45,type:`number`,validate:e=>Number(e)>=0&&Number(e)<=90,message:`expects a number between 0 and 90.`},longSwipesMs:{default:300,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},longSwipesRatio:{default:.05,type:`number`,validate:e=>Number(e)>=0&&Number(e)<=1,message:`expects a number between 0 and 1.`},preventClick:{default:!0,type:`boolean`},className:{default:pr,type:`object`,normalize:e=>({...pr,...e&&typeof e==`object`?e:{}})}},hr={validate:e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return(t.image==null||typeof t.image==`string`)&&(t.url==null||typeof t.url==`string`)&&(t.title==null||typeof t.title==`string`)&&(t.sort==null||typeof t.sort==`number`)&&(t.blank==null||typeof t.blank==`boolean`)&&(t.children==null||O(t.children))},message:`expects items with optional image, url, title, sort, blank and children fields.`};function gr(e){return e instanceof Element&&!!e.closest(`a, button, input, textarea, select, label, [data-swiper-ignore]`)}function $(e,t=0){let n=Number(e);return Number.isFinite(n)?n:t}function _r(e,t){return w(e,t)}function vr(e={}){let t=_(e,mr,`Swiper.options`);return{...t,className:{...t.className}}}function yr(e){let t=j(`[data-swiper="root"]`,e);return g(`container`,t,{validate:e=>Array.isArray(e)&&e.length===1,message:`expects exactly one [data-swiper="root"] descendant.`},`Swiper`),t[0]}function br(...e){return e.filter(Boolean).join(` `)}function xr(e,t,n=``){e.setAttribute(t,n)}function Sr(e){return p(e)}var Cr=class extends P{constructor(e,n={}){let r=vr(n);super(r),this.dom.container=e,this._built=!1,this.dom.mountTarget=null,this.dom.createdRoot=!1,this.dom.createdSlides=!1,this.dom.wrapper=null,this.dom.slides=[],this.dom.pagination=null,this.dom.prevButton=null,this.dom.nextButton=null,this.dom.bullets=[],this.dom.createdPagination=!1,this.dom.createdPrevButton=!1,this.dom.createdNextButton=!1,this.runtime.logs=[],this.runtime.startTarget=null,this.runtime.touching=!1,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.clickPrevented=!1,this.runtime.timer=null,this.runtime.imageCleanups=new Set,this.runtime.realCount=0,this.state=(0,t.createDeepStore)({index:0,trackIndex:0,transform:0,animating:!1,width:0})}build(){if(this.runtime.destroyed)throw Error(`Swiper.build: instance destroyed`);if(this._built)return this;let e=Array.isArray(this.props.data),n=D(this.dom.container,`Swiper`),r=null,i=null;e?(i=n,r=(0,t.h)(`div`,{className:this.props.className.root,"data-swiper":`root`}),i.appendChild(r)):r=yr(n);try{this.dom.root=r,this.dom.mountTarget=i,this.dom.createdRoot=e,this.dom.createdSlides=e;let t=e?this.createDataView(r,this.props.data):A(`[data-swiper-wrapper]`,r);g(`wrapper`,t,{validate:C,message:`expects [data-swiper-wrapper] in the root element.`},`Swiper`),this.dom.wrapper=t,this.dom.slides=j(`[data-swiper-slide]`,this.dom.wrapper),this.dom.pagination=A(`[data-swiper-pagination]`,r),this.dom.prevButton=A(`[data-action="prev"]`,r),this.dom.nextButton=A(`[data-action="next"]`,r),this.dom.bullets=[],this.dom.createdPagination=!1,this.dom.createdPrevButton=!1,this.dom.createdNextButton=!1,this.runtime.realCount=this.dom.slides.length,this._built=!0,this.dom.slides.length>0&&this.onInit()}catch(e){throw this.destroy(),e}return this.emit(`init`,this.props),this}set index(e){this.setState({index:$(e)})}set trackIndex(e){this.setState({trackIndex:$(e)})}set transform(e){this.setState({transform:$(e)})}set animating(e){this.setState({animating:!!e})}set width(e){this.setState({width:$(e)})}get realCount(){return this.runtime?.destroyed?0:this.runtime?.realCount||0}get realIndex(){return this.toRealIndex()}assertBuilt(e){if(!this._built)throw Error(`Swiper.${e}: call build() first.`)}createDataView(e,n){let r=this.normalizeData(n),i=(0,t.h)(`div`,{className:this.props.className.wrapper,"data-swiper-wrapper":``,"aria-live":`polite`});return e.textContent=``,r.forEach((e,t)=>{i.appendChild(this.createDataSlide(e,t))}),e.appendChild(i),i}normalizeData(e){if(!Array.isArray(e))return[];e.forEach((e,t)=>{g(String(t),e,hr,`Swiper.options.data`)});let t=e.map((e,t)=>({...e,blank:e.blank!==!1,index:t}));return t.some(e=>e.sort!=null)?t.sort((e,t)=>e.sort==null&&t.sort==null?e.index-t.index:e.sort==null?1:t.sort==null?-1:e.sort-t.sort||e.index-t.index):t}createDataSlide(e,n){let r=(0,t.h)(e.url?`a`:`div`,{className:this.props.className.slide,href:e.url||void 0,target:e.url?e.blank?`_blank`:`_self`:void 0,"data-swiper-slide":String(n),"data-swiper-index":String(n),role:`group`,"aria-label":`Slide ${n+1}`});if(e.children!=null)return r.append(..._r(e.children,{swiper:this,item:e,index:n})),r;if(e.image){let n=(0,t.h)(`img`,{className:this.props.className.image,alt:e.title||``,loading:`lazy`});this.props.lazyload?n.dataset.lazy=e.image:n.src=e.image,r.appendChild(n)}return e.title&&r.appendChild((0,t.h)(`span`,{className:this.props.className.title,children:e.title})),r}onInit(){!this.dom.root||!this.dom.wrapper||(this.dom.wrapper.setAttribute(`aria-live`,`polite`),this.updateSize(),this.props.loop&&this.realCount>1&&this.initLoop(),this.setupStyles(),this.setTrackIndex(+!!this.props.loop,!1),this.render(!1),this.bindEvents(),this.props.pagination&&this.initPagination(),this.props.navigation&&this.initNavigation(),this.props.lazyload&&this.loadImages(),this.props.autoplay&&this.play())}onDestroy(){this.pause(),this.clearImageCleanups(),this.cleanup.events.clear(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.dom.wrapper&&j(`[data-clone]`,this.dom.wrapper).forEach(e=>e.remove()),this.dom.createdPagination&&this.dom.pagination?.remove(),this.dom.createdPrevButton&&this.dom.prevButton?.remove(),this.dom.createdNextButton&&this.dom.nextButton?.remove(),this.dom.createdRoot&&this.dom.root?.remove(),this._built=!1}updateSize(){this.assertBuilt(`updateSize`),this.dom.root&&(this.width=this.dom.root.clientWidth||this.dom.root.offsetWidth)}refreshSlides(){this.dom.wrapper&&(this.dom.slides=j(`[data-swiper-slide]`,this.dom.wrapper),this.runtime.realCount=this.dom.slides.filter(e=>!e.hasAttribute(`data-clone`)).length)}initLoop(){if(!this.dom.wrapper||this.dom.slides.length===0)return;let e=this.dom.slides[0].cloneNode(!0),t=this.dom.slides[this.dom.slides.length-1].cloneNode(!0);e.setAttribute(`data-clone`,``),t.setAttribute(`data-clone`,``),e.removeAttribute(`data-swiper-index`),t.removeAttribute(`data-swiper-index`),this.dom.wrapper.appendChild(e),this.dom.wrapper.insertBefore(t,this.dom.slides[0]),this.refreshSlides()}setupStyles(){this.dom.root&&this.dom.root.style.setProperty(`--swiper-slide-width`,`${this.state.width}px`)}reInitView(){this.dom.wrapper&&(this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear(),j(`[data-clone]`,this.dom.wrapper).forEach(e=>e.remove()),this.refreshSlides(),this.props.loop&&this.realCount>1&&this.initLoop(),this.updateSize(),this.setupStyles(),this.setTrackIndex(this.trackIndexForRealIndex(this.state.index),!1),this.render(!1),this.bindEvents(),this.props.pagination?this.initPagination():this.clearPagination(),this.props.navigation?this.initNavigation():this.clearNavigation(),this.props.lazyload&&this.loadImages(),this.props.autoplay&&this.play())}clearPagination(){this.cleanup.bindings?.(),this.cleanup.bindings=null,this.dom.bullets.forEach((e,t)=>{this.cleanup.events.off(`bullet:${t}:click`),this.cleanup.events.off(`bullet:${t}:keydown`)}),this.dom.bullets=[],this.dom.createdPagination?(this.dom.pagination?.remove(),this.dom.pagination=null,this.dom.createdPagination=!1):this.dom.pagination&&(this.dom.pagination.textContent=``)}clearNavigation(){this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.off(`nav:prev`),this.cleanup.events.off(`nav:next`),this.dom.createdPrevButton&&(this.dom.prevButton?.remove(),this.dom.prevButton=null,this.dom.createdPrevButton=!1),this.dom.createdNextButton&&(this.dom.nextButton?.remove(),this.dom.nextButton=null,this.dom.createdNextButton=!1)}bindEvents(){let e=this.dom.root,t=this.dom.wrapper;!e||!t||(this.cleanup.events.on(`touchstart`,t,`touchstart`,e=>{let t=e;t.touches[0]&&this.onStart(t.touches[0],t.target)},{passive:!0}),this.cleanup.events.on(`touchmove`,t,`touchmove`,e=>{let t=e;t.touches[0]&&this.onMove(t.touches[0],e)},{passive:!1}),this.cleanup.events.on(`touchend`,t,`touchend`,e=>{let t=e;t.changedTouches[0]&&this.pushLog(t.changedTouches[0]),this.onEnd()}),this.cleanup.events.on(`touchcancel`,t,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`window:touchcancel`,window,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`mousedown`,t,`mousedown`,e=>{let n=e;n.button===0&&(this.onStart(n,n.target),t.style.cursor=`grabbing`)}),this.cleanup.events.on(`mousemove`,t,`mousemove`,e=>{let t=e;t.buttons===1&&this.onMove(t,e)}),this.cleanup.events.on(`window:mousemove`,window,`mousemove`,e=>{let t=e;this.runtime.touching&&t.buttons===1&&this.onMove(t,e)}),this.cleanup.events.on(`mouseup`,t,`mouseup`,e=>{t.style.cursor=`grab`,this.pushLog(e),this.onEnd()}),this.cleanup.events.on(`window:mouseup`,window,`mouseup`,e=>{this.runtime.touching&&(t.style.cursor=`grab`,this.pushLog(e),this.onEnd())}),this.cleanup.events.on(`wrapper:mouseleave`,t,`mouseleave`,()=>{t.style.cursor=`grab`}),this.cleanup.events.on(`click`,t,`click`,e=>{!this.runtime.clickPrevented||!this.props.preventClick||(e.preventDefault(),e.stopPropagation(),this.runtime.clickPrevented=!1)},{capture:!0}),this.cleanup.events.on(`dragstart`,t,`dragstart`,e=>e.preventDefault()),this.cleanup.events.on(`transitionend`,t,`transitionend`,e=>this.onTransitionEnd(e)),this.cleanup.events.on(`window:resize`,window,`resize`,()=>this.update(null,{force:!0})),this.cleanup.events.on(`root:mouseenter`,e,`mouseenter`,()=>this.pause()),this.cleanup.events.on(`root:mouseleave`,e,`mouseleave`,()=>this.resume()))}onStart(e,t=null){this.state.animating||(this.runtime.logs=[],this.pushLog(e),this.runtime.startTarget=t,this.runtime.touching=!0,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.clickPrevented=!1,this.pause(),this.dom.wrapper&&(this.dom.wrapper.style.transition=`none`))}onMove(e,t){if(!this.runtime.touching||this.runtime.scrolling||this.state.animating)return;this.pushLog(e);let n=this.getOffset(),r=Math.abs(n.x),i=Math.abs(n.y);if(!(r<6&&i<6)){if(!this.runtime.swiping)if(Math.atan2(i,r)*180/Math.PI<this.props.touchAngle)this.runtime.swiping=!0,this.runtime.clickPrevented=gr(this.runtime.startTarget);else{this.runtime.scrolling=!0,this.resetDrag(!0);return}this.runtime.swiping&&(t.preventDefault(),this.transform=-this.state.trackIndex*this.state.width+n.x*this.props.touchRatio,this.render(!1))}}onEnd(){if(!this.runtime.touching)return;if(this.runtime.touching=!1,!this.runtime.swiping){this.resetDrag(!0);return}let e=this.getDuration(),t=this.getOffset().x,n=this.state.trackIndex;if(e>this.props.longSwipesMs){let e=Math.ceil(Math.abs(t)/this.state.width-this.props.longSwipesRatio);e>0&&(n=this.state.trackIndex+e*(t>0?-1:1))}else{let e=Math.abs(t)/this.state.width,r=e>=this.props.longSwipesRatio?Math.max(1,Math.ceil(e-this.props.longSwipesRatio)):0;r>0&&(n=t>0?this.state.trackIndex-r:this.state.trackIndex+r)}this.slideToTrack(n),this.runtime.logs=[],this.resume()}resetDrag(e=!0){let t=this.state.trackIndex===0?0:-this.state.trackIndex*this.state.width,n=e&&this.state.transform!==t;this.runtime.touching=!1,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.logs=[],this.runtime.startTarget=null,this.transform=t,this.render(n),this.resume()}onTransitionEnd(e){e&&(e.target!==this.dom.wrapper||!(`propertyName`in e)||e.propertyName!==`transform`)||(this.animating=!1,this.props.loop&&(this.state.trackIndex===0?(this.setTrackIndex(this.realCount,!1),this.render(!1)):this.state.trackIndex===this.dom.slides.length-1&&(this.setTrackIndex(1,!1),this.render(!1))))}pushLog(e){this.runtime.logs.push({x:e.pageX??e.clientX??0,y:e.pageY??e.clientY??0,time:Date.now()}),this.runtime.logs.length>5&&this.runtime.logs.shift()}getDuration(){return this.runtime.logs.length===0?0:this.runtime.logs[this.runtime.logs.length-1].time-this.runtime.logs[0].time}getOffset(){if(this.runtime.logs.length===0)return{x:0,y:0};let e=this.runtime.logs[0],t=this.runtime.logs[this.runtime.logs.length-1];return{x:t.x-e.x,y:t.y-e.y}}toRealIndex(e=this.state.trackIndex){return this.realCount?this.props.loop?e===0?this.realCount-1:e===this.dom.slides.length-1?0:e-1:e:0}trackIndexForRealIndex(e){if(!this.realCount)return 0;let t=Math.max(0,Math.min(e,this.realCount-1));return this.props.loop&&this.realCount>1?t+1:t}setTrackIndex(e,t=!0){let n=$(e);this.setState({trackIndex:n,index:this.toRealIndex(n),transform:-n*this.state.width}),t!=null&&this.render(t)}slideTo(e){return this.slideToTrack(this.trackIndexForRealIndex(e))}slideToTrack(e){if(this.assertBuilt(`slideToTrack`),this.state.animating||this.dom.slides.length===0)return;let t=e;this.props.loop?e<0?t=0:e>=this.dom.slides.length&&(t=this.dom.slides.length-1):t=Math.max(0,Math.min(e,this.dom.slides.length-1)),this.setTrackIndex(t,!0),this.props.lazyload&&this.loadImages()}next(){this.assertBuilt(`next`),!this.state.animating&&this.slideToTrack(this.state.trackIndex+1)}prev(){this.assertBuilt(`prev`),!this.state.animating&&this.slideToTrack(this.state.trackIndex-1)}render(e){this.assertBuilt(`render`),this.dom.wrapper&&(e?(this.dom.wrapper.style.transition=`transform ${this.props.speed}ms cubic-bezier(0.25, 0.46, 0.45, 0.94)`,this.animating=!0):(this.dom.wrapper.style.transition=`none`,this.animating=!1),this.dom.wrapper.style.transform=`translate3d(${this.state.transform}px, 0, 0)`)}loadImages(){this.assertBuilt(`loadImages`);let e=[this.state.trackIndex];this.state.trackIndex>0&&e.push(this.state.trackIndex-1),this.state.trackIndex<this.dom.slides.length-1&&e.push(this.state.trackIndex+1),e.forEach(e=>{let t=this.dom.slides[e];if(!t)return;let n=A(`img[data-lazy]`,t);if(!n||n.src)return;n.classList.add(this.props.className.loading),n.src=n.dataset.lazy||``;let r=()=>{n.onload=null,n.onerror=null,this.runtime.imageCleanups.delete(r)};this.runtime.imageCleanups.add(r),n.onload=()=>{n.classList.remove(this.props.className.loading),n.classList.add(this.props.className.loaded),r()},n.onerror=()=>{n.classList.remove(this.props.className.loading),n.classList.add(this.props.className.error),r()}})}clearImageCleanups(){this.runtime.imageCleanups?.forEach(e=>e()),this.runtime.imageCleanups?.clear()}initPagination(){if(!this.dom.root)return;this.dom.pagination?(this.dom.pagination.classList.add(this.props.className.paginationHorizontal,this.props.className.paginationClickable,this.props.className.paginationBulletGroup),xr(this.dom.pagination,`data-swiper-pagination`)):(this.dom.pagination=(0,t.h)(`div`,{className:br(this.props.className.pagination,this.props.className.paginationHorizontal,this.props.className.paginationClickable,this.props.className.paginationBulletGroup),"data-swiper-pagination":``}),this.dom.root.appendChild(this.dom.pagination),this.dom.createdPagination=!0);let e=this.dom.pagination;if(e){e.textContent=``,this.dom.bullets=[];for(let n=0;n<this.realCount;n++){let r=(0,t.h)(`button`,{type:`button`,className:br(this.props.className.indicator,this.props.className.bullet),"data-swiper-bullet":String(n),"aria-label":`Go to slide ${n+1}`});this.cleanup.events.on(`bullet:${n}:click`,r,`click`,()=>{this.slideTo(n)}),this.cleanup.events.on(`bullet:${n}:keydown`,r,`keydown`,e=>{let t=e;(t.key===`Enter`||t.key===` `)&&(e.preventDefault(),this.slideTo(n))}),this.dom.bullets.push(r),e.appendChild(r)}this.cleanup.bindings=(0,t.createRoot)(e=>(this.dom.bullets.forEach((e,n)=>{(0,t.bindClass)(e,this.props.className.active,()=>this.state.index===n),(0,t.bindAttr)(e,`aria-current`,()=>this.state.index===n?`true`:null)}),e))}}initNavigation(){let e=this.ensureNavigation(`prev`,`arrow-left`),n=this.ensureNavigation(`next`,`arrow-right`);this.dom.prevButton=e,this.dom.nextButton=n,this.cleanup.events.on(`nav:prev`,e,`click`,()=>this.prev()),this.cleanup.events.on(`nav:next`,n,`click`,()=>this.next()),this.props.loop||(this.cleanup.navBindings=(0,t.createRoot)(r=>((0,t.bindClass)(e,this.props.className.disabled,()=>this.state.trackIndex<=0),(0,t.bindAttr)(e,`disabled`,()=>this.state.trackIndex<=0?``:null),(0,t.bindClass)(n,this.props.className.disabled,()=>this.state.trackIndex>=this.dom.slides.length-1),(0,t.bindAttr)(n,`disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1?``:null),r)))}ensureNavigation(e,n){if(!this.dom.root)throw Error(`Swiper.ensureNavigation: root not found.`);let r=e===`prev`?`createdPrevButton`:`createdNextButton`,i=e===`prev`?this.props.className.prev:this.props.className.next,a=br(this.props.className.navigation,i),o=A(`[data-action="${e}"]`,this.dom.root);return o?o.tagName.toLowerCase()===`button`?(o.classList.add(this.props.className.navigation,i),xr(o,`data-swiper-navigation`,e)):(o.setAttribute(`role`,`button`),o.setAttribute(`tabindex`,`0`),o.classList.add(this.props.className.navigation,i),xr(o,`data-swiper-navigation`,e)):(o=(0,t.h)(`button`,{type:`button`,className:a,"data-action":e,"data-swiper-navigation":e}),this.dom.root.appendChild(o),this.dom[r]=!0),o.setAttribute(`aria-label`,e===`prev`?`Previous slide`:`Next slide`),A(`svg`,o)||(o.textContent=``,o.appendChild(x(n))),o}play(){if(this.assertBuilt(`play`),this.runtime.destroyed||this.runtime.timer||this.realCount<=1)return;let e=Math.max(this.props.delay,16);this.runtime.timer=setInterval(()=>this.next(),e)}pause(){this.runtime.timer&&(clearInterval(this.runtime.timer),this.runtime.timer=null)}resume(){this.runtime.destroyed||this.props.autoplay&&!this.runtime.timer&&this.play()}restartAutoplay(){this.pause(),this.props.autoplay&&this.play()}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);this.assertBuilt(`update`);let n=Sr(e)?e:{},r=vr(Object.assign({},this.props,n)),i={};return Object.keys(n).forEach(e=>{let t=e;i[t]=r[t]}),this.props=r,this.emit(`beforeUpdate`,i,{force:t}),this.onUpdate(i,{force:t}),this.emit(`afterUpdate`,i,{force:t}),this}onUpdate(e={},t={force:!1}){if(e&&Object.prototype.hasOwnProperty.call(e,`data`)){this.updateData(e.data);return}if([`loop`,`pagination`,`navigation`,`lazyload`].some(t=>Object.prototype.hasOwnProperty.call(e,t))){this.reInitView();return}this.updateSize(),this.setupStyles(),this.setTrackIndex(this.trackIndexForRealIndex(this.state.index),!1),Object.prototype.hasOwnProperty.call(e,`autoplay`)||Object.prototype.hasOwnProperty.call(e,`delay`)?this.restartAutoplay():this.props.autoplay?this.resume():this.pause()}updateData(e=this.props.data){if(this.runtime.destroyed)throw Error(`Swiper.updateData: instance destroyed`);if(this.assertBuilt(`updateData`),!this.dom.createdRoot)throw Error(`Swiper.updateData: not supported on DOM-bound instances.`);if(g(`data`,e,mr.data,`Swiper.options`),!Array.isArray(e))return this.props.data=e,this.reInitView(),this;this.props.data=e;let t=this.state.index,n=this.dom.wrapper;if(!n)return this;this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear();let r=this.normalizeData(e);return n.textContent=``,r.forEach((e,t)=>{n.appendChild(this.createDataSlide(e,t))}),this.refreshSlides(),this.runtime.realCount=this.dom.slides.length,this.setState({index:Math.min(t,Math.max(0,this.realCount-1))}),this.reInitView(),this}};function wr(e,t={}){return new Cr(e,t)}let Tr={root:``,list:`menu`,item:`menu-item`,hasChildren:`menu-item-has-children`,link:`menu-link`,subMenu:`sub-menu`,back:`back`,active:`is-active`,icon:`el-icon`,iconPrefix:`el-prefix`,text:`menu-text`},Er={type:{default:`mobile`,type:`string`},id:{default:``,type:`string`,normalize:e=>typeof e==`string`?e.trim()===``?v():e.trim():e},items:{default:[],type:`array`},backText:{default:`Back`,type:`string`},className:{default:Tr,type:`object`,normalize:e=>({...Tr,...e&&typeof e==`object`?e:{}})}},Dr={type:`array`};function Or(e={}){let t=_(e,Er,`Menu.options`);return{...t,items:t.items.slice(),className:{...t.className}}}function kr(...e){return e.filter(Boolean).join(` `)}function Ar(e){return`menu-item-${e??v()}`}function jr(e){let t=e.tagName.toLowerCase();return t===`ul`||t===`ol`}function Mr(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return(typeof t.title==`string`||typeof t.title==`number`)&&(t.id==null||typeof t.id==`string`||typeof t.id==`number`)&&(t.url==null||typeof t.url==`string`)&&(t.target==null||typeof t.target==`string`)&&(t.classes==null||Array.isArray(t.classes)&&t.classes.every(e=>typeof e==`string`))&&(t.children==null||Array.isArray(t.children)&&t.children.every(Mr))}function Nr(e){return e.hasAttribute(`data-menu-list`)||jr(e)?e:A(`[data-menu-list]`,e)}function Pr(e){return j(`[data-menu-link]`,e).find(t=>t.parentElement===e)||null}function Fr(e){return j(`[data-menu-list="sub"]`,e).find(t=>t.parentElement===e)||null}function Ir(e){return j(`[data-menu-back]`,e).find(t=>t.parentElement===e)||null}var Lr=class{constructor(e={},t=!1){this.options=Or(e),this._element=t,this.dom={root:null},this.cleanup={events:M()},this._bound=!1,this._destroyed=!1}get root(){return this.dom.root}_verifyItems(e){g(`items`,e,Dr,`Menu`),e.forEach((e,t)=>{g(String(t),e,{validate:Mr,message:`expects { title, id?, url?, target?, classes?, children? }.`},`Menu.items`)})}build(){if(this._bound)return this;if(!this.options)throw Error(`Menu.build: instance destroyed.`);if(this._element===!1)this._verifyItems(this.options.items),this.dom.root=this._buildRoot(),this._bound=!0;else{let e=E(this._element);if(!e)throw Error(`Menu.element: container not found.`);this.dom.root=e,this._bound=!0}return this._bindEvents(),this}_buildRoot(){if(!this.options)throw Error(`Menu._buildRoot: instance destroyed.`);let{items:e,id:n,type:r,className:i}=this.options;return(0,t.jsx)(`nav`,{className:i.root||`j-${r}-menu`,"data-menu":`root`,"data-menu-type":r,children:(0,t.jsx)(`ul`,{className:i.list,id:n,"data-menu-list":`root`,children:e.map(e=>this._buildItem(e))})})}_buildItem(e){if(!this.options)throw Error(`Menu._buildItem: instance destroyed.`);let{className:n}=this.options,r=e.children||[],i=r.length>0,a=[n.item];i&&a.push(n.hasChildren),e.classes&&a.push(...e.classes);let o=[(0,t.jsx)(`a`,{className:n.link,href:e.url||``,...e.target&&{target:e.target},"data-menu-link":``,children:e.title})];return i&&o.push((0,t.jsx)(`ul`,{className:n.subMenu,"data-menu-list":`sub`,children:r.map(e=>this._buildItem(e))})),(0,t.jsx)(`li`,{className:kr(...a),id:Ar(e.id),"data-menu-item":e.id==null?``:String(e.id),...i&&{"data-menu-has-children":``},children:o})}_bindEvents(){!this.dom.root||!this.options||!this.cleanup||(this.options.type===`mobile`?this.cleanup.events.on(`mobile`,this.dom.root,`click`,e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-menu-back]`);if(n&&this.dom.root?.contains(n)){e.preventDefault(),this._handleBack(n);return}let r=t.closest(`[data-menu-has-children]`);if(r&&this.dom.root?.contains(r)){let n=Pr(r);n&&(t===n||n.contains(t))&&(e.preventDefault(),this._handleMenuClick(r))}}):this.options.type===`bottom`&&this.cleanup.events.on(`bottom`,document,`click`,e=>{let t=e.target;if(!(t instanceof Element)||!this.dom.root)return;let n=t.closest(`[data-menu-list="sub"] [data-menu-link]`);if(n&&this.dom.root.contains(n))return;let r=t.closest(`[data-menu-list="root"] > [data-menu-has-children]`);r&&this.dom.root.contains(r)?(e.preventDefault(),this._toggleActive(r)):this._clearActive()}))}_unbindEvents(){this.cleanup?.events.clear()}_teardown({keepElement:e=!1}={}){this._unbindEvents(),this.cleanup?.items?.(),this.cleanup&&(this.cleanup.items=null),this._element===!1&&this.dom.root?.parentElement&&this.dom.root.remove(),e||(this._element=null),this.dom.root=null,this._bound=!1}_handleMenuClick(e){if(!this.options)return;e.classList.add(this.options.className.active);let n=Fr(e);if(!n||Ir(n))return;let{className:r}=this.options,i=(0,t.jsx)(`li`,{className:kr(r.item,r.back),"data-menu-back":``,children:(0,t.jsx)(`a`,{className:r.link,href:``,"data-menu-link":``,children:[(0,t.jsx)(`icon`,{className:kr(r.icon,r.iconPrefix),children:x(`arrow-left`)}),(0,t.jsx)(`span`,{className:r.text,children:this.options.backText})]})});n.insertBefore(i,n.firstChild)}_handleBack(e){if(!this.options)return;let t=e.closest(`[data-menu-back]`);if(!t)return;let n=t.parentElement?.parentElement;n?.hasAttribute(`data-menu-has-children`)&&n.classList.remove(this.options.className.active),t.remove()}_toggleActive(e){if(!this.options)return;let t=e.classList.contains(this.options.className.active);this._clearActive(),t||e.classList.add(this.options.className.active)}_clearActive(){!this.dom.root||!this.options||j(`[data-menu-item]`,this.dom.root).forEach(e=>{e.classList.remove(this.options?.className.active||`is-active`)})}setItems(e){if(!this.options)throw Error(`Menu.setItems: instance destroyed.`);if(this._verifyItems(e),this.options.items=e,this._bound){if(this._element===!1){let e=this._element;this._teardown({keepElement:!0}),this._element=e,this.build()}else if(this.dom.root){let n=Nr(this.dom.root);if(!n)throw Error(`Menu: [data-menu-list] element not found.`);this._unbindEvents(),this.cleanup?.items?.(),this.cleanup&&(this.cleanup.items=(0,t.render)(()=>e.map(e=>this._buildItem(e)),n)),this._bindEvents()}}return this}removeItem(e){if(!this.dom.root)return this;let t=j(`[data-menu-item]`,this.dom.root).find(t=>t.dataset.menuItem===String(e));if(t&&t.remove(),this.options?.items){let t=n=>{for(let r=n.length-1;r>=0;r--)if(n[r].id===e)n.splice(r,1);else{let e=n[r].children;e&&t(e)}};t(this.options.items)}return this}destroy(){this._destroyed||(this._destroyed=!0,this._bound?this._teardown():(this._element=null,this.dom.root=null,this.cleanup?.events.clear()),this.cleanup=null,this.options=null)}};function Rr(e={},t=!1){return new Lr(e,t)}e.Accordion=mn,e.Component=P,e.Drop=xn,e.Flow=Ht,e.Form=mt,e.Menu=Lr,e.Modal=$n,e.Offcanvas=Nn,e.Pagination=dr,e.Parabola=Yt,e.Sticky=Ot,e.Swiper=Cr,e.Tabs=an,e.Theme=Ve,e.Toast=I,e.Toc=xt,e.Tooltip=En,e.Validator=$e,e.addIcons=pe,e.all=j,e.copy=i,e.createAccordion=hn,e.createDrop=Sn,e.createEventManager=M,e.createFlow=Ut,e.createForm=ht,e.createLoading=k,e.createMenu=Rr,e.createModal=er,e.createOffcanvas=Pn,e.createPagination=fr,e.createParabola=Xt,e.createSticky=kt,e.createSwiper=wr,e.createTabs=on,e.createToc=St,e.createTooltip=Dn,e.createValidator=et,e.debounce=re,e.getCookie=N,e.getRegistedIconPath=fe,e.getType=u,e.hasOwn=s,e.icon=x,e.iconHtml=ue,e.iconMarkup=de,e.isClass=f,e.isElement=C,e.isFunction=d,e.isMobile=r,e.isNode=S,e.isPlainObject=p,e.isRenderableContent=O,e.lazyRender=xe,e.listen=Ee,e.normalizeContentNodes=w,e.postJson=De,e.q=A,e.randomId=v,e.removeCookie=je,e.requireContainer=D,e.resolveContainer=be,e.resolveElement=E,e.resolveNode=ye,e.resolveNodeList=T,e.resolveProps=_,e.restUrl=Oe,e.service=o,e.setCookie=Ae,e.throttle=y,e.timer=l,e.uniq=c,e.uuid=ne,e.validateParam=g});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vanilla-signal"),require("vanilla-signal-i18n")):typeof define==`function`&&define.amd?define([`exports`,`vanilla-signal`,`vanilla-signal-i18n`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.jui={},e.vanillaSignal,e.vanillaSignalI18n))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function r(){if(typeof window>`u`||typeof navigator>`u`)return!1;if(navigator.userAgentData&&typeof navigator.userAgentData.mobile==`boolean`)return navigator.userAgentData.mobile;let e=navigator.userAgent||navigator.vendor||window.opera||``,t=/Android|iPhone|iPad|iPod|Mobile|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e),n=/iPad|Android(?!.*Mobile)|Tablet/i.test(e);if(t&&!n){if(/iPhone|iPod|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e))return!0;if(/Android/i.test(e)){let e=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window;return Math.min(window.screen.width,window.screen.height)<=768||e}}if(/Macintosh|MacIntel/i.test(e)){let e=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window,t=Math.min(window.screen.width,window.screen.height);return e&&t<=768}return!1}async function i(e){if(typeof window>`u`||typeof document>`u`)return Promise.resolve(!1);let t=String(e);if(navigator.clipboard&&typeof navigator.clipboard.writeText==`function`)try{return await navigator.clipboard.writeText(t),!0}catch{return a(t)}return a(t)}function a(e){let t=null;try{return t=document.createElement(`textarea`),t.value=e,t.setAttribute(`readonly`,``),t.style.position=`absolute`,t.style.left=`-9999px`,t.style.opacity=`0`,document.body.appendChild(t),t.select(),t.setSelectionRange(0,e.length),document.execCommand(`copy`)}catch{return!1}finally{t&&t.parentNode&&t.parentNode.removeChild(t)}}let o=(()=>{let e=new Map;return{get(t,n){return e.has(t)||e.set(t,n()),e.get(t)},destroy(t){let n=e.get(t);n&&(typeof n.destroy==`function`&&n.destroy(),e.delete(t))},destroyAll(){for(let t of e.values())typeof t.destroy==`function`&&t.destroy();e.clear()}}})(),s=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),c=e=>Array.from(new Set(e.filter(Boolean))),l={timers:{},start(e,t,n){this.timers[e]&&clearTimeout(this.timers[e]),this.timers[e]=setTimeout(()=>{n(),delete this.timers[e]},t)},cancel(e){this.timers[e]&&(clearTimeout(this.timers[e]),delete this.timers[e])}},u=e=>e===null?`null`:Array.isArray(e)?`array`:typeof HTMLElement<`u`&&e instanceof HTMLElement?`HTMLElement`:typeof Node<`u`&&e instanceof Node?`Node`:typeof e,d=e=>typeof e==`function`&&s(e,`prototype`)&&e.prototype!==null&&typeof e.prototype==`object`&&s(e.prototype,`constructor`)&&e.prototype.constructor===e,f=e=>typeof e==`function`&&/^class\s/.test(Function.prototype.toString.call(e));function p(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function m(e){return Array.isArray(e)?e.slice():p(e)?{...e}:e}function h(e={}){return typeof e==`string`||Array.isArray(e)?{type:e}:!e||typeof e!=`object`?{}:e}function ee(e,t,n=[]){let r=Array.isArray(n)?n:n?[n]:[];for(let n of r){let r,i;if(typeof n==`function`)r=n,i=`does not satisfy the required condition.`;else if(n&&typeof n.test==`function`)r=n.test,i=n.message||`condition failed.`;else throw Error(`Validator: Condition must be a function or { test, message }.`);if(!r(t))throw Error(`Validator: ${e} ${i}`)}}function te(e,t){return e?`${e}.${t}`:t}function g(e,t,n={},r=``){let i=h(n),a=te(r,e),o=s(i,`types`)?i.types:i.type;if(i.required&&t==null)throw Error(`Validator: ${a} is required.`);if(o!==void 0){let e=Array.isArray(o)?o:[o],n=u(t);if(!e.some(e=>e===n)){let t=e.join(`, `);throw Error(`Validator: ${a} expects ${t}, but got ${n}.`)}ee(a,t,i.conditions)}else ee(a,t,i.conditions);if(Array.isArray(i.enum)&&!i.enum.includes(t))throw Error(`Validator: ${a} expects one of ${i.enum.join(`, `)}.`);if(typeof i.validate==`function`&&!i.validate(t))throw Error(`Validator: ${a} ${i.message||`does not satisfy the required condition.`}`);return t}function _(e={},t={},n=`Options`){let r=e??{};if(typeof r!=`object`||Array.isArray(r))throw Error(`${n} expects object.`);let i=r,a={...i},o=Object.entries(t||{});for(let[e,t]of o){let n=h(t);a[e]=s(r,e)?r[e]:ie(n)}for(let[e,n]of o){let r=h(n);typeof r.normalize==`function`&&(a[e]=r.normalize(a[e],{key:e,input:i,options:a,schema:t}))}for(let[e,t]of o)g(e,a[e],t,n);return a}function ne(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=new Uint8Array(16);if(typeof crypto.getRandomValues!=`function`)throw Error(`Your browser is too old to support secure login.`);crypto.getRandomValues(e),e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e).map(e=>e.toString(16).padStart(2,`0`)).join(``);return[t.slice(0,8),t.slice(8,12),t.slice(12,16),t.slice(16,20),t.slice(20,32)].join(`-`)}function v(e=8){if(!Number.isInteger(e)||e<1||e>87381)throw Error(`Length must be an integer between 1 and 87381`);let t=Math.ceil(e*3/4),n=new Uint8Array(t);crypto.getRandomValues(n);let r=``;for(let e of n)r+=String.fromCharCode(e);return btoa(r).substring(0,e).replace(/\+/g,`-`).replace(/\//g,`_`)}function re(e,t=0,n={}){if(typeof e!=`function`)throw TypeError(`Expected a function`);let r=Number(t)||0,i=n&&typeof n==`object`?n:{},a=!!i.leading,o=!s(i,`trailing`)||!!i.trailing,c=s(i,`maxWait`),l=c?Math.max(Number(i.maxWait)||0,r):0,u,d,f,p,m=0;function h(t){let n=u;return n?(u=void 0,m=t,d=Reflect.apply(e,n.receiver,n.args),d):d}function ee(e){return m=e,f=setTimeout(_,r),a?h(e):d}function te(e){let t=e-(p||0),n=e-m,i=r-t;return c?Math.min(i,l-n):i}function g(e){let t=e-(p||0),n=e-m;return p===void 0||t>=r||t<0||c&&n>=l}function _(){let e=Date.now();if(g(e))return ne(e);f=setTimeout(_,te(e))}function ne(e){return f=void 0,o&&u?h(e):(u=void 0,d)}function v(){f!==void 0&&clearTimeout(f),m=0,p=void 0,f=void 0,u=void 0}function re(){return f===void 0?d:ne(Date.now())}function y(...e){let t=Date.now(),n=g(t);if(u={receiver:this,args:e},p=t,n){if(f===void 0)return ee(p);if(c)return f=setTimeout(_,r),h(p)}return f===void 0&&(f=setTimeout(_,r)),d}return y.cancel=v,y.flush=re,y}function y(e,t=0,n={}){if(typeof e!=`function`)throw TypeError(`Expected a function`);let r=n&&typeof n==`object`?n:{};return re(e,t,{leading:!s(r,`leading`)||!!r.leading,trailing:!s(r,`trailing`)||!!r.trailing,maxWait:t})}function ie(e){if(!s(e,`default`))return;let t=e.default;return m(e.factory&&typeof t==`function`?t():t)}var ae={info:`<path d="M12 22C6.47715 22 2 17.5228 2 12 2 6.47715 6.47715 2 12 2 17.5228 2 22 6.47715 22 12 22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM13 10.5V15H14V17H10V15H11V12.5H10V10.5H13ZM13.5 8C13.5 8.82843 12.8284 9.5 12 9.5 11.1716 9.5 10.5 8.82843 10.5 8 10.5 7.17157 11.1716 6.5 12 6.5 12.8284 6.5 13.5 7.17157 13.5 8Z"></path>`,success:`<path d="M4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12ZM12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2ZM17.4571 9.45711L16.0429 8.04289L11 13.0858L8.20711 10.2929L6.79289 11.7071L11 15.9142L17.4571 9.45711Z"></path>`,warning:`<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM11 15H13V17H11V15ZM11 7H13V13H11V7Z"></path>`,error:`<path d="M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM12 20C16.4183 20 20 16.4183 20 12C20 7.58172 16.4183 4 12 4C7.58172 4 4 7.58172 4 12C4 16.4183 7.58172 20 12 20ZM12 10.5858L14.8284 7.75736L16.2426 9.17157L13.4142 12L16.2426 14.8284L14.8284 16.2426L12 13.4142L9.17157 16.2426L7.75736 14.8284L10.5858 12L7.75736 9.17157L9.17157 7.75736L12 10.5858Z"></path>`,"arrow-left":`<path d="M10.8284 12.0007L15.7782 16.9504L14.364 18.3646L8 12.0007L14.364 5.63672L15.7782 7.05093L10.8284 12.0007Z"></path>`,"arrow-right":`<path d="M13.1717 12.0007L8.22192 7.05093L9.63614 5.63672L16.0001 12.0007L9.63614 18.3646L8.22192 16.9504L13.1717 12.0007Z"></path>`,"arrow-up":`<path d="M11.9999 10.8284L7.0502 15.7782L5.63599 14.364L11.9999 8L18.3639 14.364L16.9497 15.7782L11.9999 10.8284Z"></path>`,"arrow-down":`<path d="M11.9999 13.1714L16.9497 8.22168L18.3639 9.63589L11.9999 15.9999L5.63599 9.63589L7.0502 8.22168L11.9999 13.1714Z"></path>`,more:`<path d="M5 10C3.9 10 3 10.9 3 12C3 13.1 3.9 14 5 14C6.1 14 7 13.1 7 12C7 10.9 6.1 10 5 10ZM19 10C17.9 10 17 10.9 17 12C17 13.1 17.9 14 19 14C20.1 14 21 13.1 21 12C21 10.9 20.1 10 19 10ZM12 10C10.9 10 10 10.9 10 12C10 13.1 10.9 14 12 14C13.1 14 14 13.1 14 12C14 10.9 13.1 10 12 10Z"></path>`,close:`<path d="M11.9997 10.5865L16.9495 5.63672L18.3637 7.05093L13.4139 12.0007L18.3637 16.9504L16.9495 18.3646L11.9997 13.4149L7.04996 18.3646L5.63574 16.9504L10.5855 12.0007L5.63574 7.05093L7.04996 5.63672L11.9997 10.5865Z"></path>`,loader:`<path d="M12 3C16.9706 3 21 7.02944 21 12H19C19 8.13401 15.866 5 12 5V3Z"></path>`,menu:`<path d="M3 4H21V6H3V4ZM3 11H21V13H3V11ZM3 18H21V20H3V18Z"></path>`,palette:`<path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C17.5222 2 22 5.97778 22 10.8889C22 13.9556 19.5111 16.4444 16.4444 16.4444H14.4778C13.5556 16.4444 12.8111 17.1889 12.8111 18.1111C12.8111 18.5333 12.9778 18.9222 13.2333 19.2111C13.5 19.5111 13.6667 19.9 13.6667 20.3333C13.6667 21.2556 12.9 22 12 22C6.47778 22 2 17.5222 2 12C2 6.47778 6.47778 2 12 2ZM10.8111 18.1111C10.8111 16.0843 12.451 14.4444 14.4778 14.4444H16.4444C18.4065 14.4444 20 12.851 20 10.8889C20 7.1392 16.4677 4 12 4C7.58235 4 4 7.58235 4 12C4 16.19 7.2226 19.6285 11.324 19.9718C10.9948 19.4168 10.8111 18.7761 10.8111 18.1111ZM7.5 12C6.67157 12 6 11.3284 6 10.5C6 9.67157 6.67157 9 7.5 9C8.32843 9 9 9.67157 9 10.5C9 11.3284 8.32843 12 7.5 12ZM16.5 12C15.6716 12 15 11.3284 15 10.5C15 9.67157 15.6716 9 16.5 9C17.3284 9 18 9.67157 18 10.5C18 11.3284 17.3284 12 16.5 12ZM12 9C11.1716 9 10.5 8.32843 10.5 7.5C10.5 6.67157 11.1716 6 12 6C12.8284 6 13.5 6.67157 13.5 7.5C13.5 8.32843 12.8284 9 12 9Z"></path>`,message:`<path d="M2 8.99374C2 5.68349 4.67654 3 8.00066 3H15.9993C19.3134 3 22 5.69478 22 8.99374V21H8.00066C4.68659 21 2 18.3052 2 15.0063V8.99374ZM20 19V8.99374C20 6.79539 18.2049 5 15.9993 5H8.00066C5.78458 5 4 6.78458 4 8.99374V15.0063C4 17.2046 5.79512 19 8.00066 19H20ZM14 11H16V13H14V11ZM8 11H10V13H8V11Z"></path>`,chat:`<path d="M10 3H14C18.4183 3 22 6.58172 22 11C22 15.4183 18.4183 19 14 19V22.5C9 20.5 2 17.5 2 11C2 6.58172 5.58172 3 10 3ZM12 17H14C17.3137 17 20 14.3137 20 11C20 7.68629 17.3137 5 14 5H10C6.68629 5 4 7.68629 4 11C4 14.61 6.46208 16.9656 12 19.4798V17Z"></path>`,discuss:`<path d="M14 22.5L11.2 19H6C5.44772 19 5 18.5523 5 18V7.10256C5 6.55028 5.44772 6.10256 6 6.10256H22C22.5523 6.10256 23 6.55028 23 7.10256V18C23 18.5523 22.5523 19 22 19H16.8L14 22.5ZM15.8387 17H21V8.10256H7V17H11.2H12.1613L14 19.2984L15.8387 17ZM2 2H19V4H3V15H1V3C1 2.44772 1.44772 2 2 2Z"></path>`};let oe=`http://www.w3.org/2000/svg`,b=ae;function se(e){if(!(e in b))throw Error(`Icon "${e}" not found.`)}function ce(e){return se(e),`<svg xmlns="${oe}" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">${b[e]}</svg>`}function le(e){return e!==null&&e.namespaceURI===oe}function x(e,t={}){let n=document.createElement(`template`);n.innerHTML=ce(e);let r=n.content.firstElementChild;if(!le(r))throw Error(`Icon "${e}" cannot be rendered.`);for(let[e,n]of Object.entries(t||{})){if(n==null||n===!1)continue;let t=e===`className`?`class`:e;r.setAttribute(t,n===!0?``:String(n))}return r}function ue(e){return ce(e)}let de=ue;function fe(){return{...b}}function pe(e){if(typeof e!=`object`||!e)throw Error(`Icons must be a valid object.`);for(let[t,n]of Object.entries(e)){if(typeof n!=`string`||!n.trim().startsWith(`<`))throw Error(`Invalid SVG path for icon "${t}".`);b[t]=n}}let me=[`node`,`element`,`array`];function he(e){return me.includes(e)}function S(e){return e instanceof Node}function C(e){return e instanceof Element}function ge(e){return typeof e==`string`||C(e)||S(e)||Array.isArray(e)}function _e(e){return e.find(C)||null}function ve(e,t=[]){for(let n of e){if(Array.isArray(n)){if(!ve(n,t))return null;continue}if(S(n)){t.push(n);continue}return null}return t}function w(e,t){if(typeof e==`function`)return w(e(t),t);let n=e;if(n==null||n===!1||n===!0)return[];if(Array.isArray(n))return n.flatMap(e=>w(e,t));if(S(n))return[n];if(typeof n==`string`){let e=document.createElement(`template`);return e.innerHTML=n,Array.from(e.content.childNodes)}return[document.createTextNode(String(n))]}function T(e){if(e===!1||e==null)return null;if(typeof e==`string`){let t=j(e);return t.length>0?t:null}if(Array.isArray(e)){let t=ve(e,[]);return t&&t.length>0?t:null}return S(e)?[e]:null}function ye(e){return C(e)||S(e)?e:typeof e==`string`?document.querySelector(e):Array.isArray(e)&&(T(e)||[])[0]||null}function E(e){if(!ge(e))return null;if(typeof e==`string`){let t=document.querySelector(e);return C(t)?t:null}if(Array.isArray(e)){let t=T(e);return Array.isArray(t)?_e(t):null}return C(e)?e:null}function be(e,t=`Component`,n=`element`){if(!he(n))throw Error(`${t}: expect must be one of 'node', 'element', 'array'.`);return ge(e)?n===`array`?T(e):n===`node`?ye(e):E(e):null}function D(e,t=`Component`,n=`element`){let r=be(e,t,n);if(r==null)throw Error(`${t}: container not found.`);return r}function O(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`function`||Array.isArray(e)||S(e)}function k(){return(0,t.jsx)(`div`,{"aria-live":`polite`,style:{display:`flex`,justifyContent:`center`,alignItems:`center`,position:`absolute`,width:`100%`,height:`100%`,backdropFilter:`blur(4px)`},children:x(`loader`,{width:24,className:`animate-spin`})})}function A(e,t=document){return t.querySelector(e)}function j(e,t=document){return Array.from(t.querySelectorAll(e))}function xe(e,t,n={}){if(typeof t!=`function`)throw TypeError(`lazyRender: renderCallback expects function.`);let{threshold:r=.1,rootMargin:i=`0px`,root:a=null,waitForDOM:o=!0}=n,s={threshold:r,rootMargin:i,root:a};if(!Ce(e))return console.warn(`lazyRender: target 必须是 CSS 选择器字符串或 DOM 元素`),Se;let c=Se,l=we(e);if(l&&document.body.contains(l))return c=Te(l,t,s),c;if(!o||typeof MutationObserver>`u`)return t(),c;let u=new MutationObserver(()=>{let n=we(e);!n||!document.body.contains(n)||(l=n,u.disconnect(),c=Te(l,t,s))});return u.observe(document.documentElement,{childList:!0,subtree:!0}),()=>{u.disconnect(),c()}}function Se(){}function Ce(e){return typeof e==`string`||C(e)}function we(e){return typeof e==`string`?A(e):e}function Te(e,t,n){if(typeof window>`u`||window.IntersectionObserver===void 0)return t(),Se;let r=new window.IntersectionObserver(n=>{for(let i of n)if(i.isIntersecting){r.unobserve(e),r.disconnect(),t();break}},n);return r.observe(e),()=>{r.unobserve(e),r.disconnect()}}function Ee(e,t,n,r){let i=!0;return e.addEventListener(t,n,r),()=>{i&&(i=!1,e.removeEventListener(t,n,r))}}function M(){let e=new Map,t=t=>{let n=e.get(t);return n?(n(),e.delete(t),!0):!1};return{on(n,r,i,a,o){if(typeof n!=`string`||n.trim()===``)throw TypeError(`EventManager.on: key expects a non-empty string.`);if(t(n),r==null)return()=>{};let s=Ee(r,i,a,o);return e.set(n,s),s},off:t,clear(){for(let t of e.values())t();e.clear()},size(){return e.size}}}async function De(e,t,n={}){let r=new Headers(n.headers);return r.has(`Content-Type`)||r.set(`Content-Type`,`application/json`),(await fetch(e,{...n,method:`POST`,headers:r,body:JSON.stringify(t)})).json()}let Oe=typeof window<`u`?`${window.location.origin}/wp-json`:``;function N(e){if(typeof document>`u`)return null;let t=ke(e),n=document.cookie.match(RegExp(`(?:^|;\\s*)`+t+`=([^;]*)`));return n?decodeURIComponent(n[1]):null}function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Ae(e,t,n=3600*24){if(typeof document>`u`)return!1;let r=`${encodeURIComponent(e)}=${encodeURIComponent(t)}; path=/; SameSite=Lax`;if(n>0){let e=new Date(Date.now()+n*1e3).toUTCString();r+=`; expires=${e}`}return location.protocol===`https:`&&(r+=`; Secure`),document.cookie=r,N(e)===t}function je(e){return typeof document>`u`?!0:(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`,!N(e))}function Me(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var P=class e{constructor(e={}){this.props=e||{},this.dom={root:null},this.plugins=new Map,this.cleanup={events:M(),plugins:new Map},this._listeners={init:[],beforeUpdate:[],afterUpdate:[],destroy:[]},this.state=(0,t.createDeepStore)({}),this.runtime={destroyed:!1},this.installGlobalPlugins()}get root(){return this.dom?.root||null}set root(e){this.dom||(this.dom={root:null}),this.dom.root=e}use(e,t){if(!e)return this;let n=typeof e==`function`?e(this,t):e.install?.(this,t);return this.cleanup.plugins.set(e,n),this}on(e,t){return!this._listeners[e]||typeof t!=`function`||this._listeners[e].push(t),this}off(e,t){return this._listeners[e]&&(this._listeners[e]=this._listeners[e].filter(e=>e!==t)),this}installGlobalPlugins(){for(let t of e.globalPlugins.values())this.use(t)}static useGlobal(t,n){!t||!n||e.globalPlugins.set(t,n)}emit(e,...t){let n=this._listeners[e];if(!n)return this;for(let e of n)try{e(...t)}catch{}return this}init(e={}){if(this.runtime.destroyed)throw Error(`Component.init: instance destroyed`);return Me(e)&&(this.props=Object.assign({},this.props,e)),typeof this.onInit==`function`&&this.onInit(this.props),this.emit(`init`,this.props),this}setState(e={},n){if(this.runtime.destroyed)throw Error(`Component.setState: instance destroyed`);let r=typeof e==`string`&&arguments.length>1?{[e]:n}:e;if(!Me(r))throw Error(`Component.setState: expects a plain object patch.`);return(0,t.flushSync)(()=>{for(let[e,t]of Object.entries(r)){if(!this.state)return;this.state[e]=t}}),this}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);return Me(e)&&(this.props=Object.assign({},this.props,e)),this.emit(`beforeUpdate`,e,{force:t}),typeof this.onUpdate==`function`&&this.onUpdate(e,{force:t}),this.emit(`afterUpdate`,e,{force:t}),this}destroy(){if(!this.runtime.destroyed){this.runtime.destroyed=!0,typeof this.onDestroy==`function`&&this.onDestroy(),this.emit(`destroy`);for(let e of this.cleanup.plugins.values())try{typeof e==`function`?e():e&&typeof e.destroy==`function`&&e.destroy()}catch{}this.cleanup.plugins.clear(),this.cleanup.events.clear(),this.dom={root:null},this.state=null}}};P.globalPlugins=new Map;var Ne={en:{b:`Back`,t:`Customize`,sm:`Small`,md:`Medium`,lg:`Large`},zh:{b:`返回`,t:`自定义主题`,Primary:`主色`,Radius:`圆角`,Shadow:`阴影`,Font:`字号`,Mode:`模式`,Gray:`灰色`,Olive:`橄榄绿`,Tomato:`番茄红`,Ruby:`红宝石`,Pink:`粉红`,Violet:`紫罗兰`,Indigo:`靛蓝`,Blue:`蓝色`,Teal:`青色`,Grass:`草绿`,Mint:`薄荷绿`,Lime:`酸橙绿`,Yellow:`黄色`,Orange:`橙色`,Gold:`金色`,None:`无`,sm:`小`,md:`中`,lg:`大`,XL:`更大`,Round:`圆角`,Light:`浅色`,Dark:`深色`,Auto:`自动`,Close:`关闭`,Confirm:`确认`}};let Pe={panel:`j-theme-palette`,closeWrap:`theme-palette-close`,closeButton:`j-button is-text`,title:`theme-palette-title`,description:`theme-palette-description`,container:`palette-container`,item:`palette-item`,itemTitle:`item-title`,items:`items`,button:`j-button is-default`,active:`is-active`,prefix:`el-prefix`,swatch:`item-hex`,buttonText:`button-text`},Fe={mode:`dark`,theme:`indigo`,radius:`sm`,shadow:`sm`,font:`sm`,key:`ui-theme`,className:Pe},Ie={theme:`j-theme-`,radius:`j-radius-`,shadow:`j-shadow-`,font:`j-font-`};function Le(e){return{...Pe,...e}}function Re(e={}){return{...Fe,...e,className:Le(e.className)}}function ze(e){return e===`mode`||e===`theme`||e===`radius`||e===`shadow`||e===`font`}function Be(...e){return e.filter(Boolean).join(` `)}var Ve=class{constructor(e={}){this.props=(0,t.createDeepStore)(Re(e)),this.languages=Ne,this.cleanup=null,this.runtime={destroyed:!1},this.init()}init(){this.cleanup={bindings:new Set,events:M()},this.loadConfig(),this.bindEvent()}translate(e){return(0,n.t)(e,this.languages)}loadConfig(){try{let e=N(this.props.key);if(!e?.trim())return;let t=JSON.parse(e);Object.assign(this.props,t,{className:Le({...this.props.className,...t.className})})}catch{}}saveConfig(){let{mode:e,theme:t,radius:n,shadow:r,font:i}=this.props,a=e===`auto`?this.scheme():e;Ae(this.props.key,JSON.stringify({mode:e,theme:t,radius:n,shadow:r,font:i,render:a}))}scheme(){return window.matchMedia?.(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}bindActiveButtons(e){let n=(0,t.createRoot)(n=>{let r=j(`[data-theme-group]`,e);for(let e of r){let n=e.dataset.themeGroup;if(!ze(n))continue;let r=j(`[data-theme-button]`,e);for(let e of r){let r=()=>e.dataset.themeValue===String(this.props[n]);(0,t.bindClass)(e,this.props.className.active,r),(0,t.bindAttr)(e,`aria-selected`,()=>r()?`true`:null)}}return n});this.cleanup?.bindings.add(n)}bindEvent(){this.cleanup?.events.on(`palette`,document.body,`click`,e=>{if(!(e.target instanceof Element))return;let n=e.target.closest(`[data-theme-button]`);if(!n)return;let r=n.closest(`[data-theme-group]`),i=r?.dataset.themeGroup,a=n.dataset.themeValue;if(!r||!ze(i)||!a||n.classList.contains(this.props.className.active))return;let o=this.props[i];(0,t.flushSync)(()=>{this.props[i]=a});let s=document.documentElement;if(i===`mode`){let e=a===`auto`?this.scheme():a;s.classList.remove(`light`,`dark`,o),s.classList.add(e)}else{let e=Ie[i],t=Array.from(s.classList).filter(t=>t.startsWith(e));t.length&&s.classList.remove(...t),s.classList.add(`${e}${a}`)}this.saveConfig()})}unbindEvent(){this.cleanup?.events.clear()}createPanel(e=null,n=null){let r=this.props.className,i=n||this.defaultPanelConfig(),a=(0,t.jsx)(`div`,{className:e||r.panel,"data-theme-palette":`root`,children:[(0,t.jsx)(`h3`,{className:r.title,"data-theme-title":``,style:{margin:`0 0 1rem`},children:this.translate(`t`)}),(0,t.jsx)(`div`,{className:r.container,"data-theme-container":``,children:i.map(e=>(0,t.jsx)(`div`,{className:r.item,"data-palette":e.type,"data-theme-group":e.type,children:[(0,t.jsx)(`div`,{className:r.itemTitle,"data-theme-group-title":e.type,children:e.title}),(0,t.jsx)(`div`,{className:r.items,"data-theme-items":e.type,children:e.buttons.map(([n,i])=>{let a=String(this.props[e.type])===String(n);return(0,t.jsx)(`button`,{className:Be(r.button,a&&r.active),"data-palette":n,"data-theme-button":e.type,"data-theme-value":n,"aria-selected":a?`true`:null,children:[e.type===`theme`?(0,t.jsx)(`span`,{className:Be(r.prefix,r.swatch),"data-theme-swatch":n,style:{backgroundColor:`var(--ui-${n})`}}):null,(0,t.jsx)(`span`,{className:r.buttonText,"data-theme-button-text":n,children:i})]})})})]}))})]});return this.bindActiveButtons(a),a}setConfig(e){(0,t.flushSync)(()=>{Object.assign(this.props,e,{className:Le({...this.props.className,...e.className})})}),this.saveConfig()}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this.unbindEvent(),this.cleanup?.bindings.forEach(e=>e()),this.cleanup?.bindings.clear(),this.cleanup=null)}defaultPanelConfig(){return[{title:this.translate(`Primary`),type:`theme`,buttons:[[`gray`,this.translate(`Gray`)],[`olive`,this.translate(`Olive`)],[`tomato`,this.translate(`Tomato`)],[`ruby`,this.translate(`Ruby`)],[`pink`,this.translate(`Pink`)],[`violet`,this.translate(`Violet`)],[`indigo`,this.translate(`Indigo`)],[`blue`,this.translate(`Blue`)],[`teal`,this.translate(`Teal`)],[`grass`,this.translate(`Grass`)],[`mint`,this.translate(`Mint`)],[`lime`,this.translate(`Lime`)],[`yellow`,this.translate(`Yellow`)],[`orange`,this.translate(`Orange`)],[`gold`,this.translate(`Gold`)]]},{title:this.translate(`Radius`),type:`radius`,buttons:[[`none`,this.translate(`None`)],[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)],[`lg`,this.translate(`lg`)],[`xl`,this.translate(`XL`)],[`round`,this.translate(`Round`)]]},{title:this.translate(`Shadow`),type:`shadow`,buttons:[[`none`,this.translate(`None`)],[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)],[`lg`,this.translate(`lg`)]]},{title:this.translate(`Font`),type:`font`,buttons:[[`sm`,this.translate(`sm`)],[`md`,this.translate(`md`)]]},{title:this.translate(`Mode`),type:`mode`,buttons:[[`light`,this.translate(`Light`)],[`dark`,this.translate(`Dark`)],[`auto`,this.translate(`Auto`)]]}]}};let He={container:`j-toast-container`,toast:`j-toast`,icon:`toast-icon`,message:`toast-message`,hidden:`is-hidden`,lite:`j-toast-lite`,action:`is-action`,actions:`toast-actions`,button:`j-button is-sm`,closeButton:`is-ghost`,actionButton:`is-outline`,info:`is-info`,success:`is-success`,warning:`is-warning`,error:`is-error`,primary:`is-primary`},Ue={type:`string`,enum:[`info`,`success`,`warning`,`error`,`primary`]},We={type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},Ge={type:`number`,validate:e=>typeof e==`number`&&e>0,message:`expects a number greater than 0.`};function Ke(e){return{...He,...e}}function F(...e){return e.filter(Boolean).join(` `)}var I=class e{static configure(t={}){return e.options={className:Ke(t.className)},e.options}static resolveClassNames(t){return Ke({...e.options.className,...t?.className})}static show(n=``,r=3e3,i=`info`,a={}){g(`message`,n,`string`,`Toast.show`),g(`duration`,r,We,`Toast.show`),g(`type`,i,Ue,`Toast.show`);let o=e.resolveClassNames(a),s=e.getOrCreateContainer(o),c=v(),l=(0,t.jsx)(`div`,{className:F(o.toast,o[i]),"data-toast":c,role:`alert`,"aria-atomic":`true`,children:[(0,t.jsx)(`span`,{className:o.icon,"data-toast-icon":c,children:x(i===`primary`?`info`:i)}),(0,t.jsx)(`span`,{className:o.message,"data-toast-message":c,children:n})]});e.classNames.set(l,o),s.appendChild(l);let u=i===`error`?`assertive`:`polite`;e.setTimer(c,`show`,()=>l.setAttribute(`aria-live`,u),10),r>0&&e.setTimer(c,`hide`,()=>e.hide(l),r);let d=Ee(l,`click`,()=>e.hide(l));return e.disposers.set(l,d),l}static success(t=``,n=3e3,r={}){return e.show(t,n,`success`,r)}static info(t=``,n=3e3,r={}){return e.show(t,n,`info`,r)}static primary(t=``,n=3e3,r={}){return e.show(t,n,`primary`,r)}static warning(t=``,n=3e3,r={}){return e.show(t,n,`warning`,r)}static error(t=``,n=3e3,r={}){return e.show(t,n,`error`,r)}static hide(t){if(!t)return;e.disposers.get(t)?.(),e.disposers.delete(t),t.removeAttribute(`aria-live`),t.setAttribute(`aria-hidden`,`true`);let n=t.dataset.toast||v();e.setTimer(n,`remove`,()=>{t.remove();let e=A(`[data-toast-container]`);e&&e.children.length===0&&e.remove()},300)}static lite(n=``,r=2e3,i={}){g(`message`,n,`string`,`Toast.lite`),g(`duration`,r,Ge,`Toast.lite`);let a=e.resolveClassNames(i);A(`[data-toast-lite]`)?.remove();let o=v(),s=(0,t.jsx)(`div`,{className:a.lite,"data-toast":o,"data-toast-lite":``,children:n});return e.classNames.set(s,a),document.body.appendChild(s),e.setTimer(o,`show`,()=>s.setAttribute(`aria-live`,`polite`),10),e.setTimer(o,`hide`,()=>{s.removeAttribute(`aria-live`),s.setAttribute(`aria-hidden`,`true`),e.setTimer(o,`remove`,()=>s.remove(),300)},r),s}static action(r=``,i={}){g(`message`,r,`string`,`Toast.action`);let a=(0,n.t)(`Close`,Ne),o=(0,n.t)(`Confirm`,Ne),s=e.resolveClassNames(i),c=e.getOrCreateContainer(s),l=v(),u=(0,t.jsx)(`div`,{className:F(s.toast,s.action),"data-toast":l,"data-toast-action":``,children:[(0,t.jsx)(`div`,{className:s.message,"data-toast-message":l,children:r}),(0,t.jsx)(`div`,{className:s.actions,"data-toast-actions":l,children:[(0,t.jsx)(`button`,{className:F(s.button,s.closeButton),children:i.text?.close||a,"data-action":`close`,"aria-label":i.text?.close||a,onClick:async()=>{await i.onClose?.(),e.hide(u)}}),(0,t.jsx)(`button`,{className:F(s.button,s.actionButton),children:i.text?.action||o,"data-action":`toast-action`,"aria-label":i.text?.action||o,onClick:async()=>{await i.onAction?.(),e.hide(u)}})]})]});return e.classNames.set(u,s),c.appendChild(u),e.setTimer(l,`show`,()=>{u.setAttribute(`aria-live`,`polite`),A(`[data-action="toast-action"]`,u)?.focus()},10),u}static getOrCreateContainer(e){let n=A(`[data-toast-container]`);return n?n.className=e.container:(n=(0,t.jsx)(`div`,{className:e.container,"data-toast-container":``}),document.body.appendChild(n)),n}static setTimer(t,n,r,i){let a=`${t}-${n}`;return e.timers.add(a),l.start(a,i,()=>{e.timers.delete(a),r()}),a}static clearAll(){for(let t of e.timers)l.cancel(t);e.timers.clear();for(let t of e.disposers.values())t();e.disposers.clear(),A(`[data-toast-container]`)?.remove(),A(`[data-toast-lite]`)?.remove()}static destroyAll(){e.clearAll()}};I.timers=new Set,I.disposers=new Map,I.classNames=new WeakMap,I.options={className:He};let qe={rules:{default:{},type:`object`},messages:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]}};function Je(e){let t=_(e,qe,`Validator.options`);return{rules:t.rules,messages:t.messages,onSubmit:t.onSubmit}}function L(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement}function Ye(e){if(!e)return null;if(e instanceof Element)return L(e)?e:null;for(let t of Array.from(e))if(t instanceof Element&&L(t))return t;return null}function Xe(){return{valid:!0,message:``,destroyed:!1}}function Ze(e){return e.closest(`[data-form-control]`)||e.parentElement}function Qe(e){return Array.from(e.selectedOptions).map(e=>e.value.trim())}function R(e){return e instanceof HTMLInputElement&&e.type===`file`}function z(e){return!!e.files&&e.files.length>0}var $e=class{constructor(e,t={},n=!1){this.options=Je(t),this.root=this.resolveRoot(e),this.runtime=Xe(),this.cleanup={events:M()},this.validateOptions(n),n&&this.bindEvents()}resolveRoot(e){let t=E(e);if(!(t instanceof HTMLFormElement))throw Error(`Validator.element expects a form element.`);return t}validateOptions(e){g(`bindEvents`,e,`boolean`,`Validator`)}bindEvents(){this.unbindEvents(),!(!this.root||!this.cleanup)&&(this.cleanup.events.on(`submit`,this.root,`submit`,e=>{e.preventDefault(),this.validate()}),this.cleanup.events.on(`reset`,this.root,`reset`,()=>{this.reset({native:!1})}))}unbindEvents(){this.cleanup?.events.clear()}validate(){if(!this.root||!this.options)return!1;this.runtime.valid=!0,this.runtime.message=``;for(let e of Array.from(this.root.elements))if(!(!L(e)||!e.name)&&this.options.rules[e.name]&&(this.runtime.valid=this.validateRule(e,e.name),!this.runtime.valid))break;return this.runtime.valid&&this.options.onSubmit&&this.options.onSubmit(this),this.runtime.valid}validateRule(e,t){if(!this.options)return!1;let n=this.options.rules[t];if(!n)return!0;if(this.hasNativeValidationRule(e))return this.runtime.valid;for(let r of Object.keys(n)){let i=n[r],a=``;switch(r){case`required`:this.runtime.valid=this.validateRequired(e,i);break;case`minLength`:this.runtime.valid=this.validateMinLength(e,i);break;case`maxLength`:this.runtime.valid=this.validateMaxLength(e,i);break;case`equalTo`:this.runtime.valid=this.validateEqualTo(e,i);break;case`email`:this.runtime.valid=this.validateEmail(e);break;case`checked`:this.runtime.valid=this.validateCheck(e,i);break;case`selected`:this.runtime.valid=this.validateSelected(e,i);break;case`multiple`:this.runtime.valid=this.validateMultiple(e,i);break;case`min`:this.runtime.valid=this.validateSelectMin(e,i);break;case`max`:this.runtime.valid=this.validateSelectMax(e,i);break;case`noSpace`:this.runtime.valid=this.validateNoSpace(e,i);break;case`noChinese`:this.runtime.valid=!/[\u4e00-\u9fa5]/.test(e.value);break;case`noSpecial`:this.runtime.valid=!/[@#$%^&*]+/g.test(e.value);break;case`pattern`:this.runtime.valid=this.validatePattern(e,i);break;case`file`:this.runtime.valid=this.validateFile(e,i);break;case`minSize`:this.runtime.valid=this.validateMinSize(e,i);break;case`maxSize`:this.runtime.valid=this.validateMaxSize(e,i);break;case`accept`:this.runtime.valid=this.validateAccept(e,i);break;case`validate`:{let t=this.validateCustom(e,i);this.runtime.valid=t===!0,a=typeof t==`string`?t:``;break}}if(!this.runtime.valid){this.showError(e,t,r,a);break}this.showSuccess(e)}return this.runtime.valid}hasNativeValidationRule(e){return e.hasAttribute(`required`)||e.hasAttribute(`minlength`)||e.hasAttribute(`maxlength`)||e.hasAttribute(`pattern`)||e.hasAttribute(`min`)||e.hasAttribute(`max`)||e.hasAttribute(`step`)}validateRequired(e,t){return t===!0?e instanceof HTMLSelectElement?Qe(e).some(e=>e.length>0):e.value.trim().length>=1:!0}validateMinLength(e,t){return typeof t!=`number`||e.value.length>=t}validateMaxLength(e,t){return typeof t!=`number`||e.value.length<=t}validateEmail(e){return/^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(e.value)}validateEqualTo(e,t){if(!this.root||typeof t!=`string`)return!0;let n=Ye(this.root.elements.namedItem(t));if(!n)throw Error(`Validator: target element "${t}" not found.`);return e.value===n.value}validateCheck(e,t){if(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)throw Error(`Validator: element expects a checkbox input, but ${e.tagName.toLowerCase()} given.`);return e.checked===t}validateSelected(e,t){if(!(e instanceof HTMLSelectElement))throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t!==!0||Qe(e).some(e=>e.length>0)}validateMultiple(e,t){if(!(e instanceof HTMLSelectElement))throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t!==!0||e.selectedOptions.length>0}validateSelectMin(e,t){return!(e instanceof HTMLSelectElement)||typeof t!=`number`||e.selectedOptions.length>=t}validateSelectMax(e,t){return!(e instanceof HTMLSelectElement)||typeof t!=`number`||e.selectedOptions.length<=t}validateNoSpace(e,t){return!/\s/.test(e.value)||t!==!0}validatePattern(e,t){return typeof t==`string`||t instanceof RegExp?new RegExp(t).test(e.value):!0}validateFile(e,t){return!R(e)||t!==!0||z(e)}validateMinSize(e,t){return!R(e)||!z(e)||typeof t!=`number`||e.files[0].size>=t}validateMaxSize(e,t){return!R(e)||!z(e)||typeof t!=`number`||e.files[0].size<=t}validateAccept(e,t){if(!R(e)||!z(e)||typeof t!=`string`)return!0;let n=e.files[0];return t.split(`,`).map(e=>e.trim().toLowerCase()).some(e=>e.startsWith(`.`)?n.name.toLowerCase().endsWith(e):e.endsWith(`/*`)?n.type.startsWith(e.replace(`/*`,`/`)):n.type===e)}validateCustom(e,t){if(typeof t!=`function`)return!0;let n=t(e,this);return typeof n==`string`?n:!!n}showError(e,n,r,i=``){(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)&&(e.classList.remove(`is-valid`),e.classList.add(`is-invalid`));let a=i||this.options?.messages[n]?.[r]||``;if(!a)return;this.runtime.message=a;let o=Ze(e);if(!o)return;let s=j(`[data-validator-help]`,o).find(e=>e.dataset.validatorHelp===n)||null;s||(s=(0,t.jsx)(`div`,{className:`help-block is-invalid`,"data-validator-help":n}),o.appendChild(s)),s.textContent=a}showSuccess(e){let t=Ze(e);if(t)for(let n of j(`[data-validator-help]`,t))n.dataset.validatorHelp===e.name&&n.remove();(!(e instanceof HTMLInputElement)||e.type!==`checkbox`)&&(e.classList.remove(`is-invalid`),e.classList.add(`is-valid`))}reset({native:e=!0}={}){if(this.root){e&&this.root.reset();for(let e of Array.from(this.root.elements))L(e)&&(e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`));for(let e of j(`[data-validator-help]`,this.root))e.remove();this.runtime.valid=!0,this.runtime.message=``}}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this.unbindEvents(),this.reset({native:!1}),this.root=null,this.options=null,this.runtime.valid=!1,this.runtime.message=``,this.cleanup?.events.clear(),this.cleanup=null)}};function et(e,t={},n=!1){return new $e(e,t,n)}let tt={form:`j-form`,vertical:`is-vertical`,horizontal:`is-horizontal`,itemVertical:`is-item-vertical`,itemHorizontal:`is-item-horizontal`,item:`form-item`,label:`item-label`,required:`is-required`,control:`form-control`,helpInvalid:`is-invalid`,buttons:`form-buttons`,button:`j-button`,input:`j-input`,textarea:`j-textarea`,select:`j-select`,radio:`j-radio`,checkbox:`j-checkbox`,choiceVertical:`is-vertical`,choiceHorizontal:`is-horizontal`,choiceGroup:`is-group`,radioLabel:`radio-label`,radioText:`radio-text`,switch:`j-switch`,switchDefault:`is-default`,switchSizeMd:`is-md`,switchSlider:`switch-slider`},nt=[{type:`submit`,text:`Submit`,theme:`primary`,action:`submit`},{type:`reset`,text:`Reset`,theme:`ghost`,action:`reset`}],rt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():v():e??v()},vertical:{default:!0,type:`boolean`},itemVertical:{default:!0,type:`boolean`},style:{default:``,types:[`string`,`object`,`null`]},fields:{default:[],type:`array`},buttons:{default:nt,types:[`boolean`,`array`],normalize:e=>e===!1?[]:e===!0?B(nt):Array.isArray(e)?B(e):e},className:{default:tt,type:`object`,normalize:e=>ut(e)},validator:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]},onReset:{default:null,types:[`function`,`null`]}},it={validate:e=>p(e),message:`expects a props object.`};function at(e){return Array.isArray(e)?e.map(e=>e&&typeof e==`object`?{...e}:e):[]}function ot(e){return Array.isArray(e)?e.map(e=>({...e,options:at(e.options)})):[]}function B(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function st(e){return e&&typeof e==`object`?e:{value:e,text:String(e)}}function V(e){return e==null?``:typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):e.name}function ct(e,t){return O(e)?w(e,t):null}function lt(e,t){return e.name?!!e.required||!!t?.[e.name]?.required:!!e.required}function H(...e){return e.filter(Boolean).join(` `)}function ut(e){return{...tt,...p(e)?e:{}}}function dt(e,t){if(e.removeAttribute(`style`),t){if(typeof t==`string`){e.style.cssText=t;return}if(p(t))for(let[n,r]of Object.entries(t)){if(r==null||typeof r!=`string`&&typeof r!=`number`)continue;let t=n.startsWith(`--`)?n:n.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(t,String(r))}}}function ft(e){let t=p(e)?e:{};return{...t,rules:p(t.rules)?t.rules:{},messages:p(t.messages)?t.messages:{}}}function pt(e){let t=_(e,rt,`Form.props`);return{...t,id:String(t.id),vertical:!!t.vertical,itemVertical:!!t.itemVertical,style:t.style,fields:ot(t.fields),buttons:B(t.buttons),className:ut(t.className),validator:ft(t.validator),onSubmit:t.onSubmit,onReset:t.onReset}}var U=class extends P{constructor(e={},n=!1){let r=pt(e);super(r),this.dom.container=n,this.dom.fields=new Map,this.validator=null,this.cleanup.view=null,this.cache={initial:this.cloneProps(r),fieldIds:new Map},this.state=(0,t.createDeepStore)({...this.cloneProps(r),submitting:!1,data:null})}get root(){return this.dom?.root||null}set root(e){this.dom.root=e}onInit(){this.dom.container!==!1&&this.dom.container!=null&&typeof this.dom.container!=`string`&&this.mount(this.dom.container)}build(e=this.dom.container){if(this.runtime.destroyed)throw Error(`Form.build: instance destroyed`);return this.cleanup.view?this:(this.dom.container=e===!1?document.createDocumentFragment():D(e,`Form.container`),this.init(this.props),this)}mount(e=this.dom.container){return this.cleanup.view||!e||(this.cleanup.view=(0,t.createRoot)(n=>((0,t.onCleanup)((0,t.render)(()=>this.view(),e)),n))),this}view(){let e=this.state.className;return(0,t.jsx)(`form`,{className:()=>H(this.state.className.form,this.state.vertical?e.vertical:e.horizontal,this.state.itemVertical?e.itemVertical:e.itemHorizontal),id:()=>this.state.id,style:()=>this.state.style,"data-form":`root`,"data-form-layout":()=>this.state.vertical?`vertical`:`horizontal`,"data-form-item-layout":()=>this.state.itemVertical?`vertical`:`horizontal`,ref:e=>{let t=this.root!==e;this.root=e,dt(e,this.state.style),(t||!this.validator)&&this.syncValidator()},onSubmit:e=>this.handleSubmit(e),onReset:e=>this.handleReset(e),children:()=>[...this.state.fields.map((e,t)=>this.fieldView(e,t)),this.buttonsView()]})}fieldView(e,n){let r=this.resolveFieldId(e,n),i=e.type===`hidden`,a=this.state.className;return(0,t.jsx)(`div`,{className:a.item,"data-form-item":e.name||String(n),style:{display:i?`none`:``},children:[this.labelView(e,r),(0,t.jsx)(`div`,{className:a.control,"data-form-control":e.name||String(n),children:[this.controlView(e,r,n),e.help?(0,t.jsx)(`div`,{className:`help-block`,"data-form-help":e.name||String(n),children:e.help}):null]})]})}labelView(e,n){if(e.label===!1||e.label===void 0)return null;let r=this.state.className;return(0,t.jsx)(`label`,{className:H(r.label,lt(e,this.state.validator?.rules)?r.required:``),"data-form-label":e.name||n,for:n,children:e.label})}controlView(e,t,n){switch(e.type){case`textarea`:return this.textareaView(e,t);case`select`:return this.selectView(e,t);case`radio`:return this.choiceGroupView(e,t,`radio`);case`checkbox`:return Array.isArray(e.options)?this.choiceGroupView(e,t,`checkbox`):this.inputView(e,t);case`switch`:return this.switchView(e,t);case`custom`:return ct(e.content,{form:this,field:e,index:n});default:return this.inputView(e,t)}}inputView(e,n){let r=e.type||`text`;return(0,t.jsx)(`input`,{...this.controlProps(e,n,{type:r,className:e.className||this.state.className.input,autocomplete:e.autocomplete||this.autoComplete(r),value:e.value??``}),checked:e.checked===void 0?void 0:!!e.checked})}textareaView(e,n){return(0,t.jsx)(`textarea`,this.controlProps(e,n,{className:e.className||this.state.className.textarea,autocomplete:e.autocomplete,value:e.value??``}))}selectView(e,n){let r=e.value;return(0,t.jsx)(`select`,this.controlProps(e,n,{className:e.className||this.state.className.select,autocomplete:e.autocomplete||`off`,multiple:!!e.multiple,children:(e.options||[]).map(e=>{let n=st(e);return(0,t.jsx)(`option`,{value:n.value??``,disabled:!!n.disabled,selected:this.isSelected(r,n.value),children:n.text??n.label??n.value??``})})}))}choiceGroupView(e,n,r){let i=e.vertical?`vertical`:`horizontal`,a=this.state.className;return(0,t.jsx)(`div`,{className:H(r===`radio`?a.radio:a.checkbox,i===`vertical`?a.choiceVertical:a.choiceHorizontal,e.group?a.choiceGroup:``,e.size?`is-${e.size}`:``),"data-form-choice-group":e.name||n,"data-choice-type":r,"data-choice-layout":i,children:(e.options||[]).map((i,o)=>{let s=st(i),c=`${n}_${o}`;return(0,t.jsx)(`label`,{className:r===`radio`?a.radioLabel:``,"data-form-choice":e.name||n,for:c,children:[(0,t.jsx)(`input`,{type:r,id:c,name:e.name,value:s.value??``,checked:r===`radio`?this.isSelected(e.value,s.value):this.isChecked(e.value,s.value,s.checked),disabled:!!s.disabled||!!e.disabled,required:!!e.required}),(0,t.jsx)(`span`,{className:r===`radio`?a.radioText:``,"data-form-choice-text":``,children:s.text??s.label??s.value??``})]})})})}switchView(e,n){let r=this.state.className;return(0,t.jsx)(`label`,{className:H(r.switch,e.variant?`is-${e.variant}`:r.switchDefault,e.size?`is-${e.size}`:r.switchSizeMd),"data-form-switch":e.name||n,for:n,children:[(0,t.jsx)(`input`,{type:`checkbox`,id:n,name:e.name,value:e.value??`on`,checked:!!e.checked,disabled:!!e.disabled,required:!!e.required}),(0,t.jsx)(`span`,{className:r.switchSlider,"data-form-switch-slider":``})]})}buttonsView(){if(!this.state.buttons.length)return null;let e=this.state.className;return(0,t.jsx)(`div`,{className:e.buttons,"data-form-buttons":``,children:this.state.buttons.map(n=>(0,t.jsx)(`button`,{type:n.type||`button`,className:H(e.button,n.theme?`is-${n.theme}`:``,n.className||``),"data-action":n.action||n.type||`button`,disabled:()=>!!this.state.submitting||!!n.disabled,children:n.text??n.label??``}))})}controlProps(e,t,n){return{...n,name:e.name,id:t,placeholder:e.placeholder||``,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly,"data-form-field":e.name||t,ref:t=>{e.name&&this.dom.fields.set(e.name,t)}}}resolveFieldId(e,t){if(e.id)return e.id;let n=e.name||t;return this.cache.fieldIds.has(n)||this.cache.fieldIds.set(n,`${this.state.id}_field_${t}`),this.cache.fieldIds.get(n)||`${this.state.id}_field_${t}`}syncValidator(){if(!this.root)return;let e={...this.state.validator,onSubmit:null};if(this.validator?.root===this.root){this.validator.options=e;return}this.validator?.destroy(),this.validator=new $e(this.root,e,!1)}validate(){return!this.validator||this.validator.validate()}reset(){return this.validator?.reset(),(0,t.flushSync)(()=>{this.state.data=null}),this}async handleSubmit(e){if(e.preventDefault(),this.state.submitting||!this.validate())return;let n=this.collectData();(0,t.flushSync)(()=>{this.state.submitting=!0,this.state.data=n});try{await Promise.resolve(this.state.onSubmit?.(n,this))}finally{this.runtime.destroyed||(0,t.flushSync)(()=>{this.state.submitting=!1})}}handleReset(e){this.resetValidationState(),(0,t.flushSync)(()=>{this.state.data=null}),this.state.onReset?.(e,this)}resetValidationState(){if(this.root){for(let e of Array.from(this.root.elements))e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`);for(let e of j(`[data-form-help], [data-validator-help]`,this.root))(e.dataset.validatorHelp||e.classList.contains(`is-invalid`))&&e.remove()}}collectData(){return this.root?this.collectFormData(this.root):{}}collectFormData(e){let t={},n=new FormData(e);for(let[e,r]of n.entries())s(t,e)?t[e]=Array.isArray(t[e])?[...t[e],r]:[t[e],r]:t[e]=r;return t}requestSubmit(){if(!this.root)return this;if(typeof this.root.requestSubmit==`function`)return this.root.requestSubmit(),this;let e=new Event(`submit`,{bubbles:!0,cancelable:!0});return this.root.dispatchEvent(e),this}update(e={},n={}){let r=e||{};g(`props`,r,it,`Form.update`);let i=pt(Object.assign({},this.props,r));return this.props=this.cloneProps(i),this.cache.fieldIds.clear(),super.update(i),(0,t.flushSync)(()=>{let e=this.cloneProps(i);for(let t of Object.keys(e))this.state[t]=e[t]}),this}setFields(e){return g(`fields`,e,`array`,`Form.setFields`),this.update({fields:e})}resetFields(){return this.setFields(this.cache.initial.fields)}cloneProps(e){return{...e,fields:ot(e.fields),buttons:B(e.buttons),className:ut(e.className),validator:ft(e.validator)}}autoComplete(e){switch(e){case`password`:return`current-password`;case`email`:return`email`;default:return`on`}}isSelected(e,t){return Array.isArray(e)?e.map(e=>V(e)).includes(V(t)):e==t}isChecked(e,t,n){return n===void 0?Array.isArray(e)?e.map(e=>V(e)).includes(V(t)):typeof e!=`string`&&typeof e!=`boolean`&&!(e instanceof File)?!1:e===!0||V(e)===V(t):!!n}onDestroy(){let e=this.cleanup.view;typeof e==`function`&&e(),this.cleanup.view=null,this.validator?.destroy(),this.validator=null}};function mt(e={},t=!1){return new U(e,t)}let ht={toc:`j-toc`,list:`toc-list`,link:`toc-link`,active:`is-active`,levelPrefix:`is-level-`},gt={container:{default:null},target:{default:`.j-content`},headings:{default:`h2, h3`,type:`string`},offset:{default:80,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},className:{default:ht,type:`object`,normalize:e=>({...ht,...e&&typeof e==`object`?e:{}})},onUpdate:{default:null,types:[`function`,`null`]}};function _t(e){let t=_(e,gt,`Toc.props`);return{container:t.container,target:t.target,headings:t.headings,offset:t.offset,className:t.className,onUpdate:t.onUpdate}}function vt(e){let t=/^H([1-6])$/.exec(e.tagName);return t?Number(t[1]):1}function yt(e,t){return e.id||(e.id=`toc-${v()}-${t}`),{id:e.id,text:e.textContent||``,level:vt(e),element:e}}var bt=class extends P{constructor(e={}){let n=_t(e);super(n),this.dom.container=null,this.dom.target=null,this.dom.list=null,this.dom.headings=[],this.dom.links=[],this.runtime.built=!1,this.runtime.ticking=!1,this.state=(0,t.createDeepStore)({items:[],current:{index:-1,item:null}})}build(){if(this.runtime.destroyed)throw Error(`Toc.build: instance destroyed`);if(this.runtime.built)return this;this.init(this.props),this.dom.container=D(this.props.container,`Toc.container`),this.dom.target=D(this.props.target,`Toc.target`);let e=document.createElement(`nav`);return e.className=this.props.className.toc,e.dataset.toc=`root`,this.root=e,this.dom.list=document.createElement(`div`),this.dom.list.className=this.props.className.list,this.dom.list.dataset.tocList=`root`,e.appendChild(this.dom.list),this.dom.container.innerHTML=``,this.dom.container.appendChild(e),this.runtime.built=!0,this.refresh(),this}bindEvents(){this.dom.list&&(this.cleanup.events.on(`scroll`,window,`scroll`,()=>this.onScroll(),{passive:!0}),this.cleanup.events.on(`click`,this.dom.list,`click`,e=>this.onClick(e)))}onScroll(){this.runtime.ticking||(requestAnimationFrame(()=>{this.updateActive(),this.runtime.ticking=!1}),this.runtime.ticking=!0)}onClick(e){if(!(e.target instanceof Element)||!this.dom.list)return;let t=e.target.closest(`[data-toc-index]`);if(!t||!this.dom.list.contains(t))return;let n=Number(t.dataset.tocIndex),r=this.state?.items[n];r&&(e.preventDefault(),this.scrollToItem(r,{activeIndex:n,updateHash:!0}))}scrollToItem(e,{activeIndex:t=-1,updateHash:n=!1}={}){let r=window.scrollY||window.pageYOffset||0,i=Math.max(0,e.element.getBoundingClientRect().top+r-this.props.offset);window.scrollTo({top:i,behavior:`smooth`}),t>=0&&this.setActive(t),n&&window.history?.pushState&&window.history.pushState(null,``,`#${e.id}`)}linkClassName(e,t=!1){let n=[this.props.className.link,`${this.props.className.levelPrefix}${e.level}`];return t&&n.push(this.props.className.active),n.filter(Boolean).join(` `)}buildLink(e,n){return(0,t.jsx)(`a`,{className:this.linkClassName(e),href:`#${e.id}`,"data-toc-index":String(n),"data-toc-target":e.id,children:e.text})}updateActive(){if(!this.runtime.built)return;let e=-1,t=this.props.offset+1;for(let n=this.dom.headings.length-1;n>=0;n--)if(this.dom.headings[n].getBoundingClientRect().top<=t){e=n;break}this.setActive(e)}setActive(e){if(!this.state||e===this.state.current.index)return;let t=this.state.items[e]||null;this.setState({current:{index:e,item:t}});let n=this.state.items;this.dom.links.forEach((t,r)=>{let i=r===e;t.dataset.active=i?`1`:`0`,t.className=this.linkClassName(n[r],i)}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(t,e,this)}refresh(){if(this.runtime.destroyed||!this.runtime.built||!this.dom.target||!this.dom.list)return this;this.cleanup.events.clear(),this.dom.headings=j(this.props.headings,this.dom.target);let e=this.dom.headings.map(yt);this.dom.links=e.map((e,t)=>this.buildLink(e,t)),this.dom.list.innerHTML=``;for(let e of this.dom.links)this.dom.list.appendChild(e);return this.setState({items:e,current:{index:-1,item:null}}),this.bindEvents(),this.updateActive(),this}activate(e){return!this.runtime.built||!this.state||!Number.isInteger(e)||e<0||e>=this.dom.links.length||this.scrollToItem(this.state.items[e]),this}onDestroy(){this.cleanup.events.clear(),this.dom.container&&(this.dom.container.innerHTML=``),this.runtime.built=!1,this.runtime.ticking=!1,this.dom.container=null,this.dom.target=null,this.dom.list=null,this.dom.headings=[],this.dom.links=[]}};function xt(e={}){return new bt(e)}let St={target:{default:null},parent:{default:null},max:{default:10,type:`number`,validate:e=>typeof e==`number`&&Number.isInteger(e)&&e>0,message:`expects a positive integer.`},top:{default:16,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},gap:{default:16,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},overflow:{default:`destroy`,type:`string`,enum:[`destroy`,`ignore`]},onUpdate:{default:null,types:[`function`,`null`]}};function Ct(e){let t=_(e,St,`Sticky.props`);return{target:t.target,parent:t.parent,max:t.max,top:t.top,gap:t.gap,overflow:t.overflow,onUpdate:t.onUpdate}}function wt(e){let t=e.filter(e=>e instanceof HTMLElement);return Array.from(new Set(t))}function Tt(e){return e===!1||e==null?null:D(e,`Sticky.parent`,`element`)}function Et(e,t){if(e===!1||e==null)return[];if(typeof e==`string`){if(!t)return wt(D(e,`Sticky.target`,`array`));let n=wt(j(e,t));if(n.length===0)throw Error(`Sticky.target: target not found.`);return n}let n=wt(D(e,`Sticky.target`,`array`));if(!t)return n;let r=n.filter(e=>e===t||t.contains(e));if(r.length===0)throw Error(`Sticky.target: target not found in parent.`);return r}var Dt=class extends P{constructor(e={}){let n=Ct(e);super(n),this.dom.parent=null,this.dom.targets=[],this.runtime.active=!1,this.runtime.built=!1,this.runtime.ignored=!1,this.runtime.items=[],this.state=(0,t.createDeepStore)({count:0,top:n.top,items:[]})}build(){if(this.runtime.destroyed)throw Error(`Sticky.build: instance destroyed`);return this.runtime.built||(this.init(this.props),this.dom.parent=Tt(this.props.parent),this.dom.targets=Et(this.props.target,this.dom.parent),this.dom.targets=this.resolveOverflow(this.dom.targets),this.runtime.built=!0,this.dom.targets.length===0)?this:(this.runtime.active=!0,this.captureItems(),this.apply(),this)}captureItems(){this.runtime.items=this.dom.targets.map(e=>({element:e,top:this.props.top,originalPosition:e.style.position,originalTop:e.style.top,originalZIndex:e.style.zIndex}))}resolveOverflow(e){let{max:t,overflow:n}=this.props;return e.length<=t?e:(this.runtime.ignored=n===`ignore`,n===`ignore`?[]:e.slice(-t))}apply(e=this.props.top){let t=e,n=[];for(let e of this.runtime.items)e.top=t,e.element.style.position=`sticky`,e.element.style.top=`${t}px`,n.push({element:e.element,top:t}),t+=e.element.offsetHeight+this.props.gap;return this.setState({count:this.runtime.items.length,top:this.runtime.items[0]?.top??this.props.top,items:n}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(this),t}restore(){for(let e of this.runtime.items)e.element.style.position=e.originalPosition,e.element.style.top=e.originalTop,e.element.style.zIndex=e.originalZIndex}refresh(){return this.runtime.destroyed||!this.runtime.built||!this.runtime.active||this.apply(),this}destroy(){this.runtime.destroyed||(this.restore(),super.destroy())}onDestroy(){this.runtime.active=!1,this.runtime.built=!1,this.runtime.items=[],this.dom.targets=[]}};function Ot(e={}){return new Dt(e)}let W={root:`j-flow`,header:`flow-header`,title:`flow-title`,description:`flow-description`,steps:`flow-steps`,step:`flow-step`,active:`is-active`,complete:`is-complete`,stepButton:`flow-step-button`,stepIndex:`flow-step-index`,stepTitle:`flow-step-title`,body:`flow-body`,footer:`flow-footer`,button:`j-button`,buttonGhost:`is-ghost`,buttonPrimary:`is-primary`,reset:`flow-reset`,back:`flow-back`,next:`flow-next`};function kt(e){return!!e&&typeof e==`object`&&typeof e.id==`string`}function At(e){return e==null||e===!1||typeof e==`function`}function G(e){return p(e)?{...e}:{}}function jt(e){return Array.isArray(e)?[...e]:[]}function Mt(e){return Array.isArray(e)?e.map(e=>{let t=e;return{...t,data:G(t.data),modal:typeof t.modal==`function`||t.modal==null?t.modal:G(t.modal),view:G(t.view)}}):[]}function Nt(e,t){return typeof e==`string`?{id:e}:p(e)&&typeof e.id==`string`?{id:e.id,data:p(e.data)||e.data==null?e.data:void 0}:{id:t}}function Pt(e){if(typeof e==`string`){let t=e.trim();return{...W,root:t?`${W.root} ${t}`:W.root}}return{...W,...p(e)?e:{}}}function K(...e){return e.filter(Boolean).join(` `)}let Ft={validate:kt,message:`expects a step object with a string id.`},It={validate:O,message:`expects string, Node, array, function or null.`},Lt={validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty steps array.`},q={validate:e=>e==null||p(e),message:`expects an object or null.`},J={validate:At,message:`expects function, false or null.`},Rt={default:{},validate:p,message:`expects an object with text fields.`,normalize:e=>{let t=p(e)?e:{};return{...Object.fromEntries(Object.entries(t).filter(([,e])=>typeof e==`string`)),back:typeof t.back==`string`?t.back:`Back`,next:typeof t.next==`string`?t.next:`Next`,finish:typeof t.finish==`string`?t.finish:`Finish`,reset:typeof t.reset==`string`?t.reset:`Reset`}}},zt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},steps:{default:[],...Lt},initial:{default:null,types:[`string`,`number`,`null`]},cache:{default:!0,type:`boolean`},linear:{default:!0,type:`boolean`},render:{default:!0,type:`boolean`},rollbackOnError:{default:!0,type:`boolean`},busyStrategy:{default:`ignore`,type:`string`,enum:[`ignore`,`throw`]},showHeader:{default:!0,type:`boolean`},showFooter:{default:!0,type:`boolean`},showSteps:{default:!0,type:`boolean`},showBack:{default:!0,type:`boolean`},showNext:{default:!0,type:`boolean`},showReset:{default:!1,type:`boolean`},text:Rt,className:{default:W,types:[`object`,`string`],normalize:Pt},renderHeader:{default:null,...J},renderSteps:{default:null,...J},renderBody:{default:null,...J},renderFooter:{default:null,...J},onChange:{default:null,types:[`function`,`null`]},onNext:{default:null,types:[`function`,`null`]},onBack:{default:null,types:[`function`,`null`]},onFinish:{default:null,types:[`function`,`null`]},onError:{default:null,types:[`function`,`null`]},onBusy:{default:null,types:[`function`,`null`]}};function Bt(e){let t=_(e,zt,`Flow.options`);return{id:t.id,steps:Mt(t.steps),initial:t.initial,cache:t.cache,linear:t.linear,render:t.render,rollbackOnError:t.rollbackOnError,busyStrategy:t.busyStrategy,showHeader:t.showHeader,showFooter:t.showFooter,showSteps:t.showSteps,showBack:t.showBack,showNext:t.showNext,showReset:t.showReset,text:t.text,className:t.className,renderHeader:t.renderHeader,renderSteps:t.renderSteps,renderBody:t.renderBody,renderFooter:t.renderFooter,onChange:t.onChange,onNext:t.onNext,onBack:t.onBack,onFinish:t.onFinish,onError:t.onError,onBusy:t.onBusy}}var Vt=class{constructor(e={}){this.options=Bt(e),this.steps=this.options.steps,this.validateSteps(this.steps),this.stepMap=new Map(this.steps.map((e,t)=>[e.id,t])),this.initialStepId=this.resolveInitialStepId(this.options.initial),this.initialData=this.createInitialStepData(),this.subscribers=new Set,this.renderDispose=null,this.cleanupTasks=new Set,this.nodes={},this.destroyed=!1,this.activeAction=null,this.actionController=null,this.root=null,this.state=(0,t.createDeepStore)({id:this.options.id,currentId:this.initialStepId,currentIndex:this.stepMap.get(this.initialStepId)??0,previousId:null,previousIndex:null,direction:null,history:[this.initialStepId],data:G(this.initialData.global),stepData:G(this.initialData.stepData),loading:!1,error:null,busyAction:null,version:0})}get currentStep(){return this.steps[this.state.currentIndex]}get currentData(){return this.getStepData(this.state.currentId)}get canBack(){return this.state.currentIndex>0&&!this.state.loading}get canNext(){return this.state.currentIndex<this.steps.length-1&&!this.state.loading}get isLast(){return this.state.currentIndex===this.steps.length-1}subscribe(e){if(this.assertActive(`subscribe`),typeof e!=`function`)throw Error(`Flow.subscribe: handler expects a function.`);return this.subscribers.add(e),e(this.snapshot(),this,null),()=>this.subscribers.delete(e)}snapshot(){let e=this.currentStep;return{id:this.state.id,currentId:this.state.currentId,currentIndex:this.state.currentIndex,previousId:this.state.previousId,previousIndex:this.state.previousIndex,direction:this.state.direction,history:[...this.state.history],data:G(this.state.data),stepData:G(this.state.stepData),currentData:this.currentData,currentStep:this.publicStep(e),canBack:this.canBack,canNext:this.canNext,isLast:this.isLast,loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error}}mount(e){if(this.assertActive(`mount`),!this.options.render)return this;let t=D(e,`Flow.mount.container`,`element`);return this.unmount(),this.root=this.buildRoot(),t.appendChild(this.root),this.mountView(),this}unmount(){return this.renderDispose?.(),this.renderDispose=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.nodes={},this}async next(e=null){return this.assertActive(`next`),g(`payload`,e,q,`Flow.next`),this.handleBusy(`next`)||this.runAction(`next`,async()=>{if(this.isLast)return this.finish(e,{internal:!0});let t=this.currentStep,n=this.steps[this.state.currentIndex+1]?.id,{id:r,data:i}=Nt(await this.runMoveHook(`next`,t,e,n),n);return this.goTo(r,i??e,{direction:`next`,internal:!0})})}async back(e=null){return this.assertActive(`back`),g(`payload`,e,q,`Flow.back`),this.handleBusy(`back`)||(this.canBack?this.runAction(`back`,async()=>{let t=this.currentStep,n=this.steps[this.state.currentIndex-1]?.id,{id:r,data:i}=Nt(await this.runMoveHook(`back`,t,e,n),n);return this.goTo(r,i??e,{direction:`back`,internal:!0})}):this.snapshot())}async goTo(e,t=null,n={}){return this.assertActive(`goTo`),g(`payload`,t,q,`Flow.goTo`),(n.internal?null:this.handleBusy(`goTo`))||this.runAction(`goTo`,async()=>{let r=this.resolveStepIndex(e),i=this.steps[r],a=this.currentStep;return!i||i.id===this.state.currentId?(t&&this.setStepData(this.state.currentId,t),this.snapshot()):(await this.transitionTo(i,{direction:n.direction||`go`,payload:t,fromStep:a}),this.snapshot())},{internal:n.internal})}setData(e){return this.assertActive(`setData`),g(`data`,e,q,`Flow.setData`),e?((0,t.flushSync)(()=>{Object.assign(this.state.data,e),this.state.version+=1}),this.emitChange(),this):this}setStepData(e,n,r={}){return this.assertActive(`setStepData`),g(`stepId`,e,{type:`string`},`Flow.setStepData`),g(`data`,n,q,`Flow.setStepData`),!n||!this.stepMap.has(e)?this:((0,t.flushSync)(()=>{this.state.stepData[e]={...G(this.state.stepData[e]),...n},this.options.cache&&Object.assign(this.state.data,n),this.state.version+=1}),r.silent||this.emitChange(),this)}getStepData(e){return G(this.state.stepData[e])}reset(){return this.assertActive(`reset`),(0,t.flushSync)(()=>{this.state.currentId=this.initialStepId,this.state.currentIndex=this.stepMap.get(this.initialStepId)??0,this.state.previousId=null,this.state.previousIndex=null,this.state.direction=null,this.state.history.splice(0,this.state.history.length,this.initialStepId),this.replaceObject(this.state.data,G(this.initialData.global)),this.replaceObject(this.state.stepData,G(this.initialData.stepData)),this.state.loading=!1,this.state.busyAction=null,this.state.error=null,this.state.version+=1}),this.emitChange(),this}async finish(e=null,t={}){return this.assertActive(`finish`),g(`payload`,e,q,`Flow.finish`),(t.internal?null:this.handleBusy(`finish`))||this.runAction(`finish`,async()=>(e&&this.setStepData(this.state.currentId,e),await this.callHook(this.options.onFinish,[this.snapshot(),this]),this.snapshot()),{internal:t.internal})}destroy(){if(!this.destroyed){this.destroyed=!0,this.abortActiveAction(),this.unmount();for(let e of Array.from(this.cleanupTasks))e();this.cleanupTasks.clear(),this.subscribers.clear(),this.steps=[],this.stepMap.clear(),this.activeAction=null,this.actionController=null}}resolveInitialStepId(e){if(typeof e==`number`){let t=this.steps[e];if(!t)throw Error(`Flow.options.initial index is out of range.`);return t.id}if(typeof e==`string`){if(!this.stepMap.has(e))throw Error(`Flow.options.initial step "${e}" does not exist.`);return e}return this.steps[0].id}validateSteps(e){let t=new Set;for(let[n,r]of e.entries()){if(g(String(n),r,Ft,`Flow.options.steps`),g(`content`,r.content??null,It,`Flow.options.steps.${n}`),t.has(r.id))throw Error(`Flow.options.steps: duplicated step id "${r.id}".`);t.add(r.id)}}resolveStepIndex(e){if(typeof e==`number`){if(!this.steps[e])throw Error(`Flow.goTo target is out of range.`);return e}if(typeof e==`string`){let t=this.stepMap.get(e);if(t==null)throw Error(`Flow.goTo target "${e}" does not exist.`);return t}throw Error(`Flow.goTo target expects string or number.`)}createInitialStepData(){let e={},t={};for(let n of this.steps)e[n.id]=G(n.data),Object.assign(t,e[n.id]);return{stepData:e,global:t}}async runMoveHook(e,t,n,r){let i=e===`back`?this.options.onBack:this.options.onNext,a=e===`back`?t.onBack:t.onNext,o=this.createContext({payload:n,targetId:r});if(typeof a==`function`){let e=await this.callHook(a,[o]);if(e!=null)return e}if(typeof i==`function`){let e=await this.callHook(i,[o]);if(e!=null)return e}return r}async transitionTo(e,{direction:n,payload:r,fromStep:i}){let a=this.snapshot(),o=this.captureState();try{r&&this.setStepData(i.id,r,{silent:!0}),await this.assertCanLeave(i,e,n),await this.assertCanEnter(e,i,n),typeof i.onLeave==`function`&&await this.callHook(i.onLeave,[this.createContext({direction:n,step:i,targetId:e.id})]);let o=this.state.currentId,s=this.state.currentIndex,c=this.stepMap.get(e.id)??0;(0,t.flushSync)(()=>{this.state.previousId=o,this.state.previousIndex=s,this.state.currentId=e.id,this.state.currentIndex=c,this.state.direction=n,n===`back`?this.state.history.pop():this.state.history.push(e.id),this.state.error=null,this.state.version+=1}),typeof e.onEnter==`function`&&await this.callHook(e.onEnter,[this.createContext({direction:n,fromId:o,step:e})]),this.emitChange(a)}catch(e){throw this.destroyed?e:(this.options.rollbackOnError&&this.restoreState(o,{keepLoading:!0}),this.handleError(e,a),e)}}async assertCanLeave(e,t,n){if(typeof e.canLeave==`function`&&await this.callHook(e.canLeave,[this.createContext({direction:n,targetId:t.id})])===!1)throw Error(`Flow: step "${e.id}" blocked leaving.`)}async assertCanEnter(e,t,n){if(typeof e.canEnter==`function`&&await this.callHook(e.canEnter,[this.createContext({direction:n,fromId:t.id})])===!1)throw Error(`Flow: step "${e.id}" blocked entering.`)}createContext(e={}){let t=e.step||this.currentStep,n=this.snapshot();return{...e,flow:this,step:t,state:this.state,signal:this.actionController?.signal||null,snapshot:n,data:G(this.state.data),currentData:this.getStepData(t.id),setData:e=>this.setData(e),setStepData:(e,t)=>this.setStepData(e,t),getStepData:e=>this.getStepData(e),next:e=>this.next(e),back:e=>this.back(e),goTo:(e,t,n)=>this.goTo(e,t,n),addCleanup:e=>this.addCleanup(e)}}async runAction(e,t,n={}){let r=!n.internal&&!this.state.loading;r&&(this.actionController=typeof AbortController<`u`?new AbortController:null,this.activeAction=e,this.setLoading(!0,e));try{return await t()}catch(e){if(this.destroyed)return null;throw this.state.error!==e&&this.handleError(e),e}finally{r&&!this.destroyed&&(this.setLoading(!1,null),this.activeAction=null,this.actionController=null)}}handleBusy(e){if(!this.state.loading)return null;let t=Error(`Flow: action "${e}" ignored while loading.`);if(t.code=`FLOW_BUSY`,typeof this.options.onBusy==`function`&&this.options.onBusy(e,this.snapshot(),this),this.options.busyStrategy===`throw`)throw t;return this.snapshot()}abortActiveAction(){this.actionController?.abort(),this.actionController=null,this.activeAction=null}async callHook(e,t){if(typeof e!=`function`)return;let n=await e(...t);if(this.destroyed)throw this.createAbortError();return n}createAbortError(){let e=Error(`Flow: active action was aborted.`);return e.code=`FLOW_ABORTED`,e}setLoading(e,n=this.state.busyAction){(0,t.flushSync)(()=>{this.state.loading=e,this.state.busyAction=e?n:null})}handleError(e,n=null){(0,t.flushSync)(()=>{this.state.error=e,this.state.version+=1}),typeof this.options.onError==`function`&&this.options.onError(e,this.snapshot(),this,n)}emitChange(e=null){let t=this.snapshot();for(let n of Array.from(this.subscribers))n(t,this,e);typeof this.options.onChange==`function`&&this.options.onChange(t,this,e)}replaceObject(e,t){for(let t of Object.keys(e))delete e[t];Object.assign(e,t)}captureState(){return{currentId:this.state.currentId,currentIndex:this.state.currentIndex,previousId:this.state.previousId,previousIndex:this.state.previousIndex,direction:this.state.direction,history:jt(this.state.history),data:G(this.state.data),stepData:G(this.state.stepData),loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error,version:this.state.version}}restoreState(e,n={}){(0,t.flushSync)(()=>{this.state.currentId=e.currentId,this.state.currentIndex=e.currentIndex,this.state.previousId=e.previousId,this.state.previousIndex=e.previousIndex,this.state.direction=e.direction,this.state.history.splice(0,this.state.history.length,...e.history),this.replaceObject(this.state.data,e.data),this.replaceObject(this.state.stepData,e.stepData),this.state.loading=n.keepLoading?!0:e.loading,this.state.busyAction=e.busyAction,this.state.error=e.error,this.state.version=e.version+1})}addCleanup(e){if(typeof e!=`function`)throw Error(`Flow.addCleanup: cleanup expects a function.`);return this.destroyed?(e(),()=>{}):(this.cleanupTasks.add(e),()=>this.cleanupTasks.delete(e))}assertActive(e){if(this.destroyed)throw Error(`Flow.${e}: instance has been destroyed.`)}publicStep(e){if(!e)return null;let{onEnter:t,onLeave:n,onNext:r,onBack:i,canEnter:a,canLeave:o,...s}=e;return s}buildRoot(){return(0,t.jsx)(`div`,{className:this.options.className.root,id:this.options.id,role:`group`,"data-flow":`root`,"aria-busy":()=>this.state.loading?`true`:`false`,"aria-labelledby":`${this.options.id}-title`,ref:e=>{this.nodes.root=e}})}mountView(){this.renderDispose||!this.root||(this.renderDispose=(0,t.createRoot)(e=>((0,t.onCleanup)((0,t.render)(()=>this.view(),this.root)),e)))}view(){let e=this.snapshot();return[this.renderSlot(`renderHeader`,e,()=>this.options.showHeader?this.headerView(e):null),this.renderSlot(`renderSteps`,e,()=>this.options.showSteps?this.stepsView(e):null),this.renderSlot(`renderBody`,e,()=>this.bodyView(e)),this.renderSlot(`renderFooter`,e,()=>this.options.showFooter?this.footerView(e):null)]}renderSlot(e,t,n){let r=this.options[e];return r===!1?null:typeof r==`function`?r(this.createRenderContext(t,n)):n()}createRenderContext(e,t){return{flow:this,snapshot:e,state:this.state,steps:this.steps.map(e=>this.publicStep(e)),currentStep:e.currentStep,currentData:e.currentData,data:e.data,fallback:t,next:e=>this.next(e),back:e=>this.back(e),goTo:(e,t,n)=>this.goTo(e,t,n),reset:()=>this.reset()}}headerView(e){return(0,t.jsx)(`div`,{className:this.options.className.header,"data-flow-header":``,children:[(0,t.jsx)(`div`,{id:`${this.options.id}-title`,className:this.options.className.title,"data-flow-title":``,children:e.currentStep?.title||e.currentStep?.id||``}),e.currentStep?.description?(0,t.jsx)(`div`,{className:this.options.className.description,"data-flow-description":``,children:e.currentStep.description}):null]})}stepsView(e){return(0,t.jsx)(`ol`,{className:this.options.className.steps,"data-flow-steps":``,role:`list`,"aria-label":`Flow steps`,children:this.steps.map((n,r)=>(0,t.jsx)(`li`,{className:this.stepClass(r,e.currentIndex),"data-flow-step":n.id,"data-flow-step-index":String(r),"aria-current":r===e.currentIndex?`step`:void 0,children:[(0,t.jsx)(`button`,{type:`button`,className:this.options.className.stepButton,disabled:this.options.linear&&r>e.currentIndex,"aria-current":r===e.currentIndex?`step`:void 0,"aria-disabled":this.options.linear&&r>e.currentIndex?`true`:`false`,"aria-label":`${r+1}. ${n.title||n.id}`,"data-flow-step-action":`goTo`,onClick:()=>{r!==e.currentIndex&&this.goTo(r)},children:[(0,t.jsx)(`span`,{className:this.options.className.stepIndex,"data-flow-step-number":``,children:r+1}),(0,t.jsx)(`span`,{className:this.options.className.stepTitle,"data-flow-step-title":``,children:n.title||n.id})]})]}))})}bodyView(e){return(0,t.jsx)(`div`,{className:this.options.className.body,"data-flow-body":``,role:`region`,"aria-live":`polite`,"aria-busy":e.loading?`true`:`false`,children:this.contentView(this.currentStep.content)})}footerView(e){let n=K(this.options.className.button,this.options.className.buttonGhost),r=K(this.options.className.button,this.options.className.buttonPrimary);return(0,t.jsx)(`div`,{className:this.options.className.footer,"data-flow-footer":``,children:[this.options.showReset?(0,t.jsx)(`button`,{type:`button`,className:K(n,this.options.className.reset),"data-action":`reset`,onClick:()=>this.reset(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:this.options.text.reset}):null,this.options.showBack?(0,t.jsx)(`button`,{type:`button`,className:K(n,this.options.className.back),"data-action":`back`,onClick:()=>void this.back(),disabled:!e.canBack,"aria-disabled":e.canBack?`false`:`true`,children:this.options.text.back}):null,this.options.showNext?(0,t.jsx)(`button`,{type:`button`,className:K(r,this.options.className.next),"data-action":`next`,onClick:()=>void this.next(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:e.isLast?this.options.text.finish:this.options.text.next}):null]})}contentView(e){return typeof e==`function`?e(this.createContext()):e??``}stepClass(e,t=this.state.currentIndex){return K(this.options.className.step,e===t&&this.options.className.active,e<t&&this.options.className.complete)}};function Ht(e={}){return new Vt(e)}let Ut={color:`var(--tone-solid)`,size:`12px`},Wt={ball:`parabola-ball`},Gt={validate:e=>e==null||typeof e==`string`||Array.isArray(e)||S(e),message:`expects Element, Node, selector or JSX node.`},Kt={ball:{default:Ut,type:`object`,normalize:e=>({...Ut,...e&&typeof e==`object`?e:{}}),validate:e=>!!e&&typeof e==`object`&&typeof e.color==`string`&&typeof e.size==`string`,message:`expects an object with two string properties: "color" and "size".`},className:{default:Wt,type:`object`,normalize:e=>({...Wt,...e&&typeof e==`object`?e:{}})},from:{default:null,...Gt},to:{default:null,...Gt},direction:{default:`center`,type:`string`,enum:[`center`,`top-right`,`top-left`,`bottom-right`,`bottom-left`]},showDelay:{default:0,type:`number`},hideDelay:{default:0,type:`number`},onShow:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function qt(e){let t=_(e,Kt,`Parabola.options`);return{ball:t.ball,className:t.className,from:t.from,to:t.to,direction:t.direction,showDelay:t.showDelay,hideDelay:t.hideDelay,onShow:t.onShow,onHidden:t.onHidden}}var Jt=class{constructor(e={}){this.options=qt(e),this.hidden=!1,this._ball=null,this._animationId=null,this._fromEl=E(this.options.from),this._toEl=E(this.options.to),this.showTimerId=null,this.createBall()}createBall(){if(this.hidden||this._ball)return;let{color:e,size:n}=this.options.ball;this._ball=(0,t.jsx)(`div`,{className:this.options.className.ball,"data-parabola":`ball`,style:{backgroundColor:e,width:n,height:n,position:`fixed`,borderRadius:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,zIndex:`9999`,opacity:`1`}}),document.body.appendChild(this._ball)}calculatePath(){let e=this._fromEl?.getBoundingClientRect(),t=this._toEl?.getBoundingClientRect();if(!e||!t)return null;let{left:n,top:r,width:i,height:a}=e,{left:o,top:s,width:c,height:l}=t,u,d;switch(this.options.direction){case`top-left`:u=n+i*.2,d=r+a*.2;break;case`top-right`:u=n+i*.8,d=r+a*.2;break;case`bottom-left`:u=n+i*.2,d=r+a*.8;break;case`bottom-right`:u=n+i*.8,d=r+a*.8;break;default:u=n+i/2,d=r+a/2}let f=o+c/2,p=s+l/2;return{startX:u,startY:d,endX:f,endY:p}}easeOutCubic(e){return 1-(1-e)**3}animate(e,t,n,r,i=800){if(this.hidden||!this._ball)return;let a=performance.now(),o=n-e,s=r-t,c=n=>{if(this.hidden||!this._ball)return;let r=n-a,l=Math.min(r/i,1),u=this.easeOutCubic(l),d=e+o*u,f=t+-100*Math.sin(Math.PI*u)+s*u,p=1-l;this._ball.style.left=`${d}px`,this._ball.style.top=`${f}px`,this._ball.style.opacity=`${p}`,this._ball.style.transform=`translate(-50%, -50%) scale(${1-u*.3})`,l<1?this._animationId=requestAnimationFrame(c):this.destroy()};this._animationId=requestAnimationFrame(c)}show(){return this.hidden?Promise.resolve(!1):new Promise(e=>{this.showTimerId=setTimeout(()=>{if(this.showTimerId=null,this.hidden||!this._ball){e(!1);return}let t=this.calculatePath();if(!t){this.destroy(),e(!1);return}this._ball.style.left=`${t.startX}px`,this._ball.style.top=`${t.startY}px`,this.options.onShow?.(this),this.animate(t.startX,t.startY,t.endX,t.endY),e(!0)},this.options.showDelay)})}destroy(){this.hidden||(this._ball?.remove(),this.showTimerId&&(clearTimeout(this.showTimerId),this.showTimerId=null),this._animationId&&cancelAnimationFrame(this._animationId),this._ball=null,this._fromEl=null,this._toEl=null,this._animationId=null,this.hidden=!0,this.options.onHidden?.(this))}start(){return this.show()}};function Yt(e={}){return new Jt(e)}let Xt={root:`j-tabs`,top:`is-top`,bottom:`is-bottom`,left:`is-left`,right:`is-right`,wrap:`tab-wrap`,list:`tab-list`,tab:`tab-item`,panelWrap:`tab-panel`,panel:`panel-item`,disabled:`is-disabled`,dragging:`dragging`},Zt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},direction:{default:`top`,type:`string`,enum:[`top`,`bottom`,`left`,`right`]},active:{default:0,types:[`number`,`string`]},disabled:{default:[],types:[`number`,`string`,`array`]},onChange:{default:null,types:[`function`,`null`]},tabs:{default:[],type:`array`},className:{default:Xt,type:`object`,normalize:e=>({...Xt,...e&&typeof e==`object`?e:{}})},onAdd:{default:null,types:[`function`,`null`]},onRemove:{default:null,types:[`function`,`null`]}},Qt={type:`object`,validate:e=>{let t=e;return!!t&&typeof t==`object`&&O(t.title)&&O(t.panel)},message:`expects an object with renderable title and panel: string, Node, array, function or null.`};function $t(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function en(e){return typeof e==`number`&&e>0?e:0}function tn(e){let t=_(e,Zt,`Tabs`);return{id:t.id,direction:t.direction,active:t.active,disabled:t.disabled,onChange:t.onChange,tabs:$t(t.tabs),className:t.className,onAdd:t.onAdd,onRemove:t.onRemove}}function nn(...e){return e.filter(Boolean).join(` `)}var rn=class extends P{constructor(e,n={}){let r=D(e,`Tabs`),i=tn(n);super(i),this.dom.container=r,this.dom.tabs=[],this.dom.panels=[],this.bindingsDispose=null,this.isDragging=!1,this.raf=0,this.resizeRaf=0,this.velocity=0,this.state=(0,t.createDeepStore)({current:{index:-1,name:null},disabled:this.parseDisabled(i.disabled),isVertical:i.direction===`left`||i.direction===`right`,draggable:!1,loading:!1}),this.runtime.cache={panels:new Map},this.runtime.panelLoadId=0;try{this.onInit(i)}catch(e){throw this.destroy(),e}}onInit(e){this.root=this.buildRoot(e),this.rebuildItems(),this.activateInternal(e.active,!1),this.bindEvents(),this.initDrag()}buildRoot(e){let{id:n,direction:r,className:i}=e,a=(0,t.jsx)(`nav`,{className:i.list,"data-tabs-list":``}),o=(0,t.jsx)(`div`,{className:i.wrap,"data-tabs-wrap":``,children:a}),s=(0,t.jsx)(`div`,{className:i.panelWrap,"data-tabs-panel-wrap":``});return(0,t.jsx)(`div`,{className:nn(i.root,i[r]),id:n,"data-tabs":`root`,"data-tabs-direction":r,children:[o,s]})}rebuildItems(){if(!this.root)return;let e=A(`[data-tabs-list]`,this.root),n=A(`[data-tabs-panel-wrap]`,this.root);if(!e||!n)return;e.textContent=``,n.textContent=``,this.dom.tabs=[],this.dom.panels=[];let r=document.createDocumentFragment(),i=document.createDocumentFragment();this.props.tabs.forEach((e,n)=>{let a=e.name||v(),o=(0,t.jsx)(`div`,{className:this.props.className.tab,"data-tabs-tab":a,role:`tab`,children:w(e.title,{tabs:this,item:e})});this.dom.tabs.push(o);let s=(0,t.jsx)(`div`,{className:this.props.className.panel,"data-tabs-panel":a,role:`tabpanel`});this.dom.panels.push(s),typeof e.panel!=`function`&&s.append(...w(e.panel,{tabs:this,item:e,index:n,name:a})),r.append(o),i.append(s)}),e.append(r),n.append(i),this.bindingsDispose?.(),this.bindingsDispose=(0,t.createRoot)(e=>(this.dom.tabs.forEach((e,n)=>{let r=e.dataset.tabsTab||``;(0,t.bindAttr)(e,`aria-selected`,()=>this.state.current.index===n?`true`:`false`),(0,t.bindAttr)(e,`aria-disabled`,()=>this.state.disabled.names.includes(r)?`true`:`false`)}),this.dom.panels.forEach((e,n)=>{(0,t.bindAttr)(e,`aria-hidden`,()=>this.state.current.index===n?`false`:`true`)}),e))}parseDisabled(e){if(e==null)return{names:[],indexes:[]};let t=e=>typeof e==`number`?this.props.tabs[e]?.name||null:typeof e==`string`?e:null,n=Array.isArray(e)?e.map(t).filter(e=>!!e):(()=>{let n=t(e);return n?[n]:[]})();return this.createDisabledState(n)}createDisabledState(e){let t=Array.from(new Set(e));return{names:t,indexes:t.map(e=>this.props.tabs.findIndex(t=>t.name===e)).filter(e=>e>=0)}}syncCurrent(e){this.state.current={index:e,name:e>=0&&e<this.dom.tabs.length&&this.dom.tabs[e]?.dataset.tabsTab||null}}getPanelKey(e,t){return e.name||this.dom.tabs[t]?.dataset.tabsTab||String(t)}getCachedPanel(e,t){if(!e.cache)return null;let n=this.getPanelKey(e,t),r=this.runtime.cache.panels.get(n);if(!r)return null;let i=en(e.ttl);return i&&Date.now()-r.updatedAt>i?(this.runtime.cache.panels.delete(n),null):r}setCachedPanel(e,t,n){e.cache&&this.runtime.cache.panels.set(this.getPanelKey(e,t),{content:n,updatedAt:Date.now()})}renderPanelContent(e,t){let n=this.dom.panels[e],r=this.props.tabs[e];!n||!r||(n.textContent=``,n.append(...w(t,{tabs:this,item:r,index:e,name:this.dom.tabs[e]?.dataset.tabsTab||r.name||e})))}async loadPanel(e){let n=this.props.tabs[e],r=this.dom.panels[e];if(!n||!r||typeof n.panel!=`function`){this.runtime.panelLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1});return}let i=this.getCachedPanel(n,e);if(i){this.runtime.panelLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1}),this.renderPanelContent(e,i.content);return}let a=++this.runtime.panelLoadId;(0,t.flushSync)(()=>{this.state.loading=!0}),r.setAttribute(`aria-live`,`polite`),r.setAttribute(`aria-busy`,`true`),r.textContent=``,r.appendChild(k());try{let t=await Promise.resolve(n.panel({tabs:this,item:n,index:e,name:this.dom.tabs[e]?.dataset.tabsTab||n.name||e}));if(this.runtime.destroyed||a!==this.runtime.panelLoadId)return;this.setCachedPanel(n,e,t),this.renderPanelContent(e,t)}finally{!this.runtime.destroyed&&a===this.runtime.panelLoadId&&((0,t.flushSync)(()=>{this.state.loading=!1}),r.setAttribute(`aria-busy`,`false`))}}get activeIndex(){return this.state.current.index}get disabledNames(){return this.state.disabled.names}bindEvents(){if(this.unbindEvents(),!this.root)return;let e=A(`[data-tabs-list]`,this.root);e&&this.cleanup.events.on(`tabClick`,e,`click`,t=>{if(!(t.target instanceof Element))return;let n=t.target.closest(`[data-tabs-tab]`);if(!n||!e.contains(n))return;let r=n.dataset.tabsTab;r&&!this.state.disabled.names.includes(r)&&this.activate(r)})}unbindEvents(){this.cleanup.events.clear()}assertActive(e){if(this.runtime.destroyed)throw Error(`Tabs.${e}: instance has been destroyed.`)}getIndex(e){return typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tabsTab===e):-1}async activateInternal(e,n=!0){let r=this.getIndex(e),i=this.dom.tabs[r]?.dataset.tabsTab||``;if(!(r<0||r>=this.dom.tabs.length||this.state.disabled.names.includes(i)||this.state.current.index===r)&&((0,t.flushSync)(()=>{this.syncCurrent(r)}),await this.loadPanel(r),n&&this.props.onChange)){let e=this.dom.tabs[r],t=this.dom.panels[r];await Promise.resolve(this.props.onChange(r,e?.dataset.tabsTab||r,e,t))}}async activate(e){this.assertActive(`activate`),await this.activateInternal(e,!0)}build(){return this.assertActive(`build`),(0,t.insert)(this.dom.container,()=>this.root),this}render(){return this.build()}async add(e){this.assertActive(`add`),g(`tabConfig`,e,Qt,`Tabs.add`),e.name=e.name||v(),this.props.tabs=[...$t(this.props.tabs),e],this.runtime.cache.panels.clear(),this.rebuildItems(),this.syncActiveNames(this.resolveActiveIndex(this.props.active)),this.bindEvents(),this.refreshDrag();let{onAdd:t}=this.props;if(t){let n=this.props.tabs.length-1;await Promise.resolve(t(n,e,this.dom.tabs[n],this.dom.panels[n]))}}async delete(e){if(this.assertActive(`delete`),this.props.tabs.length<=1)return;let n=this.getIndex(e);if(n<0||n>=this.props.tabs.length)return;let r=this.props.tabs[n].name,{onRemove:i}=this.props;this.props.tabs=this.props.tabs.filter((e,t)=>t!==n),r&&this.runtime.cache.panels.delete(r),this.state.current.index>=this.props.tabs.length?(0,t.flushSync)(()=>{this.syncCurrent(this.props.tabs.length-1)}):this.state.current.index>n&&(0,t.flushSync)(()=>{this.syncCurrent(this.state.current.index-1)}),this.rebuildItems(),this.bindEvents(),await this.loadPanel(this.state.current.index),this.refreshDrag(),i&&await Promise.resolve(i(n,r))}disable(e){this.assertActive(`disable`);let n=typeof e==`number`?this.dom.tabs[e]?.dataset.tabsTab:e;n&&!this.state.disabled.names.includes(n)&&(0,t.flushSync)(()=>{this.state.disabled=this.createDisabledState([...this.state.disabled.names,n])})}enable(e){this.assertActive(`enable`);let n=typeof e==`number`?this.dom.tabs[e]?.dataset.tabsTab:e;n&&(0,t.flushSync)(()=>{this.state.disabled=this.createDisabledState(this.state.disabled.names.filter(e=>e!==n))})}resolveActiveIndex(e){return e==null?-1:typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tabsTab===e):0}syncActiveNames(e){(0,t.flushSync)(()=>{this.syncCurrent(e)})}async reInit(e={}){this.assertActive(`reInit`),Object.assign(this.props,tn({...this.props,...e,className:{...this.props.className,...e.className}})),(0,t.flushSync)(()=>{this.state.disabled=this.parseDisabled(this.props.disabled)}),this.rebuildItems(),this.syncActiveNames(this.resolveActiveIndex(this.props.active)),this.bindEvents(),await this.loadPanel(this.state.current.index),this.refreshDrag()}get dragContainer(){return this.root?A(`[data-tabs-wrap]`,this.root):null}get dragInner(){return this.root?A(`[data-tabs-list]`,this.root):null}initDrag(){let{direction:e}=this.props,n=this.dragContainer,r=this.dragInner;if(!n||!r)return;let i=e===`left`||e===`right`,a=i?r.scrollHeight>n.clientHeight+5:r.scrollWidth>n.clientWidth+5;if((0,t.flushSync)(()=>{this.state.isVertical=i,this.state.draggable=a}),!a){this.removeDragEvents();return}this.bindDragEvents(),this.cleanup.events.on(`resize`,window,`resize`,()=>{cancelAnimationFrame(this.resizeRaf),this.resizeRaf=requestAnimationFrame(()=>{this.refreshDrag()})})}bindDragEvents(){this.removeDragEvents();let e=this.dragContainer,t=this.dragInner;if(!e||!t)return;let n=this.state.isVertical,r=0,i=0,a=0,o=!1,s=e=>{if(`touches`in e){let t=e.touches[0]||e.changedTouches[0];return n?t.pageY:t.pageX}return n?e.pageY:e.pageX},c=o=>{!(o instanceof MouseEvent)&&!(o instanceof TouchEvent)||(this.isDragging=!0,t.classList.add(this.props.className.dragging),r=s(o),a=r,i=n?e.scrollTop:e.scrollLeft,this.velocity=0,cancelAnimationFrame(this.raf))},l=t=>{if(!this.isDragging||!(t instanceof MouseEvent)&&!(t instanceof TouchEvent))return;t.preventDefault();let c=s(t),l=r-c;this.velocity=a-c,a=c,o||(o=!0,requestAnimationFrame(()=>{o=!1,n?e.scrollTop=i+l:e.scrollLeft=i+l}))},u=()=>{this.isDragging&&(this.isDragging=!1,t.classList.remove(this.props.className.dragging),this.startInertiaScroll())};this.cleanup.events.on(`drag:mousedown`,t,`mousedown`,c),this.cleanup.events.on(`drag:touchstart`,t,`touchstart`,c,{passive:!0}),this.cleanup.events.on(`drag:mousemove`,window,`mousemove`,l,{passive:!1}),this.cleanup.events.on(`drag:touchmove`,window,`touchmove`,l,{passive:!1}),this.cleanup.events.on(`drag:mouseup`,window,`mouseup`,u),this.cleanup.events.on(`drag:touchend`,window,`touchend`,u)}startInertiaScroll(){let e=this.dragContainer;if(!e)return;let t=this.velocity,n=this.state.isVertical,r=performance.now(),i=a=>{let o=a-r;r=a,t*=.92,!(Math.abs(t)<.3)&&(n?e.scrollTop+=t*o*.05:e.scrollLeft+=t*o*.05,this.raf=requestAnimationFrame(i))};this.raf=requestAnimationFrame(i)}removeDragEvents(){this.cleanup.events.off(`drag:mousedown`),this.cleanup.events.off(`drag:touchstart`),this.cleanup.events.off(`drag:mousemove`),this.cleanup.events.off(`drag:touchmove`),this.cleanup.events.off(`drag:mouseup`),this.cleanup.events.off(`drag:touchend`)}refreshDrag(){this.initDrag()}onDestroy(){this.unbindEvents(),this.removeDragEvents(),this.bindingsDispose?.(),this.bindingsDispose=null,cancelAnimationFrame(this.raf),cancelAnimationFrame(this.resizeRaf),this.cleanup.events.off(`resize`),this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function an(e,t={}){return new rn(e,t)}let on={root:`j-accordion`,header:`accordion-header`,title:`header-title`,arrow:`header-arrow`,panel:`accordion-panel`,content:`panel-content`},sn={type:`array`,validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty array.`},cn={types:[`number`,`string`,`array`,`null`],validate:e=>e==null?!0:Array.isArray(e)?e.every(e=>typeof e==`number`||typeof e==`string`):typeof e==`number`?Number.isInteger(e)&&e>=0:typeof e==`string`&&e.trim().length>0,message:`expects a positive number, string, array or null.`},ln={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},active:{default:0,...cn},collapsible:{default:!1,type:`boolean`},multiple:{default:!1,type:`boolean`},className:{default:on,type:`object`,normalize:e=>({...on,...e&&typeof e==`object`?e:{}})},onChange:{default:null,types:[`function`,`null`]},items:{default:[],type:`array`}};function un(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function dn(e){let t=_(e,ln,`Accordion`);return{id:t.id,active:t.active,collapsible:t.collapsible,multiple:t.multiple,className:t.className,items:un(t.items),onChange:t.onChange}}function fn(e){return g(`items`,e,sn,`Accordion`),e.map(e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Accordion: item expects an object.`);if(e.name!=null&&typeof e.name!=`string`)throw Error(`Accordion: item name expects a string.`);if(!O(e.title))throw Error(`Accordion: item title expects string, Node, array, function or null.`);if(!O(e.content))throw Error(`Accordion: item content expects string, Node, array, function or null.`);return{...e,name:e.name||v()}})}var pn=class extends P{constructor(e,n={}){let r=D(e,`Accordion`),i=dn(n);super(i),this.dom.container=r,this.dom.headers=[],this.dom.panels=[],this.bindingsDispose=null,this.state=(0,t.createDeepStore)({activeNames:[],current:{index:null,name:null}});try{this.onInit(i)}catch(e){throw this.destroy(),e}}onInit(e){this.root=this.buildRoot(e),this.buildItems(e),this.syncActiveNames(this.resolveActiveNames(e.active)),this.bindEvents()}buildRoot(e){return(0,t.jsx)(`div`,{className:e.className.root,id:e.id,"data-accordion":`root`})}buildItems(e){let n=fn(e.items),r=document.createDocumentFragment();this.dom.headers=[],this.dom.panels=[],n.forEach((n,i)=>{let a=n.name||v(),o=`${e.id}_header_${i}`,s=`${e.id}_panel_${i}`,c=(0,t.jsx)(`div`,{className:e.className.header,"data-accordion-header":a,id:o,role:`button`,tabindex:`0`,"aria-controls":s,children:[(0,t.jsx)(`span`,{className:e.className.title,"data-accordion-title":a,children:this.contentView(n,i,`title`)}),(0,t.jsx)(`span`,{className:e.className.arrow,"data-accordion-arrow":a,"aria-hidden":`true`,children:x(`arrow-down`)})]}),l=(0,t.jsx)(`div`,{className:e.className.panel,"data-accordion-panel":a,id:s,role:`region`,"aria-labelledby":o,children:(0,t.jsx)(`div`,{className:e.className.content,"data-accordion-content":a,children:this.contentView(n,i,`content`)})});this.dom.headers.push(c),this.dom.panels.push(l),r.append(c,l)}),this.root?.append(r),this.bindingsDispose?.(),this.bindingsDispose=(0,t.createRoot)(e=>(this.dom.headers.forEach(e=>{let n=e.dataset.accordionHeader||``;(0,t.bindAttr)(e,`aria-expanded`,()=>this.state.activeNames.includes(n)?`true`:`false`)}),this.dom.panels.forEach((e,n)=>{let r=this.dom.headers[n]?.dataset.accordionHeader||``;(0,t.bindAttr)(e,`aria-hidden`,()=>this.state.activeNames.includes(r)?`false`:`true`),(0,t.bindAttr)(e,`hidden`,()=>!this.state.activeNames.includes(r))}),e))}contentView(e,t,n){return w(n===`title`?e.title:e.content,{accordion:this,item:e,index:t,type:n,active:!1})}resolveActiveNames(e){if(e==null)return[];let t=Array.isArray(e)?e:[e],n=[];for(let e of t){let t=this.getIndex(e);if(!(t<0||t>=this.dom.headers.length)&&(n.push(this.dom.headers[t].dataset.accordionHeader||String(t)),!this.props.multiple))break}return Array.from(new Set(n))}syncActiveNames(e){let n=e[0]||null,r=n?this.getIndex(n):null;(0,t.flushSync)(()=>{this.state.activeNames=e,this.state.current={index:r,name:n}})}bindEvents(){this.unbindEvents(),this.root&&(this.cleanup.events.on(`click`,this.root,`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-accordion-header]`);!t||!this.root?.contains(t)||this.active(t.dataset.accordionHeader)}),this.cleanup.events.on(`keydown`,this.root,`keydown`,e=>{if(!(e instanceof KeyboardEvent)||e.key!==`Enter`&&e.key!==` `||!(e.target instanceof Element))return;let t=e.target.closest(`[data-accordion-header]`);!t||!this.root?.contains(t)||(e.preventDefault(),this.active(t.dataset.accordionHeader))}))}unbindEvents(){this.cleanup.events.clear()}isActive(e){return this.state.activeNames.includes(e)}assertActive(e){if(this.runtime.destroyed)throw Error(`Accordion.${e}: instance has been destroyed.`)}async activateItem(e,t=!0){let n=this.getIndex(e);if(n<0||n>=this.dom.headers.length)return;let r=this.dom.headers[n],i=this.dom.panels[n],a=r.dataset.accordionHeader||String(n),o=this.isActive(a);if(o&&!this.props.multiple&&!this.props.collapsible)return;let s;s=this.props.multiple?o?this.state.activeNames.filter(e=>e!==a):[...this.state.activeNames,a]:o?this.props.collapsible?[]:this.state.activeNames:[a],this.syncActiveNames(s),t&&this.props.onChange&&await Promise.resolve(this.props.onChange(n,a,r,i,this))}getIndex(e){return typeof e==`number`?e:typeof e==`string`?this.dom.headers.findIndex(t=>t.dataset.accordionHeader===e):-1}async active(e){this.assertActive(`active`),await this.activateItem(e,!0)}build(){return this.assertActive(`build`),(0,t.insert)(this.dom.container,()=>this.root),this}render(){return this.build()}setItems(e,t=0){return this.assertActive(`setItems`),g(`items`,e,sn,`Accordion.setItems`),g(`active`,t,cn,`Accordion.setItems`),this.props.items=un(fn(e)),this.props.active=t,this.root&&(this.root.textContent=``),this.buildItems(this.props),this.syncActiveNames(this.resolveActiveNames(t)),this.bindEvents(),this}onDestroy(){this.unbindEvents(),this.bindingsDispose?.(),this.bindingsDispose=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function mn(e,t={}){return new pn(e,t)}let hn={root:`j-drop`,container:`drop-container`},gn={name:{default:null,types:[`string`,`null`]},mode:{default:`click`,type:`string`,enum:[`hover`,`click`]},position:{default:`auto`,type:`string`,enum:[`auto`,`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`left`,`right`]},offset:{default:10,type:`number`,validate:e=>typeof e==`number`&&e>=0,message:`expects a positive number or 0.`},content:{default:``,validate:O,message:`expects string, Node, array, function or null.`},className:{default:hn,type:`object`,normalize:e=>({...hn,...e&&typeof e==`object`?e:{}})},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},delay:{default:0,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`},onShown:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function _n(e){let t=_(e,gn,`Drop`);return{name:t.name,mode:t.mode,position:t.position,offset:t.offset,content:t.content,className:t.className,id:t.id,delay:t.delay,hoverIntent:t.hoverIntent,onShown:t.onShown,onHidden:t.onHidden}}function vn(e){return typeof e==`number`&&e>=0?{show:e,hide:e}:typeof e==`object`&&e?{show:Number(e.show)||0,hide:Number(e.hide)||0}:{show:0,hide:0}}var yn=class{constructor(e,t={}){this.target=E(e),this.props=_n(t),this.root=null,this.isVisible=!1,this.cleanup=null,this.delayShow=0,this.delayHide=0,this.timer={show:null,hide:null},this.hoverIntentData={x:0,y:0,lastMoveTime:0},this.lastX=0,this.lastY=0,this.init(this.props)}init(e){this.cleanup={events:M()};let t=vn(e.delay);this.delayShow=t.show,this.delayHide=t.hide,this.buildDrop(e),this.bindEvents(e)}buildDrop(e){let{className:n,content:r,id:i,name:a}=e,o=S(r)&&r.nodeType===Node.ELEMENT_NODE?r:(0,t.jsx)(`div`,{className:n.container,"data-drop-container":a||i,children:w(r,this)});this.root=(0,t.jsx)(`div`,{className:n.root,id:i,"data-drop":a||v(),children:o})}bindEvents(e){let{mode:t,hoverIntent:n}=e;this.unbindEvents(),!(!this.target||!this.cleanup)&&(t===`hover`?n?(this.cleanup.events.on(`target:enter`,this.target,`mouseenter`,()=>this.startHoverIntent()),this.cleanup.events.on(`target:leave`,this.target,`mouseleave`,()=>this.cancelHoverIntent())):(this.cleanup.events.on(`target:enter`,this.target,`mouseenter`,()=>this.show()),this.cleanup.events.on(`target:leave`,this.target,`mouseleave`,()=>this.hide())):(this.cleanup.events.on(`target:click`,this.target,`click`,()=>this.toggle()),this.cleanup.events.on(`document:click`,document,`click`,e=>this.docClick(e))))}bindRootEvents(){!this.root||this.props?.mode!==`hover`||!this.cleanup||(this.cleanup.events.on(`root:enter`,this.root,`mouseenter`,()=>this.show()),this.cleanup.events.on(`root:leave`,this.root,`mouseleave`,()=>this.hide()))}unbindRootEvents(){this.cleanup?.events.off(`root:enter`),this.cleanup?.events.off(`root:leave`)}unbindEvents(){this.cleanup?.events.clear()}startHoverIntent(){this.cleanup&&(this.cleanup.events.on(`document:mousemove`,document,`mousemove`,e=>this.onMouseMove(e)),this.timer.show&&clearTimeout(this.timer.show),this.timer.show=setTimeout(()=>{let e=Date.now()-this.hoverIntentData.lastMoveTime;Math.abs(this.hoverIntentData.x-this.lastX)+Math.abs(this.hoverIntentData.y-this.lastY)<5||e>100?(this.show(),this.cleanup?.events.off(`document:mousemove`)):this.startHoverIntent()},this.delayShow))}cancelHoverIntent(){this.timer.show&&clearTimeout(this.timer.show),this.cleanup?.events.off(`document:mousemove`),this.hide()}onMouseMove(e){e instanceof MouseEvent&&(this.lastX=e.clientX,this.lastY=e.clientY,this.hoverIntentData.lastMoveTime=Date.now(),this.hoverIntentData.x=e.clientX,this.hoverIntentData.y=e.clientY)}setPosition(){if(!this.target||!this.root||!this.props)return;let e=this.target.getBoundingClientRect(),t=this.root,{offset:n,position:r}=this.props;t.style.visibility=`hidden`,t.style.display=`block`;let i=t.getBoundingClientRect(),a=0,o=0,s=r;switch(s===`auto`&&(s=window.innerHeight-e.bottom>i.height+n?`top-center`:`bottom-center`),s){case`top-left`:a=e.top-i.height-n,o=e.left;break;case`top-center`:a=e.top-i.height-n,o=e.left+e.width/2-i.width/2;break;case`top-right`:a=e.top-i.height-n,o=e.right-i.width;break;case`bottom-left`:a=e.bottom+n,o=e.left;break;case`bottom-center`:a=e.bottom+n,o=e.left+e.width/2-i.width/2;break;case`bottom-right`:a=e.bottom+n,o=e.right-i.width;break;case`left`:a=e.top+e.height/2-i.height/2,o=e.left-i.width-n;break;case`right`:a=e.top+e.height/2-i.height/2,o=e.right+n;break;default:break}a=Math.max(8,Math.min(a,window.innerHeight-i.height-8)),o=Math.max(8,Math.min(o,window.innerWidth-i.width-8)),t.style.top=`${a+window.scrollY}px`,t.style.left=`${o+window.scrollX}px`,t.style.visibility=``,t.style.display=``}docClick(e){e.target instanceof Node&&(!this.root||!this.target||!this.root.contains(e.target)&&!this.target.contains(e.target)&&this.hide())}exec(e){!this.root||!this.props||(e?(this.root.parentNode||document.body.appendChild(this.root),this.bindRootEvents(),this.setPosition()):(this.unbindRootEvents(),this.root.style.top=``,this.root.style.left=``,this.root.remove()),this.root.setAttribute(`aria-hidden`,e?`false`:`true`),this.root.setAttribute(`aria-expanded`,e?`true`:`false`),this.isVisible=e)}show(e=!0){this.timer.hide&&clearTimeout(this.timer.hide),!this.isVisible&&(e&&this.delayShow>0?(this.timer.show&&clearTimeout(this.timer.show),this.timer.show=setTimeout(()=>this.exec(!0),this.delayShow)):this.exec(!0),this.props?.onShown?.(this))}hide(e=!0){this.timer.show&&clearTimeout(this.timer.show),this.isVisible&&(e&&this.delayHide>0?(this.timer.hide&&clearTimeout(this.timer.hide),this.timer.hide=setTimeout(()=>this.exec(!1),this.delayHide)):this.exec(!1),this.props?.onHidden?.(this))}toggle(){this.isVisible?this.hide():this.show()}destroy(){this.props&&(this.timer.show&&clearTimeout(this.timer.show),this.timer.hide&&clearTimeout(this.timer.hide),this.unbindEvents(),this.root?.remove(),this.props=null,this.root=null,this.target=null,this.timer={show:null,hide:null},this.cleanup?.events.clear(),this.cleanup=null,this.isVisible=!1)}};function bn(e,t={}){return new yn(e,t)}let xn={container:`j-tooltip`,message:`tooltip-message`},Sn={name:{default:null,types:[`string`,`null`]},mode:{default:`hover`,type:`string`,enum:[`hover`,`click`]},position:{default:`auto`,type:`string`,enum:[`auto`,`top-left`,`top-center`,`top-right`,`bottom-left`,`bottom-center`,`bottom-right`,`left`,`right`]},offset:{default:8,type:`number`},message:{default:``,type:`string`,normalize:e=>typeof e==`string`?e.trim():e,validate:e=>typeof e==`string`&&e.length>0,message:`expects a non-empty string.`},className:{default:xn,type:`object`,normalize:e=>({...xn,...e&&typeof e==`object`?e:{}})},id:{default:null,types:[`string`,`null`]},delay:{default:100,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`},onShown:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function Cn(e){let t=_(e,Sn,`Tooltip.props`);return{name:t.name,mode:t.mode,position:t.position,offset:t.offset,message:t.message,className:t.className,id:t.id,delay:t.delay,hoverIntent:t.hoverIntent,onShown:t.onShown,onHidden:t.onHidden}}var wn=class{constructor(e,t={}){let n=Cn(t);this.props=n,this.drop=new yn(e,{name:n.name,mode:n.mode,position:n.position,offset:n.offset,id:n.id,delay:n.delay,hoverIntent:n.hoverIntent,onShown:n.onShown,onHidden:n.onHidden,content:this.buildContent(n)})}buildContent(e){return(0,t.jsx)(`div`,{className:e.className.container,"data-tooltip":e.name||e.id||``,children:(0,t.jsx)(`div`,{className:e.className.message,"data-tooltip-message":``,children:e.message})})}show(e=!0){this.drop?.show(e)}hide(e=!0){this.drop?.hide(e)}toggle(){this.drop?.toggle()}destroy(){this.drop?.destroy(),this.drop=null,this.props=null}};function Tn(e,t={}){return new wn(e,t)}let En={root:`j-offcanvas`,overlay:`j-offcanvas-overlay`,content:`offcanvas-content`,active:`is-active`,top:`is-top`,right:`is-right`,bottom:`is-bottom`,left:`is-left`,slide:`is-slide`,none:`is-none`},Dn={content:{default:``,validate:O,message:`expects string, Node, array, function or null.`},overlay:{default:!0,type:`boolean`},filter:{default:!0,type:`boolean`},cache:{default:!1,type:`boolean`},ttl:{default:0,type:`number`},direction:{default:`left`,type:`string`,enum:[`top`,`right`,`bottom`,`left`]},animation:{default:`slide`,type:`string`,enum:[`slide`,`none`]},bgClose:{default:!0,type:`boolean`},escClose:{default:!0,type:`boolean`},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},className:{default:En,type:`object`,normalize:e=>({...En,...e&&typeof e==`object`?e:{}})},onShow:{default:null,types:[`function`,`null`]},onShown:{default:null,types:[`function`,`null`]},onHide:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};function On(e){return e>0?e:0}function kn(e){let t=_(e,Dn,`Offcanvas`);return{content:t.content,overlay:t.overlay,filter:t.filter,cache:t.cache,ttl:t.ttl,direction:t.direction,animation:t.animation,bgClose:t.bgClose,escClose:t.escClose,id:t.id,className:t.className,onShow:t.onShow,onShown:t.onShown,onHide:t.onHide,onHidden:t.onHidden}}function An(...e){return e.filter(Boolean).join(` `)}var jn=class extends P{constructor(e={}){let n=kn(e);super(n),this.dom.content=null,this._overlay=null,this.runtime.cache={content:null,hasContent:!1,updatedAt:0},this.runtime.contentLoadId=0,this.state=(0,t.createDeepStore)({visible:!1,loading:!1}),this.onInit(n)}onInit(e){e.overlay&&(this._overlay=this.buildOverlay(e)),this.root=this.buildRoot(e)}buildOverlay(e){return(0,t.jsx)(`div`,{className:e.className.overlay,"data-offcanvas-overlay":e.id,style:e.filter?{backdropFilter:`blur(2px)`}:{}})}buildRoot(e){let n=(0,t.jsx)(`div`,{className:e.className.content,"data-offcanvas-content":e.id});return this.dom.content=n,typeof e.content!=`function`&&n.append(...w(e.content,this)),(0,t.jsx)(`div`,{className:An(e.className.root,e.className[e.direction],e.className[e.animation]),id:e.id,"data-offcanvas":`root`,"data-offcanvas-direction":e.direction,"data-offcanvas-animation":e.animation,children:n})}isCacheValid(){if(!this.props.cache||!this.runtime.cache.hasContent)return!1;let e=On(this.props.ttl);return!e||Date.now()-this.runtime.cache.updatedAt<=e}renderContent(e){this.dom.content&&(this.dom.content.textContent=``,this.dom.content.append(...w(e,this)))}async loadContent(){let{content:e,cache:n}=this.props;if(typeof e!=`function`){this.runtime.contentLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1});return}if(this.isCacheValid()){this.runtime.contentLoadId+=1,this.renderContent(this.runtime.cache.content),(0,t.flushSync)(()=>{this.state.loading=!1});return}let r=++this.runtime.contentLoadId;(0,t.flushSync)(()=>{this.state.loading=!0}),this.dom.content&&(this.dom.content.textContent=``,this.dom.content.appendChild(k()));try{let t=await Promise.resolve(e(this));if(this.runtime.destroyed||r!==this.runtime.contentLoadId)return;n&&(this.runtime.cache.content=t,this.runtime.cache.hasContent=!0,this.runtime.cache.updatedAt=Date.now()),this.renderContent(t)}finally{!this.runtime.destroyed&&r===this.runtime.contentLoadId&&(0,t.flushSync)(()=>{this.state.loading=!1})}}bindEvents(){this.unbindEvents();let{bgClose:e,escClose:t}=this.props;this._overlay&&e&&this.cleanup.events.on(`overlay`,this._overlay,`click`,()=>{this.hide()}),t&&this.cleanup.events.on(`esc`,document,`keydown`,e=>{e instanceof KeyboardEvent&&e.key===`Escape`&&this.state.visible&&this.hide()}),this.dom.root&&this.cleanup.events.on(`close`,this.dom.root,`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`[data-action]`)?.dataset.action;(t===`close`||t===`cancel`)&&this.hide()})}unbindEvents(){this.cleanup?.events.clear()}renderPanel(){let{overlay:e,id:t,className:n}=this.props,r=document.body;e&&this._overlay&&r.appendChild(this._overlay),this.dom.root&&r.appendChild(this.dom.root),r.style.overflow=`hidden`,l.start(`oc-show-${t}`,10,()=>{this.dom.root&&(this._overlay?.classList.add(n.active),this.dom.root.classList.add(n.active))})}removePanel(){let{id:e,className:t}=this.props,n=document.body;this._overlay?.classList.remove(t.active),this.dom.root?.classList.remove(t.active),l.start(`oc-remove-${e}`,100,()=>{this._overlay?.remove(),this.dom.root?.remove(),n.style.overflow=``})}async show(){if(this.runtime.destroyed||this.state.visible)return;let{onShow:e,onShown:n,id:r}=this.props;e&&await Promise.resolve(e(this)),this.renderPanel(),this.bindEvents(),(0,t.flushSync)(()=>{this.state.visible=!0}),await this.loadContent(),l.start(`oc-shown-${r}`,300,()=>{this.runtime.destroyed||n?.(this)})}async hide(){if(this.runtime.destroyed||!this.state.visible)return;let{onHide:e,onHidden:n}=this.props;e&&await Promise.resolve(e(this)),this.runtime.contentLoadId+=1,(0,t.flushSync)(()=>{this.state.loading=!1}),this.unbindEvents(),this.removePanel(),(0,t.flushSync)(()=>{this.state.visible=!1}),n?.(this)}onDestroy(){let{id:e,className:t}=this.props;l.cancel(`oc-show-${e}`),l.cancel(`oc-remove-${e}`),l.cancel(`oc-shown-${e}`),this.state.visible&&this.unbindEvents(),this.dom.root?.classList.remove(t.active),this.dom.root?.remove(),this._overlay?.remove();let n=document.body;n.style.overflow=``,this._overlay=null}};function Mn(e={}){return new jn(e)}let Nn={layout:`j-popup-layout`,modal:`j-modal`,fullscreen:`is-fullscreen`,header:`modal-header`,body:`modal-body`,footer:`modal-footer`,title:`modal-title`,close:`modal-close`,cancel:`modal-cancel`,confirm:`modal-confirm`,button:`j-button`,buttonIcon:`is-icon`,buttonGhost:`is-ghost`,buttonPrimary:`is-primary`,buttonSmall:`is-sm`,formContainer:`modal-form-container`};function Y(e){return Array.isArray(e)?e.map(e=>({...e,options:Array.isArray(e.options)?e.options.map(e=>e&&typeof e==`object`?{...e}:e):e.options})):[]}function Pn(e){return{...e,fields:Array.isArray(e.fields)?Y(e.fields):null,text:{...e.text},className:{...e.className}}}function Fn(e){return p(e)}function In(e){return e==null||typeof e==`object`&&typeof e.next==`function`&&typeof e.back==`function`&&typeof e.snapshot==`function`}function Ln(e,t){return!Array.isArray(e)||!p(t)?e?Y(e):null:e.map(e=>{if(!e?.name||!s(t,e.name))return{...e};let n=t[e.name];if(e.type===`checkbox`||e.type===`radio`){let t=e.value??`on`,r=Array.isArray(n)?n.map(String).includes(String(t)):n===!0||String(n)===String(t);return{...e,checked:r}}return{...e,value:Array.isArray(n)?n.map(String):n}})}function Rn(e){let t=p(e?.text)?e.text:{};return{title:typeof t.title==`string`?t.title:`Tip`,confirm:typeof t.confirm==`string`?t.confirm:`Confirm`,cancel:typeof t.cancel==`string`?t.cancel:`Cancel`}}function zn(e){return{...e,fields:Array.isArray(e.fields)?Y(e.fields):null,text:Rn(e),loading:!1,submitting:!1,visible:!1,data:null,extraData:null}}function Bn(e,t){return!t||typeof t!=`object`?e:Object.assign(e,t)}function Vn(e){return p(e)?{...e}:{}}function X(...e){return e.filter(Boolean).join(` `)}function Hn(e){return typeof e==`string`||typeof e==`number`?String(e):``}let Un={validate:O,message:`expects string, number, Node, array, function or null.`},Wn={default:{},validate:e=>p(e),message:`expects an object with text fields.`,normalize:e=>{let t=p(e)?e:{};return{...t,title:typeof t.title==`string`?t.title:`Tip`,confirm:typeof t.confirm==`string`?t.confirm:`Confirm`,cancel:typeof t.cancel==`string`?t.cancel:`Cancel`}}},Gn={types:[`array`,`null`]},Z={content:{default:``,...Un},position:{default:`center`,type:`string`},showCancel:{default:!0,type:`boolean`},showClose:{default:!0,type:`boolean`},fullscreen:{default:!1,type:`boolean`},flow:{default:null,validate:In,message:`expects a Flow instance or null.`},text:Wn,onShow:{default:null,types:[`function`,`null`]},onShown:{default:null,types:[`function`,`null`]},onHide:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]},onConfirm:{default:null,types:[`function`,`null`]},onSubmit:{default:null,types:[`function`,`null`]},onCancel:{default:null,types:[`function`,`null`]},fields:{default:null,...Gn},header:{default:!0,type:`boolean`},footer:{default:!0,type:`boolean`},style:{default:null,types:[`string`,`null`,`object`]},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()||v():e??v()},escClose:{default:!1,type:`boolean`},bgClose:{default:!1,type:`boolean`},lazy:{default:!1,type:`boolean`},className:{default:Nn,type:`object`,normalize:e=>({...Nn,...e&&typeof e==`object`?e:{}})}},Kn={...Z,loading:{default:!1,type:`boolean`},submitting:{default:!1,type:`boolean`},visible:{default:!1,type:`boolean`},data:{default:null,types:[`object`,`null`]},extraData:{default:null,types:[`object`,`null`]}},qn=new Set([`id`,`lazy`]),Jn={validate:e=>!!e&&typeof e==`object`&&!Array.isArray(e),message:`expects an object.`},Yn={validate:Fn,message:`expects a props object.`};function Xn(e){let t=_(e,Z,`Modal`);return{content:t.content,position:t.position,showCancel:t.showCancel,showClose:t.showClose,fullscreen:t.fullscreen,flow:t.flow,text:t.text,onShow:t.onShow,onShown:t.onShown,onHide:t.onHide,onHidden:t.onHidden,onConfirm:t.onConfirm,onSubmit:t.onSubmit,onCancel:t.onCancel,fields:Array.isArray(t.fields)?Y(t.fields):null,header:t.header,footer:t.footer,style:t.style,id:t.id,escClose:t.escClose,bgClose:t.bgClose,lazy:t.lazy,className:t.className}}let Q=0,Zn=``;var Qn=class extends P{constructor(e={}){let n=Xn(e);super(n),this.dom.modal=null,this.dom.header=null,this.dom.body=null,this.dom.footer=null,this.dom.form=null,this.dom.formContainer=null,this.cleanup.visibility=null,this.cleanup.view=null,this.cleanup.hideTimer=null,this.runtime.scrollLocked=!1,this.runtime.visibleApplied=!1,this.cache={initial:Pn(this.props),fieldIds:new Map,baseStyle:``,previousActiveElement:null,formId:`${this.props.id}_form`},this.state=(0,t.createDeepStore)(zn(this.props)),this.init(n)}onInit(){this.bindReactiveVisibility(),this.state.lazy||this.buildRoot()}buildRoot(){if(this.root instanceof HTMLElement)return this.root;let{id:e,className:n}=this.state,r=(0,t.jsx)(`div`,{className:()=>X(this.state.className.layout,`is-${this.state.position}`),role:`dialog`,"data-modal":`root`,"data-modal-position":()=>this.state.position,"aria-modal":`true`,"aria-labelledby":()=>this.state.header?`${e}_title`:null,"aria-label":()=>this.state.header?null:this.state.text?.title||`Modal`,children:(0,t.jsx)(`div`,{className:()=>X(this.state.className.modal,this.state.fullscreen&&this.state.className.fullscreen),id:e,role:`document`,"data-modal-dialog":e,ref:e=>{this.dom.modal=e,this.applyStyle(e,this.state.style)},children:[(0,t.jsx)(`div`,{className:n.header,"data-modal-header":e,style:()=>({display:this.state.header?``:`none`}),ref:e=>{this.dom.header=e}}),(0,t.jsx)(`div`,{className:n.body,"data-modal-body":e,ref:e=>{this.dom.body=e}}),(0,t.jsx)(`div`,{className:n.footer,"data-modal-footer":e,style:()=>({display:this.state.footer?``:`none`}),ref:e=>{this.dom.footer=e}})]})});return this.root=r,this.mountView(),r}mountView(){this.cleanup.view||!this.dom.body||(this.cleanup.view=(0,t.createRoot)(e=>(this.dom.header&&(0,t.onCleanup)((0,t.render)(()=>this.headerView(),this.dom.header)),this.dom.body&&(0,t.render)(()=>this.bodyView(),this.dom.body),this.dom.footer&&(0,t.onCleanup)((0,t.render)(()=>this.footerView(),this.dom.footer)),this.bindReactiveLoading(),this.bindReactiveStyle(),e)))}headerView(){return()=>this.state.header?[(0,t.jsx)(`div`,{className:this.state.className.title,id:`${this.state.id}_title`,"data-modal-title":this.state.id,children:()=>this.state.text?.title}),this.state.showClose?(0,t.jsx)(`button`,{type:`button`,className:X(this.state.className.button,this.state.className.buttonIcon,this.state.className.buttonGhost,this.state.className.buttonSmall,this.state.className.close),"data-action":`close`,"aria-label":`close`,children:x(`close`)}):null]:null}footerView(){return()=>this.state.footer?[this.state.showCancel?(0,t.jsx)(`button`,{type:`button`,className:X(this.state.className.button,this.state.className.buttonGhost,this.state.className.cancel),"data-action":`close`,"aria-label":`close`,disabled:()=>this.isBusy(),children:()=>this.state.text?.cancel}):null,(0,t.jsx)(`button`,{type:()=>this.isFormMode()?`submit`:`button`,form:()=>this.isFormMode()?this.cache.formId:null,className:X(this.state.className.button,this.state.className.buttonPrimary,this.state.className.confirm),"data-action":()=>this.isFormMode()?`submit`:`confirm`,disabled:()=>this.isBusy(),children:()=>this.state.text?.confirm})]:null}bodyView(){return this.isFormMode()?this.formView():(this.destroyForm(),this.contentView(this.state.content))}formView(){return(0,t.jsx)(`div`,{className:this.state.className.formContainer,"data-modal-form-container":this.state.id,ref:e=>{this.mountForm(e)}})}mountForm(e){if(!e)return;this.dom.formContainer=e;let t=this.createFormProps();if(this.dom.form){this.dom.form.update(t);return}this.dom.form=new U(t,e).build()}createFormProps(){return{id:this.cache.formId,fields:this.state.fields||[],buttons:!1,onSubmit:e=>this.handleFormSubmit(e)}}destroyForm(){this.dom.form?.destroy(),this.dom.form=null,this.dom.formContainer=null}contentView(e){return w(e,this)}bindReactiveLoading(){let e=null;(0,t.createEffect)(()=>{this.state.loading&&!e?(e=k(),this.dom.modal?.appendChild(e)):!this.state.loading&&e&&(e.remove(),e=null)}),(0,t.onCleanup)(()=>{e?.remove(),e=null})}bindReactiveStyle(){(0,t.createEffect)(()=>{let e=this.state.style;this.dom.modal&&this.applyStyle(this.dom.modal,e)})}isFormMode(){return Array.isArray(this.state.fields)}isBusy(){return!!(this.state.loading||this.state.submitting)}validatePropsPatch(e,t=`Modal.update`){g(`props`,e,Yn,t);for(let n of Object.keys(e)){if(!s(Z,n))throw Error(`Validator: ${t}.${n} is not a supported modal prop.`);if(qn.has(n))throw Error(`Modal.update: "${n}" cannot be updated after initialization.`);g(n,e[n],Z[n],t)}}applyProps(e,{validate:n=!0,force:r=!1}={}){if(n&&this.validatePropsPatch(e),!e||Object.keys(e).length===0)return this;let i=s(e,`fields`);if(s(e,`content`)&&!i&&this.isFormMode()&&!r)throw Error(`Modal.update: Cannot update content when fields are defined.`);let a=Xn({...this.props,...e,text:s(e,`text`)?{...this.props.text,...e.text}:this.props.text,className:s(e,`className`)?{...this.props.className,...e.className}:this.props.className});this.props=a,super.update(e,{force:r}),this.props=a;let o={};i&&(this.cache.fieldIds?.clear(),o.fields=Array.isArray(e.fields)?Y(e.fields):null);for(let[t,n]of Object.entries(e))t!==`fields`&&t!==`text`&&t!==`className`&&(o[t]=n);return s(e,`text`)&&(o.text=Rn(a)),s(e,`className`)&&(o.className=a.className),(0,t.flushSync)(()=>{for(let[e,t]of Object.entries(o))this.state[e]=t}),s(e,`style`)&&this.dom.modal&&this.applyStyle(this.dom.modal,this.state.style),this.state.visible&&(s(e,`bgClose`)||s(e,`escClose`))&&this.bindEvents(this.root),this.dom.form&&i&&this.dom.form.update(this.createFormProps()),this}applyStyle(e,t){if(e.removeAttribute(`style`),!t){this.cache.baseStyle=``;return}if(typeof t==`string`){e.style.cssText=t,this.cache.baseStyle=e.getAttribute(`style`)||``;return}Object.entries(t).forEach(([t,n])=>{if(n==null)return;let r=t.startsWith(`--`)?t:t.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`);e.style.setProperty(r,String(n))}),this.cache.baseStyle=e.getAttribute(`style`)||``}bindReactiveVisibility(){this.cleanup.visibility=(0,t.createRoot)(e=>((0,t.createEffect)(()=>{let e=!!this.state.visible;(0,t.untrack)(()=>this.applyVisibility(e))}),e))}applyVisibility(e){if(e!==this.runtime.visibleApplied){if(e){this.showFromState();return}this.hideFromState()}}showFromState(){if(this.runtime.destroyed)throw Error(`Modal: The current instance has been destroyed.`);this.root||this.buildRoot(),this.cancelHideTimer(),this.resetAnimationStyles();let{onShow:e,onShown:t}=this.state;e?.(this),this.cache.previousActiveElement=document.activeElement instanceof HTMLElement?document.activeElement:null,this.root&&!this.root.parentNode&&document.body.appendChild(this.root),this.lockScroll(),this.runtime.visibleApplied=!0,this.bindEvents(this.root),this.focusFirst(),t?.(this)}hideFromState(){if(!this.runtime.visibleApplied||!this.root)return;let{onHide:e,onHidden:n}=this.state;e?.(this),this.runtime.visibleApplied=!1,this.clearEvents(),(0,t.flushSync)(()=>{this.state.loading=!1,this.state.extraData=null,this.state.data=null}),this.dom.modal&&(this.dom.modal.style.transition=`opacity 300ms ease-out, transform 300ms ease-out`,this.dom.modal.style.opacity=`0`,this.dom.modal.style.transform=`scale(0.3)`),this.cancelHideTimer(),this.cleanup.hideTimer=setTimeout(()=>this.finishHide(n),300)}bindEvents(e){this.clearEvents(),this.bindOverlayCloseEvent(e),this.bindDocumentKeyEvent(),this.bindInsideEvent()}bindOverlayCloseEvent(e){e&&this.cleanup.events.on(`bg`,e,`click`,t=>{this.state.bgClose&&t.target===e&&this.hide()})}bindDocumentKeyEvent(){this.cleanup.events.on(`keydown`,document,`keydown`,e=>{if(!(!this.state.visible||!(e instanceof KeyboardEvent))){if(e.key===`Escape`&&this.state.escClose){e.preventDefault(),this.hide();return}e.key===`Tab`&&this.trapFocus(e)}})}bindInsideEvent(){this.dom.modal&&this.cleanup.events.on(`inside`,this.dom.modal,`click`,e=>{let t=(e.target instanceof Element?e.target:null)?.closest(`[data-action]`);if(!t||!this.dom.modal?.contains(t))return;let n=t.dataset.action;if(n===`cancel`||n===`close`){this.handleCancel();return}if(n===`submit`){this.requestSubmit();return}if(n===`back`){this.handleBack();return}if(n===`next`){this.handleNext();return}if(n===`confirm`){if(this.isFormMode()){this.requestSubmit();return}this.handleConfirm()}})}clearEvents(){this.cleanup.events.clear()}requestSubmit(){if(!this.dom.form){this.handleConfirm();return}this.dom.form.requestSubmit()}async handleFormSubmit(e){if(this.isBusy())return;let n=Bn(e,this.state.extraData);(0,t.flushSync)(()=>{this.state.data=n}),await this.handleSubmit(n)}async handleNext(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`next`)}async handleBack(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`back`)}hasFlow(){return In(this.state.flow)&&!!this.state.flow}async moveFlow(e){if(!this.hasFlow())return;let n=this.createFlowPayload();if(n!==!1){(0,t.flushSync)(()=>{this.state.submitting=!0});try{let t=await Promise.resolve(this.state.flow[e](n));this.syncFlowView(this.state.flow,t)}catch(t){console.error(`Modal.flow.${e} error:`,t),this.syncFlowView(this.state.flow)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}createFlowPayload(){if(!this.isFormMode())return null;let e=this.dom.form;if(!e)return this.state.data||null;if(!e.validate())return!1;let n=Bn(e.collectData(),this.state.extraData);return(0,t.flushSync)(()=>{this.state.data=n}),this.state.data}resolveFlowModalView(e,t,n){let r=n?.modal??n?.view;if(typeof r==`function`){let i=r({flow:e,snapshot:t,step:n,modal:this,data:t?.data??null,currentData:t?.currentData??null});return p(i)?i:{}}return Vn(r)}syncFlowView(e,t=null){if(!e||!this.state)return;let n=e.snapshot()||t,r=e.currentStep||n?.currentStep||t?.currentStep,i=this.resolveFlowModalView(e,n,r),a=p(i.text)?i.text:{},o={...(!s(i,`text`)||!s(a,`title`))&&r?.title!=null?{text:{...a,title:Hn(r.title)}}:{},...!s(i,`content`)&&!s(i,`fields`)?{content:r?.content??null}:{},...i};Array.isArray(o.fields)&&(o.fields=Ln(o.fields,n?.currentData)),!s(o,`fields`)&&s(o,`content`)&&(o.fields=null),this.update(o)}async handleConfirm(){if(!this.isBusy()){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onConfirm?.(this)),this.hide()}catch(e){console.error(`Modal.onConfirm error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}async handleCancel(){if(!this.isBusy()){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onCancel?.(this)),this.hide()}catch(e){console.error(`Modal.onCancel error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}async handleSubmit(e){if(this.state.onSubmit){(0,t.flushSync)(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onSubmit(e,this)),this.state.extraData=null}catch(e){console.error(`Modal.onSubmit error:`,e)}finally{this.state&&(0,t.flushSync)(()=>{this.state.submitting=!1})}}}trapFocus(e){if(!this.dom.modal)return;let t=Array.from(j(`a[href], button:not([disabled]):not([data-action=close]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,this.dom.modal)).filter(e=>e.offsetParent!==null||e===document.activeElement);if(t.length===0){e.preventDefault(),this.dom.modal.focus();return}let n=t[0],r=t[t.length-1];e.shiftKey&&document.activeElement===n?(e.preventDefault(),r?.focus()):!e.shiftKey&&document.activeElement===r&&(e.preventDefault(),n?.focus())}focusFirst(){if(!this.dom.modal)return;let e=A(`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]):not([data-action=close]), [tabindex]:not([tabindex="-1"])`,this.dom.form?.root||this.dom.modal);e?e.focus():(this.dom.modal.setAttribute(`tabindex`,`-1`),this.dom.modal.focus())}lockScroll(){this.runtime.scrollLocked||(Q===0&&(Zn=document.body.style.overflow,document.body.style.overflow=`hidden`),Q+=1,this.runtime.scrollLocked=!0)}unlockScroll(){this.runtime.scrollLocked&&(Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow=Zn,Zn=``),this.runtime.scrollLocked=!1)}cancelHideTimer(){this.cleanup.hideTimer&&(clearTimeout(this.cleanup.hideTimer),this.cleanup.hideTimer=null)}resetAnimationStyles(){this.dom.modal&&(this.cache.baseStyle?this.dom.modal.setAttribute(`style`,this.cache.baseStyle):this.dom.modal.removeAttribute(`style`))}finishHide(e){this.cleanup.hideTimer=null,this.root?.remove(),this.resetAnimationStyles(),this.unlockScroll(),this.restoreFocus(),e?.(this)}restoreFocus(){let e=this.cache.previousActiveElement;this.cache.previousActiveElement=null,e&&typeof e.focus==`function`&&document.contains(e)&&e.focus()}assertActive(e){if(this.runtime.destroyed)throw Error(`Modal.${e}: The current instance has been destroyed.`)}validateStatePatch(e){if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Modal.setState: expects a plain object patch.`);for(let t of Object.keys(e)){if(!s(Kn,t))throw Error(`Modal.setState: "${t}" is not a supported state key.`);if(qn.has(t))throw Error(`Modal.setState: "${t}" cannot be updated after initialization.`);g(t,e[t],Kn[t],`Modal.setState`)}}setState(e={}){return this.assertActive(`setState`),this.validateStatePatch(e),(0,t.flushSync)(()=>{for(let[t,n]of Object.entries(e))t===`fields`&&this.cache.fieldIds?.clear(),this.state[t]=t===`fields`&&Array.isArray(n)?Y(n):n}),this}show(){return this.assertActive(`show`),(0,t.flushSync)(()=>{this.state.visible=!0}),this}hide(){return this.assertActive(`hide`),(0,t.flushSync)(()=>{this.state.visible=!1}),this}setFields(e,t=!1){return g(`data`,e,Gn,`Modal.setFields`),this.applyProps({fields:e},{validate:!1,force:t}),this}addFields(e){return g(`data`,e,Jn,`Modal.addFields`),(0,t.flushSync)(()=>{this.state.extraData=e}),this}setContent(e,t=!1){if(g(`content`,e,Un,`Modal.setContent`),this.isFormMode()&&!t)throw Error(`Modal.setContent: Cannot setContent when fields are defined.`);return this.applyProps({content:e},{validate:!1,force:t}),this}update(e={},t=!1){let n=typeof t==`boolean`?t:!!t.force;return this.applyProps(e||{},{validate:!0,force:n})}reset(){if(this.cache.fieldIds?.clear(),!this.cache.initial)return this;let e={...Pn(this.cache.initial)};return delete e.id,delete e.lazy,this.props=Xn(e),this.applyProps(e,{validate:!1}),(0,t.flushSync)(()=>{this.state.data=null,this.state.extraData=null}),this}resetContent(){return this.setContent(this.cache.initial?.content??``)}resetFields(){return this.setFields(Array.isArray(this.cache.initial?.fields)?Y(this.cache.initial.fields):null)}onDestroy(){let e=!!this.runtime.visibleApplied,t=this.state?.onHide,n=this.state?.onHidden;e&&t?.(this),this.cancelHideTimer(),this.clearEvents(),this.destroyForm(),this.unlockScroll(),this.cleanup.visibility?.(),this.cleanup.visibility=null,this.cleanup.view?.(),this.cleanup.view=null,this.root?.remove(),e&&n?.(this),this.cache={initial:null,fieldIds:null,baseStyle:``,previousActiveElement:null,formId:``}}destroy(){return this.runtime.destroyed||super.destroy(),this}};function $n(e={}){return new Qn(e)}let er={root:`j-pagination`,list:`pagination`,item:`item`,more:`more`,button:`j-button`,buttonIcon:`is-icon`,buttonGhost:`is-ghost`,active:`is-active`,loading:`animate-spin`},tr={type:`object`,required:!0,validate:e=>{let t=e;return!!t&&Number.isInteger(t.size)&&Number(t.size)>0&&Number.isInteger(t.current)&&Number(t.current)>0},message:`expects { size, current } with positive integers.`},nr={type:`object`,required:!0,validate:e=>{let t=e;return!!t&&Number.isInteger(t.sibling)&&Number(t.sibling)>=0&&Number.isInteger(t.boundary)&&Number(t.boundary)>=0},message:`expects { sibling, boundary } with integers greater than or equal 0.`},rr={total:{default:0,type:`number`,validate:e=>Number.isFinite(e)&&Number(e)>=0,message:`expects a non-negative finite number.`},page:{default:()=>({size:10,current:1}),factory:!0,...tr},count:{default:()=>({sibling:1,boundary:1}),factory:!0,...nr},lock:{default:!0,type:`boolean`},onChange:{default:null,types:[`function`,`null`]},className:{default:er,type:`object`,normalize:e=>({...er,...e&&typeof e==`object`?e:{}})}};function ir(e,t,n){return Math.min(Math.max(e,t),n)}function ar(e={}){let t=_(e,rr,`Pagination.props`);return{...t,page:{...t.page},count:{...t.count},className:{...t.className}}}function or(e){return{type:`more`,key:e}}function sr(e){return{type:`page`,key:`page-${e}`,page:e}}function cr(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function lr(e,t,n){if(t<=0)return[];let r=Math.max(0,n.boundary),i=Math.max(0,n.sibling);if(t<=r*2+i*2+3)return cr(1,t).map(sr);let a=new Set;for(let e=1;e<=Math.min(r,t);e++)a.add(e);for(let n=Math.max(1,e-i);n<=Math.min(t,e+i);n++)a.add(n);for(let e=Math.max(1,t-r+1);e<=t;e++)a.add(e);let o=Array.from(a).sort((e,t)=>e-t),s=[];for(let e of o){let t=s[s.length-1];t?.type===`page`&&e-t.page>1&&(e-t.page===2?s.push(sr(t.page+1)):s.push(or(`more-${t.page}-${e}`))),s.push(sr(e))}return s}var ur=class extends P{constructor(e,n={}){let r=D(e,`Pagination.container`),i=ar(n);super(i);let a=this._getPageCount(i.total,i.page.size),o=ir(i.page.current,1,a);this.dom.container=r,this.dom.list=null,this.dom.prev=null,this.dom.next=null,this.dom.pageNodes=[],this.dom.items=[],this.runtime.built=!1,this.runtime.itemsKey=``,this.runtime.changeId=0,this.state=(0,t.createDeepStore)({total:i.total,page:{size:i.page.size,current:o},count:{sibling:i.count.sibling,boundary:i.count.boundary},pageCount:a,locked:!1}),this.props.page.current=o}build(){if(this._assertActive(`build`),this.runtime.built)return this;this.init(this.props),this.root=(0,t.jsx)(`div`,{className:this.props.className.root,role:`navigation`,"aria-label":`Pagination`,"data-pagination":`root`,children:(0,t.jsx)(`ul`,{className:this.props.className.list,"data-pagination-list":``,"aria-live":`polite`})}),this.dom.list=A(`[data-pagination-list]`,this.root),this.dom.prev=this._buildControlItem(`prev`),this.dom.next=this._buildControlItem(`next`),this.dom.list?.append(this.dom.prev,this.dom.next);let e=this.dom.container;return e?(e.textContent=``,e.appendChild(this.root),this.runtime.built=!0,this._bindControlState(),this._bindPageItems(),this._bindEvents(),this):this}go(e){if(this._assertActive(`go`),g(`page`,e,{type:`number`,validate:Number.isInteger,message:`expects an integer.`},`Pagination.go`),this._isLocked())return this;let n=ir(e,1,this.state.pageCount);if(n===this.state.page.current)return this;let r=this.props.lock&&typeof this.props.onChange==`function`,i=r?++this.runtime.changeId:this.runtime.changeId;if((0,t.flushSync)(()=>{this.state.page.current=n,r&&(this.state.locked=!0)}),this.props.page.current=n,typeof this.props.onChange==`function`){let e;try{e=this.props.onChange(n,this)}catch(e){throw r&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1}),e}if(r&&e&&typeof e.then==`function`){let n=()=>{!this.runtime.destroyed&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1})};Promise.resolve(e).then(n,n)}else r&&i===this.runtime.changeId&&(0,t.flushSync)(()=>{this.state.locked=!1})}return this}update(e={}){this._assertActive(`update`),g(`newProps`,e,{type:`object`},`Pagination.update`);let n=ar({total:e.total??this.props.total,lock:s(e,`lock`)?e.lock:this.props.lock,onChange:s(e,`onChange`)?e.onChange:this.props.onChange,className:{...this.props.className,...e.className},page:{...this.props.page,...e.page},count:{...this.props.count,...e.count}}),r=this._getPageCount(n.total,n.page.size);return n.page.current=ir(n.page.current,1,r),this.props=n,(0,t.flushSync)(()=>{this.state.total=n.total,this.state.page.size=n.page.size,this.state.page.current=n.page.current,this.state.count.sibling=n.count.sibling,this.state.count.boundary=n.count.boundary,this.state.pageCount=r,n.lock||(this.state.locked=!1)}),this}_getPageCount(e,t){return Math.max(1,Math.ceil(e/t))}_getPageItems(){return lr(this.state.page.current,this.state.pageCount,this.state.count)}_getItemsKey(){return[this.state.page.current,this._isLocked()?`locked`:`unlocked`,...this._getPageItems().map(e=>e.key)].join(`|`)}_isLocked(){return this.props.lock&&this.state.locked}_isPrevDisabled(){return this._isLocked()||this.state.page.current<=1}_isNextDisabled(){return this._isLocked()||this.state.page.current>=this.state.pageCount}_buttonClass(...e){let{button:t,buttonIcon:n,buttonGhost:r}=this.props.className;return[t,n,r,...e].filter(Boolean).join(` `)}_buildControlItem(e){return(0,t.jsx)(`li`,{className:this.props.className.item,"data-pagination-control":e,children:(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,"data-page-action":e,children:x(e===`prev`?`arrow-left`:`arrow-right`)})})}_buildPageItem(e){let n=this._isLocked();return e.type===`more`?(0,t.jsx)(`li`,{className:[this.props.className.item,this.props.className.more].filter(Boolean).join(` `),"data-pagination-more":e.key,"aria-hidden":`true`,children:(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,disabled:n,children:x(`more`)})}):(0,t.jsx)(`li`,{className:this.props.className.item,"data-pagination-item":String(e.page),children:e.page===this.state.page.current?(0,t.jsx)(`span`,{className:[this.props.className.button,this.props.className.buttonIcon,this.props.className.active].filter(Boolean).join(` `),"data-current-page":String(e.page),"aria-current":`page`,"aria-label":`Page ${e.page}, current page`,children:n?(0,t.jsx)(`i`,{className:this.props.className.loading,children:x(`loader`)}):String(e.page)}):(0,t.jsx)(`button`,{className:this._buttonClass(),type:`button`,"data-page":String(e.page),"aria-label":`Go to page ${e.page}`,"aria-disabled":n?`true`:null,disabled:n,tabindex:n?`-1`:null,children:String(e.page)})})}_bindControlState(){this.cleanup.controls?.(),this.cleanup.controls=(0,t.createRoot)(e=>{let n=this.dom.prev?A(`[data-page-action]`,this.dom.prev):null,r=this.dom.next?A(`[data-page-action]`,this.dom.next):null;return n&&((0,t.bindAttr)(n,`disabled`,()=>this._isPrevDisabled()),(0,t.bindAttr)(n,`aria-disabled`,()=>this._isPrevDisabled()?`true`:`false`),(0,t.bindAttr)(n,`tabindex`,()=>this._isPrevDisabled()?`-1`:null),(0,t.bindAttr)(n,`aria-label`,()=>`Go to previous page`)),r&&((0,t.bindAttr)(r,`disabled`,()=>this._isNextDisabled()),(0,t.bindAttr)(r,`aria-disabled`,()=>this._isNextDisabled()?`true`:`false`),(0,t.bindAttr)(r,`tabindex`,()=>this._isNextDisabled()?`-1`:null),(0,t.bindAttr)(r,`aria-label`,()=>`Go to next page`)),e})}_bindPageItems(){this.cleanup.itemsEffect?.dispose(),this.cleanup.itemsEffect=(0,t.createEffect)(()=>{let e=this._getItemsKey();e!==this.runtime.itemsKey&&(this.runtime.itemsKey=e,this._renderPageItems())})}_renderPageItems(){if(this.dom.items=[],!this.dom.list||!this.dom.next)return;let e=this._getPageItems().map(e=>this._buildPageItem(e));for(let e of this.dom.pageNodes)e.remove();this.dom.pageNodes=e;for(let t of e)this.dom.list.insertBefore(t,this.dom.next)}_bindEvents(){let e=this.root;e&&this.cleanup.events.on(`click`,e,`click`,t=>{let n=t.target;if(!(n instanceof Element))return;let r=n.closest(`[data-page], [data-page-action]`);if(!r||!e.contains(r))return;t.preventDefault();let i=r.dataset.pageAction;if(i===`prev`&&!this._isPrevDisabled()){this.go(this.state.page.current-1);return}if(i===`next`&&!this._isNextDisabled()){this.go(this.state.page.current+1);return}r.dataset.page&&this.go(Number(r.dataset.page))})}_assertActive(e){if(this.runtime.destroyed)throw Error(`Pagination.${e}: instance has been destroyed.`)}onDestroy(){this.cleanup.events.clear(),this.cleanup.controls?.(),this.cleanup.itemsEffect?.dispose(),this.cleanup.controls=null,this.cleanup.itemsEffect=null,this.dom.container&&(this.dom.container.textContent=``),this.runtime.built=!1,this.runtime.itemsKey=``,this.runtime.changeId=0,this.dom.container=null,this.dom.list=null,this.dom.prev=null,this.dom.next=null,this.dom.pageNodes=[],this.dom.items=[]}};function dr(e,t={}){return new ur(e,t)}let fr={root:`j-swiper`,wrapper:`swiper-wrapper`,slide:`swiper-slide`,image:`swiper-image`,title:`swiper-slide-title`,pagination:`swiper-pagination`,paginationHorizontal:`is-horizontal`,paginationClickable:`is-clickable`,paginationBulletGroup:`is-bullet`,indicator:`swiper-pagination-indicator`,bullet:`swiper-pagination-bullet`,navigation:`swiper-navigation`,prev:`is-prev`,next:`is-next`,active:`is-active`,disabled:`is-disabled`,loading:`loading`,loaded:`loaded`,error:`error`},pr={data:{default:null,validate:e=>e==null||Array.isArray(e),message:`expects an array or null.`},loop:{default:!0,type:`boolean`},autoplay:{default:!0,type:`boolean`},delay:{default:3e3,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},lazyload:{default:!0,type:`boolean`},pagination:{default:!0,type:`boolean`},navigation:{default:!0,type:`boolean`},speed:{default:300,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},touchRatio:{default:1,type:`number`,validate:e=>Number(e)>0,message:`expects a number greater than 0.`},touchAngle:{default:45,type:`number`,validate:e=>Number(e)>=0&&Number(e)<=90,message:`expects a number between 0 and 90.`},longSwipesMs:{default:300,type:`number`,validate:e=>Number(e)>=0,message:`expects a positive number or 0.`},longSwipesRatio:{default:.05,type:`number`,validate:e=>Number(e)>=0&&Number(e)<=1,message:`expects a number between 0 and 1.`},preventClick:{default:!0,type:`boolean`},className:{default:fr,type:`object`,normalize:e=>({...fr,...e&&typeof e==`object`?e:{}})}},mr={validate:e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return(t.image==null||typeof t.image==`string`)&&(t.url==null||typeof t.url==`string`)&&(t.title==null||typeof t.title==`string`)&&(t.sort==null||typeof t.sort==`number`)&&(t.blank==null||typeof t.blank==`boolean`)&&(t.children==null||O(t.children))},message:`expects items with optional image, url, title, sort, blank and children fields.`};function hr(e){return e instanceof Element&&!!e.closest(`a, button, input, textarea, select, label, [data-swiper-ignore]`)}function $(e,t=0){let n=Number(e);return Number.isFinite(n)?n:t}function gr(e,t){return w(e,t)}function _r(e={}){let t=_(e,pr,`Swiper.options`);return{...t,className:{...t.className}}}function vr(e){let t=j(`[data-swiper="root"]`,e);return g(`container`,t,{validate:e=>Array.isArray(e)&&e.length===1,message:`expects exactly one [data-swiper="root"] descendant.`},`Swiper`),t[0]}function yr(...e){return e.filter(Boolean).join(` `)}function br(e,t,n=``){e.setAttribute(t,n)}function xr(e){return p(e)}var Sr=class extends P{constructor(e,n={}){let r=_r(n);super(r),this.dom.container=e,this._built=!1,this.dom.mountTarget=null,this.dom.createdRoot=!1,this.dom.createdSlides=!1,this.dom.wrapper=null,this.dom.slides=[],this.dom.pagination=null,this.dom.prevButton=null,this.dom.nextButton=null,this.dom.bullets=[],this.dom.createdPagination=!1,this.dom.createdPrevButton=!1,this.dom.createdNextButton=!1,this.runtime.logs=[],this.runtime.startTarget=null,this.runtime.touching=!1,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.clickPrevented=!1,this.runtime.timer=null,this.runtime.imageCleanups=new Set,this.runtime.realCount=0,this.state=(0,t.createDeepStore)({index:0,trackIndex:0,transform:0,animating:!1,width:0})}build(){if(this.runtime.destroyed)throw Error(`Swiper.build: instance destroyed`);if(this._built)return this;let e=Array.isArray(this.props.data),n=D(this.dom.container,`Swiper`),r=null,i=null;e?(i=n,r=(0,t.h)(`div`,{className:this.props.className.root,"data-swiper":`root`}),i.appendChild(r)):r=vr(n);try{this.dom.root=r,this.dom.mountTarget=i,this.dom.createdRoot=e,this.dom.createdSlides=e;let t=e?this.createDataView(r,this.props.data):A(`[data-swiper-wrapper]`,r);g(`wrapper`,t,{validate:C,message:`expects [data-swiper-wrapper] in the root element.`},`Swiper`),this.dom.wrapper=t,this.dom.slides=j(`[data-swiper-slide]`,this.dom.wrapper),this.dom.pagination=A(`[data-swiper-pagination]`,r),this.dom.prevButton=A(`[data-action="prev"]`,r),this.dom.nextButton=A(`[data-action="next"]`,r),this.dom.bullets=[],this.dom.createdPagination=!1,this.dom.createdPrevButton=!1,this.dom.createdNextButton=!1,this.runtime.realCount=this.dom.slides.length,this._built=!0,this.dom.slides.length>0&&this.onInit()}catch(e){throw this.destroy(),e}return this.emit(`init`,this.props),this}set index(e){this.setState({index:$(e)})}set trackIndex(e){this.setState({trackIndex:$(e)})}set transform(e){this.setState({transform:$(e)})}set animating(e){this.setState({animating:!!e})}set width(e){this.setState({width:$(e)})}get realCount(){return this.runtime?.destroyed?0:this.runtime?.realCount||0}get realIndex(){return this.toRealIndex()}assertBuilt(e){if(!this._built)throw Error(`Swiper.${e}: call build() first.`)}createDataView(e,n){let r=this.normalizeData(n),i=(0,t.h)(`div`,{className:this.props.className.wrapper,"data-swiper-wrapper":``,"aria-live":`polite`});return e.textContent=``,r.forEach((e,t)=>{i.appendChild(this.createDataSlide(e,t))}),e.appendChild(i),i}normalizeData(e){if(!Array.isArray(e))return[];e.forEach((e,t)=>{g(String(t),e,mr,`Swiper.options.data`)});let t=e.map((e,t)=>({...e,blank:e.blank!==!1,index:t}));return t.some(e=>e.sort!=null)?t.sort((e,t)=>e.sort==null&&t.sort==null?e.index-t.index:e.sort==null?1:t.sort==null?-1:e.sort-t.sort||e.index-t.index):t}createDataSlide(e,n){let r=(0,t.h)(e.url?`a`:`div`,{className:this.props.className.slide,href:e.url||void 0,target:e.url?e.blank?`_blank`:`_self`:void 0,"data-swiper-slide":String(n),"data-swiper-index":String(n),role:`group`,"aria-label":`Slide ${n+1}`});if(e.children!=null)return r.append(...gr(e.children,{swiper:this,item:e,index:n})),r;if(e.image){let n=(0,t.h)(`img`,{className:this.props.className.image,alt:e.title||``,loading:`lazy`});this.props.lazyload?n.dataset.lazy=e.image:n.src=e.image,r.appendChild(n)}return e.title&&r.appendChild((0,t.h)(`span`,{className:this.props.className.title,children:e.title})),r}onInit(){!this.dom.root||!this.dom.wrapper||(this.dom.wrapper.setAttribute(`aria-live`,`polite`),this.updateSize(),this.props.loop&&this.realCount>1&&this.initLoop(),this.setupStyles(),this.setTrackIndex(+!!this.props.loop,!1),this.render(!1),this.bindEvents(),this.props.pagination&&this.initPagination(),this.props.navigation&&this.initNavigation(),this.props.lazyload&&this.loadImages(),this.props.autoplay&&this.play())}onDestroy(){this.pause(),this.clearImageCleanups(),this.cleanup.events.clear(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.dom.wrapper&&j(`[data-clone]`,this.dom.wrapper).forEach(e=>e.remove()),this.dom.createdPagination&&this.dom.pagination?.remove(),this.dom.createdPrevButton&&this.dom.prevButton?.remove(),this.dom.createdNextButton&&this.dom.nextButton?.remove(),this.dom.createdRoot&&this.dom.root?.remove(),this._built=!1}updateSize(){this.assertBuilt(`updateSize`),this.dom.root&&(this.width=this.dom.root.clientWidth||this.dom.root.offsetWidth)}refreshSlides(){this.dom.wrapper&&(this.dom.slides=j(`[data-swiper-slide]`,this.dom.wrapper),this.runtime.realCount=this.dom.slides.filter(e=>!e.hasAttribute(`data-clone`)).length)}initLoop(){if(!this.dom.wrapper||this.dom.slides.length===0)return;let e=this.dom.slides[0].cloneNode(!0),t=this.dom.slides[this.dom.slides.length-1].cloneNode(!0);e.setAttribute(`data-clone`,``),t.setAttribute(`data-clone`,``),e.removeAttribute(`data-swiper-index`),t.removeAttribute(`data-swiper-index`),this.dom.wrapper.appendChild(e),this.dom.wrapper.insertBefore(t,this.dom.slides[0]),this.refreshSlides()}setupStyles(){this.dom.root&&this.dom.root.style.setProperty(`--swiper-slide-width`,`${this.state.width}px`)}reInitView(){this.dom.wrapper&&(this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear(),j(`[data-clone]`,this.dom.wrapper).forEach(e=>e.remove()),this.refreshSlides(),this.props.loop&&this.realCount>1&&this.initLoop(),this.updateSize(),this.setupStyles(),this.setTrackIndex(this.trackIndexForRealIndex(this.state.index),!1),this.render(!1),this.bindEvents(),this.props.pagination?this.initPagination():this.clearPagination(),this.props.navigation?this.initNavigation():this.clearNavigation(),this.props.lazyload&&this.loadImages(),this.props.autoplay&&this.play())}clearPagination(){this.cleanup.bindings?.(),this.cleanup.bindings=null,this.dom.bullets.forEach((e,t)=>{this.cleanup.events.off(`bullet:${t}:click`),this.cleanup.events.off(`bullet:${t}:keydown`)}),this.dom.bullets=[],this.dom.createdPagination?(this.dom.pagination?.remove(),this.dom.pagination=null,this.dom.createdPagination=!1):this.dom.pagination&&(this.dom.pagination.textContent=``)}clearNavigation(){this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.off(`nav:prev`),this.cleanup.events.off(`nav:next`),this.dom.createdPrevButton&&(this.dom.prevButton?.remove(),this.dom.prevButton=null,this.dom.createdPrevButton=!1),this.dom.createdNextButton&&(this.dom.nextButton?.remove(),this.dom.nextButton=null,this.dom.createdNextButton=!1)}bindEvents(){let e=this.dom.root,t=this.dom.wrapper;!e||!t||(this.cleanup.events.on(`touchstart`,t,`touchstart`,e=>{let t=e;t.touches[0]&&this.onStart(t.touches[0],t.target)},{passive:!0}),this.cleanup.events.on(`touchmove`,t,`touchmove`,e=>{let t=e;t.touches[0]&&this.onMove(t.touches[0],e)},{passive:!1}),this.cleanup.events.on(`touchend`,t,`touchend`,e=>{let t=e;t.changedTouches[0]&&this.pushLog(t.changedTouches[0]),this.onEnd()}),this.cleanup.events.on(`touchcancel`,t,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`window:touchcancel`,window,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`mousedown`,t,`mousedown`,e=>{let n=e;n.button===0&&(this.onStart(n,n.target),t.style.cursor=`grabbing`)}),this.cleanup.events.on(`mousemove`,t,`mousemove`,e=>{let t=e;t.buttons===1&&this.onMove(t,e)}),this.cleanup.events.on(`window:mousemove`,window,`mousemove`,e=>{let t=e;this.runtime.touching&&t.buttons===1&&this.onMove(t,e)}),this.cleanup.events.on(`mouseup`,t,`mouseup`,e=>{t.style.cursor=`grab`,this.pushLog(e),this.onEnd()}),this.cleanup.events.on(`window:mouseup`,window,`mouseup`,e=>{this.runtime.touching&&(t.style.cursor=`grab`,this.pushLog(e),this.onEnd())}),this.cleanup.events.on(`wrapper:mouseleave`,t,`mouseleave`,()=>{t.style.cursor=`grab`}),this.cleanup.events.on(`click`,t,`click`,e=>{!this.runtime.clickPrevented||!this.props.preventClick||(e.preventDefault(),e.stopPropagation(),this.runtime.clickPrevented=!1)},{capture:!0}),this.cleanup.events.on(`dragstart`,t,`dragstart`,e=>e.preventDefault()),this.cleanup.events.on(`transitionend`,t,`transitionend`,e=>this.onTransitionEnd(e)),this.cleanup.events.on(`window:resize`,window,`resize`,()=>this.update(null,{force:!0})),this.cleanup.events.on(`root:mouseenter`,e,`mouseenter`,()=>this.pause()),this.cleanup.events.on(`root:mouseleave`,e,`mouseleave`,()=>this.resume()))}onStart(e,t=null){this.state.animating||(this.runtime.logs=[],this.pushLog(e),this.runtime.startTarget=t,this.runtime.touching=!0,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.clickPrevented=!1,this.pause(),this.dom.wrapper&&(this.dom.wrapper.style.transition=`none`))}onMove(e,t){if(!this.runtime.touching||this.runtime.scrolling||this.state.animating)return;this.pushLog(e);let n=this.getOffset(),r=Math.abs(n.x),i=Math.abs(n.y);if(!(r<6&&i<6)){if(!this.runtime.swiping)if(Math.atan2(i,r)*180/Math.PI<this.props.touchAngle)this.runtime.swiping=!0,this.runtime.clickPrevented=hr(this.runtime.startTarget);else{this.runtime.scrolling=!0,this.resetDrag(!0);return}this.runtime.swiping&&(t.preventDefault(),this.transform=-this.state.trackIndex*this.state.width+n.x*this.props.touchRatio,this.render(!1))}}onEnd(){if(!this.runtime.touching)return;if(this.runtime.touching=!1,!this.runtime.swiping){this.resetDrag(!0);return}let e=this.getDuration(),t=this.getOffset().x,n=this.state.trackIndex;if(e>this.props.longSwipesMs){let e=Math.ceil(Math.abs(t)/this.state.width-this.props.longSwipesRatio);e>0&&(n=this.state.trackIndex+e*(t>0?-1:1))}else{let e=Math.abs(t)/this.state.width,r=e>=this.props.longSwipesRatio?Math.max(1,Math.ceil(e-this.props.longSwipesRatio)):0;r>0&&(n=t>0?this.state.trackIndex-r:this.state.trackIndex+r)}this.slideToTrack(n),this.runtime.logs=[],this.resume()}resetDrag(e=!0){let t=this.state.trackIndex===0?0:-this.state.trackIndex*this.state.width,n=e&&this.state.transform!==t;this.runtime.touching=!1,this.runtime.scrolling=!1,this.runtime.swiping=!1,this.runtime.logs=[],this.runtime.startTarget=null,this.transform=t,this.render(n),this.resume()}onTransitionEnd(e){e&&(e.target!==this.dom.wrapper||!(`propertyName`in e)||e.propertyName!==`transform`)||(this.animating=!1,this.props.loop&&(this.state.trackIndex===0?(this.setTrackIndex(this.realCount,!1),this.render(!1)):this.state.trackIndex===this.dom.slides.length-1&&(this.setTrackIndex(1,!1),this.render(!1))))}pushLog(e){this.runtime.logs.push({x:e.pageX??e.clientX??0,y:e.pageY??e.clientY??0,time:Date.now()}),this.runtime.logs.length>5&&this.runtime.logs.shift()}getDuration(){return this.runtime.logs.length===0?0:this.runtime.logs[this.runtime.logs.length-1].time-this.runtime.logs[0].time}getOffset(){if(this.runtime.logs.length===0)return{x:0,y:0};let e=this.runtime.logs[0],t=this.runtime.logs[this.runtime.logs.length-1];return{x:t.x-e.x,y:t.y-e.y}}toRealIndex(e=this.state.trackIndex){return this.realCount?this.props.loop?e===0?this.realCount-1:e===this.dom.slides.length-1?0:e-1:e:0}trackIndexForRealIndex(e){if(!this.realCount)return 0;let t=Math.max(0,Math.min(e,this.realCount-1));return this.props.loop&&this.realCount>1?t+1:t}setTrackIndex(e,t=!0){let n=$(e);this.setState({trackIndex:n,index:this.toRealIndex(n),transform:-n*this.state.width}),t!=null&&this.render(t)}slideTo(e){return this.slideToTrack(this.trackIndexForRealIndex(e))}slideToTrack(e){if(this.assertBuilt(`slideToTrack`),this.state.animating||this.dom.slides.length===0)return;let t=e;this.props.loop?e<0?t=0:e>=this.dom.slides.length&&(t=this.dom.slides.length-1):t=Math.max(0,Math.min(e,this.dom.slides.length-1)),this.setTrackIndex(t,!0),this.props.lazyload&&this.loadImages()}next(){this.assertBuilt(`next`),!this.state.animating&&this.slideToTrack(this.state.trackIndex+1)}prev(){this.assertBuilt(`prev`),!this.state.animating&&this.slideToTrack(this.state.trackIndex-1)}render(e){this.assertBuilt(`render`),this.dom.wrapper&&(e?(this.dom.wrapper.style.transition=`transform ${this.props.speed}ms cubic-bezier(0.25, 0.46, 0.45, 0.94)`,this.animating=!0):(this.dom.wrapper.style.transition=`none`,this.animating=!1),this.dom.wrapper.style.transform=`translate3d(${this.state.transform}px, 0, 0)`)}loadImages(){this.assertBuilt(`loadImages`);let e=[this.state.trackIndex];this.state.trackIndex>0&&e.push(this.state.trackIndex-1),this.state.trackIndex<this.dom.slides.length-1&&e.push(this.state.trackIndex+1),e.forEach(e=>{let t=this.dom.slides[e];if(!t)return;let n=A(`img[data-lazy]`,t);if(!n||n.src)return;n.classList.add(this.props.className.loading),n.src=n.dataset.lazy||``;let r=()=>{n.onload=null,n.onerror=null,this.runtime.imageCleanups.delete(r)};this.runtime.imageCleanups.add(r),n.onload=()=>{n.classList.remove(this.props.className.loading),n.classList.add(this.props.className.loaded),r()},n.onerror=()=>{n.classList.remove(this.props.className.loading),n.classList.add(this.props.className.error),r()}})}clearImageCleanups(){this.runtime.imageCleanups?.forEach(e=>e()),this.runtime.imageCleanups?.clear()}initPagination(){if(!this.dom.root)return;this.dom.pagination?(this.dom.pagination.classList.add(this.props.className.paginationHorizontal,this.props.className.paginationClickable,this.props.className.paginationBulletGroup),br(this.dom.pagination,`data-swiper-pagination`)):(this.dom.pagination=(0,t.h)(`div`,{className:yr(this.props.className.pagination,this.props.className.paginationHorizontal,this.props.className.paginationClickable,this.props.className.paginationBulletGroup),"data-swiper-pagination":``}),this.dom.root.appendChild(this.dom.pagination),this.dom.createdPagination=!0);let e=this.dom.pagination;if(e){e.textContent=``,this.dom.bullets=[];for(let n=0;n<this.realCount;n++){let r=(0,t.h)(`button`,{type:`button`,className:yr(this.props.className.indicator,this.props.className.bullet),"data-swiper-bullet":String(n),"aria-label":`Go to slide ${n+1}`});this.cleanup.events.on(`bullet:${n}:click`,r,`click`,()=>{this.slideTo(n)}),this.cleanup.events.on(`bullet:${n}:keydown`,r,`keydown`,e=>{let t=e;(t.key===`Enter`||t.key===` `)&&(e.preventDefault(),this.slideTo(n))}),this.dom.bullets.push(r),e.appendChild(r)}this.cleanup.bindings=(0,t.createRoot)(e=>(this.dom.bullets.forEach((e,n)=>{(0,t.bindClass)(e,this.props.className.active,()=>this.state.index===n),(0,t.bindAttr)(e,`aria-current`,()=>this.state.index===n?`true`:null)}),e))}}initNavigation(){let e=this.ensureNavigation(`prev`,`arrow-left`),n=this.ensureNavigation(`next`,`arrow-right`);this.dom.prevButton=e,this.dom.nextButton=n,this.cleanup.events.on(`nav:prev`,e,`click`,()=>this.prev()),this.cleanup.events.on(`nav:next`,n,`click`,()=>this.next()),this.props.loop||(this.cleanup.navBindings=(0,t.createRoot)(r=>((0,t.bindClass)(e,this.props.className.disabled,()=>this.state.trackIndex<=0),(0,t.bindAttr)(e,`disabled`,()=>this.state.trackIndex<=0?``:null),(0,t.bindClass)(n,this.props.className.disabled,()=>this.state.trackIndex>=this.dom.slides.length-1),(0,t.bindAttr)(n,`disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1?``:null),r)))}ensureNavigation(e,n){if(!this.dom.root)throw Error(`Swiper.ensureNavigation: root not found.`);let r=e===`prev`?`createdPrevButton`:`createdNextButton`,i=e===`prev`?this.props.className.prev:this.props.className.next,a=yr(this.props.className.navigation,i),o=A(`[data-action="${e}"]`,this.dom.root);return o?o.tagName.toLowerCase()===`button`?(o.classList.add(this.props.className.navigation,i),br(o,`data-swiper-navigation`,e)):(o.setAttribute(`role`,`button`),o.setAttribute(`tabindex`,`0`),o.classList.add(this.props.className.navigation,i),br(o,`data-swiper-navigation`,e)):(o=(0,t.h)(`button`,{type:`button`,className:a,"data-action":e,"data-swiper-navigation":e}),this.dom.root.appendChild(o),this.dom[r]=!0),o.setAttribute(`aria-label`,e===`prev`?`Previous slide`:`Next slide`),A(`svg`,o)||(o.textContent=``,o.appendChild(x(n))),o}play(){if(this.assertBuilt(`play`),this.runtime.destroyed||this.runtime.timer||this.realCount<=1)return;let e=Math.max(this.props.delay,16);this.runtime.timer=setInterval(()=>this.next(),e)}pause(){this.runtime.timer&&(clearInterval(this.runtime.timer),this.runtime.timer=null)}resume(){this.runtime.destroyed||this.props.autoplay&&!this.runtime.timer&&this.play()}restartAutoplay(){this.pause(),this.props.autoplay&&this.play()}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);this.assertBuilt(`update`);let n=xr(e)?e:{},r=_r(Object.assign({},this.props,n)),i={};return Object.keys(n).forEach(e=>{let t=e;i[t]=r[t]}),this.props=r,this.emit(`beforeUpdate`,i,{force:t}),this.onUpdate(i,{force:t}),this.emit(`afterUpdate`,i,{force:t}),this}onUpdate(e={},t={force:!1}){if(e&&Object.prototype.hasOwnProperty.call(e,`data`)){this.updateData(e.data);return}if([`loop`,`pagination`,`navigation`,`lazyload`].some(t=>Object.prototype.hasOwnProperty.call(e,t))){this.reInitView();return}this.updateSize(),this.setupStyles(),this.setTrackIndex(this.trackIndexForRealIndex(this.state.index),!1),Object.prototype.hasOwnProperty.call(e,`autoplay`)||Object.prototype.hasOwnProperty.call(e,`delay`)?this.restartAutoplay():this.props.autoplay?this.resume():this.pause()}updateData(e=this.props.data){if(this.runtime.destroyed)throw Error(`Swiper.updateData: instance destroyed`);if(this.assertBuilt(`updateData`),!this.dom.createdRoot)throw Error(`Swiper.updateData: not supported on DOM-bound instances.`);if(g(`data`,e,pr.data,`Swiper.options`),!Array.isArray(e))return this.props.data=e,this.reInitView(),this;this.props.data=e;let t=this.state.index,n=this.dom.wrapper;if(!n)return this;this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear();let r=this.normalizeData(e);return n.textContent=``,r.forEach((e,t)=>{n.appendChild(this.createDataSlide(e,t))}),this.refreshSlides(),this.runtime.realCount=this.dom.slides.length,this.setState({index:Math.min(t,Math.max(0,this.realCount-1))}),this.reInitView(),this}};function Cr(e,t={}){return new Sr(e,t)}let wr={root:``,list:`menu`,item:`menu-item`,hasChildren:`menu-item-has-children`,link:`menu-link`,subMenu:`sub-menu`,back:`back`,active:`is-active`,icon:`el-icon`,iconPrefix:`el-prefix`,text:`menu-text`},Tr={type:{default:`mobile`,type:`string`},id:{default:``,type:`string`,normalize:e=>typeof e==`string`?e.trim()===``?v():e.trim():e},items:{default:[],type:`array`},backText:{default:`Back`,type:`string`},className:{default:wr,type:`object`,normalize:e=>({...wr,...e&&typeof e==`object`?e:{}})}},Er={type:`array`};function Dr(e={}){let t=_(e,Tr,`Menu.options`);return{...t,items:t.items.slice(),className:{...t.className}}}function Or(...e){return e.filter(Boolean).join(` `)}function kr(e){return`menu-item-${e??v()}`}function Ar(e){let t=e.tagName.toLowerCase();return t===`ul`||t===`ol`}function jr(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return(typeof t.title==`string`||typeof t.title==`number`)&&(t.id==null||typeof t.id==`string`||typeof t.id==`number`)&&(t.url==null||typeof t.url==`string`)&&(t.target==null||typeof t.target==`string`)&&(t.classes==null||Array.isArray(t.classes)&&t.classes.every(e=>typeof e==`string`))&&(t.children==null||Array.isArray(t.children)&&t.children.every(jr))}function Mr(e){return e.hasAttribute(`data-menu-list`)||Ar(e)?e:A(`[data-menu-list]`,e)}function Nr(e){return j(`[data-menu-link]`,e).find(t=>t.parentElement===e)||null}function Pr(e){return j(`[data-menu-list="sub"]`,e).find(t=>t.parentElement===e)||null}function Fr(e){return j(`[data-menu-back]`,e).find(t=>t.parentElement===e)||null}var Ir=class{constructor(e={},t=!1){this.options=Dr(e),this._element=t,this.dom={root:null},this.cleanup={events:M()},this._bound=!1,this._destroyed=!1}get root(){return this.dom.root}_verifyItems(e){g(`items`,e,Er,`Menu`),e.forEach((e,t)=>{g(String(t),e,{validate:jr,message:`expects { title, id?, url?, target?, classes?, children? }.`},`Menu.items`)})}build(){if(this._bound)return this;if(!this.options)throw Error(`Menu.build: instance destroyed.`);if(this._element===!1)this._verifyItems(this.options.items),this.dom.root=this._buildRoot(),this._bound=!0;else{let e=E(this._element);if(!e)throw Error(`Menu.element: container not found.`);this.dom.root=e,this._bound=!0}return this._bindEvents(),this}_buildRoot(){if(!this.options)throw Error(`Menu._buildRoot: instance destroyed.`);let{items:e,id:n,type:r,className:i}=this.options;return(0,t.jsx)(`nav`,{className:i.root||`j-${r}-menu`,"data-menu":`root`,"data-menu-type":r,children:(0,t.jsx)(`ul`,{className:i.list,id:n,"data-menu-list":`root`,children:e.map(e=>this._buildItem(e))})})}_buildItem(e){if(!this.options)throw Error(`Menu._buildItem: instance destroyed.`);let{className:n}=this.options,r=e.children||[],i=r.length>0,a=[n.item];i&&a.push(n.hasChildren),e.classes&&a.push(...e.classes);let o=[(0,t.jsx)(`a`,{className:n.link,href:e.url||``,...e.target&&{target:e.target},"data-menu-link":``,children:e.title})];return i&&o.push((0,t.jsx)(`ul`,{className:n.subMenu,"data-menu-list":`sub`,children:r.map(e=>this._buildItem(e))})),(0,t.jsx)(`li`,{className:Or(...a),id:kr(e.id),"data-menu-item":e.id==null?``:String(e.id),...i&&{"data-menu-has-children":``},children:o})}_bindEvents(){!this.dom.root||!this.options||!this.cleanup||(this.options.type===`mobile`?this.cleanup.events.on(`mobile`,this.dom.root,`click`,e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`[data-menu-back]`);if(n&&this.dom.root?.contains(n)){e.preventDefault(),this._handleBack(n);return}let r=t.closest(`[data-menu-has-children]`);if(r&&this.dom.root?.contains(r)){let n=Nr(r);n&&(t===n||n.contains(t))&&(e.preventDefault(),this._handleMenuClick(r))}}):this.options.type===`bottom`&&this.cleanup.events.on(`bottom`,document,`click`,e=>{let t=e.target;if(!(t instanceof Element)||!this.dom.root)return;let n=t.closest(`[data-menu-list="sub"] [data-menu-link]`);if(n&&this.dom.root.contains(n))return;let r=t.closest(`[data-menu-list="root"] > [data-menu-has-children]`);r&&this.dom.root.contains(r)?(e.preventDefault(),this._toggleActive(r)):this._clearActive()}))}_unbindEvents(){this.cleanup?.events.clear()}_teardown({keepElement:e=!1}={}){this._unbindEvents(),this.cleanup?.items?.(),this.cleanup&&(this.cleanup.items=null),this._element===!1&&this.dom.root?.parentElement&&this.dom.root.remove(),e||(this._element=null),this.dom.root=null,this._bound=!1}_handleMenuClick(e){if(!this.options)return;e.classList.add(this.options.className.active);let n=Pr(e);if(!n||Fr(n))return;let{className:r}=this.options,i=(0,t.jsx)(`li`,{className:Or(r.item,r.back),"data-menu-back":``,children:(0,t.jsx)(`a`,{className:r.link,href:``,"data-menu-link":``,children:[(0,t.jsx)(`icon`,{className:Or(r.icon,r.iconPrefix),children:x(`arrow-left`)}),(0,t.jsx)(`span`,{className:r.text,children:this.options.backText})]})});n.insertBefore(i,n.firstChild)}_handleBack(e){if(!this.options)return;let t=e.closest(`[data-menu-back]`);if(!t)return;let n=t.parentElement?.parentElement;n?.hasAttribute(`data-menu-has-children`)&&n.classList.remove(this.options.className.active),t.remove()}_toggleActive(e){if(!this.options)return;let t=e.classList.contains(this.options.className.active);this._clearActive(),t||e.classList.add(this.options.className.active)}_clearActive(){!this.dom.root||!this.options||j(`[data-menu-item]`,this.dom.root).forEach(e=>{e.classList.remove(this.options?.className.active||`is-active`)})}setItems(e){if(!this.options)throw Error(`Menu.setItems: instance destroyed.`);if(this._verifyItems(e),this.options.items=e,this._bound){if(this._element===!1){let e=this._element;this._teardown({keepElement:!0}),this._element=e,this.build()}else if(this.dom.root){let n=Mr(this.dom.root);if(!n)throw Error(`Menu: [data-menu-list] element not found.`);this._unbindEvents(),this.cleanup?.items?.(),this.cleanup&&(this.cleanup.items=(0,t.render)(()=>e.map(e=>this._buildItem(e)),n)),this._bindEvents()}}return this}removeItem(e){if(!this.dom.root)return this;let t=j(`[data-menu-item]`,this.dom.root).find(t=>t.dataset.menuItem===String(e));if(t&&t.remove(),this.options?.items){let t=n=>{for(let r=n.length-1;r>=0;r--)if(n[r].id===e)n.splice(r,1);else{let e=n[r].children;e&&t(e)}};t(this.options.items)}return this}destroy(){this._destroyed||(this._destroyed=!0,this._bound?this._teardown():(this._element=null,this.dom.root=null,this.cleanup?.events.clear()),this.cleanup=null,this.options=null)}};function Lr(e={},t=!1){return new Ir(e,t)}e.Accordion=pn,e.Component=P,e.Drop=yn,e.Flow=Vt,e.Form=U,e.Menu=Ir,e.Modal=Qn,e.Offcanvas=jn,e.Pagination=ur,e.Parabola=Jt,e.Sticky=Dt,e.Swiper=Sr,e.Tabs=rn,e.Theme=Ve,e.Toast=I,e.Toc=bt,e.Tooltip=wn,e.Validator=$e,e.addIcons=pe,e.all=j,e.copy=i,e.createAccordion=mn,e.createDrop=bn,e.createEventManager=M,e.createFlow=Ht,e.createForm=mt,e.createLoading=k,e.createMenu=Lr,e.createModal=$n,e.createOffcanvas=Mn,e.createPagination=dr,e.createParabola=Yt,e.createSticky=Ot,e.createSwiper=Cr,e.createTabs=an,e.createToc=xt,e.createTooltip=Tn,e.createValidator=et,e.debounce=re,e.getCookie=N,e.getRegistedIconPath=fe,e.getType=u,e.hasOwn=s,e.icon=x,e.iconHtml=ue,e.iconMarkup=de,e.isClass=f,e.isElement=C,e.isFunction=d,e.isMobile=r,e.isNode=S,e.isPlainObject=p,e.isRenderableContent=O,e.lazyRender=xe,e.listen=Ee,e.normalizeContentNodes=w,e.postJson=De,e.q=A,e.randomId=v,e.removeCookie=je,e.requireContainer=D,e.resolveContainer=be,e.resolveElement=E,e.resolveNode=ye,e.resolveNodeList=T,e.resolveProps=_,e.restUrl=Oe,e.service=o,e.setCookie=Ae,e.throttle=y,e.timer=l,e.uniq=c,e.uuid=ne,e.validateParam=g});