vanilla-jui 1.2.2 → 1.3.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.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{bindAttr as e,bindClass as t,createDeepStore as n,createEffect as r,createRoot as i,flushSync as a,h as o,insert as s,jsx as c,onCleanup as l,render as u,untrack as d}from"vanilla-signal";import{t as f}from"vanilla-signal-i18n";function p(){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),r=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window,i=Math.min(window.screen.width,window.screen.height)<=768;if(t&&!n){if(/iPhone|iPod|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e))return!0;if(/Android/i.test(e))return i||r}return/Macintosh|MacIntel/i.test(e)&&r&&i}async function ee(e){if(typeof window>`u`||typeof document>`u`)return Promise.resolve(!1);let t=typeof e==`string`?e:String(e);return navigator.clipboard&&typeof navigator.clipboard.writeText==`function`?navigator.clipboard.writeText(t).then(()=>!0).catch(()=>te(t)):Promise.resolve(te(t))}function te(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)}}const m=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),h={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])}},ne=e=>e===null?`null`:Array.isArray(e)?`array`:typeof HTMLElement<`u`&&e instanceof HTMLElement?`HTMLElement`:typeof Node<`u`&&e instanceof Node?`Node`:typeof e,re=e=>typeof e==`function`&&e.prototype!==null&&e.prototype.constructor===e,ie=e=>typeof e==`function`&&/^class\s/.test(Function.prototype.toString.call(e));function g(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ae(e){return Array.isArray(e)?e.slice():g(e)?{...e}:e}function _(e={}){return typeof e==`string`||Array.isArray(e)?{type:e}:!e||typeof e!=`object`?{}:e}function oe(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 se(e,t){return e?`${e}.${t}`:t}function ce(e){if(m(e,`default`))return ae(e.factory&&typeof e.default==`function`?e.default():e.default)}function v(e,t,n={},r=``){let i=_(n),a=se(r,e),o=m(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=ne(t);if(!e.some(e=>e===n)){let t=e.join(`, `);throw Error(`Validator: ${a} expects ${t}, but got ${n}.`)}oe(a,t,i.conditions)}else oe(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 y(e={},t={},n=`Options`){let r=e??{};if(typeof r!=`object`||Array.isArray(r))throw Error(`${n} expects object.`);let i={...r},a=Object.entries(t||{});for(let[e,t]of a){let n=_(t);i[e]=m(r,e)?r[e]:ce(n)}for(let[e,n]of a){let a=_(n);typeof a.normalize==`function`&&(i[e]=a.normalize(i[e],{key:e,input:r,options:i,schema:t}))}for(let[e,r]of Object.entries(t||{}))v(e,i[e],r,n);return i}function le(){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 b(e=8){if(!Number.isInteger(e)||e<1||e>32)throw Error(`Length must be an integer between 1 and 32`);let t=new Uint8Array(e);crypto.getRandomValues(t);let n=``;for(let r=0;r<e;r++)n+=`abcdefghijkmnpqrstuvwxyz23456789`[t[r]&31];return n}const x=new Map,S=new Map,ue=(e,t=[],n=``,r=!1,i=null)=>{if(!re(e))throw Error(`First argument expects a class/constructor function.`);if(!Array.isArray(t))throw Error(`Second argument must be an array of arguments.`);if(typeof n!=`string`)throw Error(`Third argument expects a string.`);if(typeof r!=`boolean`)throw Error(`Fourth argument expects a boolean.`);if(typeof i!=`number`&&i!==null)throw Error(`Fifth argument expects a number or null.`);let a=n.trim()===``?b():n;if(x.has(a)&&!r)return x.get(a).proxy;let o=new e(...t),s=new Proxy(o,{get(e,t,n){return i&&de(a,i),Reflect.get(e,t,n)},set(e,t,n,r){return Reflect.set(e,t,n,r)}});return x.set(a,{instance:o,proxy:s}),s};function de(e,t){S.has(e)&&clearTimeout(S.get(e));let n=setTimeout(()=>{fe(e)},t);S.set(e,n)}function fe(e){if(x.has(e)){let{instance:t}=x.get(e);if(typeof t.destroy==`function`)try{t.destroy()}catch{throw Error(`release(): destroy() failed on instance with key "${e}".`)}x.delete(e)}S.has(e)&&(clearTimeout(S.get(e)),S.delete(e))}function pe(){for(let{instance:e}of x.values())if(typeof e.destroy==`function`)try{e.destroy()}catch{}x.clear();for(let e of S.values())clearTimeout(e);S.clear()}const me={instances:new Map,get(e,t){return this.instances.has(e)||this.instances.set(e,t()),this.instances.get(e)},destroy(e){if(this.instances.has(e)){let t=this.instances.get(e);t.destroy&&t.destroy(),this.instances.delete(e)}},destroyAll(){for(let e of this.instances.values())e.destroy&&e.destroy();this.instances.clear()}};function C(){return typeof document<`u`}function w(){return!C()||typeof document.createElement!=`function`?!1:typeof document.createElement(`div`).insertBefore==`function`}function T(e=`Component`){if(!w())throw Error(`${e}: DOM render environment is required.`);return!0}function E(e){return C()&&typeof Node<`u`&&e instanceof Node}function D(e){return C()&&typeof Element<`u`&&e instanceof Element}function he(e){return typeof e==`string`||D(e)||E(e)||Array.isArray(e)}function ge(e){return e.find(D)||null}function _e(e,t=[]){for(let n of e){if(Array.isArray(n)){if(!_e(n,t))return null;continue}if(E(n)){t.push(n);continue}return null}return t}function O(e,t){let n=typeof e==`function`?e(t):e;if(n==null||n===!1||n===!0)return[];if(Array.isArray(n))return n.flatMap(e=>O(e,t));if(E(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 k(e,t=`Component`){if(e===!1||e==null)return null;if(typeof e==`string`){if(!C())return null;let t=Array.from(document.querySelectorAll(e));return t.length>0?t:null}if(Array.isArray(e)){let t=_e(e,[]);return t&&t.length>0?t:null}return E(e)?[e]:null}function ve(e,t=`Component`){return D(e)||E(e)?e:typeof e==`string`?C()?document.querySelector(e):null:Array.isArray(e)&&(k(e,t)||[])[0]||null}function A(e,t=`Component`){if(!he(e)||e===!1||e==null)return null;if(typeof e==`string`){if(!C())return null;let t=document.querySelector(e);return D(t)?t:null}if(Array.isArray(e)){let n=k(e,t);return Array.isArray(n)?ge(n):null}return D(e)?e:null}function ye(e,t=`Component`,n=`element`){if(![`node`,`element`,`array`].includes(n))throw Error(`${t}: expect must be one of 'node', 'element', 'array'.`);return he(e)?n===`array`?k(e,t):n===`node`?ve(e,t):A(e,t):null}function j(e,t=`Component`,n=`element`){let r=ye(e,t,n);if(r==null)throw Error(`${t}: container not found.`);return r}function M(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`function`||Array.isArray(e)||E(e)}function N(e,t=document){return t.querySelector(e)}function P(e,t=document){return Array.from(t.querySelectorAll(e))}const be=()=>{};function xe(e){return!!e&&typeof e.addEventListener==`function`&&typeof e.removeEventListener==`function`}function Se(e,t){if(!xe(e))throw TypeError(`${t}: target expects EventTarget.`)}function Ce(e,t){if(typeof e!=`string`||e.trim()===``)throw TypeError(`${t}: type expects a non-empty string.`)}function we(e,t){if(typeof e!=`function`&&(!e||typeof e.handleEvent!=`function`))throw TypeError(`${t}: handler expects a function or EventListener object.`)}function F(e,t,n,r){Se(e,`listen`),Ce(t,`listen`),we(n,`listen`);let i=!0;return e.addEventListener(t,n,r),()=>{i&&(i=!1,e.removeEventListener(t,n,r))}}function Te(e,t,n,r){Se(e,`unlisten`),Ce(t,`unlisten`),we(n,`unlisten`),e.removeEventListener(t,n,r)}function I(){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 be;let s=F(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 Ee(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:n.method||`POST`,headers:r,body:JSON.stringify(t)})).json()}const De=typeof window<`u`?`${window.location.origin}/wp-json`:``;function L(e){if(typeof document>`u`)return null;let t=`; ${document.cookie}`.split(`; ${e}=`);return t.length===2?t.pop().split(`;`).shift():null}function Oe(e,t,n=3600*24){if(typeof document>`u`)return!1;let r=new Date(Date.now()+n*1e3).toUTCString();return document.cookie=[`${e}=${t}`,`expires=${r}`,`path=/`,`sameSite=strict`].join(`; `),L(e)===t}function ke(e){return typeof document>`u`?!0:(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`,!L(e))}const R={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>`,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>`};function Ae(e){if(!(e in R))throw Error(`Icon "${e}" not found.`)}function je(e){return Ae(e),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">${R[e]}</svg>`}function z(e,t={}){T(`icon()`);let n=document.createElement(`template`);n.innerHTML=je(e);let r=n.content.firstElementChild;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 Me(e){return je(e)}const Ne=Me;function Pe(){return{...R}}function Fe(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}".`);R[t]=n}}function B(e){"@babel/helpers - typeof";return B=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},B(e)}function Ie(e,t){if(B(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(B(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Le(e){var t=Ie(e,`string`);return B(t)==`symbol`?t:t+``}function V(e,t,n){return(t=Le(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var H=class e{constructor(e={}){this.props=e||{},this.dom={root:null},this.plugins=new Map,this.cleanup={events:I(),plugins:new Map},this._listeners={init:[],beforeUpdate:[],afterUpdate:[],destroy:[]},this.state=n({}),this.runtime={destroyed:!1},this.installGlobalPlugins()}get root(){return this.dom?.root||null}set root(e){this.dom||(this.dom={}),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 e&&typeof e==`object`&&!Array.isArray(e)&&(this.props=Object.assign({},this.props,e)),typeof this.onInit==`function`&&this.onInit(this.props),this.emit(`init`,this.props),this}setState(e={},t){if(this.runtime.destroyed)throw Error(`Component.setState: instance destroyed`);let n=typeof e==`string`&&arguments.length>1?{[e]:t}:e;if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Component.setState: expects a plain object patch.`);return a(()=>{for(let[e,t]of Object.entries(n))this.state[e]=t}),this}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);return e&&typeof e==`object`&&(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}}};V(H,`globalPlugins`,new Map);const Re={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():b():e??b()},active:{default:0,types:[`number`,`string`,`array`,`null`]},collapsible:{default:!1,type:`boolean`},multiple:{default:!1,type:`boolean`},onChange:{default:null,types:[`function`,`null`]},items:{default:[],type:`array`}},ze={type:`array`,validate:e=>e.length>0,message:`expects a non-empty array.`},Be={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:e.trim().length>0,message:`expects a positive number, string, array or null.`};function Ve(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function He(e){return v(`items`,e,ze,`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(!M(e.title))throw Error(`Accordion: item title expects string, Node, array, function or null.`);if(!M(e.content))throw Error(`Accordion: item content expects string, Node, array, function or null.`);return{...e,name:e.name||b()}})}var Ue=class extends H{constructor(e,t={}){T(`Accordion`);let r=j(e,`Accordion`),i=y(t,Re,`Accordion`);super(i),this.dom.container=r,this.dom.headers=[],this.dom.panels=[],this.state=n({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 c(`div`,{className:`j-accordion`,id:e.id})}buildItems(n){let r=He(n.items),a=document.createDocumentFragment();this.dom.headers=[],this.dom.panels=[],r.forEach((e,t)=>{let r=e.name||b(),i=`${n.id}_header_${t}`,o=`${n.id}_panel_${t}`,s=c(`div`,{className:`accordion-header`,"data-item":r,id:i,role:`button`,tabindex:`0`,"aria-controls":o,children:[c(`span`,{className:`header-title`,children:this.contentView(e.title,e,t,`title`)}),c(`span`,{className:`header-arrow`,"aria-hidden":`true`,children:z(`arrow-down`)})]}),l=c(`div`,{className:`accordion-panel`,id:o,role:`region`,"aria-labelledby":i,children:c(`div`,{className:`panel-content`,children:this.contentView(e.content,e,t,`content`)})});this.dom.headers.push(s),this.dom.panels.push(l),a.append(s,l)}),this.root.append(a),this.cleanup.bindings?.(),this.cleanup.bindings=i(n=>(this.dom.headers.forEach(n=>{let r=n.dataset.item;t(n,`is-active`,()=>this.state.activeNames.includes(r)),e(n,`aria-expanded`,()=>this.state.activeNames.includes(r))}),this.dom.panels.forEach((n,r)=>{let i=this.dom.headers[r]?.dataset.item;t(n,`is-active`,()=>this.state.activeNames.includes(i)),e(n,`aria-hidden`,()=>this.state.activeNames.includes(i)?`false`:`true`),e(n,`hidden`,()=>!this.state.activeNames.includes(i))}),n))}contentView(e,t,n,r){return O(e,{accordion:this,item:t,index:n,type:r,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.item||String(t)),!this.props.multiple))break}return Array.from(new Set(n))}syncActiveNames(e){let t=e[0]||null,n=t?this.getIndex(t):null;a(()=>{this.state.activeNames=e,this.state.current={index:n,name:t}})}bindEvents(){this.unbindEvents(),this.cleanup.events.on(`click`,this.root,`click`,e=>{let t=e.target.closest(`.accordion-header`);t&&this.active(t.dataset.item)}),this.cleanup.events.on(`keydown`,this.root,`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest(`.accordion-header`);t&&(e.preventDefault(),this.active(t.dataset.item))})}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.item||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.item===e):-1}async active(e){this.assertActive(`active`),await this.activateItem(e,!0)}render(){this.assertActive(`render`),s(this.dom.container,()=>this.root)}setItems(e,t=0){this.assertActive(`setItems`),v(`items`,e,ze,`Accordion.setItems`),v(`active`,t,Be,`Accordion.setItems`),this.props.items=Ve(He(e)),this.props.active=t,this.root.textContent=``,this.buildItems(this.props),this.syncActiveNames(this.resolveActiveNames(t)),this.bindEvents()}onDestroy(){this.unbindEvents(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};const We={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=>e>=0,message:`expects a positive number or 0.`},content:{default:``,validate:M,message:`expects string, Node, array, function or null.`},className:{default:null,types:[`string`,`null`]},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():b():e??b()},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`]}};var Ge=class{constructor(e,t={}){T(`Drop`),this.target=A(e,`Drop.element`),this.props=y(t,We,`Drop`),this._init(this.props)}_init(e){this.isVisible=!1,this.root=null,this.cleanup={events:I()},this._timer={show:null,hide:null},this._hoverIntentData={x:0,y:0,lastMoveTime:0};let{delay:t}=e;typeof t==`number`&&t>=0?(this.delayShow=t,this.delayHide=t):typeof t==`object`&&t?(this.delayShow=Number(t.show)||0,this.delayHide=Number(t.hide)||0):(this.delayShow=0,this.delayHide=0),this._buildDrop(e),this._bindEvents(e)}_buildDrop(e){let{className:t,content:n,id:r,name:i,containerClassName:a}=e,o=t||``,s=E(n)&&n.nodeType===1?n:c(`div`,{className:a?`drop-container ${a}`:`drop-container`,children:O(n,this)});this.root=c(`div`,{className:o?`j-drop ${o}`:`j-drop`,id:r,"data-drop":i||b(),children:s})}_bindEvents(e){let{mode:t,hoverIntent:n}=e;this._unbindEvents(),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())):t===`click`&&(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.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.events.on(`document:mousemove`,document,`mousemove`,e=>this._onMouseMove(e)),clearTimeout(this._timer.show),this._timer.show=setTimeout(()=>{let e=Date.now()-this._hoverIntentData.lastMoveTime;Math.abs(this._hoverIntentData.x-this._lastX||0)+Math.abs(this._hoverIntentData.y-this._lastY||0)<5||e>100?(this.show(),this.cleanup.events.off(`document:mousemove`)):this._startHoverIntent()},this.delayShow)}_cancelHoverIntent(){clearTimeout(this._timer.show),this.cleanup.events.off(`document:mousemove`),this.hide()}_onMouseMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._hoverIntentData.lastMoveTime=Date.now(),this._hoverIntentData.x=e.clientX,this._hoverIntentData.y=e.clientY}_setPosition(){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){!this.root.contains(e.target)&&!this.target.contains(e.target)&&this.hide()}_exec(e){this.root&&(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.parentNode&&this.root.parentNode.removeChild(this.root)),this.root.classList.toggle(`is-active`,e),this.isVisible=e)}show(e=!0){clearTimeout(this._timer.hide),!this.isVisible&&(e&&this.delayShow>0?(clearTimeout(this._timer.show),this._timer.show=setTimeout(()=>this._exec(!0),this.delayShow)):this._exec(!0),this.props.onShown&&this.props.onShown())}hide(e=!0){clearTimeout(this._timer.show),this.isVisible&&(e&&this.delayHide>0?(clearTimeout(this._timer.hide),this._timer.hide=setTimeout(()=>this._exec(!1),this.delayHide)):this._exec(!1),this.props.onHidden&&this.props.onHidden())}toggle(){this.isVisible?this.hide():this.show()}destroy(){this.props&&(clearTimeout(this._timer?.show),clearTimeout(this._timer?.hide),this._unbindEvents(),this.root?.parentNode&&this.root.parentNode.removeChild(this.root),this.props=null,this.root=null,this.target=null,this._timer={show:null,hide:null},this.cleanup?.events.clear(),this.cleanup=null)}};function Ke(e){return e==null||typeof e==`string`||typeof e==`function`||Array.isArray(e)||typeof Node<`u`&&e instanceof Node}function qe(e){return!!e&&typeof e==`object`&&typeof e.id==`string`}function Je(e){return e==null||e===!1||typeof e==`function`}function U(e){return e&&typeof e==`object`&&!Array.isArray(e)?{...e}:{}}function Ye(e){return Array.isArray(e)?[...e]:[]}function Xe(e){return Array.isArray(e)?e.map(e=>({...e,data:U(e.data),modal:U(e.modal),view:U(e.view)})):[]}function Ze(e,t){return typeof e==`string`?{id:e}:e&&typeof e==`object`?e:{id:t}}const Qe={validate:qe,message:`expects a step object with a string id.`},$e={validate:Ke,message:`expects string, Node, array, function or null.`},et={validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty steps array.`},W={validate:e=>e==null||typeof e==`object`&&!Array.isArray(e),message:`expects an object or null.`},G={validate:Je,message:`expects function, false or null.`},tt={default:{},validate:e=>g(e),message:`expects an object with text fields.`,normalize:e=>{let t=g(e)?e:{};return{...t,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`}}},nt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():b():e??b()},steps:{default:[],...et},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:tt,className:{default:``,type:`string`},renderHeader:{default:null,...G},renderSteps:{default:null,...G},renderBody:{default:null,...G},renderFooter:{default:null,...G},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`]}};var rt=class{constructor(e={}){this.options=y(e,nt,`Flow.options`),this._init(this.options)}_init(e){this.steps=Xe(e.steps),this._validateSteps(this.steps),this._stepMap=new Map(this.steps.map((e,t)=>[e.id,t])),this._initialStepId=this._resolveInitialStepId(e.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=n({id:e.id,currentId:this._initialStepId,currentIndex:this._stepMap.get(this._initialStepId),previousId:null,previousIndex:null,direction:null,history:[this._initialStepId],data:U(this._initialData.global),stepData:U(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),()=>this._subscribers.delete(e)}snapshot(){if(!this.state)return null;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:U(this.state.data),stepData:U(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;T(`Flow.mount`);let t=A(e,`Flow.mount.container`);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`),v(`payload`,e,W,`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}=Ze(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`),v(`payload`,e,W,`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}=Ze(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`),v(`payload`,t,W,`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`),v(`data`,e,W,`Flow.setData`),e?(a(()=>{Object.assign(this.state.data,e),this.state.version+=1}),this._emitChange(),this):this}setStepData(e,t,n={}){return this._assertActive(`setStepData`),v(`stepId`,e,{type:`string`},`Flow.setStepData`),v(`data`,t,W,`Flow.setStepData`),!t||!this._stepMap.has(e)?this:(a(()=>{this.state.stepData[e]={...U(this.state.stepData[e]),...t},this.options.cache&&Object.assign(this.state.data,t),this.state.version+=1}),n.silent||this._emitChange(),this)}getStepData(e){return U(this.state.stepData[e])}reset(){return this._assertActive(`reset`),a(()=>{this.state.currentId=this._initialStepId,this.state.currentIndex=this._stepMap.get(this._initialStepId),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,U(this._initialData.global)),this._replaceObject(this.state.stepData,U(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`),v(`payload`,e,W,`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=null,this.options=null,this.state=null,this._stepMap=null,this._initialData=null,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(v(String(n),r,Qe,`Flow.options.steps`),v(`content`,r.content??null,$e,`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`){if(!this._stepMap.has(e))throw Error(`Flow.goTo target "${e}" does not exist.`);return this._stepMap.get(e)}throw Error(`Flow.goTo target expects string or number.`)}_createInitialStepData(){let e={},t={};for(let n of this.steps)e[n.id]=U(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:t,payload:n,fromStep:r}){let i=this.snapshot(),o=this._captureState();try{n&&this.setStepData(r.id,n,{silent:!0}),await this._assertCanLeave(r,e,t),await this._assertCanEnter(e,r,t),typeof r.onLeave==`function`&&await this._callHook(r.onLeave,[this._createContext({direction:t,step:r,targetId:e.id})]);let o=this.state.currentId,s=this.state.currentIndex,c=this._stepMap.get(e.id);a(()=>{this.state.previousId=o,this.state.previousIndex=s,this.state.currentId=e.id,this.state.currentIndex=c,this.state.direction=t,t===`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:t,fromId:o,step:e})]),this._emitChange(i)}catch(e){throw this._destroyed||!this.state||!this.options?e:(this.options.rollbackOnError&&this._restoreState(o,{keepLoading:!0}),this._handleError(e,i),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:U(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||!this.state)return null;throw!this._destroyed&&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||!this.state)throw this._createAbortError();return n}_createAbortError(){let e=Error(`Flow: active action was aborted.`);return e.code=`FLOW_ABORTED`,e}_setLoading(e,t=this.state?.busyAction||null){this.state&&a(()=>{this.state.loading=e,this.state.busyAction=e?t:null})}_handleError(e,t=null){this.state&&(a(()=>{this.state.error=e,this.state.version+=1}),typeof this.options.onError==`function`&&this.options.onError(e,this.snapshot(),this,t))}_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:Ye(this.state.history),data:U(this.state.data),stepData:U(this.state.stepData),loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error,version:this.state.version}}_restoreState(e,t={}){a(()=>{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=t.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||!this.state)throw Error(`Flow.${e}: instance has been destroyed.`)}_publicStep(e){if(!e)return null;let t={...e};return delete t.onEnter,delete t.onLeave,delete t.onNext,delete t.onBack,delete t.canEnter,delete t.canLeave,t}_buildRoot(){return c(`div`,{className:`j-flow ${this.options.className||``}`.trim(),id:this.options.id,role:`group`,"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=i(e=>(l(u(()=>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 c(`div`,{className:`flow-header`,children:[c(`div`,{id:`${this.options.id}-title`,className:`flow-title`,children:e.currentStep?.title||e.currentStep?.id||``}),e.currentStep?.description?c(`div`,{className:`flow-description`,children:e.currentStep.description}):null]})}_stepsView(e){return c(`ol`,{className:`flow-steps`,role:`list`,"aria-label":`Flow steps`,children:this.steps.map((t,n)=>c(`li`,{className:this._stepClass(n,e.currentIndex),"aria-current":n===e.currentIndex?`step`:void 0,children:[c(`button`,{type:`button`,className:`flow-step-button`,disabled:this.options.linear&&n>e.currentIndex,"aria-current":n===e.currentIndex?`step`:void 0,"aria-disabled":this.options.linear&&n>e.currentIndex?`true`:`false`,"aria-label":`${n+1}. ${t.title||t.id}`,onClick:()=>{n!==e.currentIndex&&this.goTo(n)},children:[c(`span`,{className:`flow-step-index`,children:n+1}),c(`span`,{className:`flow-step-title`,children:t.title||t.id})]})]}))})}_bodyView(e){return c(`div`,{className:`flow-body`,role:`region`,"aria-live":`polite`,"aria-busy":e.loading?`true`:`false`,children:this._contentView(e.currentStep?.content)})}_footerView(e){return c(`div`,{className:`flow-footer`,children:[this.options.showReset?c(`button`,{type:`button`,className:`j-button is-ghost flow-reset`,onClick:()=>this.reset(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:this.options.text.reset}):null,this.options.showBack?c(`button`,{type:`button`,className:`j-button is-ghost flow-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?c(`button`,{type:`button`,className:`j-button is-primary flow-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()):Array.isArray(e)||typeof Node<`u`&&e instanceof Node?e:e==null||typeof e!=`string`?``:e}_stepClass(e,t=this.state.currentIndex){let n=[`flow-step`];return e===t&&n.push(`is-active`),e<t&&n.push(`is-complete`),n.join(` `)}};function it(e){return new rt(e)}const at={type:{default:`mobile`,type:`string`},id:{default:``,type:`string`,normalize:e=>e.trim()===``?b():e.trim()},items:{default:[],type:`array`},backText:{default:`Back`,type:`string`}},ot={type:`array`};var st=class{constructor(e={},t=!1){this.options=y(e,at,`Menu.options`),this._element=t,this.root=null,this.cleanup={events:I()},this._bound=!1,this._destroyed=!1}_verifyItems(e){v(`items`,e,ot,`Menu`)}build(){return this._bound?this:(T(`Menu`),this._element===!1?(this.root=this._buildRoot(),this._bound=!0):(this.root=A(this._element,`Menu.element`),this._bound=!0),this._bindEvents(),this)}_buildRoot(){let{items:e,id:t,type:n}=this.options;return c(`nav`,{className:`j-${n}-menu`,children:c(`ul`,{className:`menu`,id:t,children:e.map(e=>this._buildItem(e))})})}_buildItem(e){let t=e.children&&e.children.length>0,n=[`menu-item`];t&&n.push(`menu-item-has-children`),e.classes&&Array.isArray(e.classes)&&n.push(...e.classes);let r=[c(`a`,{className:`menu-link`,href:e.url||`#`,...e.target&&{target:e.target},children:e.title})];return t&&r.push(c(`ul`,{className:`sub-menu`,children:e.children.map(e=>this._buildItem(e))})),c(`li`,{className:n.join(` `),id:`menu-item-${e.id||b()}`,children:r})}_bindEvents(){this.root&&(this.options.type===`mobile`?this.cleanup.events.on(`mobile`,this.root,`click`,e=>{let t=e.target;if(t.closest(`.menu-item.back`)){e.preventDefault(),this._handleBack(t);return}let n=t.closest(`.menu-item.menu-item-has-children`);if(n){let r=N(`:scope > a`,n);r&&(t===r||r.contains(t))&&(e.preventDefault(),this._handleMenuClick(n))}}):this.options.type===`bottom`&&this.cleanup.events.on(`bottom`,document,`click`,e=>{let t=e.target;if(t.closest(`.sub-menu a`))return;let n=t.closest(`.menu > .menu-item.menu-item-has-children`);n?(e.preventDefault(),this._toggleActive(n)):N(`.menu-item.is-active`,this.root)?.classList.remove(`is-active`)}))}_unbindEvents(){this.cleanup.events.clear()}_teardown({keepElement:e=!1}={}){this._unbindEvents(),this.cleanup.items?.(),this.cleanup.items=null,this._element===!1&&this.root?.parentElement&&this.root.remove(),e||(this._element=null),this.root=null,this._bound=!1}_handleMenuClick(e){e.classList.add(`is-active`);let t=N(`:scope > .sub-menu`,e);if(!t||N(`:scope > .menu-item.back`,t))return;let n=c(`li`,{className:`menu-item back`,children:c(`a`,{className:`menu-link`,children:[c(`icon`,{className:`el-icon el-prefix`,children:z(`arrow-left`)}),c(`span`,{className:`menu-text`,children:this.options.backText})]})});t.insertBefore(n,t.firstChild)}_handleBack(e){let t=e.closest(`.menu-item.back`);if(!t)return;let n=t.parentElement.parentElement;n&&n.classList.contains(`menu-item-has-children`)&&n.classList.remove(`is-active`),t.remove()}_toggleActive(e){let t=e.classList.contains(`is-active`);N(`.menu-item.is-active`,this.root)?.classList.remove(`is-active`),t||e.classList.add(`is-active`)}setItems(e){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{let t=this.root.matches?.(`.menu`)||this.root.matches?.(`ul`)||this.root.matches?.(`ol`)?this.root:N(`:scope > .menu`,this.root)||N(`.menu`,this.root);if(!t)throw Error(`Menu: .menu element not found for setItems().`);this._unbindEvents(),this.cleanup.items?.(),this.cleanup.items=u(()=>e.map(e=>this._buildItem(e)),t),this._bindEvents()}return this}removeItem(e){if(!this.root)return this;let t=N(`[id^="menu-item-${e}"]`,this.root);if(t&&t.remove(),this.options.items){let t=n=>{for(let r=n.length-1;r>=0;r--)n[r].id===e?n.splice(r,1):n[r].children&&t(n[r].children)};t(this.options.items)}return this}destroy(){this._destroyed||(this._destroyed=!0,this._bound?this._teardown():(this._element=null,this.root=null,this.cleanup.events.clear()),this.cleanup=null,this.options=null)}};function K(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 q(e){return{...e,fields:Array.isArray(e.fields)?K(e.fields):e.fields}}function ct(e){return e&&typeof e==`object`?e:{value:e,text:e}}function lt(e){return e==null||typeof e==`string`||typeof e==`function`||Array.isArray(e)||E(e)}function ut(e){return g(e)}function dt(e){return e==null||typeof e==`object`&&typeof e.next==`function`&&typeof e.back==`function`&&typeof e.snapshot==`function`}function ft(e,t){return!Array.isArray(e)||!g(t)?e:e.map(e=>{if(!e?.name||!m(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:n}})}function pt(e){let t=g(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 mt(e){return{...e,fields:Array.isArray(e.fields)?K(e.fields):null,text:pt(e),loading:!1,submitting:!1,visible:!1,data:null,extraData:null}}function ht(e,t){return!t||typeof t!=`object`?e:Object.assign(e,t)}function gt(e){return g(e)?{...e}:{}}const _t={validate:lt,message:`expects string, Node, array, function or null.`},vt={default:{},validate:e=>g(e),message:`expects an object with text fields.`,normalize:e=>{let t=g(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`}}},yt={types:[`array`,`null`]},J={content:{default:``,..._t},position:{default:`center`,type:`string`},showCancel:{default:!0,type:`boolean`},showClose:{default:!0,type:`boolean`},fullscreen:{default:!1,type:`boolean`},flow:{default:null,validate:dt,message:`expects a Flow instance or null.`},text:vt,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,...yt},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()?e.trim():b():e??b()},escClose:{default:!1,type:`boolean`},bgClose:{default:!1,type:`boolean`},lazy:{default:!1,type:`boolean`}},bt={...J,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`]}},xt=new Set([`id`,`lazy`]),St={validate:e=>!!e&&typeof e==`object`&&!Array.isArray(e),message:`expects an object.`},Ct={validate:ut,message:`expects a props object.`};let Y=0,X=``;var wt=class extends H{constructor(e={}){let t=y(e,J,`Modal`);super(t),this.dom.modal=null,this.dom.header=null,this.dom.body=null,this.dom.footer=null,this.dom.form=null,this.cleanup.visibility=null,this.cleanup.view=null,this.cleanup.hideTimer=null,this.runtime.scrollLocked=!1,this.runtime.visibleApplied=!1,this.cache={initial:q(this.props),fieldIds:new Map,baseStyle:``,previousActiveElement:null,formId:`${this.props.id}_form`},this.state=n(mt(this.props)),this.init(t)}onInit(){this.bindReactiveVisibility(),!this.state.lazy&&w()&&this.buildRoot()}buildRoot(){if(this.root)return this.root;let{id:e}=this.state,t=c(`div`,{className:()=>`j-popup-layout is-${this.state.position}`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":()=>this.state.header?`${e}_title`:null,"aria-label":()=>this.state.header?null:this.state.text?.title||`Modal`,children:c(`div`,{className:()=>this.state.fullscreen?`j-modal is-fullscreen`:`j-modal`,id:e,role:`document`,ref:e=>{this.dom.modal=e,this.applyStyle(e,this.state.style)},children:[c(`div`,{className:`modal-header`,style:()=>({display:this.state.header?``:`none`}),ref:e=>{this.dom.header=e}}),c(`div`,{className:`modal-body`,ref:e=>{this.dom.body=e}}),c(`div`,{className:`modal-footer`,style:()=>({display:this.state.footer?``:`none`}),ref:e=>{this.dom.footer=e}})]})});return this.root=t,this.mountView(),t}mountView(){this.cleanup.view||!this.dom.body||(this.cleanup.view=i(e=>(this.dom.header&&l(u(()=>this.headerView(),this.dom.header)),u(()=>this.bodyView(),this.dom.body),this.dom.footer&&l(u(()=>this.footerView(),this.dom.footer)),this.bindReactiveLoading(),this.bindReactiveStyle(),e)))}headerView(){return()=>this.state.header?[c(`div`,{className:`modal-title`,id:`${this.state.id}_title`,children:()=>this.state.text?.title}),this.state.showClose?c(`button`,{type:`button`,className:`is-reset modal-close`,"data-action":`close`,"aria-label":`close`,children:z(`close`)}):null]:null}footerView(){return()=>this.state.footer?[this.state.showCancel?c(`button`,{type:`button`,className:`j-button is-ghost modal-cancel`,"data-action":`close`,"aria-label":`close`,disabled:()=>this.isBusy(),children:()=>this.state.text?.cancel}):null,c(`button`,{type:()=>this.isFormMode()?`submit`:`button`,form:()=>this.isFormMode()?this.cache.formId:null,className:`j-button is-primary modal-confirm`,"data-action":this.isFormMode()?`submit`:`confirm`,disabled:()=>this.isBusy(),children:()=>this.state.text?.confirm})]:null}bodyView(){return this.isFormMode()?this.formView():(this.dom.form=null,this.contentView(this.state.content))}formView(){return c(`div`,{className:`modal-form-container`,children:c(`form`,{id:this.cache.formId,className:`j-form is-vertical is-item-vertical`,ref:e=>{this.dom.form=e},onSubmit:e=>this.handleFormSubmit(e),onKeyDown:e=>this.handleFormKeydown(e),children:(this.state.fields||[]).map((e,t)=>this.fieldView(e,t))})})}fieldView(e,t){let n=this.resolveFieldId(e,t),r=this.labelView(e,n);return c(`div`,{className:`form-item`,style:{display:e.type===`hidden`?`none`:``},children:[r,c(`div`,{className:`form-control`,children:this.controlView(e,n)})]})}labelView(e,t){return c(`label`,{className:`item-label ${e.required?`is-required`:``}`,for:t,style:{display:e.label===void 0?`none`:``},children:e.label===void 0?``:e.label})}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}_${b()}`),this.cache.fieldIds.get(n)}controlView(e,t){switch(e.type){case`textarea`:return this.textareaView(e,t);case`select`:return this.selectView(e,t);default:return this.inputView(e,t)}}inputView(e,t){let n=e.type||`text`,r={type:n,className:`j-input`,name:e.name,id:t,placeholder:e.placeholder||``,value:e.value??``,autocomplete:e.autocomplete||this.autoComplete(n),required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly};return e.checked!==void 0&&(r.checked=!!e.checked),c(`input`,r)}textareaView(e,t){return c(`textarea`,{className:`j-textarea`,name:e.name,id:t,placeholder:e.placeholder||``,value:e.value??``,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly})}selectView(e,t){let n=e.value;return c(`select`,{className:`j-select`,name:e.name,id:t,autocomplete:`off`,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly,multiple:!!e.multiple,children:(e.options||[]).map(e=>{let t=ct(e);return c(`option`,{value:t.value??``,disabled:!!t.disabled,selected:this.isSelected(n,t.value),children:t.text??t.label??t.value??``})})})}contentView(e){if(typeof e==`function`)return e(this);if(Array.isArray(e)||E(e))return e;if(e==null||typeof e!=`string`)return``;let t=document.createElement(`template`);return t.innerHTML=e,Array.from(t.content.childNodes)}bindReactiveLoading(){let e=null;r(()=>{this.state.loading&&!e?(e=c(`div`,{className:`j-loading is-active`,"aria-live":`polite`,children:c(`div`,{className:`loading-spinner`})}),this.dom.modal.appendChild(e)):!this.state.loading&&e&&(e.remove(),e=null)}),l(()=>{e?.remove(),e=null})}bindReactiveStyle(){r(()=>{let e=this.state.style;this.dom.modal&&this.applyStyle(this.dom.modal,e)})}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(String).includes(String(t)):e==t}isFormMode(){return Array.isArray(this.state.fields)}isBusy(){return!!(this.state.loading||this.state.submitting)}validatePropsPatch(e,t=`Modal.update`){v(`props`,e,Ct,t);for(let n of Object.keys(e)){if(!m(J,n))throw Error(`Validator: ${t}.${n} is not a supported modal prop.`);if(xt.has(n))throw Error(`Modal.update: "${n}" cannot be updated after initialization.`);v(n,e[n],J[n],t)}}applyProps(e,{validate:t=!0,force:n=!1}={}){if(t&&this.validatePropsPatch(e),!e||Object.keys(e).length===0)return this;let r=m(e,`fields`);if(m(e,`content`)&&!r&&this.isFormMode()&&!n)throw Error(`Modal.update: Cannot update content when fields are defined.`);let i=Object.assign({},this.props,e);m(e,`text`)&&(i.text=Object.assign({},this.props.text||{},e.text)),this.props=i,super.update(e,{force:n}),this.props=i;let o={};r&&(this.cache.fieldIds.clear(),o.fields=Array.isArray(e.fields)?K(e.fields):null);for(let[t,n]of Object.entries(e))t===`fields`||t===`text`||(o[t]=n);return m(e,`text`)&&(o.text=pt(this.props)),a(()=>{for(let[e,t]of Object.entries(o))this.state[e]=t}),m(e,`style`)&&this.dom.modal&&this.applyStyle(this.dom.modal,this.state.style),this.state.visible&&(m(e,`bgClose`)||m(e,`escClose`))&&this.bindEvents(this.root),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}typeof t==`object`&&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`)||``}normalizeIcon(e){if(!(e instanceof Element))return;let t=N(`.modal-close`,e);t&&(t.style.transform=`translateX(${t.clientHeight/3}px)`)}bindReactiveVisibility(){this.cleanup.visibility=i(e=>(r(()=>{let e=!!this.state.visible;d(()=>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.`);T(`Modal.show`),this.root||this.buildRoot(),this.cancelHideTimer(),this.resetAnimationStyles();let{onShow:e,onShown:t}=this.state;e&&e(),this.cache.previousActiveElement=document.activeElement,this.root.parentNode||document.body.appendChild(this.root),this.lockScroll(),this.runtime.visibleApplied=!0,this.normalizeIcon(this.dom.modal),this.bindEvents(this.root),this.focusFirst(),t&&t()}hideFromState(){if(!this.runtime.visibleApplied||!this.root)return;let{onHide:e,onHidden:t}=this.state;e&&e(),this.runtime.visibleApplied=!1,this.clearEvents(),a(()=>{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(t),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){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`||t.classList.contains(`modal-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()){if(t.classList.contains(`modal-confirm`))return;this.requestSubmit();return}this.handleConfirm()}})}clearEvents(){this.cleanup.events.clear()}requestSubmit(){if(!this.dom.form){this.handleConfirm();return}if(typeof this.dom.form.requestSubmit==`function`){this.dom.form.requestSubmit();return}let e=new Event(`submit`,{bubbles:!0,cancelable:!0});this.dom.form.dispatchEvent(e)}async handleFormSubmit(e){if(e.preventDefault(),this.isBusy())return;let t=e.currentTarget;if(!t.checkValidity()){t.reportValidity();return}let n=ht(this.collectFormData(t),this.state.extraData);a(()=>{this.state.data=n}),await this.handleSubmit(n)}handleFormKeydown(e){if(e.key!==`Enter`||e.isComposing||this.isBusy())return;let t=e.target,n=t?.tagName?.toLowerCase(),r=t?.type?.toLowerCase();n!==`textarea`&&(r===`button`||r===`submit`||r===`reset`||(e.preventDefault(),this.requestSubmit()))}collectFormData(e){let t={},n=new FormData(e);for(let[e,r]of n.entries())m(t,e)?t[e]=Array.isArray(t[e])?[...t[e],r]:[t[e],r]:t[e]=r;return t}async handleNext(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`next`)}async handleBack(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`back`)}hasFlow(){return dt(this.state.flow)&&!!this.state.flow}async moveFlow(e){let t=this.createFlowPayload();if(t!==!1){a(()=>{this.state.submitting=!0});try{let n=await this.state.flow[e](t);this.syncFlowView(this.state.flow,n)}catch(t){console.error(`Modal.flow.${e} error:`,t),this.syncFlowView(this.state.flow)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}createFlowPayload(){if(!this.isFormMode())return null;let e=this.dom.form;if(!e)return this.state.data||null;if(!e.checkValidity())return e.reportValidity(),!1;let t=ht(this.collectFormData(e),this.state.extraData);return a(()=>{this.state.data=t}),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 g(i)?i:{}}return gt(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=g(i.text)?i.text:{},o={...(!m(i,`text`)||!m(a,`title`))&&r?.title!=null?{text:{...a,title:r.title}}:{},...!m(i,`content`)&&!m(i,`fields`)?{content:r?.content??null}:{},...i};Array.isArray(o.fields)&&(o.fields=ft(o.fields,n?.currentData)),!m(o,`fields`)&&m(o,`content`)&&(o.fields=null),this.update(o)}async handleConfirm(){if(!this.isBusy()){a(()=>{this.state.submitting=!0});try{this.state.onConfirm&&await Promise.resolve(this.state.onConfirm()),this.hide()}catch(e){console.error(`Modal.onConfirm error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}async handleCancel(){if(!this.isBusy()){a(()=>{this.state.submitting=!0});try{this.state.onCancel&&await Promise.resolve(this.state.onCancel(this)),this.hide()}catch(e){console.error(`Modal.onCancel error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}async handleSubmit(e){if(this.state.onSubmit){a(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onSubmit(e)),this.state.extraData=null}catch(e){console.error(`Modal.onSubmit error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}trapFocus(e){if(!this.dom.modal)return;let t=Array.from(P(`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=N(`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]):not([data-action=close]), [tabindex]:not([tabindex="-1"])`,this.dom.form||this.dom.modal);e?e.focus():(this.dom.modal.setAttribute(`tabindex`,`-1`),this.dom.modal.focus())}lockScroll(){this.runtime.scrollLocked||!C()||(Y===0&&(X=document.body.style.overflow,document.body.style.overflow=`hidden`),Y+=1,this.runtime.scrollLocked=!0)}unlockScroll(){!this.runtime.scrollLocked||!C()||(Y=Math.max(0,Y-1),Y===0&&(document.body.style.overflow=X,X=``),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?.parentNode&&this.root.parentNode.removeChild(this.root),this.resetAnimationStyles(),this.unlockScroll(),this.restoreFocus(),e&&e()}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(!m(bt,t))throw Error(`Modal.setState: "${t}" is not a supported state key.`);if(xt.has(t))throw Error(`Modal.setState: "${t}" cannot be updated after initialization.`);v(t,e[t],bt[t],`Modal.setState`)}}setState(e={}){return this.assertActive(`setState`),this.validateStatePatch(e),a(()=>{for(let[t,n]of Object.entries(e))t===`fields`&&this.cache.fieldIds.clear(),this.state[t]=t===`fields`&&Array.isArray(n)?K(n):n}),this}show(){return this.assertActive(`show`),a(()=>{this.state.visible=!0}),this}hide(){return this.assertActive(`hide`),a(()=>{this.state.visible=!1}),this}setFields(e,t=!1){return v(`data`,e,yt,`Modal.setFields`),this.applyProps({fields:e},{validate:!1,force:t}),this}addFields(e){return v(`data`,e,St,`Modal.addFields`),a(()=>{this.state.extraData=e}),this}setContent(e,t=!1){if(v(`content`,e,_t,`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){return this.applyProps(e,{validate:!0,force:t})}reset(){this.cache.fieldIds.clear();let e=q(this.cache.initial);return delete e.id,delete e.lazy,this.props=q(e),this.applyProps(e,{validate:!1}),a(()=>{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)?K(this.cache.initial.fields):null)}onDestroy(){let e=!!this.runtime.visibleApplied,t=this.state?.onHide,n=this.state?.onHidden;e&&t&&t(),this.cancelHideTimer(),this.clearEvents(),this.unlockScroll(),this.cleanup.visibility?.(),this.cleanup.visibility=null,this.cleanup.view?.(),this.cleanup.view=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root),e&&n&&n(),this.cache={initial:null,fieldIds:null,baseStyle:``,previousActiveElement:null,formId:``}}destroy(){if(!this.runtime.destroyed)return super.destroy(),this}};const Tt={content:{default:``,validate:M,message:`expects string, Node, array, function or null.`},overlay:{default:!0,type:`boolean`},filter:{default:!0,type:`boolean`},direction:{default:`left`,type:`string`,enum:[`top`,`right`,`bottom`,`left`]},animation:{default:`slide`,type:`string`,enum:[`slide`,`push`,`none`]},bgClose:{default:!0,type:`boolean`},escClose:{default:!0,type:`boolean`},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():b():e??b()},onShow:{default:null,types:[`function`,`null`]},onShown:{default:null,types:[`function`,`null`]},onHide:{default:null,types:[`function`,`null`]},onHidden:{default:null,types:[`function`,`null`]}};var Et=class extends H{constructor(e={}){T(`Offcanvas`);let t=y(e,Tt,`Offcanvas`);super(t),this._overlay=null,this.state=n({visible:!1}),this.onInit(t)}onInit(e){e.overlay&&(this._overlay=this._buildOverlay(e)),this.root=this._buildRoot(e)}_buildOverlay(e){return c(`div`,{className:`j-offcanvas-overlay`,style:e.filter?{backdropFilter:`blur(2px)`}:{}})}_buildRoot(e){return c(`div`,{className:`j-offcanvas is-${e.direction} is-${e.animation}`,id:e.id,children:c(`div`,{className:`offcanvas-content`,children:O(e.content,this)})})}_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.key===`Escape`&&this.state.visible&&this.hide()}),this.cleanup.events.on(`close`,this.root,`click`,e=>{let t=e.target.dataset.action;(t===`close`||t===`cancel`)&&this.hide()})}unbindEvents(){this.cleanup?.events.clear()}_render(){let{overlay:e,animation:t,direction:n,id:r}=this.props,i=document.body;e&&i.appendChild(this._overlay),i.appendChild(this.root),i.style.overflow=`hidden`,t===`push`&&i.classList.add(`offcanvas-push-body`),h.start(`oc-show-${r}`,10,()=>{this.root&&(this._overlay&&this._overlay.classList.add(`is-active`),t===`push`&&i.classList.add(`offcanvas-push-${n}`),this.root.classList.add(`is-active`))})}_remove(){let{animation:e,direction:t,id:n}=this.props,r=document.body;this._overlay&&this._overlay.classList.remove(`is-active`),this.root.classList.remove(`is-active`),e===`push`&&r.classList.remove(`offcanvas-push-${t}`),h.start(`oc-remove-${n}`,100,()=>{this._overlay?.parentNode?.removeChild(this._overlay),this.root?.parentNode?.removeChild(this.root),e===`push`&&r.classList.remove(`offcanvas-push-body`),r.style.overflow=``})}async show(){if(this.runtime.destroyed||this.state.visible)return;let{onShow:e,onShown:t,id:n}=this.props;e&&await Promise.resolve(e()),this._render(),this._bindEvents(),a(()=>{this.state.visible=!0}),h.start(`oc-shown-${n}`,300,()=>{this.runtime.destroyed||t&&t()})}async hide(){if(this.runtime.destroyed||!this.state.visible)return;let{onHide:e,onHidden:t}=this.props;e&&await Promise.resolve(e()),this.unbindEvents(),this._remove(),a(()=>{this.state.visible=!1}),t&&t()}onDestroy(){let{id:e}=this.props;h.cancel(`oc-show-${e}`),h.cancel(`oc-remove-${e}`),h.cancel(`oc-shown-${e}`),this.state.visible&&this.unbindEvents(),this.root?.classList.remove(`is-active`),this.root?.parentNode?.removeChild(this.root),this._overlay?.parentNode?.removeChild(this._overlay);let t=document.body;t.style.overflow=``,t.classList.remove(`offcanvas-push-body`,`offcanvas-push-${this.props.direction}`),this._overlay=null}};const Dt={validate:e=>e==null||typeof e==`string`||Array.isArray(e)||E(e),message:`expects Element, Node, selector or JSX node.`},Ot={ball:{default:{color:`var(--primary, #3e63dd)`,size:`10px`},type:`object`,validate:e=>e&&Object.keys(e).length===2&&typeof e.color==`string`&&typeof e.size==`string`,message:`expects an object with two string properties: "color" and "size".`},from:{default:null,...Dt},to:{default:null,...Dt},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`]}};var kt=class{constructor(e){T(`Parabola`),this.options=y(e,Ot,`Parabola.options`),this._init(this.options)}_init(e){this.hidden=!1,this._ball=null,this._animationId=null;let t=A(e.from,`Parabola.from`),n=A(e.to,`Parabola.to`);this._fromEl=t,this._toEl=n,this._createBall(e)}_createBall(e){if(this.hidden||this._ball)return;let{color:t,size:n}=e.ball;this._ball=c(`div`,{className:`parabola-ball`,style:{backgroundColor:t,width:n,height:n,position:`fixed`,borderRadius:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,zIndex:`9999`,opacity:`1`}}),document.body.appendChild(this._ball)}_calculatePath(e){let t=this._fromEl?.getBoundingClientRect(),n=this._toEl?.getBoundingClientRect();if(!t||!n)return null;let{left:r,top:i,width:a,height:o}=t,{left:s,top:c,width:l,height:u}=n,d,f;switch(e.direction){case`top-left`:d=r+a*.2,f=i+o*.2;break;case`top-right`:d=r+a*.8,f=i+o*.2;break;case`bottom-left`:d=r+a*.2,f=i+o*.8;break;case`bottom-right`:d=r+a*.8,f=i+o*.8;break;default:d=r+a/2,f=i+o/2}let p=s+l/2,ee=c+u/2;return{startX:d,startY:f,endX:p,endY:ee}}_easeOutCubic(e){return 1-(1-e)**3}_animate(e,t,n,r,i=800){if(this.hidden)return;let a=performance.now(),o=n-e,s=r-t,c=n=>{if(this.hidden)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)}async show(){return this.hidden?!1:new Promise(e=>{h.start(`show`,this.options.showDelay,()=>{if(this.hidden){e(!1);return}let t=this._calculatePath(this.options);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.options.onShow(),this._animate(t.startX,t.startY,t.endX,t.endY),e(!0)})})}destroy(){this.hidden||(this._ball?.remove(),h.cancel(`show`),this._animationId&&cancelAnimationFrame(this._animationId),this._ball=null,this._fromEl=null,this._toEl=null,this.hidden=!0,this.options.onHidden&&this.options.onHidden())}start(){return this.show()}};const At={target:{default:null},parent:{default:null},max:{default:10,type:`number`,validate:e=>Number.isInteger(e)&&e>0,message:`expects a positive integer.`},top:{default:16,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},gap:{default:16,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},overflow:{default:`destroy`,type:`string`,enum:[`destroy`,`ignore`]},onUpdate:{default:null,types:[`function`,`null`]}};function Z(e){return Array.from(new Set(e.filter(D)))}function jt(e,t){return!t||e===t||t.contains(e)}function Mt(e){return e===!1||e==null?null:j(e,`Sticky.parent`,`element`)}function Nt(e,t){if(e===!1||e==null)return[];if(typeof e==`string`){if(!t)return Z(j(e,`Sticky.target`,`array`));let n=Z(Array.from(t.querySelectorAll(e)));if(n.length===0)throw Error(`Sticky.target: target not found.`);return n}let n=Z(j(e,`Sticky.target`,`array`));if(!t)return n;let r=n.filter(e=>jt(e,t));if(r.length===0)throw Error(`Sticky.target: target not found in parent.`);return r}function Pt(e){let t=e.offsetHeight;return Number.isFinite(t)?t:0}var Ft=class extends H{constructor(e={}){let t=y(e,At,`Sticky.props`);super(t),this.dom.parent=null,this.dom.targets=[],this.runtime.active=!1,this.runtime.built=!1,this.runtime.ignored=!1,this.runtime.items=[],this.state=n({count:0,top:t.top,items:[]})}build(){if(this.runtime.destroyed)throw Error(`Sticky.build: instance destroyed`);return this.runtime.built||(T(`Sticky`),this.init(this.props),this.dom.parent=Mt(this.props.parent),this.dom.targets=Nt(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+=Pt(e.element)+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}onDestroy(){this._restore(),this.runtime.active=!1,this.runtime.built=!1,this.runtime.items=[],this.dom.targets=[]}};function It(e={}){return new Ft(e)}const Lt={container:{default:null},target:{default:`.j-content`},headings:{default:`h2, h3`,type:`string`},offset:{default:80,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},onUpdate:{default:null,types:[`function`,`null`]}};function Rt(e){let t=/^H([1-6])$/.exec(e.tagName);return t?Number(t[1]):1}function zt(e,t){return e.id||(e.id=`toc-${b()}-${t}`),{id:e.id,text:e.textContent||``,level:Rt(e),element:e}}var Bt=class extends H{constructor(e={}){let t=y(e,Lt,`Toc.props`);super(t),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=n({items:[],current:{index:-1,item:null}})}build(){if(this.runtime.destroyed)throw Error(`Toc.build: instance destroyed`);return this.runtime.built?this:(T(`Toc`),this.init(this.props),this.dom.container=j(this.props.container,`Toc.container`),this.dom.target=j(this.props.target,`Toc.target`),this.root=document.createElement(`nav`),this.root.className=`j-toc`,this.dom.list=document.createElement(`div`),this.dom.list.className=`toc-list`,this.root.appendChild(this.dom.list),this.dom.container.innerHTML=``,this.dom.container.appendChild(this.root),this.runtime.built=!0,this.refresh(),this)}_bindEvents(){this.cleanup.events.on(`scroll`,window,`scroll`,()=>this._onScroll(),{passive:!0})}_onScroll(){this.runtime.ticking||(requestAnimationFrame(()=>{this._updateActive(),this.runtime.ticking=!1}),this.runtime.ticking=!0)}_buildLink(e){let t=document.createElement(`a`);return t.href=`#${e.id}`,t.className=`toc-link is-level-${e.level}`,t.textContent=e.text,t.dataset.tocTarget=e.id,t}_updateActive(){if(!this.runtime.built)return;let e=-1;for(let t=this.dom.headings.length-1;t>=0;t--)if(this.dom.headings[t].getBoundingClientRect().top<=this.props.offset){e=t;break}if(e===this.state.current.index)return;let t=this.state.items[e]||null;this.setState({current:{index:e,item:t}}),this.dom.links.forEach((t,n)=>{let r=n===e;t.dataset.active=r?`1`:`0`,t.className=`toc-link is-level-${this.state.items[n].level}${r?` is-active`:``}`}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(t,e,this)}refresh(){if(this.runtime.destroyed||!this.runtime.built)return this;this.cleanup.events.clear(),this.dom.headings=Array.from(this.dom.target.querySelectorAll(this.props.headings));let e=this.dom.headings.map(zt);this.dom.links=e.map(e=>this._buildLink(e)),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||!Number.isInteger(e)||e<0||e>=this.dom.links.length||this.dom.links[e].scrollIntoView({behavior:`smooth`,block:`start`}),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 Vt(e={}){return new Bt(e)}const Q={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=>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=>e>=0,message:`expects a positive number or 0.`},touchRatio:{default:1,type:`number`,validate:e=>e>0,message:`expects a number greater than 0.`},touchAngle:{default:45,type:`number`,validate:e=>e>=0&&e<=90,message:`expects a number between 0 and 90.`},longSwipesMs:{default:300,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},longSwipesRatio:{default:.05,type:`number`,validate:e=>e>=0&&e<=1,message:`expects a number between 0 and 1.`},preventClick:{default:!0,type:`boolean`}},Ht={validate:e=>!e||typeof e!=`object`||Array.isArray(e)?!1:(e.image==null||typeof e.image==`string`)&&(e.url==null||typeof e.url==`string`)&&(e.title==null||typeof e.title==`string`)&&(e.sort==null||typeof e.sort==`number`)&&(e.blank==null||typeof e.blank==`boolean`)&&(e.children==null||M(e.children)),message:`expects items with optional image, url, title, sort, blank and children fields.`};function Ut(e){return!!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 Wt(e,t){return O(e,t)}function Gt(e){let t=P(`.j-swiper`,e);return v(`container`,t,{validate:e=>e.length===1,message:`expects exactly one .j-swiper descendant.`},`Swiper`),t[0]}var Kt=class extends H{constructor(e,t={}){let r=y(t,Q,`Swiper.options`);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=n({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;T(`Swiper`);let e=Array.isArray(this.props.data),t=j(this.dom.container,`Swiper`),n=null,r=null;e?(r=t,n=o(`div`,{className:`j-swiper`}),r.appendChild(n)):n=Gt(t);try{this.dom.root=n,this.dom.mountTarget=r,this.dom.createdRoot=e,this.dom.createdSlides=e;let t=e?this.createDataView(n,this.props.data):N(`.swiper-wrapper`,n);v(`wrapper`,t,{validate:D,message:`expects .swiper-wrapper in the root element.`},`Swiper`),this.dom.wrapper=t,this.dom.slides=P(`.swiper-slide`,t),this.dom.pagination=N(`.swiper-pagination`,n),this.dom.prevButton=N(`.swiper-navigation.is-prev`,n),this.dom.nextButton=N(`.swiper-navigation.is-next`,n),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,t){let n=this.normalizeData(t),r=o(`div`,{className:`swiper-wrapper`,"aria-live":`polite`});return e.textContent=``,n.forEach((e,t)=>{r.appendChild(this.createDataSlide(e,t))}),e.appendChild(r),r}normalizeData(e){e.forEach((e,t)=>{v(String(t),e,Ht,`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,t){let n=o(e.url?`a`:`div`,{className:`swiper-slide`,href:e.url||void 0,target:e.url?e.blank?`_blank`:`_self`:void 0,"data-swiper-index":String(t),role:`group`,"aria-label":`Slide ${t+1}`});if(e.children!=null)return n.append(...Wt(e.children,{swiper:this,item:e,index:t})),n;if(e.image){let t=o(`img`,{className:`swiper-image`,alt:e.title||``,loading:`lazy`});this.props.lazyload?t.dataset.lazy=e.image:t.src=e.image,n.appendChild(t)}return e.title&&n.appendChild(o(`span`,{className:`swiper-slide-title`,children:e.title})),n}onInit(){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&&P(`[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.width=this.dom.root.clientWidth||this.dom.root.offsetWidth}refreshSlides(){this.dom.slides=P(`.swiper-slide`,this.dom.wrapper),this.runtime.realCount=this.dom.slides.filter(e=>!e.hasAttribute(`data-clone`)).length}initLoop(){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.style.setProperty(`--swiper-slide-width`,`${this.state.width}px`)}reInitView(){this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear(),P(`[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(){this.cleanup.events.on(`touchstart`,this.dom.wrapper,`touchstart`,e=>{e.touches[0]&&this.onStart(e.touches[0],e.target)},{passive:!0}),this.cleanup.events.on(`touchmove`,this.dom.wrapper,`touchmove`,e=>{e.touches[0]&&this.onMove(e.touches[0],e)},{passive:!1}),this.cleanup.events.on(`touchend`,this.dom.wrapper,`touchend`,e=>{e.changedTouches[0]&&this.pushLog(e.changedTouches[0]),this.onEnd()}),this.cleanup.events.on(`touchcancel`,this.dom.wrapper,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`window:touchcancel`,window,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`mousedown`,this.dom.wrapper,`mousedown`,e=>{e.button===0&&(this.onStart(e,e.target),this.dom.wrapper.style.cursor=`grabbing`)}),this.cleanup.events.on(`mousemove`,this.dom.wrapper,`mousemove`,e=>{e.buttons===1&&this.onMove(e,e)}),this.cleanup.events.on(`window:mousemove`,window,`mousemove`,e=>{this.runtime.touching&&e.buttons===1&&this.onMove(e,e)}),this.cleanup.events.on(`mouseup`,this.dom.wrapper,`mouseup`,e=>{this.dom.wrapper.style.cursor=`grab`,this.pushLog(e),this.onEnd()}),this.cleanup.events.on(`window:mouseup`,window,`mouseup`,e=>{this.runtime.touching&&(this.dom.wrapper.style.cursor=`grab`,this.pushLog(e),this.onEnd())}),this.cleanup.events.on(`wrapper:mouseleave`,this.dom.wrapper,`mouseleave`,()=>{this.dom.wrapper.style.cursor=`grab`}),this.cleanup.events.on(`click`,this.dom.wrapper,`click`,e=>{!this.runtime.clickPrevented||!this.props.preventClick||(e.preventDefault(),e.stopPropagation(),this.runtime.clickPrevented=!1)},{capture:!0}),this.cleanup.events.on(`dragstart`,this.dom.wrapper,`dragstart`,e=>e.preventDefault()),this.cleanup.events.on(`transitionend`,this.dom.wrapper,`transitionend`,e=>this.onTransitionEnd(e)),this.cleanup.events.on(`window:resize`,window,`resize`,()=>this.update(null,{force:!0})),this.cleanup.events.on(`root:mouseenter`,this.dom.root,`mouseenter`,()=>this.pause()),this.cleanup.events.on(`root:mouseleave`,this.dom.root,`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.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=Ut(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||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`),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=N(`img[data-lazy]`,t);if(!n||n.src)return;n.classList.add(`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(`loading`),n.classList.add(`loaded`),r()},n.onerror=()=>{n.classList.remove(`loading`),n.classList.add(`error`),r()}})}clearImageCleanups(){this.runtime.imageCleanups?.forEach(e=>e()),this.runtime.imageCleanups?.clear()}initPagination(){this.dom.pagination?this.dom.pagination.classList.add(`is-horizontal`,`is-clickable`,`is-bullet`):(this.dom.pagination=o(`div`,{className:`swiper-pagination is-horizontal is-clickable is-bullet`}),this.dom.root.appendChild(this.dom.pagination),this.dom.createdPagination=!0),this.dom.pagination.textContent=``,this.dom.bullets=[];for(let e=0;e<this.realCount;e++){let t=o(`button`,{type:`button`,className:`swiper-pagination-indicator swiper-pagination-bullet`,"aria-label":`Go to slide ${e+1}`});this.cleanup.events.on(`bullet:${e}:click`,t,`click`,()=>{this.slideTo(e)}),this.cleanup.events.on(`bullet:${e}:keydown`,t,`keydown`,t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),this.slideTo(e))}),this.dom.bullets.push(t),this.dom.pagination.appendChild(t)}this.cleanup.bindings=i(n=>(this.dom.bullets.forEach((n,r)=>{t(n,`is-active`,()=>this.state.index===r),e(n,`aria-current`,()=>this.state.index===r?`true`:null)}),n))}initNavigation(){this.dom.prevButton=this.ensureNavigation(`prev`,`arrow-left`),this.dom.nextButton=this.ensureNavigation(`next`,`arrow-right`),this.cleanup.events.on(`nav:prev`,this.dom.prevButton,`click`,()=>this.prev()),this.cleanup.events.on(`nav:next`,this.dom.nextButton,`click`,()=>this.next()),this.props.loop||(this.cleanup.navBindings=i(n=>(t(this.dom.prevButton,`is-disabled`,()=>this.state.trackIndex<=0),e(this.dom.prevButton,`disabled`,()=>this.state.trackIndex<=0?``:null),t(this.dom.nextButton,`is-disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1),e(this.dom.nextButton,`disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1?``:null),n)))}ensureNavigation(e,t){let n=e===`prev`?`createdPrevButton`:`createdNextButton`,r=`swiper-navigation is-${e}`,i=N(`.swiper-navigation.is-${e}`,this.dom.root);return i?i.matches(`button`)||(i.setAttribute(`role`,`button`),i.setAttribute(`tabindex`,`0`),i.classList.add(`swiper-navigation`,`is-${e}`)):(i=o(`button`,{type:`button`,className:r}),this.dom.root.appendChild(i),this.dom[n]=!0),i.setAttribute(`aria-label`,e===`prev`?`Previous slide`:`Next slide`),i.querySelector(`svg`)||(i.textContent=``,i.appendChild(z(t))),i}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=e&&typeof e==`object`&&!Array.isArray(e)?e:{},r=y(Object.assign({},this.props,n),Q,`Swiper.options`),i={};return Object.keys(n).forEach(e=>{i[e]=r[e]}),this.props=r,this.emit(`beforeUpdate`,i,{force:t}),this.onUpdate(i,{force:t}),this.emit(`afterUpdate`,i,{force:t}),this}onUpdate(e={}){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(v(`data`,e,Q.data,`Swiper.options`),!Array.isArray(e))return this.props.data=e,this.reInitView(),this;this.props.data=e;let t=this.state.index;this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear();let n=this.normalizeData(e);return this.dom.wrapper.textContent=``,n.forEach((e,t)=>{this.dom.wrapper.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}};const qt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():b():e??b()},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`},onAdd:{default:null,types:[`function`,`null`]},onRemove:{default:null,types:[`function`,`null`]}},Jt={type:`object`,validate:e=>!!e&&M(e.title)&&M(e.panel),message:`expects an object with renderable title and panel: string, Node, array, function or null.`};function Yt(e){return Array.isArray(e)?e.map(e=>({...e})):[]}var Xt=class extends H{constructor(e,t={}){T(`Tabs`);let r=j(e,`Tabs`),i=y(t,qt,`Tabs`);super(i),this.dom.container=r,this.state=n({current:{index:-1,name:null},disabled:this._parseDisabled(i.disabled),isVertical:i.direction===`left`||i.direction===`right`,draggable:!1});try{this.onInit(i)}catch(e){throw this.destroy(),e}}onInit(e){this.root=this.buildRoot(e),this.rebuildItems(),this._activate(e.active,!1),this.bindEvents(),this._initDrag()}buildRoot(e){let{id:t,direction:n}=e,r=c(`div`,{className:`tab-wrap`,children:c(`nav`,{className:`tab-list`})}),i=c(`div`,{className:`tab-panel`});return c(`div`,{className:`j-tabs is-${n}`,id:t,children:[r,i]})}rebuildItems(){let n=N(`.tab-list`,this.root),r=N(`.tab-panel`,this.root);if(!n||!r)return;n.textContent=``,r.textContent=``,this.dom.tabs=[],this.dom.panels=[];let a=document.createDocumentFragment(),o=document.createDocumentFragment();this.props.tabs.forEach(e=>{let t=c(`div`,{className:`tab-item`,"data-tab":e.name||b(),children:c(`span`,{children:O(e.title,{tabs:this,item:e})})});this.dom.tabs.push(t),this.dom.panels.push(c(`div`,{className:`panel-item`,role:`tabpanel`,children:c(`div`,{children:O(e.panel,{tabs:this,item:e})})})),a.append(t),o.append(this.dom.panels[this.dom.panels.length-1])}),n.append(a),r.append(o),this.cleanup.bindings?.(),this.cleanup.bindings=i(n=>(this.dom.tabs.forEach((n,r)=>{let i=n.dataset.tab;t(n,`is-active`,()=>this.state.current.index===r),t(n,`is-disabled`,()=>this.state.disabled.names.includes(i)),e(n,`aria-selected`,()=>this.state.current.index===r),e(n,`aria-disabled`,()=>this.state.disabled.names.includes(i))}),this.dom.panels.forEach((n,r)=>{t(n,`is-active`,()=>this.state.current.index===r),e(n,`aria-hidden`,()=>this.state.current.index!==r)}),n))}_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(Boolean):(()=>{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.tab||null}}get activeIndex(){return this.state.current.index}get disabledNames(){return this.state.disabled.names}bindEvents(){this.unbindEvents();let e=N(`.tab-list`,this.root);e&&this.cleanup.events.on(`tabClick`,e,`click`,e=>{let t=e.target.closest(`.tab-item`);if(!t)return;let n=t.dataset.tab;n&&!this.state.disabled.names.includes(n)&&this.activate(n)})}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.tab===e):-1}async _activate(e,t=!0){let n=this._getIndex(e);if(!(n<0||n>=this.dom.tabs.length||this.state.disabled.names.includes(this.dom.tabs[n]?.dataset.tab)||this.state.current.index===n)&&(a(()=>{this._syncCurrent(n)}),t&&this.props.onChange)){let e=this.dom.tabs[n],t=this.dom.panels[n];await Promise.resolve(this.props.onChange(n,e?.dataset.tab||n,e,t))}}async activate(e){this.assertActive(`activate`),await this._activate(e,!0)}render(){this.assertActive(`render`),s(this.dom.container,()=>this.root)}async add(e){this.assertActive(`add`),v(`tabConfig`,e,Jt,`Tabs.add`),e.name=e.name||b(),this.props.tabs=[...Yt(this.props.tabs),e],this.rebuildItems(),this.syncActiveNames(this.resolveActiveNames(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 t=this._getIndex(e);if(t<0||t>=this.props.tabs.length)return;let n=this.props.tabs[t].name,{onRemove:r}=this.props;this.props.tabs=this.props.tabs.filter((e,n)=>n!==t),this.state.current.index>=this.props.tabs.length?a(()=>{this._syncCurrent(this.props.tabs.length-1)}):this.state.current.index>t&&a(()=>{this._syncCurrent(this.state.current.index-1)}),this.rebuildItems(),this.bindEvents(),this._refreshDrag(),r&&await Promise.resolve(r(t,n))}disable(e){this.assertActive(`disable`);let t=typeof e==`number`?this.dom.tabs[e]?.dataset.tab:e;t&&!this.state.disabled.names.includes(t)&&a(()=>{this.state.disabled=this._createDisabledState([...this.state.disabled.names,t])})}enable(e){this.assertActive(`enable`);let t=typeof e==`number`?this.dom.tabs[e]?.dataset.tab:e;t&&a(()=>{this.state.disabled=this._createDisabledState(this.state.disabled.names.filter(e=>e!==t))})}resolveActiveNames(e){return e==null?-1:typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tab===e):0}syncActiveNames(e){a(()=>{this._syncCurrent(e)})}async reInit(e={}){this.assertActive(`reInit`),Object.assign(this.props,y(e,qt,`Tabs`)),a(()=>{this.state.disabled=this._parseDisabled(this.props.disabled)}),this.rebuildItems(),this.syncActiveNames(this.resolveActiveNames(this.props.active)),this.bindEvents(),this._refreshDrag()}get _dragContainer(){return this.root?N(`.tab-wrap`,this.root):null}get _dragInner(){return this.root?N(`.tab-list`,this.root):null}_initDrag(){let{direction:e}=this.props;if(!this._dragContainer||!this._dragInner)return;let t=e===`left`||e===`right`,n=t?this._dragInner.scrollHeight>this._dragContainer.clientHeight+5:this._dragInner.scrollWidth>this._dragContainer.clientWidth+5;if(a(()=>{this.state.isVertical=t,this.state.draggable=n}),!n){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,n=this.state.isVertical,r=0,i=0,a=0,o=!1,s=e=>n?e.touches?e.touches[0].pageY:e.pageY:e.touches?e.touches[0].pageX:e.pageX,c=o=>{this.isDragging=!0,t.classList.add(`dragging`),r=s(o),a=r,i=n?e.scrollTop:e.scrollLeft,this._velocity=0,cancelAnimationFrame(this.raf)},l=t=>{if(!this.isDragging)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(`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,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.cleanup.bindings?.(),this.cleanup.bindings=null,cancelAnimationFrame(this.raf),cancelAnimationFrame(this._resizeRaf),this.cleanup.events.off(`resize`),this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}},Zt={en:{b:`Back`,t:`Customize`,d:`Customize your UI experience.`,theme:`Theme`,radius:`Radius`,shadow:`Shadow`,font:`Font`,mode:`Mode`,gray:`Gray`,olive:`Olive`,tomato:`Tomato`,ruby:`Ruby`,pink:`Pink`,violet:`Violet`,indigo:`Indigo`,blue:`Blue`,teal:`Teal`,grass:`Grass`,mint:`Mint`,lime:`Lime`,yellow:`Yellow`,orange:`Orange`,gold:`Gold`,n:`None`,sm:`Small`,md:`Medium`,lg:`Large`,xl:`XL`,round:`Round`,light:`Light`,dark:`Dark`,auto:`Auto`},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:`金色`,n:`无`,sm:`小`,md:`中`,lg:`大`,xl:`更大`,round:`圆角`,light:`浅色`,dark:`深色`,auto:`自动`}},Qt=class{constructor(e={}){T(`Theme`),this.options={mode:`dark`,render:`dark`,theme:`indigo`,radius:`sm`,shadow:`sm`,font:`sm`,key:`jui-theme`,...e},this.languages=Zt,this._init()}_init(){this.cleanup={events:I()},this._destroyed=!1,this.mq=window.matchMedia&&window.matchMedia(`(prefers-color-scheme: dark)`),this._loadConfig(),this._applyConfig(),this._bindEvent(),this._syncActiveButtons(document)}_t(e){return f(e,this.languages)}_loadConfig(){try{let e=L(this.options.key);e&&e.trim()&&(this.options=Object.assign({},this.options,JSON.parse(e)))}catch{}}_saveConfig(){let e=this.mq&&this.mq.matches?`dark`:`light`;this.options.render=this.options.mode===`auto`?e:this.options.mode;let t=JSON.stringify(this.options);Oe(this.options.key,t)}_removePrefixedClasses(){let e=[],t=document.documentElement;for(let n of t.classList)(n===`light`||n===`dark`)&&e.push(n),(n.startsWith(`j-theme-`)||n.startsWith(`j-radius-`)||n.startsWith(`j-shadow-`)||n.startsWith(`j-font-`))&&e.push(n);e.length&&t.classList.remove(...e)}_applyMqClass(){let e=document.documentElement,{mode:t}=this.options;if(t===`auto`){let t=this.mq&&this.mq.matches?`dark`:`light`;e.classList.remove(`light`,`dark`),e.classList.add(t)}else e.classList.remove(`light`,`dark`),e.classList.add(t===`dark`?`dark`:`light`)}_applyConfig(){let{theme:e,radius:t,shadow:n,font:r}=this.options;this._removePrefixedClasses(),this._applyMqClass(),document.documentElement.classList.add(`j-theme-${e}`,`j-radius-${t}`,`j-shadow-${n}`,`j-font-${r}`)}_syncActiveButtons(e=document){let t=P(`.palette-item`,e);for(let e of t){let t=e.dataset.palette,n=this.options[t],r=P(`button[data-palette]`,e);for(let e of r){let t=e.dataset.palette===(n===void 0?null:n);e.classList.toggle(`is-active`,t)}}}_bindEvent(){this.cleanup.events.on(`palette`,document.body,`click`,e=>{let t=e.target.closest(`.palette-item .items > button[data-palette]`);if(!t)return;let n=t.closest(`.palette-item`);if(!n)return;let r=n.dataset.palette,i=t.dataset.palette;t.classList.contains(`is-active`)||(this.options[r]=i,this._applyConfig(),this._saveConfig(),this._syncActiveButtons())})}_unbindEvent(){this.cleanup?.events.clear()}createPanel(e=`j-theme-palette`,t=null){let n=t||[{title:this._t(`theme`),type:`theme`,buttons:[[`gray`,this._t(`gray`)],[`olive`,this._t(`olive`)],[`tomato`,this._t(`tomato`)],[`ruby`,this._t(`ruby`)],[`pink`,this._t(`pink`)],[`violet`,this._t(`violet`)],[`indigo`,this._t(`indigo`)],[`blue`,this._t(`blue`)],[`teal`,this._t(`teal`)],[`grass`,this._t(`grass`)],[`mint`,this._t(`mint`)],[`lime`,this._t(`lime`)],[`yellow`,this._t(`yellow`)],[`orange`,this._t(`orange`)],[`gold`,this._t(`gold`)]]},{title:this._t(`radius`),type:`radius`,buttons:[[`none`,this._t(`n`)],[`sm`,this._t(`sm`)],[`md`,this._t(`md`)],[`lg`,this._t(`lg`)],[`xl`,this._t(`xl`)],[`round`,this._t(`round`)]]},{title:this._t(`shadow`),type:`shadow`,buttons:[[`none`,this._t(`n`)],[`sm`,this._t(`sm`)],[`md`,this._t(`md`)],[`lg`,this._t(`lg`)]]},{title:this._t(`font`),type:`font`,buttons:[[`sm`,this._t(`sm`)],[`md`,this._t(`md`)]]},{title:this._t(`mode`),type:`mode`,buttons:[[`light`,this._t(`light`)],[`dark`,this._t(`dark`)],[`auto`,this._t(`auto`)]]}];return c(`div`,{className:e,children:[c(`div`,{style:{display:`flex`,justifyContent:`center`},children:c(`button`,{className:`j-button is-text`,"data-action":`close`,children:this._t(`b`)})}),c(`h3`,{children:this._t(`t`)}),c(`p`,{style:{marginTop:0,fontSize:`var(--text-sm, 0.875rem)`},children:this._t(`d`)}),c(`div`,{className:`palette-container`,children:n.map(e=>c(`div`,{className:`palette-item`,"data-palette":e.type,children:[c(`div`,{className:`item-title`,children:e.title}),c(`div`,{className:`items`,children:e.buttons.map(([t,n])=>c(`button`,{className:`j-button is-default${String(this.options[e.type])===String(t)?` is-active`:``}`,"data-palette":t,children:[e.type===`theme`?c(`span`,{className:`el-prefix item-hex`,style:{backgroundColor:`var(--ui-${t})`}}):null,c(`span`,{className:`button-text`,children:n})]}))})]}))})]})}setConfig(e){this.options=Object.assign({},this.options,e),this._applyConfig(),this._saveConfig(),this._syncActiveButtons(document)}destroy(){this._destroyed||(this._destroyed=!0,this._unbindEvent(),this.options={},this.languages={},this.cleanup=null,this.mq=null)}};const $t={type:`string`,enum:[`info`,`success`,`warning`,`error`,`primary`]},en={type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},tn={type:`number`,validate:e=>e>0,message:`expects a number greater than 0.`};var nn=class e{static show(t=``,n=3e3,r=`info`){T(`Toast`),v(`message`,t,`string`,`Toast.show`),v(`duration`,n,en,`Toast.show`),v(`type`,r,$t,`Toast.show`);let i=N(`.j-toast-container`);i||(i=c(`div`,{className:`j-toast-container`}),document.body.appendChild(i));let a=b(),o=c(`div`,{className:`j-toast is-${r}`,"data-toast":a,children:[c(`span`,{className:`toast-icon`,children:z(r===`primary`?`info`:r)}),c(`span`,{className:`toast-message`,children:t})]});i.appendChild(o),e._setTimer(a,`show`,()=>{o.classList.add(`toast-show`)},10),n>0&&e._setTimer(a,`hide`,()=>{e.hide(o)},n);let s=F(o,`click`,()=>{e.hide(o)});return e.disposers.set(o,s),o}static success(t=``,n=3e3){return e.show(t,n,`success`)}static info(t=``,n=3e3){return e.show(t,n,`info`)}static primary(t=``,n=3e3){return e.show(t,n,`primary`)}static warning(t=``,n=3e3){return e.show(t,n,`warning`)}static error(t=``,n=3e3){return e.show(t,n,`error`)}static hide(t){if(t){e.disposers.get(t)?.(),e.disposers.delete(t),t.classList.remove(`toast-show`),t.classList.add(`toast-hide`);let n=t.dataset.toast;e._setTimer(n,`remove`,()=>{t.parentNode&&t.parentNode.removeChild(t);let e=N(`.j-toast-container`);e&&e.children.length===0&&e.parentNode.removeChild(e)},300)}}static lite(t=``,n=2e3){T(`Toast`),v(`message`,t,`string`,`Toast.lite`),v(`duration`,n,tn,`Toast.lite`);let r=N(`.j-toast-lite`);r&&r.remove();let i=b(),a=c(`div`,{className:`j-toast-lite`,"data-toast":i,children:t});return document.body.appendChild(a),e._setTimer(i,`show`,()=>a.classList.add(`is-shown`),10),e._setTimer(i,`hide`,()=>{a.classList.remove(`is-shown`),a.classList.add(`is-hidden`),e._setTimer(i,`remove`,()=>a.remove(),300)},n),a}static _setTimer(t,n,r,i){let a=`${t}-${n}`;return e.timers.add(a),h.start(a,i,()=>{e.timers.delete(a),r()}),a}static clearAll(){for(let t of e.timers)h.cancel(t);e.timers.clear();for(let t of e.disposers.values())t();e.disposers.clear(),N(`.j-toast-container`)?.remove(),N(`.j-toast-lite`)?.remove()}static destroyAll(){e.clearAll()}};V(nn,`timers`,new Set),V(nn,`disposers`,new Map);const rn={name:{default:null,types:[`string`,`null`]},mode:{default:`hover`,type:`string`},position:{default:`auto`,type:`string`},offset:{default:8,type:`number`},message:{default:``,type:`string`,normalize:e=>String(e||``).trim(),validate:e=>e.length>0,message:`expects a non-empty string.`},className:{default:null,types:[`string`,`null`]},id:{default:null,types:[`string`,`null`]},delay:{default:100,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`}};var an=class{constructor(e,t={}){let n=y(t,rn,`Tooltip.props`);this.drop=new Ge(e,{...n,content:this._buildContent(n)})}_buildContent(e){return c(`div`,{className:e.className?`j-tooltip ${e.className}`:`j-tooltip`,children:c(`div`,{className:`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&&(this.drop.destroy(),this.drop=null)}};const on={rules:{default:{},type:`object`},messages:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]}};var sn=class{constructor(e,t={},n=!1){T(`Validator`),this.options=y(t,on,`Validator.options`),this._validateOptions(e,this.options,n),this._init(e),n&&this._bindEvents()}_validateOptions(e,t,n){v(`bindEvents`,n,`boolean`,`Validator`)}_init(e){this.root=A(e,`Validator.element`),this.runtime={valid:!0,message:``,destroyed:!1},this.cleanup={events:I()}}_bindEvents(){this._unbindEvents(),this.cleanup.events.on(`submit`,this.root,`submit`,e=>{e.preventDefault(),this.runtime.validate()}),this.cleanup.events.on(`reset`,this.root,`reset`,()=>{this.reset()})}_unbindEvents(){this.cleanup?.events.clear()}validate(){this.runtime.valid=!0,this.runtime.message=``;for(let e of this.root.elements){let t=e.name;if(this.options.rules[t]&&(this.runtime.valid=this._validateRule(e,t),!this.runtime.valid))break}return this.runtime.valid&&this.options.onSubmit&&this.options.onSubmit(),this.runtime.valid}_validateRule(e,t){let n=this.options.rules[t];if(e.hasAttribute(`required`)||e.hasAttribute(`minlength`)||e.hasAttribute(`maxlength`)||e.hasAttribute(`pattern`)||e.hasAttribute(`min`)||e.hasAttribute(`max`)||e.hasAttribute(`step`))return this.runtime.valid;for(let r in n){switch(r){case`required`:this.runtime.valid=this._validateRequired(e,n[r]);break;case`minLength`:this.runtime.valid=this._validateMinLength(e,n[r]);break;case`maxLength`:this.runtime.valid=this._validateMaxLength(e,n[r]);break;case`equalTo`:this.runtime.valid=this._validateEqualTo(e,n[r]);break;case`email`:this.runtime.valid=this._validateEmail(e);break;case`checked`:this.runtime.valid=this._validateCheck(e,n[r]);break;case`selected`:this.runtime.valid=this._validateSelected(e,n[r]);break;case`multiple`:this.runtime.valid=this._validateMultiple(e,n[r]);break;case`min`:this.runtime.valid=this._validateSelectMin(e,n[r]);break;case`max`:this.runtime.valid=this._validateSelectMax(e,n[r]);break;case`noSpace`:this.runtime.valid=this._validateNoSpace(e,n[r]);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=new RegExp(n[r]).test(e.value);break;case`file`:this.runtime.valid=this._validateFile(e,n[r]);break;case`minSize`:this.runtime.valid=this._validateMinSize(e,n[r]);break;case`maxSize`:this.runtime.valid=this._validateMaxSize(e,n[r]);break;case`accept`:this.runtime.valid=this._validateAccept(e,n[r]);break;case`validate`:this.runtime.valid=this._validateCustom(e,n[r]);break}if(this.runtime.valid)this._success(e);else{this._errorMsg(e,t,r);break}}return this.runtime.valid}_validateRequired(e,t){return e.value.trim().length>=1&&t===!0}_validateMinLength(e,t){return e.value.length>=t}_validateMaxLength(e,t){return e.value.length<=t}_validateEmail(e){return/^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(e.value)}_validateEqualTo(e,t){let n=this.root.elements[t];if(n==null)throw Error(`Validator: target element "${t}" not found.`);return e.value===n.value}_validateCheck(e,t){if(e.type!==`checkbox`)throw Error(`Validator: element expects a checkbox input, but ${e.type} given.`);return e.checked===t}_validateSelected(e,t){if(e.tagName!==`SELECT`)throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t===!0?Array.from(e.selectedOptions).map(e=>e.value.trim()).some(e=>e.length>0):!0}_validateMultiple(e,t){if(e.tagName!==`SELECT`)throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t===!0?e.selectedOptions.length>0:!0}_validateSelectMin(e,t){return e.tagName===`SELECT`?e.selectedOptions.length>=t:!0}_validateSelectMax(e,t){return e.tagName===`SELECT`?e.selectedOptions.length<=t:!0}_validateNoSpace(e,t){return!/\s/.test(e.value)||t!==!0}_validateFile(e,t){return e.type===`file`&&t===!0?e.files.length>0:!0}_validateMinSize(e,t){return e.type!==`file`||!e.files.length?!0:e.files[0].size>=t}_validateMaxSize(e,t){return e.type!==`file`||!e.files.length?!0:e.files[0].size<=t}_validateAccept(e,t){if(e.type!==`file`||!e.files.length)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);return typeof n==`string`?!1:!!n}_errorMsg(e,t,n){e.type!==`checkbox`&&(e.classList.remove(`is-valid`),e.classList.add(`is-invalid`));let r=this.options.messages[t]&&this.options.messages[t][n];if(r){this.runtime.message=r;let t=e.closest(`.form-control`),n=t?N(`.help-block`,t):null;n||(n=c(`div`,{className:`help-block is-invalid`,children:r}),t.appendChild(n))}}_success(e){let t=e.closest(`.form-control`),n=t?N(`.help-block`,t):null;n&&t.removeChild(n),e.type!==`checkbox`&&(e.classList.remove(`is-invalid`),e.classList.add(`is-valid`))}reset(){this.root.reset();for(let e of this.root.elements)e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`);let e=P(`.help-block`,this.root);for(let t of e)t.remove();this.runtime.valid=!0,this.runtime.message=``}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this._unbindEvents(),this.reset(),this.root=null,this.options=null,this.runtime.valid=null,this.runtime.message=null,this.cleanup?.events.clear(),this.cleanup=null)}};export{Ue as Accordion,H as Component,Ge as Drop,rt as Flow,st as Menu,wt as Modal,Et as Offcanvas,kt as Parabola,Ft as Sticky,Kt as Swiper,Xt as Tabs,Qt as Theme,nn as Toast,Bt as Toc,an as Tooltip,sn as Validator,Fe as addIcons,P as all,w as canRenderDOM,C as canUseDOM,ee as copy,I as createEventManager,it as createFlow,It as createSticky,Vt as createToc,pe as destroyAll,L as getCookie,Pe as getRegistedIconPath,ne as getType,m as hasOwn,z as icon,Me as iconHtml,Ne as iconMarkup,ie as isClass,D as isElement,re as isFunction,p as isMobile,E as isNode,g as isPlainObject,M as isRenderableContent,F as listen,O as normalizeContentNodes,Ee as postJson,N as q,b as randomId,fe as release,ke as removeCookie,j as requireContainer,T as requireRenderDOM,ye as resolveContainer,A as resolveElement,ve as resolveNode,k as resolveNodeList,y as resolveProps,De as restUrl,me as service,Oe as setCookie,ue as singleton,h as timer,Te as unlisten,le as uuid,v as validateParam};
1
+ import{bindAttr as e,bindClass as t,createDeepStore as n,createEffect as r,createRoot as i,flushSync as a,h as o,insert as s,jsx as c,onCleanup as l,render as u,untrack as d}from"vanilla-signal";import{t as f}from"vanilla-signal-i18n";function p(){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),r=`maxTouchPoints`in navigator?navigator.maxTouchPoints>0:`ontouchstart`in window,i=Math.min(window.screen.width,window.screen.height)<=768;if(t&&!n){if(/iPhone|iPod|Windows Phone|webOS|BlackBerry|IEMobile|Opera Mini/i.test(e))return!0;if(/Android/i.test(e))return i||r}return/Macintosh|MacIntel/i.test(e)&&r&&i}async function m(e){if(typeof window>`u`||typeof document>`u`)return Promise.resolve(!1);let t=typeof e==`string`?e:String(e);return navigator.clipboard&&typeof navigator.clipboard.writeText==`function`?navigator.clipboard.writeText(t).then(()=>!0).catch(()=>h(t)):Promise.resolve(h(t))}function h(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)}}const g=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),_={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])}},ee=e=>e===null?`null`:Array.isArray(e)?`array`:typeof HTMLElement<`u`&&e instanceof HTMLElement?`HTMLElement`:typeof Node<`u`&&e instanceof Node?`Node`:typeof e,v=e=>typeof e==`function`&&e.prototype!==null&&e.prototype.constructor===e,y=e=>typeof e==`function`&&/^class\s/.test(Function.prototype.toString.call(e));function b(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function te(e){return Array.isArray(e)?e.slice():b(e)?{...e}:e}function x(e={}){return typeof e==`string`||Array.isArray(e)?{type:e}:!e||typeof e!=`object`?{}:e}function S(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 ne(e,t){return e?`${e}.${t}`:t}function re(e){if(g(e,`default`))return te(e.factory&&typeof e.default==`function`?e.default():e.default)}function C(e,t,n={},r=``){let i=x(n),a=ne(r,e),o=g(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=ee(t);if(!e.some(e=>e===n)){let t=e.join(`, `);throw Error(`Validator: ${a} expects ${t}, but got ${n}.`)}S(a,t,i.conditions)}else S(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 w(e={},t={},n=`Options`){let r=e??{};if(typeof r!=`object`||Array.isArray(r))throw Error(`${n} expects object.`);let i={...r},a=Object.entries(t||{});for(let[e,t]of a){let n=x(t);i[e]=g(r,e)?r[e]:re(n)}for(let[e,n]of a){let a=x(n);typeof a.normalize==`function`&&(i[e]=a.normalize(i[e],{key:e,input:r,options:i,schema:t}))}for(let[e,r]of Object.entries(t||{}))C(e,i[e],r,n);return i}function ie(){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 T(e=8){if(!Number.isInteger(e)||e<1||e>32)throw Error(`Length must be an integer between 1 and 32`);let t=new Uint8Array(e);crypto.getRandomValues(t);let n=``;for(let r=0;r<e;r++)n+=`abcdefghijkmnpqrstuvwxyz23456789`[t[r]&31];return n}function ae(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=g(i,`trailing`)?!!i.trailing:!0,s=g(i,`maxWait`),c=s?Math.max(Number(i.maxWait)||0,r):0,l,u,d,f,p,m=0;function h(t){let n=l,r=u;return l=void 0,u=void 0,m=t,d=e.apply(r,n),d}function _(e){return m=e,f=setTimeout(y,r),a?h(e):d}function ee(e){let t=e-p,n=e-m,i=r-t;return s?Math.min(i,c-n):i}function v(e){let t=e-p,n=e-m;return p===void 0||t>=r||t<0||s&&n>=c}function y(){let e=Date.now();if(v(e))return b(e);f=setTimeout(y,ee(e))}function b(e){return f=void 0,o&&l?h(e):(l=void 0,u=void 0,d)}function te(){f!==void 0&&clearTimeout(f),m=0,p=void 0,f=void 0,l=void 0,u=void 0}function x(){return f===void 0?d:b(Date.now())}function S(...e){let t=Date.now(),n=v(t);if(l=e,u=this,p=t,n){if(f===void 0)return _(p);if(s)return f=setTimeout(y,r),h(p)}return f===void 0&&(f=setTimeout(y,r)),d}return S.cancel=te,S.flush=x,S}function oe(e,t=0,n={}){if(typeof e!=`function`)throw TypeError(`Expected a function`);let r=n&&typeof n==`object`?n:{};return ae(e,t,{leading:g(r,`leading`)?!!r.leading:!0,trailing:g(r,`trailing`)?!!r.trailing:!0,maxWait:t})}const E=new Map,D=new Map,se=(e,t=[],n=``,r=!1,i=null)=>{if(!v(e))throw Error(`First argument expects a class/constructor function.`);if(!Array.isArray(t))throw Error(`Second argument must be an array of arguments.`);if(typeof n!=`string`)throw Error(`Third argument expects a string.`);if(typeof r!=`boolean`)throw Error(`Fourth argument expects a boolean.`);if(typeof i!=`number`&&i!==null)throw Error(`Fifth argument expects a number or null.`);let a=n.trim()===``?T():n;if(E.has(a)&&!r)return E.get(a).proxy;let o=new e(...t),s=new Proxy(o,{get(e,t,n){return i&&ce(a,i),Reflect.get(e,t,n)},set(e,t,n,r){return Reflect.set(e,t,n,r)}});return E.set(a,{instance:o,proxy:s}),s};function ce(e,t){D.has(e)&&clearTimeout(D.get(e));let n=setTimeout(()=>{le(e)},t);D.set(e,n)}function le(e){if(E.has(e)){let{instance:t}=E.get(e);if(typeof t.destroy==`function`)try{t.destroy()}catch{throw Error(`release(): destroy() failed on instance with key "${e}".`)}E.delete(e)}D.has(e)&&(clearTimeout(D.get(e)),D.delete(e))}function ue(){for(let{instance:e}of E.values())if(typeof e.destroy==`function`)try{e.destroy()}catch{}E.clear();for(let e of D.values())clearTimeout(e);D.clear()}const de={instances:new Map,get(e,t){return this.instances.has(e)||this.instances.set(e,t()),this.instances.get(e)},destroy(e){if(this.instances.has(e)){let t=this.instances.get(e);t.destroy&&t.destroy(),this.instances.delete(e)}},destroyAll(){for(let e of this.instances.values())e.destroy&&e.destroy();this.instances.clear()}};function O(){return typeof document<`u`}function fe(){return!O()||typeof document.createElement!=`function`?!1:typeof document.createElement(`div`).insertBefore==`function`}function k(e=`Component`){if(!fe())throw Error(`${e}: DOM render environment is required.`);return!0}function A(e){return O()&&typeof Node<`u`&&e instanceof Node}function j(e){return O()&&typeof Element<`u`&&e instanceof Element}function pe(e){return typeof e==`string`||j(e)||A(e)||Array.isArray(e)}function me(e){return e.find(j)||null}function he(e,t=[]){for(let n of e){if(Array.isArray(n)){if(!he(n,t))return null;continue}if(A(n)){t.push(n);continue}return null}return t}function M(e,t){let n=typeof e==`function`?e(t):e;if(n==null||n===!1||n===!0)return[];if(Array.isArray(n))return n.flatMap(e=>M(e,t));if(A(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 N(e,t=`Component`){if(e===!1||e==null)return null;if(typeof e==`string`){if(!O())return null;let t=Array.from(document.querySelectorAll(e));return t.length>0?t:null}if(Array.isArray(e)){let t=he(e,[]);return t&&t.length>0?t:null}return A(e)?[e]:null}function ge(e,t=`Component`){return j(e)||A(e)?e:typeof e==`string`?O()?document.querySelector(e):null:Array.isArray(e)&&(N(e,t)||[])[0]||null}function P(e,t=`Component`){if(!pe(e)||e===!1||e==null)return null;if(typeof e==`string`){if(!O())return null;let t=document.querySelector(e);return j(t)?t:null}if(Array.isArray(e)){let n=N(e,t);return Array.isArray(n)?me(n):null}return j(e)?e:null}function _e(e,t=`Component`,n=`element`){if(![`node`,`element`,`array`].includes(n))throw Error(`${t}: expect must be one of 'node', 'element', 'array'.`);return pe(e)?n===`array`?N(e,t):n===`node`?ge(e,t):P(e,t):null}function F(e,t=`Component`,n=`element`){let r=_e(e,t,n);if(r==null)throw Error(`${t}: container not found.`);return r}function I(e){return e==null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`||typeof e==`function`||Array.isArray(e)||A(e)}function L(e=`j-loading is-active`){return c(`div`,{className:e,"aria-live":`polite`,children:c(`div`,{className:`loading-spinner`})})}function R(e,t=document){return t.querySelector(e)}function z(e,t=document){return Array.from(t.querySelectorAll(e))}const ve=()=>{};function B(e,t,n,r){let i=!0;return e.addEventListener(t,n,r),()=>{i&&(i=!1,e.removeEventListener(t,n,r))}}function V(){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 ve;let s=B(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 ye(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:n.method||`POST`,headers:r,body:JSON.stringify(t)})).json()}const be=typeof window<`u`?`${window.location.origin}/wp-json`:``;function H(e){if(typeof document>`u`)return null;let t=`; ${document.cookie}`.split(`; ${e}=`);return t.length===2?t.pop().split(`;`).shift():null}function xe(e,t,n=3600*24){if(typeof document>`u`)return!1;let r=new Date(Date.now()+n*1e3).toUTCString();return document.cookie=[`${e}=${t}`,`expires=${r}`,`path=/`,`sameSite=strict`].join(`; `),H(e)===t}function Se(e){return typeof document>`u`?!0:(document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`,!H(e))}const U={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>`};function Ce(e){if(!(e in U))throw Error(`Icon "${e}" not found.`)}function we(e){return Ce(e),`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" focusable="false">${U[e]}</svg>`}function W(e,t={}){k(`icon()`);let n=document.createElement(`template`);n.innerHTML=we(e);let r=n.content.firstElementChild;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 Te(e){return we(e)}const Ee=Te;function De(){return{...U}}function Oe(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}".`);U[t]=n}}function G(e){"@babel/helpers - typeof";return G=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},G(e)}function ke(e,t){if(G(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(G(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Ae(e){var t=ke(e,`string`);return G(t)==`symbol`?t:t+``}function je(e,t,n){return(t=Ae(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var K=class e{constructor(e={}){this.props=e||{},this.dom={root:null},this.plugins=new Map,this.cleanup={events:V(),plugins:new Map},this._listeners={init:[],beforeUpdate:[],afterUpdate:[],destroy:[]},this.state=n({}),this.runtime={destroyed:!1},this.installGlobalPlugins()}get root(){return this.dom?.root||null}set root(e){this.dom||(this.dom={}),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 e&&typeof e==`object`&&!Array.isArray(e)&&(this.props=Object.assign({},this.props,e)),typeof this.onInit==`function`&&this.onInit(this.props),this.emit(`init`,this.props),this}setState(e={},t){if(this.runtime.destroyed)throw Error(`Component.setState: instance destroyed`);let n=typeof e==`string`&&arguments.length>1?{[e]:t}:e;if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Component.setState: expects a plain object patch.`);return a(()=>{for(let[e,t]of Object.entries(n))this.state[e]=t}),this}update(e={},{force:t=!1}={}){if(this.runtime.destroyed)throw Error(`Component.update: instance destroyed`);return e&&typeof e==`object`&&(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}}};je(K,`globalPlugins`,new Map);const Me={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():T():e??T()},active:{default:0,types:[`number`,`string`,`array`,`null`]},collapsible:{default:!1,type:`boolean`},multiple:{default:!1,type:`boolean`},onChange:{default:null,types:[`function`,`null`]},items:{default:[],type:`array`}},Ne={type:`array`,validate:e=>e.length>0,message:`expects a non-empty array.`},Pe={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:e.trim().length>0,message:`expects a positive number, string, array or null.`};function Fe(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function Ie(e){return C(`items`,e,Ne,`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(!I(e.title))throw Error(`Accordion: item title expects string, Node, array, function or null.`);if(!I(e.content))throw Error(`Accordion: item content expects string, Node, array, function or null.`);return{...e,name:e.name||T()}})}var Le=class extends K{constructor(e,t={}){k(`Accordion`);let r=F(e,`Accordion`),i=w(t,Me,`Accordion`);super(i),this.dom.container=r,this.dom.headers=[],this.dom.panels=[],this.state=n({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 c(`div`,{className:`j-accordion`,id:e.id})}buildItems(n){let r=Ie(n.items),a=document.createDocumentFragment();this.dom.headers=[],this.dom.panels=[],r.forEach((e,t)=>{let r=e.name||T(),i=`${n.id}_header_${t}`,o=`${n.id}_panel_${t}`,s=c(`div`,{className:`accordion-header`,"data-item":r,id:i,role:`button`,tabindex:`0`,"aria-controls":o,children:[c(`span`,{className:`header-title`,children:this.contentView(e.title,e,t,`title`)}),c(`span`,{className:`header-arrow`,"aria-hidden":`true`,children:W(`arrow-down`)})]}),l=c(`div`,{className:`accordion-panel`,id:o,role:`region`,"aria-labelledby":i,children:c(`div`,{className:`panel-content`,children:this.contentView(e.content,e,t,`content`)})});this.dom.headers.push(s),this.dom.panels.push(l),a.append(s,l)}),this.root.append(a),this.cleanup.bindings?.(),this.cleanup.bindings=i(n=>(this.dom.headers.forEach(n=>{let r=n.dataset.item;t(n,`is-active`,()=>this.state.activeNames.includes(r)),e(n,`aria-expanded`,()=>this.state.activeNames.includes(r))}),this.dom.panels.forEach((n,r)=>{let i=this.dom.headers[r]?.dataset.item;t(n,`is-active`,()=>this.state.activeNames.includes(i)),e(n,`aria-hidden`,()=>this.state.activeNames.includes(i)?`false`:`true`),e(n,`hidden`,()=>!this.state.activeNames.includes(i))}),n))}contentView(e,t,n,r){return M(e,{accordion:this,item:t,index:n,type:r,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.item||String(t)),!this.props.multiple))break}return Array.from(new Set(n))}syncActiveNames(e){let t=e[0]||null,n=t?this.getIndex(t):null;a(()=>{this.state.activeNames=e,this.state.current={index:n,name:t}})}bindEvents(){this.unbindEvents(),this.cleanup.events.on(`click`,this.root,`click`,e=>{let t=e.target.closest(`.accordion-header`);t&&this.active(t.dataset.item)}),this.cleanup.events.on(`keydown`,this.root,`keydown`,e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=e.target.closest(`.accordion-header`);t&&(e.preventDefault(),this.active(t.dataset.item))})}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.item||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.item===e):-1}async active(e){this.assertActive(`active`),await this.activateItem(e,!0)}build(){this.assertActive(`build`),s(this.dom.container,()=>this.root)}setItems(e,t=0){this.assertActive(`setItems`),C(`items`,e,Ne,`Accordion.setItems`),C(`active`,t,Pe,`Accordion.setItems`),this.props.items=Fe(Ie(e)),this.props.active=t,this.root.textContent=``,this.buildItems(this.props),this.syncActiveNames(this.resolveActiveNames(t)),this.bindEvents()}onDestroy(){this.unbindEvents(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function Re(e,t={}){return new Le(e,t)}const ze={content:{default:``,validate:I,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`,`push`,`none`]},bgClose:{default:!0,type:`boolean`},escClose:{default:!0,type:`boolean`},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():T():e??T()},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 Be(e){return typeof e==`number`&&e>0?e:0}var Ve=class extends K{constructor(e={}){k(`Offcanvas`);let t=w(e,ze,`Offcanvas`);super(t),this._overlay=null,this.runtime.cache={content:null,hasContent:!1,updatedAt:0},this.runtime.contentLoadId=0,this.state=n({visible:!1,loading:!1}),this.onInit(t)}onInit(e){e.overlay&&(this._overlay=this._buildOverlay(e)),this.root=this._buildRoot(e)}_buildOverlay(e){return c(`div`,{className:`j-offcanvas-overlay`,style:e.filter?{backdropFilter:`blur(2px)`}:{}})}_buildRoot(e){let t=c(`div`,{className:`offcanvas-content`});return this.dom.content=t,typeof e.content!=`function`&&t.append(...M(e.content,this)),c(`div`,{className:`j-offcanvas is-${e.direction} is-${e.animation}`,id:e.id,children:t})}_isCacheValid(){if(!this.props.cache||!this.runtime.cache.hasContent)return!1;let e=Be(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(...M(e,this)))}async _loadContent(){let{content:e,cache:t}=this.props;if(typeof e!=`function`){this.runtime.contentLoadId+=1,a(()=>{this.state.loading=!1});return}if(this._isCacheValid()){this.runtime.contentLoadId+=1,this._renderContent(this.runtime.cache.content),a(()=>{this.state.loading=!1});return}let n=++this.runtime.contentLoadId;a(()=>{this.state.loading=!0}),this.dom.content.textContent=``,this.dom.content.appendChild(L());try{let r=await Promise.resolve(e(this));if(this.runtime.destroyed||n!==this.runtime.contentLoadId)return;t&&(this.runtime.cache.content=r,this.runtime.cache.hasContent=!0,this.runtime.cache.updatedAt=Date.now()),this._renderContent(r)}finally{!this.runtime.destroyed&&n===this.runtime.contentLoadId&&a(()=>{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.key===`Escape`&&this.state.visible&&this.hide()}),this.cleanup.events.on(`close`,this.root,`click`,e=>{let t=e.target.dataset.action;(t===`close`||t===`cancel`)&&this.hide()})}unbindEvents(){this.cleanup?.events.clear()}_render(){let{overlay:e,animation:t,direction:n,id:r}=this.props,i=document.body;e&&i.appendChild(this._overlay),i.appendChild(this.root),i.style.overflow=`hidden`,t===`push`&&i.classList.add(`offcanvas-push-body`),_.start(`oc-show-${r}`,10,()=>{this.root&&(this._overlay&&this._overlay.classList.add(`is-active`),t===`push`&&i.classList.add(`offcanvas-push-${n}`),this.root.classList.add(`is-active`))})}_remove(){let{animation:e,direction:t,id:n}=this.props,r=document.body;this._overlay&&this._overlay.classList.remove(`is-active`),this.root.classList.remove(`is-active`),e===`push`&&r.classList.remove(`offcanvas-push-${t}`),_.start(`oc-remove-${n}`,100,()=>{this._overlay?.parentNode?.removeChild(this._overlay),this.root?.parentNode?.removeChild(this.root),e===`push`&&r.classList.remove(`offcanvas-push-body`),r.style.overflow=``})}async show(){if(this.runtime.destroyed||this.state.visible)return;let{onShow:e,onShown:t,id:n}=this.props;e&&await Promise.resolve(e()),this._render(),this._bindEvents(),a(()=>{this.state.visible=!0}),await this._loadContent(),_.start(`oc-shown-${n}`,300,()=>{this.runtime.destroyed||t&&t()})}async hide(){if(this.runtime.destroyed||!this.state.visible)return;let{onHide:e,onHidden:t}=this.props;e&&await Promise.resolve(e()),this.runtime.contentLoadId+=1,a(()=>{this.state.loading=!1}),this.unbindEvents(),this._remove(),a(()=>{this.state.visible=!1}),t&&t()}onDestroy(){let{id:e}=this.props;_.cancel(`oc-show-${e}`),_.cancel(`oc-remove-${e}`),_.cancel(`oc-shown-${e}`),this.state.visible&&this.unbindEvents(),this.root?.classList.remove(`is-active`),this.root?.parentNode?.removeChild(this.root),this._overlay?.parentNode?.removeChild(this._overlay);let t=document.body;t.style.overflow=``,t.classList.remove(`offcanvas-push-body`,`offcanvas-push-${this.props.direction}`),this._overlay=null}};function He(e={}){return new Ve(e)}const Ue={rules:{default:{},type:`object`},messages:{default:{},type:`object`},onSubmit:{default:null,types:[`function`,`null`]}};var We=class{constructor(e,t={},n=!1){k(`Validator`),this.options=w(t,Ue,`Validator.options`),this._validateOptions(e,this.options,n),this._init(e),n&&this._bindEvents()}_validateOptions(e,t,n){C(`bindEvents`,n,`boolean`,`Validator`)}_init(e){this.root=P(e,`Validator.element`),this.runtime={valid:!0,message:``,destroyed:!1},this.cleanup={events:V()}}_bindEvents(){this._unbindEvents(),this.cleanup.events.on(`submit`,this.root,`submit`,e=>{e.preventDefault(),this.validate()}),this.cleanup.events.on(`reset`,this.root,`reset`,()=>{this.reset()})}_unbindEvents(){this.cleanup?.events.clear()}validate(){this.runtime.valid=!0,this.runtime.message=``;for(let e of this.root.elements){let t=e.name;if(this.options.rules[t]&&(this.runtime.valid=this._validateRule(e,t),!this.runtime.valid))break}return this.runtime.valid&&this.options.onSubmit&&this.options.onSubmit(),this.runtime.valid}_validateRule(e,t){let n=this.options.rules[t];if(e.hasAttribute(`required`)||e.hasAttribute(`minlength`)||e.hasAttribute(`maxlength`)||e.hasAttribute(`pattern`)||e.hasAttribute(`min`)||e.hasAttribute(`max`)||e.hasAttribute(`step`))return this.runtime.valid;for(let r in n){switch(r){case`required`:this.runtime.valid=this._validateRequired(e,n[r]);break;case`minLength`:this.runtime.valid=this._validateMinLength(e,n[r]);break;case`maxLength`:this.runtime.valid=this._validateMaxLength(e,n[r]);break;case`equalTo`:this.runtime.valid=this._validateEqualTo(e,n[r]);break;case`email`:this.runtime.valid=this._validateEmail(e);break;case`checked`:this.runtime.valid=this._validateCheck(e,n[r]);break;case`selected`:this.runtime.valid=this._validateSelected(e,n[r]);break;case`multiple`:this.runtime.valid=this._validateMultiple(e,n[r]);break;case`min`:this.runtime.valid=this._validateSelectMin(e,n[r]);break;case`max`:this.runtime.valid=this._validateSelectMax(e,n[r]);break;case`noSpace`:this.runtime.valid=this._validateNoSpace(e,n[r]);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=new RegExp(n[r]).test(e.value);break;case`file`:this.runtime.valid=this._validateFile(e,n[r]);break;case`minSize`:this.runtime.valid=this._validateMinSize(e,n[r]);break;case`maxSize`:this.runtime.valid=this._validateMaxSize(e,n[r]);break;case`accept`:this.runtime.valid=this._validateAccept(e,n[r]);break;case`validate`:this.runtime.valid=this._validateCustom(e,n[r]);break}if(this.runtime.valid)this._success(e);else{this._errorMsg(e,t,r);break}}return this.runtime.valid}_validateRequired(e,t){return e.value.trim().length>=1&&t===!0}_validateMinLength(e,t){return e.value.length>=t}_validateMaxLength(e,t){return e.value.length<=t}_validateEmail(e){return/^([\w-.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(e.value)}_validateEqualTo(e,t){let n=this.root.elements[t];if(n==null)throw Error(`Validator: target element "${t}" not found.`);return e.value===n.value}_validateCheck(e,t){if(e.type!==`checkbox`)throw Error(`Validator: element expects a checkbox input, but ${e.type} given.`);return e.checked===t}_validateSelected(e,t){if(e.tagName!==`SELECT`)throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t===!0?Array.from(e.selectedOptions).map(e=>e.value.trim()).some(e=>e.length>0):!0}_validateMultiple(e,t){if(e.tagName!==`SELECT`)throw Error(`Validator: element expects a select element, but ${e.tagName.toLowerCase()} given.`);return t===!0?e.selectedOptions.length>0:!0}_validateSelectMin(e,t){return e.tagName===`SELECT`?e.selectedOptions.length>=t:!0}_validateSelectMax(e,t){return e.tagName===`SELECT`?e.selectedOptions.length<=t:!0}_validateNoSpace(e,t){return!/\s/.test(e.value)||t!==!0}_validateFile(e,t){return e.type===`file`&&t===!0?e.files.length>0:!0}_validateMinSize(e,t){return e.type!==`file`||!e.files.length?!0:e.files[0].size>=t}_validateMaxSize(e,t){return e.type!==`file`||!e.files.length?!0:e.files[0].size<=t}_validateAccept(e,t){if(e.type!==`file`||!e.files.length)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);return typeof n==`string`?!1:!!n}_errorMsg(e,t,n){e.type!==`checkbox`&&(e.classList.remove(`is-valid`),e.classList.add(`is-invalid`));let r=this.options.messages[t]&&this.options.messages[t][n];if(r){this.runtime.message=r;let t=e.closest(`.form-control`),n=t?R(`.help-block`,t):null;n||(n=c(`div`,{className:`help-block is-invalid`,children:r}),t.appendChild(n))}}_success(e){let t=e.closest(`.form-control`),n=t?R(`.help-block`,t):null;n&&t.removeChild(n),e.type!==`checkbox`&&(e.classList.remove(`is-invalid`),e.classList.add(`is-valid`))}reset(){this.root.reset();for(let e of this.root.elements)e.classList.remove(`is-valid`),e.classList.remove(`is-invalid`);let e=z(`.help-block`,this.root);for(let t of e)t.remove();this.runtime.valid=!0,this.runtime.message=``}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this._unbindEvents(),this.reset(),this.root=null,this.options=null,this.runtime.valid=null,this.runtime.message=null,this.cleanup?.events.clear(),this.cleanup=null)}};function Ge(e,t={},n=!1){return new We(e,t,n)}const Ke={type:`object`,required:!0,validate:e=>Number.isInteger(e.size)&&e.size>0&&Number.isInteger(e.current)&&e.current>0,message:`expects { size, current } with positive integers.`},qe={type:`object`,required:!0,validate:e=>Number.isInteger(e.sibling)&&e.sibling>=0&&Number.isInteger(e.boundary)&&e.boundary>=0,message:`expects { sibling, boundary } with integers greater than or equal 0.`},Je={total:{default:0,type:`number`,validate:e=>Number.isFinite(e)&&e>=0,message:`expects a non-negative finite number.`},page:{default:()=>({size:10,current:1}),factory:!0,...Ke},count:{default:()=>({sibling:1,boundary:1}),factory:!0,...qe},lock:{default:!0,type:`boolean`},onChange:{default:null,types:[`function`,`null`]}};function Ye(e,t,n){return Math.min(Math.max(e,t),n)}function Xe(e={}){let t=w(e,Je,`Pagination.props`);return{...t,page:{...t.page},count:{...t.count}}}function Ze(e){return{type:`more`,key:e}}function Qe(e){return{type:`page`,key:`page-${e}`,page:e}}function $e(e,t){let n=[];for(let r=e;r<=t;r++)n.push(r);return n}function et(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 $e(1,t).map(Qe);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.at(-1);t?.type===`page`&&e-t.page>1&&(e-t.page===2?s.push(Qe(t.page+1)):s.push(Ze(`more-${t.page}-${e}`))),s.push(Qe(e))}return s}var tt=class extends K{constructor(e,t={}){k(`Pagination`);let r=F(e,`Pagination.container`),i=Xe(t);super(i);let a=this._getPageCount(i.total,i.page.size),o=Ye(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=n({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(){return this._assertActive(`build`),this.runtime.built?this:(this.init(this.props),this.root=c(`div`,{className:`j-pagination`,role:`navigation`,"aria-label":`Pagination`,children:c(`ul`,{className:`pagination`,"aria-live":`polite`})}),this.dom.list=this.root.querySelector(`.pagination`),this.dom.prev=this._buildControlItem(`prev`),this.dom.next=this._buildControlItem(`next`),this.dom.list.append(this.dom.prev,this.dom.next),this.dom.container.textContent=``,this.dom.container.appendChild(this.root),this.runtime.built=!0,this._bindControlState(),this._bindPageItems(),this._bindEvents(),this)}go(e){if(this._assertActive(`go`),C(`page`,e,{type:`number`,validate:Number.isInteger,message:`expects an integer.`},`Pagination.go`),this._isLocked())return this;let t=Ye(e,1,this.state.pageCount);if(t===this.state.page.current)return this;let n=this.props.lock&&typeof this.props.onChange==`function`,r=n?++this.runtime.changeId:this.runtime.changeId;if(a(()=>{this.state.page.current=t,n&&(this.state.locked=!0)}),this.props.page.current=t,typeof this.props.onChange==`function`){let e;try{e=this.props.onChange(t,this)}catch(e){throw n&&r===this.runtime.changeId&&a(()=>{this.state.locked=!1}),e}if(n&&e&&typeof e.then==`function`){let t=()=>{!this.runtime.destroyed&&r===this.runtime.changeId&&a(()=>{this.state.locked=!1})};Promise.resolve(e).then(t,t)}else n&&r===this.runtime.changeId&&a(()=>{this.state.locked=!1})}return this}update(e={}){this._assertActive(`update`),C(`newProps`,e,{type:`object`},`Pagination.update`);let t=Xe({total:e.total??this.props.total,lock:Object.hasOwn(e,`lock`)?e.lock:this.props.lock,onChange:Object.hasOwn(e,`onChange`)?e.onChange:this.props.onChange,page:{...this.props.page,...e.page},count:{...this.props.count,...e.count}}),n=this._getPageCount(t.total,t.page.size);return t.page.current=Ye(t.page.current,1,n),this.props=t,a(()=>{this.state.total=t.total,this.state.page.size=t.page.size,this.state.page.current=t.page.current,this.state.count.sibling=t.count.sibling,this.state.count.boundary=t.count.boundary,this.state.pageCount=n,t.lock||(this.state.locked=!1)}),this}_getPageCount(e,t){return Math.max(1,Math.ceil(e/t))}_getPageItems(){return et(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}_buildControlItem(e){return c(`li`,{className:`item`,children:c(`button`,{className:`j-button is-icon is-ghost`,type:`button`,"data-page-action":e,children:W(e===`prev`?`arrow-left`:`arrow-right`)})})}_buildPageItem(e){let t=this._isLocked();return e.type===`more`?c(`li`,{className:`item more`,"aria-hidden":`true`,children:c(`button`,{className:`j-button is-icon is-ghost`,type:`button`,disabled:t,children:W(`more`)})}):c(`li`,{className:`item`,children:e.page===this.state.page.current?c(`span`,{className:`j-button is-icon is-active`,"data-current-page":String(e.page),"aria-current":`page`,"aria-label":`Page ${e.page}, current page`,children:String(e.page)}):c(`button`,{className:`j-button is-icon is-ghost`,type:`button`,"data-page":String(e.page),"aria-label":`Go to page ${e.page}`,"aria-disabled":t?`true`:null,disabled:t,tabindex:t?`-1`:null,children:String(e.page)})})}_bindControlState(){this.cleanup.controls?.(),this.cleanup.controls=i(t=>{let n=this.dom.prev?.querySelector(`[data-page-action]`),r=this.dom.next?.querySelector(`[data-page-action]`);return n&&(e(n,`disabled`,()=>this._isPrevDisabled()),e(n,`aria-disabled`,()=>this._isPrevDisabled()?`true`:`false`),e(n,`tabindex`,()=>this._isPrevDisabled()?`-1`:null),e(n,`aria-label`,()=>`Go to previous page`)),r&&(e(r,`disabled`,()=>this._isNextDisabled()),e(r,`aria-disabled`,()=>this._isNextDisabled()?`true`:`false`),e(r,`tabindex`,()=>this._isNextDisabled()?`-1`:null),e(r,`aria-label`,()=>`Go to next page`)),t})}_bindPageItems(){this.cleanup.itemsEffect?.dispose(),this.cleanup.itemsEffect=r(()=>{let e=this._getItemsKey();e!==this.runtime.itemsKey&&(this.runtime.itemsKey=e,this._renderPageItems())})}_renderPageItems(){this.dom.items=[];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(){this.cleanup.events.on(`click`,this.root,`click`,e=>{let t=e.target.closest(`[data-page], [data-page-action]`);if(!t||!this.root.contains(t))return;e.preventDefault();let n=t.dataset.pageAction;if(n===`prev`&&!this._isPrevDisabled()){this.go(this.state.page.current-1);return}if(n===`next`&&!this._isNextDisabled()){this.go(this.state.page.current+1);return}t.dataset.page&&this.go(Number(t.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 nt(e,t={}){return new tt(e,t)}const rt={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=>e>=0,message:`expects a positive number or 0.`},content:{default:``,validate:I,message:`expects string, Node, array, function or null.`},className:{default:null,types:[`string`,`null`]},id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():T():e??T()},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`]}};var it=class{constructor(e,t={}){k(`Drop`),this.target=P(e,`Drop.element`),this.props=w(t,rt,`Drop`),this._init(this.props)}_init(e){this.isVisible=!1,this.root=null,this.cleanup={events:V()},this._timer={show:null,hide:null},this._hoverIntentData={x:0,y:0,lastMoveTime:0};let{delay:t}=e;typeof t==`number`&&t>=0?(this.delayShow=t,this.delayHide=t):typeof t==`object`&&t?(this.delayShow=Number(t.show)||0,this.delayHide=Number(t.hide)||0):(this.delayShow=0,this.delayHide=0),this._buildDrop(e),this._bindEvents(e)}_buildDrop(e){let{className:t,content:n,id:r,name:i,containerClassName:a}=e,o=t||``,s=A(n)&&n.nodeType===1?n:c(`div`,{className:a?`drop-container ${a}`:`drop-container`,children:M(n,this)});this.root=c(`div`,{className:o?`j-drop ${o}`:`j-drop`,id:r,"data-drop":i||T(),children:s})}_bindEvents(e){let{mode:t,hoverIntent:n}=e;this._unbindEvents(),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())):t===`click`&&(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.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.events.on(`document:mousemove`,document,`mousemove`,e=>this._onMouseMove(e)),clearTimeout(this._timer.show),this._timer.show=setTimeout(()=>{let e=Date.now()-this._hoverIntentData.lastMoveTime;Math.abs(this._hoverIntentData.x-this._lastX||0)+Math.abs(this._hoverIntentData.y-this._lastY||0)<5||e>100?(this.show(),this.cleanup.events.off(`document:mousemove`)):this._startHoverIntent()},this.delayShow)}_cancelHoverIntent(){clearTimeout(this._timer.show),this.cleanup.events.off(`document:mousemove`),this.hide()}_onMouseMove(e){this._lastX=e.clientX,this._lastY=e.clientY,this._hoverIntentData.lastMoveTime=Date.now(),this._hoverIntentData.x=e.clientX,this._hoverIntentData.y=e.clientY}_setPosition(){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){!this.root.contains(e.target)&&!this.target.contains(e.target)&&this.hide()}_exec(e){this.root&&(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.parentNode&&this.root.parentNode.removeChild(this.root)),this.root.classList.toggle(`is-active`,e),this.isVisible=e)}show(e=!0){clearTimeout(this._timer.hide),!this.isVisible&&(e&&this.delayShow>0?(clearTimeout(this._timer.show),this._timer.show=setTimeout(()=>this._exec(!0),this.delayShow)):this._exec(!0),this.props.onShown&&this.props.onShown())}hide(e=!0){clearTimeout(this._timer.show),this.isVisible&&(e&&this.delayHide>0?(clearTimeout(this._timer.hide),this._timer.hide=setTimeout(()=>this._exec(!1),this.delayHide)):this._exec(!1),this.props.onHidden&&this.props.onHidden())}toggle(){this.isVisible?this.hide():this.show()}destroy(){this.props&&(clearTimeout(this._timer?.show),clearTimeout(this._timer?.hide),this._unbindEvents(),this.root?.parentNode&&this.root.parentNode.removeChild(this.root),this.props=null,this.root=null,this.target=null,this._timer={show:null,hide:null},this.cleanup?.events.clear(),this.cleanup=null)}};function at(e,t={}){return new it(e,t)}const ot={name:{default:null,types:[`string`,`null`]},mode:{default:`hover`,type:`string`},position:{default:`auto`,type:`string`},offset:{default:8,type:`number`},message:{default:``,type:`string`,normalize:e=>String(e||``).trim(),validate:e=>e.length>0,message:`expects a non-empty string.`},className:{default:null,types:[`string`,`null`]},id:{default:null,types:[`string`,`null`]},delay:{default:100,types:[`number`,`object`]},hoverIntent:{default:!0,type:`boolean`}};var st=class{constructor(e,t={}){let n=w(t,ot,`Tooltip.props`);this.drop=new it(e,{...n,content:this._buildContent(n)})}_buildContent(e){return c(`div`,{className:e.className?`j-tooltip ${e.className}`:`j-tooltip`,children:c(`div`,{className:`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&&(this.drop.destroy(),this.drop=null)}};function ct(e,t={}){return new st(e,t)}function lt(e){return e==null||typeof e==`string`||typeof e==`function`||Array.isArray(e)||typeof Node<`u`&&e instanceof Node}function ut(e){return!!e&&typeof e==`object`&&typeof e.id==`string`}function dt(e){return e==null||e===!1||typeof e==`function`}function q(e){return e&&typeof e==`object`&&!Array.isArray(e)?{...e}:{}}function ft(e){return Array.isArray(e)?[...e]:[]}function pt(e){return Array.isArray(e)?e.map(e=>({...e,data:q(e.data),modal:q(e.modal),view:q(e.view)})):[]}function mt(e,t){return typeof e==`string`?{id:e}:e&&typeof e==`object`?e:{id:t}}const ht={validate:ut,message:`expects a step object with a string id.`},gt={validate:lt,message:`expects string, Node, array, function or null.`},_t={validate:e=>Array.isArray(e)&&e.length>0,message:`expects a non-empty steps array.`},J={validate:e=>e==null||typeof e==`object`&&!Array.isArray(e),message:`expects an object or null.`},Y={validate:dt,message:`expects function, false or null.`},vt={default:{},validate:e=>b(e),message:`expects an object with text fields.`,normalize:e=>{let t=b(e)?e:{};return{...t,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`}}},yt={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():T():e??T()},steps:{default:[],..._t},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:vt,className:{default:``,type:`string`},renderHeader:{default:null,...Y},renderSteps:{default:null,...Y},renderBody:{default:null,...Y},renderFooter:{default:null,...Y},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`]}};var bt=class{constructor(e={}){this.options=w(e,yt,`Flow.options`),this._init(this.options)}_init(e){this.steps=pt(e.steps),this._validateSteps(this.steps),this._stepMap=new Map(this.steps.map((e,t)=>[e.id,t])),this._initialStepId=this._resolveInitialStepId(e.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=n({id:e.id,currentId:this._initialStepId,currentIndex:this._stepMap.get(this._initialStepId),previousId:null,previousIndex:null,direction:null,history:[this._initialStepId],data:q(this._initialData.global),stepData:q(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),()=>this._subscribers.delete(e)}snapshot(){if(!this.state)return null;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:q(this.state.data),stepData:q(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;k(`Flow.mount`);let t=P(e,`Flow.mount.container`);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`),C(`payload`,e,J,`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}=mt(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`),C(`payload`,e,J,`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}=mt(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`),C(`payload`,t,J,`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`),C(`data`,e,J,`Flow.setData`),e?(a(()=>{Object.assign(this.state.data,e),this.state.version+=1}),this._emitChange(),this):this}setStepData(e,t,n={}){return this._assertActive(`setStepData`),C(`stepId`,e,{type:`string`},`Flow.setStepData`),C(`data`,t,J,`Flow.setStepData`),!t||!this._stepMap.has(e)?this:(a(()=>{this.state.stepData[e]={...q(this.state.stepData[e]),...t},this.options.cache&&Object.assign(this.state.data,t),this.state.version+=1}),n.silent||this._emitChange(),this)}getStepData(e){return q(this.state.stepData[e])}reset(){return this._assertActive(`reset`),a(()=>{this.state.currentId=this._initialStepId,this.state.currentIndex=this._stepMap.get(this._initialStepId),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,q(this._initialData.global)),this._replaceObject(this.state.stepData,q(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`),C(`payload`,e,J,`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=null,this.options=null,this.state=null,this._stepMap=null,this._initialData=null,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(C(String(n),r,ht,`Flow.options.steps`),C(`content`,r.content??null,gt,`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`){if(!this._stepMap.has(e))throw Error(`Flow.goTo target "${e}" does not exist.`);return this._stepMap.get(e)}throw Error(`Flow.goTo target expects string or number.`)}_createInitialStepData(){let e={},t={};for(let n of this.steps)e[n.id]=q(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:t,payload:n,fromStep:r}){let i=this.snapshot(),o=this._captureState();try{n&&this.setStepData(r.id,n,{silent:!0}),await this._assertCanLeave(r,e,t),await this._assertCanEnter(e,r,t),typeof r.onLeave==`function`&&await this._callHook(r.onLeave,[this._createContext({direction:t,step:r,targetId:e.id})]);let o=this.state.currentId,s=this.state.currentIndex,c=this._stepMap.get(e.id);a(()=>{this.state.previousId=o,this.state.previousIndex=s,this.state.currentId=e.id,this.state.currentIndex=c,this.state.direction=t,t===`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:t,fromId:o,step:e})]),this._emitChange(i)}catch(e){throw this._destroyed||!this.state||!this.options?e:(this.options.rollbackOnError&&this._restoreState(o,{keepLoading:!0}),this._handleError(e,i),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:q(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||!this.state)return null;throw!this._destroyed&&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||!this.state)throw this._createAbortError();return n}_createAbortError(){let e=Error(`Flow: active action was aborted.`);return e.code=`FLOW_ABORTED`,e}_setLoading(e,t=this.state?.busyAction||null){this.state&&a(()=>{this.state.loading=e,this.state.busyAction=e?t:null})}_handleError(e,t=null){this.state&&(a(()=>{this.state.error=e,this.state.version+=1}),typeof this.options.onError==`function`&&this.options.onError(e,this.snapshot(),this,t))}_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:ft(this.state.history),data:q(this.state.data),stepData:q(this.state.stepData),loading:this.state.loading,busyAction:this.state.busyAction,error:this.state.error,version:this.state.version}}_restoreState(e,t={}){a(()=>{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=t.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||!this.state)throw Error(`Flow.${e}: instance has been destroyed.`)}_publicStep(e){if(!e)return null;let t={...e};return delete t.onEnter,delete t.onLeave,delete t.onNext,delete t.onBack,delete t.canEnter,delete t.canLeave,t}_buildRoot(){return c(`div`,{className:`j-flow ${this.options.className||``}`.trim(),id:this.options.id,role:`group`,"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=i(e=>(l(u(()=>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 c(`div`,{className:`flow-header`,children:[c(`div`,{id:`${this.options.id}-title`,className:`flow-title`,children:e.currentStep?.title||e.currentStep?.id||``}),e.currentStep?.description?c(`div`,{className:`flow-description`,children:e.currentStep.description}):null]})}_stepsView(e){return c(`ol`,{className:`flow-steps`,role:`list`,"aria-label":`Flow steps`,children:this.steps.map((t,n)=>c(`li`,{className:this._stepClass(n,e.currentIndex),"aria-current":n===e.currentIndex?`step`:void 0,children:[c(`button`,{type:`button`,className:`flow-step-button`,disabled:this.options.linear&&n>e.currentIndex,"aria-current":n===e.currentIndex?`step`:void 0,"aria-disabled":this.options.linear&&n>e.currentIndex?`true`:`false`,"aria-label":`${n+1}. ${t.title||t.id}`,onClick:()=>{n!==e.currentIndex&&this.goTo(n)},children:[c(`span`,{className:`flow-step-index`,children:n+1}),c(`span`,{className:`flow-step-title`,children:t.title||t.id})]})]}))})}_bodyView(e){return c(`div`,{className:`flow-body`,role:`region`,"aria-live":`polite`,"aria-busy":e.loading?`true`:`false`,children:this._contentView(e.currentStep?.content)})}_footerView(e){return c(`div`,{className:`flow-footer`,children:[this.options.showReset?c(`button`,{type:`button`,className:`j-button is-ghost flow-reset`,onClick:()=>this.reset(),disabled:e.loading,"aria-disabled":e.loading?`true`:`false`,children:this.options.text.reset}):null,this.options.showBack?c(`button`,{type:`button`,className:`j-button is-ghost flow-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?c(`button`,{type:`button`,className:`j-button is-primary flow-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()):Array.isArray(e)||typeof Node<`u`&&e instanceof Node?e:e==null||typeof e!=`string`?``:e}_stepClass(e,t=this.state.currentIndex){let n=[`flow-step`];return e===t&&n.push(`is-active`),e<t&&n.push(`is-complete`),n.join(` `)}};function xt(e){return new bt(e)}const St={type:{default:`mobile`,type:`string`},id:{default:``,type:`string`,normalize:e=>e.trim()===``?T():e.trim()},items:{default:[],type:`array`},backText:{default:`Back`,type:`string`}},Ct={type:`array`};var wt=class{constructor(e={},t=!1){this.options=w(e,St,`Menu.options`),this._element=t,this.dom={root:null},this.cleanup={events:V()},this._bound=!1,this._destroyed=!1}_verifyItems(e){C(`items`,e,Ct,`Menu`)}build(){return this._bound?this:(k(`Menu`),this._element===!1?(this.dom.root=this._buildRoot(),this._bound=!0):(this.dom.root=P(this._element,`Menu.element`),this._bound=!0),this._bindEvents(),this)}_buildRoot(){let{items:e,id:t,type:n}=this.options;return c(`nav`,{className:`j-${n}-menu`,children:c(`ul`,{className:`menu`,id:t,children:e.map(e=>this._buildItem(e))})})}_buildItem(e){let t=e.children&&e.children.length>0,n=[`menu-item`];t&&n.push(`menu-item-has-children`),e.classes&&Array.isArray(e.classes)&&n.push(...e.classes);let r=[];return e.url?r.push(c(`a`,{className:`menu-link`,href:e.url,...e.target&&{target:e.target},children:e.title})):r.push(c`${e.title}`),t&&r.push(c(`ul`,{className:`sub-menu`,children:e.children.map(e=>this._buildItem(e))})),c(`li`,{className:n.join(` `),id:`menu-item-${e.id||T()}`,children:r})}_bindEvents(){this.dom.root&&(this.options.type===`mobile`?this.cleanup.events.on(`mobile`,this.dom.root,`click`,e=>{let t=e.target;if(t.closest(`.menu-item.back`)){e.preventDefault(),this._handleBack(t);return}let n=t.closest(`.menu-item.menu-item-has-children`);if(n){let r=R(`:scope > a`,n);r&&(t===r||r.contains(t))&&(e.preventDefault(),this._handleMenuClick(n))}}):this.options.type===`bottom`&&this.cleanup.events.on(`bottom`,document,`click`,e=>{let t=e.target;if(t.closest(`.sub-menu a`))return;let n=t.closest(`.menu > .menu-item.menu-item-has-children`);n?(e.preventDefault(),this._toggleActive(n)):R(`.menu-item.is-active`,this.dom.root)?.classList.remove(`is-active`)}))}_unbindEvents(){this.cleanup.events.clear()}_teardown({keepElement:e=!1}={}){this._unbindEvents(),this.cleanup.items?.(),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){e.classList.add(`is-active`);let t=R(`:scope > .sub-menu`,e);if(!t||R(`:scope > .menu-item.back`,t))return;let n=c(`li`,{className:`menu-item back`,children:c(`a`,{className:`menu-link`,children:[c(`icon`,{className:`el-icon el-prefix`,children:W(`arrow-left`)}),c(`span`,{className:`menu-text`,children:this.options.backText})]})});t.insertBefore(n,t.firstChild)}_handleBack(e){let t=e.closest(`.menu-item.back`);if(!t)return;let n=t.parentElement.parentElement;n&&n.classList.contains(`menu-item-has-children`)&&n.classList.remove(`is-active`),t.remove()}_toggleActive(e){let t=e.classList.contains(`is-active`);R(`.menu-item.is-active`,this.dom.root)?.classList.remove(`is-active`),t||e.classList.add(`is-active`)}setItems(e){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{let t=this.dom.root.matches?.(`.menu`)||this.dom.root.matches?.(`ul`)||this.dom.root.matches?.(`ol`)?this.dom.root:R(`:scope > .menu`,this.dom.root)||R(`.menu`,this.dom.root);if(!t)throw Error(`Menu: .menu element not found for setItems().`);this._unbindEvents(),this.cleanup.items?.(),this.cleanup.items=u(()=>e.map(e=>this._buildItem(e)),t),this._bindEvents()}return this}removeItem(e){if(!this.dom.root)return this;let t=R(`[id^="menu-item-${e}"]`,this.dom.root);if(t&&t.remove(),this.options.items){let t=n=>{for(let r=n.length-1;r>=0;r--)n[r].id===e?n.splice(r,1):n[r].children&&t(n[r].children)};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 Tt(e,t={}){return new wt(e,t)}function X(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 Et(e){return{...e,fields:Array.isArray(e.fields)?X(e.fields):e.fields}}function Dt(e){return e&&typeof e==`object`?e:{value:e,text:e}}function Ot(e){return e==null||typeof e==`string`||typeof e==`function`||Array.isArray(e)||A(e)}function kt(e){return b(e)}function At(e){return e==null||typeof e==`object`&&typeof e.next==`function`&&typeof e.back==`function`&&typeof e.snapshot==`function`}function jt(e,t){return!Array.isArray(e)||!b(t)?e:e.map(e=>{if(!e?.name||!g(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:n}})}function Mt(e){let t=b(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 Nt(e){return{...e,fields:Array.isArray(e.fields)?X(e.fields):null,text:Mt(e),loading:!1,submitting:!1,visible:!1,data:null,extraData:null}}function Pt(e,t){return!t||typeof t!=`object`?e:Object.assign(e,t)}function Ft(e){return b(e)?{...e}:{}}const It={validate:Ot,message:`expects string, Node, array, function or null.`},Lt={default:{},validate:e=>b(e),message:`expects an object with text fields.`,normalize:e=>{let t=b(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`}}},Rt={types:[`array`,`null`]},Z={content:{default:``,...It},position:{default:`center`,type:`string`},showCancel:{default:!0,type:`boolean`},showClose:{default:!0,type:`boolean`},fullscreen:{default:!1,type:`boolean`},flow:{default:null,validate:At,message:`expects a Flow instance or null.`},text:Lt,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,...Rt},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()?e.trim():T():e??T()},escClose:{default:!1,type:`boolean`},bgClose:{default:!1,type:`boolean`},lazy:{default:!1,type:`boolean`}},zt={...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`]}},Bt=new Set([`id`,`lazy`]),Vt={validate:e=>!!e&&typeof e==`object`&&!Array.isArray(e),message:`expects an object.`},Ht={validate:kt,message:`expects a props object.`};let Q=0,Ut=``;var Wt=class extends K{constructor(e={}){let t=w(e,Z,`Modal`);super(t),this.dom.modal=null,this.dom.header=null,this.dom.body=null,this.dom.footer=null,this.dom.form=null,this.cleanup.visibility=null,this.cleanup.view=null,this.cleanup.hideTimer=null,this.runtime.scrollLocked=!1,this.runtime.visibleApplied=!1,this.cache={initial:Et(this.props),fieldIds:new Map,baseStyle:``,previousActiveElement:null,formId:`${this.props.id}_form`},this.state=n(Nt(this.props)),this.init(t)}onInit(){this.bindReactiveVisibility(),!this.state.lazy&&fe()&&this.buildRoot()}buildRoot(){if(this.root)return this.root;let{id:e}=this.state,t=c(`div`,{className:()=>`j-popup-layout is-${this.state.position}`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":()=>this.state.header?`${e}_title`:null,"aria-label":()=>this.state.header?null:this.state.text?.title||`Modal`,children:c(`div`,{className:()=>this.state.fullscreen?`j-modal is-fullscreen`:`j-modal`,id:e,role:`document`,ref:e=>{this.dom.modal=e,this.applyStyle(e,this.state.style)},children:[c(`div`,{className:`modal-header`,style:()=>({display:this.state.header?``:`none`}),ref:e=>{this.dom.header=e}}),c(`div`,{className:`modal-body`,ref:e=>{this.dom.body=e}}),c(`div`,{className:`modal-footer`,style:()=>({display:this.state.footer?``:`none`}),ref:e=>{this.dom.footer=e}})]})});return this.root=t,this.mountView(),t}mountView(){this.cleanup.view||!this.dom.body||(this.cleanup.view=i(e=>(this.dom.header&&l(u(()=>this.headerView(),this.dom.header)),u(()=>this.bodyView(),this.dom.body),this.dom.footer&&l(u(()=>this.footerView(),this.dom.footer)),this.bindReactiveLoading(),this.bindReactiveStyle(),e)))}headerView(){return()=>this.state.header?[c(`div`,{className:`modal-title`,id:`${this.state.id}_title`,children:()=>this.state.text?.title}),this.state.showClose?c(`button`,{type:`button`,className:`is-reset modal-close`,"data-action":`close`,"aria-label":`close`,children:W(`close`)}):null]:null}footerView(){return()=>this.state.footer?[this.state.showCancel?c(`button`,{type:`button`,className:`j-button is-ghost modal-cancel`,"data-action":`close`,"aria-label":`close`,disabled:()=>this.isBusy(),children:()=>this.state.text?.cancel}):null,c(`button`,{type:()=>this.isFormMode()?`submit`:`button`,form:()=>this.isFormMode()?this.cache.formId:null,className:`j-button is-primary modal-confirm`,"data-action":this.isFormMode()?`submit`:`confirm`,disabled:()=>this.isBusy(),children:()=>this.state.text?.confirm})]:null}bodyView(){return this.isFormMode()?this.formView():(this.dom.form=null,this.contentView(this.state.content))}formView(){return c(`div`,{className:`modal-form-container`,children:c(`form`,{id:this.cache.formId,className:`j-form is-vertical is-item-vertical`,ref:e=>{this.dom.form=e},onSubmit:e=>this.handleFormSubmit(e),onKeyDown:e=>this.handleFormKeydown(e),children:(this.state.fields||[]).map((e,t)=>this.fieldView(e,t))})})}fieldView(e,t){let n=this.resolveFieldId(e,t),r=this.labelView(e,n);return c(`div`,{className:`form-item`,style:{display:e.type===`hidden`?`none`:``},children:[r,c(`div`,{className:`form-control`,children:this.controlView(e,n)})]})}labelView(e,t){return c(`label`,{className:`item-label ${e.required?`is-required`:``}`,for:t,style:{display:e.label===void 0?`none`:``},children:e.label===void 0?``:e.label})}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}_${T()}`),this.cache.fieldIds.get(n)}controlView(e,t){switch(e.type){case`textarea`:return this.textareaView(e,t);case`select`:return this.selectView(e,t);default:return this.inputView(e,t)}}inputView(e,t){let n=e.type||`text`,r={type:n,className:`j-input`,name:e.name,id:t,placeholder:e.placeholder||``,value:e.value??``,autocomplete:e.autocomplete||this.autoComplete(n),required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly};return e.checked!==void 0&&(r.checked=!!e.checked),c(`input`,r)}textareaView(e,t){return c(`textarea`,{className:`j-textarea`,name:e.name,id:t,placeholder:e.placeholder||``,value:e.value??``,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly})}selectView(e,t){let n=e.value;return c(`select`,{className:`j-select`,name:e.name,id:t,autocomplete:`off`,required:!!e.required,disabled:!!e.disabled,readonly:!!e.readonly,multiple:!!e.multiple,children:(e.options||[]).map(e=>{let t=Dt(e);return c(`option`,{value:t.value??``,disabled:!!t.disabled,selected:this.isSelected(n,t.value),children:t.text??t.label??t.value??``})})})}contentView(e){if(typeof e==`function`)return e(this);if(Array.isArray(e)||A(e))return e;if(e==null||typeof e!=`string`)return``;let t=document.createElement(`template`);return t.innerHTML=e,Array.from(t.content.childNodes)}bindReactiveLoading(){let e=null;r(()=>{this.state.loading&&!e?(e=L(),this.dom.modal.appendChild(e)):!this.state.loading&&e&&(e.remove(),e=null)}),l(()=>{e?.remove(),e=null})}bindReactiveStyle(){r(()=>{let e=this.state.style;this.dom.modal&&this.applyStyle(this.dom.modal,e)})}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(String).includes(String(t)):e==t}isFormMode(){return Array.isArray(this.state.fields)}isBusy(){return!!(this.state.loading||this.state.submitting)}validatePropsPatch(e,t=`Modal.update`){C(`props`,e,Ht,t);for(let n of Object.keys(e)){if(!g(Z,n))throw Error(`Validator: ${t}.${n} is not a supported modal prop.`);if(Bt.has(n))throw Error(`Modal.update: "${n}" cannot be updated after initialization.`);C(n,e[n],Z[n],t)}}applyProps(e,{validate:t=!0,force:n=!1}={}){if(t&&this.validatePropsPatch(e),!e||Object.keys(e).length===0)return this;let r=g(e,`fields`);if(g(e,`content`)&&!r&&this.isFormMode()&&!n)throw Error(`Modal.update: Cannot update content when fields are defined.`);let i=Object.assign({},this.props,e);g(e,`text`)&&(i.text=Object.assign({},this.props.text||{},e.text)),this.props=i,super.update(e,{force:n}),this.props=i;let o={};r&&(this.cache.fieldIds.clear(),o.fields=Array.isArray(e.fields)?X(e.fields):null);for(let[t,n]of Object.entries(e))t===`fields`||t===`text`||(o[t]=n);return g(e,`text`)&&(o.text=Mt(this.props)),a(()=>{for(let[e,t]of Object.entries(o))this.state[e]=t}),g(e,`style`)&&this.dom.modal&&this.applyStyle(this.dom.modal,this.state.style),this.state.visible&&(g(e,`bgClose`)||g(e,`escClose`))&&this.bindEvents(this.root),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}typeof t==`object`&&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`)||``}normalizeIcon(e){if(!(e instanceof Element))return;let t=R(`.modal-close`,e);t&&(t.style.transform=`translateX(${t.clientHeight/3}px)`)}bindReactiveVisibility(){this.cleanup.visibility=i(e=>(r(()=>{let e=!!this.state.visible;d(()=>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.`);k(`Modal.show`),this.root||this.buildRoot(),this.cancelHideTimer(),this.resetAnimationStyles();let{onShow:e,onShown:t}=this.state;e&&e(),this.cache.previousActiveElement=document.activeElement,this.root.parentNode||document.body.appendChild(this.root),this.lockScroll(),this.runtime.visibleApplied=!0,this.normalizeIcon(this.dom.modal),this.bindEvents(this.root),this.focusFirst(),t&&t()}hideFromState(){if(!this.runtime.visibleApplied||!this.root)return;let{onHide:e,onHidden:t}=this.state;e&&e(),this.runtime.visibleApplied=!1,this.clearEvents(),a(()=>{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(t),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){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`||t.classList.contains(`modal-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()){if(t.classList.contains(`modal-confirm`))return;this.requestSubmit();return}this.handleConfirm()}})}clearEvents(){this.cleanup.events.clear()}requestSubmit(){if(!this.dom.form){this.handleConfirm();return}if(typeof this.dom.form.requestSubmit==`function`){this.dom.form.requestSubmit();return}let e=new Event(`submit`,{bubbles:!0,cancelable:!0});this.dom.form.dispatchEvent(e)}async handleFormSubmit(e){if(e.preventDefault(),this.isBusy())return;let t=e.currentTarget;if(!t.checkValidity()){t.reportValidity();return}let n=Pt(this.collectFormData(t),this.state.extraData);a(()=>{this.state.data=n}),await this.handleSubmit(n)}handleFormKeydown(e){if(e.key!==`Enter`||e.isComposing||this.isBusy())return;let t=e.target,n=t?.tagName?.toLowerCase(),r=t?.type?.toLowerCase();n!==`textarea`&&(r===`button`||r===`submit`||r===`reset`||(e.preventDefault(),this.requestSubmit()))}collectFormData(e){let t={},n=new FormData(e);for(let[e,r]of n.entries())g(t,e)?t[e]=Array.isArray(t[e])?[...t[e],r]:[t[e],r]:t[e]=r;return t}async handleNext(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`next`)}async handleBack(){this.isBusy()||this.hasFlow()&&await this.moveFlow(`back`)}hasFlow(){return At(this.state.flow)&&!!this.state.flow}async moveFlow(e){let t=this.createFlowPayload();if(t!==!1){a(()=>{this.state.submitting=!0});try{let n=await this.state.flow[e](t);this.syncFlowView(this.state.flow,n)}catch(t){console.error(`Modal.flow.${e} error:`,t),this.syncFlowView(this.state.flow)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}createFlowPayload(){if(!this.isFormMode())return null;let e=this.dom.form;if(!e)return this.state.data||null;if(!e.checkValidity())return e.reportValidity(),!1;let t=Pt(this.collectFormData(e),this.state.extraData);return a(()=>{this.state.data=t}),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 b(i)?i:{}}return Ft(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=b(i.text)?i.text:{},o={...(!g(i,`text`)||!g(a,`title`))&&r?.title!=null?{text:{...a,title:r.title}}:{},...!g(i,`content`)&&!g(i,`fields`)?{content:r?.content??null}:{},...i};Array.isArray(o.fields)&&(o.fields=jt(o.fields,n?.currentData)),!g(o,`fields`)&&g(o,`content`)&&(o.fields=null),this.update(o)}async handleConfirm(){if(!this.isBusy()){a(()=>{this.state.submitting=!0});try{this.state.onConfirm&&await Promise.resolve(this.state.onConfirm()),this.hide()}catch(e){console.error(`Modal.onConfirm error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}async handleCancel(){if(!this.isBusy()){a(()=>{this.state.submitting=!0});try{this.state.onCancel&&await Promise.resolve(this.state.onCancel(this)),this.hide()}catch(e){console.error(`Modal.onCancel error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}async handleSubmit(e){if(this.state.onSubmit){a(()=>{this.state.submitting=!0});try{await Promise.resolve(this.state.onSubmit(e)),this.state.extraData=null}catch(e){console.error(`Modal.onSubmit error:`,e)}finally{this.state&&a(()=>{this.state.submitting=!1})}}}trapFocus(e){if(!this.dom.modal)return;let t=Array.from(z(`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=R(`input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]):not([data-action=close]), [tabindex]:not([tabindex="-1"])`,this.dom.form||this.dom.modal);e?e.focus():(this.dom.modal.setAttribute(`tabindex`,`-1`),this.dom.modal.focus())}lockScroll(){this.runtime.scrollLocked||!O()||(Q===0&&(Ut=document.body.style.overflow,document.body.style.overflow=`hidden`),Q+=1,this.runtime.scrollLocked=!0)}unlockScroll(){!this.runtime.scrollLocked||!O()||(Q=Math.max(0,Q-1),Q===0&&(document.body.style.overflow=Ut,Ut=``),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?.parentNode&&this.root.parentNode.removeChild(this.root),this.resetAnimationStyles(),this.unlockScroll(),this.restoreFocus(),e&&e()}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(!g(zt,t))throw Error(`Modal.setState: "${t}" is not a supported state key.`);if(Bt.has(t))throw Error(`Modal.setState: "${t}" cannot be updated after initialization.`);C(t,e[t],zt[t],`Modal.setState`)}}setState(e={}){return this.assertActive(`setState`),this.validateStatePatch(e),a(()=>{for(let[t,n]of Object.entries(e))t===`fields`&&this.cache.fieldIds.clear(),this.state[t]=t===`fields`&&Array.isArray(n)?X(n):n}),this}show(){return this.assertActive(`show`),a(()=>{this.state.visible=!0}),this}hide(){return this.assertActive(`hide`),a(()=>{this.state.visible=!1}),this}setFields(e,t=!1){return C(`data`,e,Rt,`Modal.setFields`),this.applyProps({fields:e},{validate:!1,force:t}),this}addFields(e){return C(`data`,e,Vt,`Modal.addFields`),a(()=>{this.state.extraData=e}),this}setContent(e,t=!1){if(C(`content`,e,It,`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){return this.applyProps(e,{validate:!0,force:t})}reset(){this.cache.fieldIds.clear();let e=Et(this.cache.initial);return delete e.id,delete e.lazy,this.props=Et(e),this.applyProps(e,{validate:!1}),a(()=>{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)?X(this.cache.initial.fields):null)}onDestroy(){let e=!!this.runtime.visibleApplied,t=this.state?.onHide,n=this.state?.onHidden;e&&t&&t(),this.cancelHideTimer(),this.clearEvents(),this.unlockScroll(),this.cleanup.visibility?.(),this.cleanup.visibility=null,this.cleanup.view?.(),this.cleanup.view=null,this.root?.parentNode&&this.root.parentNode.removeChild(this.root),e&&n&&n(),this.cache={initial:null,fieldIds:null,baseStyle:``,previousActiveElement:null,formId:``}}destroy(){if(!this.runtime.destroyed)return super.destroy(),this}};function Gt(e){return new Wt(e)}const Kt={validate:e=>e==null||typeof e==`string`||Array.isArray(e)||A(e),message:`expects Element, Node, selector or JSX node.`},qt={ball:{default:{color:`var(--primary, #3e63dd)`,size:`10px`},type:`object`,validate:e=>e&&Object.keys(e).length===2&&typeof e.color==`string`&&typeof e.size==`string`,message:`expects an object with two string properties: "color" and "size".`},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`]}};var Jt=class{constructor(e){k(`Parabola`),this.options=w(e,qt,`Parabola.options`),this._init(this.options)}_init(e){this.hidden=!1,this._ball=null,this._animationId=null;let t=P(e.from,`Parabola.from`),n=P(e.to,`Parabola.to`);this._fromEl=t,this._toEl=n,this._createBall(e)}_createBall(e){if(this.hidden||this._ball)return;let{color:t,size:n}=e.ball;this._ball=c(`div`,{className:`parabola-ball`,style:{backgroundColor:t,width:n,height:n,position:`fixed`,borderRadius:`50%`,transform:`translate(-50%, -50%)`,pointerEvents:`none`,zIndex:`9999`,opacity:`1`}}),document.body.appendChild(this._ball)}_calculatePath(e){let t=this._fromEl?.getBoundingClientRect(),n=this._toEl?.getBoundingClientRect();if(!t||!n)return null;let{left:r,top:i,width:a,height:o}=t,{left:s,top:c,width:l,height:u}=n,d,f;switch(e.direction){case`top-left`:d=r+a*.2,f=i+o*.2;break;case`top-right`:d=r+a*.8,f=i+o*.2;break;case`bottom-left`:d=r+a*.2,f=i+o*.8;break;case`bottom-right`:d=r+a*.8,f=i+o*.8;break;default:d=r+a/2,f=i+o/2}let p=s+l/2,m=c+u/2;return{startX:d,startY:f,endX:p,endY:m}}_easeOutCubic(e){return 1-(1-e)**3}_animate(e,t,n,r,i=800){if(this.hidden)return;let a=performance.now(),o=n-e,s=r-t,c=n=>{if(this.hidden)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)}async show(){return this.hidden?!1:new Promise(e=>{_.start(`show`,this.options.showDelay,()=>{if(this.hidden){e(!1);return}let t=this._calculatePath(this.options);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.options.onShow(),this._animate(t.startX,t.startY,t.endX,t.endY),e(!0)})})}destroy(){this.hidden||(this._ball?.remove(),_.cancel(`show`),this._animationId&&cancelAnimationFrame(this._animationId),this._ball=null,this._fromEl=null,this._toEl=null,this.hidden=!0,this.options.onHidden&&this.options.onHidden())}start(){return this.show()}};function Yt(e={}){return new Jt(e)}const Xt={target:{default:null},parent:{default:null},max:{default:10,type:`number`,validate:e=>Number.isInteger(e)&&e>0,message:`expects a positive integer.`},top:{default:16,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},gap:{default:16,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},overflow:{default:`destroy`,type:`string`,enum:[`destroy`,`ignore`]},onUpdate:{default:null,types:[`function`,`null`]}};function Zt(e){return Array.from(new Set(e.filter(j)))}function Qt(e,t){return!t||e===t||t.contains(e)}function $t(e){return e===!1||e==null?null:F(e,`Sticky.parent`,`element`)}function en(e,t){if(e===!1||e==null)return[];if(typeof e==`string`){if(!t)return Zt(F(e,`Sticky.target`,`array`));let n=Zt(Array.from(t.querySelectorAll(e)));if(n.length===0)throw Error(`Sticky.target: target not found.`);return n}let n=Zt(F(e,`Sticky.target`,`array`));if(!t)return n;let r=n.filter(e=>Qt(e,t));if(r.length===0)throw Error(`Sticky.target: target not found in parent.`);return r}function tn(e){let t=e.offsetHeight;return Number.isFinite(t)?t:0}var nn=class extends K{constructor(e={}){let t=w(e,Xt,`Sticky.props`);super(t),this.dom.parent=null,this.dom.targets=[],this.runtime.active=!1,this.runtime.built=!1,this.runtime.ignored=!1,this.runtime.items=[],this.state=n({count:0,top:t.top,items:[]})}build(){if(this.runtime.destroyed)throw Error(`Sticky.build: instance destroyed`);return this.runtime.built||(k(`Sticky`),this.init(this.props),this.dom.parent=$t(this.props.parent),this.dom.targets=en(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+=tn(e.element)+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}onDestroy(){this._restore(),this.runtime.active=!1,this.runtime.built=!1,this.runtime.items=[],this.dom.targets=[]}};function rn(e={}){return new nn(e)}const an={container:{default:null},target:{default:`.j-content`},headings:{default:`h2, h3`,type:`string`},offset:{default:80,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},onUpdate:{default:null,types:[`function`,`null`]}};function on(e){let t=/^H([1-6])$/.exec(e.tagName);return t?Number(t[1]):1}function sn(e,t){return e.id||(e.id=`toc-${T()}-${t}`),{id:e.id,text:e.textContent||``,level:on(e),element:e}}var cn=class extends K{constructor(e={}){let t=w(e,an,`Toc.props`);super(t),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=n({items:[],current:{index:-1,item:null}})}build(){if(this.runtime.destroyed)throw Error(`Toc.build: instance destroyed`);return this.runtime.built?this:(k(`Toc`),this.init(this.props),this.dom.container=F(this.props.container,`Toc.container`),this.dom.target=F(this.props.target,`Toc.target`),this.root=document.createElement(`nav`),this.root.className=`j-toc`,this.dom.list=document.createElement(`div`),this.dom.list.className=`toc-list`,this.root.appendChild(this.dom.list),this.dom.container.innerHTML=``,this.dom.container.appendChild(this.root),this.runtime.built=!0,this.refresh(),this)}_bindEvents(){this.cleanup.events.on(`scroll`,window,`scroll`,()=>this._onScroll(),{passive:!0})}_onScroll(){this.runtime.ticking||(requestAnimationFrame(()=>{this._updateActive(),this.runtime.ticking=!1}),this.runtime.ticking=!0)}_buildLink(e){let t=document.createElement(`a`);return t.href=`#${e.id}`,t.className=`toc-link is-level-${e.level}`,t.textContent=e.text,t.dataset.tocTarget=e.id,t}_updateActive(){if(!this.runtime.built)return;let e=-1;for(let t=this.dom.headings.length-1;t>=0;t--)if(this.dom.headings[t].getBoundingClientRect().top<=this.props.offset){e=t;break}if(e===this.state.current.index)return;let t=this.state.items[e]||null;this.setState({current:{index:e,item:t}}),this.dom.links.forEach((t,n)=>{let r=n===e;t.dataset.active=r?`1`:`0`,t.className=`toc-link is-level-${this.state.items[n].level}${r?` is-active`:``}`}),typeof this.props.onUpdate==`function`&&this.props.onUpdate(t,e,this)}refresh(){if(this.runtime.destroyed||!this.runtime.built)return this;this.cleanup.events.clear(),this.dom.headings=Array.from(this.dom.target.querySelectorAll(this.props.headings));let e=this.dom.headings.map(sn);this.dom.links=e.map(e=>this._buildLink(e)),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||!Number.isInteger(e)||e<0||e>=this.dom.links.length||this.dom.links[e].scrollIntoView({behavior:`smooth`,block:`start`}),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 ln(e={}){return new cn(e)}const un={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=>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=>e>=0,message:`expects a positive number or 0.`},touchRatio:{default:1,type:`number`,validate:e=>e>0,message:`expects a number greater than 0.`},touchAngle:{default:45,type:`number`,validate:e=>e>=0&&e<=90,message:`expects a number between 0 and 90.`},longSwipesMs:{default:300,type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},longSwipesRatio:{default:.05,type:`number`,validate:e=>e>=0&&e<=1,message:`expects a number between 0 and 1.`},preventClick:{default:!0,type:`boolean`}},dn={validate:e=>!e||typeof e!=`object`||Array.isArray(e)?!1:(e.image==null||typeof e.image==`string`)&&(e.url==null||typeof e.url==`string`)&&(e.title==null||typeof e.title==`string`)&&(e.sort==null||typeof e.sort==`number`)&&(e.blank==null||typeof e.blank==`boolean`)&&(e.children==null||I(e.children)),message:`expects items with optional image, url, title, sort, blank and children fields.`};function fn(e){return!!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 pn(e,t){return M(e,t)}function mn(e){let t=z(`.j-swiper`,e);return C(`container`,t,{validate:e=>e.length===1,message:`expects exactly one .j-swiper descendant.`},`Swiper`),t[0]}var hn=class extends K{constructor(e,t={}){let r=w(t,un,`Swiper.options`);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=n({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;k(`Swiper`);let e=Array.isArray(this.props.data),t=F(this.dom.container,`Swiper`),n=null,r=null;e?(r=t,n=o(`div`,{className:`j-swiper`}),r.appendChild(n)):n=mn(t);try{this.dom.root=n,this.dom.mountTarget=r,this.dom.createdRoot=e,this.dom.createdSlides=e;let t=e?this.createDataView(n,this.props.data):R(`.swiper-wrapper`,n);C(`wrapper`,t,{validate:j,message:`expects .swiper-wrapper in the root element.`},`Swiper`),this.dom.wrapper=t,this.dom.slides=z(`.swiper-slide`,t),this.dom.pagination=R(`.swiper-pagination`,n),this.dom.prevButton=R(`.swiper-navigation.is-prev`,n),this.dom.nextButton=R(`.swiper-navigation.is-next`,n),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,t){let n=this.normalizeData(t),r=o(`div`,{className:`swiper-wrapper`,"aria-live":`polite`});return e.textContent=``,n.forEach((e,t)=>{r.appendChild(this.createDataSlide(e,t))}),e.appendChild(r),r}normalizeData(e){e.forEach((e,t)=>{C(String(t),e,dn,`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,t){let n=o(e.url?`a`:`div`,{className:`swiper-slide`,href:e.url||void 0,target:e.url?e.blank?`_blank`:`_self`:void 0,"data-swiper-index":String(t),role:`group`,"aria-label":`Slide ${t+1}`});if(e.children!=null)return n.append(...pn(e.children,{swiper:this,item:e,index:t})),n;if(e.image){let t=o(`img`,{className:`swiper-image`,alt:e.title||``,loading:`lazy`});this.props.lazyload?t.dataset.lazy=e.image:t.src=e.image,n.appendChild(t)}return e.title&&n.appendChild(o(`span`,{className:`swiper-slide-title`,children:e.title})),n}onInit(){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&&z(`[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.width=this.dom.root.clientWidth||this.dom.root.offsetWidth}refreshSlides(){this.dom.slides=z(`.swiper-slide`,this.dom.wrapper),this.runtime.realCount=this.dom.slides.filter(e=>!e.hasAttribute(`data-clone`)).length}initLoop(){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.style.setProperty(`--swiper-slide-width`,`${this.state.width}px`)}reInitView(){this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear(),z(`[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(){this.cleanup.events.on(`touchstart`,this.dom.wrapper,`touchstart`,e=>{e.touches[0]&&this.onStart(e.touches[0],e.target)},{passive:!0}),this.cleanup.events.on(`touchmove`,this.dom.wrapper,`touchmove`,e=>{e.touches[0]&&this.onMove(e.touches[0],e)},{passive:!1}),this.cleanup.events.on(`touchend`,this.dom.wrapper,`touchend`,e=>{e.changedTouches[0]&&this.pushLog(e.changedTouches[0]),this.onEnd()}),this.cleanup.events.on(`touchcancel`,this.dom.wrapper,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`window:touchcancel`,window,`touchcancel`,()=>{this.resetDrag(!0)}),this.cleanup.events.on(`mousedown`,this.dom.wrapper,`mousedown`,e=>{e.button===0&&(this.onStart(e,e.target),this.dom.wrapper.style.cursor=`grabbing`)}),this.cleanup.events.on(`mousemove`,this.dom.wrapper,`mousemove`,e=>{e.buttons===1&&this.onMove(e,e)}),this.cleanup.events.on(`window:mousemove`,window,`mousemove`,e=>{this.runtime.touching&&e.buttons===1&&this.onMove(e,e)}),this.cleanup.events.on(`mouseup`,this.dom.wrapper,`mouseup`,e=>{this.dom.wrapper.style.cursor=`grab`,this.pushLog(e),this.onEnd()}),this.cleanup.events.on(`window:mouseup`,window,`mouseup`,e=>{this.runtime.touching&&(this.dom.wrapper.style.cursor=`grab`,this.pushLog(e),this.onEnd())}),this.cleanup.events.on(`wrapper:mouseleave`,this.dom.wrapper,`mouseleave`,()=>{this.dom.wrapper.style.cursor=`grab`}),this.cleanup.events.on(`click`,this.dom.wrapper,`click`,e=>{!this.runtime.clickPrevented||!this.props.preventClick||(e.preventDefault(),e.stopPropagation(),this.runtime.clickPrevented=!1)},{capture:!0}),this.cleanup.events.on(`dragstart`,this.dom.wrapper,`dragstart`,e=>e.preventDefault()),this.cleanup.events.on(`transitionend`,this.dom.wrapper,`transitionend`,e=>this.onTransitionEnd(e)),this.cleanup.events.on(`window:resize`,window,`resize`,()=>this.update(null,{force:!0})),this.cleanup.events.on(`root:mouseenter`,this.dom.root,`mouseenter`,()=>this.pause()),this.cleanup.events.on(`root:mouseleave`,this.dom.root,`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.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=fn(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||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`),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=R(`img[data-lazy]`,t);if(!n||n.src)return;n.classList.add(`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(`loading`),n.classList.add(`loaded`),r()},n.onerror=()=>{n.classList.remove(`loading`),n.classList.add(`error`),r()}})}clearImageCleanups(){this.runtime.imageCleanups?.forEach(e=>e()),this.runtime.imageCleanups?.clear()}initPagination(){this.dom.pagination?this.dom.pagination.classList.add(`is-horizontal`,`is-clickable`,`is-bullet`):(this.dom.pagination=o(`div`,{className:`swiper-pagination is-horizontal is-clickable is-bullet`}),this.dom.root.appendChild(this.dom.pagination),this.dom.createdPagination=!0),this.dom.pagination.textContent=``,this.dom.bullets=[];for(let e=0;e<this.realCount;e++){let t=o(`button`,{type:`button`,className:`swiper-pagination-indicator swiper-pagination-bullet`,"aria-label":`Go to slide ${e+1}`});this.cleanup.events.on(`bullet:${e}:click`,t,`click`,()=>{this.slideTo(e)}),this.cleanup.events.on(`bullet:${e}:keydown`,t,`keydown`,t=>{t.key!==`Enter`&&t.key!==` `||(t.preventDefault(),this.slideTo(e))}),this.dom.bullets.push(t),this.dom.pagination.appendChild(t)}this.cleanup.bindings=i(n=>(this.dom.bullets.forEach((n,r)=>{t(n,`is-active`,()=>this.state.index===r),e(n,`aria-current`,()=>this.state.index===r?`true`:null)}),n))}initNavigation(){this.dom.prevButton=this.ensureNavigation(`prev`,`arrow-left`),this.dom.nextButton=this.ensureNavigation(`next`,`arrow-right`),this.cleanup.events.on(`nav:prev`,this.dom.prevButton,`click`,()=>this.prev()),this.cleanup.events.on(`nav:next`,this.dom.nextButton,`click`,()=>this.next()),this.props.loop||(this.cleanup.navBindings=i(n=>(t(this.dom.prevButton,`is-disabled`,()=>this.state.trackIndex<=0),e(this.dom.prevButton,`disabled`,()=>this.state.trackIndex<=0?``:null),t(this.dom.nextButton,`is-disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1),e(this.dom.nextButton,`disabled`,()=>this.state.trackIndex>=this.dom.slides.length-1?``:null),n)))}ensureNavigation(e,t){let n=e===`prev`?`createdPrevButton`:`createdNextButton`,r=`swiper-navigation is-${e}`,i=R(`.swiper-navigation.is-${e}`,this.dom.root);return i?i.matches(`button`)||(i.setAttribute(`role`,`button`),i.setAttribute(`tabindex`,`0`),i.classList.add(`swiper-navigation`,`is-${e}`)):(i=o(`button`,{type:`button`,className:r}),this.dom.root.appendChild(i),this.dom[n]=!0),i.setAttribute(`aria-label`,e===`prev`?`Previous slide`:`Next slide`),i.querySelector(`svg`)||(i.textContent=``,i.appendChild(W(t))),i}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=e&&typeof e==`object`&&!Array.isArray(e)?e:{},r=w(Object.assign({},this.props,n),un,`Swiper.options`),i={};return Object.keys(n).forEach(e=>{i[e]=r[e]}),this.props=r,this.emit(`beforeUpdate`,i,{force:t}),this.onUpdate(i,{force:t}),this.emit(`afterUpdate`,i,{force:t}),this}onUpdate(e={}){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(C(`data`,e,un.data,`Swiper.options`),!Array.isArray(e))return this.props.data=e,this.reInitView(),this;this.props.data=e;let t=this.state.index;this.pause(),this.clearImageCleanups(),this.cleanup.bindings?.(),this.cleanup.bindings=null,this.cleanup.navBindings?.(),this.cleanup.navBindings=null,this.cleanup.events.clear();let n=this.normalizeData(e);return this.dom.wrapper.textContent=``,n.forEach((e,t)=>{this.dom.wrapper.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 gn(e,t={}){return new hn(t)}const _n={id:{default:null,types:[`string`,`null`],normalize:e=>typeof e==`string`?e.trim()?e.trim():T():e??T()},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`},onAdd:{default:null,types:[`function`,`null`]},onRemove:{default:null,types:[`function`,`null`]}},vn={type:`object`,validate:e=>!!e&&I(e.title)&&I(e.panel),message:`expects an object with renderable title and panel: string, Node, array, function or null.`};function yn(e){return Array.isArray(e)?e.map(e=>({...e})):[]}function bn(e){return typeof e==`number`&&e>0?e:0}var xn=class extends K{constructor(e,t={}){k(`Tabs`);let r=F(e,`Tabs`),i=w(t,_n,`Tabs`);super(i),this.dom.container=r,this.state=n({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._activate(e.active,!1),this.bindEvents(),this._initDrag()}buildRoot(e){let{id:t,direction:n}=e,r=c(`div`,{className:`tab-wrap`,children:c(`nav`,{className:`tab-list`})}),i=c(`div`,{className:`tab-panel`});return c(`div`,{className:`j-tabs is-${n}`,id:t,children:[r,i]})}rebuildItems(){let n=R(`.tab-list`,this.root),r=R(`.tab-panel`,this.root);if(!n||!r)return;n.textContent=``,r.textContent=``,this.dom.tabs=[],this.dom.panels=[],this.dom.panelBodies=[];let a=document.createDocumentFragment(),o=document.createDocumentFragment();this.props.tabs.forEach((e,t)=>{let n=e.name||T(),r=c(`div`,{className:`tab-item`,"data-tab":n,children:c(`span`,{children:M(e.title,{tabs:this,item:e})})});this.dom.tabs.push(r);let i=c(`div`);this.dom.panels.push(c(`div`,{className:`panel-item`,role:`tabpanel`,children:i})),this.dom.panelBodies.push(i),typeof e.panel!=`function`&&i.append(...M(e.panel,{tabs:this,item:e,index:t,name:n})),a.append(r),o.append(this.dom.panels[this.dom.panels.length-1])}),n.append(a),r.append(o),this.cleanup.bindings?.(),this.cleanup.bindings=i(n=>(this.dom.tabs.forEach((n,r)=>{let i=n.dataset.tab;t(n,`is-active`,()=>this.state.current.index===r),t(n,`is-disabled`,()=>this.state.disabled.names.includes(i)),e(n,`aria-selected`,()=>this.state.current.index===r),e(n,`aria-disabled`,()=>this.state.disabled.names.includes(i))}),this.dom.panels.forEach((n,r)=>{t(n,`is-active`,()=>this.state.current.index===r),e(n,`aria-hidden`,()=>this.state.current.index!==r)}),n))}_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(Boolean):(()=>{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.tab||null}}_getPanelKey(e,t){return e.name||this.dom.tabs[t]?.dataset.tab||String(t)}_getCachedPanel(e,t){if(!e?.cache)return null;let n=this.runtime.cache.panels.get(this._getPanelKey(e,t));if(!n)return null;let r=bn(e.ttl);return r&&Date.now()-n.updatedAt>r?(this.runtime.cache.panels.delete(this._getPanelKey(e,t)),null):n}_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.panelBodies[e],r=this.props.tabs[e];!n||!r||(n.textContent=``,n.append(...M(t,{tabs:this,item:r,index:e,name:this.dom.tabs[e]?.dataset.tab||r.name||e})))}async _loadPanel(e){let t=this.props.tabs[e],n=this.dom.panelBodies[e];if(!t||!n||typeof t.panel!=`function`){this.runtime.panelLoadId+=1,a(()=>{this.state.loading=!1});return}let r=this._getCachedPanel(t,e);if(r){this.runtime.panelLoadId+=1,a(()=>{this.state.loading=!1}),this._renderPanelContent(e,r.content);return}let i=++this.runtime.panelLoadId;a(()=>{this.state.loading=!0}),n.textContent=``,n.style.minHeight=`80px`,n.appendChild(L());try{let n=await Promise.resolve(t.panel({tabs:this,item:t,index:e,name:this.dom.tabs[e]?.dataset.tab||t.name||e}));if(this.runtime.destroyed||i!==this.runtime.panelLoadId)return;this._setCachedPanel(t,e,n),this._renderPanelContent(e,n)}finally{!this.runtime.destroyed&&i===this.runtime.panelLoadId&&a(()=>{this.state.loading=!1,n.style.minHeight=``})}}get activeIndex(){return this.state.current.index}get disabledNames(){return this.state.disabled.names}bindEvents(){this.unbindEvents();let e=R(`.tab-list`,this.root);e&&this.cleanup.events.on(`tabClick`,e,`click`,e=>{let t=e.target.closest(`.tab-item`);if(!t)return;let n=t.dataset.tab;n&&!this.state.disabled.names.includes(n)&&this.activate(n)})}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.tab===e):-1}async _activate(e,t=!0){let n=this._getIndex(e);if(!(n<0||n>=this.dom.tabs.length||this.state.disabled.names.includes(this.dom.tabs[n]?.dataset.tab)||this.state.current.index===n)&&(a(()=>{this._syncCurrent(n)}),await this._loadPanel(n),t&&this.props.onChange)){let e=this.dom.tabs[n],t=this.dom.panels[n];await Promise.resolve(this.props.onChange(n,e?.dataset.tab||n,e,t))}}async activate(e){this.assertActive(`activate`),await this._activate(e,!0)}build(){this.assertActive(`render`),s(this.dom.container,()=>this.root)}async add(e){this.assertActive(`add`),C(`tabConfig`,e,vn,`Tabs.add`),e.name=e.name||T(),this.props.tabs=[...yn(this.props.tabs),e],this.runtime.cache.panels.clear(),this.rebuildItems(),this.syncActiveNames(this.resolveActiveNames(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 t=this._getIndex(e);if(t<0||t>=this.props.tabs.length)return;let n=this.props.tabs[t].name,{onRemove:r}=this.props;this.props.tabs=this.props.tabs.filter((e,n)=>n!==t),this.runtime.cache.panels.delete(n),this.state.current.index>=this.props.tabs.length?a(()=>{this._syncCurrent(this.props.tabs.length-1)}):this.state.current.index>t&&a(()=>{this._syncCurrent(this.state.current.index-1)}),this.rebuildItems(),this.bindEvents(),await this._loadPanel(this.state.current.index),this._refreshDrag(),r&&await Promise.resolve(r(t,n))}disable(e){this.assertActive(`disable`);let t=typeof e==`number`?this.dom.tabs[e]?.dataset.tab:e;t&&!this.state.disabled.names.includes(t)&&a(()=>{this.state.disabled=this._createDisabledState([...this.state.disabled.names,t])})}enable(e){this.assertActive(`enable`);let t=typeof e==`number`?this.dom.tabs[e]?.dataset.tab:e;t&&a(()=>{this.state.disabled=this._createDisabledState(this.state.disabled.names.filter(e=>e!==t))})}resolveActiveNames(e){return e==null?-1:typeof e==`number`?e:typeof e==`string`?this.dom.tabs.findIndex(t=>t.dataset.tab===e):0}syncActiveNames(e){a(()=>{this._syncCurrent(e)})}async reInit(e={}){this.assertActive(`reInit`),Object.assign(this.props,w(e,_n,`Tabs`)),a(()=>{this.state.disabled=this._parseDisabled(this.props.disabled)}),this.rebuildItems(),this.syncActiveNames(this.resolveActiveNames(this.props.active)),this.bindEvents(),await this._loadPanel(this.state.current.index),this._refreshDrag()}get _dragContainer(){return this.root?R(`.tab-wrap`,this.root):null}get _dragInner(){return this.root?R(`.tab-list`,this.root):null}_initDrag(){let{direction:e}=this.props;if(!this._dragContainer||!this._dragInner)return;let t=e===`left`||e===`right`,n=t?this._dragInner.scrollHeight>this._dragContainer.clientHeight+5:this._dragInner.scrollWidth>this._dragContainer.clientWidth+5;if(a(()=>{this.state.isVertical=t,this.state.draggable=n}),!n){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,n=this.state.isVertical,r=0,i=0,a=0,o=!1,s=e=>n?e.touches?e.touches[0].pageY:e.pageY:e.touches?e.touches[0].pageX:e.pageX,c=o=>{this.isDragging=!0,t.classList.add(`dragging`),r=s(o),a=r,i=n?e.scrollTop:e.scrollLeft,this._velocity=0,cancelAnimationFrame(this.raf)},l=t=>{if(!this.isDragging)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(`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,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.cleanup.bindings?.(),this.cleanup.bindings=null,cancelAnimationFrame(this.raf),cancelAnimationFrame(this._resizeRaf),this.cleanup.events.off(`resize`),this.root?.parentNode&&this.root.parentNode.removeChild(this.root)}};function Sn(e,t={}){return new xn(e,t)}var Cn={en:{b:`Back`,t:`Customize`,d:`Customize your UI experience.`,theme:`Theme`,radius:`Radius`,shadow:`Shadow`,font:`Font`,mode:`Mode`,gray:`Gray`,olive:`Olive`,tomato:`Tomato`,ruby:`Ruby`,pink:`Pink`,violet:`Violet`,indigo:`Indigo`,blue:`Blue`,teal:`Teal`,grass:`Grass`,mint:`Mint`,lime:`Lime`,yellow:`Yellow`,orange:`Orange`,gold:`Gold`,n:`None`,sm:`Small`,md:`Medium`,lg:`Large`,xl:`XL`,round:`Round`,light:`Light`,dark:`Dark`,auto:`Auto`},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:`金色`,n:`无`,sm:`小`,md:`中`,lg:`大`,xl:`更大`,round:`圆角`,light:`浅色`,dark:`深色`,auto:`自动`}},wn=class{constructor(e={}){k(`Theme`),this.props={mode:`dark`,theme:`indigo`,radius:`sm`,shadow:`sm`,font:`sm`,key:`jui-theme`,...e},this.languages=Cn,this._init()}_init(){this.cleanup={events:V()},this.runtime={destroyed:!1},this._loadConfig(),this._bindEvent(),this._syncActiveButtons()}_t(e){return f(e,this.languages)}_loadConfig(){try{let e=H(this.props.key);e&&e.trim()&&(this.props=Object.assign({},this.props,JSON.parse(e)))}catch{}}_saveConfig(){let{mode:e,theme:t,radius:n,shadow:r,font:i}=this.props,a=e===`auto`?this._scheme():e;xe(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`}_syncActiveButtons(){let e=z(`.palette-item`);for(let t of e){let e=t.dataset.palette,n=this.props[e],r=z(`button[data-palette]`,t);for(let e of r){let t=e.dataset.palette===(n===void 0?null:n);e.classList.toggle(`is-active`,t)}}}_bindEvent(){this.cleanup.events.on(`palette`,document.body,`click`,e=>{let t=e.target.closest(`.palette-item .items > button[data-palette]`);if(!t)return;let n=t.closest(`.palette-item`);if(!n)return;let r=n.dataset.palette,i=t.dataset.palette;if(t.classList.contains(`is-active`))return;let a=this.props[r];this.props[r]=i;let o=document.documentElement;if(r===`mode`){let e=i===`auto`?this._scheme():i;o.classList.remove(`light`,`dark`,a),e&&o.classList.add(e)}else{let e={theme:`j-theme-`,radius:`j-radius-`,shadow:`j-shadow-`,font:`j-font-`}[r];if(e){let t=Array.from(o.classList).filter(t=>t.startsWith(e));t.length&&o.classList.remove(...t),o.classList.add(`${e}${i}`)}}this._saveConfig(),this._syncActiveButtons()})}_unbindEvent(){this.cleanup.events.clear()}createPanel(e=`j-theme-palette`,t=null){let n=t||[{title:this._t(`theme`),type:`theme`,buttons:[[`gray`,this._t(`gray`)],[`olive`,this._t(`olive`)],[`tomato`,this._t(`tomato`)],[`ruby`,this._t(`ruby`)],[`pink`,this._t(`pink`)],[`violet`,this._t(`violet`)],[`indigo`,this._t(`indigo`)],[`blue`,this._t(`blue`)],[`teal`,this._t(`teal`)],[`grass`,this._t(`grass`)],[`mint`,this._t(`mint`)],[`lime`,this._t(`lime`)],[`yellow`,this._t(`yellow`)],[`orange`,this._t(`orange`)],[`gold`,this._t(`gold`)]]},{title:this._t(`radius`),type:`radius`,buttons:[[`none`,this._t(`n`)],[`sm`,this._t(`sm`)],[`md`,this._t(`md`)],[`lg`,this._t(`lg`)],[`xl`,this._t(`xl`)],[`round`,this._t(`round`)]]},{title:this._t(`shadow`),type:`shadow`,buttons:[[`none`,this._t(`n`)],[`sm`,this._t(`sm`)],[`md`,this._t(`md`)],[`lg`,this._t(`lg`)]]},{title:this._t(`font`),type:`font`,buttons:[[`sm`,this._t(`sm`)],[`md`,this._t(`md`)]]},{title:this._t(`mode`),type:`mode`,buttons:[[`light`,this._t(`light`)],[`dark`,this._t(`dark`)],[`auto`,this._t(`auto`)]]}];return c(`div`,{className:e,children:[c(`div`,{style:{display:`flex`,justifyContent:`center`},children:c(`button`,{className:`j-button is-text`,"data-action":`close`,children:this._t(`b`)})}),c(`h3`,{children:this._t(`t`)}),c(`p`,{style:{marginTop:0,fontSize:`var(--text-sm, 0.875rem)`},children:this._t(`d`)}),c(`div`,{className:`palette-container`,children:n.map(e=>c(`div`,{className:`palette-item`,"data-palette":e.type,children:[c(`div`,{className:`item-title`,children:e.title}),c(`div`,{className:`items`,children:e.buttons.map(([t,n])=>c(`button`,{className:`j-button is-default${String(this.props[e.type])===String(t)?` is-active`:``}`,"data-palette":t,children:[e.type===`theme`?c(`span`,{className:`el-prefix item-hex`,style:{backgroundColor:`var(--ui-${t})`}}):null,c(`span`,{className:`button-text`,children:n})]}))})]}))})]})}setConfig(e){this.props=Object.assign({},this.props,e),this._saveConfig(),this._syncActiveButtons()}destroy(){this.runtime.destroyed||(this.runtime.destroyed=!0,this._unbindEvent(),this.cleanup=null)}};const Tn={type:`string`,enum:[`info`,`success`,`warning`,`error`,`primary`]},En={type:`number`,validate:e=>e>=0,message:`expects a positive number or 0.`},Dn={type:`number`,validate:e=>e>0,message:`expects a number greater than 0.`};var On=class e{static show(t=``,n=3e3,r=`info`){k(`Toast`),C(`message`,t,`string`,`Toast.show`),C(`duration`,n,En,`Toast.show`),C(`type`,r,Tn,`Toast.show`);let i=e._getOrCreateContainer(),a=T(),o=c(`div`,{className:`j-toast is-${r}`,"data-toast":a,children:[c(`span`,{className:`toast-icon`,children:W(r===`primary`?`info`:r)}),c(`span`,{className:`toast-message`,children:t})]});i.appendChild(o),e._setTimer(a,`show`,()=>{o.classList.add(`is-shown`)},10),n>0&&e._setTimer(a,`hide`,()=>{e.hide(o)},n);let s=B(o,`click`,()=>{e.hide(o)});return e.disposers.set(o,s),o}static success(t=``,n=3e3){return e.show(t,n,`success`)}static info(t=``,n=3e3){return e.show(t,n,`info`)}static primary(t=``,n=3e3){return e.show(t,n,`primary`)}static warning(t=``,n=3e3){return e.show(t,n,`warning`)}static error(t=``,n=3e3){return e.show(t,n,`error`)}static hide(t){if(t){e.disposers.get(t)?.(),e.disposers.delete(t),t.classList.remove(`is-shown`),t.classList.add(`is-hidden`);let n=t.dataset.toast;e._setTimer(n,`remove`,()=>{t.parentNode&&t.parentNode.removeChild(t);let e=R(`.j-toast-container`);e&&e.children.length===0&&e.parentNode.removeChild(e)},300)}}static lite(t=``,n=2e3){k(`Toast`),C(`message`,t,`string`,`Toast.lite`),C(`duration`,n,Dn,`Toast.lite`);let r=R(`.j-toast-lite`);r&&r.remove();let i=T(),a=c(`div`,{className:`j-toast-lite`,"data-toast":i,children:t});return document.body.appendChild(a),e._setTimer(i,`show`,()=>a.classList.add(`is-shown`),10),e._setTimer(i,`hide`,()=>{a.classList.remove(`is-shown`),a.classList.add(`is-hidden`),e._setTimer(i,`remove`,()=>a.remove(),300)},n),a}static action(t=``,n={}){k(`Toast`);let r=e._getOrCreateContainer(),i=T(),a=c(`div`,{className:`j-toast is-action`,"data-toast":i,children:[c(`div`,{className:`toast-message`,children:t}),c(`div`,{className:`toast-action`,children:[c(`button`,{className:`j-button is-sm is-ghost`,children:n.text.cancel||`cancel`,onClick:()=>{a.classList.remove(`is-shown`),a.classList.add(`is-hidden`),e.hide(a)}}),c(`button`,{className:`j-button is-sm is-outline`,children:n.text.action||`action`,onClick:async()=>{await n.onAction?.(),e.hide(a)}})]})]});return r.appendChild(a),e._setTimer(i,`show`,()=>{a.classList.add(`is-shown`)},10),a}static _getOrCreateContainer(){let e=R(`.j-toast-container`);return e||(e=c(`div`,{className:`j-toast-container`}),document.body.appendChild(e)),e}static _setTimer(t,n,r,i){let a=`${t}-${n}`;return e.timers.add(a),_.start(a,i,()=>{e.timers.delete(a),r()}),a}static clearAll(){for(let t of e.timers)_.cancel(t);e.timers.clear();for(let t of e.disposers.values())t();e.disposers.clear(),R(`.j-toast-container`)?.remove(),R(`.j-toast-lite`)?.remove()}};je(On,`timers`,new Set),je(On,`disposers`,new Map);export{Le as Accordion,K as Component,it as Drop,bt as Flow,wt as Menu,Wt as Modal,Ve as Offcanvas,tt as Pagination,Jt as Parabola,nn as Sticky,hn as Swiper,xn as Tabs,wn as Theme,On as Toast,cn as Toc,st as Tooltip,We as Validator,Oe as addIcons,z as all,fe as canRenderDOM,O as canUseDOM,m as copy,Re as createAccordion,at as createDrop,V as createEventManager,xt as createFlow,L as createLoading,Tt as createMenu,Gt as createModal,He as createOffcanvas,nt as createPagination,Yt as createParabola,rn as createSticky,gn as createSwiper,Sn as createTabs,ln as createToc,ct as createTooltip,Ge as createValidator,ae as debounce,ue as destroyAll,H as getCookie,De as getRegistedIconPath,ee as getType,g as hasOwn,W as icon,Te as iconHtml,Ee as iconMarkup,y as isClass,j as isElement,v as isFunction,p as isMobile,A as isNode,b as isPlainObject,I as isRenderableContent,B as listen,M as normalizeContentNodes,ye as postJson,R as q,T as randomId,le as release,Se as removeCookie,F as requireContainer,k as requireRenderDOM,_e as resolveContainer,P as resolveElement,ge as resolveNode,N as resolveNodeList,w as resolveProps,be as restUrl,de as service,xe as setCookie,se as singleton,oe as throttle,_ as timer,ie as uuid,C as validateParam};