@je-es/client 0.2.4 → 0.2.5

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/main.js CHANGED
@@ -1,15 +1,14 @@
1
- import {setConfig,button,i,form,textarea,option,select,input,a,img,p as p$1,h6,h5,h4,h3,h2,h1,span,div,patch,html,createElement,label,createDOMElement}from'@je-es/vdom';export{a,button,createDOMElement,createElement,div,form,h1,h2,h3,h4,h5,h6,html,i,img,input,isVNode,label,option,p,patch,select,span,textarea,validateVNode}from'@je-es/vdom';import {configureApi,api}from'@je-es/capi';export{api,configureApi,getApiConfig,http,resetApiConfig}from'@je-es/capi';var Pe=Object.defineProperty;var Qe=(i,t)=>{for(var e in t)Pe(i,e,{get:t[e],enumerable:true});};var p=(i,t,e,n)=>{for(var r=void 0,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(s(t,e,r))||r);return r&&Pe(t,e,r),r};var q=class{static{this.styles=new Map;}static{this.scopeCounter=0;}static inject(t,e){let n=e||`style-${this.scopeCounter++}`;if(this.styles.has(n))return n;let r=document.createElement("style");r.setAttribute("data-component",n);let o=this.scopeStyles(t,n);return r.textContent=o,document.head.appendChild(r),this.styles.set(n,r),n}static remove(t){let e=this.styles.get(t);e&&e.parentElement&&(e.parentElement.removeChild(e),this.styles.delete(t));}static scopeStyles(t,e){let n=t.split(`
1
+ import {setConfig,button,i,form,textarea,option,select,input,a,img,p as p$1,h6,h5,h4,h3,h2,h1,span,div,patch,html,createElement,label,createDOMElement}from'@je-es/vdom';export{a,button,createDOMElement,createElement,div,form,h1,h2,h3,h4,h5,h6,html,i,img,input,isVNode,label,option,p,patch,select,span,textarea,validateVNode}from'@je-es/vdom';import {configureApi,api}from'@je-es/capi';export{api,configureApi,getApiConfig,http,resetApiConfig}from'@je-es/capi';var Fe=Object.defineProperty;var rt=(i,t)=>{for(var e in t)Fe(i,e,{get:t[e],enumerable:true});};var p=(i,t,e,n)=>{for(var r=void 0,o=i.length-1,s;o>=0;o--)(s=i[o])&&(r=(s(t,e,r))||r);return r&&Fe(t,e,r),r};var q=class{static{this.styles=new Map;}static{this.scopeCounter=0;}static inject(t,e){let n=e||`style-${this.scopeCounter++}`;if(this.styles.has(n))return n;let r=document.createElement("style");r.setAttribute("data-component",n);let o=this.scopeStyles(t,n);return r.textContent=o,document.head.appendChild(r),this.styles.set(n,r),n}static remove(t){let e=this.styles.get(t);e&&e.parentElement&&(e.parentElement.removeChild(e),this.styles.delete(t));}static scopeStyles(t,e){let n=t.split(`
2
2
  `),r=[],s=0;for(let a of n){if(a=a.trim(),a.startsWith("@media")){r.push(a);continue}if(s+=(a.match(/{/g)||[]).length,s-=(a.match(/}/g)||[]).length,a.includes("{")&&!a.startsWith("@")&&!a.startsWith("}")){let l=a.substring(0,a.indexOf("{")).trim(),c=a.substring(a.indexOf("{"));if(l===":root"||l==="*"||a.startsWith("@"))r.push(a);else {let u=`[data-scope="${e}"] ${l}`;r.push(`${u} ${c}`);}}else r.push(a);}return r.join(`
3
- `)}static clear(){for(let[,t]of this.styles)t.parentElement&&t.parentElement.removeChild(t);this.styles.clear();}};function Ve(i,...t){let e="";for(let n=0;n<i.length;n++)e+=i[n],n<t.length&&(e+=t[n]);return e}var oe=class{constructor(){this.queue=new Set;this.isFlushScheduled=false;this.isFlushing=false;}schedule(t){if(this.isFlushing){requestAnimationFrame(()=>this.schedule(t));return}this.queue.add(t),this.isFlushScheduled||(this.isFlushScheduled=true,Promise.resolve().then(()=>{requestAnimationFrame(()=>this.flush());}));}flushSync(t){t();}flush(){if(this.queue.size===0){this.isFlushScheduled=false;return}this.isFlushing=true,this.isFlushScheduled=false;let t=Array.from(this.queue);this.queue.clear();for(let e of t)try{e();}catch(n){console.error("Error during update:",n);}this.isFlushing=false,this.queue.size>0&&this.schedule(()=>{});}clear(){this.queue.clear(),this.isFlushScheduled=false;}get size(){return this.queue.size}},W=new oe;var b=class{constructor(t,e){this._isMounted=false;this._isUnmounting=false;this._element=null;this._vnode=null;this._styleId=null;this._isScheduledForUpdate=false;this._updateBatch=new Set;this._refs=new Map;this._subscriptions=[];this._memoCache=new Map;this._isInitializing=false;this._skipNextUpdate=false;this._preservedElements=new Map;this._updateInProgress=false;this.props=t||{},this.state=e||{};}setState(t,e){if(this._isInitializing){let s=typeof t=="function"?t(this.state):t;this.state={...this.state,...s};return}if(this._isUnmounting)return;let n={...this.state},r=typeof t=="function"?t(this.state):t,o=false;for(let s in r)if(n[s]!==r[s]){o=true;break}if(!o){e&&W.schedule(e);return}this.state={...this.state,...r},this.onStateChange?.(n,this.state),this.update(),e&&W.schedule(e);}setProps(t){if(this._isUnmounting)return;let e={...this.props},n=false;for(let r in t)if(e[r]!==t[r]){n=true;break}n&&(this.props={...this.props,...t},this.onPropsChange?.(e,this.props),this.update());}batchUpdate(t){let e=this._isScheduledForUpdate;this._isScheduledForUpdate=true;try{t();}finally{e||(this._isScheduledForUpdate=false,this.update());}}update(t){if(this._skipNextUpdate){this._skipNextUpdate=false;return}this._isInitializing||this._isUnmounting||!this._isMounted||this._updateInProgress||(t&&this._updateBatch.add(t),!this._isScheduledForUpdate&&(this._isScheduledForUpdate=true,W.schedule(()=>{this._isScheduledForUpdate=false,this._updateBatch.clear(),this._performUpdate();})));}forceUpdate(){!this._isMounted||this._isUnmounting||this._updateInProgress||W.flushSync(()=>{this._performUpdate();});}skipNextUpdate(){this._skipNextUpdate=true;}beginInitialization(){this._isInitializing=true;}endInitialization(){this._isInitializing=false;}async mount(t){if(this._isMounted){console.warn(`Component ${this.constructor.name} is already mounted`);return}if(!t)throw new Error(`Cannot mount ${this.constructor.name}: container is null or undefined`);try{this._isInitializing=!0,await this.onBeforeMount?.(),this._vnode=this.render(),this._element=this._createElementFromVNode(this._vnode),this.styles&&(this._styleId=q.inject(this.styles(),this.constructor.name),this._element?.setAttribute("data-scope",this.constructor.name)),t.appendChild(this._element),this._isMounted=!0,this._isInitializing=!1,await this.onMount?.();}catch(e){throw this._isInitializing=false,this._isMounted=false,this._handleError(e,{componentStack:this.constructor.name}),e}}unmount(){if(!(!this._isMounted||this._isUnmounting)){this._isUnmounting=true;try{this.onBeforeUnmount?.(),this._isScheduledForUpdate=!1,this._updateBatch.clear(),this._styleId&&(q.remove(this._styleId),this._styleId=null),this._subscriptions.forEach(t=>{try{t();}catch(e){console.error("Error during unsubscribe:",e);}}),this._subscriptions=[],this._element?.parentElement&&this._element.parentElement.removeChild(this._element),this._isMounted=!1,this._element=null,this._vnode=null,this.onUnmount?.(),this._refs.clear(),this._memoCache.clear(),this._preservedElements.clear();}catch(t){this._handleError(t,{componentStack:this.constructor.name});}finally{this._isUnmounting=false;}}}getRef(t){return this._refs.get(t)}createRef(t){return e=>{e?this._refs.set(t,e):this._refs.delete(t);}}memo(t,e,n){let r=this._memoCache.get(t);if(r&&this._areDepsEqual(r.args,n))return r.result;let o=e();return this._memoCache.set(t,{args:n,result:o}),o}subscribe(t){this._subscriptions.push(t);}debounce(t,e){let n=null;return (...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,t.apply(this,r);},e);}}throttle(t,e){let n=0,r=null;return (...o)=>{let s=Date.now(),a=s-n;a>=e?(n=s,t.apply(this,o)):r||(r=setTimeout(()=>{n=Date.now(),r=null,t.apply(this,o);},e-a));}}get element(){return this._element}get isMounted(){return this._isMounted}get isUnmounting(){return this._isUnmounting}get isInitializing(){return this._isInitializing}async _performUpdate(){if(!this._isMounted||!this._element||this._isUnmounting||this._isInitializing||this._updateInProgress)return;this._updateInProgress=true;let t={...this.props},e={...this.state};try{if(this.shouldUpdate&&!this.shouldUpdate(t,e))return;await this.onBeforeUpdate?.(t,e),this._preserveComponentMounts();let n=this.render(),r=this._element.parentElement;if(this._vnode&&r){let o=Array.from(r.childNodes).indexOf(this._element);if(o===-1){console.warn(`Component ${this.constructor.name} element removed from parent, skipping update`);return}let s=this._convertToVDomNode(this._vnode),a=this._convertToVDomNode(n);patch(r,s,a,o),this._element=r.childNodes[o];}this._vnode=n,this._restoreComponentMounts(),this.onUpdate?.(t,e);}catch(n){this._handleError(n,{componentStack:this.constructor.name});}finally{this._updateInProgress=false;}}_preserveComponentMounts(){if(!this._element)return;this._preservedElements.clear(),["[data-language-dropdown-mount]","[data-user-dropdown-mount]","[data-notifications-dropdown-mount]","[data-dropdown-id]","[data-preserve]","[data-toast-mount]","[data-popup-mount]","[data-loader-mount]","[data-navbar-notifications-list]"].forEach(e=>{this._element.querySelectorAll(e).forEach(r=>{r.children.length>0&&r.parentElement&&this._preservedElements.set(r,{parent:r,children:Array.from(r.childNodes)});});});}_restoreComponentMounts(){this._element&&(this._preservedElements.forEach((t,e)=>{let n=null,r=Array.from(e.attributes);for(let o of r)if(o.name.startsWith("data-")){let s=`[${o.name}="${o.value}"]`;if(n=this._element.querySelector(s),n)break}if(n&&t.children.length>0){for(;n.firstChild;)n.removeChild(n.firstChild);t.children.forEach(o=>{n.appendChild(o);});}}),this._preservedElements.clear());}_convertToVDomNode(t){if(typeof t.type!="string")throw new Error("Component VNodes cannot be converted to VDom nodes");let e={};for(let[r,o]of Object.entries(t.props))r!=="children"&&(e[r]=o);let n=t.children.map(r=>r==null||typeof r=="boolean"?null:typeof r=="string"||typeof r=="number"?r:this._convertToVDomNode(r)).filter(r=>r!==null);return {type:t.type,props:e,children:n}}_createElementFromVNode(t){if(typeof t.type!="string")throw new Error("Component VNodes not supported in _createElementFromVNode");let e=document.createElement(t.type);for(let[n,r]of Object.entries(t.props))n!=="children"&&this._setElementProperty(e,n,r);for(let n of t.children)n==null||n===false||(typeof n=="string"||typeof n=="number"?e.appendChild(document.createTextNode(String(n))):typeof n=="object"&&"type"in n&&e.appendChild(this._createElementFromVNode(n)));return e}_setElementProperty(t,e,n){if(e.startsWith("on")&&typeof n=="function"){let r=e.substring(2).toLowerCase();t.addEventListener(r,n);return}if(e==="className"&&typeof n=="string"){t.className=n;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n!==null&&Object.assign(t.style,n);return}if(e==="ref"&&typeof n=="function"){n(t);return}if(e==="checked"||e==="disabled"||e==="selected"){(n==="true"||n===true||n==="")&&t.setAttribute(e,"");return}n!=null&&n!==false&&t.setAttribute(e,String(n));}_handleError(t,e){if(console.error(`Error in component ${this.constructor.name}:`,t),console.error("Component stack:",e.componentStack),this.onError)this.onError(t,e);else throw t}_areDepsEqual(t,e){return t.length!==e.length?false:t.every((n,r)=>Object.is(n,e[r]))}_invalidateAllComputed(){for(let t in this)t.startsWith("_computed_dirty_")&&(this[t]=true);}_triggerWatchers(t,e,n){let r=this.constructor.__watchers__;if(r?.[t]){for(let o of r[t])if(typeof this[o]=="function")try{this[o].call(this,e,n);}catch(s){console.error(`Watcher error in ${o}:`,s);}}}setElement(t){this._element=t;}};function f(i,t){if(t&&typeof t=="object"&&"kind"in t){let s=t.name;return t.addInitializer(function(){let a=this;a.constructor.__reactiveProps__||(a.constructor.__reactiveProps__=[]),a.constructor.__reactiveProps__.includes(s)||a.constructor.__reactiveProps__.push(s);}),function(a){let l=this,c=`_state_${s}`;return l[c]=a,Object.defineProperty(this,s,{get(){return this[c]},set(u){let h=this,y=h[c];y!==u&&(h[c]=u,typeof h._invalidateAllComputed=="function"&&h._invalidateAllComputed(),typeof h._triggerWatchers=="function"&&h._triggerWatchers(s,u,y),h._isMounted&&typeof h.update=="function"&&h.update());},enumerable:true,configurable:true}),a}}let e=t,n=i.constructor;n.__reactiveProps__||(n.__reactiveProps__=[]),n.__reactiveProps__.includes(e)||n.__reactiveProps__.push(e);let r=`_state_${e}`,o=`_state_init_${e}`;Object.defineProperty(i,e,{get(){let s=this;if(s[o])return s[r]},set(s){let a=this;if(!a[o]){a[r]=s,a[o]=true;return}let l=a[r];l!==s&&(a[r]=s,typeof a._invalidateAllComputed=="function"&&a._invalidateAllComputed(),typeof a._triggerWatchers=="function"&&a._triggerWatchers(e,s,l),a._isMounted&&typeof a.update=="function"&&a.update());},enumerable:true,configurable:true});}function wn(i,t,e){if(t&&typeof t=="object"&&"kind"in t){let a=t;if(a.kind!=="getter")throw new Error("@computed can only be used on getters");let l=i,c=a.name,u=`_computed_cache_${c}`,h=`_computed_dirty_${c}`;return function(){let y=this;return y[h]===void 0&&(y[h]=true),y[h]===true&&(y[u]=l.call(this),y[h]=false),y[u]}}let n=t;if(!e)throw new Error("@computed requires a property descriptor");let r=e.get;if(!r)throw new Error("@computed can only be used on getters");let o=`_computed_cache_${n}`,s=`_computed_dirty_${n}`;return {get(){let a=this;return a[s]===void 0&&(a[s]=true),a[s]===true&&(a[o]=r.call(this),a[s]=false),a[o]},enumerable:e.enumerable,configurable:e.configurable}}function Tn(i){function t(e,n,r){if(n&&typeof n=="object"&&"kind"in n){if(n.kind!=="method")throw new Error("@watch can only be used on methods");let l=n.name;n.addInitializer(function(){let c=this;c.constructor.__watchers__||(c.constructor.__watchers__={}),c.constructor.__watchers__[i]||(c.constructor.__watchers__[i]=[]),c.constructor.__watchers__[i].includes(l)||c.constructor.__watchers__[i].push(l);});return}let o=n;if(!r)throw new Error("@watch requires a property descriptor");let a=e.constructor;return a.__watchers__||(a.__watchers__={}),a.__watchers__[i]||(a.__watchers__[i]=[]),a.__watchers__[i].includes(o)||a.__watchers__[i].push(o),r}return t}var X=class{constructor(t){this._subscribers=new Set;this._value=t,this._defaultValue=t;}get value(){return this._value}set value(t){this._value!==t&&(this._value=t,this._notify());}subscribe(t){this._subscribers.add(t);try{t(this._value);}catch(e){console.error("Context subscriber error:",e);}return ()=>{this._subscribers.delete(t);}}reset(){this.value=this._defaultValue;}update(t){this.value=t(this._value);}_notify(){for(let t of this._subscribers)try{t(this._value);}catch(e){console.error("Context subscriber error:",e);}}get subscriberCount(){return this._subscribers.size}};function xn(i){return new X(i)}var Ne=class extends b{onMount(){this.props.context.value=this.props.value;}onUpdate(){this.props.context.value=this.props.value;}onUnmount(){}render(){let t=Array.isArray(this.props.children)?this.props.children:[this.props.children];return html`
3
+ `)}static clear(){for(let[,t]of this.styles)t.parentElement&&t.parentElement.removeChild(t);this.styles.clear();}};function Re(i,...t){let e="";for(let n=0;n<i.length;n++)e+=i[n],n<t.length&&(e+=t[n]);return e}var ae=class{constructor(){this.queue=new Set;this.isFlushScheduled=false;this.isFlushing=false;}schedule(t){if(this.isFlushing){requestAnimationFrame(()=>this.schedule(t));return}this.queue.add(t),this.isFlushScheduled||(this.isFlushScheduled=true,Promise.resolve().then(()=>{requestAnimationFrame(()=>this.flush());}));}flushSync(t){t();}flush(){if(this.queue.size===0){this.isFlushScheduled=false;return}this.isFlushing=true,this.isFlushScheduled=false;let t=Array.from(this.queue);this.queue.clear();for(let e of t)try{e();}catch(n){console.error("Error during update:",n);}this.isFlushing=false,this.queue.size>0&&this.schedule(()=>{});}clear(){this.queue.clear(),this.isFlushScheduled=false;}get size(){return this.queue.size}},W=new ae;var b=class{constructor(t,e){this._isMounted=false;this._isUnmounting=false;this._element=null;this._vnode=null;this._styleId=null;this._isScheduledForUpdate=false;this._updateBatch=new Set;this._refs=new Map;this._subscriptions=[];this._memoCache=new Map;this._isInitializing=false;this._skipNextUpdate=false;this._preservedElements=new Map;this._updateInProgress=false;this.props=t||{},this.state=e||{};}setState(t,e){if(this._isInitializing){let s=typeof t=="function"?t(this.state):t;this.state={...this.state,...s};return}if(this._isUnmounting)return;let n={...this.state},r=typeof t=="function"?t(this.state):t,o=false;for(let s in r)if(n[s]!==r[s]){o=true;break}if(!o){e&&W.schedule(e);return}this.state={...this.state,...r},this.onStateChange?.(n,this.state),this.update(),e&&W.schedule(e);}setProps(t){if(this._isUnmounting)return;let e={...this.props},n=false;for(let r in t)if(e[r]!==t[r]){n=true;break}n&&(this.props={...this.props,...t},this.onPropsChange?.(e,this.props),this.update());}batchUpdate(t){let e=this._isScheduledForUpdate;this._isScheduledForUpdate=true;try{t();}finally{e||(this._isScheduledForUpdate=false,this.update());}}update(t){if(this._skipNextUpdate){this._skipNextUpdate=false;return}this._isInitializing||this._isUnmounting||!this._isMounted||this._updateInProgress||(t&&this._updateBatch.add(t),!this._isScheduledForUpdate&&(this._isScheduledForUpdate=true,W.schedule(()=>{this._isScheduledForUpdate=false,this._updateBatch.clear(),this._performUpdate();})));}forceUpdate(){!this._isMounted||this._isUnmounting||this._updateInProgress||W.flushSync(()=>{this._performUpdate();});}skipNextUpdate(){this._skipNextUpdate=true;}beginInitialization(){this._isInitializing=true;}endInitialization(){this._isInitializing=false;}async mount(t){if(this._isMounted){console.warn(`Component ${this.constructor.name} is already mounted`);return}if(!t)throw new Error(`Cannot mount ${this.constructor.name}: container is null or undefined`);try{this._isInitializing=!0,await this.onBeforeMount?.(),this._vnode=this.render(),this._element=this._createElementFromVNode(this._vnode),this.styles&&(this._styleId=q.inject(this.styles(),this.constructor.name),this._element?.setAttribute("data-scope",this.constructor.name)),t.appendChild(this._element),this._isMounted=!0,this._isInitializing=!1,await this.onMount?.();}catch(e){throw this._isInitializing=false,this._isMounted=false,this._handleError(e,{componentStack:this.constructor.name}),e}}unmount(){if(!(!this._isMounted||this._isUnmounting)){this._isUnmounting=true;try{this.onBeforeUnmount?.(),this._isScheduledForUpdate=!1,this._updateBatch.clear(),this._styleId&&(q.remove(this._styleId),this._styleId=null),this._subscriptions.forEach(t=>{try{t();}catch(e){console.error("Error during unsubscribe:",e);}}),this._subscriptions=[],this._element?.parentElement&&this._element.parentElement.removeChild(this._element),this._isMounted=!1,this._element=null,this._vnode=null,this.onUnmount?.(),this._refs.clear(),this._memoCache.clear(),this._preservedElements.clear();}catch(t){this._handleError(t,{componentStack:this.constructor.name});}finally{this._isUnmounting=false;}}}getRef(t){return this._refs.get(t)}createRef(t){return e=>{e?this._refs.set(t,e):this._refs.delete(t);}}memo(t,e,n){let r=this._memoCache.get(t);if(r&&this._areDepsEqual(r.args,n))return r.result;let o=e();return this._memoCache.set(t,{args:n,result:o}),o}subscribe(t){this._subscriptions.push(t);}debounce(t,e){let n=null;return (...r)=>{n!==null&&clearTimeout(n),n=setTimeout(()=>{n=null,t.apply(this,r);},e);}}throttle(t,e){let n=0,r=null;return (...o)=>{let s=Date.now(),a=s-n;a>=e?(n=s,t.apply(this,o)):r||(r=setTimeout(()=>{n=Date.now(),r=null,t.apply(this,o);},e-a));}}get element(){return this._element}get isMounted(){return this._isMounted}get isUnmounting(){return this._isUnmounting}get isInitializing(){return this._isInitializing}async _performUpdate(){if(!this._isMounted||!this._element||this._isUnmounting||this._isInitializing||this._updateInProgress)return;this._updateInProgress=true;let t={...this.props},e={...this.state};try{if(this.shouldUpdate&&!this.shouldUpdate(t,e))return;await this.onBeforeUpdate?.(t,e),this._preserveComponentMounts();let n=this.render(),r=this._element.parentElement;if(this._vnode&&r){let o=Array.from(r.childNodes).indexOf(this._element);if(o===-1){console.warn(`Component ${this.constructor.name} element removed from parent, skipping update`);return}let s=this._convertToVDomNode(this._vnode),a=this._convertToVDomNode(n);patch(r,s,a,o),this._element=r.childNodes[o];}this._vnode=n,this._restoreComponentMounts(),this.onUpdate?.(t,e);}catch(n){this._handleError(n,{componentStack:this.constructor.name});}finally{this._updateInProgress=false;}}_preserveComponentMounts(){if(!this._element)return;this._preservedElements.clear(),["[data-language-dropdown-mount]","[data-user-dropdown-mount]","[data-notifications-dropdown-mount]","[data-dropdown-id]","[data-preserve]","[data-toast-mount]","[data-popup-mount]","[data-loader-mount]","[data-navbar-notifications-list]"].forEach(e=>{this._element.querySelectorAll(e).forEach(r=>{r.children.length>0&&r.parentElement&&this._preservedElements.set(r,{parent:r,children:Array.from(r.childNodes)});});});}_restoreComponentMounts(){this._element&&(this._preservedElements.forEach((t,e)=>{let n=null,r=Array.from(e.attributes);for(let o of r)if(o.name.startsWith("data-")){let s=`[${o.name}="${o.value}"]`;if(n=this._element.querySelector(s),n)break}if(n&&t.children.length>0){for(;n.firstChild;)n.removeChild(n.firstChild);t.children.forEach(o=>{n.appendChild(o);});}}),this._preservedElements.clear());}_convertToVDomNode(t){if(typeof t.type!="string")throw new Error("Component VNodes cannot be converted to VDom nodes");let e={};for(let[r,o]of Object.entries(t.props))r!=="children"&&(e[r]=o);let n=t.children.map(r=>r==null||typeof r=="boolean"?null:typeof r=="string"||typeof r=="number"?r:this._convertToVDomNode(r)).filter(r=>r!==null);return {type:t.type,props:e,children:n}}_createElementFromVNode(t){if(typeof t.type!="string")throw new Error("Component VNodes not supported in _createElementFromVNode");let e=document.createElement(t.type);for(let[n,r]of Object.entries(t.props))n!=="children"&&this._setElementProperty(e,n,r);for(let n of t.children)n==null||n===false||(typeof n=="string"||typeof n=="number"?e.appendChild(document.createTextNode(String(n))):typeof n=="object"&&"type"in n&&e.appendChild(this._createElementFromVNode(n)));return e}_setElementProperty(t,e,n){if(e.startsWith("on")&&typeof n=="function"){let r=e.substring(2).toLowerCase();t.addEventListener(r,n);return}if(e==="className"&&typeof n=="string"){t.className=n;return}if(e==="style"){typeof n=="string"?t.setAttribute("style",n):typeof n=="object"&&n!==null&&Object.assign(t.style,n);return}if(e==="ref"&&typeof n=="function"){n(t);return}if(e==="checked"||e==="disabled"||e==="selected"){(n==="true"||n===true||n==="")&&t.setAttribute(e,"");return}n!=null&&n!==false&&t.setAttribute(e,String(n));}_handleError(t,e){if(console.error(`Error in component ${this.constructor.name}:`,t),console.error("Component stack:",e.componentStack),this.onError)this.onError(t,e);else throw t}_areDepsEqual(t,e){return t.length!==e.length?false:t.every((n,r)=>Object.is(n,e[r]))}_invalidateAllComputed(){for(let t in this)t.startsWith("_computed_dirty_")&&(this[t]=true);}_triggerWatchers(t,e,n){let r=this.constructor.__watchers__;if(r?.[t]){for(let o of r[t])if(typeof this[o]=="function")try{this[o].call(this,e,n);}catch(s){console.error(`Watcher error in ${o}:`,s);}}}setElement(t){this._element=t;}};function f(i,t){if(t&&typeof t=="object"&&"kind"in t){let s=t.name;return t.addInitializer(function(){let a=this;a.constructor.__reactiveProps__||(a.constructor.__reactiveProps__=[]),a.constructor.__reactiveProps__.includes(s)||a.constructor.__reactiveProps__.push(s);}),function(a){let l=this,c=`_state_${s}`;return l[c]=a,Object.defineProperty(this,s,{get(){return this[c]},set(u){let h=this,y=h[c];y!==u&&(h[c]=u,typeof h._invalidateAllComputed=="function"&&h._invalidateAllComputed(),typeof h._triggerWatchers=="function"&&h._triggerWatchers(s,u,y),h._isMounted&&typeof h.update=="function"&&h.update());},enumerable:true,configurable:true}),a}}let e=t,n=i.constructor;n.__reactiveProps__||(n.__reactiveProps__=[]),n.__reactiveProps__.includes(e)||n.__reactiveProps__.push(e);let r=`_state_${e}`,o=`_state_init_${e}`;Object.defineProperty(i,e,{get(){let s=this;if(s[o])return s[r]},set(s){let a=this;if(!a[o]){a[r]=s,a[o]=true;return}let l=a[r];l!==s&&(a[r]=s,typeof a._invalidateAllComputed=="function"&&a._invalidateAllComputed(),typeof a._triggerWatchers=="function"&&a._triggerWatchers(e,s,l),a._isMounted&&typeof a.update=="function"&&a.update());},enumerable:true,configurable:true});}function Pn(i,t,e){if(t&&typeof t=="object"&&"kind"in t){let a=t;if(a.kind!=="getter")throw new Error("@computed can only be used on getters");let l=i,c=a.name,u=`_computed_cache_${c}`,h=`_computed_dirty_${c}`;return function(){let y=this;return y[h]===void 0&&(y[h]=true),y[h]===true&&(y[u]=l.call(this),y[h]=false),y[u]}}let n=t;if(!e)throw new Error("@computed requires a property descriptor");let r=e.get;if(!r)throw new Error("@computed can only be used on getters");let o=`_computed_cache_${n}`,s=`_computed_dirty_${n}`;return {get(){let a=this;return a[s]===void 0&&(a[s]=true),a[s]===true&&(a[o]=r.call(this),a[s]=false),a[o]},enumerable:e.enumerable,configurable:e.configurable}}function Vn(i){function t(e,n,r){if(n&&typeof n=="object"&&"kind"in n){if(n.kind!=="method")throw new Error("@watch can only be used on methods");let l=n.name;n.addInitializer(function(){let c=this;c.constructor.__watchers__||(c.constructor.__watchers__={}),c.constructor.__watchers__[i]||(c.constructor.__watchers__[i]=[]),c.constructor.__watchers__[i].includes(l)||c.constructor.__watchers__[i].push(l);});return}let o=n;if(!r)throw new Error("@watch requires a property descriptor");let a=e.constructor;return a.__watchers__||(a.__watchers__={}),a.__watchers__[i]||(a.__watchers__[i]=[]),a.__watchers__[i].includes(o)||a.__watchers__[i].push(o),r}return t}var X=class{constructor(t){this._subscribers=new Set;this._value=t,this._defaultValue=t;}get value(){return this._value}set value(t){this._value!==t&&(this._value=t,this._notify());}subscribe(t){this._subscribers.add(t);try{t(this._value);}catch(e){console.error("Context subscriber error:",e);}return ()=>{this._subscribers.delete(t);}}reset(){this.value=this._defaultValue;}update(t){this.value=t(this._value);}_notify(){for(let t of this._subscribers)try{t(this._value);}catch(e){console.error("Context subscriber error:",e);}}get subscriberCount(){return this._subscribers.size}};function On(i){return new X(i)}var Oe=class extends b{onMount(){this.props.context.value=this.props.value;}onUpdate(){this.props.context.value=this.props.value;}onUnmount(){}render(){let t=Array.isArray(this.props.children)?this.props.children:[this.props.children];return html`
4
4
  <div class="context-provider" style="display: contents;">
5
5
  ${t}
6
6
  </div>
7
- `}};function En(i,t){let e=i.subscribe(()=>{t.isMounted&&t.update();});return t.subscribe(()=>e),i.value}var se=class{constructor(t){this.contexts=new Map;for(let[e,n]of Object.entries(t))this.contexts.set(e,new X(n));}get(t){let e=this.contexts.get(t);if(!e)throw new Error(`Context key "${String(t)}" not found`);return e}set(t,e){let n=this.contexts.get(t);n&&(n.value=e);}subscribe(t,e){let n=this.contexts.get(t);if(!n)throw new Error(`Context key "${String(t)}" not found`);return n.subscribe(e)}reset(){for(let t of this.contexts.values())t.reset();}};function kn(i){return new se(i)}var E=null,U=0,ae=new WeakMap;function et(i){E=i,U=0;}function tt(){E=null,U=0;}function ee(i){return ae.has(i)||ae.set(i,[]),ae.get(i)}function N(i){if(!E)throw new Error("useState must be called inside a component");let t=E,e=U++,n=ee(t);n[e]===void 0&&(n[e]={value:typeof i=="function"?i():i});let r=o=>{let s=n[e],a=typeof o=="function"?o(s.value):o;s.value!==a&&(s.value=a,t.update());};return [n[e].value,r]}function R(i,t){if(!E)throw new Error("useEffect must be called inside a component");let e=E,n=U++,r=ee(e),o=r[n];if(!o||!t||!Re(o.deps,t)){if(o?.value&&typeof o.value=="function")try{o.value();}catch(a){console.error("Error in effect cleanup:",a);}Promise.resolve().then(()=>{try{let a=i();r[n]={value:a,deps:t?[...t]:void 0};}catch(a){console.error("Error in effect:",a);}});}}function nt(i,t){if(!E)throw new Error("useMemo must be called inside a component");let e=U++,n=ee(E),r=n[e];return (!r||!Re(r.deps,t))&&(n[e]={value:i(),deps:[...t]}),n[e].value}function le(i,t){return nt(()=>i,t)}function ce(i){if(!E)throw new Error("useRef must be called inside a component");let t=U++,e=ee(E);return e[t]===void 0&&(e[t]={value:{current:i}}),e[t].value}function In(i,t){let[e,n]=N(t),r=le(o=>{n(s=>i(s,o));},[i]);return [e,r]}function Pn(i,t){let[e,n]=N(()=>{try{let o=window.localStorage.getItem(i);return o?JSON.parse(o):t}catch(o){return console.error("Error loading from localStorage:",o),t}});return [e,o=>{n(s=>{let a=o instanceof Function?o(s):o;try{window.localStorage.setItem(i,JSON.stringify(a));}catch(l){console.error("Error saving to localStorage:",l);}return a});}]}function Vn(i,t){let[e,n]=N(i);return R(()=>{let r=setTimeout(()=>{n(i);},t);return ()=>{clearTimeout(r);}},[i,t]),e}function Nn(i){let t=ce(void 0);return R(()=>{t.current=i;}),t.current}function Rn(i=false){let[t,e]=N(i),n=le(()=>{e(r=>!r);},[]);return [t,n]}function Fn(i,t){let e=ce(i);R(()=>{e.current=i;},[i]),R(()=>{if(t===null)return;let n=setInterval(()=>e.current(),t);return ()=>clearInterval(n)},[t]);}function On(i,t){let[e,n]=N(null),[r,o]=N(true),[s,a]=N(null),l=le(async()=>{o(true),a(null);try{let c=await fetch(i,t);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);let u=await c.json();n(u);}catch(c){a(c);}finally{o(false);}},[i]);return R(()=>{l();},[l]),{data:e,loading:r,error:s,refetch:l}}function Bn(){let[i,t]=N({width:window.innerWidth,height:window.innerHeight});return R(()=>{let e=()=>{t({width:window.innerWidth,height:window.innerHeight});};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i}function An(i,t,e=window){let n=ce(t);R(()=>{n.current=t;},[t]),R(()=>{if(!(e&&"addEventListener"in e))return;let o=s=>{n.current(s);};return e.addEventListener(i,o),()=>{e.removeEventListener(i,o);}},[i,e]);}function Kn(i,t){class e extends b{render(){et(this);try{return i(this.props)}finally{tt();}}}return t&&Object.defineProperty(e,"name",{value:t}),e}function Re(i,t){if(!i||i.length!==t.length)return false;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return false;return true}var ue=class{constructor(){this.routes=[];this.currentRoute=null;this.mode="history";this.base="/";this.beforeEachHooks=[];this.afterEachHooks=[];this.currentComponent=null;this.routerOutlet=null;this.isNavigating=false;this.scrollBehavior="auto";this.notFoundHandler=null;this._internalPath=null;}init(t,e="history",n="/",r="auto"){this.routes=t,this.mode=e,this.base=n.endsWith("/")?n.slice(0,-1):n,this.scrollBehavior=r,this._initializeRouting(),this._handleRoute();}async push(t,e){this.isNavigating&&(this.isNavigating=false),this._internalPath=t,this.mode==="history"?window.history.pushState(e||{},"",this._buildFullPath(t)):window.location.hash=t,await this._handleRoute();}async replace(t,e){return this._internalPath=t,this.mode==="history"?window.history.replaceState(e||{},"",this._buildFullPath(t)):window.location.hash=t,this._handleRoute()}back(){window.history.back();}forward(){window.history.forward();}go(t){window.history.go(t);}beforeEach(t){this.beforeEachHooks.push(t);}afterEach(t){this.afterEachHooks.push(t);}onNotFound(t){this.notFoundHandler=t;}getCurrentRoute(){return this.currentRoute?{...this.currentRoute}:null}isActive(t,e=false){return this.currentRoute?e?this.currentRoute.path===t:this.currentRoute.path.startsWith(t):false}outlet(){return createElement("div",{"data-router-outlet":"true",style:"display: contents;"})}getRoute(t){return this.routes.find(e=>e.name===t)}async pushNamed(t,e){let n=this.getRoute(t);if(!n){console.error(`Route with name "${t}" not found`);return}let r=n.path;if(e)for(let[o,s]of Object.entries(e))r=r.replace(`:${o}`,s);return this.push(r)}resolve(t){let e=this._matchRoute(t);if(!e)return null;let{route:n,params:r}=e;return {path:t,params:r,query:this._parseQuery(t),meta:n.meta||{},hash:t.includes("#")?t.split("#")[1]:"",name:n.name}}_initializeRouting(){window.addEventListener("popstate",()=>{this._internalPath=null,this._handleRoute();}),this.mode==="hash"&&window.addEventListener("hashchange",()=>{this._internalPath=null,this._handleRoute();}),document.addEventListener("click",t=>{let e=t.target.closest("a[href]");if(e&&this._shouldInterceptLink(e)){t.preventDefault();let n=e.getAttribute("href");if(n){let r=this.mode==="hash"&&n.startsWith("#")?n.substring(1):n.replace(this.base,"");this.push(r);}}});}_shouldInterceptLink(t){return !!(t.getAttribute("href")&&t.hostname===window.location.hostname&&t.target!=="_blank"&&!t.hasAttribute("download")&&t.rel!=="external")}async _handleRoute(){if(!this.isNavigating){this.isNavigating=true;try{let t=this._getCurrentPath(),e=this._matchRoute(t);if(!e){this._handleNotFound(t);return}let{route:n,params:r}=e,o=this._buildRouteObject(t,r,n),s=this.currentRoute||this._buildEmptyRoute();if(!await this._runNavigationGuards(n,o,s))return;this.currentRoute=o,await this._renderComponent(n),this._handleScrollBehavior(o,s),n.meta?.title&&typeof n.meta.title=="string"&&(document.title=n.meta.title),this.afterEachHooks.forEach(l=>l(o,s));}catch(t){console.error("Router error:",t);}finally{this.isNavigating=false;}}}_handleNotFound(t){console.warn(`No route matched for path: ${t}`),this.currentRoute={path:t,params:{},query:this._parseQuery(),meta:{},hash:window.location.hash.substring(1)},this.notFoundHandler&&this.notFoundHandler();}_buildRouteObject(t,e,n){return {path:t,params:e,query:this._parseQuery(),meta:n.meta||{},hash:window.location.hash.substring(1),name:n.name}}_buildEmptyRoute(){return {path:"",params:{},query:{},meta:{},hash:""}}async _runNavigationGuards(t,e,n){if(t.beforeEnter&&!await this._runGuard(t.beforeEnter,e,n))return false;for(let r of this.beforeEachHooks)if(!await this._runGuard(r,e,n))return false;return true}_runGuard(t,e,n){return new Promise(r=>{t(e,n,o=>{o===false?r(false):typeof o=="string"?(this.push(o),r(false)):r(true);});})}async _renderComponent(t){if(!this.routerOutlet&&(this.routerOutlet=document.querySelector('[data-router-outlet="true"]'),!this.routerOutlet)){console.warn("Router outlet not found");return}this.currentComponent&&(this.currentComponent.unmount(),this.currentComponent=null),this.routerOutlet.innerHTML="";try{let e=await this._resolveComponent(t.component);if(!e||typeof e!="function")throw new Error("Component is null or not a constructor");let n=e;this.currentComponent=new n,this.currentComponent&&await this.currentComponent.mount(this.routerOutlet);}catch(e){throw this._renderError(t.path,e),e}}async _resolveComponent(t){if(typeof t=="function"){let n="prototype"in t&&t.prototype?t.prototype:null;if(n&&typeof n=="object"&&"constructor"in n&&n.constructor===t)return t;try{let o=await t();return o.HomePage||o.TodoPage||o.default||Object.values(o).find(a=>{if(typeof a!="function")return !1;let c=a.prototype;return c!==null&&typeof c=="object"&&c!==void 0&&"constructor"in c})||null}catch(o){return console.error("Failed to load lazy component:",o),null}}return null}_renderError(t,e){if(this.routerOutlet){let n=e instanceof Error?e.message:String(e);this.routerOutlet.innerHTML=`
8
- <div style="padding: 2rem; background: #121212ff; border: 2px solid #303030ff;
9
- border-radius: 8px; margin: 2rem;">
10
- <h2 style="color: rgba(208, 31, 31, 1); margin-top: 0;">\u26A0\uFE0F Failed to Load Component</h2>
7
+ `}};function An(i,t){let e=i.subscribe(()=>{t.isMounted&&t.update();});return t.subscribe(()=>e),i.value}var le=class{constructor(t){this.contexts=new Map;for(let[e,n]of Object.entries(t))this.contexts.set(e,new X(n));}get(t){let e=this.contexts.get(t);if(!e)throw new Error(`Context key "${String(t)}" not found`);return e}set(t,e){let n=this.contexts.get(t);n&&(n.value=e);}subscribe(t,e){let n=this.contexts.get(t);if(!n)throw new Error(`Context key "${String(t)}" not found`);return n.subscribe(e)}reset(){for(let t of this.contexts.values())t.reset();}};function Bn(i){return new le(i)}var E=null,j=0,ce=new WeakMap;function st(i){E=i,j=0;}function at(){E=null,j=0;}function ee(i){return ce.has(i)||ce.set(i,[]),ce.get(i)}function N(i){if(!E)throw new Error("useState must be called inside a component");let t=E,e=j++,n=ee(t);n[e]===void 0&&(n[e]={value:typeof i=="function"?i():i});let r=o=>{let s=n[e],a=typeof o=="function"?o(s.value):o;s.value!==a&&(s.value=a,t.update());};return [n[e].value,r]}function F(i,t){if(!E)throw new Error("useEffect must be called inside a component");let e=E,n=j++,r=ee(e),o=r[n];if(!o||!t||!Ae(o.deps,t)){if(o?.value&&typeof o.value=="function")try{o.value();}catch(a){console.error("Error in effect cleanup:",a);}Promise.resolve().then(()=>{try{let a=i();r[n]={value:a,deps:t?[...t]:void 0};}catch(a){console.error("Error in effect:",a);}});}}function lt(i,t){if(!E)throw new Error("useMemo must be called inside a component");let e=j++,n=ee(E),r=n[e];return (!r||!Ae(r.deps,t))&&(n[e]={value:i(),deps:[...t]}),n[e].value}function ue(i,t){return lt(()=>i,t)}function de(i){if(!E)throw new Error("useRef must be called inside a component");let t=j++,e=ee(E);return e[t]===void 0&&(e[t]={value:{current:i}}),e[t].value}function Dn(i,t){let[e,n]=N(t),r=ue(o=>{n(s=>i(s,o));},[i]);return [e,r]}function Hn(i,t){let[e,n]=N(()=>{try{let o=window.localStorage.getItem(i);return o?JSON.parse(o):t}catch(o){return console.error("Error loading from localStorage:",o),t}});return [e,o=>{n(s=>{let a=o instanceof Function?o(s):o;try{window.localStorage.setItem(i,JSON.stringify(a));}catch(l){console.error("Error saving to localStorage:",l);}return a});}]}function jn(i,t){let[e,n]=N(i);return F(()=>{let r=setTimeout(()=>{n(i);},t);return ()=>{clearTimeout(r);}},[i,t]),e}function Un(i){let t=de(void 0);return F(()=>{t.current=i;}),t.current}function zn(i=false){let[t,e]=N(i),n=ue(()=>{e(r=>!r);},[]);return [t,n]}function qn(i,t){let e=de(i);F(()=>{e.current=i;},[i]),F(()=>{if(t===null)return;let n=setInterval(()=>e.current(),t);return ()=>clearInterval(n)},[t]);}function Wn(i,t){let[e,n]=N(null),[r,o]=N(true),[s,a]=N(null),l=ue(async()=>{o(true),a(null);try{let c=await fetch(i,t);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);let u=await c.json();n(u);}catch(c){a(c);}finally{o(false);}},[i]);return F(()=>{l();},[l]),{data:e,loading:r,error:s,refetch:l}}function Gn(){let[i,t]=N({width:window.innerWidth,height:window.innerHeight});return F(()=>{let e=()=>{t({width:window.innerWidth,height:window.innerHeight});};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),i}function Jn(i,t,e=window){let n=de(t);F(()=>{n.current=t;},[t]),F(()=>{if(!(e&&"addEventListener"in e))return;let o=s=>{n.current(s);};return e.addEventListener(i,o),()=>{e.removeEventListener(i,o);}},[i,e]);}function Yn(i,t){class e extends b{render(){st(this);try{return i(this.props)}finally{at();}}}return t&&Object.defineProperty(e,"name",{value:t}),e}function Ae(i,t){if(!i||i.length!==t.length)return false;for(let e=0;e<i.length;e++)if(i[e]!==t[e])return false;return true}var J=class{constructor(t){this.translations={};this.currentLanguage="en";this.defaultLanguage="en";this.supportedLanguages=new Set(["en"]);this.cachePath="";this.readyListeners=[];t&&(this.defaultLanguage=t.defaultLanguage||"en",this.cachePath=t.staticPath||"static/i18n",this.currentLanguage=this.getStoredLanguage()||t.defaultLanguage||"en",t.supportedLanguages&&(this.supportedLanguages=new Set(t.supportedLanguages)));}loadLanguage(t,e){this.translations[t]||(this.translations[t]={});let n=this.flattenObject(e);this.translations[t]={...this.translations[t],...n},this.supportedLanguages.add(t);}flattenObject(t,e=""){let n={};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let o=t[r],s=e?`${e}.${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?Object.assign(n,this.flattenObject(o,s)):n[s]=String(o);}return n}loadTranslations(t){Object.entries(t).forEach(([e,n])=>{this.loadLanguage(e,n);});}setLanguage(t){this.supportedLanguages.has(t)?(this.currentLanguage=t,this.storeLanguage(t),this.dispatchLanguageChangeEvent()):this.supportedLanguages.has(this.defaultLanguage)&&(this.currentLanguage=this.defaultLanguage);}getLanguage(){return this.currentLanguage}getSupportedLanguages(){return Array.from(this.supportedLanguages)}t(t,e,n){let r=this.currentLanguage,o=this.getTranslation(t,n);return e&&Object.entries(e).forEach(([s,a])=>{let l=this.translations[r]?.[a]||this.translations[this.defaultLanguage]?.[a]||a;o=o.replace(new RegExp(`\\{${s}\\}`,"g"),l);}),o}getTranslation(t,e){let n=this.currentLanguage;return this.translations[n]?.[t]?this.translations[n]?.[t]||this.translations[this.defaultLanguage]?.[t]:(console.warn(`Translation key not found: ${t}`),e||t)}tLang(t,e,n){let r=this.currentLanguage;this.currentLanguage=e;let o=this.t(t,n);return this.currentLanguage=r,o}tHtml(t,e,n){let r=this.t(t,e,n);return this.parseHtmlString(r)}parseHtmlString(t){let e=t.replace(/\\n|\/n/g,"<br>"),n=[],r=/<([^/>]+)>([^<]*)<\/\1>|<([^/>]+)\s*\/?>|([^<]+)/g,o;for(;(o=r.exec(e))!==null;){let s=o[1],a=o[2],l=o[3],c=o[4];if(c)n.push(c);else if(s){let u=s.split(/\s+/)[0].toLowerCase();n.push(createElement(u,{},a));}else if(l){let u=l.trim().toLowerCase();n.push(createElement(u,{}));}}return n.length>0?n:[t]}getTranslations(){return this.translations[this.currentLanguage]||{}}hasKey(t){return !!(this.translations[this.currentLanguage]?.[t]||this.translations[this.defaultLanguage]?.[t])}createTranslator(t){let e=()=>t();return typeof window<"u"?(window.addEventListener("languagechange",e),()=>window.removeEventListener("languagechange",e)):()=>{}}async loadFromUrl(t){let e=Array.isArray(t)?t:[t],n={};for(let r of e)if(r.includes("*")){let o=r.replace("*.json",""),s=this.supportedLanguages;for(let a of s)try{let l=`${o}${a}.json`;typeof window<"u"&&!l.startsWith("http")&&(l=window.location.origin+(l.startsWith("/")?l:"/"+l));let c=await fetch(l);if(c.ok){let u=await c.json();n[a]=u;}}catch{}}else try{let o=r;typeof window<"u"&&!o.startsWith("http")&&(o=window.location.origin+(o.startsWith("/")?o:"/"+o));let s=await fetch(o);if(s.ok){let a=await s.json(),l=r.match(/([a-z]{2,3})\.json$/i),c=l?l[1].toLowerCase():"en";n[c]=a,this.supportedLanguages.add(c);}}catch{}Object.keys(n).length>0&&(this.loadTranslations(n),this.notifyReady());}onReady(t){Object.keys(this.translations).length>0?t():this.readyListeners.push(t);}notifyReady(){for(let t of this.readyListeners)t();this.readyListeners=[];}getStoredLanguage(){return typeof localStorage<"u"&&localStorage.getItem("app-language")||null}storeLanguage(t){typeof localStorage<"u"&&localStorage.setItem("app-language",t);}dispatchLanguageChangeEvent(){typeof window<"u"&&window.dispatchEvent(new CustomEvent("languagechange",{detail:{language:this.currentLanguage}}));}},G=null;function S(){return G||(G=new J),G}function d(i,t,e){return S().t(i,t,e)}function Xn(i,t,e){return S().tLang(i,t,e)}function he(i,t,e){return S().tHtml(i,t,e)}function er(i){S().setLanguage(i);}async function tr(i,t){let e=S(),n=e.getTranslations();if(!(Object.keys(n).length>0)&&t){let o=t.endsWith("/")?t:t+"/";try{await e.loadFromUrl(o+`${i}.json`);}catch(s){console.warn(`Failed to lazy-load language: ${i}`,s);}}e.setLanguage(i);}function nr(){return S().getLanguage()}function rr(i,t){S().loadLanguage(i,t);}function ir(i){S().loadTranslations(i);}function or(){return S().getSupportedLanguages()}function sr(i){return S().hasKey(i)}function ar(){return S().getTranslations()}function lr(i){return S().createTranslator(i)}async function cr(i){return S().loadFromUrl(i)}function ur(i){G=new J(i);}async function dr(i){let t=new J(i);if(G=t,i.staticPath){let e=i.staticPath.endsWith("/")?i.staticPath:i.staticPath+"/",n=t.getLanguage(),r=e+`${n}.json`;await t.loadFromUrl(r);}}async function hr(i,t){let e=S(),n=t||"static/i18n",o=(n.endsWith("/")?n:n+"/")+i+".json";await e.loadFromUrl(o);}var pe=class{constructor(){this.routes=[];this.currentRoute=null;this.mode="history";this.base="/";this.beforeEachHooks=[];this.afterEachHooks=[];this.currentComponent=null;this.routerOutlet=null;this.isNavigating=false;this.scrollBehavior="auto";this.notFoundHandler=null;this._internalPath=null;}init(t,e="history",n="/",r="auto"){this.routes=t,this.mode=e,this.base=n.endsWith("/")?n.slice(0,-1):n,this.scrollBehavior=r,this._initializeRouting(),this._handleRoute();}async push(t,e){this.isNavigating&&(this.isNavigating=false),this._internalPath=t,this.mode==="history"?window.history.pushState(e||{},"",this._buildFullPath(t)):window.location.hash=t,await this._handleRoute();}async replace(t,e){return this._internalPath=t,this.mode==="history"?window.history.replaceState(e||{},"",this._buildFullPath(t)):window.location.hash=t,this._handleRoute()}back(){window.history.back();}forward(){window.history.forward();}go(t){window.history.go(t);}beforeEach(t){this.beforeEachHooks.push(t);}afterEach(t){this.afterEachHooks.push(t);}onNotFound(t){this.notFoundHandler=t;}getCurrentRoute(){return this.currentRoute?{...this.currentRoute}:null}isActive(t,e=false){return this.currentRoute?e?this.currentRoute.path===t:this.currentRoute.path.startsWith(t):false}outlet(){return createElement("div",{"data-router-outlet":"true",style:"display: contents;"})}getRoute(t){return this.routes.find(e=>e.name===t)}async pushNamed(t,e){let n=this.getRoute(t);if(!n){console.error(`Route with name "${t}" not found`);return}let r=n.path;if(e)for(let[o,s]of Object.entries(e))r=r.replace(`:${o}`,s);return this.push(r)}resolve(t){let e=this._matchRoute(t);if(!e)return null;let{route:n,params:r}=e;return {path:t,params:r,query:this._parseQuery(t),meta:n.meta||{},hash:t.includes("#")?t.split("#")[1]:"",name:n.name}}_initializeRouting(){window.addEventListener("popstate",()=>{this._internalPath=null,this._handleRoute();}),this.mode==="hash"&&window.addEventListener("hashchange",()=>{this._internalPath=null,this._handleRoute();}),document.addEventListener("click",t=>{let e=t.target.closest("a[href]");if(e&&this._shouldInterceptLink(e)){t.preventDefault();let n=e.getAttribute("href");if(n){let r=this.mode==="hash"&&n.startsWith("#")?n.substring(1):n.replace(this.base,"");this.push(r);}}});}_shouldInterceptLink(t){return !!(t.getAttribute("href")&&t.hostname===window.location.hostname&&t.target!=="_blank"&&!t.hasAttribute("download")&&t.rel!=="external")}async _handleRoute(){if(!this.isNavigating){this.isNavigating=true;try{let t=this._getCurrentPath(),e=this._matchRoute(t);if(!e){this._handleNotFound(t);return}let{route:n,params:r}=e,o=this._buildRouteObject(t,r,n),s=this.currentRoute||this._buildEmptyRoute();if(!await this._runNavigationGuards(n,o,s))return;this.currentRoute=o,await this._renderComponent(n),this._handleScrollBehavior(o,s),n.meta?.t_title&&typeof n.meta.t_title=="string"?document.title=d(n.meta.t_title):n.meta?.title&&typeof n.meta.title=="string"&&(document.title=n.meta.title),this.afterEachHooks.forEach(l=>l(o,s));}catch(t){console.error("Router error:",t);}finally{this.isNavigating=false;}}}_handleNotFound(t){console.warn(`No route matched for path: ${t}`),this.currentRoute={path:t,params:{},query:this._parseQuery(),meta:{},hash:window.location.hash.substring(1)},this.notFoundHandler&&this.notFoundHandler();}_buildRouteObject(t,e,n){return {path:t,params:e,query:this._parseQuery(),meta:n.meta||{},hash:window.location.hash.substring(1),name:n.name}}_buildEmptyRoute(){return {path:"",params:{},query:{},meta:{},hash:""}}async _runNavigationGuards(t,e,n){if(t.beforeEnter&&!await this._runGuard(t.beforeEnter,e,n))return false;for(let r of this.beforeEachHooks)if(!await this._runGuard(r,e,n))return false;return true}_runGuard(t,e,n){return new Promise(r=>{t(e,n,o=>{o===false?r(false):typeof o=="string"?(this.push(o),r(false)):r(true);});})}async _renderComponent(t){if(!this.routerOutlet&&(this.routerOutlet=document.querySelector('[data-router-outlet="true"]'),!this.routerOutlet)){console.warn("Router outlet not found");return}this.currentComponent&&(this.currentComponent.unmount(),this.currentComponent=null),this.routerOutlet.innerHTML="";try{let e=await this._resolveComponent(t.component);if(!e||typeof e!="function")throw new Error("Component is null or not a constructor");let n=e;this.currentComponent=new n,this.currentComponent&&await this.currentComponent.mount(this.routerOutlet);}catch(e){throw this._renderError(t.path,e),e}}async _resolveComponent(t){if(typeof t=="function"){let n="prototype"in t&&t.prototype?t.prototype:null;if(n&&typeof n=="object"&&"constructor"in n&&n.constructor===t)return t;try{let o=await t();return o.HomePage||o.TodoPage||o.default||Object.values(o).find(a=>{if(typeof a!="function")return !1;let c=a.prototype;return c!==null&&typeof c=="object"&&c!==void 0&&"constructor"in c})||null}catch(o){return console.error("Failed to load lazy component:",o),null}}return null}_renderError(t,e){if(this.routerOutlet){let n=e instanceof Error?e.message:String(e);this.routerOutlet.innerHTML=`
8
+ <div style="padding: 2rem; background: #121212ff; border: 2px solid #303030ff; border-radius: 8px; margin: 2rem auto; max-width: 600px; direction: ltr;">
9
+ <h2 style="color: rgba(208, 31, 31, 1); margin-top: 0;">Failed to Load Component</h2>
11
10
  <p style="color: #a3a3a3ff;"><strong>Route:</strong> ${t}</p>
12
11
  <p style="color: #a3a3a3ff;"><strong>Error:</strong> ${n}</p>
13
12
  </div>
14
- `;}}_handleScrollBehavior(t,e){if(t.hash){let n=document.getElementById(t.hash);if(n){n.scrollIntoView({behavior:this.scrollBehavior});return}}t.path!==e.path&&window.scrollTo({top:0,behavior:this.scrollBehavior});}_getCurrentPath(){if(this._internalPath!==null)return this._internalPath;if(this.mode==="hash")return window.location.hash.substring(1).split("?")[0]||"/";let t=window.location.pathname;return (!t||t==="blank"||t==="about:blank")&&(t="/"),this.base&&t.startsWith(this.base)&&(t=t.substring(this.base.length)),t||"/"}_buildFullPath(t){if(t.startsWith("http"))return t;let e=t.startsWith("/")?t:"/"+t;return this.base+e}_matchRoute(t){let e=t.split("?")[0].split("#")[0];for(let n of this.routes){let r=this._matchPath(n.path,e);if(r!==null)return {route:n,params:r}}return null}_matchPath(t,e){if(t==="*")return {};if(t===e)return {};let n=[],r=t.replace(/\*/g,".*").replace(/:([^/]+)/g,(a,l)=>(n.push(l),"([^/]+)")),o=new RegExp(`^${r}$`),s=e.match(o);return s?n.reduce((a,l,c)=>(a[l]=decodeURIComponent(s[c+1]),a),{}):null}_parseQuery(t){let e=t?t.includes("?")?t.split("?")[1].split("#")[0]:"":window.location.search.substring(1);return e?e.split("&").reduce((n,r)=>{let[o,s]=r.split("=").map(decodeURIComponent);return o&&(n[o]=s||""),n},{}):{}}},F=new ue;function Fe(i,t=false){t?F.replace(i):F.push(i),window.dispatchEvent(new CustomEvent("navigation",{detail:{path:i}}));}function Dn(){F.back();}function Un(){window.history.forward();}function de(){return window.location.pathname}function jn(i){return de()===i}function zn(i){return de().startsWith(i)}function qn(){let i=de();Fe(i,true);}function Wn(i,t){let e=new URLSearchParams(t).toString();Fe(`${i}?${e}`);}function it(){return new URLSearchParams(window.location.search)}function Gn(i){return it().get(i)}var he=class{constructor(t){this._subscribers=new Set;this._storage=null;this._middleware=[];this._isHydrating=false;if(this._persist=t.persist??false,this._storageKey=t.storageKey||`store_${Date.now()}`,this._persist&&typeof window<"u"&&(this._storage=t.storage==="sessionStorage"?sessionStorage:localStorage),this._persist&&this._storage){let e=this._loadFromStorage();this._state=e!==null?e:t.state;}else this._state=t.state;t.middleware&&(this._middleware=t.middleware);}get state(){return {...this._state}}set state(t){this.setState(t);}setState(t,e){let n={...this._state},r=typeof t=="function"?t(n):t;this._state={...n,...r};for(let o of this._middleware)try{o(this._state,e);}catch(s){console.error("Store middleware error:",s);}this._persist&&!this._isHydrating&&this._saveToStorage(),this._notify();}get(t){return this._state[t]}set(t,e,n){let r={[t]:e};this.setState(r,n);}subscribe(t){return this._subscribers.add(t),t(this._state),()=>{this._subscribers.delete(t);}}subscribeToKey(t,e){let n=this._state[t],r=o=>{let s=o[t];n!==s&&(n=s,e(s));};return this.subscribe(r)}use(t){this._middleware.push(t);}clear(){if(this._state={},this._persist&&this._storage)try{this._storage.removeItem(this._storageKey);}catch(t){console.error("Failed to clear storage:",t);}this._notify();}reset(t){this._state={...t},this._persist&&this._saveToStorage(),this._notify();}hydrate(){if(!this._persist||!this._storage){console.warn("Cannot hydrate: persistence not enabled");return}this._isHydrating=true;let t=this._loadFromStorage();t!==null&&(this._state=t,this._notify()),this._isHydrating=false;}getSnapshot(){return {state:{...this._state},subscribers:this._subscribers.size,storageKey:this._storageKey}}batch(t){let e=this._notify.bind(this),n=false;this._notify=()=>{n=true;};try{t();}finally{this._notify=e,n&&this._notify();}}_notify(){let t={...this._state};for(let e of this._subscribers)try{e(t);}catch(n){console.error("Store subscriber error:",n);}}_loadFromStorage(){if(!this._storage)return null;try{let t=this._storage.getItem(this._storageKey);return t?JSON.parse(t):null}catch(t){return console.error("Failed to load from storage:",t),null}}_saveToStorage(){if(this._storage)try{this._storage.setItem(this._storageKey,JSON.stringify(this._state));}catch(t){console.error("Failed to save to storage:",t),t instanceof DOMException&&t.name==="QuotaExceededError"&&console.warn("Storage quota exceeded");}}destroy(){this._subscribers.clear(),this._middleware=[],this._state={};}};function ot(i){return new he(i)}function Yn(i,t){let e=ot({state:{value:t(...i.map(n=>n.state))}});for(let n of i)n.subscribe(()=>{e.setState({value:t(...i.map(r=>r.state))});});return e}function Qn(i,t,e){return i.subscribe(r=>{let o=e(r);Object.assign(t,o),typeof t.update=="function"&&t.update();})}function tr(i){let t=i;return {async build(){if(!t.build){console.warn("No build configuration provided");return}console.log("\u{1F528} Building @je-es/client application...");try{await this._buildJS(),await this._buildStyles(),console.log("\u2705 Build completed successfully!");}catch(e){throw console.error("\u274C Build error:",e),e}},async _buildJS(){if(!t.build)return;let e=await Bun.build({entrypoints:[t.build.entry],outdir:t.build.output.substring(0,t.build.output.lastIndexOf("/")),target:"browser",minify:t.build.minify??false,sourcemap:t.build.sourcemap?"external":"none",splitting:t.build.optimization?.splitChunks??false,naming:{entry:t.build.output.substring(t.build.output.lastIndexOf("/")+1)},external:["sass","fs","path","url","util","stream","buffer","events","crypto","os","child_process"]});if(!e.success)throw console.error("\u274C JS Build failed:",e.logs),new Error("JS Build failed")},async _buildStyles(){let e=t.build?.styles?.input||"./app/gui/style",n=t.build?.styles?.output||"./static/client.css",r=await import('sass'),{writeFileSync:o,existsSync:s,mkdirSync:a}=await import('fs'),{join:l,dirname:c}=await import('path'),u=c(n),h=n.split("/").pop()||"client.css",y=l(e,"index.scss");if(!s(y)){console.log("\u26A0\uFE0F No index.scss found, skipping CSS build");return}try{s(u)||a(u,{recursive:!0});let K=r.compile(y,{style:t.build?.minify?"compressed":"expanded",sourceMap:!!t.build?.sourcemap,loadPaths:[e]}),Ie=l(u,h);o(Ie,K.css,"utf-8"),t.build?.sourcemap&&K.sourceMap&&o(`${Ie}.map`,JSON.stringify(K.sourceMap),"utf-8");}catch(K){throw console.error("\u274C CSS Build failed:",K),K}},async _collectScssFiles(e){let{readdirSync:n,statSync:r,existsSync:o}=await import('fs'),{join:s,extname:a}=await import('path'),l=[];if(!o(e))return l;let c=n(e);for(let u of c){let h=s(e,u),y=r(h);y.isDirectory()?l.push(...await this._collectScssFiles(h)):y.isFile()&&a(u)===".scss"&&!u.startsWith("_")&&l.push(h);}return l.sort()},async watch(){console.log("\u{1F440} Watching for changes..."),await this.build();let{watch:e}=await import('fs'),{dirname:n}=await import('path'),{existsSync:r}=await import('fs');if(t.build?.entry){let s=n(t.build.entry);e(s,{recursive:true},async(a,l)=>{if(l&&(l.endsWith(".ts")||l.endsWith(".tsx"))){console.log(`\u{1F504} ${l} changed, rebuilding JS...`);try{await this._buildJS(),console.log("\u2705 JS rebuild complete");}catch(c){console.error("\u274C JS rebuild failed:",c);}}});}let o="./app/style";r(o)&&e(o,{recursive:true},async(s,a)=>{if(a&&a.endsWith(".scss")){console.log(`\u{1F504} ${a} changed, rebuilding CSS...`);try{await this._buildStyles(),console.log("\u2705 CSS rebuild complete");}catch(l){console.error("\u274C CSS rebuild failed:",l);}}});},async init(){if(console.log("\u{1F680} [client] Initializing @je-es/client..."),t.api){let e={baseURL:t.api.baseURL,timeout:t.api.timeout,headers:t.api.headers};t.api.interceptors&&(e.interceptors={request:t.api.interceptors.request||null,response:t.api.interceptors.response||null,error:t.api.interceptors.error||null}),configureApi(e);}t.router&&t.app?.routes&&(F.init(t.app.routes,t.router.mode,t.router.base),t.router.beforeEach&&F.beforeEach(t.router.beforeEach),t.router.afterEach&&F.afterEach(t.router.afterEach)),t.app?.root&&(document.querySelector(t.app.root)||console.error(`\u274C Root element "${t.app.root}" not found`)),t.devTools?.enabled&&this._enableDevTools();},_enableDevTools(){window.__JEES_DEV__={router:F,config:t,version:"0.0.1"};},getConfig(){return t}}}var v={fa:(i,t="solid")=>{let e="bb_icon";if(i.includes("fa-"))return e+" "+i;let r={solid:"fas",regular:"far",light:"fal",thin:"fat",duotone:"fad",brands:"fab","sharp-solid":"fass","sharp-regular":"fasr","sharp-light":"fasl","sharp-thin":"fast","sharp-duotone-solid":"fasds","sharp-duotone-regular":"fasdr","sharp-duotone-light":"fasdl","sharp-duotone-thin":"fasdt",notdog:"fa-notdog","notdog-duo":"fa-notdog-duo",jelly:"fa-jelly","jelly-fill":"fa-jelly-fill","jelly-duo":"fa-jelly-duo",chisel:"fa-chisel",etch:"fa-etch",slab:"fa-slab","slab-press":"fa-slab-press",thumbprint:"fa-thumbprint",utility:"fa-utility","utility-fill":"fa-utility-fill","utility-duo":"fa-utility-duo",whiteboard:"fa-whiteboard"}[t]||"fas";return `${e} ${r} fa-${i}`},btn:(i,t="")=>{let e="bb_btn",n=`bb_btn_${i}`;return `${e} ${n} ${t}`.trim()}},$=v,pe={div:div,span:span,h1:h1,h2:h2,h3:h3,h4:h4,h5:h5,h6:h6,p:p$1,i:i,img:img,a:a,button:button,input:input,select:select,option:option,textarea:textarea,form:form,icon:(i$1,t)=>i(v.fa(i$1,t)),btn:i=>button({class:v.btn(i.level||"secondary",i.className),onclick:i.onClick,disabled:i.disabled},i.icon?pe.icon(i.icon,i.iconStyle):null,i.label)},_t=pe;var J=class{constructor(t){this.translations={};this.currentLanguage="en";this.defaultLanguage="en";this.supportedLanguages=new Set(["en"]);this.cachePath="";this.readyListeners=[];t&&(this.defaultLanguage=t.defaultLanguage||"en",this.cachePath=t.staticPath||"static/i18n",this.currentLanguage=this.getStoredLanguage()||t.defaultLanguage||"en",t.supportedLanguages&&(this.supportedLanguages=new Set(t.supportedLanguages)));}loadLanguage(t,e){this.translations[t]||(this.translations[t]={});let n=this.flattenObject(e);this.translations[t]={...this.translations[t],...n},this.supportedLanguages.add(t);}flattenObject(t,e=""){let n={};for(let r in t)if(Object.prototype.hasOwnProperty.call(t,r)){let o=t[r],s=e?`${e}.${r}`:r;typeof o=="object"&&o!==null&&!Array.isArray(o)?Object.assign(n,this.flattenObject(o,s)):n[s]=String(o);}return n}loadTranslations(t){Object.entries(t).forEach(([e,n])=>{this.loadLanguage(e,n);});}setLanguage(t){this.supportedLanguages.has(t)?(this.currentLanguage=t,this.storeLanguage(t),this.dispatchLanguageChangeEvent()):this.supportedLanguages.has(this.defaultLanguage)&&(this.currentLanguage=this.defaultLanguage);}getLanguage(){return this.currentLanguage}getSupportedLanguages(){return Array.from(this.supportedLanguages)}t(t,e,n){let r=this.currentLanguage,o=this.getTranslation(t,n);return e&&Object.entries(e).forEach(([s,a])=>{let l=this.translations[r]?.[a]||this.translations[this.defaultLanguage]?.[a]||a;o=o.replace(new RegExp(`\\{${s}\\}`,"g"),l);}),o}getTranslation(t,e){let n=this.currentLanguage;return this.translations[n]?.[t]?this.translations[n]?.[t]||this.translations[this.defaultLanguage]?.[t]:(console.warn(`Translation key not found: ${t}`),e||t)}tLang(t,e,n){let r=this.currentLanguage;this.currentLanguage=e;let o=this.t(t,n);return this.currentLanguage=r,o}tHtml(t,e,n){let r=this.t(t,e,n);return this.parseHtmlString(r)}parseHtmlString(t){let e=t.replace(/\\n|\/n/g,"<br>"),n=[],r=/<([^/>]+)>([^<]*)<\/\1>|<([^/>]+)\s*\/?>|([^<]+)/g,o;for(;(o=r.exec(e))!==null;){let s=o[1],a=o[2],l=o[3],c=o[4];if(c)n.push(c);else if(s){let u=s.split(/\s+/)[0].toLowerCase();n.push(createElement(u,{},a));}else if(l){let u=l.trim().toLowerCase();n.push(createElement(u,{}));}}return n.length>0?n:[t]}getTranslations(){return this.translations[this.currentLanguage]||{}}hasKey(t){return !!(this.translations[this.currentLanguage]?.[t]||this.translations[this.defaultLanguage]?.[t])}createTranslator(t){let e=()=>t();return typeof window<"u"?(window.addEventListener("languagechange",e),()=>window.removeEventListener("languagechange",e)):()=>{}}async loadFromUrl(t){let e=Array.isArray(t)?t:[t],n={};for(let r of e)if(r.includes("*")){let o=r.replace("*.json",""),s=this.supportedLanguages;for(let a of s)try{let l=`${o}${a}.json`;typeof window<"u"&&!l.startsWith("http")&&(l=window.location.origin+(l.startsWith("/")?l:"/"+l));let c=await fetch(l);if(c.ok){let u=await c.json();n[a]=u;}}catch{}}else try{let o=r;typeof window<"u"&&!o.startsWith("http")&&(o=window.location.origin+(o.startsWith("/")?o:"/"+o));let s=await fetch(o);if(s.ok){let a=await s.json(),l=r.match(/([a-z]{2,3})\.json$/i),c=l?l[1].toLowerCase():"en";n[c]=a,this.supportedLanguages.add(c);}}catch{}Object.keys(n).length>0&&(this.loadTranslations(n),this.notifyReady());}onReady(t){Object.keys(this.translations).length>0?t():this.readyListeners.push(t);}notifyReady(){for(let t of this.readyListeners)t();this.readyListeners=[];}getStoredLanguage(){return typeof localStorage<"u"&&localStorage.getItem("app-language")||null}storeLanguage(t){typeof localStorage<"u"&&localStorage.setItem("app-language",t);}dispatchLanguageChangeEvent(){typeof window<"u"&&window.dispatchEvent(new CustomEvent("languagechange",{detail:{language:this.currentLanguage}}));}},G=null;function S(){return G||(G=new J),G}function d(i,t,e){return S().t(i,t,e)}function sr(i,t,e){return S().tLang(i,t,e)}function fe(i,t,e){return S().tHtml(i,t,e)}function ar(i){S().setLanguage(i);}async function lr(i,t){let e=S(),n=e.getTranslations();if(!(Object.keys(n).length>0)&&t){let o=t.endsWith("/")?t:t+"/";try{await e.loadFromUrl(o+`${i}.json`);}catch(s){console.warn(`Failed to lazy-load language: ${i}`,s);}}e.setLanguage(i);}function cr(){return S().getLanguage()}function ur(i,t){S().loadLanguage(i,t);}function dr(i){S().loadTranslations(i);}function hr(){return S().getSupportedLanguages()}function pr(i){return S().hasKey(i)}function fr(){return S().getTranslations()}function gr(i){return S().createTranslator(i)}async function mr(i){return S().loadFromUrl(i)}function br(i){G=new J(i);}async function vr(i){let t=new J(i);if(G=t,i.staticPath){let e=i.staticPath.endsWith("/")?i.staticPath:i.staticPath+"/",n=t.getLanguage(),r=e+`${n}.json`;await t.loadFromUrl(r);}}async function yr(i,t){let e=S(),n=t||"static/i18n",o=(n.endsWith("/")?n:n+"/")+i+".json";await e.loadFromUrl(o);}var ge={};Qe(ge,{default:()=>T,dropdown:()=>Lt,form:()=>St,itemsLoader:()=>Mt,loader:()=>Et,popup:()=>kt,tabbedView:()=>It,toast:()=>xt});var St={base:"bb_form",field:"bb_formField",fieldCheckbox:"bb_formFieldCheckbox",fieldInput:"bb_formFieldInput",fieldInputContainer:"bb_formFieldInputContainer",fieldInputButtons:"bb_formFieldInputButtons",fieldInputButton:"bb_formFieldInputButton",fieldInputButtonRules:"bb_formFieldInputButtonRules",fieldInputButtonRulesContent:"bb_formFieldInputButtonRulesContent",fieldTextarea:"bb_formFieldTextarea",fieldSelect:"bb_formFieldSelect",fieldLabel:"bb_formFieldLabel",fieldError:"bb_formFieldError",fieldTitle:"bb_formFieldTitle",buttonsContainer:"bb_formButtonsContainer",button:"bb_formButton",alert:"bb_formAlert",alertError:"bb_formAlert-error",alertSuccess:"bb_formAlert-success"},xt={container:"bb_toastContainer",toast:"bb_toast",icon:"bb_toastIcon",msg:"bb_toastMsg"},Et={container:"bb_loaderContainer",containerOverlay:"bb_loaderContainer--overlay",bg:"bb_loaderBg",loader:"bb_loader",spinner:{container:"bb_loaderSpinnerContainer",icon:"bb_loaderSpinnerIcon",dot:"bb_loaderSpinnerDot",pulse:"bb_loaderSpinnerPulse",text:"bb_loaderSpinnerText"},progress:{container:"bb_loaderProgressContainer",bar:"bb_loaderProgressBar",text:"bb_loaderProgressText"}},kt={container:"bb_popupContainer",overlay:"bb_popupOverlay",popup:{base:"bb_popup",close:"bb_popupClose"},header:{container:"bb_popupHeader",icon:"bb_popupHeaderIcon",content:"bb_popupHeaderContent",title:"bb_popupHeaderContentTitle",description:"bb_popupHeaderContentDesc"},body:{container:"bb_popupBody",message:"bb_popupBodyMsg",input:"bb_popupBodyInput",formContainer:"bb_popupBodyFormContainer"},footer:"bb_popupFooter",button:"bb_btn"},Lt={container:"bb_dropdown",trigger:"bb_dropdownTrigger",menu:"bb_dropdownMenu",item:"bb_dropdownItem",divider:"bb_dropdownDivider",icon:"bb_dropdownIcon"},Mt={container:"bb_itemsLoaderContainer",list:"bb_itemsLoaderList",searchbar:"bb_itemsLoaderSearchbar",loading:"bb_itemsLoaderLoading",error:"bb_itemsLoaderError",trigger:"bb_itemsLoaderTrigger",end:"bb_itemsLoaderEnd",emptyState:"bb_tabbedviewEmptyState",button:"bb_btn",item:"bb_itemsLoader-item",formFieldInput:"bb_formFieldInput"},It={container:"bb_tabbedview",header:"bb_tabbedviewHeader",tab:{base:"bb_tabbedviewTab",active:"bb_tabbedviewTab--active",disabled:"bb_tabbedviewTab--disabled",badge:"bb_tabbedviewBadge"},content:{container:"bb_tabbedviewContent",emptyState:"bb_tabbedviewEmptyState",error:"bb_tabbedviewError"}},T={form:St,toast:xt,loader:Et,popup:kt,dropdown:Lt,itemsLoader:Mt,tabbedView:It};var Y=T.toast,te=class extends b{constructor(){super(...arguments);this.messages=[];this.nextId=0;}show(e,n="info",r=2e3,o){let s=this.nextId++;this.messages=[...this.messages,{id:s,message:e,type:n,translateKey:o}],setTimeout(()=>{this.messages=this.messages.filter(a=>a.id!==s),this.update();},r);}success(e,n,r){this.show(e,"success",n,r);}error(e,n,r){this.show(e,"error",n,r);}info(e,n,r){this.show(e,"info",n,r);}warning(e,n,r){this.show(e,"warning",n,r);}render(){return this.messages.length===0?html``:div(Y.container,...this.messages.map(e=>this.renderToast(e)))}renderToast(e){let n={success:v.fa("check-circle"),error:v.fa("exclamation-circle"),info:v.fa("info-circle"),warning:v.fa("exclamation-triangle")},r=e.translateKey?d(e.translateKey):e.message;return div({key:String(e.id),class:`${Y.toast} ${Y.toast}--${e.type}`,"data-translate":e.translateKey||void 0},i(`${n[e.type]} ${Y.icon}`),span(Y.msg,r))}};p([f],te.prototype,"messages");var B=null;function Rt(i){if(B)return B;let t=i||document.createElement("div");return i||document.body.appendChild(t),B=new te,B.mount(t),B}function Q(){return B||(B=Rt()),B}var kr={show:(i,t="info",e,n)=>{Q().show(i,t,e,n);},success:(i,t,e)=>{Q().success(i,t,e);},error:(i,t,e)=>{Q().error(i,t,e);},info:(i,t,e)=>{Q().info(i,t,e);},warning:(i,t,e)=>{Q().warning(i,t,e);}};var Ft=T.loader,I=class extends b{constructor(){super(...arguments);this.visible=false;this.message="";this.variant="spinner";this.size="medium";this.overlay=true;this.progress=0;this.showProgress=false;this.animationFrame=null;this.hideTimeout=null;this.handleKeyPress=e=>{e.key==="Escape"&&this.visible&&!this.overlay&&this.hide();};}async onMount(){this.setupKeyboardListener(),this.initializeAccessibility(),window.addEventListener("languagechange",()=>{this.message||this.update();});}onUnmount(){this.animationFrame&&cancelAnimationFrame(this.animationFrame),this.hideTimeout&&clearTimeout(this.hideTimeout),document.removeEventListener("keydown",this.handleKeyPress);}render(){let{loader:e}=T,n=[e.container,this.overlay?`${e.containerOverlay}`:"",`${e.container}--${this.size}`].filter(Boolean).join(" ");return div({class:n,"data-status":this.visible?"visible":"hidden",role:"status","aria-live":"polite","aria-busy":"true"},div(e.bg),div(e.loader,this.renderSpinner(),this.renderMessage(),this.showProgress?this.renderProgressBar():null))}renderSpinner(){let{loader:e}=T,n=`${e.spinner.container} ${e.spinner.container}--${this.variant}`;switch(this.variant){case "dots":return div(n,div(e.spinner.dot),div(e.spinner.dot),div(e.spinner.dot));case "pulse":return div(n,div(e.spinner.pulse));case "spinner":default:return div(n,div(e.spinner.icon))}}renderMessage(){let{loader:e}=T,n=this.message||d("loader.loading");return div({class:e.spinner.text,"data-translate":this.message?void 0:"loader.loading"},n)}renderProgressBar(){let{loader:e}=T;return div(e.progress.container,div({class:e.progress.bar,style:`width: ${this.progress}%`,"aria-valuenow":this.progress.toString(),"aria-valuemin":"0","aria-valuemax":"100"}),div(e.progress.text,`${Math.round(this.progress)}%`))}show(e){typeof e=="string"?this.message=e:e&&(this.message=e.message||"",this.variant=e.variant||"spinner",this.size=e.size||"medium",this.overlay=e.overlay!==void 0?e.overlay:true),this.visible=true,this.progress=0,this.showProgress=false,this.applyBodyLock(),this.update();}hide(e=0){this.hideTimeout&&clearTimeout(this.hideTimeout),e>0?this.hideTimeout=window.setTimeout(()=>{this.performHide();},e):this.performHide();}setMessage(e){this.message=e,this.update();}setProgress(e){this.showProgress=true,this.progress=Math.max(0,Math.min(100,e)),this.update();}updateProgress(e){this.setProgress(this.progress+e);}performHide(){this.visible=false,this.message="",this.progress=0,this.showProgress=false,this.removeBodyLock(),this.update();}applyBodyLock(){this.overlay&&(document.body.style.overflow="hidden");}removeBodyLock(){document.body.style.overflow="";}setupKeyboardListener(){this.handleKeyPress=this.handleKeyPress.bind(this),document.addEventListener("keydown",this.handleKeyPress);}initializeAccessibility(){let e=this.element?.querySelector(`.${Ft.spinner.container}`);e&&e.setAttribute("aria-label",d("loading"));}isVisible(){return this.visible}getStatus(){return {visible:this.visible,message:this.message,progress:this.progress}}};p([f],I.prototype,"visible"),p([f],I.prototype,"message"),p([f],I.prototype,"variant"),p([f],I.prototype,"size"),p([f],I.prototype,"overlay"),p([f],I.prototype,"progress"),p([f],I.prototype,"showProgress");var g={form:"bb_form",field:"bb_formField",fieldCheckbox:"bb_formFieldCheckbox",fieldInput:"bb_formFieldInput",fieldInputContainer:"bb_formFieldInputContainer",fieldInputButtons:"bb_formFieldInputButtons",fieldInputButton:"bb_formFieldInputButton",fieldInputButtonRules:"bb_formFieldInputButtonRules",fieldInputButtonRulesContent:"bb_formFieldInputButtonRulesContent",fieldTextarea:"bb_formFieldTextarea",fieldSelect:"bb_formFieldSelect",fieldError:"bb_formFieldError",buttonsContainer:"bb_formButtonsContainer",button:"bb_formButton",alert:"bb_formAlert",alertError:"bb_formAlert-error",alertSuccess:"bb_formAlert-success"},P=class extends b{constructor(e){super(e);this.fields=[];this.formData={};this.isSubmitting=false;this.submitError="";this.submitSuccess=false;this.passwordVisibility={};let n=[];for(let r of this.props.fields)if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&"name"in o&&"type"in o&&n.push(o);else n.push(r);this.fields=n.map(r=>({...r,error:void 0,touched:false}));for(let r of this.fields)this.formData[r.name]=r.value||"";}onMount(){}handleChange(e,n){this.formData[e]=n;let r=this.fields.find(o=>o.name===e);r&&this.props.autoValidate&&(r.error=this.validateField(r,n),r.touched=true),this.update();}handleBlur(e){let n=this.fields.find(r=>r.name===e);n&&(n.touched=true,n.error=this.validateField(n,this.formData[e]),this.update());}validateField(e,n){let r=e.validation;if(!r)return;if(r.required&&!n)return r.message||`${e.label||e.name} is required`;if(!n)return;let o=String(n);if(r.minLength&&o.length<r.minLength)return r.message||`Minimum ${r.minLength} characters required`;if(r.maxLength&&o.length>r.maxLength)return r.message||`Maximum ${r.maxLength} characters allowed`;if(r.min!==void 0&&Number(n)<r.min)return r.message||`Minimum value is ${r.min}`;if(r.max!==void 0&&Number(n)>r.max)return r.message||`Maximum value is ${r.max}`;if(r.pattern&&!r.pattern.test(o))return r.message||"Invalid format";if(r.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return r.message||"Invalid email format";if(r.url&&!/^https?:\/\/.+/.test(o))return r.message||"Invalid URL format";if(r.custom){let s=r.custom(n);if(s!==true)return typeof s=="string"?s:void 0}}validateForm(){let e=true,n={};for(let r of this.fields){let o=this.validateField(r,this.formData[r.name]);r.error=o,r.touched=true,o&&(e=false,n[r.name]=o);}return this.update(),!e&&this.props.onValidationError&&this.props.onValidationError(n),e}async handleSubmit(e){if(e.preventDefault(),!this.validateForm()){let n=this.fields.find(r=>r.error);n&&document.querySelector(`[name="${n.name}"]`)?.focus();return}this.isSubmitting=true,this.submitError="",this.submitSuccess=false,this.update();try{if(this.props.onSubmit)await this.props.onSubmit(this.formData,e);else if(this.props.endpoint){let n=await api({method:this.props.method||"POST",url:this.props.endpoint,data:this.formData});this.submitSuccess=!0,this.props.onSuccess&&this.props.onSuccess(n.data);}}catch(n){let r=n instanceof Error?n.message:d("global.loading");this.submitError=r,this.props.onError&&this.props.onError(n);}finally{this.isSubmitting=false,this.update();}}renderLabel(e){return !e.label&&!e.icon?"":e.icon?label({for:e.name},span($.fa(e.icon)),e.label?span(De.form.fieldTitle,e.label):""):label({for:e.name},e.label)}getFieldButtons(e){let n=[];if(!e.fieldButtons&&!e.showValidationRules)return n;if(e.type==="password"&&(e.fieldButtons?.includes("togglePassword")||e.fieldButtons?.some(r=>r?.type==="togglePassword"))&&n.push({type:"togglePassword",icon:"eye",tooltip:d("form.showPassword",{},"Show Password")}),(e.showValidationRules===true||e.fieldButtons?.includes("rules"))&&e.validation&&n.push({type:"rules",icon:"list-check"}),e.fieldButtons)for(let r of e.fieldButtons)typeof r=="object"&&r.type==="custom"&&n.push(r);return n}handleFieldButton(e,n){if(n==="togglePassword"){this.passwordVisibility[e.name]=!this.passwordVisibility[e.name];let r=this.passwordVisibility[e.name],o=document.querySelector(`input[name="${e.name}"]`);o&&(o.type=r?"text":"password");let a=o?.closest(`.${g.fieldInputContainer}`)?.querySelector(`.${g.fieldInputButtons}`)?.querySelector("button");if(a){let l=a.querySelector("span");l&&(l.className=l.className.replace(/fa-eye(-slash)?/,r?"fa-eye-slash":"fa-eye")),a.title=r?d("form.hidePassword",{},"Hide Password"):d("form.showPassword",{},"Show Password");}}}renderValidationRules(e){if(!e.validation)return "";let n=[];return e.validation.required&&n.push(d("form.rule.required",{},"This field is required")),e.validation.minLength&&n.push(d("form.rule.minLength",{length:String(e.validation.minLength)},`Minimum ${e.validation.minLength} characters`)),e.validation.maxLength&&n.push(d("form.rule.maxLength",{length:String(e.validation.maxLength)},`Maximum ${e.validation.maxLength} characters`)),e.validation.min!==void 0&&n.push(d("form.rule.min",{value:String(e.validation.min)},`Minimum value: ${e.validation.min}`)),e.validation.max!==void 0&&n.push(d("form.rule.max",{value:String(e.validation.max)},`Maximum value: ${e.validation.max}`)),e.validation.email&&n.push(d("form.rule.email",{},"Valid email format required")),e.validation.url&&n.push(d("form.rule.url",{},"Valid URL format required")),e.validation.pattern&&n.push(d("form.rule.pattern",{},"Pattern does not match")),n.length===0?"":div({class:g.fieldInputButtonRulesContent},...n.map(r=>div({},r)))}renderFieldButtons(e){let n=this.getFieldButtons(e);if(n.length===0)return "";let r=[];for(let o of n)o.type==="rules"?r.push(div({class:g.fieldInputButtonRules,title:o.tooltip},button({type:"button",class:g.fieldInputButton,tabindex:-1,onclick:s=>{s.preventDefault(),s.stopPropagation();}},span($.fa(o.icon||"fa-circle-info"))),this.renderValidationRules(e))):r.push(button({type:"button",class:g.fieldInputButton,title:o.tooltip,tabindex:-1,onclick:s=>{s.preventDefault(),s.stopPropagation(),o.type==="togglePassword"?this.handleFieldButton(e,o.type):o.onClick&&o.onClick();}},span($.fa(o.icon||"fa-gear"))));return div({class:g.fieldInputButtons},...r)}renderField(e){let n=this.formData[e.name]||"",r=this.renderLabel(e),o=[g.field,e.className].filter(Boolean).join(" "),s=e.error&&e.touched?span({class:g.fieldError},e.error):"";switch(e.type){case "textarea":return div({class:o},r,div({class:g.fieldInputContainer},textarea({id:e.name,name:e.name,placeholder:e.placeholder||"",disabled:e.disabled||this.isSubmitting,oninput:a=>{let l=a.target;this.handleChange(e.name,l.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldTextarea},String(n)),this.renderFieldButtons(e)),s);case "select":{let l=(e.options||[]).map(c=>option({value:String(c.value),selected:String(c.value)===String(n)},c.label));return div({class:o},r,div({class:g.fieldInputContainer},select({id:e.name,name:e.name,disabled:e.disabled||this.isSubmitting,onchange:c=>{let u=c.target;this.handleChange(e.name,u.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldSelect},option({value:"",selected:String(n)===""},d("form.select_placeholder",{},"Select...")),...l),this.renderFieldButtons(e)),s)}case "checkbox":{let a=!!n,l=[g.field,g.fieldCheckbox,e.className].filter(Boolean).join(" ");return div({class:l},input({type:"checkbox",id:e.name,name:e.name,checked:a,disabled:e.disabled||this.isSubmitting,onchange:c=>{let u=c.target;this.handleChange(e.name,u.checked);},class:g.fieldCheckbox}),label({for:e.name},e.icon?span($.fa(e.icon)):"",e.label||""),s)}default:{let l=e.type==="password"&&this.passwordVisibility[e.name]?"text":e.type||"text";return div({class:o},r,div({class:g.fieldInputContainer},input({type:l,id:e.name,name:e.name,placeholder:e.placeholder||"",value:String(n),disabled:e.disabled||this.isSubmitting,oninput:c=>{let u=c.target;this.handleChange(e.name,u.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldInput}),this.renderFieldButtons(e)),s)}}}renderButtons(){let e=this.props.buttons||{submit:{label:d("form.submit",{},"Submit"),onClick:"submit"}},n=[];for(let[r,o]of Object.entries(e)){let s=o.onClick==="submit"||r==="submit",a=this.isSubmitting&&s,l=this.isSubmitting&&s&&o.loadingLabel||o.label;n.push(button({type:s?"submit":"button",class:[g.button,o.className].filter(Boolean).join(" "),disabled:a,onclick:s?void 0:async c=>{if(c.preventDefault(),typeof o.onClick=="function")try{this.isSubmitting=!0,this.update(),await o.onClick();}finally{this.isSubmitting=false,this.update();}}},o.icon?span($.fa(o.icon)," "):"",l));}return div({class:g.buttonsContainer},...n)}render(){let e=[];for(let r of this.props.fields)if(Array.isArray(r)){let o=[];for(let s of r)if(s&&typeof s=="object"&&"name"in s&&"type"in s){let a=this.fields.find(l=>l.name===s.name);a&&o.push(this.renderField(a));}else o.push(s);e.push(div({class:"bb_formFieldGroup"},...o));}else {let o=this.fields.find(s=>s.name===r.name);o&&e.push(this.renderField(o));}let n=[g.form,this.props.className].filter(Boolean).join(" ");return form({class:n,onsubmit:r=>this.handleSubmit(r)},this.submitError?div({class:[g.alert,g.alertError].join(" ")},this.submitError):"",this.submitSuccess?div({class:[g.alert,g.alertSuccess].join(" ")},d("form.success",{},"Success")):"",...e,this.renderButtons())}styles(){return Ve``}};p([f],P.prototype,"fields"),p([f],P.prototype,"formData"),p([f],P.prototype,"isSubmitting"),p([f],P.prototype,"submitError"),p([f],P.prototype,"submitSuccess");function ve(i){return new P(i).render()}var w=T.popup,re=class extends b{constructor(){super(...arguments);this.popups=[];this.nextId=0;}async onMount(){this.setupKeyboardListener(),window.addEventListener("languagechange",()=>{this.update();});}onUnmount(){this.handleEscapeKey&&document.removeEventListener("keydown",this.handleEscapeKey);}render(){return this.popups.length===0?div(w.container):div(w.container,...this.popups.map(e=>this.renderPopup(e)))}renderPopup(e){let n=`bb_popup--${e.size||"medium"}`,r=e.variant?`bb_popup--${e.variant}`:"";return div({key:String(e.id),class:w.overlay,"data-popup-id":e.id,onclick:o=>{o.target.classList.contains(w.overlay)&&e.closeOnOverlay!==false&&this.closePopup(e.id,false);}},div({class:`${w.popup.base} ${n} ${r}`,role:"dialog","aria-modal":"true","aria-labelledby":`popup-title-${e.id}`},e.showCloseButton!==false?button({class:w.popup.close,onclick:()=>this.closePopup(e.id,false),"aria-label":"Close"},i(v.fa("times"))):null,div(w.header.container,e.icon?div(w.header.icon,i(e.icon)):null,div(w.header.content,h2({id:`popup-title-${e.id}`,class:w.header.title,"data-translate":e.titleTranslateKey},e.titleTranslateKey?d(e.titleTranslateKey):e.title),e.description?p$1({class:w.header.description,"data-translate":e.descriptionTranslateKey},e.descriptionTranslateKey?fe(e.descriptionTranslateKey):e.description):null)),div(w.body.container,e.message?p$1({class:w.body.message,"data-translate":e.messageTranslateKey},e.messageTranslateKey?fe(e.messageTranslateKey):e.message):null,e.type==="prompt"?input({type:"text",class:w.body.input,value:e.inputValue||"",placeholder:d("popup.prompt.placeholder"),"data-translate":"popup.prompt.placeholder",oninput:o=>{e.inputValue=o.target.value;}}):null,e.type==="form"&&e.formConfig?div(w.body.formContainer,ve(e.formConfig)):null,e.customContent||null),e.buttons&&e.buttons.length>0&&e.type!=="form"?div(w.footer,...e.buttons.map(o=>button({class:`${w.button} ${o.variant||"secondary"}`,"data-translate":o.translateKey,disabled:o.loading||e.isSubmitting,onclick:async()=>{o.loading||e.isSubmitting||await o.onClick();}},o.icon?i(o.icon):null,o.loading||e.isSubmitting?i(v.fa("spinner","solid")+" fa-spin"):null," ",o.translateKey?d(o.translateKey):o.label))):null))}show(e){return new Promise(n=>{let r=this.nextId++,o={...e,id:r,resolve:n,type:e.type||"custom",size:e.size||"medium",closeOnOverlay:e.closeOnOverlay!==false,closeOnEscape:e.closeOnEscape!==false,showCloseButton:e.showCloseButton!==false,isSubmitting:false};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}showForm(e){return new Promise((n,r)=>{let o=this.nextId++,s={...e.formConfig,onSubmit:async l=>{let c=this.popups.find(u=>u.id===o);c&&(c.isSubmitting=true,this.update());try{e.formConfig.onSubmit&&await e.formConfig.onSubmit(l,new Event("submit")),this.closePopup(o,l),n(l);}catch(u){c&&(c.isSubmitting=false,this.update()),e.formConfig.onError&&e.formConfig.onError(u);}},buttons:e.formConfig.buttons||{submit:{label:d("global.submit",{},"Submit"),className:`${w.button} primary wide`,onClick:"submit"}}},a={title:e.title,titleTranslateKey:e.titleTranslateKey,description:e.description,descriptionTranslateKey:e.descriptionTranslateKey,type:"form",variant:e.variant||"default",size:e.size||"medium",icon:e.icon,formConfig:s,closeOnOverlay:e.closeOnOverlay!==false,closeOnEscape:e.closeOnEscape!==false,showCloseButton:e.showCloseButton!==false,id:o,resolve:n,isSubmitting:false};this.popups=[...this.popups,a],this.applyBodyLock(),this.update();})}confirm(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"confirm",variant:e.variant||"default",size:e.size||"small",icon:e.icon,resolve:n,onConfirm:e.onConfirm,onCancel:e.onCancel,buttons:[{label:e.cancelLabel||"Cancel",translateKey:e.cancelTranslateKey||"button.cancel",variant:"secondary",icon:v.fa("times"),onClick:async()=>{e.onCancel&&await e.onCancel(),this.closePopup(r,false);}},{label:e.confirmLabel||"Confirm",translateKey:e.confirmTranslateKey||"button.confirm",variant:e.variant==="danger"?"danger":"primary",icon:v.fa("check"),onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}alert(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"alert",variant:e.variant||"info",size:e.size||"small",icon:e.icon,resolve:n,onConfirm:e.onConfirm,buttons:[{label:e.okLabel||"OK",translateKey:e.okTranslateKey||"popup.ok",variant:"primary",icon:v.fa("check"),onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}prompt(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"prompt",variant:"default",icon:e.icon,inputValue:e.defaultValue||"",resolve:n,onConfirm:e.onConfirm,onCancel:e.onCancel,buttons:[{label:e.cancelLabel||"Cancel",translateKey:e.cancelTranslateKey||"popup.cancel",variant:"secondary",onClick:async()=>{e.onCancel&&await e.onCancel(),this.closePopup(r,null);}},{label:e.confirmLabel||"OK",translateKey:e.confirmTranslateKey||"popup.ok",variant:"primary",onClick:async()=>{let s=o.inputValue||"";e.onConfirm&&await e.onConfirm(s),this.closePopup(r,s);}}]};this.popups=[...this.popups,o],this.applyBodyLock();})}closePopup(e,n){let r=this.popups.find(o=>o.id===e);r?.resolve&&r.resolve(n),this.popups=this.popups.filter(o=>o.id!==e),this.popups.length===0&&this.removeBodyLock(),this.update();}closeAll(){this.popups.forEach(e=>{e.resolve&&e.resolve(false);}),this.popups=[],this.removeBodyLock(),this.update();}applyBodyLock(){document.body.style.overflow="hidden";}removeBodyLock(){document.body.style.overflow="";}setupKeyboardListener(){this.handleEscapeKey=e=>{if(e.key==="Escape"&&this.popups.length>0){let n=this.popups[this.popups.length-1];n.closeOnEscape!==false&&this.closePopup(n.id,false);}},document.addEventListener("keydown",this.handleEscapeKey);}};p([f],re.prototype,"popups");var A=null;function Dt(i){if(A)return A;let t=i||document.createElement("div");return i||document.body.appendChild(t),A=new re,A.mount(t),A}function L(){return A||(A=Dt()),A}var ei={show:i=>L().show(i),confirm:i=>L().confirm(i),alert:i=>L().alert(i),prompt:i=>L().prompt(i),showForm:i=>L().showForm(i),closePopup:(i,t)=>L().closePopup(i,t),closeLastPopup:()=>L().closePopup(L().popups.length-1,false),closeFirstPopup:()=>L().closePopup(0,false),closeAll:()=>L().closeAll()};var {tabbedView:M}=T,x=class extends b{constructor(){super(...arguments);this.activeTabId="";this.tabs=[];this.position="top";this.style="default";this.className="";this.headerClassName="";this.contentClassName="";this.showTabCount=false;this.persistState=false;this.storageKey="tabbedview-active";this.currentTabComponent=null;}async onMount(){window.addEventListener("languagechange",()=>{this.update();});}onUnmount(){this.currentTabComponent&&typeof this.currentTabComponent.onUnmount=="function"&&this.currentTabComponent.onUnmount();}init(e){if(this.tabs=e.tabs,this.position=e.position||"top",this.style=e.style||"default",this.className=e.className||"",this.headerClassName=e.headerClassName||"",this.contentClassName=e.contentClassName||"",this.showTabCount=e.showTabCount||false,this.persistState=e.persistState||false,this.storageKey=e.storageKey||"tabbedview-active",this.onChange=e.onChange,this.persistState){let n=localStorage.getItem(this.storageKey);n&&this.tabs.find(r=>r.id===n)&&(this.activeTabId=n);}return this.activeTabId||(this.activeTabId=e.defaultTab||this.tabs[0]?.id||""),this.update(),this}async setActiveTab(e){let n=this.tabs.find(r=>r.id===e);!n||n.disabled||(this.currentTabComponent&&typeof this.currentTabComponent.onUnmount=="function"&&this.currentTabComponent.onUnmount(),this.currentTabComponent=null,this.activeTabId=e,this.persistState&&localStorage.setItem(this.storageKey,e),n.onActivate&&await n.onActivate(),this.onChange&&await this.onChange(e),this.update());}addTab(e){this.tabs=[...this.tabs,e],this.update();}removeTab(e){this.tabs=this.tabs.filter(n=>n.id!==e),this.activeTabId===e&&this.tabs.length>0&&(this.activeTabId=this.tabs[0].id),this.update();}updateTab(e,n){let r=this.tabs.find(o=>o.id===e);r&&(Object.assign(r,n),this.update());}getActiveTab(){return this.tabs.find(e=>e.id===this.activeTabId)}render(){let e=[M.container,`bb_tabbedview__--${this.position}`,`bb_tabbedview__--${this.style}`,this.className].filter(Boolean).join(" ");return div(e,this.renderTabList(),this.renderTabContent())}renderTabList(){let e=[M.header,this.headerClassName].filter(Boolean).join(" ");return div(e,...this.tabs.map(n=>this.renderTab(n)))}renderTab(e){let n=this.activeTabId===e.id,r=[M.tab.base,n?M.tab.active:"",e.disabled?M.tab.disabled:""].filter(Boolean).join(" "),o=e.translateKey?d(e.translateKey):e.label;return button({key:e.id,class:r,onclick:()=>this.setActiveTab(e.id),disabled:e.disabled,"data-translate":e.translateKey,"aria-selected":n,role:"tab"},e.icon?i(e.icon):null,span({},o),e.badge!==void 0&&e.badge!==null&&e.badge!==0?span(M.tab.badge,typeof e.badge=="number"&&e.badge>99?"99+":String(e.badge)):null)}renderTabContent(){let e=[M.content.container,this.contentClassName].filter(Boolean).join(" "),n=this.getActiveTab();return n?div({class:e,role:"tabpanel"},this.renderActiveTabContent(n)):div(e,div(M.content.emptyState,p$1({},d("tabbedView.no_content"))))}renderActiveTabContent(e){if(e.component)try{if(e.component instanceof b){this.currentTabComponent=e.component;let n=this.currentTabComponent.render(),r={...n.props,ref:s=>{s&&this.currentTabComponent&&this.currentTabComponent.setElement(s),typeof n.props.ref=="function"&&n.props.ref(s);}},o={...n,props:r};return typeof this.currentTabComponent.onMount=="function"&&setTimeout(()=>{this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&this.currentTabComponent.onMount();},0),o}if(typeof e.component=="function"){let n=e.component;return n.prototype&&typeof n.prototype.render=="function"?(this.currentTabComponent||(this.currentTabComponent=new n,this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&setTimeout(()=>{this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&this.currentTabComponent.onMount();},0)),this.currentTabComponent.render()):n()}}catch(n){return console.error("Error rendering tab component:",n),div(M.content.error,d("global.loading"))}return e.content?e.content:div(M.content.emptyState,p$1({},d("tabbedView.no_content")))}};p([f],x.prototype,"activeTabId"),p([f],x.prototype,"tabs"),p([f],x.prototype,"position"),p([f],x.prototype,"style"),p([f],x.prototype,"className"),p([f],x.prototype,"headerClassName"),p([f],x.prototype,"contentClassName"),p([f],x.prototype,"showTabCount"),p([f],x.prototype,"persistState"),p([f],x.prototype,"storageKey");function zt(i){let t=new x;return t.init(i),t}async function li(i,t){let e=zt(t);return await e.mount(i),e}var m=T.itemsLoader,Te=class extends b{constructor(){super(...arguments);this.items=[];this.loadState={loading:false,error:null,hasMore:true,page:0,total:0};this.filters={};this.scrollContainer=null;this.loadMoreObserver=null;this.currentLoadMoreTrigger=null;this.loadMoreMutationObserver=null;this.visibilityObserver=null;this.viewedItems=new Set;this.dropdownIsOpen=false;this.itemsListContainer=null;this.searchInput=null;this.isUpdating=false;this.searchDebounceTimer=null;this.handleScroll=()=>{if(!this.scrollContainer||this.loadState.loading||!this.loadState.hasMore)return;let{scrollTop:e,scrollHeight:n,clientHeight:r}=this.scrollContainer;n-e-r<this.config.scrollThreshold&&this.loadMore();};this.handleItemClick=(e,n)=>{this.config.onItemClick?.(e,n);};}initialize(e){this.config={pageSize:10,loadMoreText:"Load More",loadingText:"Loading...",errorText:"Failed to load items",containerClassName:m.container,itemClassName:m.item,enableInfiniteScroll:true,scrollThreshold:200,enableSearch:false,searchPlaceholder:"Search...",searchFilterKey:"search",searchDebounceMs:300,enableVisibilityTracking:false,visibilityThreshold:.5,visibilityRootMargin:"0px",extractItems:n=>n.notifications||n.items||n.data||n.logs||[],extractTotal:n=>n.pagination?.total||n.total||n.count||0,...e},this.config.filters&&(this.filters={...this.config.filters}),this.config.initialItems&&(this.items=[...this.config.initialItems]);}async onMount(){this.items.length===0&&await this.loadMore(),this.config.enableInfiniteScroll&&this.setupInfiniteScroll(),this.config.scrollThreshold&&this.setupScrollListener(),this.config.enableVisibilityTracking&&this.setupVisibilityTracking();}onUnmount(){this.disconnectInfiniteScrollObserver(),this.disconnectVisibilityObserver(),this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null),this.scrollContainer&&(this.scrollContainer.removeEventListener("scroll",this.handleScroll),this.scrollContainer=null),this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer);}async loadMore(){if(!(this.loadState.loading||!this.loadState.hasMore))try{let e=this.scrollContainer||this.findScrollContainer(),n=e?.scrollTop||0,r=e?.scrollHeight||0;this.loadState={...this.loadState,loading:!0,error:null},this.updateLoadingState();let o=this.loadState.page+1,s=this.buildUrl(o),a=await fetch(s,{credentials:"include",headers:this.buildHeaders()});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let l=await a.json(),c=this.config.extractItems(l),u=this.config.extractTotal(l);this.items=[...this.items,...c],this.loadState={loading:!1,error:null,hasMore:this.items.length<u,page:o,total:u},this.updateLoadingState(),this.appendNewItems(c),e&&n>0&&(e.scrollTop=n,requestAnimationFrame(()=>{let y=e.scrollHeight-r;Math.abs(y)>10&&(e.scrollTop=n);})),this.reconnectInfiniteScrollObserver(),this.config.onLoadMore?.(o,this.items);}catch(e){this.loadState={...this.loadState,loading:false,error:e instanceof Error?e.message:this.config.errorText},this.updateLoadingState(),this.updateFooter(),this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async reload(){this.items=[],this.loadState={loading:false,error:null,hasMore:true,page:0,total:0},await this.loadMore();}async applyFilters(e){if(!this.isUpdating){this.isUpdating=true,this.filters={...e},this.items=[],this.loadState={loading:true,error:null,hasMore:true,page:0,total:0},this.updateLoadingState();try{let n=this.buildUrl(1),r=await fetch(n,{credentials:"include",headers:this.buildHeaders()});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);let o=await r.json(),s=this.config.extractItems(o),a=this.config.extractTotal(o);this.items=[...s],this.loadState={loading:!1,error:null,hasMore:this.items.length<a,page:1,total:a},this.itemsListContainer&&(this.itemsListContainer.innerHTML=""),this.element&&this.element.querySelectorAll(`.${m.trigger}, .${m.end}, .${m.error}, .${m.loading}, .${m.emptyState}`).forEach(l=>l.remove()),this.items.length>0?(this.itemsListContainer||(this.itemsListContainer=this.element?.querySelector(`.${m.list}`)),this.itemsListContainer&&this.appendNewItems(this.items)):this.updateFooter(),this.itemsListContainer=this.element?.querySelector(`.${m.list}`),this.reconnectInfiniteScrollObserver(),this.config.onLoadMore?.(1,this.items),this.config.onFiltersChange?.(this.filters);}catch(n){this.loadState={...this.loadState,loading:false,error:n instanceof Error?n.message:this.config.errorText},this.updateLoadingState(),this.config.onError?.(n instanceof Error?n:new Error("Unknown error"));}finally{this.isUpdating=false;}}}async handleSearch(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(async()=>{let n={...this.filters};e.trim()?n[this.config.searchFilterKey]=e.trim():delete n[this.config.searchFilterKey],await this.applyFilters(n);},this.config.searchDebounceMs);}updateItems(e){this.items=[...e],this.itemsListContainer&&(this.itemsListContainer.innerHTML="",this.appendNewItems(e));}setupVisibilityTracking(){if(!this.config.enableVisibilityTracking)return;this.visibilityObserver&&this.visibilityObserver.disconnect();let e=this.findScrollContainer();this.visibilityObserver=new IntersectionObserver(n=>{n.forEach(r=>{if(r.isIntersecting&&this.dropdownIsOpen){let o=r.target,s=parseInt(o.getAttribute("data-item-index")||"-1");if(s>=0&&s<this.items.length){let a=this.items[s],l=this.config.getItemId?.(a),c=this.config.shouldTrackItem?.(a)??true;l&&!this.viewedItems.has(l)&&c&&this.viewedItems.add(l);}}});},{root:e,rootMargin:this.config.visibilityRootMargin,threshold:this.config.visibilityThreshold}),this.observeTrackableItems();}observeTrackableItems(){if(!this.visibilityObserver||!this.itemsListContainer)return;this.itemsListContainer.querySelectorAll("[data-item-index]").forEach(n=>{let r=parseInt(n.getAttribute("data-item-index")||"-1");if(r>=0&&r<this.items.length){let o=this.items[r];(this.config.shouldTrackItem?.(o)??true)&&this.visibilityObserver.observe(n);}});}trackAlreadyVisibleItems(){if(!this.itemsListContainer)return;let e=this.findScrollContainer();if(!e)return;let n=this.itemsListContainer.querySelectorAll("[data-item-index]"),r=e.getBoundingClientRect();n.forEach(o=>{let s=parseInt(o.getAttribute("data-item-index")||"-1");if(s<0||s>=this.items.length)return;let a=this.items[s],l=this.config.getItemId?.(a);if(!l||this.viewedItems.has(l)||!(this.config.shouldTrackItem?.(a)??true))return;let u=o.getBoundingClientRect();u.top<r.bottom&&u.bottom>r.top&&u.top>=r.top-100&&u.bottom<=r.bottom+100&&this.viewedItems.add(l);});}disconnectVisibilityObserver(){this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null);}handleDropdownOpen(){this.dropdownIsOpen=true,this.viewedItems.clear(),this.config.enableVisibilityTracking&&(this.trackAlreadyVisibleItems(),this.observeTrackableItems()),this.config.onDropdownOpen?.();}async handleDropdownClose(){if(this.dropdownIsOpen=false,this.viewedItems.size>0&&this.config.onItemsViewed){let e=this.items.filter(n=>{let r=this.config.getItemId?.(n);return r&&this.viewedItems.has(r)});await this.config.onItemsViewed(e);}this.viewedItems.clear(),this.config.onDropdownClose?.();}async performBatchAction(e,n){this.config.onBatchAction&&await this.config.onBatchAction(e,n);}appendNewItems(e){if(this.itemsListContainer||(this.itemsListContainer=this.element?.querySelector(`.${m.list}`)),!this.itemsListContainer)return;let n=document.createDocumentFragment(),r=this.items.length-e.length;e.forEach((o,s)=>{let a=r+s,l=this.config.renderItem(o,a);l.setAttribute("data-item-index",a.toString()),this.config.onItemClick?(l.className=`${l.className} ${this.config.itemClassName} clickable`,l.onclick=()=>this.handleItemClick(o,a)):l.className=`${l.className} ${this.config.itemClassName}`,n.appendChild(l);}),this.itemsListContainer.appendChild(n),this.updateFooter(),this.config.enableVisibilityTracking&&this.dropdownIsOpen&&setTimeout(()=>this.observeTrackableItems(),100);}updateLoadingState(){let e=this.element?.querySelector(`.${m.container}`);if(!e)return;let n=e.querySelector(`.${m.loading}`);if(this.loadState.loading){if(!n){let r=this.renderLoading();n=this.createElementFromVNode(r),e.appendChild(n);}}else n&&n.remove();}updateFooter(){let e=this.element;if(e){if(e.querySelectorAll(`.${m.trigger}, .${m.end}, .${m.emptyState}`).forEach(n=>{n.remove();}),this.items.length===0&&!this.loadState.loading&&this.config.emptyStateConfig){let n=this.renderEmptyState(),r=createDOMElement(n);e.appendChild(r);return}if(this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0){let n=this.renderLoadMoreTrigger(),r=createDOMElement(n);e.appendChild(r);}if(!this.loadState.hasMore&&this.items.length>0){let n=this.renderEndMessage(),r=createDOMElement(n);e.appendChild(r);}}}setupInfiniteScroll(){this.loadMoreObserver&&this.loadMoreObserver.disconnect(),this.loadMoreObserver=new IntersectionObserver(e=>{let[n]=e;n.isIntersecting&&!this.loadState.loading&&this.loadState.hasMore&&this.loadMore();},{threshold:.1,rootMargin:"50px"}),this.reconnectInfiniteScrollObserver();}reconnectInfiniteScrollObserver(){if(!this.config.enableInfiniteScroll||!this.loadMoreObserver)return;this.currentLoadMoreTrigger&&(this.loadMoreObserver.unobserve(this.currentLoadMoreTrigger),this.currentLoadMoreTrigger=null);let e=()=>{let n=this.element?.querySelector('[data-load-more-trigger="true"]');return n?(this.loadMoreObserver.observe(n),this.currentLoadMoreTrigger=n,true):false};e()||(this.loadMoreMutationObserver&&this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=new MutationObserver(()=>{e()&&this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null);}),this.element&&(this.loadMoreMutationObserver.observe(this.element,{childList:true,subtree:true}),setTimeout(()=>{this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null);},5e3)));}disconnectInfiniteScrollObserver(){this.loadMoreObserver&&this.currentLoadMoreTrigger&&(this.loadMoreObserver.unobserve(this.currentLoadMoreTrigger),this.currentLoadMoreTrigger=null);}setupScrollListener(){requestAnimationFrame(()=>{this.scrollContainer=this.findScrollContainer(),this.scrollContainer&&("scrollRestoration"in history&&(history.scrollRestoration="manual"),this.scrollContainer.addEventListener("scroll",this.handleScroll));});}findScrollContainer(){let e=[this.element?.closest(".bb_notificationsContent"),this.element?.closest(".bb_dropdownMenu"),this.element?.querySelector("[data-notifications-loader]"),this.element?.closest("[data-notifications-loader]"),this.element?.closest(".scrollbar-thin"),this.element?.parentElement,this.element];for(let n of e)if(n){let r=n;if(r.scrollHeight>r.clientHeight||r.classList.contains("scrollbar-thin"))return r}return null}buildUrl(e){if(typeof this.config.fetchUrl=="function")return this.config.fetchUrl(e,this.filters);let n=this.config.fetchUrl.includes("?")?"&":"?",r=new URLSearchParams({page:e.toString(),limit:this.config.pageSize.toString(),...this.filters});return `${this.config.fetchUrl}${n}${r}`}buildHeaders(){let e={"Content-Type":"application/json"},n=this.config.getAuthToken?.();return n&&(e.Authorization=`Bearer ${n}`),e}createElementFromVNode(e){if(typeof e.type!="string")throw new Error("Can only create elements from string types");let n=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([r,o])=>{r==="className"?n.className=o:r==="style"?typeof o=="string"?n.setAttribute("style",o):typeof o=="object"&&o!==null&&Object.assign(n.style,o):r==="onclick"&&typeof o=="function"?n.addEventListener("click",o):r!=="children"&&r!=="ref"&&n.setAttribute(r,String(o));}),e.children&&e.children.forEach(r=>{r!=null&&(typeof r=="string"||typeof r=="number"?n.appendChild(document.createTextNode(String(r))):typeof r=="object"&&n.appendChild(this.createElementFromVNode(r)));}),n}render(){return div({class:this.config.containerClassName},this.config.enableSearch?this.renderSearchBar():null,div({class:m.list,ref:e=>{e&&(this.itemsListContainer=e);}}),this.loadState.error?this.renderError():null,this.loadState.loading?this.renderLoading():null,this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0?this.renderLoadMoreTrigger():null,!this.loadState.hasMore&&this.items.length>0?this.renderEndMessage():null)}renderSearchBar(){return div(m.searchbar,div("row gap-sm",i(v.fa("search")),input({type:"text",class:m.formFieldInput,placeholder:this.config.searchPlaceholder,ref:e=>{e&&(this.searchInput=e,this.searchInput.addEventListener("input",n=>{let r=n.target.value;this.handleSearch(r);}));}})))}renderEmptyState(){let e=this.config.emptyStateConfig;return div(m.emptyState,i(`__icon ${e.icon}`),span("__title",e.title),p$1("__desc",e.description))}renderLoading(){return div(m.loading,i(v.fa("spinner")+" fa-spin"),p$1({},this.config.loadingText))}renderError(){return div(m.error,i(v.fa("exclamation-triangle")),p$1({},this.loadState.error),button({class:`${m.button} secondary`,onclick:()=>this.loadMore()},i(v.fa("redo"))," Retry"))}renderLoadMoreTrigger(){return div({class:m.trigger,"data-load-more-trigger":"true",style:"height: 1px; visibility: hidden;"})}renderEndMessage(){return div({class:m.end},i(v.fa("check-circle")),d("All loaded",{count:String(this.loadState.total)}))}};function mi(i){let t=new Te;return t.initialize(i),t}var xe=class i{constructor(){this.dropdowns=new Map;this.hierarchy=new Map;this.setupGlobalClickHandler();}static getInstance(){return i.instance||(i.instance=new i),i.instance}register(t){this.dropdowns.set(t.config.id,t),t.config.parentId&&this.hierarchy.set(t.config.id,t.config.parentId);}unregister(t){this.dropdowns.delete(t),this.hierarchy.delete(t);}open(t){let e=this.dropdowns.get(t);e&&(this.closeSiblings(t),e.setOpen(true));}close(t){let e=this.dropdowns.get(t);e&&(e.setOpen(false),this.closeChildren(t));}closeAll(){Array.from(this.dropdowns.values()).filter(e=>!e.config.parentId).forEach(e=>this.close(e.config.id));}destroy(){this.clickHandler&&typeof window<"u"&&document.removeEventListener("click",this.clickHandler,true),this.dropdowns.clear(),this.hierarchy.clear();}isAncestor(t,e){let n=e;for(;n;){if(n===t)return true;n=this.hierarchy.get(n);}return false}isDescendant(t,e){return this.isAncestor(e,t)}getAncestors(t){let e=new Set,n=t;for(;n;){let r=this.hierarchy.get(n);if(r)e.add(r),n=r;else break}return e}getDescendants(t){let e=new Set,n=r=>{Array.from(this.hierarchy.entries()).filter(([s,a])=>a===r).map(([s,a])=>s).forEach(s=>{e.add(s),n(s);});};return n(t),e}closeSiblings(t){let e=this.dropdowns.get(t);if(!e)return;let n=e.config.parentId;Array.from(this.dropdowns.values()).filter(o=>o.config.parentId===n&&o.config.id!==t).forEach(o=>this.close(o.config.id));}closeChildren(t){Array.from(this.dropdowns.values()).filter(n=>n.config.parentId===t).forEach(n=>this.close(n.config.id));}hasOpenDropdowns(){return Array.from(this.dropdowns.values()).some(t=>t.isOpen)}findDropdownForElement(t){let e=t;for(;e&&e!==document.body;){let n=e.getAttribute("data-dropdown-id");if(n)return n;e=e.parentElement;}return null}setupGlobalClickHandler(){typeof window>"u"||(this.clickHandler=t=>{let e=t.target;if(!this.hasOpenDropdowns())return;let n=this.findDropdownForElement(e);if(!n){this.closeAll();return}if(this.dropdowns.get(n)?.config.preventAutoClose||e.closest(".bb_dropdownTrigger"))return;if(e.closest(".bb_dropdownMenu")){let a=this.getAncestors(n),l=this.getDescendants(n);Array.from(this.dropdowns.values()).filter(u=>!u.config.parentId).forEach(u=>{let h=u.config.id;h===n||a.has(h)||l.has(h)||this.isDescendant(n,h)||this.close(h);});}},document.addEventListener("click",this.clickHandler,true));}},Z=xe.getInstance(),Ee=class extends b{constructor(e){super();this.isOpen=false;this.mounted=false;this.bb_=T.dropdown;this.config={closeOnItemClick:true,preventAutoClose:false,...e};}onMount(){this.mounted=true,Z.register(this);}onUnmount(){this.mounted=false,Z.unregister(this.config.id);}setOpen(e){this.isOpen!==e&&(this.isOpen=e,e?this.config.onOpen?.():this.config.onClose?.(),this.updateDOM());}toggle(e){e.preventDefault(),e.stopPropagation(),this.isOpen?Z.close(this.config.id):Z.open(this.config.id);}handleItemClick(e,n){if(e.disabled){n.preventDefault(),n.stopPropagation();return}this.config.closeOnItemClick&&(n.preventDefault(),n.stopPropagation(),Z.close(this.config.id)),e.onclick?.(n),this.config.onSelect?.(e);}render(){let e=this.renderTrigger(),n=this.isOpen?this.renderMenu():null,r=["bb_dropdown",`bb_dropdown--${this.config.position||"left"}`,this.isOpen?"bb_dropdown--open":"",this.config.asIcon?"bb_dropdown--asIcon":"",this.config.className||""].filter(Boolean).join(" ");return div({class:r,"data-dropdown-id":this.config.id},e,n)}updateDOM(){if(!this.mounted||!this.element)return;this.isOpen?this.element.classList.add("bb_dropdown--open"):this.element.classList.remove("bb_dropdown--open");let n=this.element.querySelector(".bb_dropdownTrigger")?.nextElementSibling;if(this.isOpen){if(!n||!n.classList.contains("bb_dropdownMenu")){let r=this.renderMenu(),o=this.createElementFromVNode(r);this.element.appendChild(o);}}else n&&n.classList.contains("bb_dropdownMenu")&&n.remove();}createElementFromVNode(e){if(typeof e.type=="string"){let n=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([r,o])=>{r==="className"?n.className=o:r==="onclick"&&typeof o=="function"?n.addEventListener("click",o):r!=="children"&&r!=="key"&&n.setAttribute(r,String(o));}),e.children&&e.children.forEach(r=>{r!=null&&(typeof r=="string"||typeof r=="number"?n.appendChild(document.createTextNode(String(r))):typeof r=="object"&&n.appendChild(this.createElementFromVNode(r)));}),n}return document.createElement("div")}renderTrigger(){let e=this.config.trigger.element?.(),n=["bb_dropdownTrigger",this.config.trigger.className||""].filter(Boolean).join(" ");if(e)return button({class:n,onclick:o=>this.toggle(o)},e);let r=["bb_dropdownArrow","fas","fa-chevron-down",this.isOpen?"bb_dropdownArrow--open":"",this.config.hideArrow?"hidden":""].filter(Boolean).join(" ");return button({class:n,onclick:o=>this.toggle(o)},this.config.trigger.icon?i(this.config.trigger.icon):null,this.config.trigger.text?span({},this.config.trigger.text):null,i(r))}renderMenu(){return div({class:"bb_dropdownMenu",onclick:e=>{this.config.preventAutoClose&&e.stopPropagation();}},...this.config.items.map((e,n)=>{if(e==="divider")return div({class:"bb_dropdown__divider",key:`divider-${n}`});let r=e.selected||this.config.defaultSelected&&e.id===this.config.defaultSelected,o=["bb_dropdownItem",e.className||"",e.disabled?"bb_dropdownItem--disabled":"",r?"bb_dropdownItem--selected":""].filter(Boolean).join(" "),s={key:e.id||`item-${n}`,class:o,onclick:a=>this.handleItemClick(e,a)};return e.disabled&&(s.disabled=true),button(s,e.icon?i(e.icon):null,span({},e.label))}))}};function Ti(i){return new Ee(i)}function Jt(i,t){let e=null;return (...n)=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i(...n);},t);}}function Yt(i,t){let e=0,n=null;return (...r)=>{let o=Date.now(),s=o-e;s>=t?(e=o,i(...r)):n||(n=setTimeout(()=>{e=Date.now(),n=null,i(...r);},t-s));}}function Qt(...i){let t=[];for(let e of i)if(e){if(typeof e=="string")t.push(e);else if(typeof e=="object")for(let[n,r]of Object.entries(e))r&&t.push(n);}return t.join(" ")}function Zt(i,t="YYYY-MM-DD"){let e=i instanceof Date?i:new Date(i);if(isNaN(e.getTime()))throw new Error("Invalid date provided to formatDate");let n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return t.replace("YYYY",String(n)).replace("MM",r).replace("DD",o).replace("HH",s).replace("mm",a).replace("ss",l)}function z(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(Array.isArray(i))return i.map(t=>z(t));if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(i instanceof Map){let t=new Map;return i.forEach((e,n)=>{t.set(z(n),z(e));}),t}if(i instanceof Set){let t=new Set;return i.forEach(e=>{t.add(z(e));}),t}if(Object.prototype.toString.call(i)==="[object Object]"){let t={};for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=z(i[e]));return t}return i}function Le(i,...t){if(!t.length)return i;let e=t.shift();if(!e)return i;if(ie(i)&&ie(e)){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n],o=i[n];r!==void 0&&(ie(r)&&!Array.isArray(r)?((!o||!ie(o))&&(i[n]={}),Le(i[n],r)):i[n]=r);}}return Le(i,...t)}function ie(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}var ke=0;function Xt(i="id"){let t=Date.now().toString(36),e=Math.random().toString(36).substring(2,11);ke=(ke||0)+1;let n=ke.toString(36);return `${i}_${t}_${e}_${n}`}function en(i){if(i<0)throw new Error("Sleep duration must be non-negative");return new Promise(t=>setTimeout(t,i))}function tn(i){return i==null?true:typeof i=="string"?i.trim().length===0:Array.isArray(i)?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:false}function nn(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function rn(i){return i?i.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase():""}function Ge(i){return i?i.replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase()):""}function on(i){if(!i)return "";let t=Ge(i);return t.charAt(0).toUpperCase()+t.slice(1)}function sn(i,t,e="..."){return !i||i.length<=t?i:i.substring(0,t-e.length)+e}function an(i){let t={},e=i.replace(/^\?/,"");if(!e)return t;let n=e.split("&");for(let r of n){let[o,s]=r.split("=").map(decodeURIComponent);if(!o)continue;let a=s||"";if(o.endsWith("[]")){let l=o.slice(0,-2);t[l]||(t[l]=[]),t[l].push(a);}else t[o]=a;}return t}function ln(i){let t=[];for(let[e,n]of Object.entries(i))if(n!=null)if(Array.isArray(n))for(let r of n)r!=null&&t.push(`${encodeURIComponent(e)}[]=${encodeURIComponent(String(r))}`);else t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`);return t.length>0?`?${t.join("&")}`:""}function cn(i,t,e){return Math.min(Math.max(i,t),e)}function un(){return typeof window<"u"&&typeof document<"u"}function dn(i,t){try{return JSON.parse(i)}catch{return t}}var _i={debounce:Jt,throttle:Yt,classNames:Qt,formatDate:Zt,deepClone:z,deepMerge:Le,uniqueId:Xt,sleep:en,isEmpty:tn,capitalize:nn,kebabCase:rn,camelCase:Ge,pascalCase:on,truncate:sn,parseQuery:an,stringifyQuery:ln,clamp:cn,isBrowser:un,safeJsonParse:dn};var Je=class{constructor(t){this.observer=null;this.observedElements=new Map;this.observer=new IntersectionObserver(e=>{e.forEach(n=>{let r=this.observedElements.get(n.target)??false,o=n.isIntersecting;o&&!r?(this.observedElements.set(n.target,true),t.onEnter?.(n),t.once&&this.unobserve(n.target)):!o&&r&&(this.observedElements.set(n.target,false),t.onExit?.(n));});},{root:t.root||null,rootMargin:t.rootMargin||"0px",threshold:t.threshold??.1});}observe(t){this.observer&&(this.observer.observe(t),this.observedElements.set(t,false));}unobserve(t){this.observer&&(this.observer.unobserve(t),this.observedElements.delete(t));}disconnect(){this.observer&&(this.observer.disconnect(),this.observedElements.clear());}};function xi(i,t){let e=new IntersectionObserver(n=>{n.forEach(r=>{r.isIntersecting&&(t(r),e.unobserve(i));});},{threshold:.1});return e.observe(i),()=>e.disconnect()}function Me(i){let t=typeof i=="string"?new Date(i):i,n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),o=Math.floor(r/60),s=Math.floor(o/60),a=Math.floor(s/24),l=Math.floor(a/7),c=Math.floor(a/30),u=Math.floor(a/365),h="";return r<0?h=d("time.just_now"):r<60?h=d("time.just_now"):o<2?h=d("time.minute_ago"):o<60?h=d("time.minutes_ago",{count:o.toString()}):s<2?h=d("time.hour_ago"):s<24?h=d("time.hours_ago",{count:s.toString()}):a<2?h=d("time.day_ago"):a<7?h=d("time.days_ago",{count:a.toString()}):l<2?h=d("time.week_ago"):l<4?h=d("time.weeks_ago",{count:l.toString()}):c<2?h=d("time.month_ago"):c<12?h=d("time.months_ago",{count:c.toString()}):u<2?h=d("time.year_ago"):h=d("time.years_ago",{count:u.toString()}),{formatted:h,originalDate:t.toISOString(),title:t.toLocaleString()}}function Li(i){let{formatted:t,title:e}=Me(i);return {text:t,title:e}}function Mi(i){return Me(i).formatted}function Ii(i){return Me(i).title}setConfig({devMode:false,sanitizeHTML:true});var De=ge;export{$ as CM,v as ClassMaker,se as CombinedContext,b as Component,X as Context,Ee as Dropdown,_t as EC,pe as ElementCreator,J as I18nManager,Te as ItemsLoader,I as Loader,re as Popup,Ne as Provider,ue as Router,ve as SmartForm,P as SmartFormComponent,he as Store,q as StyleManager,x as TabbedView,te as Toast,Je as VisibilityObserver,De as bbMap,Ge as camelCase,nn as capitalize,cn as clamp,Qt as classNames,tt as clearHookContext,tr as client,wn as computed,Qn as connect,kn as createCombinedContext,Yn as createComputedStore,xn as createContext,Ti as createDropdown,Kn as createFunctionalComponent,mi as createItemsLoader,ot as createStore,zt as createTabbedView,gr as createTranslator,Ve as css,Jt as debounce,z as deepClone,Le as deepMerge,Zt as formatDate,Me as formatRelativeTime,Mi as formatTimeAgo,cr as getCurrentLanguage,de as getCurrentPath,S as getI18n,L as getPopup,Gn as getQueryParam,it as getQueryParams,hr as getSupportedLanguages,Li as getTimeDisplay,Ii as getTimeTitle,Q as getToast,fr as getTranslations,Dn as goBack,Un as goForward,pr as hasKey,Dt as initPopup,Rt as initToast,br as initializeI18n,un as isBrowser,jn as isCurrentPath,zn as isCurrentPathPrefix,tn as isEmpty,rn as kebabCase,mr as loadFromUrl,ur as loadLanguage,yr as loadLanguageFile,dr as loadTranslations,li as mountTabbedView,Fe as navigate,Wn as navigateWithQuery,xi as observeVisibility,an as parseQuery,on as pascalCase,ei as popup,qn as reloadRoute,F as router,dn as safeJsonParse,W as scheduler,et as setHookContext,ar as setLanguage,lr as setLanguageAsync,vr as setupI18n,en as sleep,f as state,ln as stringifyQuery,d as t,fe as tHtml,sr as tLang,Yt as throttle,kr as toast,sn as truncate,Xt as uniqueId,le as useCallback,En as useContext,Vn as useDebounce,R as useEffect,An as useEventListener,On as useFetch,Fn as useInterval,Pn as useLocalStorage,nt as useMemo,Nn as usePrevious,In as useReducer,ce as useRef,N as useState,Rn as useToggle,Bn as useWindowSize,_i as utils,Tn as watch};//# sourceMappingURL=main.js.map
13
+ `;}}_handleScrollBehavior(t,e){if(t.hash){let n=document.getElementById(t.hash);if(n){n.scrollIntoView({behavior:this.scrollBehavior});return}}t.path!==e.path&&window.scrollTo({top:0,behavior:this.scrollBehavior});}_getCurrentPath(){if(this._internalPath!==null)return this._internalPath;if(this.mode==="hash")return window.location.hash.substring(1).split("?")[0]||"/";let t=window.location.pathname;return (!t||t==="blank"||t==="about:blank")&&(t="/"),this.base&&t.startsWith(this.base)&&(t=t.substring(this.base.length)),t||"/"}_buildFullPath(t){if(t.startsWith("http"))return t;let e=t.startsWith("/")?t:"/"+t;return this.base+e}_matchRoute(t){let e=t.split("?")[0].split("#")[0];for(let n of this.routes){let r=this._matchPath(n.path,e);if(r!==null)return {route:n,params:r}}return null}_matchPath(t,e){if(t==="*")return {};if(t===e)return {};let n=[],r=t.replace(/\*/g,".*").replace(/:([^/]+)/g,(a,l)=>(n.push(l),"([^/]+)")),o=new RegExp(`^${r}$`),s=e.match(o);return s?n.reduce((a,l,c)=>(a[l]=decodeURIComponent(s[c+1]),a),{}):null}_parseQuery(t){let e=t?t.includes("?")?t.split("?")[1].split("#")[0]:"":window.location.search.substring(1);return e?e.split("&").reduce((n,r)=>{let[o,s]=r.split("=").map(decodeURIComponent);return o&&(n[o]=s||""),n},{}):{}}},R=new pe;function Ke(i,t=false){t?R.replace(i):R.push(i),window.dispatchEvent(new CustomEvent("navigation",{detail:{path:i}}));}function mr(){R.back();}function br(){window.history.forward();}function fe(){return window.location.pathname}function vr(i){return fe()===i}function yr(i){return fe().startsWith(i)}function wr(){let i=fe();Ke(i,true);}function Tr(i,t){let e=new URLSearchParams(t).toString();Ke(`${i}?${e}`);}function ut(){return new URLSearchParams(window.location.search)}function Cr(i){return ut().get(i)}var ge=class{constructor(t){this._subscribers=new Set;this._storage=null;this._middleware=[];this._isHydrating=false;if(this._persist=t.persist??false,this._storageKey=t.storageKey||`store_${Date.now()}`,this._persist&&typeof window<"u"&&(this._storage=t.storage==="sessionStorage"?sessionStorage:localStorage),this._persist&&this._storage){let e=this._loadFromStorage();this._state=e!==null?e:t.state;}else this._state=t.state;t.middleware&&(this._middleware=t.middleware);}get state(){return {...this._state}}set state(t){this.setState(t);}setState(t,e){let n={...this._state},r=typeof t=="function"?t(n):t;this._state={...n,...r};for(let o of this._middleware)try{o(this._state,e);}catch(s){console.error("Store middleware error:",s);}this._persist&&!this._isHydrating&&this._saveToStorage(),this._notify();}get(t){return this._state[t]}set(t,e,n){let r={[t]:e};this.setState(r,n);}subscribe(t){return this._subscribers.add(t),t(this._state),()=>{this._subscribers.delete(t);}}subscribeToKey(t,e){let n=this._state[t],r=o=>{let s=o[t];n!==s&&(n=s,e(s));};return this.subscribe(r)}use(t){this._middleware.push(t);}clear(){if(this._state={},this._persist&&this._storage)try{this._storage.removeItem(this._storageKey);}catch(t){console.error("Failed to clear storage:",t);}this._notify();}reset(t){this._state={...t},this._persist&&this._saveToStorage(),this._notify();}hydrate(){if(!this._persist||!this._storage){console.warn("Cannot hydrate: persistence not enabled");return}this._isHydrating=true;let t=this._loadFromStorage();t!==null&&(this._state=t,this._notify()),this._isHydrating=false;}getSnapshot(){return {state:{...this._state},subscribers:this._subscribers.size,storageKey:this._storageKey}}batch(t){let e=this._notify.bind(this),n=false;this._notify=()=>{n=true;};try{t();}finally{this._notify=e,n&&this._notify();}}_notify(){let t={...this._state};for(let e of this._subscribers)try{e(t);}catch(n){console.error("Store subscriber error:",n);}}_loadFromStorage(){if(!this._storage)return null;try{let t=this._storage.getItem(this._storageKey);return t?JSON.parse(t):null}catch(t){return console.error("Failed to load from storage:",t),null}}_saveToStorage(){if(this._storage)try{this._storage.setItem(this._storageKey,JSON.stringify(this._state));}catch(t){console.error("Failed to save to storage:",t),t instanceof DOMException&&t.name==="QuotaExceededError"&&console.warn("Storage quota exceeded");}}destroy(){this._subscribers.clear(),this._middleware=[],this._state={};}};function dt(i){return new ge(i)}function Sr(i,t){let e=dt({state:{value:t(...i.map(n=>n.state))}});for(let n of i)n.subscribe(()=>{e.setState({value:t(...i.map(r=>r.state))});});return e}function xr(i,t,e){return i.subscribe(r=>{let o=e(r);Object.assign(t,o),typeof t.update=="function"&&t.update();})}var $e="solid";function De(){return $e}function ht(i){$e=i;}function He(i){i?.theme&&ht(i.theme);}function Pr(i){let t=i;return {async build(){if(!t.build){console.warn("No build configuration provided");return}console.log("\u{1F528} Building @je-es/client application...");try{await this._buildJS(),await this._buildStyles(),console.log("\u2705 Build completed successfully!");}catch(e){throw console.error("\u274C Build error:",e),e}},async _buildJS(){if(!t.build)return;let e=await Bun.build({entrypoints:[t.build.entry],outdir:t.build.output.substring(0,t.build.output.lastIndexOf("/")),target:"browser",minify:t.build.minify??false,sourcemap:t.build.sourcemap?"external":"none",splitting:t.build.optimization?.splitChunks??false,naming:{entry:t.build.output.substring(t.build.output.lastIndexOf("/")+1)},external:["sass","fs","path","url","util","stream","buffer","events","crypto","os","child_process"]});if(!e.success)throw console.error("\u274C JS Build failed:",e.logs),new Error("JS Build failed")},async _buildStyles(){let e=t.build?.styles?.input||"./app/gui/style",n=t.build?.styles?.output||"./static/client.css",r=await import('sass'),{writeFileSync:o,existsSync:s,mkdirSync:a}=await import('fs'),{join:l,dirname:c}=await import('path'),u=c(n),h=n.split("/").pop()||"client.css",y=l(e,"index.scss");if(!s(y)){console.log("\u26A0\uFE0F No index.scss found, skipping CSS build");return}try{s(u)||a(u,{recursive:!0});let K=r.compile(y,{style:t.build?.minify?"compressed":"expanded",sourceMap:!!t.build?.sourcemap,loadPaths:[e]}),Ne=l(u,h);o(Ne,K.css,"utf-8"),t.build?.sourcemap&&K.sourceMap&&o(`${Ne}.map`,JSON.stringify(K.sourceMap),"utf-8");}catch(K){throw console.error("\u274C CSS Build failed:",K),K}},async _collectScssFiles(e){let{readdirSync:n,statSync:r,existsSync:o}=await import('fs'),{join:s,extname:a}=await import('path'),l=[];if(!o(e))return l;let c=n(e);for(let u of c){let h=s(e,u),y=r(h);y.isDirectory()?l.push(...await this._collectScssFiles(h)):y.isFile()&&a(u)===".scss"&&!u.startsWith("_")&&l.push(h);}return l.sort()},async watch(){console.log("\u{1F440} Watching for changes..."),await this.build();let{watch:e}=await import('fs'),{dirname:n}=await import('path'),{existsSync:r}=await import('fs');if(t.build?.entry){let s=n(t.build.entry);e(s,{recursive:true},async(a,l)=>{if(l&&(l.endsWith(".ts")||l.endsWith(".tsx"))){console.log(`\u{1F504} ${l} changed, rebuilding JS...`);try{await this._buildJS(),console.log("\u2705 JS rebuild complete");}catch(c){console.error("\u274C JS rebuild failed:",c);}}});}let o="./app/style";r(o)&&e(o,{recursive:true},async(s,a)=>{if(a&&a.endsWith(".scss")){console.log(`\u{1F504} ${a} changed, rebuilding CSS...`);try{await this._buildStyles(),console.log("\u2705 CSS rebuild complete");}catch(l){console.error("\u274C CSS rebuild failed:",l);}}});},async init(){if(console.log("\u{1F680} [client] Initializing @je-es/client..."),t.api){let e={baseURL:t.api.baseURL,timeout:t.api.timeout,headers:t.api.headers};t.api.interceptors&&(e.interceptors={request:t.api.interceptors.request||null,response:t.api.interceptors.response||null,error:t.api.interceptors.error||null}),configureApi(e);}t.fa&&He(t.fa),t.router&&t.app?.routes&&(R.init(t.app.routes,t.router.mode,t.router.base),t.router.beforeEach&&R.beforeEach(t.router.beforeEach),t.router.afterEach&&R.afterEach(t.router.afterEach)),t.app?.root&&(document.querySelector(t.app.root)||console.error(`\u274C Root element "${t.app.root}" not found`)),t.devTools?.enabled&&this._enableDevTools();},_enableDevTools(){window.__JEES_DEV__={router:R,config:t,version:"0.0.1"};},getConfig(){return t}}}var v={fa:(i,t)=>{let e="bb_icon";if(i.includes("fa-"))return e+" "+i;let n=t||De(),o={solid:"fas",regular:"far",light:"fal",thin:"fat",duotone:"fad",brands:"fab","sharp-solid":"fass","sharp-regular":"fasr","sharp-light":"fasl","sharp-thin":"fast","sharp-duotone-solid":"fasds","sharp-duotone-regular":"fasdr","sharp-duotone-light":"fasdl","sharp-duotone-thin":"fasdt",notdog:"fa-notdog","notdog-duo":"fa-notdog-duo",jelly:"fa-jelly","jelly-fill":"fa-jelly-fill","jelly-duo":"fa-jelly-duo",chisel:"fa-chisel",etch:"fa-etch",slab:"fa-slab","slab-press":"fa-slab-press",thumbprint:"fa-thumbprint",utility:"fa-utility","utility-fill":"fa-utility-fill","utility-duo":"fa-utility-duo",whiteboard:"fa-whiteboard"}[n]||"fas";return `${e} ${o} fa-${i}`},btn:(i,t="")=>{let e="bb_btn",n=`bb_btn_${i}`;return `${e} ${n} ${t}`.trim()}},$=v,be={div:div,span:span,h1:h1,h2:h2,h3:h3,h4:h4,h5:h5,h6:h6,p:p$1,i:i,img:img,a:a,button:button,input:input,select:select,option:option,textarea:textarea,form:form,icon:(i$1,t)=>i(v.fa(i$1,t)),btn:i=>button({class:v.btn(i.level||"secondary",i.className),onclick:i.onClick,disabled:i.disabled},i.icon?be.icon(i.icon,i.iconStyle):null,i.label)},It=be,me=class{constructor(){this._handlers=new Map;}add(t,e){this._handlers.has(t)||this._handlers.set(t,new Set),this._handlers.get(t).add(e),window.addEventListener(t,e);}remove(t,e){window.removeEventListener(t,e),this._handlers.get(t)?.delete(e);}removeAll(t){if(t){let e=this._handlers.get(t);e&&(e.forEach(n=>window.removeEventListener(t,n)),this._handlers.delete(t));}else this._handlers.forEach((e,n)=>{e.forEach(r=>window.removeEventListener(n,r));}),this._handlers.clear();}get(t){return this._handlers.get(t)}has(t){return this._handlers.has(t)}count(t){return t?this._handlers.get(t)?.size??0:Array.from(this._handlers.values()).reduce((e,n)=>e+n.size,0)}};function Pt(){return window.__globalToast}function Vt(){return window.__globalPopup}function ve(){return window.__globalLoader}function Nt(){ve().hide();}function Ft(i){ve().show(i);}var te={Events:new me,toast:Pt,popup:Vt,loader:ve,showLoader:Ft,hideLoader:Nt,reload:()=>{window.location.reload();},getPathName:()=>window.location.pathname,setAttributes:(i,t)=>{document.documentElement.setAttribute(i,t);},getAttributes:i=>document.documentElement.getAttribute(i),setLocalStorage:(i,t)=>{localStorage.setItem(i,t);},getLocalStorage:i=>localStorage.getItem(i),addEventListener:(i,t)=>{te.Events.add(i,t);},removeEventListener:(i,t)=>{te.Events.remove(i,t);},dispatchEvent:i=>{window.dispatchEvent(i);},onScroll:i=>{te.Events.add("scroll",i);},getScrollY:()=>window.pageYOffset};var ye={};rt(ye,{default:()=>T,dropdown:()=>Kt,form:()=>Rt,itemsLoader:()=>$t,loader:()=>At,popup:()=>Bt,tabbedView:()=>Dt,toast:()=>Ot});var Rt={base:"bb_form",field:"bb_formField",fieldCheckbox:"bb_formFieldCheckbox",fieldInput:"bb_formFieldInput",fieldInputContainer:"bb_formFieldInputContainer",fieldInputButtons:"bb_formFieldInputButtons",fieldInputButton:"bb_formFieldInputButton",fieldInputButtonRules:"bb_formFieldInputButtonRules",fieldInputButtonRulesContent:"bb_formFieldInputButtonRulesContent",fieldTextarea:"bb_formFieldTextarea",fieldSelect:"bb_formFieldSelect",fieldLabel:"bb_formFieldLabel",fieldError:"bb_formFieldError",fieldTitle:"bb_formFieldTitle",buttonsContainer:"bb_formButtonsContainer",button:"bb_formButton",alert:"bb_formAlert",alertError:"bb_formAlert-error",alertSuccess:"bb_formAlert-success"},Ot={container:"bb_toastContainer",toast:"bb_toast",icon:"bb_toastIcon",msg:"bb_toastMsg"},At={container:"bb_loaderContainer",containerOverlay:"bb_loaderContainer--overlay",bg:"bb_loaderBg",loader:"bb_loader",spinner:{container:"bb_loaderSpinnerContainer",icon:"bb_loaderSpinnerIcon",dot:"bb_loaderSpinnerDot",pulse:"bb_loaderSpinnerPulse",text:"bb_loaderSpinnerText"},progress:{container:"bb_loaderProgressContainer",bar:"bb_loaderProgressBar",text:"bb_loaderProgressText"}},Bt={container:"bb_popupContainer",overlay:"bb_popupOverlay",popup:{base:"bb_popup",close:"bb_popupClose"},header:{container:"bb_popupHeader",icon:"bb_popupHeaderIcon",content:"bb_popupHeaderContent",title:"bb_popupHeaderContentTitle",description:"bb_popupHeaderContentDesc"},body:{container:"bb_popupBody",message:"bb_popupBodyMsg",input:"bb_popupBodyInput",formContainer:"bb_popupBodyFormContainer"},footer:"bb_popupFooter",button:"bb_btn"},Kt={container:"bb_dropdown",trigger:"bb_dropdownTrigger",menu:"bb_dropdownMenu",item:"bb_dropdownItem",divider:"bb_dropdownDivider",icon:"bb_dropdownIcon"},$t={container:"bb_itemsLoaderContainer",list:"bb_itemsLoaderList",searchbar:"bb_itemsLoaderSearchbar",loading:"bb_itemsLoaderLoading",error:"bb_itemsLoaderError",trigger:"bb_itemsLoaderTrigger",end:"bb_itemsLoaderEnd",emptyState:"bb_tabbedviewEmptyState",button:"bb_btn",item:"bb_itemsLoader-item",formFieldInput:"bb_formFieldInput"},Dt={container:"bb_tabbedview",header:"bb_tabbedviewHeader",tab:{base:"bb_tabbedviewTab",active:"bb_tabbedviewTab--active",disabled:"bb_tabbedviewTab--disabled",badge:"bb_tabbedviewBadge"},content:{container:"bb_tabbedviewContent",emptyState:"bb_tabbedviewEmptyState",error:"bb_tabbedviewError"}},T={form:Rt,toast:Ot,loader:At,popup:Bt,dropdown:Kt,itemsLoader:$t,tabbedView:Dt};var Y=T.toast,ne=class extends b{constructor(){super(...arguments);this.messages=[];this.nextId=0;}show(e,n="info",r=2e3,o){let s=this.nextId++;this.messages=[...this.messages,{id:s,message:e,type:n,translateKey:o}],setTimeout(()=>{this.messages=this.messages.filter(a=>a.id!==s),this.update();},r);}success(e,n,r){this.show(e,"success",n,r);}error(e,n,r){this.show(e,"error",n,r);}info(e,n,r){this.show(e,"info",n,r);}warning(e,n,r){this.show(e,"warning",n,r);}render(){return this.messages.length===0?html``:div(Y.container,...this.messages.map(e=>this.renderToast(e)))}renderToast(e){let n={success:v.fa("check-circle"),error:v.fa("exclamation-circle"),info:v.fa("info-circle"),warning:v.fa("exclamation-triangle")},r=e.translateKey?d(e.translateKey):e.message;return div({key:String(e.id),class:`${Y.toast} ${Y.toast}--${e.type}`,"data-translate":e.translateKey||void 0},i(`${n[e.type]} ${Y.icon}`),span(Y.msg,r))}};p([f],ne.prototype,"messages");var A=null;function zt(i){if(A)return A;let t=i||document.createElement("div");return i||document.body.appendChild(t),A=new ne,A.mount(t),A}function Q(){return A||(A=zt()),A}var Hr={show:(i,t="info",e,n)=>{Q().show(i,t,e,n);},success:(i,t,e)=>{Q().success(i,t,e);},error:(i,t,e)=>{Q().error(i,t,e);},info:(i,t,e)=>{Q().info(i,t,e);},warning:(i,t,e)=>{Q().warning(i,t,e);}};var qt=T.loader,I=class extends b{constructor(){super(...arguments);this.visible=false;this.message="";this.variant="spinner";this.size="medium";this.overlay=true;this.progress=0;this.showProgress=false;this.animationFrame=null;this.hideTimeout=null;this.handleKeyPress=e=>{e.key==="Escape"&&this.visible&&!this.overlay&&this.hide();};}async onMount(){this.setupKeyboardListener(),this.initializeAccessibility(),window.addEventListener("languagechange",()=>{this.message||this.update();});}onUnmount(){this.animationFrame&&cancelAnimationFrame(this.animationFrame),this.hideTimeout&&clearTimeout(this.hideTimeout),document.removeEventListener("keydown",this.handleKeyPress);}render(){let{loader:e}=T,n=[e.container,this.overlay?`${e.containerOverlay}`:"",`${e.container}--${this.size}`].filter(Boolean).join(" ");return div({class:n,"data-status":this.visible?"visible":"hidden",role:"status","aria-live":"polite","aria-busy":"true"},div(e.bg),div(e.loader,this.renderSpinner(),this.renderMessage(),this.showProgress?this.renderProgressBar():null))}renderSpinner(){let{loader:e}=T,n=`${e.spinner.container} ${e.spinner.container}--${this.variant}`;switch(this.variant){case "dots":return div(n,div(e.spinner.dot),div(e.spinner.dot),div(e.spinner.dot));case "pulse":return div(n,div(e.spinner.pulse));case "spinner":default:return div(n,div(e.spinner.icon))}}renderMessage(){let{loader:e}=T,n=this.message||d("loader.loading");return div({class:e.spinner.text,"data-translate":this.message?void 0:"loader.loading"},n)}renderProgressBar(){let{loader:e}=T;return div(e.progress.container,div({class:e.progress.bar,style:`width: ${this.progress}%`,"aria-valuenow":this.progress.toString(),"aria-valuemin":"0","aria-valuemax":"100"}),div(e.progress.text,`${Math.round(this.progress)}%`))}show(e){typeof e=="string"?this.message=e:e&&(this.message=e.message||"",this.variant=e.variant||"spinner",this.size=e.size||"medium",this.overlay=e.overlay!==void 0?e.overlay:true),this.visible=true,this.progress=0,this.showProgress=false,this.applyBodyLock(),this.update();}hide(e=0){this.hideTimeout&&clearTimeout(this.hideTimeout),e>0?this.hideTimeout=window.setTimeout(()=>{this.performHide();},e):this.performHide();}setMessage(e){this.message=e,this.update();}setProgress(e){this.showProgress=true,this.progress=Math.max(0,Math.min(100,e)),this.update();}updateProgress(e){this.setProgress(this.progress+e);}performHide(){this.visible=false,this.message="",this.progress=0,this.showProgress=false,this.removeBodyLock(),this.update();}applyBodyLock(){this.overlay&&(document.body.style.overflow="hidden");}removeBodyLock(){document.body.style.overflow="";}setupKeyboardListener(){this.handleKeyPress=this.handleKeyPress.bind(this),document.addEventListener("keydown",this.handleKeyPress);}initializeAccessibility(){let e=this.element?.querySelector(`.${qt.spinner.container}`);e&&e.setAttribute("aria-label",d("loading"));}isVisible(){return this.visible}getStatus(){return {visible:this.visible,message:this.message,progress:this.progress}}};p([f],I.prototype,"visible"),p([f],I.prototype,"message"),p([f],I.prototype,"variant"),p([f],I.prototype,"size"),p([f],I.prototype,"overlay"),p([f],I.prototype,"progress"),p([f],I.prototype,"showProgress");var g={form:"bb_form",field:"bb_formField",fieldCheckbox:"bb_formFieldCheckbox",fieldInput:"bb_formFieldInput",fieldInputContainer:"bb_formFieldInputContainer",fieldInputButtons:"bb_formFieldInputButtons",fieldInputButton:"bb_formFieldInputButton",fieldInputButtonRules:"bb_formFieldInputButtonRules",fieldInputButtonRulesContent:"bb_formFieldInputButtonRulesContent",fieldTextarea:"bb_formFieldTextarea",fieldSelect:"bb_formFieldSelect",fieldError:"bb_formFieldError",buttonsContainer:"bb_formButtonsContainer",button:"bb_formButton",alert:"bb_formAlert",alertError:"bb_formAlert-error",alertSuccess:"bb_formAlert-success"},P=class extends b{constructor(e){super(e);this.fields=[];this.formData={};this.isSubmitting=false;this.submitError="";this.submitSuccess=false;this.passwordVisibility={};let n=[];for(let r of this.props.fields)if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&"name"in o&&"type"in o&&n.push(o);else n.push(r);this.fields=n.map(r=>({...r,error:void 0,touched:false}));for(let r of this.fields)this.formData[r.name]=r.value||"";}onMount(){}handleChange(e,n){this.formData[e]=n;let r=this.fields.find(o=>o.name===e);r&&this.props.autoValidate&&(r.error=this.validateField(r,n),r.touched=true),this.update();}handleBlur(e){let n=this.fields.find(r=>r.name===e);n&&(n.touched=true,n.error=this.validateField(n,this.formData[e]),this.update());}validateField(e,n){let r=e.validation;if(!r)return;if(r.required&&!n)return r.message||`${e.label||e.name} is required`;if(!n)return;let o=String(n);if(r.minLength&&o.length<r.minLength)return r.message||`Minimum ${r.minLength} characters required`;if(r.maxLength&&o.length>r.maxLength)return r.message||`Maximum ${r.maxLength} characters allowed`;if(r.min!==void 0&&Number(n)<r.min)return r.message||`Minimum value is ${r.min}`;if(r.max!==void 0&&Number(n)>r.max)return r.message||`Maximum value is ${r.max}`;if(r.pattern&&!r.pattern.test(o))return r.message||"Invalid format";if(r.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))return r.message||"Invalid email format";if(r.url&&!/^https?:\/\/.+/.test(o))return r.message||"Invalid URL format";if(r.custom){let s=r.custom(n);if(s!==true)return typeof s=="string"?s:void 0}}validateForm(){let e=true,n={};for(let r of this.fields){let o=this.validateField(r,this.formData[r.name]);r.error=o,r.touched=true,o&&(e=false,n[r.name]=o);}return this.update(),!e&&this.props.onValidationError&&this.props.onValidationError(n),e}async handleSubmit(e){if(e.preventDefault(),!this.validateForm()){let n=this.fields.find(r=>r.error);n&&document.querySelector(`[name="${n.name}"]`)?.focus();return}this.isSubmitting=true,this.submitError="",this.submitSuccess=false,this.update();try{if(this.props.onSubmit)await this.props.onSubmit(this.formData,e);else if(this.props.endpoint){let n=await api({method:this.props.method||"POST",url:this.props.endpoint,data:this.formData});this.submitSuccess=!0,this.props.onSuccess&&this.props.onSuccess(n.data);}}catch(n){let r=n instanceof Error?n.message:d("global.loading");this.submitError=r,this.props.onError&&this.props.onError(n);}finally{this.isSubmitting=false,this.update();}}renderLabel(e){if(typeof e.label=="object"&&e.label!==null){let r=e.label,o=r.text,s=r.icon,a=r.title;if(!o&&!s)return "";let l={for:e.name};return a&&(l.title=a),s?label(l,span($.fa(s)),o?span(Ge.form.fieldTitle,o):""):label(l,o||"")}if(!e.label)return "";let n={for:e.name};return label(n,String(e.label))}getFieldButtons(e){let n=[];if(!e.fieldButtons&&!e.showValidationRules)return n;if(e.type==="password"&&(e.fieldButtons?.includes("togglePassword")||e.fieldButtons?.some(r=>r?.type==="togglePassword"))&&n.push({type:"togglePassword",icon:"eye",title:d("form.showPassword",{},"Show Password")}),(e.showValidationRules===true||e.fieldButtons?.includes("rules"))&&e.validation&&n.push({type:"rules",icon:"list-check"}),e.fieldButtons)for(let r of e.fieldButtons)typeof r=="object"&&r.type==="custom"&&n.push(r);return n}handleFieldButton(e,n){if(n==="togglePassword"){this.passwordVisibility[e.name]=!this.passwordVisibility[e.name];let r=this.passwordVisibility[e.name],o=document.querySelector(`input[name="${e.name}"]`);o&&(o.type=r?"text":"password");let a=o?.closest(`.${g.fieldInputContainer}`)?.querySelector(`.${g.fieldInputButtons}`)?.querySelector("button");if(a){let l=a.querySelector("span");l&&(l.className=l.className.replace(/fa-eye(-slash)?/,r?"fa-eye-slash":"fa-eye")),a.title=r?d("form.hidePassword",{},"Hide Password"):d("form.showPassword",{},"Show Password");}}}renderValidationRules(e){if(!e.validation)return "";let n=[];return e.validation.required&&n.push(d("form.rule.required",{},"This field is required")),e.validation.minLength&&n.push(d("form.rule.minLength",{length:String(e.validation.minLength)},`Minimum ${e.validation.minLength} characters`)),e.validation.maxLength&&n.push(d("form.rule.maxLength",{length:String(e.validation.maxLength)},`Maximum ${e.validation.maxLength} characters`)),e.validation.min!==void 0&&n.push(d("form.rule.min",{value:String(e.validation.min)},`Minimum value: ${e.validation.min}`)),e.validation.max!==void 0&&n.push(d("form.rule.max",{value:String(e.validation.max)},`Maximum value: ${e.validation.max}`)),e.validation.email&&n.push(d("form.rule.email",{},"Valid email format required")),e.validation.url&&n.push(d("form.rule.url",{},"Valid URL format required")),e.validation.pattern&&n.push(d("form.rule.pattern",{},"Pattern does not match")),n.length===0?"":div({class:g.fieldInputButtonRulesContent},...n.map(r=>div({},r)))}renderFieldButtons(e){let n=this.getFieldButtons(e);if(n.length===0)return "";let r=[];for(let o of n)o.type==="rules"?r.push(div({class:g.fieldInputButtonRules,title:o.title},button({type:"button",class:g.fieldInputButton,tabindex:-1,onclick:s=>{s.preventDefault(),s.stopPropagation();}},span($.fa(o.icon||"fa-circle-info"))),this.renderValidationRules(e))):r.push(button({type:"button",class:g.fieldInputButton,title:o.title,tabindex:-1,onclick:s=>{s.preventDefault(),s.stopPropagation(),o.type==="togglePassword"?this.handleFieldButton(e,o.type):o.onClick&&o.onClick();}},span($.fa(o.icon||"fa-gear"))));return div({class:g.fieldInputButtons},...r)}renderField(e){let n=this.formData[e.name]||"",r=this.renderLabel(e),o=[g.field,e.className].filter(Boolean).join(" "),s=e.error&&e.touched?span({class:g.fieldError},e.error):"";switch(e.type){case "textarea":return div({class:o},r,div({class:g.fieldInputContainer},textarea({id:e.name,name:e.name,placeholder:e.placeholder||"",disabled:e.disabled||this.isSubmitting,oninput:a=>{let l=a.target;this.handleChange(e.name,l.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldTextarea},String(n)),this.renderFieldButtons(e)),s);case "select":{let l=(e.options||[]).map(c=>option({value:String(c.value),selected:String(c.value)===String(n)},c.label));return div({class:o},r,div({class:g.fieldInputContainer},select({id:e.name,name:e.name,disabled:e.disabled||this.isSubmitting,onchange:c=>{let u=c.target;this.handleChange(e.name,u.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldSelect},option({value:"",selected:String(n)===""},d("form.select_placeholder",{},"Select...")),...l),this.renderFieldButtons(e)),s)}case "checkbox":{let a=!!n,l=[g.field,g.fieldCheckbox,e.className].filter(Boolean).join(" "),c="",u="";return typeof e.label=="object"&&e.label!==null?(c=e.label.icon||"",u=e.label.text||""):typeof e.label=="string"&&(u=e.label),div({class:l},input({type:"checkbox",id:e.name,name:e.name,checked:a,disabled:e.disabled||this.isSubmitting,onchange:h=>{let y=h.target;this.handleChange(e.name,y.checked);},class:g.fieldCheckbox}),label({for:e.name},c?span($.fa(c)):"",u||""),s)}default:{let l=e.type==="password"&&this.passwordVisibility[e.name]?"text":e.type||"text";return div({class:o},r,div({class:g.fieldInputContainer},input({type:l,id:e.name,name:e.name,placeholder:e.placeholder||"",value:String(n),disabled:e.disabled||this.isSubmitting,oninput:c=>{let u=c.target;this.handleChange(e.name,u.value);},onblur:()=>this.handleBlur(e.name),class:g.fieldInput}),this.renderFieldButtons(e)),s)}}}renderButtons(){let e=this.props.buttons||{submit:{label:d("form.submit",{},"Submit"),onClick:"submit"}},n=[];for(let[r,o]of Object.entries(e)){let s=o.onClick==="submit"||r==="submit",a=this.isSubmitting&&s,l=this.isSubmitting&&s&&o.loadingLabel||o.label;n.push(button({type:s?"submit":"button",class:[g.button,o.className].filter(Boolean).join(" "),disabled:a,title:o.title,onclick:s?void 0:async c=>{if(c.preventDefault(),typeof o.onClick=="function")try{this.isSubmitting=!0,this.update(),await o.onClick();}finally{this.isSubmitting=false,this.update();}}},o.icon?span($.fa(o.icon)," "):"",l));}return div({class:g.buttonsContainer},...n)}render(){let e=[];for(let r of this.props.fields)if(Array.isArray(r)){let o=[];for(let s of r)if(s&&typeof s=="object"&&"name"in s&&"type"in s){let a=this.fields.find(l=>l.name===s.name);a&&o.push(this.renderField(a));}else o.push(s);e.push(div({class:"bb_formFieldGroup"},...o));}else {let o=this.fields.find(s=>s.name===r.name);o&&e.push(this.renderField(o));}let n=[g.form,this.props.className].filter(Boolean).join(" ");return form({class:n,onsubmit:r=>this.handleSubmit(r)},this.submitError?div({class:[g.alert,g.alertError].join(" ")},this.submitError):"",this.submitSuccess?div({class:[g.alert,g.alertSuccess].join(" ")},d("form.success",{},"Success")):"",...e,this.renderButtons())}styles(){return Re``}};p([f],P.prototype,"fields"),p([f],P.prototype,"formData"),p([f],P.prototype,"isSubmitting"),p([f],P.prototype,"submitError"),p([f],P.prototype,"submitSuccess");function Te(i){return new P(i).render()}var w=T.popup,oe=class extends b{constructor(){super(...arguments);this.popups=[];this.nextId=0;}async onMount(){this.setupKeyboardListener(),window.addEventListener("languagechange",()=>{this.update();});}onUnmount(){this.handleEscapeKey&&document.removeEventListener("keydown",this.handleEscapeKey);}render(){return this.popups.length===0?div(w.container):div(w.container,...this.popups.map(e=>this.renderPopup(e)))}renderPopup(e){let n=`bb_popup--${e.size||"medium"}`,r=e.variant?`bb_popup--${e.variant}`:"";return div({key:String(e.id),class:w.overlay,"data-popup-id":e.id,onclick:o=>{o.target.classList.contains(w.overlay)&&e.closeOnOverlay!==false&&this.closePopup(e.id,false);}},div({class:`${w.popup.base} ${n} ${r}`,role:"dialog","aria-modal":"true","aria-labelledby":`popup-title-${e.id}`},e.showCloseButton!==false?button({class:w.popup.close,onclick:()=>this.closePopup(e.id,false),"aria-label":"Close"},i(v.fa("times"))):null,div(w.header.container,e.icon?div(w.header.icon,i(e.icon)):null,div(w.header.content,h2({id:`popup-title-${e.id}`,class:w.header.title,"data-translate":e.titleTranslateKey},e.titleTranslateKey?d(e.titleTranslateKey):e.title),e.description?p$1({class:w.header.description,"data-translate":e.descriptionTranslateKey},e.descriptionTranslateKey?he(e.descriptionTranslateKey):e.description):null)),div(w.body.container,e.message?p$1({class:w.body.message,"data-translate":e.messageTranslateKey},e.messageTranslateKey?he(e.messageTranslateKey):e.message):null,e.type==="prompt"?input({type:"text",class:w.body.input,value:e.inputValue||"",placeholder:d("popup.prompt.placeholder"),"data-translate":"popup.prompt.placeholder",oninput:o=>{e.inputValue=o.target.value;}}):null,e.type==="form"&&e.formConfig?div(w.body.formContainer,Te(e.formConfig)):null,e.customContent||null),e.buttons&&e.buttons.length>0&&e.type!=="form"?div(w.footer,...e.buttons.map(o=>button({class:`${w.button} ${o.variant||"secondary"}`,"data-translate":o.translateKey,disabled:o.loading||e.isSubmitting,onclick:async()=>{o.loading||e.isSubmitting||await o.onClick();}},o.icon?i(o.icon):null,o.loading||e.isSubmitting?i(v.fa("spinner","solid")+" fa-spin"):null," ",o.translateKey?d(o.translateKey):o.label))):null))}show(e){return new Promise(n=>{let r=this.nextId++,o={...e,id:r,resolve:n,type:e.type||"custom",size:e.size||"medium",closeOnOverlay:e.closeOnOverlay!==false,closeOnEscape:e.closeOnEscape!==false,showCloseButton:e.showCloseButton!==false,isSubmitting:false};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}showForm(e){return new Promise((n,r)=>{let o=this.nextId++,s={...e.formConfig,onSubmit:async l=>{let c=this.popups.find(u=>u.id===o);c&&(c.isSubmitting=true,this.update());try{e.formConfig.onSubmit&&await e.formConfig.onSubmit(l,new Event("submit")),this.closePopup(o,l),n(l);}catch(u){c&&(c.isSubmitting=false,this.update()),e.formConfig.onError&&e.formConfig.onError(u);}},buttons:e.formConfig.buttons||{submit:{label:d("global.submit",{},"Submit"),className:`${w.button} primary wide`,onClick:"submit"}}},a={title:e.title,titleTranslateKey:e.titleTranslateKey,description:e.description,descriptionTranslateKey:e.descriptionTranslateKey,type:"form",variant:e.variant||"default",size:e.size||"medium",icon:e.icon,formConfig:s,closeOnOverlay:e.closeOnOverlay!==false,closeOnEscape:e.closeOnEscape!==false,showCloseButton:e.showCloseButton!==false,id:o,resolve:n,isSubmitting:false};this.popups=[...this.popups,a],this.applyBodyLock(),this.update();})}confirm(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"confirm",variant:e.variant||"default",size:e.size||"small",icon:e.icon,resolve:n,onConfirm:e.onConfirm,onCancel:e.onCancel,buttons:[{label:e.cancelLabel||"Cancel",translateKey:e.cancelTranslateKey||"button.cancel",variant:"secondary",icon:v.fa("times"),onClick:async()=>{e.onCancel&&await e.onCancel(),this.closePopup(r,false);}},{label:e.confirmLabel||"Confirm",translateKey:e.confirmTranslateKey||"button.confirm",variant:e.variant==="danger"?"danger":"primary",icon:v.fa("check"),onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}alert(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"alert",variant:e.variant||"info",size:e.size||"small",icon:e.icon,resolve:n,onConfirm:e.onConfirm,buttons:[{label:e.okLabel||"OK",translateKey:e.okTranslateKey||"popup.ok",variant:"primary",icon:v.fa("check"),onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,o],this.applyBodyLock(),this.update();})}prompt(e){return new Promise(n=>{let r=this.nextId++,o={id:r,title:e.title,titleTranslateKey:e.titleTranslateKey,message:e.message,messageTranslateKey:e.messageTranslateKey,type:"prompt",variant:"default",icon:e.icon,inputValue:e.defaultValue||"",resolve:n,onConfirm:e.onConfirm,onCancel:e.onCancel,buttons:[{label:e.cancelLabel||"Cancel",translateKey:e.cancelTranslateKey||"popup.cancel",variant:"secondary",onClick:async()=>{e.onCancel&&await e.onCancel(),this.closePopup(r,null);}},{label:e.confirmLabel||"OK",translateKey:e.confirmTranslateKey||"popup.ok",variant:"primary",onClick:async()=>{let s=o.inputValue||"";e.onConfirm&&await e.onConfirm(s),this.closePopup(r,s);}}]};this.popups=[...this.popups,o],this.applyBodyLock();})}closePopup(e,n){let r=this.popups.find(o=>o.id===e);r?.resolve&&r.resolve(n),this.popups=this.popups.filter(o=>o.id!==e),this.popups.length===0&&this.removeBodyLock(),this.update();}closeAll(){this.popups.forEach(e=>{e.resolve&&e.resolve(false);}),this.popups=[],this.removeBodyLock(),this.update();}applyBodyLock(){document.body.style.overflow="hidden";}removeBodyLock(){document.body.style.overflow="";}setupKeyboardListener(){this.handleEscapeKey=e=>{if(e.key==="Escape"&&this.popups.length>0){let n=this.popups[this.popups.length-1];n.closeOnEscape!==false&&this.closePopup(n.id,false);}},document.addEventListener("keydown",this.handleEscapeKey);}};p([f],oe.prototype,"popups");var B=null;function Xt(i){if(B)return B;let t=i||document.createElement("div");return i||document.body.appendChild(t),B=new oe,B.mount(t),B}function k(){return B||(B=Xt()),B}var gi={show:i=>k().show(i),confirm:i=>k().confirm(i),alert:i=>k().alert(i),prompt:i=>k().prompt(i),showForm:i=>k().showForm(i),closePopup:(i,t)=>k().closePopup(i,t),closeLastPopup:()=>k().closePopup(k().popups.length-1,false),closeFirstPopup:()=>k().closePopup(0,false),closeAll:()=>k().closeAll()};var {tabbedView:M}=T,x=class extends b{constructor(){super(...arguments);this.activeTabId="";this.tabs=[];this.position="top";this.style="default";this.className="";this.headerClassName="";this.contentClassName="";this.showTabCount=false;this.persistState=false;this.storageKey="tabbedview-active";this.currentTabComponent=null;}async onMount(){window.addEventListener("languagechange",()=>{this.update();});}onUnmount(){this.currentTabComponent&&typeof this.currentTabComponent.onUnmount=="function"&&this.currentTabComponent.onUnmount();}init(e){if(this.tabs=e.tabs,this.position=e.position||"top",this.style=e.style||"default",this.className=e.className||"",this.headerClassName=e.headerClassName||"",this.contentClassName=e.contentClassName||"",this.showTabCount=e.showTabCount||false,this.persistState=e.persistState||false,this.storageKey=e.storageKey||"tabbedview-active",this.onChange=e.onChange,this.persistState){let n=localStorage.getItem(this.storageKey);n&&this.tabs.find(r=>r.id===n)&&(this.activeTabId=n);}return this.activeTabId||(this.activeTabId=e.defaultTab||this.tabs[0]?.id||""),this.update(),this}async setActiveTab(e){let n=this.tabs.find(r=>r.id===e);!n||n.disabled||(this.currentTabComponent&&typeof this.currentTabComponent.onUnmount=="function"&&this.currentTabComponent.onUnmount(),this.currentTabComponent=null,this.activeTabId=e,this.persistState&&localStorage.setItem(this.storageKey,e),n.onActivate&&await n.onActivate(),this.onChange&&await this.onChange(e),this.update());}addTab(e){this.tabs=[...this.tabs,e],this.update();}removeTab(e){this.tabs=this.tabs.filter(n=>n.id!==e),this.activeTabId===e&&this.tabs.length>0&&(this.activeTabId=this.tabs[0].id),this.update();}updateTab(e,n){let r=this.tabs.find(o=>o.id===e);r&&(Object.assign(r,n),this.update());}getActiveTab(){return this.tabs.find(e=>e.id===this.activeTabId)}render(){let e=[M.container,`bb_tabbedview__--${this.position}`,`bb_tabbedview__--${this.style}`,this.className].filter(Boolean).join(" ");return div(e,this.renderTabList(),this.renderTabContent())}renderTabList(){let e=[M.header,this.headerClassName].filter(Boolean).join(" ");return div(e,...this.tabs.map(n=>this.renderTab(n)))}renderTab(e){let n=this.activeTabId===e.id,r=[M.tab.base,n?M.tab.active:"",e.disabled?M.tab.disabled:""].filter(Boolean).join(" "),o=e.translateKey?d(e.translateKey):e.label;return button({key:e.id,class:r,onclick:()=>this.setActiveTab(e.id),disabled:e.disabled,"data-translate":e.translateKey,"aria-selected":n,role:"tab"},e.icon?i(e.icon):null,span({},o),e.badge!==void 0&&e.badge!==null&&e.badge!==0?span(M.tab.badge,typeof e.badge=="number"&&e.badge>99?"99+":String(e.badge)):null)}renderTabContent(){let e=[M.content.container,this.contentClassName].filter(Boolean).join(" "),n=this.getActiveTab();return n?div({class:e,role:"tabpanel"},this.renderActiveTabContent(n)):div(e,div(M.content.emptyState,p$1({},d("tabbedView.no_content"))))}renderActiveTabContent(e){if(e.component)try{if(e.component instanceof b){this.currentTabComponent=e.component;let n=this.currentTabComponent.render(),r={...n.props,ref:s=>{s&&this.currentTabComponent&&this.currentTabComponent.setElement(s),typeof n.props.ref=="function"&&n.props.ref(s);}},o={...n,props:r};return typeof this.currentTabComponent.onMount=="function"&&setTimeout(()=>{this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&this.currentTabComponent.onMount();},0),o}if(typeof e.component=="function"){let n=e.component;return n.prototype&&typeof n.prototype.render=="function"?(this.currentTabComponent||(this.currentTabComponent=new n,this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&setTimeout(()=>{this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&this.currentTabComponent.onMount();},0)),this.currentTabComponent.render()):n()}}catch(n){return console.error("Error rendering tab component:",n),div(M.content.error,d("global.loading"))}return e.content?e.content:div(M.content.emptyState,p$1({},d("tabbedView.no_content")))}};p([f],x.prototype,"activeTabId"),p([f],x.prototype,"tabs"),p([f],x.prototype,"position"),p([f],x.prototype,"style"),p([f],x.prototype,"className"),p([f],x.prototype,"headerClassName"),p([f],x.prototype,"contentClassName"),p([f],x.prototype,"showTabCount"),p([f],x.prototype,"persistState"),p([f],x.prototype,"storageKey");function nn(i){let t=new x;return t.init(i),t}async function _i(i,t){let e=nn(t);return await e.mount(i),e}var m=T.itemsLoader,Se=class extends b{constructor(){super(...arguments);this.items=[];this.loadState={loading:false,error:null,hasMore:true,page:0,total:0};this.filters={};this.scrollContainer=null;this.loadMoreObserver=null;this.currentLoadMoreTrigger=null;this.loadMoreMutationObserver=null;this.visibilityObserver=null;this.viewedItems=new Set;this.dropdownIsOpen=false;this.itemsListContainer=null;this.searchInput=null;this.isUpdating=false;this.searchDebounceTimer=null;this.handleScroll=()=>{if(!this.scrollContainer||this.loadState.loading||!this.loadState.hasMore)return;let{scrollTop:e,scrollHeight:n,clientHeight:r}=this.scrollContainer;n-e-r<this.config.scrollThreshold&&this.loadMore();};this.handleItemClick=(e,n)=>{this.config.onItemClick?.(e,n);};}initialize(e){this.config={pageSize:10,loadMoreText:"Load More",loadingText:"Loading...",errorText:"Failed to load items",containerClassName:m.container,itemClassName:m.item,enableInfiniteScroll:true,scrollThreshold:200,enableSearch:false,searchPlaceholder:"Search...",searchFilterKey:"search",searchDebounceMs:300,enableVisibilityTracking:false,visibilityThreshold:.5,visibilityRootMargin:"0px",extractItems:n=>n.notifications||n.items||n.data||n.logs||[],extractTotal:n=>n.pagination?.total||n.total||n.count||0,...e},this.config.filters&&(this.filters={...this.config.filters}),this.config.initialItems&&(this.items=[...this.config.initialItems]);}async onMount(){this.items.length===0&&await this.loadMore(),this.config.enableInfiniteScroll&&this.setupInfiniteScroll(),this.config.scrollThreshold&&this.setupScrollListener(),this.config.enableVisibilityTracking&&this.setupVisibilityTracking();}onUnmount(){this.disconnectInfiniteScrollObserver(),this.disconnectVisibilityObserver(),this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null),this.scrollContainer&&(this.scrollContainer.removeEventListener("scroll",this.handleScroll),this.scrollContainer=null),this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer);}async loadMore(){if(!(this.loadState.loading||!this.loadState.hasMore))try{let e=this.scrollContainer||this.findScrollContainer(),n=e?.scrollTop||0,r=e?.scrollHeight||0;this.loadState={...this.loadState,loading:!0,error:null},this.updateLoadingState();let o=this.loadState.page+1,s=this.buildUrl(o),a=await fetch(s,{credentials:"include",headers:this.buildHeaders()});if(!a.ok)throw new Error(`HTTP ${a.status}: ${a.statusText}`);let l=await a.json(),c=this.config.extractItems(l),u=this.config.extractTotal(l);this.items=[...this.items,...c],this.loadState={loading:!1,error:null,hasMore:this.items.length<u,page:o,total:u},this.updateLoadingState(),this.appendNewItems(c),e&&n>0&&(e.scrollTop=n,requestAnimationFrame(()=>{let y=e.scrollHeight-r;Math.abs(y)>10&&(e.scrollTop=n);})),this.reconnectInfiniteScrollObserver(),this.config.onLoadMore?.(o,this.items);}catch(e){this.loadState={...this.loadState,loading:false,error:e instanceof Error?e.message:this.config.errorText},this.updateLoadingState(),this.updateFooter(),this.config.onError?.(e instanceof Error?e:new Error("Unknown error"));}}async reload(){this.items=[],this.loadState={loading:false,error:null,hasMore:true,page:0,total:0},await this.loadMore();}async applyFilters(e){if(!this.isUpdating){this.isUpdating=true,this.filters={...e},this.items=[],this.loadState={loading:true,error:null,hasMore:true,page:0,total:0},this.updateLoadingState();try{let n=this.buildUrl(1),r=await fetch(n,{credentials:"include",headers:this.buildHeaders()});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);let o=await r.json(),s=this.config.extractItems(o),a=this.config.extractTotal(o);this.items=[...s],this.loadState={loading:!1,error:null,hasMore:this.items.length<a,page:1,total:a},this.itemsListContainer&&(this.itemsListContainer.innerHTML=""),this.element&&this.element.querySelectorAll(`.${m.trigger}, .${m.end}, .${m.error}, .${m.loading}, .${m.emptyState}`).forEach(l=>l.remove()),this.items.length>0?(this.itemsListContainer||(this.itemsListContainer=this.element?.querySelector(`.${m.list}`)),this.itemsListContainer&&this.appendNewItems(this.items)):this.updateFooter(),this.itemsListContainer=this.element?.querySelector(`.${m.list}`),this.reconnectInfiniteScrollObserver(),this.config.onLoadMore?.(1,this.items),this.config.onFiltersChange?.(this.filters);}catch(n){this.loadState={...this.loadState,loading:false,error:n instanceof Error?n.message:this.config.errorText},this.updateLoadingState(),this.config.onError?.(n instanceof Error?n:new Error("Unknown error"));}finally{this.isUpdating=false;}}}async handleSearch(e){this.searchDebounceTimer&&clearTimeout(this.searchDebounceTimer),this.searchDebounceTimer=setTimeout(async()=>{let n={...this.filters};e.trim()?n[this.config.searchFilterKey]=e.trim():delete n[this.config.searchFilterKey],await this.applyFilters(n);},this.config.searchDebounceMs);}updateItems(e){this.items=[...e],this.itemsListContainer&&(this.itemsListContainer.innerHTML="",this.appendNewItems(e));}setupVisibilityTracking(){if(!this.config.enableVisibilityTracking)return;this.visibilityObserver&&this.visibilityObserver.disconnect();let e=this.findScrollContainer();this.visibilityObserver=new IntersectionObserver(n=>{n.forEach(r=>{if(r.isIntersecting&&this.dropdownIsOpen){let o=r.target,s=parseInt(o.getAttribute("data-item-index")||"-1");if(s>=0&&s<this.items.length){let a=this.items[s],l=this.config.getItemId?.(a),c=this.config.shouldTrackItem?.(a)??true;l&&!this.viewedItems.has(l)&&c&&this.viewedItems.add(l);}}});},{root:e,rootMargin:this.config.visibilityRootMargin,threshold:this.config.visibilityThreshold}),this.observeTrackableItems();}observeTrackableItems(){if(!this.visibilityObserver||!this.itemsListContainer)return;this.itemsListContainer.querySelectorAll("[data-item-index]").forEach(n=>{let r=parseInt(n.getAttribute("data-item-index")||"-1");if(r>=0&&r<this.items.length){let o=this.items[r];(this.config.shouldTrackItem?.(o)??true)&&this.visibilityObserver.observe(n);}});}trackAlreadyVisibleItems(){if(!this.itemsListContainer)return;let e=this.findScrollContainer();if(!e)return;let n=this.itemsListContainer.querySelectorAll("[data-item-index]"),r=e.getBoundingClientRect();n.forEach(o=>{let s=parseInt(o.getAttribute("data-item-index")||"-1");if(s<0||s>=this.items.length)return;let a=this.items[s],l=this.config.getItemId?.(a);if(!l||this.viewedItems.has(l)||!(this.config.shouldTrackItem?.(a)??true))return;let u=o.getBoundingClientRect();u.top<r.bottom&&u.bottom>r.top&&u.top>=r.top-100&&u.bottom<=r.bottom+100&&this.viewedItems.add(l);});}disconnectVisibilityObserver(){this.visibilityObserver&&(this.visibilityObserver.disconnect(),this.visibilityObserver=null);}handleDropdownOpen(){this.dropdownIsOpen=true,this.viewedItems.clear(),this.config.enableVisibilityTracking&&(this.trackAlreadyVisibleItems(),this.observeTrackableItems()),this.config.onDropdownOpen?.();}async handleDropdownClose(){if(this.dropdownIsOpen=false,this.viewedItems.size>0&&this.config.onItemsViewed){let e=this.items.filter(n=>{let r=this.config.getItemId?.(n);return r&&this.viewedItems.has(r)});await this.config.onItemsViewed(e);}this.viewedItems.clear(),this.config.onDropdownClose?.();}async performBatchAction(e,n){this.config.onBatchAction&&await this.config.onBatchAction(e,n);}appendNewItems(e){if(this.itemsListContainer||(this.itemsListContainer=this.element?.querySelector(`.${m.list}`)),!this.itemsListContainer)return;let n=document.createDocumentFragment(),r=this.items.length-e.length;e.forEach((o,s)=>{let a=r+s,l=this.config.renderItem(o,a);l.setAttribute("data-item-index",a.toString()),this.config.onItemClick?(l.className=`${l.className} ${this.config.itemClassName} clickable`,l.onclick=()=>this.handleItemClick(o,a)):l.className=`${l.className} ${this.config.itemClassName}`,n.appendChild(l);}),this.itemsListContainer.appendChild(n),this.updateFooter(),this.config.enableVisibilityTracking&&this.dropdownIsOpen&&setTimeout(()=>this.observeTrackableItems(),100);}updateLoadingState(){let e=this.element?.querySelector(`.${m.container}`);if(!e)return;let n=e.querySelector(`.${m.loading}`);if(this.loadState.loading){if(!n){let r=this.renderLoading();n=this.createElementFromVNode(r),e.appendChild(n);}}else n&&n.remove();}updateFooter(){let e=this.element;if(e){if(e.querySelectorAll(`.${m.trigger}, .${m.end}, .${m.emptyState}`).forEach(n=>{n.remove();}),this.items.length===0&&!this.loadState.loading&&this.config.emptyStateConfig){let n=this.renderEmptyState(),r=createDOMElement(n);e.appendChild(r);return}if(this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0){let n=this.renderLoadMoreTrigger(),r=createDOMElement(n);e.appendChild(r);}if(!this.loadState.hasMore&&this.items.length>0){let n=this.renderEndMessage(),r=createDOMElement(n);e.appendChild(r);}}}setupInfiniteScroll(){this.loadMoreObserver&&this.loadMoreObserver.disconnect(),this.loadMoreObserver=new IntersectionObserver(e=>{let[n]=e;n.isIntersecting&&!this.loadState.loading&&this.loadState.hasMore&&this.loadMore();},{threshold:.1,rootMargin:"50px"}),this.reconnectInfiniteScrollObserver();}reconnectInfiniteScrollObserver(){if(!this.config.enableInfiniteScroll||!this.loadMoreObserver)return;this.currentLoadMoreTrigger&&(this.loadMoreObserver.unobserve(this.currentLoadMoreTrigger),this.currentLoadMoreTrigger=null);let e=()=>{let n=this.element?.querySelector('[data-load-more-trigger="true"]');return n?(this.loadMoreObserver.observe(n),this.currentLoadMoreTrigger=n,true):false};e()||(this.loadMoreMutationObserver&&this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=new MutationObserver(()=>{e()&&this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null);}),this.element&&(this.loadMoreMutationObserver.observe(this.element,{childList:true,subtree:true}),setTimeout(()=>{this.loadMoreMutationObserver&&(this.loadMoreMutationObserver.disconnect(),this.loadMoreMutationObserver=null);},5e3)));}disconnectInfiniteScrollObserver(){this.loadMoreObserver&&this.currentLoadMoreTrigger&&(this.loadMoreObserver.unobserve(this.currentLoadMoreTrigger),this.currentLoadMoreTrigger=null);}setupScrollListener(){requestAnimationFrame(()=>{this.scrollContainer=this.findScrollContainer(),this.scrollContainer&&("scrollRestoration"in history&&(history.scrollRestoration="manual"),this.scrollContainer.addEventListener("scroll",this.handleScroll));});}findScrollContainer(){let e=[this.element?.closest(".bb_notificationsContent"),this.element?.closest(".bb_dropdownMenu"),this.element?.querySelector("[data-notifications-loader]"),this.element?.closest("[data-notifications-loader]"),this.element?.closest(".scrollbar-thin"),this.element?.parentElement,this.element];for(let n of e)if(n){let r=n;if(r.scrollHeight>r.clientHeight||r.classList.contains("scrollbar-thin"))return r}return null}buildUrl(e){if(typeof this.config.fetchUrl=="function")return this.config.fetchUrl(e,this.filters);let n=this.config.fetchUrl.includes("?")?"&":"?",r=new URLSearchParams({page:e.toString(),limit:this.config.pageSize.toString(),...this.filters});return `${this.config.fetchUrl}${n}${r}`}buildHeaders(){let e={"Content-Type":"application/json"},n=this.config.getAuthToken?.();return n&&(e.Authorization=`Bearer ${n}`),e}createElementFromVNode(e){if(typeof e.type!="string")throw new Error("Can only create elements from string types");let n=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([r,o])=>{r==="className"?n.className=o:r==="style"?typeof o=="string"?n.setAttribute("style",o):typeof o=="object"&&o!==null&&Object.assign(n.style,o):r==="onclick"&&typeof o=="function"?n.addEventListener("click",o):r!=="children"&&r!=="ref"&&n.setAttribute(r,String(o));}),e.children&&e.children.forEach(r=>{r!=null&&(typeof r=="string"||typeof r=="number"?n.appendChild(document.createTextNode(String(r))):typeof r=="object"&&n.appendChild(this.createElementFromVNode(r)));}),n}render(){return div({class:this.config.containerClassName},this.config.enableSearch?this.renderSearchBar():null,div({class:m.list,ref:e=>{e&&(this.itemsListContainer=e);}}),this.loadState.error?this.renderError():null,this.loadState.loading?this.renderLoading():null,this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0?this.renderLoadMoreTrigger():null,!this.loadState.hasMore&&this.items.length>0?this.renderEndMessage():null)}renderSearchBar(){return div(m.searchbar,div("row gap-sm",i(v.fa("search")),input({type:"text",class:m.formFieldInput,placeholder:this.config.searchPlaceholder,ref:e=>{e&&(this.searchInput=e,this.searchInput.addEventListener("input",n=>{let r=n.target.value;this.handleSearch(r);}));}})))}renderEmptyState(){let e=this.config.emptyStateConfig;return div(m.emptyState,i(`__icon ${e.icon}`),span("__title",e.title),p$1("__desc",e.description))}renderLoading(){return div(m.loading,i(v.fa("spinner")+" fa-spin"),p$1({},this.config.loadingText))}renderError(){return div(m.error,i(v.fa("exclamation-triangle")),p$1({},this.loadState.error),button({class:`${m.button} secondary`,onclick:()=>this.loadMore()},i(v.fa("redo"))," Retry"))}renderLoadMoreTrigger(){return div({class:m.trigger,"data-load-more-trigger":"true",style:"height: 1px; visibility: hidden;"})}renderEndMessage(){return div({class:m.end},i(v.fa("check-circle")),d("All loaded",{count:String(this.loadState.total)}))}};function Pi(i){let t=new Se;return t.initialize(i),t}var ke=class i{constructor(){this.dropdowns=new Map;this.hierarchy=new Map;this.setupGlobalClickHandler();}static getInstance(){return i.instance||(i.instance=new i),i.instance}register(t){this.dropdowns.set(t.config.id,t),t.config.parentId&&this.hierarchy.set(t.config.id,t.config.parentId);}unregister(t){this.dropdowns.delete(t),this.hierarchy.delete(t);}open(t){let e=this.dropdowns.get(t);e&&(this.closeSiblings(t),e.setOpen(true));}close(t){let e=this.dropdowns.get(t);e&&(e.setOpen(false),this.closeChildren(t));}closeAll(){Array.from(this.dropdowns.values()).filter(e=>!e.config.parentId).forEach(e=>this.close(e.config.id));}destroy(){this.clickHandler&&typeof window<"u"&&document.removeEventListener("click",this.clickHandler,true),this.dropdowns.clear(),this.hierarchy.clear();}isAncestor(t,e){let n=e;for(;n;){if(n===t)return true;n=this.hierarchy.get(n);}return false}isDescendant(t,e){return this.isAncestor(e,t)}getAncestors(t){let e=new Set,n=t;for(;n;){let r=this.hierarchy.get(n);if(r)e.add(r),n=r;else break}return e}getDescendants(t){let e=new Set,n=r=>{Array.from(this.hierarchy.entries()).filter(([s,a])=>a===r).map(([s,a])=>s).forEach(s=>{e.add(s),n(s);});};return n(t),e}closeSiblings(t){let e=this.dropdowns.get(t);if(!e)return;let n=e.config.parentId;Array.from(this.dropdowns.values()).filter(o=>o.config.parentId===n&&o.config.id!==t).forEach(o=>this.close(o.config.id));}closeChildren(t){Array.from(this.dropdowns.values()).filter(n=>n.config.parentId===t).forEach(n=>this.close(n.config.id));}hasOpenDropdowns(){return Array.from(this.dropdowns.values()).some(t=>t.isOpen)}findDropdownForElement(t){let e=t;for(;e&&e!==document.body;){let n=e.getAttribute("data-dropdown-id");if(n)return n;e=e.parentElement;}return null}setupGlobalClickHandler(){typeof window>"u"||(this.clickHandler=t=>{let e=t.target;if(!this.hasOpenDropdowns())return;let n=this.findDropdownForElement(e);if(!n){this.closeAll();return}if(this.dropdowns.get(n)?.config.preventAutoClose||e.closest(".bb_dropdownTrigger"))return;if(e.closest(".bb_dropdownMenu")){let a=this.getAncestors(n),l=this.getDescendants(n);Array.from(this.dropdowns.values()).filter(u=>!u.config.parentId).forEach(u=>{let h=u.config.id;h===n||a.has(h)||l.has(h)||this.isDescendant(n,h)||this.close(h);});}},document.addEventListener("click",this.clickHandler,true));}},Z=ke.getInstance(),Me=class extends b{constructor(e){super();this.isOpen=false;this.mounted=false;this.bb_=T.dropdown;this.config={closeOnItemClick:true,preventAutoClose:false,...e};}onMount(){this.mounted=true,Z.register(this);}onUnmount(){this.mounted=false,Z.unregister(this.config.id);}setOpen(e){this.isOpen!==e&&(this.isOpen=e,e?this.config.onOpen?.():this.config.onClose?.(),this.updateDOM());}toggle(e){e.preventDefault(),e.stopPropagation(),this.isOpen?Z.close(this.config.id):Z.open(this.config.id);}handleItemClick(e,n){if(e.disabled){n.preventDefault(),n.stopPropagation();return}this.config.closeOnItemClick&&(n.preventDefault(),n.stopPropagation(),Z.close(this.config.id)),e.onclick?.(n),this.config.onSelect?.(e);}render(){let e=this.renderTrigger(),n=this.isOpen?this.renderMenu():null,r=["bb_dropdown",`bb_dropdown--${this.config.position||"left"}`,this.isOpen?"bb_dropdown--open":"",this.config.asIcon?"bb_dropdown--asIcon":"",this.config.className||""].filter(Boolean).join(" ");return div({class:r,"data-dropdown-id":this.config.id},e,n)}updateDOM(){if(!this.mounted||!this.element)return;this.isOpen?this.element.classList.add("bb_dropdown--open"):this.element.classList.remove("bb_dropdown--open");let n=this.element.querySelector(".bb_dropdownTrigger")?.nextElementSibling;if(this.isOpen){if(!n||!n.classList.contains("bb_dropdownMenu")){let r=this.renderMenu(),o=this.createElementFromVNode(r);this.element.appendChild(o);}}else n&&n.classList.contains("bb_dropdownMenu")&&n.remove();}createElementFromVNode(e){if(typeof e.type=="string"){let n=document.createElement(e.type);return e.props&&Object.entries(e.props).forEach(([r,o])=>{r==="className"?n.className=o:r==="onclick"&&typeof o=="function"?n.addEventListener("click",o):r!=="children"&&r!=="key"&&n.setAttribute(r,String(o));}),e.children&&e.children.forEach(r=>{r!=null&&(typeof r=="string"||typeof r=="number"?n.appendChild(document.createTextNode(String(r))):typeof r=="object"&&n.appendChild(this.createElementFromVNode(r)));}),n}return document.createElement("div")}renderTrigger(){let e=this.config.trigger.element?.(),n=["bb_dropdownTrigger",this.config.trigger.className||""].filter(Boolean).join(" ");if(e)return button({class:n,onclick:o=>this.toggle(o)},e);let r=["bb_dropdownArrow","fas","fa-chevron-down",this.isOpen?"bb_dropdownArrow--open":"",this.config.hideArrow?"hidden":""].filter(Boolean).join(" ");return button({class:n,onclick:o=>this.toggle(o)},this.config.trigger.icon?i(this.config.trigger.icon):null,this.config.trigger.text?span({},this.config.trigger.text):null,i(r))}renderMenu(){return div({class:"bb_dropdownMenu",onclick:e=>{this.config.preventAutoClose&&e.stopPropagation();}},...this.config.items.map((e,n)=>{if(e==="divider")return div({class:"bb_dropdown__divider",key:`divider-${n}`});let r=e.selected||this.config.defaultSelected&&e.id===this.config.defaultSelected,o=["bb_dropdownItem",e.className||"",e.disabled?"bb_dropdownItem--disabled":"",r?"bb_dropdownItem--selected":""].filter(Boolean).join(" "),s={key:e.id||`item-${n}`,class:o,onclick:a=>this.handleItemClick(e,a)};return e.disabled&&(s.disabled=true),button(s,e.icon?i(e.icon):null,span({},e.label))}))}};function Oi(i){return new Me(i)}function an(i,t){let e=null;return (...n)=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,i(...n);},t);}}function ln(i,t){let e=0,n=null;return (...r)=>{let o=Date.now(),s=o-e;s>=t?(e=o,i(...r)):n||(n=setTimeout(()=>{e=Date.now(),n=null,i(...r);},t-s));}}function cn(...i){let t=[];for(let e of i)if(e){if(typeof e=="string")t.push(e);else if(typeof e=="object")for(let[n,r]of Object.entries(e))r&&t.push(n);}return t.join(" ")}function un(i,t="YYYY-MM-DD"){let e=i instanceof Date?i:new Date(i);if(isNaN(e.getTime()))throw new Error("Invalid date provided to formatDate");let n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),a=String(e.getMinutes()).padStart(2,"0"),l=String(e.getSeconds()).padStart(2,"0");return t.replace("YYYY",String(n)).replace("MM",r).replace("DD",o).replace("HH",s).replace("mm",a).replace("ss",l)}function z(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(Array.isArray(i))return i.map(t=>z(t));if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(i instanceof Map){let t=new Map;return i.forEach((e,n)=>{t.set(z(n),z(e));}),t}if(i instanceof Set){let t=new Set;return i.forEach(e=>{t.add(z(e));}),t}if(Object.prototype.toString.call(i)==="[object Object]"){let t={};for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=z(i[e]));return t}return i}function Pe(i,...t){if(!t.length)return i;let e=t.shift();if(!e)return i;if(se(i)&&se(e)){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n],o=i[n];r!==void 0&&(se(r)&&!Array.isArray(r)?((!o||!se(o))&&(i[n]={}),Pe(i[n],r)):i[n]=r);}}return Pe(i,...t)}function se(i){return i!==null&&typeof i=="object"&&!Array.isArray(i)}var Ie=0;function dn(i="id"){let t=Date.now().toString(36),e=Math.random().toString(36).substring(2,11);Ie=(Ie||0)+1;let n=Ie.toString(36);return `${i}_${t}_${e}_${n}`}function hn(i){if(i<0)throw new Error("Sleep duration must be non-negative");return new Promise(t=>setTimeout(t,i))}function pn(i){return i==null?true:typeof i=="string"?i.trim().length===0:Array.isArray(i)?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:false}function fn(i){return i?i.charAt(0).toUpperCase()+i.slice(1):""}function gn(i){return i?i.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase():""}function et(i){return i?i.replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase()):""}function mn(i){if(!i)return "";let t=et(i);return t.charAt(0).toUpperCase()+t.slice(1)}function bn(i,t,e="..."){return !i||i.length<=t?i:i.substring(0,t-e.length)+e}function vn(i){let t={},e=i.replace(/^\?/,"");if(!e)return t;let n=e.split("&");for(let r of n){let[o,s]=r.split("=").map(decodeURIComponent);if(!o)continue;let a=s||"";if(o.endsWith("[]")){let l=o.slice(0,-2);t[l]||(t[l]=[]),t[l].push(a);}else t[o]=a;}return t}function yn(i){let t=[];for(let[e,n]of Object.entries(i))if(n!=null)if(Array.isArray(n))for(let r of n)r!=null&&t.push(`${encodeURIComponent(e)}[]=${encodeURIComponent(String(r))}`);else t.push(`${encodeURIComponent(e)}=${encodeURIComponent(String(n))}`);return t.length>0?`?${t.join("&")}`:""}function wn(i,t,e){return Math.min(Math.max(i,t),e)}function Tn(){return typeof window<"u"&&typeof document<"u"}function Cn(i,t){try{return JSON.parse(i)}catch{return t}}var Bi={debounce:an,throttle:ln,classNames:cn,formatDate:un,deepClone:z,deepMerge:Pe,uniqueId:dn,sleep:hn,isEmpty:pn,capitalize:fn,kebabCase:gn,camelCase:et,pascalCase:mn,truncate:bn,parseQuery:vn,stringifyQuery:yn,clamp:wn,isBrowser:Tn,safeJsonParse:Cn};var tt=class{constructor(t){this.observer=null;this.observedElements=new Map;this.observer=new IntersectionObserver(e=>{e.forEach(n=>{let r=this.observedElements.get(n.target)??false,o=n.isIntersecting;o&&!r?(this.observedElements.set(n.target,true),t.onEnter?.(n),t.once&&this.unobserve(n.target)):!o&&r&&(this.observedElements.set(n.target,false),t.onExit?.(n));});},{root:t.root||null,rootMargin:t.rootMargin||"0px",threshold:t.threshold??.1});}observe(t){this.observer&&(this.observer.observe(t),this.observedElements.set(t,false));}unobserve(t){this.observer&&(this.observer.unobserve(t),this.observedElements.delete(t));}disconnect(){this.observer&&(this.observer.disconnect(),this.observedElements.clear());}};function $i(i,t){let e=new IntersectionObserver(n=>{n.forEach(r=>{r.isIntersecting&&(t(r),e.unobserve(i));});},{threshold:.1});return e.observe(i),()=>e.disconnect()}function Ve(i){let t=typeof i=="string"?new Date(i):i,n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),o=Math.floor(r/60),s=Math.floor(o/60),a=Math.floor(s/24),l=Math.floor(a/7),c=Math.floor(a/30),u=Math.floor(a/365),h="";return r<0?h=d("time.just_now"):r<60?h=d("time.just_now"):o<2?h=d("time.minute_ago"):o<60?h=d("time.minutes_ago",{count:o.toString()}):s<2?h=d("time.hour_ago"):s<24?h=d("time.hours_ago",{count:s.toString()}):a<2?h=d("time.day_ago"):a<7?h=d("time.days_ago",{count:a.toString()}):l<2?h=d("time.week_ago"):l<4?h=d("time.weeks_ago",{count:l.toString()}):c<2?h=d("time.month_ago"):c<12?h=d("time.months_ago",{count:c.toString()}):u<2?h=d("time.year_ago"):h=d("time.years_ago",{count:u.toString()}),{formatted:h,originalDate:t.toISOString(),title:t.toLocaleString()}}function ji(i){let{formatted:t,title:e}=Ve(i);return {text:t,title:e}}function Ui(i){return Ve(i).formatted}function zi(i){return Ve(i).title}setConfig({devMode:false,sanitizeHTML:true});var Ge=ye;export{$ as CM,v as ClassMaker,le as CombinedContext,b as Component,X as Context,Me as Dropdown,It as EC,be as ElementCreator,J as I18nManager,Se as ItemsLoader,I as Loader,oe as Popup,Oe as Provider,pe as Router,Te as SmartForm,P as SmartFormComponent,ge as Store,q as StyleManager,x as TabbedView,ne as Toast,tt as VisibilityObserver,te as Window,Ge as bbMap,et as camelCase,fn as capitalize,wn as clamp,cn as classNames,at as clearHookContext,Pr as client,Pn as computed,xr as connect,Bn as createCombinedContext,Sr as createComputedStore,On as createContext,Oi as createDropdown,Yn as createFunctionalComponent,Pi as createItemsLoader,dt as createStore,nn as createTabbedView,lr as createTranslator,Re as css,an as debounce,z as deepClone,Pe as deepMerge,un as formatDate,Ve as formatRelativeTime,Ui as formatTimeAgo,nr as getCurrentLanguage,fe as getCurrentPath,De as getDefaultFATheme,S as getI18n,k as getPopup,Cr as getQueryParam,ut as getQueryParams,or as getSupportedLanguages,ji as getTimeDisplay,zi as getTimeTitle,Q as getToast,ar as getTranslations,mr as goBack,br as goForward,sr as hasKey,Xt as initPopup,zt as initToast,He as initializeFAConfig,ur as initializeI18n,Tn as isBrowser,vr as isCurrentPath,yr as isCurrentPathPrefix,pn as isEmpty,gn as kebabCase,cr as loadFromUrl,rr as loadLanguage,hr as loadLanguageFile,ir as loadTranslations,_i as mountTabbedView,Ke as navigate,Tr as navigateWithQuery,$i as observeVisibility,vn as parseQuery,mn as pascalCase,gi as popup,wr as reloadRoute,R as router,Cn as safeJsonParse,W as scheduler,ht as setDefaultFATheme,st as setHookContext,er as setLanguage,tr as setLanguageAsync,dr as setupI18n,hn as sleep,f as state,yn as stringifyQuery,d as t,he as tHtml,Xn as tLang,ln as throttle,Hr as toast,bn as truncate,dn as uniqueId,ue as useCallback,An as useContext,jn as useDebounce,F as useEffect,Jn as useEventListener,Wn as useFetch,qn as useInterval,Hn as useLocalStorage,lt as useMemo,Un as usePrevious,Dn as useReducer,de as useRef,N as useState,zn as useToggle,Gn as useWindowSize,Bi as utils,Vn as watch};//# sourceMappingURL=main.js.map
15
14
  //# sourceMappingURL=main.js.map