@base-framework/base 3.5.25 → 3.5.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/base.js CHANGED
@@ -1,2 +1,2 @@
1
- var N=class{static toArray(t){return Array.from(t)}static inArray(t,e,r){return Array.isArray(t)?t.indexOf(e,r):-1}};var h=class{static getType(t){let e=typeof t;return e!=="object"?e:Array.isArray(t)?"array":"object"}static isUndefined(t){return typeof t>"u"}static isObject(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}static isFunction(t){return typeof t=="function"}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}};var g={create(s){return Object.create(s||null)},extendObject(s,t){return!h.isObject(s)||!h.isObject(t)?!1:(Object.keys(s).forEach(e=>{this.hasOwnProp(t,e)||(t[e]=s[e])}),t)},clone(s){return!s||!h.isObject(s)?{}:JSON.parse(JSON.stringify(s))},getClassObject(s){return typeof s=="function"?s.prototype:s},extendClass(s,t){let e=this.getClassObject(s),r=this.getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let i=Object.create(e);for(var n in r)i[n]=r[n];return i},hasOwnProp(s,t){return Object.prototype.hasOwnProperty.call(s,t)},isPlainObject(s){return!!s&&Object.prototype.toString.call(s)==="[object Object]"},isEmpty(s){return h.isObject(s)?Object.keys(s).length===0:!0}};var Z={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var ht=class{constructor(){this.types=new Map}add(t,e){this.types.has(t)||this.types.set(t,[]),this.types.get(t).push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){if(!this.types.has(t))return;let e=this.types.get(t);if(!e.length)return;let r,i=Z.get(t);if(i){for(var n=0,o=e.length;n<o;n++)r=e[n],r&&(e[n]=null,this.removeByCallBack(i,r));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}this.types.forEach((e,r)=>{r&&this.removeType(r)}),this.types.clear()}};var f=class{static trackers=new Map;static trackingCount=0;static addType(t,e){Z.add(t,e)}static removeType(t){Z.remove(t)}static getTrackingId(t){return t?t.trackingId||(t.trackingId=`dt${this.trackingCount++}`):""}static add(t,e,r){let i=this.getTrackingId(t);this.find(i).add(e,r)}static get(t,e){let r=t.trackingId,i=this.trackers.get(r);return i?e?i.get(e):i:!1}static has(t,e){let r=this.getTrackingId(t);if(!r)return!1;let i=this.trackers.get(r);return i&&e?i.has(e):!1}static find(t){return this.trackers.has(t)||this.trackers.set(t,new ht),this.trackers.get(t)}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let r=t.trackingId;if(!r||!this.trackers.has(r))return;let i=this.trackers.get(r);if(!e){i.remove(),this.trackers.delete(r),delete t.trackingId;return}i.remove(e),this.isEmpty(i.types)&&(this.trackers.delete(r),delete t.trackingId)}};var Ft=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=Ft(s[e]));return t},ee=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(let[r,i]of Object.entries(s)){if(!g.hasOwnProp(t,r))break;let n=t[r];if(typeof i!=typeof n)break;if(typeof i=="object"){if(e=ee(i,n),e!==!0)break}else if(i===n)e=!0;else break}return e},tr=(s,t)=>{let e=Ft(s),r=Ft(t);return e!==r?!1:ee(s,t)},re=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?tr(s,t):s===t};var l={getEvents(s){return h.isObject(s)===!1?[]:f.get(s,"events")},create(s,t,e,r=!1,i=!1,n=null){return i=i===!0,{event:s,obj:t,fn:e,capture:r,swapped:i,originalFn:n}},on(s,t,e,r){return Array.isArray(s)?s.forEach(i=>this.add(i,t,e,r)):this.add(s,t,e,r),this},off(s,t,e,r){if(Array.isArray(s)){var i;s.forEach(n=>this.remove(n,t,e,r))}else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,i=!1,n=null){if(h.isObject(t)===!1)return this;let o=this.create(s,t,e,r,i,n);return f.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let i=this.getEvent(s,t,e,r);return i===!1?this:(typeof i=="object"&&this.removeEvent(i),this)},removeEvent(s){return typeof s=="object"&&s.obj.removeEventListener(s.event,s.fn,s.capture),this},getEvent(s,t,e,r){if(typeof t!="object")return!1;let i=this.getEvents(t);if(!i||i.length<1)return!1;let n=this.create(s,t,e,r);return this.search(n,i)},search(s,t){let e,r=this.isSwappable(s.event);for(var i=0,n=t.length;i<n;i++)if(e=t[i],!(e.event!==s.event||e.obj!==s.obj)&&(e.fn===s.fn||r===!0&&e.originalFn===s.fn))return e;return!1},removeEvents(s){return h.isObject(s)===!1?this:(f.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};f.addType("events",s=>{l.removeEvent(s)});var Vt={events:l,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.add(n,t,e,r)}):i.add(s,t,e,r),this},off(s,t,e,r){let i=this.events;return Array.isArray(s)?s.forEach(n=>{i.remove(n,t,e,r)}):i.remove(s,t,e,r),this},removeListener(s,t,e,r){return this.events.remove(s,t,e,r),this},_createEvent(s,t,e,r){let i;switch(t){case"HTMLEvents":i=new Event(s,e);break;case"MouseEvents":i=new MouseEvent(s,e);break;default:i=new CustomEvent(s,r);break}return i},createEvent(s,t,e,r){if(h.isObject(t)===!1)return!1;let i={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};h.isObject(e)&&(i=Object.assign(i,e));let n=this._getEventType(s);return this._createEvent(s,n,i,r)},_getEventType(s){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e="CustomEvent";for(let[r,i]of Object.entries(t))if(s.match(i)){e=r;break}return e},trigger(s,t,e){if(h.isObject(t)===!1)return this;let r=typeof s=="string"?this.createEvent(s,t,null,e):s;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let s=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=s())},onMouseWheel(s,t,e,r=!1){typeof t>"u"&&(t=window);let i=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof s=="function"&&s(a,o),e===!0&&o.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,i,r,!0,s),this},offMouseWheel(s,t,e=!1){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,s,e),this},preventDefault(s){return typeof s.preventDefault=="function"?s.preventDefault():s.returnValue=!1,this},stopPropagation(s){return typeof s.stopPropagation=="function"?s.stopPropagation():s.cancelBubble=!0,this}};var tt=class{constructor(){this.errors=[],this.dataTracker=f}augment(t){if(!h.isObject(t))return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,i){return(t[e]=r).apply(t,N.toArray(i))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(h.isObject(t)===!1)return"";let i=t[e];return typeof i<"u"?i:typeof r<"u"?r:""}createCallBack(t,e,r=[],i=!1){return typeof e!="function"?!1:(...n)=>(i===!0&&(r=r.concat(n)),e.apply(t,r))}bind(t,e){return e.bind(t)}};tt.prototype.extend=(function(){return tt.prototype})();var T=new tt;T.augment({...g,...Vt,...h,equals:re});var et={url:"",responseType:"json",method:"POST",fixedParams:"",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},beforeSend:[],async:!0,crossDomain:!1,withCredentials:!1,completed:null,failed:null,aborted:null,progress:null};var se=()=>{T.augment({xhrSettings:et,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=g.extendClass(T.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=et}})};var v=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,r=!0){typeof t!="string"&&(t=window.location.search),t=this.limit(t);let i={},n=/([^?=&]+)(=([^&]*))?/g;return t.replace(n,function(o,a,c,u){i[a]=e!==!1?decodeURIComponent(u):u}),i}static camelCase(t){t=this.limit(t);let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let r=/([A-Z]{1,})/g;return t.replace(r,i=>e+i.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,r=>r.charAt(0).toUpperCase()+r.substring(1).toLowerCase())}};var lt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:r,url:i,async:n}=this.settings;e.open(r,i,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=et.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var i=0,n=t.length;i<n;i++){var o=t[i];o&&o(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let i=typeof e;if(r==="string")return i!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(i==="string"&&(e=v.parseQueryString(e,!1)),t instanceof FormData)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.append(n,e[n]);else r==="object"&&(t=g.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings={...T.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var r=0,i=t.length;r<i;r++){var n=t[r];switch(r){case 0:e.url=n;break;case 1:e.params=n;break;case 2:e.completed=n,e.failed=n;break;case 3:e.responseType=n||"json";break;case 4:e.method=n?n.toUpperCase():"POST";break;case 5:e.async=typeof n<"u"?n:!0;break}}else e=this.settings=g.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t||typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,i=()=>{l.removeEvents(r.upload),l.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let a=this.getResponseData();n.completed(a,this.xhr)}i();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),i();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),i();break}}getResponseData(){let t=this.xhr,e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=this.update.bind(this);l.on(["load","error","abort"],e,r),l.on("progress",e.upload,r)}};se();var ft=(...s)=>new lt(s).xhr;var er=s=>typeof s!="string"?s:ie(s),ie=s=>[{tag:"text",textContent:s}],pt=()=>({props:{},children:[]}),dt=s=>({props:{},children:ie(s)}),mt=s=>({props:{},children:s}),gt=s=>({props:s[0]||{},children:er(s[1])});var yt=class{constructor(){this.connections=new Map}add(t,e,r){let i=this.getOrCreate(t),n=i.get(e);return n?Array.isArray(n)?n.push(r):i.set(e,[n,r]):i.set(e,r),r}get(t,e){let r=this.connections.get(t)?.get(e);return r?Array.isArray(r)?r[r.length-1]||!1:r:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let r=this.connections.get(t);if(r)if(e)this.unsubscribe(r.get(e)),r.delete(e),r.size===0&&this.connections.delete(t);else{for(let i of r.values())this.unsubscribe(i);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var j=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var bt=class extends j{constructor(t){super(),this.data=t}subscribe(t,e){this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data&&this.msg&&this.token&&this.data.off(this.msg,this.token),this.data=null,this.msg=null,this.token=null}};var W=class{unsubscribe(){}};var xt=class extends W{constructor(){super(),this.source=null}addSource(t){return this.source=new bt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var $=class extends j{constructor(t){super(),this.pubSub=t}subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=this.pubSub.on(t,e)}unsubscribe(){this.pubSub&&this.msg&&this.token&&this.pubSub.off(this.msg,this.token),this.pubSub=null,this.msg=null,this.token=null}callBack(){}};var vt=class extends ${constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}unsubscribe(){super.unsubscribe(),this.data=null,this.prop=null}};var d=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?N.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:N.toArray(r):!1}static html(t,e){return h.isObject(t)===!1?!1:h.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return h.isObject(t)===!1||h.isUndefined(e)?this:(e=v.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=v.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let i=null,n=t.currentStyle;if(n&&(i=n[e]))return i;let o=window.getComputedStyle(t,null);return o?o[e]:r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return h.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=v.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=v.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=v.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(h.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(h.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return h.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return h.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return h.isObject(t)?t.offsetWidth:!1}static getHeight(t){return h.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return h.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,i=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||i.clientWidth,o=t.innerHeight||r.clientHeight||i.clientHeight;return{width:n,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,i=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:i}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(h.isObject(t)===!1)return r;let i=0;for(;t&&(e===0||i<e);)i++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}static addClass(t,e){if(h.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,i=n.length;r<i;r++)t.classList.add(e)}return this}static removeClass(t,e){return h.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return h.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return h.isObject(t)===!1?this:(t.classList.toggle(e),this)}};var St=s=>{let t="textContent";if(!s||typeof s!="object")return t;let e=s.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let r=s.type;if(!r)return t="value",t;switch(r){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var rr=(s,t,e)=>{d.setAttr(s,t,e)},sr=(s,t,e)=>{s.checked=s.value==e},ir=(s,t,e)=>{e=e==1,ne(s,t,e)},ne=(s,t,e)=>{s[t]=e},nr=(s,t)=>d.getAttr(s,t),or=(s,t)=>s[t],kt=class extends ${constructor(t,e,r,i){super(i),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.substring(4,1)==="-")return this.setValue=rr,this.getValue=nr,this;this.getValue=or;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=ir;return;case"radio":this.setValue=sr;return}return this.setValue=ne,this}getAttrBind(t){return t||St(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;return!e||typeof e!="object"?this:(this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t),this)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){return e!==this.element&&this.set(t),this}unsubscribe(){super.unsubscribe(),this.element=null,this.attr=null,this.filter=null,this.setValue=null,this.getValue=null}};var wt=class extends W{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new kt(t,e,r,this.pubSub)}addData(t,e){return this.data=new vt(t,e,this.pubSub)}unsubscribeSource(t){return t&&t.unsubscribe(),this}unsubscribe(){return this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null,this}};var oe=-1,F=class{constructor(){this.callBacks=new Map}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),oe=-1}on(t,e){let r=(++oe).toString();return this.get(t).set(r,e),r}off(t,e){let r=this.callBacks.get(t);r&&(e=String(e),r.delete(e),r.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,...e){let r=this.callBacks.get(t);if(r)for(let i of r.values())i&&i.apply(this,e)}};var Jt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new yt,this.pubSub=new F,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,i){let n=r,o=null;if(r.indexOf(":")!==-1){let p=r.split(":");p.length>1&&(n=p[1],o=p[0])}let a=this.setupConnection(t,e,n,o,i),c=a.element,u=e.get(n);return typeof u<"u"?c.set(u):(u=c.get(),u!==""&&a.data.set(u)),this}setupConnection(t,e,r,i,n){let o=this.getBindId(t),a=new wt(this.pubSub);a.addData(e,r).subscribe(o);let p=`${e.getDataId()}:${r}`;return a.addElement(t,i,n).subscribe(p),this.addConnection(o,"bind",a),a}addConnection(t,e,r){return this.connections.add(t,e,r),this}setBindId(t){let e="db-"+this.idCount++;return t.dataset&&(t.dataset[this.attr]=e),t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,i){if(h.isObject(t)===!1)return this;let n=new xt;n.addSource(e).subscribe(r,i);let a=this.getBindId(t),c=e.getDataId()+":"+r;this.addConnection(a,c,n);let u=e.get(r);return i(u),this}unwatch(t,e,r){if(h.isObject(t)===!1)return this;let i=t[this.attr];if(i){let n=e.getDataId()+":"+r;this.connections.remove(i,n)}return this}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.indexOf(t.keyCode)!==-1}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r!==null){let i=this.connections.get(r,"bind");if(i){let n=i.element.get();this.pubSub.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){typeof document<"u"&&l.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){typeof document<"u"&&l.off(["change","paste","input"],document,this.changeHandler,!1)}},x=new Jt;var D=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var ar={class:"className",text:"textContent",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",celpadding:"cellPadding",useMap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},rt=s=>ar[s]||s,st=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,A=class{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e),i===!0?this.prepend(r,n):this.append(r,n),n}static addAttributes(t,e){if(!e||typeof e!="object")return;let r=e.type;typeof r<"u"&&d.setAttr(t,"type",r);for(let[i,n]of Object.entries(e))i==="innerHTML"?t.innerHTML=n:i.indexOf("-")!==-1?d.setAttr(t,i,n):this.addAttr(t,i,n)}static addHtml(t,e){return typeof e>"u"||e===""?this:(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(r===""||!e)return;if(typeof r==="function")e=st(e),r.originalCallback?l.add(e,t,r,!1,!1,r.originalCallback):l.add(e,t,r);else{let n=rt(e);t[n]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!h.isObject(t)||!h.isArray(e))return!1;e.forEach(i=>{let n=new Option(i.label,i.value);t.options.add(n),r!==null&&n.value==r&&(n.selected=!0)})}static removeElementData(t){f.remove(t);let e=t.childNodes;if(e){let o=e.length-1;for(var r=o;r>=0;r--){var i=e[r];i&&this.removeElementData(i)}}t.bindId&&x.unbind(t)}static removeElement(t){if(!t)return this;let e=f.has(t,"manual-destroy");return this.removeElementData(t),e===!1&&t.remove(),this}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(!h.isObject(t))return this;let e=t.childNodes;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.removeElementData(e[r]);return t.innerHTML="",this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let i=r||t.firstChild;return t.insertBefore(e,i),this}static clone(t,e=!1){return h.isObject(t)?t.cloneNode(e):!1}};var w=class extends A{static create(t,e,r,i){let n=document.createElement(t);return this.addAttributes(n,e,i),r.appendChild(n),n}static addAttributes(t,e,r){!e||e.length<1||e.forEach(i=>{let{key:n,value:o}=i;this.addAttr(t,n,o,r)})}static addAttr(t,e,r,i){if(r===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){e=st(e),l.add(e,t,function(a){r.call(this,a,i)});return}if(e.substr(4,1)==="-"){d.setAttr(t,e,r);return}let o=rt(e);t[o]=r}static addContent(t,e){e&&(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}};var qt=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,C={isWatching(s){return Array.isArray(s)?typeof s[0]=="string"&&this.hasParams(s[0]):this.hasParams(s)},hasParams(s){return h.isString(s)&&s.includes("[[")},_getWatcherProps(s){let t=s.match(qt);return t?t.map(e=>e.slice(2,-2)):null},updateAttr(s,t,e){switch(t){case"text":case"textContent":s.textContent=e;break;case"disabled":s.disabled=!e;break;case"checked":s.checked=!!e;break;case"required":s.required=!!e;break;case"src":if(s.tagName.toLowerCase()==="img"){s.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}s.src=e;break;default:w.addAttr(s,t,e);break}},replaceParams(s,t,e=!1){let r=0;return s.replace(qt,function(){let i=e?t[r]:t;r++;let n=i.get(arguments[2]);return typeof n<"u"&&n!==null?n:""})},_getWatcherCallBack(s,t,e,r,i){return()=>{let n=this.replaceParams(e,t,i);this.updateAttr(s,r,n)}},getValue(s,t){let e=s.value;return Array.isArray(e)===!1?[e,D(t)]:(e.length<2&&e.push(D(t)),e)},getPropValues(s,t,e){let r=[];for(var i=0,n=t.length;i<n;i++){var o=e?s[i]:s,a=o.get(t[i]);a=typeof a<"u"?a:"",r.push(a)}return r},getCallBack(s,t,e,r,i){let n=s.attr||"textContent",o=s.callBack;if(typeof o=="function"){let a=r.match(qt)||[],c=a&&a.length>1;return(u,p)=>{u=c!==!0?u:this.getPropValues(e,a,i);let y=o(u,t,p);typeof y<"u"&&this.updateAttr(t,n,y)}}return this._getWatcherCallBack(t,e,r,n,i)},addDataWatcher(s,t,e){let r=this.getValue(t,e),i=r[1]??e?.data??e?.context?.data??e?.state??null;if(!i)return;let n=r[0],o=Array.isArray(i),a=this.getCallBack(t,s,i,n,o),c=this._getWatcherProps(n);for(var u=0,p=c.length;u<p;u++){var y=o?i[u]:i;this.addWatcher(s,y,c[u],a)}},getWatcherSettings(s,t=null){if(typeof s=="string")return{attr:t,value:s};if(Array.isArray(s)){let e=s[s.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let r=s[1]&&typeof s[1]=="object"?[s[0],s[1]]:[s[0]];return typeof e=="function"?{attr:t,value:r,callBack:e}:{attr:e||"textContent",value:r}}return s},setup(s,t,e){t&&this.addDataWatcher(s,this.getWatcherSettings(t),e)},addWatcher(s,t,e,r){x.watch(s,t,e,r)}};var cr=s=>({props:{watch:s},children:[]}),ur=s=>{if(!s)return pt();let t=s[0],e=typeof t;if(e==="string"||e==="number")return dt(t);if(Array.isArray(t))return C.isWatching(t)===!1?mt(t):cr(t);let r=s[1]??s[0]??[];return r&&Array.isArray(r)&&C.isWatching(r)===!0&&(s[0]=Array.isArray(s[0])?{}:s[0],s[0].watch=r,s[1]=[]),gt(s)},hr=s=>(...t)=>{let{props:e,children:r}=ur(t);return s(e,r)};function ae(s,t){let e=isNaN(Number(t)),r=e?t:`[${t}]`;return s===""?r:e?`${s}.${r}`:`${s}${r}`}function ce(s,t="",e=""){return{get(r,i,n){let o=r[i];if(t===""&&i in r)return typeof o=="function"?o.bind(r):o;let a=r[e]||r;if(o=Reflect.get(a,i,n),g.isPlainObject(o)||Array.isArray(o)){let c=ae(t,i);return new Proxy(o,ce(s,c,e))}return o},set(r,i,n,o){if(t===""&&i in r)return r[i]=n,!0;let a=ae(t,i);return s.set(a,n),!0}}}var Ct=(s,t="stage")=>new Proxy(s,ce(s,"",t));var it=class{static resume(t,e){if(!t)return null;let r,i=localStorage.getItem(t);return i===null?e&&(r=e):r=JSON.parse(i),r}static store(t,e){if(!t||!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var At=(s={})=>{let t={};if(!h.isObject(s))return t;let e=g.clone(s);return Object.keys(e).forEach(r=>{let i=e[r];typeof i!="function"&&(t[r]=i)}),t};var lr=0,L={CHANGE:"change",DELETE:"delete"},zt=(s,t)=>`${s}:${t}`,M=class{constructor(t={}){this.dirty=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new F;let e=At(t);return this.set(e),Ct(this)}setup(){this.stage={}}_init(){let t=++lr;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}getDataId(){return this._id}remove(){}on(t,e){let r=zt(t,L.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=zt(t,L.CHANGE);this.eventSub.off(r,e)}_setAttr(t,e,r=this,i=!1){let n=this.stage[t];e!==n&&(this.stage[t]=e,this._publish(t,e,r,L.CHANGE))}publishLocalEvent(t,e,r,i){let n=zt(t,i);this.eventSub.publish(n,e,r)}_publish(t,e,r,i){this.publishLocalEvent(t,e,r,i),r=r||this,x.publish(this._dataId+t,e,r)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,i]=t;return Object.entries(e).forEach(([n,o])=>{typeof o!="function"&&this._setAttr(n,o,r,i)}),this}getModelData(){return this.stage}_deleteAttr(t,e,r=this){delete t[e],this.publishLocalEvent(e,null,r,L.DELETE)}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r+e),this}decrement(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r-e),this}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=it.resume(this.key,t);return e?(this.set(e),this):this}store(){let t=this.get();return it.store(this.key,t)}delete(t){return typeof t=="string"?(this._deleteAttr(this.stage,t),this):(this.setup(),this)}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let i=[];return Object.entries(e).forEach(([n])=>{i.push(this.remoteLink(t,n))}),i}remoteLink(t,e,r){let i=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let o=t.on(e,(c,u)=>{if(u===this)return!1;this.set(i,c,t)});this.addLink(o,t);let a=this.on(i,(c,u)=>{if(u===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links.set(t,e)}unlink(t){if(t){this.removeLink(t);return}let e=this.links;g.isEmpty(e)||(e.forEach((r,i)=>{this.removeLink(i,!1)}),this.links=new Map)}removeLink(t,e=!0){let r=this.links.get(t);r&&r.off(t),e!==!1&&this.links.delete(t)}};M.prototype.isData=!0;var E={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.deepDataPattern;return s.match(t)}};var I=class{static set(t,e,r){if(!E.hasDeepData(e)){t[e]=r;return}let i,n=E.getSegments(e),o=n.length,a=o-1;for(var c=0;c<o;c++){if(i=n[c],c===a){t[i]=r;break}t[i]===void 0&&(t[i]=isNaN(i)?{}:[]),t=t[i]}}static delete(t,e){if(!E.hasDeepData(e)){delete t[e];return}let r=E.getSegments(e),i=r.length,n=i-1;for(var o=0;o<i;o++){var a=r[o],c=t[a];if(c===void 0)break;if(o===n){if(Array.isArray(t)){t.splice(Number(a),1);break}delete t[a];break}t=c}}static get(t,e){if(!E.hasDeepData(e))return t[e]??void 0;let r=E.getSegments(e),i=r.length,n=i-1;for(var o=0;o<i;o++){var a=r[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===n)return t}}};var nt=class{static publishDeep(t,e,r,i){if(!E.hasDeepData(e)){this.publish(e,r,i);return}let n,o=E.getSegments(e),a=o.length,c=a-1,u="";for(var p=0;p<a;p++){n=o[p],t=t[n],p>0?isNaN(n)&&(u+="."+n):u=n;var y;if(p===c)y=r;else{var b=o[p+1];if(isNaN(b)===!1){u+="["+b+"]";continue}var k={};k[b]=t[b],y=k}this.publish(u,y,i)}}static publish(t,e,r){if(t=t||"",r(t,e),!(!e||typeof e!="object")){if(Array.isArray(e)){this.publishArray(t,e,r);return}this.publishObject(t,e,r)}}static publishArray(t,e,r){let i,n,o=e.length;for(var a=0;a<o;a++)n=e[a],i=t+"["+a+"]",this._checkPublish(i,n,r)}static publishObject(t,e,r){let i,n;for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(n=e[o],i=t+"."+o,this._checkPublish(i,n,r))}static _checkPublish(t,e,r){if(!e||typeof e!="object"){r(t,e);return}this.publish(t,e,r)}};var B=class extends M{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,i){typeof e!="object"&&e===this.get(t)||(!r&&i!==!0?I.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),I.set(this.stage,t,e),r=r||this,this._publish(t,e,r,L.CHANGE))}linkAttr(t,e){let r=t.get(e);if(r)for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&this.link(t,e+"."+i,i)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let i=new e(r);return i.linkAttr(this,t),i}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}concat(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r=r.concat(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}getIndex(t,e,r){let i=this.get(t);return Array.isArray(i)===!1?-1:typeof i[0]!="object"?i.indexOf(e):i.findIndex(o=>o[e]===r)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r,i){let n=(o,a)=>this._publishAttr(o,a,r,i);nt.publish(t,e,n)}_publishAttr(t,e,r,i){let n=this._dataId+t;x.publish(n,e,r),this.publishLocalEvent(t,e,r,i)}mergeStage(){this.attributes=g.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,r=this){I.delete(t,e);let i=(n,o)=>this.publishLocalEvent(n,o,r,L.DELETE);nt.publish(e,e,i)}_getAttr(t,e){return I.get(t,e)}};var fr={"\n":"\\n","\r":"\\n"," ":"\\t"},pr=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>fr[r])},ue=(s,t)=>{if(typeof s!="string")return s;s=pr(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},Yt=(s,t)=>{let e=typeof s;return e==="undefined"?s:e!=="object"?(s=ue(s),s):(Object.entries(s).forEach(([r,i])=>{i!==null&&(s[r]=typeof i=="string"?Yt(i,t):ue(i,t))}),s)};function he(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function Gt(s){return typeof s<"u"?JSON.stringify(s):null}var ot=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?g.clone(t):t,i=Yt(r,e);return Gt(i)}static json={encode:Gt,decode:he};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Tt=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=v.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=v.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),i="id="+r,n=this.model;return this._get(`/${r}`,i,t,e,o=>{if(o){let a=this.getObject(o);a&&n.set(a)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ot.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=typeof i>"u"?"":`/${i}`;return this._put(n,r,t,e)}add(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=typeof i>"u"?"":`/${i}`;return this._post(n,r,t,e)}update(t,e){if(!this.isValid())return;let r=this.setupObjectData(),i=this.model.id,n=typeof i>"u"?"":`/${i}`;return this._patch(n,r,t,e)}delete(t,e){let r=this.model.get("id"),i=typeof r<"u"?"id="+r:this.setupObjectData(),n=typeof r>"u"?"":`/${r}`;return this._delete(n,i,t,e)}all(t,e,r,i,n=null,o=null){let a=this.model.get();r=isNaN(r)?0:r,i=isNaN(i)?50:i;let c=a.search||"",u=a.filter||"";typeof u=="object"&&(u=JSON.stringify(u));let p=a.dates||"";typeof p=="object"&&(p=JSON.stringify(p));let y=a.orderBy||"";typeof y=="object"&&(y=JSON.stringify(y));let b=a.groupBy||"";Array.isArray(b)&&(b=JSON.stringify(b));let k="&filter="+u+"&offset="+r+"&limit="+i+"&dates="+p+"&orderBy="+y+"&groupBy="+b+"&search="+c+"&lastCursor="+(typeof n<"u"&&n!==null?n:"")+"&since="+(typeof o<"u"&&o!==null?o:"");return this._get("",k,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let r=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(r)}setupRequest(t,e,r,i,n){let o={url:this.getUrl(t),method:e,params:r,completed:(c,u)=>{typeof n=="function"&&n(c),this.getResponse(c,i,u)}};return this._isFormData(r)&&(o.headers={}),ft(o)}setupEventSource(t,e,r,i,n=!0){let o=null,a=null,c=!1,u=()=>{if(c)return;let p=this.getUrl(t),y=e?"?"+e:"";o=new EventSource(p+y,{withCredentials:!0}),o.onopen=()=>{i&&i()},o.onerror=b=>{o.close(),!c&&n&&(a=setTimeout(()=>{u()},3e3))},o.onmessage=b=>{try{let k=JSON.parse(b.data);r&&r(k)}catch{}}};return u(),{get source(){return o},close:()=>{c=!0,a&&n&&clearTimeout(a),o&&o.close()}}}replaceUrl(t){return C.isWatching(t)&&(t=C.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,r,i){return this._request("","POST",t,e,r,i)}_get(t,e,r,i,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",i,n)}_post(t,e,r,i,n){return this._request(t,"POST",e,r,i,n)}_put(t,e,r,i,n){return this._request(t,"PUT",e,r,i,n)}_patch(t,e,r,i,n){return this._request(t,"PATCH",e,r,i,n)}_delete(t,e,r,i,n){return this._request(t,"DELETE",e,r,i,n)}_request(t,e,r,i,n,o){return r=this.setupParams(r),r=this.addParams(r,i),this.setupRequest(t,e,r,n,o)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var dr=s=>{let t={};if(!h.isObject(s)||!s.defaults)return t;let{defaults:e}=s;return Object.keys(e).forEach(r=>{let i=e[r];typeof i!="function"&&(t[r]=i)}),delete s.defaults,t},mr=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},gr=0,V=class extends B{constructor(t){let e=super(t);return this.initialize(),e}setup(){this.attributes={},this.stage={},this.url=this.url||"",this.xhr=this.xhr||{}}initialize(){}static extend(t={}){let e=this,r=mr(t),i=e.prototype.service.extend(r),n=dr(t);class o extends e{constructor(c){let u={...n,...At(c)};super(u),this.xhr=new i(this)}dataTypeId=`bm${gr++}`}return Object.assign(o.prototype,t),o.prototype.service=i,o}};V.prototype.service=Tt;var R=class extends M{};var J=class extends R{setup(){this.stage={}}addAction(t,e){return typeof e<"u"&&this.set(t,e),this}getState(t){return this.get(t)}removeAction(t,e){if(e)return this.off(t,e),this;let r=this.stage;return typeof r[t]<"u"&&delete r[t],this}};var Dt=class extends J{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=null}};var O=class{static targets=new Map;static restore(t,e){this.targets.set(t,e)}static getTarget(t){return this.targets.has(t)||this.targets.set(t,new Dt(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let i=this.getTarget(t);return e&&i.addAction(e,r),i}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){this.off(t,e,r)}static on(t,e,r){let i=this.getTarget(t);return e?i.on(e,r):null}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let i=this.targets,n=i.get(t);if(n){if(e){n.off(e,r);return}this.targets.delete(t)}}static set(t,e,r){this.getTarget(t).set(e,r)}};var Et=class{constructor(){this.events=[]}addEvents(t){t.length<1||t.forEach(r=>{this.on(...r)})}on(t,e,r,i){l.on(t,e,r,i),this.events.push({event:t,obj:e,callBack:r,capture:i})}off(t,e,r,i){l.off(t,e,r,i);let n,o=this.events;for(var a=0,c=o.length;a<c;a++)if(n=o[a],n.event===t&&n.obj===e){o.splice(a,1);break}}set(){this.events.forEach(t=>{l.on(t.event,t.obj,t.callBack,t.capture)})}unset(){this.events.forEach(t=>{l.off(t.event,t.obj,t.callBack,t.capture)})}reset(){this.unset(),this.events=[]}};var Ot=class{constructor(t,e){this.remoteStates=[];let r=this.convertStates(e);this.addStatesToTarget(t,r)}addStates(t,e){let r=this.convertStates(e);this.addStatesToTarget(t,r)}createState(t,e,r,i){return{action:t,state:e,callBack:r,targetId:i,token:null}}convertStates(t){let e=[];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var i=null,n=null,o=t[r];o&&typeof o=="object"&&(n=o.callBack,i=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,n,i))}return e}setupRemoteStates(t,e){let r;for(var i=0,n=t.length;i<n;i++)if(r=t[i],!!r){for(var o in r)if(!(!Object.prototype.hasOwnProperty.call(r,o)||o==="id")){var a=null,c=r[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,r.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(var r=0,i=e.length;r<i;r++){var n=e[r];n.token&&this.unbindRemoteState(t,n.token),O.remove(n.targetId,n.action,n.token)}}restore(t){O.restore(t.id,t);let e=this.remoteStates;if(e)for(var r=0,i=e.length;r<i;r++){var n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let i=O.getTarget(r);return t.link(i,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var i=0,n=e.length;i<n;i++){var o=e[i],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}r.length<1&&(this.remoteStates=[])}addAction(t,e){let r,i=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,i,n)),typeof e.state<"u"&&t.addAction(i,e.state);let o=e.callBack;return typeof o=="function"&&t.on(i,o),r}};var le=s=>{if(!s)return pt();let t=s[0],e=typeof t;return e==="string"||e==="number"?dt(t):Array.isArray(t)?mt(t):gt(s)};f.addType("components",s=>{if(!s)return;let t=s.component;!t||!t.isUnit||(t.rendered===!0&&t.prepareDestroy(),t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken))});var yr=0,at=class{constructor(...t){this.isUnit=!0,this.data=null,this.persist=null,this.nest=null,this.state=null,this.panel=null,this.parent=null,this.unitType=null,this.init();let{props:e,children:r}=le(t);this.setupProps(e),this.children=r||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+yr++,this.unitType=this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=this.persistedCount++,r="pc"+e,n=Object.keys(this.persistedChildren)[e],o=this.persistedChildren[n];return o&&t.unitType===o.unitType&&(r=n,t.resumeScope(o)),t.persistToken=r,this.persistedChildren[r]=t,r}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];r&&(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context??={},this.context[t]=e}setContext(t){return null}addContext(t){return null}removeContext(){this.addingContext&&this.removeContextBranch(this.contextBranchName)}removeContextBranch(t){t&&delete this.context[t]}getContext(){return this.context}onCreated(){}render(){return{}}_cacheRoot(t){return t&&(t.id||(t.id=this.getId()),t.cache="panel",t)}_createLayout(){return this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){f.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var i=0,n=t.length;i<n;i++){let o=e(t[i],i);r.push(o)}return r}removeAll(t){return A.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.setContainer(t),this.initialize()}setContainer(t){this.container=t}_remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;A.removeElement(t),this.panel=null,this.parent=null,this.container=null,this.children=null,this.persistedChildren=null}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&(typeof this.data.unlink=="function"&&this.data.unlink(),this.data=null)}beforeDestroy(){}destroy(){this._remove()}};var S=class extends at{constructor(...t){super(...t),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this.data=t.data,this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,this.id=t.id}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=O.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();g.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new Ot(this.state,t))}addState(t){!this.stateHelper||this.stateResumed==!0||this.stateHelper.addStates(this.state,t)}removeStates(){let t=this.state;if(!t)return;this.stateHelper.removeRemoteStates(t);let e=this.stateTargetId||this.id;e===this.id&&O.remove(e),this.stateResumed=!1}setEventHelper(){this.events||(this.events=new Et)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events.addEvents(t))}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&(typeof this.data.unlink=="function"&&this.data.unlink(),this.data=null)}};var Pt={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var br=s=>typeof s=="function"?s:()=>s,xr=s=>{let t={};return s&&Object.entries(s).forEach(([e,r])=>{let i=Pt[e]||e;t[i]=br(r)}),t},fe=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e},_=(s,t=S)=>{if(!s)return null;let e,r=typeof s;return r==="object"&&s.render?(e=xr(s),fe(t,e)):(e={render:r==="function"?s:()=>s},fe(t,e))};var vr=(s,t)=>(Object.entries(s).forEach(([e,r])=>{let i=Pt[e]||e;t.prototype[i]=r}),t),Sr=s=>class extends s{},kr=(s,t=S)=>{if(!s)return null;let e=Sr(t),r={},i=s(r);return vr(r,e),e.prototype.render=i,e};var wr={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(s=new Date().getDay(),t=!1){let e=this.dayNames;if(s>e.length)return null;let r=e[s];return t?r.substring(0,3):r},convertJsMonth(s){return this.padNumber(s+1)},convertDate(s,t=!1){s=s?s.replace(/\s/,"T"):"";let e=new Date(s),r=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+r},padNumber(s){return s<=9?"0"+s:String(s)},createDate(s){return s?(typeof s=="string"&&s.indexOf("-")>-1&&(s=s.replace(/\s/,"T"),s=s.indexOf(":")>-1?s:s+"T00:00:00"),new Date(s)):new Date},format(s,t){let e=this.createDate(t);return this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),s)},formatTime(s,t){let e=this.createDate(s),r=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),r)},getMeridian(s){return s=Number(s),s>=12?"PM":"AM"},convert24To12(s){return s=Number(s),s>12&&(s=s-12),s},convert12To24(s,t){return s=Number(s),t.toLowerCase()==="pm"&&(s=s+12),s},renderDate(s,t,e,r="sql"){return t=Number(t),e=Number(e),r==="sql"?`${s}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${s}`},renderTime(s,t,e=0,r="sql"){if(r==="sql")return`${this.padNumber(s)}:${this.padNumber(t)}:${this.padNumber(e)}`;let i=this.getMeridian(s);return s=this.convert24To12(s),`${s}:${this.padNumber(t)} ${i}`},leapYear(s){return s%400===0||s%100!==0&&s%4===0},getMonthName(s=new Date().getMonth(),t=!1){let e=this.monthNames;if(s>e.length)return"";let r=e[s];return r?t?r.substring(0,3):r:""},getMonthLength(s,t){let e=new Date;return s=typeof s<"u"?s:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[s]},getMonthsLength(s=new Date().getFullYear()){return this.leapYear(s)===!0?[31,29,31,30,31,30,31,31,30,31,30,31]:[31,28,31,30,31,30,31,31,30,31,30,31]},getLocalDate(s,t="America/Denver"){let e=new Date(s);if(Number.isNaN(e.getMonth())===!0){let n=/[- :]/,o=s.split(n);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let r=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),i=e.getTime()-r.getTime();return new Date(e.getTime()+i)},getLocalTime(s,t=!1,e=!1,r="America/Denver"){if(!s)return"";let i=this.getLocalDate(s,r),n=i.getMonth()+1,o=t===!0?"sql":"standard",a="";return e===!1&&(a+=this.renderDate(i.getFullYear(),n,i.getDate(),o)+" "),a+this.renderTime(i.getHours(),i.getMinutes(),i.getSeconds(),o)},getDiffFromNow(s,t=!1){s=s.replace(/\s/,"T");let e=new Date(s),r=new Date;return t===!0&&r.setHours(0,0,0,0),r.getTime()-e.getTime()},getAge(s){let t=this.getDiffFromNow(s),e,r;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:r=this.toDays(t),e=r+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:r=this.toDays(t);var i=Math.floor(r/7);e=i+" weeks";break;case t<5184e6:e="1 month";break;case t<31104e6:var n=this.toMonths(t);e=n+" months";break;default:var o=this.toYears(t);e=o}return String(e)},getTimeFrame(s){let t=this.getDiffFromNow(s);return this.convertToEstimate(t)},convertToEstimate(s){let t="",e,r,i,n,o,a,c;if(s<=0)switch(!0){case s<-63072e6:i=this.toYears(Math.abs(s)),t="in "+i+" years";break;case s<-31536e6:t="in a year";break;case s<-5184e6:n=this.toMonths(Math.abs(s)),t="in "+n+" months";break;case s<-2592e6:t="in a month";break;case s<-12096e5:e=this.toDays(Math.abs(s)),r=Math.floor(e/7),t="in "+r+" weeks";break;case s<-6048e5:t="in a week";break;case s<-1728e5:e=this.toDays(Math.abs(s)),t="in "+e+" days";break;case s<-864e5:t="tomorrow";break;case s<-72e5:o=this.toHours(Math.abs(s)),t="in "+o+" hours";break;case s<=-36e5:t="in an hour";break;case s<-12e4:a=this.toMinutes(Math.abs(s)),t="in "+a+" minutes";break;case s<-6e4:t="in a minute";break;case s<-2e3:c=this.toSeconds(Math.abs(s)),t="in "+c+" seconds";break;case s<-1:t="in 1 second";break;default:t="now"}else switch(!0){case s<1e3:t="1 second ago";break;case s<6e4:c=this.toSeconds(s),t=c+" seconds ago";break;case s<12e4:t="1 minute ago";break;case s<36e5:a=this.toMinutes(s),t=a+" minutes ago";break;case s<72e5:t="1 hour ago";break;case s<864e5:o=this.toHours(s),t=o+" hours ago";break;case s<1728e5:t="yesterday";break;case s<6048e5:e=this.toDays(s),t=e+" days ago";break;case s<12096e5:t="a week ago";break;case s<2592e6:e=this.toDays(s),r=Math.floor(e/7),t=r+" weeks ago";break;case s<5184e6:t="a month ago";break;case s<31536e6:n=this.toMonths(s),t=n+" months ago";break;case s<63072e6:t="a year ago";break;default:i=this.toYears(s),t=i+" years ago"}return t},toYears(s){return typeof s!="number"?0:Math.floor(s/31558464e3)},toMonths(s){return typeof s=="number"?Math.floor(s/2592e6):0},toDays(s){return typeof s!="number"?0:Math.floor(s/864e5*1)},toHours(s){return typeof s!="number"?0:Math.floor(s%864e5/36e5*1)},toMinutes(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5/6e4*1)},toSeconds(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5%6e4/1e3*1)},getDifference(s,t){let e=new Date(s),r=new Date(t),i=r.getTime()-e.getTime();return{years:this.toYears(i),days:this.toDays(i),hours:this.toHours(i),minutes:this.toMinutes(i),seconds:this.toSeconds(i)}}};var pe=(s,t)=>({name:s,callBack:t});var q={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=pe(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var Xt=(s,t)=>({attr:s,directive:t});var z=(s,t)=>({key:s,value:t});var de=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var H=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,r,i){return t==="text"?(i.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(z("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){t.push(Xt(z(e,C.getWatcherSettings(r,rt(e))),q.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let i=e.type||"button";r.push(z("type",i))}}static parse(t,e){let r=[],i=[],n=this.getTag(t);this.setButtonType(n,t,r),this.setupChildren(t);let o=[];var a,c;for(var u in t){if(!g.hasOwnProp(t,u)||u==="tag"||(a=t[u],a==null))continue;if(u==="children"){o=Array.isArray(a)?o.concat(a):o.concat([a]);continue}if((c=q.get(u))!==null){i.push(Xt(z(u,a),c));continue}let p=typeof a;if(p==="object"){if(C.isWatching(a)){this.setTextAsWatcher(i,u,a);continue}o.push(a);continue}if(p==="function"){let y=a,b=function(k){y.call(this,k,e)};b.originalCallback=y,a=b}if(C.isWatching(a)){this.setTextAsWatcher(i,u,a);continue}this.setElementContent(u,a,r,o)||r.push(z(u,a))}return de(n,r,i,o)}};var Y=class{build(t,e,r){}setupComponent(t,e,r){t.parent=r,r&&r.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&r&&(r[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),r=this.build(e,t.container,t.getChildScope());return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),r}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t),t}setDirectives(t,e,r){}removeNode(t){}removeAll(t){}};var Mt=class extends Y{build(t,e,r){let i=w.createDocFragment();return(Array.isArray(t)?t:[t]).forEach(o=>this.buildElement(o,i,r)),e&&typeof e=="object"&&e.appendChild(i),i}buildElement(t,e,r){if(t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}createElement(t,e,r){if(t.data||t.state){this.createTempComponent(t,e,r);return}let i=H.parse(t,r),n=this.createNode(i,e,r);this.cache(n,t.cache,r),i.children.forEach(a=>{a!==null&&this.buildElement(a,n,r)});let o=i.directives;o&&o.length&&this.setDirectives(n,o,r)}createTempComponent(t,e,r){let i={setData:()=>t.data,render(){return{...t,data:null,state:null}}};t.state&&(i.setupStateTarget=function(o){this.state=t.state});let n=new S(i);this.createComponent(n,e,r)}setDirectives(t,e,r){e.forEach(i=>{this.handleDirective(t,i,r)})}handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}cache(t,e,r){r&&e&&(r[e]=t)}createNode(t,e,r){let i=t.tag;if(i==="text"){let n=t.attr[0],o=n?n.value:"";return w.createText(o,e)}else if(i==="comment"){let n=t.attr[0],o=n?n.value:"";return w.createComment(o,e)}return w.create(i,t.attr,e,r)}removeNode(t){w.removeElement(t)}removeAll(t){w.removeAll(t)}};var Cr=["area","base","br","col","embed","hr","img","input","link","meta","source"],G=class{static create(t,e=[],r=""){let i=this.getInnerContent(e);i+=this.getInnerHtml(e);let n=this.createAttributes(e);return Cr.includes(t)?`<${t} ${n} />`:`<${t} ${n}>`+i+r+`</${t}>`}static getInnerContent(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="text"&&r!=="textContent")return"";t.splice(n,1),e+=i}),e}static getInnerHtml(t){let e="";return t.forEach(({key:r,value:i},n)=>{if(r!=="html"&&r!=="innerHTML")return"";t.splice(n,1),e+=i}),e}static createAttributes(t=[]){return!t||t.length<1?"":t.map(e=>{let{key:r,value:i}=e;return typeof i=="function"&&(r="on"+st(r)),`${r}="${i}"`}).join(" ")}static createText(t){return t}static createComment(t){return`<!-- ${t} -->`}};var Bt=class extends Y{build(t,e,r){return(Array.isArray(t)?t:[t]).map(n=>this.buildElement(n,r)).join("")}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,e):this.createElement(t,e):""}createElement(t,e){let r=H.parse(t,e),i=r.children.map(n=>n!==null?this.buildElement(n,e):"").join("");return this.createNode(r,i)}createNode(t,e){let r=t.tag;if(r==="text"){let i=t.attr[0],n=i?i.value:"";return G.createText(n)}else if(r==="comment"){let i=t.attr[0],n=i?i.value:"";return G.createComment(n)}return G.create(r,t.attr,e)}removeAll(t){}};var Nt=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new Mt:new Bt}};var U=Nt.setup(),Ar=s=>typeof s=="object"&&s.isUnit===!0,Tr=s=>{let t=_(s);return new t},m=class{static render(t,e,r){return t?(Ar(t)||(t=Tr(t)),U.createComponent(t,e,r)):null}static build(t,e,r){return U.build(t,e,r)}static rebuild(t,e,r){return U.removeAll(e),this.build(t,e,r)}static setDirectives(t,e,r){U.setDirectives(t,e,r)}static createNode(t,e,r){return U.createNode(t,e,r)}static removeNode(t){U.removeNode(t)}static removeAll(t){U.removeAll(t)}};T.augment({buildLayout(s,t,e){m.build(s,t,e)}});var Kt=[],Dr=s=>Kt.indexOf(s)!==-1,Er=s=>({tag:"script",src:s.src,async:!1,load(t){Kt.push(s.src);let e=s.load;e&&e()}}),Or=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){Kt.push(s.src);let e=s.load;e&&e()}}),Ht=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=Or({load:r,src:t}):e=Er({load:r,src:t}),m.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{Dr(e)||this.add(e)})}update(){if(this.updateProgress()<100)return;let e=this.callBack;e&&e()}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}};var Pr=s=>s?typeof s?.prototype?.constructor=="function":!1,X=class{static process(t,e){let r=t.default;return r?e.callback?e.callback(r):(Pr(r)?r=new r:r=r(),r.isUnit===!0&&(r.route=e.route,e.persist&&(r.persist=!0)),r):null}static render(t,e,r){let i=m.build(t,null,r),n=i.firstChild||t?.panel;return e.after(i),n}};var Lt=class{static load(t,e){return t.then(r=>(e&&e(r),r)).catch(r=>{console.error("Error loading module:",r)})}};var Mr=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),Br=s=>{let t=typeof s;return t==="string"?import(s):t==="function"?s():s},me=_({declareProps(){this.loaded=!1,this.loadId=0},render(){return Mr({onCreated:s=>{if(this.src){if(this.layout){this.layoutRoot=X.render(this.layout,this.panel,this.parent);return}if(this.depends){new Ht(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},loadAndRender(s){let t=++this.loadId;this.src=Br(this.src),Lt.load(this.src,e=>{if(this.loadId!==t)return;this.loaded=!0;let r=this.layout||X.process(e,{callback:this.callback,route:this.route,persist:this.persist});this.layout=r,this.layoutRoot=X.render(r,s,this.parent)})},shouldUpdate(s){return this.updateLayout===!0?!0:this.updateLayout=s&&s.isUnit&&typeof s.update=="function"},updateModuleLayout(s){let t=this.layout;this.shouldUpdate(t)&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},destroy(){this.loadId++;let s=this.layout;s&&(typeof s.destroy=="function"?s.destroy():this.layoutRoot&&m.removeNode(this.layoutRoot),this.layout=null),this.panel&&(m.removeNode(this.panel),this.panel=null),this.layoutRoot=null,this.loaded=!1}});var ct=s=>{let t=typeof s;return(t==="string"||t==="function"||s instanceof Promise)&&(s={src:s}),new me(s)};var ge=(s,t,e=null)=>{l.on("animationend",s,function r(){d.removeClass(s,t),l.off("animationend",s,r),e&&e()}),d.addClass(s,t)},ye=(s,t,e)=>{ge(s,t)},be=(s,t,e)=>{let r=()=>s&&s.remove();Nr(s,()=>ge(s,t,r),e)};f.addType("manual-destroy",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var Nr=(s,t,e)=>{f.add(s,"manual-destroy",{ele:s,callBack:t,parent:e})};var ut=(s,t,e,r)=>{if(Array.isArray(e[0])){e.forEach(i=>{i&&ut(s,t,i,r)});return}Hr(s,t,e,r)},Hr=(s,t,e,r)=>{let i,n;if(e.length<3?[i,n]=e:[t,i,n]=e,!t||!i)return;let o=Lr(s,i,n,r);x.watch(s,t,i,o)},Lr=(s,t,e,r)=>typeof e=="object"?i=>{_r(s,e,i)}:i=>{Ir(s,e,t,i,r)},Ir=(s,t,e,r,i)=>{let n=t(r,s,i);switch(typeof n){case"object":Rr(n,s,i);break;case"string":let o=St(s);if(o!=="textContent"){d.setAttr(s,o,n);break}A.addHtml(s,n);break}},Rr=(s,t,e)=>{m.rebuild(s,t,e)},_r=(s,t,e)=>{for(let[r,i]of Object.entries(t))r&&(i===e?d.addClass(s,r):d.removeClass(s,r))};var K=(s,t,e)=>{let r=D(e);ut(s,r,t,e)};var xe=(s,t,e)=>{t&&t&&d.setAttr(s,"role",t)},Ur=s=>(t,e)=>{let r=t?"true":"false";d.setAttr(e,s,r)},ve=(s,t,e)=>{if(!t)return;let r=t.role;r&&(d.setAttr(s,"role",r),t.role=null),Object.entries(t).forEach(([i,n])=>{if(n===null)return;let o=`aria-${i}`;if(Array.isArray(n)){let a=[...n];a.push(Ur(o)),K(s,a,e)}else d.setAttr(s,o,n)})};var Se=(s,t,e)=>{if(!t)return;let r=H.parse(t,e);w.addAttributes(s,r.attr,e),m.setDirectives(s,r.directives,e)};f.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var Qt=s=>s?s.getContext():null,ke=(s,t,e)=>{if(typeof t!="function")return;let r=Qt(e),i=t(r);Se(s,i,e)},we=(s,t,e)=>{if(typeof t!="function")return;let r=Qt(e);t(r)},Ce=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=Qt(e),i=t(r);i&&e.addContextBranch(i[0],i[1])};var Ae=(s,t,e)=>{};var Te=(s,t,e)=>{if(!e)return;let r=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",s),console.log("Data: ",t),console.log("Layout: ",r),console.log("parent: ",e)};var De=(s,t,e)=>{},Ee=(s,t,e)=>{if(!t||!e)return;let r=t(e,s);r&&m.build(r,s,e)},Oe=(s,t,e)=>{if(!t||!e)return;let r=e.getId(t);s.id=r},Pe=(s,t,e)=>{if(!t||!e)return;let r=t(e.data,s);r&&m.build(r,s,e)},Me=(s,t,e)=>{if(!t||!e)return;let r=t(e.state,s);r&&m.build(r,s,e)},Be=(s,t,e)=>{if(!t||!e)return;let r=e.state,i=t(r);if(!e.state){e.setStateHelper(i);return}e.addState(i)},Ne=(s,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let r=t[2];t[2]=i=>{r(i,e)}}e.events.on(...t)}};var He=(s,t,e)=>{let r,i,n;if(typeof t=="string"){if(r=D(e),!r)return;i=t}else if(Array.isArray(t)){if(typeof t[0]!="object"){let o=D(e);if(!o)return;t.unshift(o)}[r,i,n]=t}x.bind(s,r,i,n)};var It=(s,t,e)=>{ut(s,e.state,t,e)};var Le=s=>(t,e)=>{let[r,i,n="active"]=s,o=t===i?n:"";d.setData(e,r,o)},Ie=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Le(i)),K(s,r,e)},Re=(s,t,e)=>{if(!t)return;let r=[...t],i=r.pop();r.push(Le(i)),It(s,r,e)};var _e=(s,t,e)=>{let r,i,n,o;if(t.length<3){let c=D(e);if(!c)return;r=c,[i,n,o]=t}else[r,i,n,o]=t;let a=o!==!1;x.watch(s,r,i,c=>{if(m.removeAll(s),!c||c.length<1)return;let u=[];return c.forEach((p,y)=>{let b=a?r.scope(`${i}[${y}]`):null,k=n(c[y],y,b,u);k!==null&&u.push(k)}),m.build(u,s,e)})};var Ue=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let i=t[1],n=[];r.forEach((o,a)=>{if(!o)return;let c=i(o,a);c!==null&&n.push(c)}),m.build(n,s,e)};var je=(s,t,e)=>{t(s,e)};f.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var We=(s,t,e)=>{jr(s,t,e)},jr=(s,t,e)=>{f.add(s,"destroyed",{ele:s,callBack:t,parent:e})};var $e=(s,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(var r=0,i=t.length;r<i;r++)C.setup(s,t[r],e);else C.setup(s,t,e)};var Wr=0,Q=class{constructor(t){this.router=t,this.locationId="base-app-router-"+Wr++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}check(t){}getScrollPosition(){return{x:window.scrollX,y:window.scrollY}}scrollTo(t){window.scrollTo(t.x,t.y)}addEvent(){return this}};var Rt=class extends Q{addEvent(){return l.on("popstate",window,this.callBack),this}removeEvent(){return l.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let r=e.scrollPosition;r&&this.scrollTo(r)}createState(t,e={}){let r=this.getScrollPosition();return{location:this.locationId,...e,scrollPosition:r,uri:t}}addState(t,e,r=!1){let i=window.history,n=i.state;if(n&&n.uri===t)return this;let o=this.createState(t,e);return i[r===!1?"pushState":"replaceState"](o,null,t),this}};var _t=class extends Q{addEvent(){return l.on("hashchange",window,this.callBack),this}removeEvent(){return l.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};var Ut=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new Rt(t).setup():new _t(t).setup()}};var Zt=class extends S{getChildScope(){return this.parent}},Fe=s=>_(s,Zt);var jt=class{constructor(t,e){this.route=t,this.template=e.component,this.importSrc=e.importSrc||null,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent}focus(t){this.setup===!1&&(this.importSrc&&(!this.template||this.template.panel===null)&&(this.template=ct(this.importSrc),this.hasTemplate=!1),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){let t=this.template();this.transferSettings(t)}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){if(!this.template)return;this.template.isUnit||(this.template=new(Fe(this.template)));let t=this.template;this.transferSettings(t)}create(){if(this.setupTemplate(),!this.hasTemplate)return;this.setup=!0;let t=this.component;m.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return;this.setup=!1;let t=this.component;t&&(typeof t.destroy=="function"&&t.destroy(),this.component=null)}update(t){let e=this.component;e&&typeof e.update=="function"&&e.update(t)}};var Ve=s=>{if(!s.length)return null;let t={};return s.forEach(e=>{t[e]=null}),t},Je=s=>{let t=[];if(!s)return t;let e=/[*?]/g;s=s.replace(e,"");let r=/:(.[^./?&($]+)\?*/g,i=s.match(r);return i===null||i.forEach(n=>{n&&(n=n.replace(":",""),t.push(n))}),t};var $r=s=>s.replace(/\//g,"/"),Fr=s=>s.replace(/(\/):[^/(]*?\?/g,t=>t.replace(/\//g,"(?:$|/)")),Vr=s=>(s=s.replace(/(\?\/+\*?)/g,"?/*"),s.replace(/(:[^/?&($]+)/g,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),Jr=s=>s.replace(/(\*)/g,".*"),qr=(s,t)=>s+=t[t.length-1]==="*"?"":"$",qe=s=>{if(!s)return"";let t=$r(s);return t=Fr(t),t=Vr(t),t=Jr(t),t=qr(t,s),t};var zr=0,Wt=class extends M{constructor(t,e){let r=t.baseUri,i=Je(r),n=Ve(i),o=super(n);return this.uri=r,this.paramKeys=i,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),o}setup(){this.stage={},this.id=null,this.uri=null,this.uriQuery=null,this.controller=null,this.paramKeys=null,this.titleCallBack=null,this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1}setupRoute(t){this.id=t.id||"bs-rte-"+zr++,this.path=null,this.referralPath=null;let e=qe(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1}setTitle(t){this.title=t,this.titleCallBack(this,t)}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?ct(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:r,persist:i,parent:n}=t,o={component:e,container:r,persist:i,parent:n,importSrc:t.import||null},a=Ct(this);this.controller=new jt(a,o)}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let i=this.path;if(!i)return;let n=i.split("#")[1];n&&this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);e&&e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(Array.isArray(r)&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(!Array.isArray(t))return;let e=this.paramKeys;if(!e)return;let r={};e.forEach((i,n)=>{typeof i<"u"&&(r[i]=t[n])}),this.set(r)}getParams(){return this.stage}};var Yr=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},Gr=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(let[r,i]of Object.entries(e)){let n=new RegExp(":"+r,"gi");s=s.replace(n,i)}return s},Xr=(s,t)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=Gr(t,s),Yr(t)),Kr=(s,t)=>(t!==""&&(s+=" - "+t),s),ze=(s,t,e)=>t&&(t=Xr(s,t),Kr(t,e));var Ye={removeSlashes(s){return typeof s!="string"?"":(s.substring(0,1)==="/"&&(s=s.substring(1)),s.substring(-1)==="/"&&(s=s.substring(0,s.length-1)),s)}};var Ge=(s,t)=>({attr:s,value:t}),Qr=(s,t)=>new RegExp("^"+s+"($|#|/|\\.).*").test(t),$t=class extends S{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",class:this.class||this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),nest:this.nest||this.children,dataStateSet:this.dataSet,watch:r}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact===!0,i=P.data,n=[];return t&&typeof t=="object"&&n.push(Ge("href",t)),e&&typeof e=="object"&&n.push(Ge("text",e)),n.push({value:["[[path]]",i],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.hash,u=r?o===c:Qr(a.pathname,o);this.update(u)}}),n}setupStates(){return{selected:!1}}update(t){this.state.selected=t}};var Zr=()=>typeof window<"u"?window.location:{},te=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=Zr(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new B({path:""})}setupHistory(){this.history=Ut.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new Wt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+Ye.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var i=0;i<r;i++){var n=e[i];if(n.uri===t)return n}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var i=0;i<r;i++){var n=e[i];if(n.id===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);return t.forEach(i=>{if(!i)return;let n=this.createRoute(i);r.push(n)}),this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,i=this.getSwitchGroup(r);return t.forEach(n=>{let o=n.component.route;o.resume(e),i.push(o)}),this.checkGroup(i,this.getPath()),r}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let r=[];return this.switches.set(t,r),r}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.path=this.getPath(),this.callBackLink=this.checkLink.bind(this),l.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||d.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let i=this.baseURI,n=i!=="/"?r.replace(i,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,r=t.length;e<r;e++){let i=t[e];i&&typeof i.deactivate=="function"&&i.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;document.title=ze(t,e,this.title)}checkActiveRoutes(t){this.lastPath=this.path,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,i;for(var n=0;n<r;n++)i=e[n],!(typeof i>"u")&&this.checkRoute(i,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){this.switches.forEach(r=>{this.checkGroup(r,t)})}checkGroup(t,e){if(!t.length)return;let r=t.find(o=>o.get("active"));r&&r.match(e)===!1&&r.deactivate();let i;for(let o of t){if(typeof o>"u")continue;if(i){o.deactivate();continue}o.match(e)!==!1&&i===void 0&&o.controller&&(i=o,this.select(o))}let n=t[0];i||this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),t.preventScroll!==!0&&this.checkToScroll())}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),r=this.cleanPath(this.lastPath).split("/"),i=t.split("/");if(r.length!==i.length)return!0;let n=r[r.length-1],o=i[i.length-1];return n!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){l.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},P=new te;f.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&P.removeRoute(t)});var Ke=(s,t,e)=>{t&&(Array.isArray(t)?t.forEach(r=>{r&&Xe(s,r,e)}):Xe(s,t,e))},Xe=(s,t,e)=>{t.container=s,t.parent=e;let r=P.add(t);ts(s,r)},ts=(s,t)=>{f.add(s,"routes",{route:t})};var Qe=(s,t,e)=>{};f.addType("switch",s=>{if(!s)return!1;let t=s.id;P.removeSwitch(t)});var Ze=(s,t,e)=>{let r=t[0];t.forEach(n=>{n&&(n.container=s,n.parent=e)});let i=P.addSwitch(t);es(s,i)},es=(s,t)=>{f.add(s,"switch",{id:t})};q.add("cache",De).add("onCreated",je).add("onDestroyed",We).add("bind",He).add("data",Ae).add("state",Qe).add("onSet",K).add("onState",It).add("animateIn",ye).add("animateOut",be).add("watch",$e).add("useParent",Ee).add("useData",Pe).add("useState",Me).add("getId",Oe).add("addState",Be).add("addEvent",Ne).add("map",Ue).add("for",_e).add("useContext",we).add("addContext",Ce).add("context",ke).add("role",xe).add("aria",ve).add("route",Ke).add("debug",Te).add("dataSet",Ie).add("dataStateSet",Re).add("switch",Ze);T.augment({Ajax:ft,Html:A,dataBinder:x,Data:B,SimpleData:R,Model:V,State:J,Builder:m,router:P,Component:S});export{ft as Ajax,N as Arrays,hr as Atom,m as Builder,S as Component,B as Data,f as DataTracker,wr as DateTime,q as Directives,d as Dom,ot as Encode,Vt as Events,A as Html,ct as Import,_ as Jot,V as Model,$t as NavLink,g as Objects,kr as Pod,R as SimpleData,J as State,O as Store,v as Strings,h as Types,at as Unit,T as base,x as dataBinder,P as router};
1
+ var N=class{static toArray(t){return Array.from(t)}static inArray(t,e,r){return Array.isArray(t)?t.indexOf(e,r):-1}};var h=class{static getType(t){let e=typeof t;return e!=="object"?e:Array.isArray(t)?"array":"object"}static isUndefined(t){return typeof t>"u"}static isObject(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}static isFunction(t){return typeof t=="function"}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}};var g={create(s){return Object.create(s||null)},extendObject(s,t){return!h.isObject(s)||!h.isObject(t)?!1:(Object.keys(s).forEach(e=>{this.hasOwnProp(t,e)||(t[e]=s[e])}),t)},clone(s){return!s||!h.isObject(s)?{}:JSON.parse(JSON.stringify(s))},getClassObject(s){return typeof s=="function"?s.prototype:s},extendClass(s,t){let e=this.getClassObject(s),r=this.getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let n=Object.create(e);for(var i in r)n[i]=r[i];return n},hasOwnProp(s,t){return Object.prototype.hasOwnProperty.call(s,t)},isPlainObject(s){return!!s&&Object.prototype.toString.call(s)==="[object Object]"},isEmpty(s){return h.isObject(s)?Object.keys(s).length===0:!0}};var Z={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var ut=class{constructor(){this.types=new Map}add(t,e){this.types.has(t)||this.types.set(t,[]),this.types.get(t).push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){if(!this.types.has(t))return;let e=this.types.get(t);if(!e.length)return;let r,n=Z.get(t);if(n){for(var i=0,o=e.length;i<o;i++)r=e[i],r&&(e[i]=null,this.removeByCallBack(n,r));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}this.types.forEach((e,r)=>{r&&this.removeType(r)}),this.types.clear()}};var l=class{static trackers=new Map;static trackingCount=0;static addType(t,e){Z.add(t,e)}static removeType(t){Z.remove(t)}static getTrackingId(t){return t?t.trackingId||(t.trackingId=`dt${this.trackingCount++}`):""}static add(t,e,r){let n=this.getTrackingId(t);this.find(n).add(e,r)}static get(t,e){let r=t.trackingId,n=this.trackers.get(r);return n?e?n.get(e):n:!1}static has(t,e){let r=this.getTrackingId(t);if(!r)return!1;let n=this.trackers.get(r);return n&&e?n.has(e):!1}static find(t){return this.trackers.has(t)||this.trackers.set(t,new ut),this.trackers.get(t)}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let r=t.trackingId;if(!r||!this.trackers.has(r))return;let n=this.trackers.get(r);if(!e){n.remove(),this.trackers.delete(r),delete t.trackingId;return}n.remove(e),this.isEmpty(n.types)&&(this.trackers.delete(r),delete t.trackingId)}};var $t=s=>{let t=0;for(let[e,r]of Object.entries(s))t++,typeof s[e]=="object"&&(t+=$t(s[e]));return t},ee=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(let[r,n]of Object.entries(s)){if(!g.hasOwnProp(t,r))break;let i=t[r];if(typeof n!=typeof i)break;if(typeof n=="object"){if(e=ee(n,i),e!==!0)break}else if(n===i)e=!0;else break}return e},tr=(s,t)=>{let e=$t(s),r=$t(t);return e!==r?!1:ee(s,t)},re=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?tr(s,t):s===t};var f={getEvents(s){return h.isObject(s)===!1?[]:l.get(s,"events")},create(s,t,e,r=!1,n=!1,i=null){return n=n===!0,{event:s,obj:t,fn:e,capture:r,swapped:n,originalFn:i}},on(s,t,e,r){return Array.isArray(s)?s.forEach(n=>this.add(n,t,e,r)):this.add(s,t,e,r),this},off(s,t,e,r){if(Array.isArray(s)){var n;s.forEach(i=>this.remove(i,t,e,r))}else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,n=!1,i=null){if(h.isObject(t)===!1)return this;let o=this.create(s,t,e,r,n,i);return l.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let n=this.getEvent(s,t,e,r);return n===!1?this:(typeof n=="object"&&this.removeEvent(n),this)},removeEvent(s){return typeof s=="object"&&s.obj.removeEventListener(s.event,s.fn,s.capture),this},getEvent(s,t,e,r){if(typeof t!="object")return!1;let n=this.getEvents(t);if(!n||n.length<1)return!1;let i=this.create(s,t,e,r);return this.search(i,n)},search(s,t){let e,r=this.isSwappable(s.event);for(var n=0,i=t.length;n<i;n++)if(e=t[n],!(e.event!==s.event||e.obj!==s.obj)&&(e.fn===s.fn||r===!0&&e.originalFn===s.fn))return e;return!1},removeEvents(s){return h.isObject(s)===!1?this:(l.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return this.swap.includes(s)}};l.addType("events",s=>{f.removeEvent(s)});var Ft={events:f,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let n=this.events;return Array.isArray(s)?s.forEach(i=>{n.add(i,t,e,r)}):n.add(s,t,e,r),this},off(s,t,e,r){let n=this.events;return Array.isArray(s)?s.forEach(i=>{n.remove(i,t,e,r)}):n.remove(s,t,e,r),this},removeListener(s,t,e,r){return this.events.remove(s,t,e,r),this},_createEvent(s,t,e,r){let n;switch(t){case"HTMLEvents":n=new Event(s,e);break;case"MouseEvents":n=new MouseEvent(s,e);break;default:n=new CustomEvent(s,r);break}return n},createEvent(s,t,e,r){if(h.isObject(t)===!1)return!1;let n={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};h.isObject(e)&&(n=Object.assign(n,e));let i=this._getEventType(s);return this._createEvent(s,i,n,r)},_getEventType(s){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e="CustomEvent";for(let[r,n]of Object.entries(t))if(s.match(n)){e=r;break}return e},trigger(s,t,e){if(h.isObject(t)===!1)return this;let r=typeof s=="string"?this.createEvent(s,t,null,e):s;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let s=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=s())},onMouseWheel(s,t,e,r=!1){typeof t>"u"&&(t=window);let n=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof s=="function"&&s(a,o),e===!0&&o.preventDefault()},i=this.getWheelEventType();return this.events.add(i,t,n,r,!0,s),this},offMouseWheel(s,t,e=!1){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,s,e),this},preventDefault(s){return typeof s.preventDefault=="function"?s.preventDefault():s.returnValue=!1,this},stopPropagation(s){return typeof s.stopPropagation=="function"?s.stopPropagation():s.cancelBubble=!0,this}};var tt=class{constructor(){this.errors=[],this.dataTracker=l}augment(t){if(!h.isObject(t))return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,n){return(t[e]=r).apply(t,N.toArray(n))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(h.isObject(t)===!1)return"";let n=t[e];return typeof n<"u"?n:typeof r<"u"?r:""}createCallBack(t,e,r=[],n=!1){return typeof e!="function"?!1:(...i)=>(n===!0&&(r=r.concat(i)),e.apply(t,r))}bind(t,e){return e.bind(t)}};tt.prototype.extend=(function(){return tt.prototype})();var T=new tt;T.augment({...g,...Ft,...h,equals:re});var et={url:"",responseType:"json",method:"POST",fixedParams:"",headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"},beforeSend:[],async:!0,crossDomain:!1,withCredentials:!1,completed:null,failed:null,aborted:null,progress:null};var se=()=>{T.augment({xhrSettings:et,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=g.extendClass(T.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=et}})};var v=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,r=!0){typeof t!="string"&&(t=window.location.search),t=this.limit(t);let n={},i=/([^?=&]+)(=([^&]*))?/g;return t.replace(i,function(o,a,c,u){n[a]=e!==!1?decodeURIComponent(u):u}),n}static camelCase(t){t=this.limit(t);let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let r=/([A-Z]{1,})/g;return t.replace(r,n=>e+n.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,r=>r.charAt(0).toUpperCase()+r.substring(1).toLowerCase())}};var ht=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:r,url:n,async:i}=this.settings;e.open(r,n,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=et.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var n=0,i=t.length;n<i;n++){var o=t[n];o&&o(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let n=typeof e;if(r==="string")return n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(n==="string"&&(e=v.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else r==="object"&&(t=g.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings={...T.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var r=0,n=t.length;r<n;r++){var i=t[r];switch(r){case 0:e.url=i;break;case 1:e.params=i;break;case 2:e.completed=i,e.failed=i;break;case 3:e.responseType=i||"json";break;case 4:e.method=i?i.toUpperCase():"POST";break;case 5:e.async=typeof i<"u"?i:!0;break}}else e=this.settings=g.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t||typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,n=()=>{f.removeEvents(r.upload),f.removeEvents(r)},i=this.settings;if(!i)return!1;switch(e||t.type){case"load":if(typeof i.completed=="function"){let a=this.getResponseData();i.completed(a,this.xhr)}n();break;case"error":typeof i.failed=="function"&&i.failed(!1,this.xhr),n();break;case"progress":typeof i.progress=="function"&&i.progress(t);break;case"abort":typeof i.aborted=="function"&&i.aborted(!1,this.xhr),n();break}}getResponseData(){let t=this.xhr,e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=this.update.bind(this);f.on(["load","error","abort"],e,r),f.on("progress",e.upload,r)}};se();var ft=(...s)=>new ht(s).xhr;var er=s=>typeof s!="string"?s:ne(s),ne=s=>[{tag:"text",textContent:s}],lt=()=>({props:{},children:[]}),dt=s=>({props:{},children:ne(s)}),pt=s=>({props:{},children:s}),mt=s=>({props:s[0]||{},children:er(s[1])});var gt=class{constructor(){this.connections=new Map}add(t,e,r){let n=this.getOrCreate(t),i=n.get(e);return i?Array.isArray(i)?i.push(r):n.set(e,[i,r]):n.set(e,r),r}get(t,e){let r=this.connections.get(t)?.get(e);return r?Array.isArray(r)?r[r.length-1]||!1:r:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let r=this.connections.get(t);if(r)if(e)this.unsubscribe(r.get(e)),r.delete(e),r.size===0&&this.connections.delete(t);else{for(let n of r.values())this.unsubscribe(n);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,r=t.length;e<r;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var j=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var yt=class extends j{constructor(t){super(),this.data=t}subscribe(t,e){this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data&&this.msg&&this.token&&this.data.off(this.msg,this.token),this.data=null,this.msg=null,this.token=null}};var W=class{unsubscribe(){}};var bt=class extends W{constructor(){super(),this.source=null}addSource(t){return this.source=new yt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var $=class extends j{constructor(t){super(),this.pubSub=t}subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=this.pubSub.on(t,e)}unsubscribe(){this.pubSub&&this.msg&&this.token&&this.pubSub.off(this.msg,this.token),this.pubSub=null,this.msg=null,this.token=null}callBack(){}};var xt=class extends ${constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}unsubscribe(){super.unsubscribe(),this.data=null,this.prop=null}};var p=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?N.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:N.toArray(r):!1}static html(t,e){return h.isObject(t)===!1?!1:h.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return h.isObject(t)===!1||h.isUndefined(e)?this:(e=v.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=v.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let n=null,i=t.currentStyle;if(i&&(n=i[e]))return n;let o=window.getComputedStyle(t,null);return o?o[e]:r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return h.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=v.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=v.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=v.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return h.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(h.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(h.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return h.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return h.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return h.isObject(t)?t.offsetWidth:!1}static getHeight(t){return h.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return h.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,n=e.getElementsByTagName("body")[0],i=t.innerWidth||r.clientWidth||n.clientWidth,o=t.innerHeight||r.clientHeight||n.clientHeight;return{width:i,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,n=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:n}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(h.isObject(t)===!1)return r;let n=0;for(;t&&(e===0||n<e);)n++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}static addClass(t,e){if(h.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let i=e.split(" ");for(var r=0,n=i.length;r<n;r++)t.classList.add(e)}return this}static removeClass(t,e){return h.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return h.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return h.isObject(t)===!1?this:(t.classList.toggle(e),this)}};var vt=s=>{let t="textContent";if(!s||typeof s!="object")return t;let e=s.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let r=s.type;if(!r)return t="value",t;switch(r){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var rr=(s,t,e)=>{p.setAttr(s,t,e)},sr=(s,t,e)=>{s.checked=s.value==e},nr=(s,t,e)=>{e=e==1,ie(s,t,e)},ie=(s,t,e)=>{s[t]=e},ir=(s,t)=>p.getAttr(s,t),or=(s,t)=>s[t],St=class extends ${constructor(t,e,r,n){super(n),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.substring(4,1)==="-")return this.setValue=rr,this.getValue=ir,this;this.getValue=or;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=nr;return;case"radio":this.setValue=sr;return}return this.setValue=ie,this}getAttrBind(t){return t||vt(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;return!e||typeof e!="object"?this:(this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t),this)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){return e!==this.element&&this.set(t),this}unsubscribe(){super.unsubscribe(),this.element=null,this.attr=null,this.filter=null,this.setValue=null,this.getValue=null}};var kt=class extends W{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new St(t,e,r,this.pubSub)}addData(t,e){return this.data=new xt(t,e,this.pubSub)}unsubscribeSource(t){return t&&t.unsubscribe(),this}unsubscribe(){return this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null,this}};var oe=-1,F=class{constructor(){this.callBacks=new Map}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),oe=-1}on(t,e){let r=(++oe).toString();return this.get(t).set(r,e),r}off(t,e){let r=this.callBacks.get(t);r&&(e=String(e),r.delete(e),r.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,...e){let r=this.callBacks.get(t);if(r)for(let n of r.values())n&&n.apply(this,e)}};var Vt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new gt,this.pubSub=new F,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,n){let i=r,o=null;if(r.indexOf(":")!==-1){let d=r.split(":");d.length>1&&(i=d[1],o=d[0])}let a=this.setupConnection(t,e,i,o,n),c=a.element,u=e.get(i);return typeof u<"u"?c.set(u):(u=c.get(),u!==""&&a.data.set(u)),this}setupConnection(t,e,r,n,i){let o=this.getBindId(t),a=new kt(this.pubSub);a.addData(e,r).subscribe(o);let d=`${e.getDataId()}:${r}`;return a.addElement(t,n,i).subscribe(d),this.addConnection(o,"bind",a),a}addConnection(t,e,r){return this.connections.add(t,e,r),this}setBindId(t){let e="db-"+this.idCount++;return t.dataset&&(t.dataset[this.attr]=e),t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,n){if(h.isObject(t)===!1)return this;let i=new bt;i.addSource(e).subscribe(r,n);let a=this.getBindId(t),c=e.getDataId()+":"+r;this.addConnection(a,c,i);let u=e.get(r);return n(u),this}unwatch(t,e,r){if(h.isObject(t)===!1)return this;let n=t[this.attr];if(n){let i=e.getDataId()+":"+r;this.connections.remove(n,i)}return this}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.indexOf(t.keyCode)!==-1}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r!==null){let n=this.connections.get(r,"bind");if(n){let i=n.element.get();this.pubSub.publish(r,i,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){typeof document<"u"&&f.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){typeof document<"u"&&f.off(["change","paste","input"],document,this.changeHandler,!1)}},x=new Vt;var D=s=>s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null;var ar={class:"className",text:"textContent",for:"htmlFor",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",celpadding:"cellPadding",useMap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},rt=s=>ar[s]||s,st=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,A=class{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e),n===!0?this.prepend(r,i):this.append(r,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return;let r=e.type;typeof r<"u"&&p.setAttr(t,"type",r);for(let[n,i]of Object.entries(e))n==="innerHTML"?t.innerHTML=i:n.indexOf("-")!==-1?p.setAttr(t,n,i):this.addAttr(t,n,i)}static addHtml(t,e){return typeof e>"u"||e===""?this:(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(r===""||!e)return;if(typeof r==="function")e=st(e),r.originalCallback?f.add(e,t,r,!1,!1,r.originalCallback):f.add(e,t,r);else{let i=rt(e);t[i]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!h.isObject(t)||!h.isArray(e))return!1;e.forEach(n=>{let i=new Option(n.label,n.value);t.options.add(i),r!==null&&i.value==r&&(i.selected=!0)})}static removeElementData(t){l.remove(t);let e=t.childNodes;if(e){let o=e.length-1;for(var r=o;r>=0;r--){var n=e[r];n&&this.removeElementData(n)}}t.bindId&&x.unbind(t)}static removeElement(t){if(!t)return this;let e=l.has(t,"manual-destroy");return this.removeElementData(t),e===!1&&t.remove(),this}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(!h.isObject(t))return this;let e=t.childNodes;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.removeElementData(e[r]);return t.innerHTML="",this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let n=r||t.firstChild;return t.insertBefore(e,n),this}static clone(t,e=!1){return h.isObject(t)?t.cloneNode(e):!1}};var w=class extends A{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e,n),r.appendChild(i),i}static addAttributes(t,e,r){!e||e.length<1||e.forEach(n=>{let{key:i,value:o}=n;this.addAttr(t,i,o,r)})}static addAttr(t,e,r,n){if(r===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=r;return}if(typeof r==="function"){e=st(e),f.add(e,t,function(a){r.call(this,a,n)});return}if(e.substr(4,1)==="-"){p.setAttr(t,e,r);return}let o=rt(e);t[o]=r}static addContent(t,e){e&&(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}};var Jt=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,C={isWatching(s){return Array.isArray(s)?typeof s[0]=="string"&&this.hasParams(s[0]):this.hasParams(s)},hasParams(s){return h.isString(s)&&s.includes("[[")},_getWatcherProps(s){let t=s.match(Jt);return t?t.map(e=>e.slice(2,-2)):null},updateAttr(s,t,e){switch(t){case"text":case"textContent":s.textContent=e;break;case"disabled":s.disabled=!e;break;case"checked":s.checked=!!e;break;case"required":s.required=!!e;break;case"src":if(s.tagName.toLowerCase()==="img"){s.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}s.src=e;break;default:w.addAttr(s,t,e);break}},replaceParams(s,t,e=!1){let r=0;return s.replace(Jt,function(){let n=e?t[r]:t;r++;let i=n.get(arguments[2]);return typeof i<"u"&&i!==null?i:""})},_getWatcherCallBack(s,t,e,r,n){return()=>{let i=this.replaceParams(e,t,n);this.updateAttr(s,r,i)}},getValue(s,t){let e=s.value;return Array.isArray(e)===!1?[e,D(t)]:(e.length<2&&e.push(D(t)),e)},getPropValues(s,t,e){let r=[];for(var n=0,i=t.length;n<i;n++){var o=e?s[n]:s,a=o.get(t[n]);a=typeof a<"u"?a:"",r.push(a)}return r},getCallBack(s,t,e,r,n){let i=s.attr||"textContent",o=s.callBack;if(typeof o=="function"){let a=r.match(Jt)||[],c=a&&a.length>1;return(u,d)=>{u=c!==!0?u:this.getPropValues(e,a,n);let y=o(u,t,d);typeof y<"u"&&this.updateAttr(t,i,y)}}return this._getWatcherCallBack(t,e,r,i,n)},addDataWatcher(s,t,e){let r=this.getValue(t,e),n=r[1]??e?.data??e?.context?.data??e?.state??null;if(!n)return;let i=r[0],o=Array.isArray(n),a=this.getCallBack(t,s,n,i,o),c=this._getWatcherProps(i);for(var u=0,d=c.length;u<d;u++){var y=o?n[u]:n;this.addWatcher(s,y,c[u],a)}},getWatcherSettings(s,t=null){if(typeof s=="string")return{attr:t,value:s};if(Array.isArray(s)){let e=s[s.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let r=s[1]&&typeof s[1]=="object"?[s[0],s[1]]:[s[0]];return typeof e=="function"?{attr:t,value:r,callBack:e}:{attr:e||"textContent",value:r}}return s},setup(s,t,e){t&&this.addDataWatcher(s,this.getWatcherSettings(t),e)},addWatcher(s,t,e,r){x.watch(s,t,e,r)}};var cr=s=>({props:{watch:s},children:[]}),ur=s=>{if(!s)return lt();let t=s[0],e=typeof t;if(e==="string"||e==="number")return dt(t);if(Array.isArray(t))return C.isWatching(t)===!1?pt(t):cr(t);let r=s[1]??s[0]??[];return r&&Array.isArray(r)&&C.isWatching(r)===!0&&(s[0]=Array.isArray(s[0])?{}:s[0],s[0].watch=r,s[1]=[]),mt(s)},hr=s=>(...t)=>{let{props:e,children:r}=ur(t);return s(e,r)};function ae(s,t){let e=isNaN(Number(t)),r=e?t:`[${t}]`;return s===""?r:e?`${s}.${r}`:`${s}${r}`}function ce(s,t="",e=""){return{get(r,n,i){let o=r[n];if(t===""&&n in r)return typeof o=="function"?o.bind(r):o;let a=r[e]||r;if(o=Reflect.get(a,n,i),g.isPlainObject(o)||Array.isArray(o)){let c=ae(t,n);return new Proxy(o,ce(s,c,e))}return o},set(r,n,i,o){if(t===""&&n in r)return r[n]=i,!0;let a=ae(t,n);return s.set(a,i),!0}}}var wt=(s,t="stage")=>new Proxy(s,ce(s,"",t));var nt=class{static resume(t,e){if(!t)return null;let r,n=localStorage.getItem(t);return n===null?e&&(r=e):r=JSON.parse(n),r}static store(t,e){if(!t||!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var Ct=(s={})=>{let t={};if(!h.isObject(s))return t;let e=g.clone(s);return Object.keys(e).forEach(r=>{let n=e[r];typeof n!="function"&&(t[r]=n)}),t};var fr=0,L={CHANGE:"change",DELETE:"delete"},qt=(s,t)=>`${s}:${t}`,P=class{constructor(t={}){this.dirty=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new F;let e=Ct(t);return this.set(e),wt(this)}setup(){this.stage={}}_init(){let t=++fr;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}getDataId(){return this._id}remove(){}on(t,e){let r=qt(t,L.CHANGE);return this.eventSub.on(r,e)}off(t,e){let r=qt(t,L.CHANGE);this.eventSub.off(r,e)}_setAttr(t,e,r=this,n=!1){let i=this.stage[t];e!==i&&(this.stage[t]=e,this._publish(t,e,r,L.CHANGE))}publishLocalEvent(t,e,r,n){let i=qt(t,n);this.eventSub.publish(i,e,r)}_publish(t,e,r,n){this.publishLocalEvent(t,e,r,n),r=r||this,x.publish(this._dataId+t,e,r)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,n]=t;return Object.entries(e).forEach(([i,o])=>{typeof o!="function"&&this._setAttr(i,o,r,n)}),this}getModelData(){return this.stage}_deleteAttr(t,e,r=this){delete t[e],this.publishLocalEvent(e,null,r,L.DELETE)}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r+e),this}decrement(t,e=null){if(typeof t>"u")return;e=e!==null&&typeof e=="number"?e:1;let r=this.get(t);return this.set(t,r-e),this}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=nt.resume(this.key,t);return e?(this.set(e),this):this}store(){let t=this.get();return nt.store(this.key,t)}delete(t){return typeof t=="string"?(this._deleteAttr(this.stage,t),this):(this.setup(),this)}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let n=[];return Object.entries(e).forEach(([i])=>{n.push(this.remoteLink(t,i))}),n}remoteLink(t,e,r){let n=r||e,i=t.get(e);typeof i<"u"&&this.get(e)!==i&&this.set(e,i);let o=t.on(e,(c,u)=>{if(u===this)return!1;this.set(n,c,t)});this.addLink(o,t);let a=this.on(n,(c,u)=>{if(u===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links.set(t,e)}unlink(t){if(t){this.removeLink(t);return}let e=this.links;g.isEmpty(e)||(e.forEach((r,n)=>{this.removeLink(n,!1)}),this.links=new Map)}removeLink(t,e=!0){let r=this.links.get(t);r&&r.off(t),e!==!1&&this.links.delete(t)}};P.prototype.isData=!0;var E={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.deepDataPattern;return s.match(t)}};var R=class{static set(t,e,r){if(!E.hasDeepData(e)){t[e]=r;return}let n,i=E.getSegments(e),o=i.length,a=o-1;for(var c=0;c<o;c++){if(n=i[c],c===a){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}static delete(t,e){if(!E.hasDeepData(e)){delete t[e];return}let r=E.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a];if(c===void 0)break;if(o===i){if(Array.isArray(t)){t.splice(Number(a),1);break}delete t[a];break}t=c}}static get(t,e){if(!E.hasDeepData(e))return t[e]??void 0;let r=E.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===i)return t}}};var it=class{static publishDeep(t,e,r,n){if(!E.hasDeepData(e)){this.publish(e,r,n);return}let i,o=E.getSegments(e),a=o.length,c=a-1,u="";for(var d=0;d<a;d++){i=o[d],t=t[i],d>0?isNaN(i)&&(u+="."+i):u=i;var y;if(d===c)y=r;else{var b=o[d+1];if(isNaN(b)===!1){u+="["+b+"]";continue}var k={};k[b]=t[b],y=k}this.publish(u,y,n)}}static publish(t,e,r){if(t=t||"",r(t,e),!(!e||typeof e!="object")){if(Array.isArray(e)){this.publishArray(t,e,r);return}this.publishObject(t,e,r)}}static publishArray(t,e,r){let n,i,o=e.length;for(var a=0;a<o;a++)i=e[a],n=t+"["+a+"]",this._checkPublish(n,i,r)}static publishObject(t,e,r){let n,i;for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(i=e[o],n=t+"."+o,this._checkPublish(n,i,r))}static _checkPublish(t,e,r){if(!e||typeof e!="object"){r(t,e);return}this.publish(t,e,r)}};var M=class extends P{setup(){this.attributes={},this.stage={}}_setAttr(t,e,r,n){typeof e!="object"&&e===this.get(t)||(!r&&n!==!0?R.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),R.set(this.stage,t,e),r=r||this,this._publish(t,e,r,L.CHANGE))}linkAttr(t,e){let r=t.get(e);if(r)for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&this.link(t,e+"."+n,n)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let n=new e(r);return n.linkAttr(this,t),n}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}concat(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r=r.concat(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}getIndex(t,e,r){let n=this.get(t);return Array.isArray(n)===!1?-1:typeof n[0]!="object"?n.indexOf(e):n.findIndex(o=>o[e]===r)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r,n){let i=(o,a)=>this._publishAttr(o,a,r,n);it.publish(t,e,i)}_publishAttr(t,e,r,n){let i=this._dataId+t;x.publish(i,e,r),this.publishLocalEvent(t,e,r,n)}mergeStage(){this.attributes=g.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,r=this){R.delete(t,e);let n=(i,o)=>this.publishLocalEvent(i,o,r,L.DELETE);it.publish(e,e,n)}_getAttr(t,e){return R.get(t,e)}};var lr={"\n":"\\n","\r":"\\n"," ":"\\t"},dr=(s,t)=>{typeof s!="string"&&(s=String(s));let e=t?/[\n\r\t]/g:/\t/g;return s.replace(e,r=>lr[r])},ue=(s,t)=>{if(typeof s!="string")return s;s=dr(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},zt=(s,t)=>{let e=typeof s;return e==="undefined"?s:e!=="object"?(s=ue(s),s):(Object.entries(s).forEach(([r,n])=>{n!==null&&(s[r]=typeof n=="string"?zt(n,t):ue(n,t))}),s)};function he(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function Yt(s){return typeof s<"u"?JSON.stringify(s):null}var ot=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?g.clone(t):t,n=zt(r,e);return Yt(n)}static json={encode:Yt,decode:he};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var At=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=v.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=v.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),n="id="+r,i=this.model;return this._get(`/${r}`,n,t,e,o=>{if(o){let a=this.getObject(o);a&&i.set(a)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ot.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let r=this.setupObjectData(),n=this.model.id,i=typeof n>"u"?"":`/${n}`;return this._put(i,r,t,e)}add(t,e){if(!this.isValid())return;let r=this.setupObjectData(),n=this.model.id,i=typeof n>"u"?"":`/${n}`;return this._post(i,r,t,e)}update(t,e){if(!this.isValid())return;let r=this.setupObjectData(),n=this.model.id,i=typeof n>"u"?"":`/${n}`;return this._patch(i,r,t,e)}delete(t,e){let r=this.model.get("id"),n=typeof r<"u"?"id="+r:this.setupObjectData(),i=typeof r>"u"?"":`/${r}`;return this._delete(i,n,t,e)}all(t,e,r,n,i=null,o=null){let a=this.model.get();r=isNaN(r)?0:r,n=isNaN(n)?50:n;let c=a.search||"",u=a.filter||"";typeof u=="object"&&(u=JSON.stringify(u));let d=a.dates||"";typeof d=="object"&&(d=JSON.stringify(d));let y=a.orderBy||"";typeof y=="object"&&(y=JSON.stringify(y));let b=a.groupBy||"";Array.isArray(b)&&(b=JSON.stringify(b));let k="&filter="+u+"&offset="+r+"&limit="+n+"&dates="+d+"&orderBy="+y+"&groupBy="+b+"&search="+c+"&lastCursor="+(typeof i<"u"&&i!==null?i:"")+"&since="+(typeof o<"u"&&o!==null?o:"");return this._get("",k,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let r=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(r)}setupRequest(t,e,r,n,i){let o={url:this.getUrl(t),method:e,params:r,completed:(c,u)=>{typeof i=="function"&&i(c),this.getResponse(c,n,u)}};return this._isFormData(r)&&(o.headers={}),ft(o)}setupEventSource(t,e,r,n,i=!0){let o=null,a=null,c=!1,u=()=>{if(c)return;let d=this.getUrl(t),y=e?"?"+e:"";o=new EventSource(d+y,{withCredentials:!0}),o.onopen=()=>{n&&n()},o.onerror=b=>{o.close(),!c&&i&&(a=setTimeout(()=>{u()},3e3))},o.onmessage=b=>{try{let k=JSON.parse(b.data);r&&r(k)}catch{}}};return u(),{get source(){return o},close:()=>{c=!0,a&&i&&clearTimeout(a),o&&o.close()}}}replaceUrl(t){return C.isWatching(t)&&(t=C.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,r,n){return this._request("","POST",t,e,r,n)}_get(t,e,r,n,i){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",n,i)}_post(t,e,r,n,i){return this._request(t,"POST",e,r,n,i)}_put(t,e,r,n,i){return this._request(t,"PUT",e,r,n,i)}_patch(t,e,r,n,i){return this._request(t,"PATCH",e,r,n,i)}_delete(t,e,r,n,i){return this._request(t,"DELETE",e,r,n,i)}_request(t,e,r,n,i,o){return r=this.setupParams(r),r=this.addParams(r,n),this.setupRequest(t,e,r,i,o)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(i){super(i)}}return Object.assign(r.prototype,t),r}};var pr=s=>{let t={};if(!h.isObject(s)||!s.defaults)return t;let{defaults:e}=s;return Object.keys(e).forEach(r=>{let n=e[r];typeof n!="function"&&(t[r]=n)}),delete s.defaults,t},mr=s=>{if(!s||typeof s.xhr!="object")return{};let t={...s.xhr};return delete s.xhr,t},gr=0,V=class extends M{constructor(t){let e=super(t);return this.initialize(),e}setup(){this.attributes={},this.stage={},this.url=this.url||"",this.xhr=this.xhr||{}}initialize(){}static extend(t={}){let e=this,r=mr(t),n=e.prototype.service.extend(r),i=pr(t);class o extends e{constructor(c){let u={...i,...Ct(c)};super(u),this.xhr=new n(this)}dataTypeId=`bm${gr++}`}return Object.assign(o.prototype,t),o.prototype.service=n,o}};V.prototype.service=At;var I=class extends P{};var J=class extends I{setup(){this.stage={}}addAction(t,e){return typeof e<"u"&&this.set(t,e),this}getState(t){return this.get(t)}removeAction(t,e){if(e)return this.off(t,e),this;let r=this.stage;return typeof r[t]<"u"&&delete r[t],this}};var Tt=class extends J{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=null}};var B=class{static targets=new Map;static restore(t,e){this.targets.set(t,e)}static getTarget(t){return this.targets.has(t)||this.targets.set(t,new Tt(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let n=this.getTarget(t);return e&&n.addAction(e,r),n}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){this.off(t,e,r)}static on(t,e,r){let n=this.getTarget(t);return e?n.on(e,r):null}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let n=this.targets,i=n.get(t);if(i){if(e){i.off(e,r);return}this.targets.delete(t)}}static set(t,e,r){this.getTarget(t).set(e,r)}};var Dt=class{constructor(){this.events=[]}addEvents(t){t.length<1||t.forEach(r=>{this.on(...r)})}on(t,e,r,n){f.on(t,e,r,n),this.events.push({event:t,obj:e,callBack:r,capture:n})}off(t,e,r,n){f.off(t,e,r,n);let i,o=this.events;for(var a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.obj===e){o.splice(a,1);break}}set(){this.events.forEach(t=>{f.on(t.event,t.obj,t.callBack,t.capture)})}unset(){this.events.forEach(t=>{f.off(t.event,t.obj,t.callBack,t.capture)})}reset(){this.unset(),this.events=[]}};var Et=class{constructor(t,e){this.remoteStates=[];let r=this.convertStates(e);this.addStatesToTarget(t,r)}addStates(t,e){let r=this.convertStates(e);this.addStatesToTarget(t,r)}createState(t,e,r,n){return{action:t,state:e,callBack:r,targetId:n,token:null}}convertStates(t){let e=[];for(var r in t)if(Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var n=null,i=null,o=t[r];o&&typeof o=="object"&&(i=o.callBack,n=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,i,n))}return e}setupRemoteStates(t,e){let r;for(var n=0,i=t.length;n<i;n++)if(r=t[n],!!r){for(var o in r)if(!(!Object.prototype.hasOwnProperty.call(r,o)||o==="id")){var a=null,c=r[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,r.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(var r=0,n=e.length;r<n;r++){var i=e[r];i.token&&this.unbindRemoteState(t,i.token),B.remove(i.targetId,i.action,i.token)}}restore(t){B.restore(t.id,t);let e=this.remoteStates;if(e)for(var r=0,n=e.length;r<n;r++){var i=e[r];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,r){let n=B.getTarget(r);return t.link(n,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var n=0,i=e.length;n<i;n++){var o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}r.length<1&&(this.remoteStates=[])}addAction(t,e){let r,n=e.action,i=e.targetId;i&&(r=this.bindRemoteState(t,n,i)),typeof e.state<"u"&&t.addAction(n,e.state);let o=e.callBack;return typeof o=="function"&&t.on(n,o),r}};var fe=s=>{if(!s)return lt();let t=s[0],e=typeof t;return e==="string"||e==="number"?dt(t):Array.isArray(t)?pt(t):mt(s)};l.addType("components",s=>{if(!s)return;let t=s.component;!t||!t.isUnit||(t.rendered===!0&&t.prepareDestroy(),t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken))});var yr=0,at=class{constructor(...t){this.isUnit=!0,this.data=null,this.persist=null,this.nest=null,this.state=null,this.panel=null,this.parent=null,this.unitType=null,this.init();let{props:e,children:r}=fe(t);this.setupProps(e),this.children=r||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+yr++,this.unitType=this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=this.persistedCount++,r="pc"+e,i=Object.keys(this.persistedChildren)[e],o=this.persistedChildren[i];return o&&t.unitType===o.unitType&&(r=i,t.resumeScope(o)),t.persistToken=r,this.persistedChildren[r]=t,r}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];r&&(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context??={},this.context[t]=e}setContext(t){return null}addContext(t){return null}removeContext(){this.addingContext&&this.removeContextBranch(this.contextBranchName)}removeContextBranch(t){t&&delete this.context[t]}getContext(){return this.context}onCreated(){}render(){return{}}_cacheRoot(t){return t&&(t.id||(t.id=this.getId()),t.cache="panel",t)}_createLayout(){return this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){l.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var n=0,i=t.length;n<i;n++){let o=e(t[n],n);r.push(o)}return r}removeAll(t){return A.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.setContainer(t),this.initialize()}setContainer(t){this.container=t}_remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;A.removeElement(t)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var S=class extends at{constructor(...t){super(...t),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this.data=t.data,this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,this.id=t.id}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=B.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();g.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new Et(this.state,t))}addState(t){!this.stateHelper||this.stateResumed==!0||this.stateHelper.addStates(this.state,t)}removeStates(){let t=this.state;t&&(this.stateHelper.removeRemoteStates(t),t.remove(),this.stateResumed=!1)}setEventHelper(){this.events||(this.events=new Dt)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events.addEvents(t))}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist===!1&&this.data.unlink()}};var Ot={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var br=s=>typeof s=="function"?s:()=>s,xr=s=>{let t={};return s&&Object.entries(s).forEach(([e,r])=>{let n=Ot[e]||e;t[n]=br(r)}),t},le=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e},_=(s,t=S)=>{if(!s)return null;let e,r=typeof s;return r==="object"&&s.render?(e=xr(s),le(t,e)):(e={render:r==="function"?s:()=>s},le(t,e))};var vr=(s,t)=>(Object.entries(s).forEach(([e,r])=>{let n=Ot[e]||e;t.prototype[n]=r}),t),Sr=s=>class extends s{},kr=(s,t=S)=>{if(!s)return null;let e=Sr(t),r={},n=s(r);return vr(r,e),e.prototype.render=n,e};var wr={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(s=new Date().getDay(),t=!1){let e=this.dayNames;if(s>e.length)return null;let r=e[s];return t?r.substring(0,3):r},convertJsMonth(s){return this.padNumber(s+1)},convertDate(s,t=!1){s=s?s.replace(/\s/,"T"):"";let e=new Date(s),r=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+r},padNumber(s){return s<=9?"0"+s:String(s)},createDate(s){return s?(typeof s=="string"&&s.indexOf("-")>-1&&(s=s.replace(/\s/,"T"),s=s.indexOf(":")>-1?s:s+"T00:00:00"),new Date(s)):new Date},format(s,t){let e=this.createDate(t);return this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),s)},formatTime(s,t){let e=this.createDate(s),r=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),r)},getMeridian(s){return s=Number(s),s>=12?"PM":"AM"},convert24To12(s){return s=Number(s),s>12&&(s=s-12),s},convert12To24(s,t){return s=Number(s),t.toLowerCase()==="pm"&&(s=s+12),s},renderDate(s,t,e,r="sql"){return t=Number(t),e=Number(e),r==="sql"?`${s}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${s}`},renderTime(s,t,e=0,r="sql"){if(r==="sql")return`${this.padNumber(s)}:${this.padNumber(t)}:${this.padNumber(e)}`;let n=this.getMeridian(s);return s=this.convert24To12(s),`${s}:${this.padNumber(t)} ${n}`},leapYear(s){return s%400===0||s%100!==0&&s%4===0},getMonthName(s=new Date().getMonth(),t=!1){let e=this.monthNames;if(s>e.length)return"";let r=e[s];return r?t?r.substring(0,3):r:""},getMonthLength(s,t){let e=new Date;return s=typeof s<"u"?s:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[s]},getMonthsLength(s=new Date().getFullYear()){return this.leapYear(s)===!0?[31,29,31,30,31,30,31,31,30,31,30,31]:[31,28,31,30,31,30,31,31,30,31,30,31]},getLocalDate(s,t="America/Denver"){let e=new Date(s);if(Number.isNaN(e.getMonth())===!0){let i=/[- :]/,o=s.split(i);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let r=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),n=e.getTime()-r.getTime();return new Date(e.getTime()+n)},getLocalTime(s,t=!1,e=!1,r="America/Denver"){if(!s)return"";let n=this.getLocalDate(s,r),i=n.getMonth()+1,o=t===!0?"sql":"standard",a="";return e===!1&&(a+=this.renderDate(n.getFullYear(),i,n.getDate(),o)+" "),a+this.renderTime(n.getHours(),n.getMinutes(),n.getSeconds(),o)},getDiffFromNow(s,t=!1){s=s.replace(/\s/,"T");let e=new Date(s),r=new Date;return t===!0&&r.setHours(0,0,0,0),r.getTime()-e.getTime()},getAge(s){let t=this.getDiffFromNow(s),e,r;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:r=this.toDays(t),e=r+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:r=this.toDays(t);var n=Math.floor(r/7);e=n+" weeks";break;case t<5184e6:e="1 month";break;case t<31104e6:var i=this.toMonths(t);e=i+" months";break;default:var o=this.toYears(t);e=o}return String(e)},getTimeFrame(s){let t=this.getDiffFromNow(s);return this.convertToEstimate(t)},convertToEstimate(s){let t="",e,r,n,i,o,a,c;if(s<=0)switch(!0){case s<-63072e6:n=this.toYears(Math.abs(s)),t="in "+n+" years";break;case s<-31536e6:t="in a year";break;case s<-5184e6:i=this.toMonths(Math.abs(s)),t="in "+i+" months";break;case s<-2592e6:t="in a month";break;case s<-12096e5:e=this.toDays(Math.abs(s)),r=Math.floor(e/7),t="in "+r+" weeks";break;case s<-6048e5:t="in a week";break;case s<-1728e5:e=this.toDays(Math.abs(s)),t="in "+e+" days";break;case s<-864e5:t="tomorrow";break;case s<-72e5:o=this.toHours(Math.abs(s)),t="in "+o+" hours";break;case s<=-36e5:t="in an hour";break;case s<-12e4:a=this.toMinutes(Math.abs(s)),t="in "+a+" minutes";break;case s<-6e4:t="in a minute";break;case s<-2e3:c=this.toSeconds(Math.abs(s)),t="in "+c+" seconds";break;case s<-1:t="in 1 second";break;default:t="now"}else switch(!0){case s<1e3:t="1 second ago";break;case s<6e4:c=this.toSeconds(s),t=c+" seconds ago";break;case s<12e4:t="1 minute ago";break;case s<36e5:a=this.toMinutes(s),t=a+" minutes ago";break;case s<72e5:t="1 hour ago";break;case s<864e5:o=this.toHours(s),t=o+" hours ago";break;case s<1728e5:t="yesterday";break;case s<6048e5:e=this.toDays(s),t=e+" days ago";break;case s<12096e5:t="a week ago";break;case s<2592e6:e=this.toDays(s),r=Math.floor(e/7),t=r+" weeks ago";break;case s<5184e6:t="a month ago";break;case s<31536e6:i=this.toMonths(s),t=i+" months ago";break;case s<63072e6:t="a year ago";break;default:n=this.toYears(s),t=n+" years ago"}return t},toYears(s){return typeof s!="number"?0:Math.floor(s/31558464e3)},toMonths(s){return typeof s=="number"?Math.floor(s/2592e6):0},toDays(s){return typeof s!="number"?0:Math.floor(s/864e5*1)},toHours(s){return typeof s!="number"?0:Math.floor(s%864e5/36e5*1)},toMinutes(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5/6e4*1)},toSeconds(s){return typeof s!="number"?0:Math.floor(s%864e5%36e5%6e4/1e3*1)},getDifference(s,t){let e=new Date(s),r=new Date(t),n=r.getTime()-e.getTime();return{years:this.toYears(n),days:this.toDays(n),hours:this.toHours(n),minutes:this.toMinutes(n),seconds:this.toSeconds(n)}}};var de=(s,t)=>({name:s,callBack:t});var q={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=de(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var Gt=(s,t)=>({attr:s,directive:t});var z=(s,t)=>({key:s,value:t});var pe=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var H=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,r,n){return t==="text"?(n.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(r.push(z("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){t.push(Gt(z(e,C.getWatcherSettings(r,rt(e))),q.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let n=e.type||"button";r.push(z("type",n))}}static parse(t,e){let r=[],n=[],i=this.getTag(t);this.setButtonType(i,t,r),this.setupChildren(t);let o=[];var a,c;for(var u in t){if(!g.hasOwnProp(t,u)||u==="tag"||(a=t[u],a==null))continue;if(u==="children"){o=Array.isArray(a)?o.concat(a):o.concat([a]);continue}if((c=q.get(u))!==null){n.push(Gt(z(u,a),c));continue}let d=typeof a;if(d==="object"){if(C.isWatching(a)){this.setTextAsWatcher(n,u,a);continue}o.push(a);continue}if(d==="function"){let y=a,b=function(k){y.call(this,k,e)};b.originalCallback=y,a=b}if(C.isWatching(a)){this.setTextAsWatcher(n,u,a);continue}this.setElementContent(u,a,r,o)||r.push(z(u,a))}return pe(i,r,n,o)}};var Y=class{build(t,e,r){}setupComponent(t,e,r){t.parent=r,r&&r.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&r&&(r[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),r=this.build(e,t.container,t.getChildScope());return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),r}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t),t}setDirectives(t,e,r){}removeNode(t){}removeAll(t){}};var Pt=class extends Y{build(t,e,r){let n=w.createDocFragment();return(Array.isArray(t)?t:[t]).forEach(o=>this.buildElement(o,n,r)),e&&typeof e=="object"&&e.appendChild(n),n}buildElement(t,e,r){if(t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}createElement(t,e,r){if(t.data||t.state){this.createTempComponent(t,e,r);return}let n=H.parse(t,r),i=this.createNode(n,e,r);this.cache(i,t.cache,r),n.children.forEach(a=>{a!==null&&this.buildElement(a,i,r)});let o=n.directives;o&&o.length&&this.setDirectives(i,o,r)}createTempComponent(t,e,r){let n={setData:()=>t.data,render(){return{...t,data:null,state:null}}};t.state&&(n.setupStateTarget=function(o){this.state=t.state});let i=new S(n);this.createComponent(i,e,r)}setDirectives(t,e,r){e.forEach(n=>{this.handleDirective(t,n,r)})}handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}cache(t,e,r){r&&e&&(r[e]=t)}createNode(t,e,r){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:"";return w.createText(o,e)}else if(n==="comment"){let i=t.attr[0],o=i?i.value:"";return w.createComment(o,e)}return w.create(n,t.attr,e,r)}removeNode(t){w.removeElement(t)}removeAll(t){w.removeAll(t)}};var Cr=["area","base","br","col","embed","hr","img","input","link","meta","source"],G=class{static create(t,e=[],r=""){let n=this.getInnerContent(e);n+=this.getInnerHtml(e);let i=this.createAttributes(e);return Cr.includes(t)?`<${t} ${i} />`:`<${t} ${i}>`+n+r+`</${t}>`}static getInnerContent(t){let e="";return t.forEach(({key:r,value:n},i)=>{if(r!=="text"&&r!=="textContent")return"";t.splice(i,1),e+=n}),e}static getInnerHtml(t){let e="";return t.forEach(({key:r,value:n},i)=>{if(r!=="html"&&r!=="innerHTML")return"";t.splice(i,1),e+=n}),e}static createAttributes(t=[]){return!t||t.length<1?"":t.map(e=>{let{key:r,value:n}=e;return typeof n=="function"&&(r="on"+st(r)),`${r}="${n}"`}).join(" ")}static createText(t){return t}static createComment(t){return`<!-- ${t} -->`}};var Mt=class extends Y{build(t,e,r){return(Array.isArray(t)?t:[t]).map(i=>this.buildElement(i,r)).join("")}createComponent(t,e,r){return this.setupComponent(t,e,r),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,e):this.createElement(t,e):""}createElement(t,e){let r=H.parse(t,e),n=r.children.map(i=>i!==null?this.buildElement(i,e):"").join("");return this.createNode(r,n)}createNode(t,e){let r=t.tag;if(r==="text"){let n=t.attr[0],i=n?n.value:"";return G.createText(i)}else if(r==="comment"){let n=t.attr[0],i=n?n.value:"";return G.createComment(i)}return G.create(r,t.attr,e)}removeAll(t){}};var Bt=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new Pt:new Mt}};var U=Bt.setup(),Ar=s=>typeof s=="object"&&s.isUnit===!0,Tr=s=>{let t=_(s);return new t},m=class{static render(t,e,r){return t?(Ar(t)||(t=Tr(t)),U.createComponent(t,e,r)):null}static build(t,e,r){return U.build(t,e,r)}static rebuild(t,e,r){return U.removeAll(e),this.build(t,e,r)}static setDirectives(t,e,r){U.setDirectives(t,e,r)}static createNode(t,e,r){return U.createNode(t,e,r)}static removeNode(t){U.removeNode(t)}static removeAll(t){U.removeAll(t)}};T.augment({buildLayout(s,t,e){m.build(s,t,e)}});var Xt=[],Dr=s=>Xt.indexOf(s)!==-1,Er=s=>({tag:"script",src:s.src,async:!1,load(t){Xt.push(s.src);let e=s.load;e&&e()}}),Or=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){Xt.push(s.src);let e=s.load;e&&e()}}),Nt=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,r=this.update.bind(this);t.indexOf(".css")!==-1?e=Or({load:r,src:t}):e=Er({load:r,src:t}),m.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{Dr(e)||this.add(e)})}update(){if(this.updateProgress()<100)return;let e=this.callBack;e&&e()}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}};var Pr=s=>s?typeof s?.prototype?.constructor=="function":!1,X=class{static process(t,e){let r=t.default;return r?e.callback?e.callback(r):(Pr(r)?r=new r:r=r(),r.isUnit===!0&&(r.route=e.route,e.persist&&(r.persist=!0)),r):null}static render(t,e,r){let n=m.build(t,null,r),i=n.firstChild||t?.panel;return e.after(n),i}};var Ht=class{static load(t,e){return t.then(r=>(e&&e(r),r)).catch(r=>{console.error("Error loading module:",r)})}};var Mr=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),Br=s=>{let t=typeof s;return t==="string"?import(s):t==="function"?s():s},me=_({declareProps(){this.loaded=!1,this.blockRender=!1},render(){return Mr({onCreated:s=>{if(this.src){if(this.layout){this.layoutRoot=X.render(this.layout,this.panel,this.parent);return}if(this.depends){new Nt(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},loadAndRender(s){this.src=Br(this.src),Ht.load(this.src,t=>{if(this.loaded=!0,this.blockRender===!0){this.blockRender=!1;return}let e=this.layout||X.process(t,{callback:this.callback,route:this.route,persist:this.persist});this.layout=e,this.layoutRoot=X.render(e,s,this.parent)})},shouldUpdate(s){return this.updateLayout===!0?!0:this.updateLayout=s&&s.isUnit&&typeof s.update=="function"},updateModuleLayout(s){let t=this.layout;this.shouldUpdate(t)&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},destroy(){if(!this.layoutRoot){this.blockRender=!0;return}this.blockRender=!1,m.removeNode(this.layoutRoot)}});var Kt=s=>{let t=typeof s;return(t==="string"||t==="function"||s instanceof Promise)&&(s={src:s}),new me(s)};var ge=(s,t,e=null)=>{f.on("animationend",s,function r(){p.removeClass(s,t),f.off("animationend",s,r),e&&e()}),p.addClass(s,t)},ye=(s,t,e)=>{ge(s,t)},be=(s,t,e)=>{let r=()=>s&&s.remove();Nr(s,()=>ge(s,t,r),e)};l.addType("manual-destroy",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var Nr=(s,t,e)=>{l.add(s,"manual-destroy",{ele:s,callBack:t,parent:e})};var ct=(s,t,e,r)=>{if(Array.isArray(e[0])){e.forEach(n=>{n&&ct(s,t,n,r)});return}Hr(s,t,e,r)},Hr=(s,t,e,r)=>{let n,i;if(e.length<3?[n,i]=e:[t,n,i]=e,!t||!n)return;let o=Lr(s,n,i,r);x.watch(s,t,n,o)},Lr=(s,t,e,r)=>typeof e=="object"?n=>{_r(s,e,n)}:n=>{Rr(s,e,t,n,r)},Rr=(s,t,e,r,n)=>{let i=t(r,s,n);switch(typeof i){case"object":Ir(i,s,n);break;case"string":let o=vt(s);if(o!=="textContent"){p.setAttr(s,o,i);break}A.addHtml(s,i);break}},Ir=(s,t,e)=>{m.rebuild(s,t,e)},_r=(s,t,e)=>{for(let[r,n]of Object.entries(t))r&&(n===e?p.addClass(s,r):p.removeClass(s,r))};var K=(s,t,e)=>{let r=D(e);ct(s,r,t,e)};var xe=(s,t,e)=>{t&&t&&p.setAttr(s,"role",t)},Ur=s=>(t,e)=>{let r=t?"true":"false";p.setAttr(e,s,r)},ve=(s,t,e)=>{if(!t)return;let r=t.role;r&&(p.setAttr(s,"role",r),t.role=null),Object.entries(t).forEach(([n,i])=>{if(i===null)return;let o=`aria-${n}`;if(Array.isArray(i)){let a=[...i];a.push(Ur(o)),K(s,a,e)}else p.setAttr(s,o,i)})};var Se=(s,t,e)=>{if(!t)return;let r=H.parse(t,e);w.addAttributes(s,r.attr,e),m.setDirectives(s,r.directives,e)};l.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var Qt=s=>s?s.getContext():null,ke=(s,t,e)=>{if(typeof t!="function")return;let r=Qt(e),n=t(r);Se(s,n,e)},we=(s,t,e)=>{if(typeof t!="function")return;let r=Qt(e);t(r)},Ce=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=Qt(e),n=t(r);n&&e.addContextBranch(n[0],n[1])};var Ae=(s,t,e)=>{};var Te=(s,t,e)=>{if(!e)return;let r=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",s),console.log("Data: ",t),console.log("Layout: ",r),console.log("parent: ",e)};var De=(s,t,e)=>{},Ee=(s,t,e)=>{if(!t||!e)return;let r=t(e,s);r&&m.build(r,s,e)},Oe=(s,t,e)=>{if(!t||!e)return;let r=e.getId(t);s.id=r},Pe=(s,t,e)=>{if(!t||!e)return;let r=t(e.data,s);r&&m.build(r,s,e)},Me=(s,t,e)=>{if(!t||!e)return;let r=t(e.state,s);r&&m.build(r,s,e)},Be=(s,t,e)=>{if(!t||!e)return;let r=e.state,n=t(r);if(!e.state){e.setStateHelper(n);return}e.addState(n)},Ne=(s,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let r=t[2];t[2]=n=>{r(n,e)}}e.events.on(...t)}};var He=(s,t,e)=>{let r,n,i;if(typeof t=="string"){if(r=D(e),!r)return;n=t}else if(Array.isArray(t)){if(typeof t[0]!="object"){let o=D(e);if(!o)return;t.unshift(o)}[r,n,i]=t}x.bind(s,r,n,i)};var Lt=(s,t,e)=>{ct(s,e.state,t,e)};var Le=s=>(t,e)=>{let[r,n,i="active"]=s,o=t===n?i:"";p.setData(e,r,o)},Re=(s,t,e)=>{if(!t)return;let r=[...t],n=r.pop();r.push(Le(n)),K(s,r,e)},Ie=(s,t,e)=>{if(!t)return;let r=[...t],n=r.pop();r.push(Le(n)),Lt(s,r,e)};var _e=(s,t,e)=>{let r,n,i,o;if(t.length<3){let c=D(e);if(!c)return;r=c,[n,i,o]=t}else[r,n,i,o]=t;let a=o!==!1;x.watch(s,r,n,c=>{if(m.removeAll(s),!c||c.length<1)return;let u=[];return c.forEach((d,y)=>{let b=a?r.scope(`${n}[${y}]`):null,k=i(c[y],y,b,u);k!==null&&u.push(k)}),m.build(u,s,e)})};var Ue=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let n=t[1],i=[];r.forEach((o,a)=>{if(!o)return;let c=n(o,a);c!==null&&i.push(c)}),m.build(i,s,e)};var je=(s,t,e)=>{t(s,e)};l.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var We=(s,t,e)=>{jr(s,t,e)},jr=(s,t,e)=>{l.add(s,"destroyed",{ele:s,callBack:t,parent:e})};var $e=(s,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(var r=0,n=t.length;r<n;r++)C.setup(s,t[r],e);else C.setup(s,t,e)};var Wr=0,Q=class{constructor(t){this.router=t,this.locationId="base-app-router-"+Wr++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}check(t){}getScrollPosition(){return{x:window.scrollX,y:window.scrollY}}scrollTo(t){window.scrollTo(t.x,t.y)}addEvent(){return this}};var Rt=class extends Q{addEvent(){return f.on("popstate",window,this.callBack),this}removeEvent(){return f.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let r=e.scrollPosition;r&&this.scrollTo(r)}createState(t,e={}){let r=this.getScrollPosition();return{location:this.locationId,...e,scrollPosition:r,uri:t}}addState(t,e,r=!1){let n=window.history,i=n.state;if(i&&i.uri===t)return this;let o=this.createState(t,e);return n[r===!1?"pushState":"replaceState"](o,null,t),this}};var It=class extends Q{addEvent(){return f.on("hashchange",window,this.callBack),this}removeEvent(){return f.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};var _t=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new Rt(t).setup():new It(t).setup()}};var Zt=class extends S{getChildScope(){return this.parent}},Fe=s=>_(s,Zt);var Ut=class{constructor(t,e){this.route=t,this.template=e.component,this.component=null,this.hasTemplate=!1,this.setup=!1,this.container=e.container,this.persist=e.persist,this.parent=e.parent}focus(t){this.setup===!1&&this.create(),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){let t=this.template();this.transferSettings(t)}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){this.template.isUnit||(this.template=new(Fe(this.template)));let t=this.template;this.transferSettings(t)}create(){if(this.setupTemplate(),!this.hasTemplate)return;this.setup=!0;let t=this.component;m.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return;this.setup=!1;let t=this.component;t&&(typeof t.destroy=="function"&&t.destroy(),this.component=null)}update(t){let e=this.component;e&&typeof e.update=="function"&&e.update(t)}};var Ve=s=>{if(!s.length)return null;let t={};return s.forEach(e=>{t[e]=null}),t},Je=s=>{let t=[];if(!s)return t;let e=/[*?]/g;s=s.replace(e,"");let r=/:(.[^./?&($]+)\?*/g,n=s.match(r);return n===null||n.forEach(i=>{i&&(i=i.replace(":",""),t.push(i))}),t};var $r=s=>s.replace(/\//g,"/"),Fr=s=>s.replace(/(\/):[^/(]*?\?/g,t=>t.replace(/\//g,"(?:$|/)")),Vr=s=>(s=s.replace(/(\?\/+\*?)/g,"?/*"),s.replace(/(:[^/?&($]+)/g,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),Jr=s=>s.replace(/(\*)/g,".*"),qr=(s,t)=>s+=t[t.length-1]==="*"?"":"$",qe=s=>{if(!s)return"";let t=$r(s);return t=Fr(t),t=Vr(t),t=Jr(t),t=qr(t,s),t};var zr=0,jt=class extends P{constructor(t,e){let r=t.baseUri,n=Je(r),i=Ve(n),o=super(i);return this.uri=r,this.paramKeys=n,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),o}setup(){this.stage={},this.id=null,this.uri=null,this.uriQuery=null,this.controller=null,this.paramKeys=null,this.titleCallBack=null,this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1}setupRoute(t){this.id=t.id||"bs-rte-"+zr++,this.path=null,this.referralPath=null;let e=qe(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1}setTitle(t){this.title=t,this.titleCallBack(this,t)}deactivate(){this.set("active",!1);let t=this.controller;t&&t.remove()}getLayout(t){if(t.component)return t.component;let e=t.import;return e?Kt(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:r,persist:n,parent:i}=t,o={component:e,container:r,persist:n,parent:i},a=wt(this);this.controller=new Ut(a,o)}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let n=this.path;if(!n)return;let i=n.split("#")[1];i&&this.scrollToId(i)}scrollToId(t){if(!t)return;let e=document.getElementById(t);e&&e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(Array.isArray(r)&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(!Array.isArray(t))return;let e=this.paramKeys;if(!e)return;let r={};e.forEach((n,i)=>{typeof n<"u"&&(r[n]=t[i])}),this.set(r)}getParams(){return this.stage}};var Yr=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},Gr=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(let[r,n]of Object.entries(e)){let i=new RegExp(":"+r,"gi");s=s.replace(i,n)}return s},Xr=(s,t)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=Gr(t,s),Yr(t)),Kr=(s,t)=>(t!==""&&(s+=" - "+t),s),ze=(s,t,e)=>t&&(t=Xr(s,t),Kr(t,e));var Ye={removeSlashes(s){return typeof s!="string"?"":(s.substring(0,1)==="/"&&(s=s.substring(1)),s.substring(-1)==="/"&&(s=s.substring(0,s.length-1)),s)}};var Ge=(s,t)=>({attr:s,value:t}),Qr=(s,t)=>new RegExp("^"+s+"($|#|/|\\.).*").test(t),Wt=class extends S{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",class:this.class||this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),nest:this.nest||this.children,dataStateSet:this.dataSet,watch:r}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact===!0,n=O.data,i=[];return t&&typeof t=="object"&&i.push(Ge("href",t)),e&&typeof e=="object"&&i.push(Ge("text",e)),i.push({value:["[[path]]",n],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.hash,u=r?o===c:Qr(a.pathname,o);this.update(u)}}),i}setupStates(){return{selected:!1}}update(t){this.state.selected=t}};var Zr=()=>typeof window<"u"?window.location:{},te=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=Zr(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new M({path:""})}setupHistory(){this.history=_t.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new jt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+Ye.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var n=0;n<r;n++){var i=e[n];if(i.uri===t)return i}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var n=0;n<r;n++){var i=e[n];if(i.id===t)return i}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);return t.forEach(n=>{if(!n)return;let i=this.createRoute(n);r.push(i)}),this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,n=this.getSwitchGroup(r);return t.forEach(i=>{let o=i.component.route;o.resume(e),n.push(o)}),this.checkGroup(n,this.getPath()),r}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let r=[];return this.switches.set(t,r),r}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.path=this.getPath(),this.callBackLink=this.checkLink.bind(this),f.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||p.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let n=this.baseURI,i=n!=="/"?r.replace(n,""):r;return this.navigate(i),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,r=t.length;e<r;e++){let n=t[e];n&&typeof n.deactivate=="function"&&n.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;document.title=ze(t,e,this.title)}checkActiveRoutes(t){this.lastPath=this.path,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,n;for(var i=0;i<r;i++)n=e[i],!(typeof n>"u")&&this.checkRoute(n,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){this.switches.forEach(r=>{this.checkGroup(r,t)})}checkGroup(t,e){if(!t.length)return;let r=t.find(o=>o.get("active"));r&&r.match(e)===!1&&r.deactivate();let n;for(let o of t){if(typeof o>"u")continue;if(n){o.deactivate();continue}o.match(e)!==!1&&n===void 0&&o.controller&&(n=o,this.select(o))}let i=t[0];n||this.select(i)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),t.preventScroll!==!0&&this.checkToScroll())}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),r=this.cleanPath(this.lastPath).split("/"),n=t.split("/");if(r.length!==n.length)return!0;let i=r[r.length-1],o=n[n.length-1];return i!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){f.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},O=new te;l.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&O.removeRoute(t)});var Ke=(s,t,e)=>{t&&(Array.isArray(t)?t.forEach(r=>{r&&Xe(s,r,e)}):Xe(s,t,e))},Xe=(s,t,e)=>{t.container=s,t.parent=e;let r=O.add(t);ts(s,r)},ts=(s,t)=>{l.add(s,"routes",{route:t})};var Qe=(s,t,e)=>{};l.addType("switch",s=>{if(!s)return!1;let t=s.id;O.removeSwitch(t)});var Ze=(s,t,e)=>{let r=t[0];t.forEach(i=>{i&&(i.container=s,i.parent=e)});let n=O.addSwitch(t);es(s,n)},es=(s,t)=>{l.add(s,"switch",{id:t})};q.add("cache",De).add("onCreated",je).add("onDestroyed",We).add("bind",He).add("data",Ae).add("state",Qe).add("onSet",K).add("onState",Lt).add("animateIn",ye).add("animateOut",be).add("watch",$e).add("useParent",Ee).add("useData",Pe).add("useState",Me).add("getId",Oe).add("addState",Be).add("addEvent",Ne).add("map",Ue).add("for",_e).add("useContext",we).add("addContext",Ce).add("context",ke).add("role",xe).add("aria",ve).add("route",Ke).add("debug",Te).add("dataSet",Re).add("dataStateSet",Ie).add("switch",Ze);T.augment({Ajax:ft,Html:A,dataBinder:x,Data:M,SimpleData:I,Model:V,State:J,Builder:m,router:O,Component:S});export{ft as Ajax,N as Arrays,hr as Atom,m as Builder,S as Component,M as Data,l as DataTracker,wr as DateTime,q as Directives,p as Dom,ot as Encode,Ft as Events,A as Html,Kt as Import,_ as Jot,V as Model,Wt as NavLink,g as Objects,kr as Pod,I as SimpleData,J as State,B as Store,v as Strings,h as Types,at as Unit,T as base,x as dataBinder,O as router};
2
2
  //# sourceMappingURL=base.js.map