@je-es/client 0.2.3 → 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/README.md +1 -1
- package/dist/main.cjs +7 -107
- package/dist/main.cjs.map +1 -1
- package/dist/main.d.cts +753 -441
- package/dist/main.d.ts +753 -441
- package/dist/main.js +7 -107
- package/dist/main.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
</div>
|
|
9
9
|
|
|
10
10
|
<div align="center">
|
|
11
|
-
<img src="https://img.shields.io/badge/v-0.2.
|
|
11
|
+
<img src="https://img.shields.io/badge/v-0.2.5-black"/>
|
|
12
12
|
<img src="https://img.shields.io/badge/🔥-@je--es-black"/>
|
|
13
13
|
<br>
|
|
14
14
|
<img src="https://github.com/je-es/client/actions/workflows/ci.yml/badge.svg" alt="CI" />
|
package/dist/main.cjs
CHANGED
|
@@ -1,114 +1,14 @@
|
|
|
1
|
-
'use strict';var vdom=require('@je-es/vdom'),capi=require('@je-es/capi');var
|
|
2
|
-
`),r=[],
|
|
3
|
-
`)}static clear(){for(let[,t]of this.styles)t.parentElement&&t.parentElement.removeChild(t);this.styles.clear();}};function be(s,...t){let e="";for(let n=0;n<s.length;n++)e+=s[n],n<t.length&&(e+=t[n]);return e}var ee=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}},U=new ee;var m=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 o=typeof t=="function"?t(this.state):t;this.state={...this.state,...o};return}if(this._isUnmounting)return;let n={...this.state},r=typeof t=="function"?t(this.state):t,i=false;for(let o in r)if(n[o]!==r[o]){i=true;break}if(!i){e&&U.schedule(e);return}this.state={...this.state,...r},this.onStateChange?.(n,this.state),this.update(),e&&U.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,U.schedule(()=>{this._isScheduledForUpdate=false,this._updateBatch.clear(),this._performUpdate();})));}forceUpdate(){!this._isMounted||this._isUnmounting||this._updateInProgress||U.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=D.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&&(D.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 i=e();return this._memoCache.set(t,{args:n,result:i}),i}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 (...i)=>{let o=Date.now(),a=o-n;a>=e?(n=o,t.apply(this,i)):r||(r=setTimeout(()=>{n=Date.now(),r=null,t.apply(this,i);},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 i=Array.from(r.childNodes).indexOf(this._element);if(i===-1){console.warn(`Component ${this.constructor.name} element removed from parent, skipping update`);return}let o=this._convertToVDomNode(this._vnode),a=this._convertToVDomNode(n);vdom.patch(r,o,a,i),this._element=r.childNodes[i];}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 i of r)if(i.name.startsWith("data-")){let o=`[${i.name}="${i.value}"]`;if(n=this._element.querySelector(o),n)break}if(n&&t.children.length>0){for(;n.firstChild;)n.removeChild(n.firstChild);t.children.forEach(i=>{n.appendChild(i);});}}),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,i]of Object.entries(t.props))r!=="children"&&(e[r]=i);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 i of r[t])if(typeof this[i]=="function")try{this[i].call(this,e,n);}catch(o){console.error(`Watcher error in ${i}:`,o);}}}setElement(t){this._element=t;}};function g(s,t){if(t&&typeof t=="object"&&"kind"in t){let o=t.name;return t.addInitializer(function(){let a=this;a.constructor.__reactiveProps__||(a.constructor.__reactiveProps__=[]),a.constructor.__reactiveProps__.includes(o)||a.constructor.__reactiveProps__.push(o);}),function(a){let l=this,c=`_state_${o}`;return l[c]=a,Object.defineProperty(this,o,{get(){return this[c]},set(u){let d=this,y=d[c];y!==u&&(d[c]=u,typeof d._invalidateAllComputed=="function"&&d._invalidateAllComputed(),typeof d._triggerWatchers=="function"&&d._triggerWatchers(o,u,y),d._isMounted&&typeof d.update=="function"&&d.update());},enumerable:true,configurable:true}),a}}let e=t,n=s.constructor;n.__reactiveProps__||(n.__reactiveProps__=[]),n.__reactiveProps__.includes(e)||n.__reactiveProps__.push(e);let r=`_state_${e}`,i=`_state_init_${e}`;Object.defineProperty(s,e,{get(){let o=this;if(o[i])return o[r]},set(o){let a=this;if(!a[i]){a[r]=o,a[i]=true;return}let l=a[r];l!==o&&(a[r]=o,typeof a._invalidateAllComputed=="function"&&a._invalidateAllComputed(),typeof a._triggerWatchers=="function"&&a._triggerWatchers(e,o,l),a._isMounted&&typeof a.update=="function"&&a.update());},enumerable:true,configurable:true});}function dt(s,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=s,c=a.name,u=`_computed_cache_${c}`,d=`_computed_dirty_${c}`;return function(){let y=this;return y[d]===void 0&&(y[d]=true),y[d]===true&&(y[u]=l.call(this),y[d]=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 i=`_computed_cache_${n}`,o=`_computed_dirty_${n}`;return {get(){let a=this;return a[o]===void 0&&(a[o]=true),a[o]===true&&(a[i]=r.call(this),a[o]=false),a[i]},enumerable:e.enumerable,configurable:e.configurable}}function ht(s){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__[s]||(c.constructor.__watchers__[s]=[]),c.constructor.__watchers__[s].includes(l)||c.constructor.__watchers__[s].push(l);});return}let i=n;if(!r)throw new Error("@watch requires a property descriptor");let a=e.constructor;return a.__watchers__||(a.__watchers__={}),a.__watchers__[s]||(a.__watchers__[s]=[]),a.__watchers__[s].includes(i)||a.__watchers__[s].push(i),r}return t}var G=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 mt(s){return new G(s)}var ve=class extends m{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 vdom.html`
|
|
1
|
+
'use strict';var vdom=require('@je-es/vdom'),capi=require('@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
|
+
`),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 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);vdom.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 vdom.html`
|
|
4
4
|
<div class="context-provider" style="display: contents;">
|
|
5
5
|
${t}
|
|
6
6
|
</div>
|
|
7
|
-
`}};function bt(s,t){let e=s.subscribe(()=>{t.isMounted&&t.update();});return t.subscribe(()=>e),s.value}var te=class{constructor(t){this.contexts=new Map;for(let[e,n]of Object.entries(t))this.contexts.set(e,new G(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 vt(s){return new te(s)}var L=null,A=0,ne=new WeakMap;function Me(s){L=s,A=0;}function Pe(){L=null,A=0;}function J(s){return ne.has(s)||ne.set(s,[]),ne.get(s)}function N(s){if(!L)throw new Error("useState must be called inside a component");let t=L,e=A++,n=J(t);n[e]===void 0&&(n[e]={value:typeof s=="function"?s():s});let r=i=>{let o=n[e],a=typeof i=="function"?i(o.value):i;o.value!==a&&(o.value=a,t.update());};return [n[e].value,r]}function R(s,t){if(!L)throw new Error("useEffect must be called inside a component");let e=L,n=A++,r=J(e),i=r[n];if(!i||!t||!ye(i.deps,t)){if(i?.value&&typeof i.value=="function")try{i.value();}catch(a){console.error("Error in effect cleanup:",a);}Promise.resolve().then(()=>{try{let a=s();r[n]={value:a,deps:t?[...t]:void 0};}catch(a){console.error("Error in effect:",a);}});}}function Ie(s,t){if(!L)throw new Error("useMemo must be called inside a component");let e=A++,n=J(L),r=n[e];return (!r||!ye(r.deps,t))&&(n[e]={value:s(),deps:[...t]}),n[e].value}function re(s,t){return Ie(()=>s,t)}function se(s){if(!L)throw new Error("useRef must be called inside a component");let t=A++,e=J(L);return e[t]===void 0&&(e[t]={value:{current:s}}),e[t].value}function Tt(s,t){let[e,n]=N(t),r=re(i=>{n(o=>s(o,i));},[s]);return [e,r]}function _t(s,t){let[e,n]=N(()=>{try{let i=window.localStorage.getItem(s);return i?JSON.parse(i):t}catch(i){return console.error("Error loading from localStorage:",i),t}});return [e,i=>{n(o=>{let a=i instanceof Function?i(o):i;try{window.localStorage.setItem(s,JSON.stringify(a));}catch(l){console.error("Error saving to localStorage:",l);}return a});}]}function Ct(s,t){let[e,n]=N(s);return R(()=>{let r=setTimeout(()=>{n(s);},t);return ()=>{clearTimeout(r);}},[s,t]),e}function St(s){let t=se(void 0);return R(()=>{t.current=s;}),t.current}function Et(s=false){let[t,e]=N(s),n=re(()=>{e(r=>!r);},[]);return [t,n]}function xt(s,t){let e=se(s);R(()=>{e.current=s;},[s]),R(()=>{if(t===null)return;let n=setInterval(()=>e.current(),t);return ()=>clearInterval(n)},[t]);}function kt(s,t){let[e,n]=N(null),[r,i]=N(true),[o,a]=N(null),l=re(async()=>{i(true),a(null);try{let c=await fetch(s,t);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);let u=await c.json();n(u);}catch(c){a(c);}finally{i(false);}},[s]);return R(()=>{l();},[l]),{data:e,loading:r,error:o,refetch:l}}function Lt(){let[s,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)},[]),s}function Mt(s,t,e=window){let n=se(t);R(()=>{n.current=t;},[t]),R(()=>{if(!(e&&"addEventListener"in e))return;let i=o=>{n.current(o);};return e.addEventListener(s,i),()=>{e.removeEventListener(s,i);}},[s,e]);}function Pt(s,t){class e extends m{render(){Me(this);try{return s(this.props)}finally{Pe();}}}return t&&Object.defineProperty(e,"name",{value:t}),e}function ye(s,t){if(!s||s.length!==t.length)return false;for(let e=0;e<s.length;e++)if(s[e]!==t[e])return false;return true}var ie=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 vdom.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[i,o]of Object.entries(e))r=r.replace(`:${i}`,o);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,i=this._buildRouteObject(t,r,n),o=this.currentRoute||this._buildEmptyRoute();if(!await this._runNavigationGuards(n,i,o))return;this.currentRoute=i,await this._renderComponent(n),this._handleScrollBehavior(i,o),n.meta?.title&&typeof n.meta.title=="string"&&(document.title=n.meta.title),this.afterEachHooks.forEach(l=>l(i,o));}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,i=>{i===false?r(false):typeof i=="string"?(this.push(i),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 i=await t();return i.HomePage||i.TodoPage||i.default||Object.values(i).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(i){return console.error("Failed to load lazy component:",i),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
|
-
|
|
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(vdom.createElement(u,{},a));}else if(l){let u=l.trim().toLowerCase();n.push(vdom.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 vdom.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),"([^/]+)")),i=new RegExp(`^${r}$`),o=e.match(i);return o?n.reduce((a,l,c)=>(a[l]=decodeURIComponent(o[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[i,o]=r.split("=").map(decodeURIComponent);return i&&(n[i]=o||""),n},{}):{}}},O=new ie;function we(s,t=false){t?O.replace(s):O.push(s),window.dispatchEvent(new CustomEvent("navigation",{detail:{path:s}}));}function Rt(){O.back();}function Ot(){window.history.forward();}function oe(){return window.location.pathname}function $t(s){return oe()===s}function Vt(s){return oe().startsWith(s)}function Ft(){let s=oe();we(s,true);}function Kt(s,t){let e=new URLSearchParams(t).toString();we(`${s}?${e}`);}function Re(){return new URLSearchParams(window.location.search)}function At(s){return Re().get(s)}var ae=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 i of this._middleware)try{i(this._state,e);}catch(o){console.error("Store middleware error:",o);}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=i=>{let o=i[t];n!==o&&(n=o,e(o));};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 Oe(s){return new ae(s)}function Dt(s,t){let e=Oe({state:{value:t(...s.map(n=>n.state))}});for(let n of s)n.subscribe(()=>{e.setState({value:t(...s.map(r=>r.state))});});return e}function Ut(s,t,e){return s.subscribe(r=>{let i=e(r);Object.assign(t,i),typeof t.update=="function"&&t.update();})}function qt(s){let t=s;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:i,existsSync:o,mkdirSync:a}=await import('fs'),{join:l,dirname:c}=await import('path'),u=c(n),d=n.split("/").pop()||"client.css",y=l(e,"index.scss");if(!o(y)){console.log("\u26A0\uFE0F No index.scss found, skipping CSS build");return}try{o(u)||a(u,{recursive:!0});let K=r.compile(y,{style:t.build?.minify?"compressed":"expanded",sourceMap:!!t.build?.sourcemap,loadPaths:[e]}),me=l(u,d);i(me,K.css,"utf-8"),t.build?.sourcemap&&K.sourceMap&&i(`${me}.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:i}=await import('fs'),{join:o,extname:a}=await import('path'),l=[];if(!i(e))return l;let c=n(e);for(let u of c){let d=o(e,u),y=r(d);y.isDirectory()?l.push(...await this._collectScssFiles(d)):y.isFile()&&a(u)===".scss"&&!u.startsWith("_")&&l.push(d);}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 o=n(t.build.entry);e(o,{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 i="./app/style";r(i)&&e(i,{recursive:true},async(o,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}),capi.configureApi(e);}t.router&&t.app?.routes&&(O.init(t.app.routes,t.router.mode,t.router.base),t.router.beforeEach&&O.beforeEach(t.router.beforeEach),t.router.afterEach&&O.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:O,config:t,version:"0.0.1"};},getConfig(){return t}}}var z=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]={}),this.translations[t]={...this.translations[t],...e},this.supportedLanguages.add(t);}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,i=this.getTranslation(t,n);return e&&Object.entries(e).forEach(([o,a])=>{let l=this.translations[r]?.[a]||this.translations[this.defaultLanguage]?.[a]||a;i=i.replace(new RegExp(`\\{${o}\\}`,"g"),l);}),i}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 i=this.t(t,n);return this.currentLanguage=r,i}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,i;for(;(i=r.exec(e))!==null;){let o=i[1],a=i[2],l=i[3],c=i[4];if(c)n.push(c);else if(o){let u=o.split(/\s+/)[0].toLowerCase();n.push(vdom.createElement(u,{},a));}else if(l){let u=l.trim().toLowerCase();n.push(vdom.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 i=r.replace("*.json",""),o=this.supportedLanguages;for(let a of o)try{let l=`${i}${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 i=r;typeof window<"u"&&!i.startsWith("http")&&(i=window.location.origin+(i.startsWith("/")?i:"/"+i));let o=await fetch(i);if(o.ok){let a=await o.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}}));}},B=null;function S(){return B||(B=new z),B}function h(s,t,e){return S().t(s,t,e)}function Jt(s,t,e){return S().tLang(s,t,e)}function le(s,t,e){return S().tHtml(s,t,e)}function Qt(s){S().setLanguage(s);}async function Yt(s,t){let e=S(),n=e.getTranslations();if(!(Object.keys(n).length>0)&&t){let i=t.endsWith("/")?t:t+"/";try{await e.loadFromUrl(i+`${s}.json`);}catch(o){console.warn(`Failed to lazy-load language: ${s}`,o);}}e.setLanguage(s);}function Zt(){return S().getLanguage()}function Xt(s,t){S().loadLanguage(s,t);}function en(s){S().loadTranslations(s);}function tn(){return S().getSupportedLanguages()}function nn(s){return S().hasKey(s)}function rn(){return S().getTranslations()}function sn(s){return S().createTranslator(s)}async function on(s){return S().loadFromUrl(s)}function an(s){B=new z(s);}async function ln(s){let t=new z(s);if(B=t,s.staticPath){let e=s.staticPath.endsWith("/")?s.staticPath:s.staticPath+"/",n=t.getLanguage(),r=e+`${n}.json`;await t.loadFromUrl(r);}}async function cn(s,t){let e=S(),n=t||"static/i18n",i=(n.endsWith("/")?n:n+"/")+s+".json";await e.loadFromUrl(i);}var j={toast:"bb_toast",container:"bb_toastContainer",icon:"bb_toastIcon",msg:"bb_toastMsg"},Y=class extends m{constructor(){super(...arguments);this.messages=[];this.nextId=0;}show(e,n="info",r=2e3,i){let o=this.nextId++;this.messages=[...this.messages,{id:o,message:e,type:n,translateKey:i}],setTimeout(()=>{this.messages=this.messages.filter(a=>a.id!==o);},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?vdom.html``:vdom.createElement("div",{className:j.container},...this.messages.map(e=>this.renderToast(e)))}renderToast(e){let n={success:"fas fa-check-circle",error:"fas fa-exclamation-circle",info:"fas fa-info-circle",warning:"fas fa-exclamation-triangle"},r=e.translateKey?h(e.translateKey):e.message;return vdom.createElement("div",{key:String(e.id),className:`${j.toast} ${j.toast}--${e.type}`,"data-translate":e.translateKey||void 0},vdom.createElement("i",{className:`${n[e.type]} ${j.icon}`}),vdom.createElement("span",{className:j.msg},r))}};p([g],Y.prototype,"messages");var $=null;function Fe(s){if($)return $;let t=s||document.createElement("div");return s||document.body.appendChild(t),$=new Y,$.mount(t),$}function q(){return $||($=Fe()),$}var fn={show:(s,t="info",e,n)=>{q().show(s,t,e,n);},success:(s,t,e)=>{q().success(s,t,e);},error:(s,t,e)=>{q().error(s,t,e);},info:(s,t,e)=>{q().info(s,t,e);},warning:(s,t,e)=>{q().warning(s,t,e);}};var T={loader:{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"}},I=class extends m{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 e=[T.loader.container,this.overlay?`${T.loader.containerOverlay}`:"",`${T.loader.container}--${this.size}`].filter(Boolean).join(" ");return vdom.createElement("div",{className:e,"data-status":this.visible?"visible":"hidden",role:"status","aria-live":"polite","aria-busy":"true"},vdom.createElement("div",{className:T.loader.bg}),vdom.createElement("div",{className:T.loader.loader},this.renderSpinner(),this.renderMessage(),this.showProgress?this.renderProgressBar():null))}renderSpinner(){let e=`${T.spinner.container} ${T.spinner.container}--${this.variant}`;switch(this.variant){case "dots":return vdom.createElement("div",{className:e},vdom.createElement("div",{className:T.spinner.dot}),vdom.createElement("div",{className:T.spinner.dot}),vdom.createElement("div",{className:T.spinner.dot}));case "pulse":return vdom.createElement("div",{className:e},vdom.createElement("div",{className:T.spinner.pulse}));case "spinner":default:return vdom.createElement("div",{className:e},vdom.createElement("div",{className:T.spinner.icon}))}}renderMessage(){let e=this.message||h("global.loading");return vdom.createElement("div",{className:T.spinner.text,"data-translate":this.message?void 0:"global.loading"},e)}renderProgressBar(){return vdom.createElement("div",{className:T.progress.container},vdom.createElement("div",{className:T.progress.bar,style:`width: ${this.progress}%`,"aria-valuenow":this.progress.toString(),"aria-valuemin":"0","aria-valuemax":"100"}),vdom.createElement("div",{className:T.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(`.${T.spinner.container}`);e&&e.setAttribute("aria-label",h("loading"));}isVisible(){return this.visible}getStatus(){return {visible:this.visible,message:this.message,progress:this.progress}}};p([g],I.prototype,"visible"),p([g],I.prototype,"message"),p([g],I.prototype,"variant"),p([g],I.prototype,"size"),p([g],I.prototype,"overlay"),p([g],I.prototype,"progress"),p([g],I.prototype,"showProgress");var V=class extends m{constructor(e){super(e);this.fields=[];this.formData={};this.isSubmitting=false;this.submitError="";this.submitSuccess=false;this.fields=this.props.fields.map(n=>({...n,error:void 0,touched:false}));for(let n of this.fields)this.formData[n.name]=n.value||"";}onMount(){}handleChange(e,n){this.formData[e]=n;let r=this.fields.find(i=>i.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 i=String(n);if(r.minLength&&i.length<r.minLength)return r.message||`Minimum ${r.minLength} characters required`;if(r.maxLength&&i.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(i))return r.message||"Invalid format";if(r.email&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))return r.message||"Invalid email format";if(r.url&&!/^https?:\/\/.+/.test(i))return r.message||"Invalid URL format";if(r.custom){let o=r.custom(n);if(o!==true)return typeof o=="string"?o:void 0}}validateForm(){let e=true,n={};for(let r of this.fields){let i=this.validateField(r,this.formData[r.name]);r.error=i,r.touched=true,i&&(e=false,n[r.name]=i);}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 capi.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:h("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?vdom.html`
|
|
15
|
-
<label for=${e.name}>
|
|
16
|
-
<i class="fa ${e.icon}"></i>
|
|
17
|
-
${e.label?vdom.html`<span>${e.label}</span>`:""}
|
|
18
|
-
</label>
|
|
19
|
-
`:vdom.html`<label for=${e.name}>${e.label}</label>`}renderField(e){let n=this.formData[e.name]||"",r=this.renderLabel(e);switch(e.type){case "textarea":return vdom.html`
|
|
20
|
-
<div class="bb_formField ${e.className||""}">
|
|
21
|
-
${r}
|
|
22
|
-
<textarea
|
|
23
|
-
id=${e.name}
|
|
24
|
-
name=${e.name}
|
|
25
|
-
placeholder=${e.placeholder||""}
|
|
26
|
-
disabled=${String(e.disabled||this.isSubmitting)}
|
|
27
|
-
oninput=${i=>{let o=i.target;this.handleChange(e.name,o.value);}}
|
|
28
|
-
onblur=${()=>this.handleBlur(e.name)}
|
|
29
|
-
class="bb_formFieldTextarea"
|
|
30
|
-
>${String(n)}</textarea>
|
|
31
|
-
${e.error&&e.touched?vdom.html`
|
|
32
|
-
<span class="field-error">${e.error}</span>
|
|
33
|
-
`:""}
|
|
34
|
-
</div>
|
|
35
|
-
`;case "select":{let o=(e.options||[]).map(a=>{let l=String(a.value)===String(n);return vdom.html`<option value=${String(a.value)} selected=${l}>${a.label}</option>`});return vdom.html`
|
|
36
|
-
<div class="bb_formField ${e.className||""}">
|
|
37
|
-
${r}
|
|
38
|
-
<select
|
|
39
|
-
id=${e.name}
|
|
40
|
-
name=${e.name}
|
|
41
|
-
disabled=${String(e.disabled||this.isSubmitting)}
|
|
42
|
-
onchange=${a=>{let l=a.target;this.handleChange(e.name,l.value);}}
|
|
43
|
-
onblur=${()=>this.handleBlur(e.name)}
|
|
44
|
-
class="bb_formFieldSelect"
|
|
45
|
-
>
|
|
46
|
-
<option value="" selected=${String(n)===""}>${h("global.please_select",{},"Select...")}</option>
|
|
47
|
-
${o}
|
|
48
|
-
</select>
|
|
49
|
-
${e.error&&e.touched?vdom.html`
|
|
50
|
-
<span class="field-error">${e.error}</span>
|
|
51
|
-
`:""}
|
|
52
|
-
</div>
|
|
53
|
-
`}case "checkbox":{let i=!!n;return vdom.html`
|
|
54
|
-
<div class="bb_formField bb_formField-checkbox ${e.className||""}">
|
|
55
|
-
<label>
|
|
56
|
-
<input
|
|
57
|
-
type="checkbox"
|
|
58
|
-
id=${e.name}
|
|
59
|
-
name=${e.name}
|
|
60
|
-
checked=${i}
|
|
61
|
-
disabled=${String(e.disabled||this.isSubmitting)}
|
|
62
|
-
onchange=${o=>{let a=o.target;this.handleChange(e.name,a.checked);}}
|
|
63
|
-
class="bb_formFieldCheckbox"
|
|
64
|
-
/>
|
|
65
|
-
${e.icon?vdom.html`<i class="fa ${e.icon}"></i>`:""}
|
|
66
|
-
${e.label||""}
|
|
67
|
-
</label>
|
|
68
|
-
${e.error&&e.touched?vdom.html`
|
|
69
|
-
<span class="field-error">${e.error}</span>
|
|
70
|
-
`:""}
|
|
71
|
-
</div>
|
|
72
|
-
`}default:return vdom.html`
|
|
73
|
-
<div class="bb_formField ${e.className||""}">
|
|
74
|
-
${r}
|
|
75
|
-
<input
|
|
76
|
-
type="${e.type||"text"}"
|
|
77
|
-
id="${e.name}"
|
|
78
|
-
name="${e.name}"
|
|
79
|
-
placeholder="${e.placeholder||""}"
|
|
80
|
-
value="${String(n)}"
|
|
81
|
-
disabled="${e.disabled||this.isSubmitting}"
|
|
82
|
-
oninput=${i=>{let o=i.target;this.handleChange(e.name,o.value);}}
|
|
83
|
-
onblur=${()=>this.handleBlur(e.name)}
|
|
84
|
-
class="bb_formFieldInput"
|
|
85
|
-
/>
|
|
86
|
-
${e.error&&e.touched?vdom.html`
|
|
87
|
-
<span class="field-error">${e.error}</span>
|
|
88
|
-
`:""}
|
|
89
|
-
</div>
|
|
90
|
-
`}}render(){let e=this.props.submitButton||{},n=this.fields.map(r=>this.renderField(r));return vdom.html`
|
|
91
|
-
<form
|
|
92
|
-
class="smart_form ${this.props.className||""}"
|
|
93
|
-
onsubmit=${r=>this.handleSubmit(r)}
|
|
94
|
-
>
|
|
95
|
-
${this.submitError?vdom.html`
|
|
96
|
-
<div class="alert alert-error">${this.submitError}</div>
|
|
97
|
-
`:""}
|
|
98
|
-
|
|
99
|
-
${this.submitSuccess?vdom.html`
|
|
100
|
-
<div class="alert alert-success">${h("global.loading")}</div>
|
|
101
|
-
`:""}
|
|
102
|
-
|
|
103
|
-
${n}
|
|
104
|
-
|
|
105
|
-
<button
|
|
106
|
-
type="submit"
|
|
107
|
-
class="submit-button ${e.className||""}"
|
|
108
|
-
disabled=${String(this.isSubmitting)}
|
|
109
|
-
>
|
|
110
|
-
${this.isSubmitting?e.loadingLabel||h("global.loading"):e.label||h("global.loading")}
|
|
111
|
-
</button>
|
|
112
|
-
</form>
|
|
113
|
-
`}styles(){return be``}};p([g],V.prototype,"fields"),p([g],V.prototype,"formData"),p([g],V.prototype,"isSubmitting"),p([g],V.prototype,"submitError"),p([g],V.prototype,"submitSuccess");function _e(s){return new V(s).render()}var w={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"},Z=class extends m{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?vdom.createElement("div",{className:w.container}):vdom.createElement("div",{className: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 vdom.createElement("div",{key:String(e.id),className:w.overlay,"data-popup-id":e.id,onClick:i=>{i.target.classList.contains(w.overlay)&&e.closeOnOverlay!==false&&this.closePopup(e.id,false);}},vdom.createElement("div",{className:`${w.popup.base} ${n} ${r}`,role:"dialog","aria-modal":"true","aria-labelledby":`popup-title-${e.id}`},e.showCloseButton!==false?vdom.createElement("button",{className:w.popup.close,onClick:()=>this.closePopup(e.id,false),"aria-label":"Close"},vdom.createElement("i",{className:"fas fa-times"})):null,vdom.createElement("div",{className:w.header.container},e.icon?vdom.createElement("div",{className:w.header.icon},vdom.createElement("i",{className:e.icon})):null,vdom.createElement("div",{className:w.header.content},vdom.createElement("h2",{id:`popup-title-${e.id}`,className:w.header.title,"data-translate":e.titleTranslateKey},e.titleTranslateKey?h(e.titleTranslateKey):e.title),e.description?vdom.createElement("p",{className:w.header.description,"data-translate":e.descriptionTranslateKey},e.descriptionTranslateKey?le(e.descriptionTranslateKey):e.description):null)),vdom.createElement("div",{className:w.body.container},e.message?vdom.createElement("p",{className:w.body.message,"data-translate":e.messageTranslateKey},e.messageTranslateKey?le(e.messageTranslateKey):e.message):null,e.type==="prompt"?vdom.createElement("input",{type:"text",className:w.body.input,value:e.inputValue||"",placeholder:h("popup.prompt.placeholder"),"data-translate":"popup.prompt.placeholder",onInput:i=>{e.inputValue=i.target.value;}}):null,e.type==="form"&&e.formConfig?vdom.createElement("div",{className:w.body.formContainer},_e(e.formConfig)):null,e.customContent||null),e.buttons&&e.buttons.length>0&&e.type!=="form"?vdom.createElement("div",{className:w.footer},...e.buttons.map(i=>vdom.createElement("button",{className:`${w.button} ${i.variant||"secondary"}`,"data-translate":i.translateKey,disabled:i.loading||e.isSubmitting,onClick:async()=>{i.loading||e.isSubmitting||await i.onClick();}},i.icon?vdom.createElement("i",{className:i.icon}):null,i.loading||e.isSubmitting?vdom.createElement("i",{className:"fas fa-spinner fa-spin"}):null," ",i.translateKey?h(i.translateKey):i.label))):null))}show(e){return new Promise(n=>{let r=this.nextId++,i={...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,i],this.applyBodyLock(),this.update();})}showForm(e){return new Promise((n,r)=>{let i=this.nextId++,o={...e.formConfig,onSubmit:async l=>{let c=this.popups.find(u=>u.id===i);c&&(c.isSubmitting=true,this.update());try{e.formConfig.onSubmit&&await e.formConfig.onSubmit(l,new Event("submit")),this.closePopup(i,l),n(l);}catch(u){c&&(c.isSubmitting=false,this.update()),e.formConfig.onError&&e.formConfig.onError(u);}},submitButton:{...e.formConfig.submitButton,className:e.formConfig.submitButton?.className||`${w.button} primary wide`}},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:o,closeOnOverlay:e.closeOnOverlay!==false,closeOnEscape:e.closeOnEscape!==false,showCloseButton:e.showCloseButton!==false,id:i,resolve:n,isSubmitting:false};this.popups=[...this.popups,a],this.applyBodyLock(),this.update();})}confirm(e){return new Promise(n=>{let r=this.nextId++,i={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:"fas 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:"fas fa-check",onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,i],this.applyBodyLock(),this.update();})}alert(e){return new Promise(n=>{let r=this.nextId++,i={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:"fas fa-check",onClick:async()=>{e.onConfirm&&await e.onConfirm(),this.closePopup(r,true);}}]};this.popups=[...this.popups,i],this.applyBodyLock(),this.update();})}prompt(e){return new Promise(n=>{let r=this.nextId++,i={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 o=i.inputValue||"";e.onConfirm&&await e.onConfirm(o),this.closePopup(r,o);}}]};this.popups=[...this.popups,i],this.applyBodyLock();})}closePopup(e,n){let r=this.popups.find(i=>i.id===e);r?.resolve&&r.resolve(n),this.popups=this.popups.filter(i=>i.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([g],Z.prototype,"popups");var F=null;function Ae(s){if(F)return F;let t=s||document.createElement("div");return s||document.body.appendChild(t),F=new Z,F.mount(t),F}function M(){return F||(F=Ae()),F}var An={show:s=>M().show(s),confirm:s=>M().confirm(s),alert:s=>M().alert(s),prompt:s=>M().prompt(s),showForm:s=>M().showForm(s),closePopup:(s,t)=>M().closePopup(s,t),closeLastPopup:()=>M().closePopup(M().popups.length-1,false),closeFirstPopup:()=>M().closePopup(0,false),closeAll:()=>M().closeAll()};var P={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"}},x=class extends m{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(i=>i.id===e);r&&(Object.assign(r,n),this.update());}getActiveTab(){return this.tabs.find(e=>e.id===this.activeTabId)}render(){let e=[P.container,`bb_tabbedview__--${this.position}`,`bb_tabbedview__--${this.style}`,this.className].filter(Boolean).join(" ");return vdom.createElement("div",{className:e},this.renderTabList(),this.renderTabContent())}renderTabList(){let e=[P.header,this.headerClassName].filter(Boolean).join(" ");return vdom.createElement("div",{className:e},...this.tabs.map(n=>this.renderTab(n)))}renderTab(e){let n=this.activeTabId===e.id,r=[P.tab.base,n?P.tab.active:"",e.disabled?P.tab.disabled:""].filter(Boolean).join(" "),i=e.translateKey?h(e.translateKey):e.label;return vdom.createElement("button",{key:e.id,className:r,onclick:()=>this.setActiveTab(e.id),disabled:e.disabled,"data-translate":e.translateKey,"aria-selected":n,role:"tab"},e.icon?vdom.createElement("i",{className:e.icon}):null,vdom.createElement("span",{},i),e.badge!==void 0&&e.badge!==null&&e.badge!==0?vdom.createElement("span",{className:P.tab.badge},typeof e.badge=="number"&&e.badge>99?"99+":String(e.badge)):null)}renderTabContent(){let e=[P.content.container,this.contentClassName].filter(Boolean).join(" "),n=this.getActiveTab();return n?vdom.createElement("div",{className:e,role:"tabpanel"},this.renderActiveTabContent(n)):vdom.createElement("div",{className:e},vdom.createElement("div",{className:P.content.emptyState},vdom.createElement("p",{},h("global.loading"))))}renderActiveTabContent(e){if(e.component)try{if(e.component instanceof m){this.currentTabComponent=e.component;let n=this.currentTabComponent.render(),r={...n.props,ref:o=>{o&&this.currentTabComponent&&this.currentTabComponent.setElement(o),typeof n.props.ref=="function"&&n.props.ref(o);}},i={...n,props:r};return typeof this.currentTabComponent.onMount=="function"&&setTimeout(()=>{this.currentTabComponent&&typeof this.currentTabComponent.onMount=="function"&&this.currentTabComponent.onMount();},0),i}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),vdom.createElement("div",{className:P.content.error},h("global.loading"))}return e.content?e.content:vdom.createElement("div",{className:P.content.emptyState},vdom.createElement("p",{},h("global.loading")))}};p([g],x.prototype,"activeTabId"),p([g],x.prototype,"tabs"),p([g],x.prototype,"position"),p([g],x.prototype,"style"),p([g],x.prototype,"className"),p([g],x.prototype,"headerClassName"),p([g],x.prototype,"contentClassName"),p([g],x.prototype,"showTabCount"),p([g],x.prototype,"persistState"),p([g],x.prototype,"storageKey");function He(s){let t=new x;return t.init(s),t}async function Wn(s,t){let e=He(t);return await e.mount(s),e}var f={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"},ue=class extends m{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:f.container,itemClassName:f.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 i=this.loadState.page+1,o=this.buildUrl(i),a=await fetch(o,{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:i,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?.(i,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 i=await r.json(),o=this.config.extractItems(i),a=this.config.extractTotal(i);this.items=[...o],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(`.${f.trigger}, .${f.end}, .${f.error}, .${f.loading}, .${f.emptyState}`).forEach(l=>l.remove()),this.items.length>0?(this.itemsListContainer||(this.itemsListContainer=this.element?.querySelector(`.${f.list}`)),this.itemsListContainer&&this.appendNewItems(this.items)):this.updateFooter(),this.itemsListContainer=this.element?.querySelector(`.${f.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 i=r.target,o=parseInt(i.getAttribute("data-item-index")||"-1");if(o>=0&&o<this.items.length){let a=this.items[o],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 i=this.items[r];(this.config.shouldTrackItem?.(i)??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(i=>{let o=parseInt(i.getAttribute("data-item-index")||"-1");if(o<0||o>=this.items.length)return;let a=this.items[o],l=this.config.getItemId?.(a);if(!l||this.viewedItems.has(l)||!(this.config.shouldTrackItem?.(a)??true))return;let u=i.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(`.${f.list}`)),!this.itemsListContainer)return;let n=document.createDocumentFragment(),r=this.items.length-e.length;e.forEach((i,o)=>{let a=r+o,l=this.config.renderItem(i,a);l.setAttribute("data-item-index",a.toString()),this.config.onItemClick?(l.className=`${l.className} ${this.config.itemClassName} clickable`,l.onclick=()=>this.handleItemClick(i,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(`.${f.container}`);if(!e)return;let n=e.querySelector(`.${f.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(`.${f.trigger}, .${f.end}, .${f.emptyState}`).forEach(n=>{n.remove();}),this.items.length===0&&!this.loadState.loading&&this.config.emptyStateConfig){let n=this.renderEmptyState(),r=vdom.createDOMElement(n);e.appendChild(r);return}if(this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0){let n=this.renderLoadMoreTrigger(),r=vdom.createDOMElement(n);e.appendChild(r);}if(!this.loadState.hasMore&&this.items.length>0){let n=this.renderEndMessage(),r=vdom.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,i])=>{r==="className"?n.className=i:r==="style"?typeof i=="string"?n.setAttribute("style",i):typeof i=="object"&&i!==null&&Object.assign(n.style,i):r==="onclick"&&typeof i=="function"?n.addEventListener("click",i):r!=="children"&&r!=="ref"&&n.setAttribute(r,String(i));}),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 vdom.createElement("div",{className:this.config.containerClassName},this.config.enableSearch?this.renderSearchBar():null,vdom.createElement("div",{className:f.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 vdom.createElement("div",{className:f.searchbar},vdom.createElement("div",{className:"row gap-sm"},vdom.createElement("i",{className:"fas fa-search"}),vdom.createElement("input",{type:"text",className:f.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 vdom.createElement("div",{className:f.emptyState},vdom.createElement("i",{className:`__icon ${e.icon}`}),vdom.createElement("h3",{className:"__title"},e.title),vdom.createElement("p",{className:"__desc"},e.description))}renderLoading(){return vdom.createElement("div",{className:f.loading},vdom.createElement("i",{className:"fas fa-spinner fa-spin"}),vdom.createElement("p",{},this.config.loadingText))}renderError(){return vdom.createElement("div",{className:f.error},vdom.createElement("i",{className:"fas fa-exclamation-triangle"}),vdom.createElement("p",{},this.loadState.error),vdom.createElement("button",{className:`${f.button} secondary`,onclick:()=>this.loadMore()},vdom.createElement("i",{className:"fas fa-redo"})," Retry"))}renderLoadMoreTrigger(){return vdom.createElement("div",{className:f.trigger,"data-load-more-trigger":"true",style:"height: 1px; visibility: hidden;"})}renderEndMessage(){return vdom.createElement("div",{className:f.end},vdom.createElement("i",{className:"fas fa-check-circle"}),h("All loaded",{count:String(this.loadState.total)}))}};function tr(s){let t=new ue;return t.initialize(s),t}var de=class s{constructor(){this.dropdowns=new Map;this.hierarchy=new Map;this.setupGlobalClickHandler();}static getInstance(){return s.instance||(s.instance=new s),s.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(([o,a])=>a===r).map(([o,a])=>o).forEach(o=>{e.add(o),n(o);});};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(i=>i.config.parentId===n&&i.config.id!==t).forEach(i=>this.close(i.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 d=u.config.id;d===n||a.has(d)||l.has(d)||this.isDescendant(n,d)||this.close(d);});}},document.addEventListener("click",this.clickHandler,true));}},W=de.getInstance(),he=class extends m{constructor(e){super();this.isOpen=false;this.mounted=false;this.config={closeOnItemClick:true,preventAutoClose:false,...e};}onMount(){this.mounted=true,W.register(this);}onUnmount(){this.mounted=false,W.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?W.close(this.config.id):W.open(this.config.id);}handleItemClick(e,n){if(e.disabled){n.preventDefault(),n.stopPropagation();return}this.config.closeOnItemClick&&(n.preventDefault(),n.stopPropagation(),W.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 vdom.createElement("div",{className: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(),i=this.createElementFromVNode(r);this.element.appendChild(i);}}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,i])=>{r==="className"?n.className=i:r==="onclick"&&typeof i=="function"?n.addEventListener("click",i):r!=="children"&&r!=="key"&&n.setAttribute(r,String(i));}),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 vdom.createElement("button",{className:n,onclick:i=>this.toggle(i)},e);let r=["bb_dropdownArrow","fas","fa-chevron-down",this.isOpen?"bb_dropdownArrow--open":"",this.config.hideArrow?"hidden":""].filter(Boolean).join(" ");return vdom.createElement("button",{className:n,onclick:i=>this.toggle(i)},this.config.trigger.icon?vdom.createElement("i",{className:this.config.trigger.icon}):null,this.config.trigger.text?vdom.createElement("span",{},this.config.trigger.text):null,vdom.createElement("i",{className:r}))}renderMenu(){return vdom.createElement("div",{className:"bb_dropdownMenu",onclick:e=>{this.config.preventAutoClose&&e.stopPropagation();}},this.config.items.map((e,n)=>{if(e==="divider")return vdom.createElement("div",{className:"bb_dropdown__divider",key:`divider-${n}`});let r=e.selected||this.config.defaultSelected&&e.id===this.config.defaultSelected,i=["bb_dropdownItem",e.className||"",e.disabled?"bb_dropdownItem--disabled":"",r?"bb_dropdownItem--selected":""].filter(Boolean).join(" "),o={key:e.id||`item-${n}`,className:i,onclick:a=>this.handleItemClick(e,a)};return e.disabled&&(o.disabled=true),vdom.createElement("button",o,e.icon?vdom.createElement("i",{className:e.icon}):null,vdom.createElement("span",{},e.label))}))}};function ar(s){return new he(s)}function De(s,t){let e=null;return (...n)=>{e!==null&&clearTimeout(e),e=setTimeout(()=>{e=null,s(...n);},t);}}function Ue(s,t){let e=0,n=null;return (...r)=>{let i=Date.now(),o=i-e;o>=t?(e=i,s(...r)):n||(n=setTimeout(()=>{e=Date.now(),n=null,s(...r);},t-o));}}function Be(...s){let t=[];for(let e of s)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 ze(s,t="YYYY-MM-DD"){let e=s instanceof Date?s:new Date(s);if(isNaN(e.getTime()))throw new Error("Invalid date provided to formatDate");let n=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),o=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",i).replace("HH",o).replace("mm",a).replace("ss",l)}function H(s){if(s===null||typeof s!="object")return s;if(s instanceof Date)return new Date(s.getTime());if(Array.isArray(s))return s.map(t=>H(t));if(s instanceof RegExp)return new RegExp(s.source,s.flags);if(s instanceof Map){let t=new Map;return s.forEach((e,n)=>{t.set(H(n),H(e));}),t}if(s instanceof Set){let t=new Set;return s.forEach(e=>{t.add(H(e));}),t}if(Object.prototype.toString.call(s)==="[object Object]"){let t={};for(let e in s)Object.prototype.hasOwnProperty.call(s,e)&&(t[e]=H(s[e]));return t}return s}function ge(s,...t){if(!t.length)return s;let e=t.shift();if(!e)return s;if(X(s)&&X(e)){for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n)){let r=e[n],i=s[n];r!==void 0&&(X(r)&&!Array.isArray(r)?((!i||!X(i))&&(s[n]={}),ge(s[n],r)):s[n]=r);}}return ge(s,...t)}function X(s){return s!==null&&typeof s=="object"&&!Array.isArray(s)}var pe=0;function je(s="id"){let t=Date.now().toString(36),e=Math.random().toString(36).substring(2,11);pe=(pe||0)+1;let n=pe.toString(36);return `${s}_${t}_${e}_${n}`}function qe(s){if(s<0)throw new Error("Sleep duration must be non-negative");return new Promise(t=>setTimeout(t,s))}function We(s){return s==null?true:typeof s=="string"?s.trim().length===0:Array.isArray(s)?s.length===0:s instanceof Map||s instanceof Set?s.size===0:typeof s=="object"?Object.keys(s).length===0:false}function Ge(s){return s?s.charAt(0).toUpperCase()+s.slice(1):""}function Je(s){return s?s.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase():""}function Ce(s){return s?s.replace(/[-_\s]+(.)?/g,(t,e)=>e?e.toUpperCase():"").replace(/^[A-Z]/,t=>t.toLowerCase()):""}function Qe(s){if(!s)return "";let t=Ce(s);return t.charAt(0).toUpperCase()+t.slice(1)}function Ye(s,t,e="..."){return !s||s.length<=t?s:s.substring(0,t-e.length)+e}function Ze(s){let t={},e=s.replace(/^\?/,"");if(!e)return t;let n=e.split("&");for(let r of n){let[i,o]=r.split("=").map(decodeURIComponent);if(!i)continue;let a=o||"";if(i.endsWith("[]")){let l=i.slice(0,-2);t[l]||(t[l]=[]),t[l].push(a);}else t[i]=a;}return t}function Xe(s){let t=[];for(let[e,n]of Object.entries(s))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 et(s,t,e){return Math.min(Math.max(s,t),e)}function tt(){return typeof window<"u"&&typeof document<"u"}function nt(s,t){try{return JSON.parse(s)}catch{return t}}var cr={debounce:De,throttle:Ue,classNames:Be,formatDate:ze,deepClone:H,deepMerge:ge,uniqueId:je,sleep:qe,isEmpty:We,capitalize:Ge,kebabCase:Je,camelCase:Ce,pascalCase:Qe,truncate:Ye,parseQuery:Ze,stringifyQuery:Xe,clamp:et,isBrowser:tt,safeJsonParse:nt};var Se=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,i=n.isIntersecting;i&&!r?(this.observedElements.set(n.target,true),t.onEnter?.(n),t.once&&this.unobserve(n.target)):!i&&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 dr(s,t){let e=new IntersectionObserver(n=>{n.forEach(r=>{r.isIntersecting&&(t(r),e.unobserve(s));});},{threshold:.1});return e.observe(s),()=>e.disconnect()}function fe(s){let t=typeof s=="string"?new Date(s):s,n=new Date().getTime()-t.getTime(),r=Math.floor(n/1e3),i=Math.floor(r/60),o=Math.floor(i/60),a=Math.floor(o/24),l=Math.floor(a/7),c=Math.floor(a/30),u=Math.floor(a/365),d="";return r<0?d=h("time.just_now"):r<60?d=h("time.just_now"):i<2?d=h("time.minute_ago"):i<60?d=h("time.minutes_ago",{count:i.toString()}):o<2?d=h("time.hour_ago"):o<24?d=h("time.hours_ago",{count:o.toString()}):a<2?d=h("time.day_ago"):a<7?d=h("time.days_ago",{count:a.toString()}):l<2?d=h("time.week_ago"):l<4?d=h("time.weeks_ago",{count:l.toString()}):c<2?d=h("time.month_ago"):c<12?d=h("time.months_ago",{count:c.toString()}):u<2?d=h("time.year_ago"):d=h("time.years_ago",{count:u.toString()}),{formatted:d,originalDate:t.toISOString(),title:t.toLocaleString()}}function gr(s){let{formatted:t,title:e}=fe(s);return {text:t,title:e}}function fr(s){return fe(s).formatted}function mr(s){return fe(s).title}vdom.setConfig({devMode:false,sanitizeHTML:true});Object.defineProperty(exports,"createDOMElement",{enumerable:true,get:function(){return vdom.createDOMElement}});Object.defineProperty(exports,"createElement",{enumerable:true,get:function(){return vdom.createElement}});Object.defineProperty(exports,"html",{enumerable:true,get:function(){return vdom.html}});Object.defineProperty(exports,"patch",{enumerable:true,get:function(){return vdom.patch}});Object.defineProperty(exports,"api",{enumerable:true,get:function(){return capi.api}});Object.defineProperty(exports,"configureApi",{enumerable:true,get:function(){return capi.configureApi}});Object.defineProperty(exports,"getApiConfig",{enumerable:true,get:function(){return capi.getApiConfig}});Object.defineProperty(exports,"http",{enumerable:true,get:function(){return capi.http}});Object.defineProperty(exports,"resetApiConfig",{enumerable:true,get:function(){return capi.resetApiConfig}});exports.CombinedContext=te;exports.Component=m;exports.Context=G;exports.Dropdown=he;exports.I18nManager=z;exports.ItemsLoader=ue;exports.Loader=I;exports.Popup=Z;exports.Provider=ve;exports.Router=ie;exports.SmartForm=_e;exports.SmartFormComponent=V;exports.Store=ae;exports.StyleManager=D;exports.TabbedView=x;exports.Toast=Y;exports.VisibilityObserver=Se;exports.camelCase=Ce;exports.capitalize=Ge;exports.clamp=et;exports.classNames=Be;exports.clearHookContext=Pe;exports.client=qt;exports.computed=dt;exports.connect=Ut;exports.createCombinedContext=vt;exports.createComputedStore=Dt;exports.createContext=mt;exports.createDropdown=ar;exports.createFunctionalComponent=Pt;exports.createItemsLoader=tr;exports.createStore=Oe;exports.createTabbedView=He;exports.createTranslator=sn;exports.css=be;exports.debounce=De;exports.deepClone=H;exports.deepMerge=ge;exports.formatDate=ze;exports.formatRelativeTime=fe;exports.formatTimeAgo=fr;exports.getCurrentLanguage=Zt;exports.getCurrentPath=oe;exports.getI18n=S;exports.getPopup=M;exports.getQueryParam=At;exports.getQueryParams=Re;exports.getSupportedLanguages=tn;exports.getTimeDisplay=gr;exports.getTimeTitle=mr;exports.getToast=q;exports.getTranslations=rn;exports.goBack=Rt;exports.goForward=Ot;exports.hasKey=nn;exports.initPopup=Ae;exports.initToast=Fe;exports.initializeI18n=an;exports.isBrowser=tt;exports.isCurrentPath=$t;exports.isCurrentPathPrefix=Vt;exports.isEmpty=We;exports.kebabCase=Je;exports.loadFromUrl=on;exports.loadLanguage=Xt;exports.loadLanguageFile=cn;exports.loadTranslations=en;exports.mountTabbedView=Wn;exports.navigate=we;exports.navigateWithQuery=Kt;exports.observeVisibility=dr;exports.parseQuery=Ze;exports.pascalCase=Qe;exports.popup=An;exports.reloadRoute=Ft;exports.router=O;exports.safeJsonParse=nt;exports.scheduler=U;exports.setHookContext=Me;exports.setLanguage=Qt;exports.setLanguageAsync=Yt;exports.setupI18n=ln;exports.sleep=qe;exports.state=g;exports.stringifyQuery=Xe;exports.t=h;exports.tHtml=le;exports.tLang=Jt;exports.throttle=Ue;exports.toast=fn;exports.truncate=Ye;exports.uniqueId=je;exports.useCallback=re;exports.useContext=bt;exports.useDebounce=Ct;exports.useEffect=R;exports.useEventListener=Mt;exports.useFetch=kt;exports.useInterval=xt;exports.useLocalStorage=_t;exports.useMemo=Ie;exports.usePrevious=St;exports.useReducer=Tt;exports.useRef=se;exports.useState=N;exports.useToggle=Et;exports.useWindowSize=Lt;exports.utils=cr;exports.watch=ht;//# sourceMappingURL=main.cjs.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}),capi.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:vdom.div,span:vdom.span,h1:vdom.h1,h2:vdom.h2,h3:vdom.h3,h4:vdom.h4,h5:vdom.h5,h6:vdom.h6,p:vdom.p,i:vdom.i,img:vdom.img,a:vdom.a,button:vdom.button,input:vdom.input,select:vdom.select,option:vdom.option,textarea:vdom.textarea,form:vdom.form,icon:(i,t)=>vdom.i(v.fa(i,t)),btn:i=>vdom.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?vdom.html``:vdom.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 vdom.div({key:String(e.id),class:`${Y.toast} ${Y.toast}--${e.type}`,"data-translate":e.translateKey||void 0},vdom.i(`${n[e.type]} ${Y.icon}`),vdom.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 vdom.div({class:n,"data-status":this.visible?"visible":"hidden",role:"status","aria-live":"polite","aria-busy":"true"},vdom.div(e.bg),vdom.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 vdom.div(n,vdom.div(e.spinner.dot),vdom.div(e.spinner.dot),vdom.div(e.spinner.dot));case "pulse":return vdom.div(n,vdom.div(e.spinner.pulse));case "spinner":default:return vdom.div(n,vdom.div(e.spinner.icon))}}renderMessage(){let{loader:e}=T,n=this.message||d("loader.loading");return vdom.div({class:e.spinner.text,"data-translate":this.message?void 0:"loader.loading"},n)}renderProgressBar(){let{loader:e}=T;return vdom.div(e.progress.container,vdom.div({class:e.progress.bar,style:`width: ${this.progress}%`,"aria-valuenow":this.progress.toString(),"aria-valuemin":"0","aria-valuemax":"100"}),vdom.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 capi.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?vdom.label(l,vdom.span($.fa(s)),o?vdom.span(Ge.form.fieldTitle,o):""):vdom.label(l,o||"")}if(!e.label)return "";let n={for:e.name};return vdom.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?"":vdom.div({class:g.fieldInputButtonRulesContent},...n.map(r=>vdom.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(vdom.div({class:g.fieldInputButtonRules,title:o.title},vdom.button({type:"button",class:g.fieldInputButton,tabindex:-1,onclick:s=>{s.preventDefault(),s.stopPropagation();}},vdom.span($.fa(o.icon||"fa-circle-info"))),this.renderValidationRules(e))):r.push(vdom.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();}},vdom.span($.fa(o.icon||"fa-gear"))));return vdom.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?vdom.span({class:g.fieldError},e.error):"";switch(e.type){case "textarea":return vdom.div({class:o},r,vdom.div({class:g.fieldInputContainer},vdom.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=>vdom.option({value:String(c.value),selected:String(c.value)===String(n)},c.label));return vdom.div({class:o},r,vdom.div({class:g.fieldInputContainer},vdom.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},vdom.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),vdom.div({class:l},vdom.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}),vdom.label({for:e.name},c?vdom.span($.fa(c)):"",u||""),s)}default:{let l=e.type==="password"&&this.passwordVisibility[e.name]?"text":e.type||"text";return vdom.div({class:o},r,vdom.div({class:g.fieldInputContainer},vdom.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(vdom.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?vdom.span($.fa(o.icon)," "):"",l));}return vdom.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(vdom.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 vdom.form({class:n,onsubmit:r=>this.handleSubmit(r)},this.submitError?vdom.div({class:[g.alert,g.alertError].join(" ")},this.submitError):"",this.submitSuccess?vdom.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?vdom.div(w.container):vdom.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 vdom.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);}},vdom.div({class:`${w.popup.base} ${n} ${r}`,role:"dialog","aria-modal":"true","aria-labelledby":`popup-title-${e.id}`},e.showCloseButton!==false?vdom.button({class:w.popup.close,onclick:()=>this.closePopup(e.id,false),"aria-label":"Close"},vdom.i(v.fa("times"))):null,vdom.div(w.header.container,e.icon?vdom.div(w.header.icon,vdom.i(e.icon)):null,vdom.div(w.header.content,vdom.h2({id:`popup-title-${e.id}`,class:w.header.title,"data-translate":e.titleTranslateKey},e.titleTranslateKey?d(e.titleTranslateKey):e.title),e.description?vdom.p({class:w.header.description,"data-translate":e.descriptionTranslateKey},e.descriptionTranslateKey?he(e.descriptionTranslateKey):e.description):null)),vdom.div(w.body.container,e.message?vdom.p({class:w.body.message,"data-translate":e.messageTranslateKey},e.messageTranslateKey?he(e.messageTranslateKey):e.message):null,e.type==="prompt"?vdom.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?vdom.div(w.body.formContainer,Te(e.formConfig)):null,e.customContent||null),e.buttons&&e.buttons.length>0&&e.type!=="form"?vdom.div(w.footer,...e.buttons.map(o=>vdom.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?vdom.i(o.icon):null,o.loading||e.isSubmitting?vdom.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 vdom.div(e,this.renderTabList(),this.renderTabContent())}renderTabList(){let e=[M.header,this.headerClassName].filter(Boolean).join(" ");return vdom.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 vdom.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?vdom.i(e.icon):null,vdom.span({},o),e.badge!==void 0&&e.badge!==null&&e.badge!==0?vdom.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?vdom.div({class:e,role:"tabpanel"},this.renderActiveTabContent(n)):vdom.div(e,vdom.div(M.content.emptyState,vdom.p({},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),vdom.div(M.content.error,d("global.loading"))}return e.content?e.content:vdom.div(M.content.emptyState,vdom.p({},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=vdom.createDOMElement(n);e.appendChild(r);return}if(this.loadState.hasMore&&!this.loadState.loading&&this.items.length>0){let n=this.renderLoadMoreTrigger(),r=vdom.createDOMElement(n);e.appendChild(r);}if(!this.loadState.hasMore&&this.items.length>0){let n=this.renderEndMessage(),r=vdom.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 vdom.div({class:this.config.containerClassName},this.config.enableSearch?this.renderSearchBar():null,vdom.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 vdom.div(m.searchbar,vdom.div("row gap-sm",vdom.i(v.fa("search")),vdom.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 vdom.div(m.emptyState,vdom.i(`__icon ${e.icon}`),vdom.span("__title",e.title),vdom.p("__desc",e.description))}renderLoading(){return vdom.div(m.loading,vdom.i(v.fa("spinner")+" fa-spin"),vdom.p({},this.config.loadingText))}renderError(){return vdom.div(m.error,vdom.i(v.fa("exclamation-triangle")),vdom.p({},this.loadState.error),vdom.button({class:`${m.button} secondary`,onclick:()=>this.loadMore()},vdom.i(v.fa("redo"))," Retry"))}renderLoadMoreTrigger(){return vdom.div({class:m.trigger,"data-load-more-trigger":"true",style:"height: 1px; visibility: hidden;"})}renderEndMessage(){return vdom.div({class:m.end},vdom.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 vdom.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 vdom.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 vdom.button({class:n,onclick:o=>this.toggle(o)},this.config.trigger.icon?vdom.i(this.config.trigger.icon):null,this.config.trigger.text?vdom.span({},this.config.trigger.text):null,vdom.i(r))}renderMenu(){return vdom.div({class:"bb_dropdownMenu",onclick:e=>{this.config.preventAutoClose&&e.stopPropagation();}},...this.config.items.map((e,n)=>{if(e==="divider")return vdom.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),vdom.button(s,e.icon?vdom.i(e.icon):null,vdom.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}vdom.setConfig({devMode:false,sanitizeHTML:true});var Ge=ye;Object.defineProperty(exports,"a",{enumerable:true,get:function(){return vdom.a}});Object.defineProperty(exports,"button",{enumerable:true,get:function(){return vdom.button}});Object.defineProperty(exports,"createDOMElement",{enumerable:true,get:function(){return vdom.createDOMElement}});Object.defineProperty(exports,"createElement",{enumerable:true,get:function(){return vdom.createElement}});Object.defineProperty(exports,"div",{enumerable:true,get:function(){return vdom.div}});Object.defineProperty(exports,"form",{enumerable:true,get:function(){return vdom.form}});Object.defineProperty(exports,"h1",{enumerable:true,get:function(){return vdom.h1}});Object.defineProperty(exports,"h2",{enumerable:true,get:function(){return vdom.h2}});Object.defineProperty(exports,"h3",{enumerable:true,get:function(){return vdom.h3}});Object.defineProperty(exports,"h4",{enumerable:true,get:function(){return vdom.h4}});Object.defineProperty(exports,"h5",{enumerable:true,get:function(){return vdom.h5}});Object.defineProperty(exports,"h6",{enumerable:true,get:function(){return vdom.h6}});Object.defineProperty(exports,"html",{enumerable:true,get:function(){return vdom.html}});Object.defineProperty(exports,"i",{enumerable:true,get:function(){return vdom.i}});Object.defineProperty(exports,"img",{enumerable:true,get:function(){return vdom.img}});Object.defineProperty(exports,"input",{enumerable:true,get:function(){return vdom.input}});Object.defineProperty(exports,"isVNode",{enumerable:true,get:function(){return vdom.isVNode}});Object.defineProperty(exports,"label",{enumerable:true,get:function(){return vdom.label}});Object.defineProperty(exports,"option",{enumerable:true,get:function(){return vdom.option}});Object.defineProperty(exports,"p",{enumerable:true,get:function(){return vdom.p}});Object.defineProperty(exports,"patch",{enumerable:true,get:function(){return vdom.patch}});Object.defineProperty(exports,"select",{enumerable:true,get:function(){return vdom.select}});Object.defineProperty(exports,"span",{enumerable:true,get:function(){return vdom.span}});Object.defineProperty(exports,"textarea",{enumerable:true,get:function(){return vdom.textarea}});Object.defineProperty(exports,"validateVNode",{enumerable:true,get:function(){return vdom.validateVNode}});Object.defineProperty(exports,"api",{enumerable:true,get:function(){return capi.api}});Object.defineProperty(exports,"configureApi",{enumerable:true,get:function(){return capi.configureApi}});Object.defineProperty(exports,"getApiConfig",{enumerable:true,get:function(){return capi.getApiConfig}});Object.defineProperty(exports,"http",{enumerable:true,get:function(){return capi.http}});Object.defineProperty(exports,"resetApiConfig",{enumerable:true,get:function(){return capi.resetApiConfig}});exports.CM=$;exports.ClassMaker=v;exports.CombinedContext=le;exports.Component=b;exports.Context=X;exports.Dropdown=Me;exports.EC=It;exports.ElementCreator=be;exports.I18nManager=J;exports.ItemsLoader=Se;exports.Loader=I;exports.Popup=oe;exports.Provider=Oe;exports.Router=pe;exports.SmartForm=Te;exports.SmartFormComponent=P;exports.Store=ge;exports.StyleManager=q;exports.TabbedView=x;exports.Toast=ne;exports.VisibilityObserver=tt;exports.Window=te;exports.bbMap=Ge;exports.camelCase=et;exports.capitalize=fn;exports.clamp=wn;exports.classNames=cn;exports.clearHookContext=at;exports.client=Pr;exports.computed=Pn;exports.connect=xr;exports.createCombinedContext=Bn;exports.createComputedStore=Sr;exports.createContext=On;exports.createDropdown=Oi;exports.createFunctionalComponent=Yn;exports.createItemsLoader=Pi;exports.createStore=dt;exports.createTabbedView=nn;exports.createTranslator=lr;exports.css=Re;exports.debounce=an;exports.deepClone=z;exports.deepMerge=Pe;exports.formatDate=un;exports.formatRelativeTime=Ve;exports.formatTimeAgo=Ui;exports.getCurrentLanguage=nr;exports.getCurrentPath=fe;exports.getDefaultFATheme=De;exports.getI18n=S;exports.getPopup=k;exports.getQueryParam=Cr;exports.getQueryParams=ut;exports.getSupportedLanguages=or;exports.getTimeDisplay=ji;exports.getTimeTitle=zi;exports.getToast=Q;exports.getTranslations=ar;exports.goBack=mr;exports.goForward=br;exports.hasKey=sr;exports.initPopup=Xt;exports.initToast=zt;exports.initializeFAConfig=He;exports.initializeI18n=ur;exports.isBrowser=Tn;exports.isCurrentPath=vr;exports.isCurrentPathPrefix=yr;exports.isEmpty=pn;exports.kebabCase=gn;exports.loadFromUrl=cr;exports.loadLanguage=rr;exports.loadLanguageFile=hr;exports.loadTranslations=ir;exports.mountTabbedView=_i;exports.navigate=Ke;exports.navigateWithQuery=Tr;exports.observeVisibility=$i;exports.parseQuery=vn;exports.pascalCase=mn;exports.popup=gi;exports.reloadRoute=wr;exports.router=R;exports.safeJsonParse=Cn;exports.scheduler=W;exports.setDefaultFATheme=ht;exports.setHookContext=st;exports.setLanguage=er;exports.setLanguageAsync=tr;exports.setupI18n=dr;exports.sleep=hn;exports.state=f;exports.stringifyQuery=yn;exports.t=d;exports.tHtml=he;exports.tLang=Xn;exports.throttle=ln;exports.toast=Hr;exports.truncate=bn;exports.uniqueId=dn;exports.useCallback=ue;exports.useContext=An;exports.useDebounce=jn;exports.useEffect=F;exports.useEventListener=Jn;exports.useFetch=Wn;exports.useInterval=qn;exports.useLocalStorage=Hn;exports.useMemo=lt;exports.usePrevious=Un;exports.useReducer=Dn;exports.useRef=de;exports.useState=N;exports.useToggle=zn;exports.useWindowSize=Gn;exports.utils=Bi;exports.watch=Vn;//# sourceMappingURL=main.cjs.map
|
|
114
14
|
//# sourceMappingURL=main.cjs.map
|