@base-framework/base 3.7.84 → 3.7.85

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 st=class{static toArray(t){return Array.from(t)}static inArray(t,e,s){return Array.isArray(t)?t.indexOf(e,s):-1}};var xs=Object.prototype.toString,yt=Object.prototype.hasOwnProperty,b={create(r){return Object.create(r||null)},extendObject(r,t){if(!r||typeof r!="object"||!t||typeof t!="object")return!1;for(let e in r)yt.call(r,e)&&!yt.call(t,e)&&(t[e]=r[e]);return t},clone(r){if(!r||typeof r!="object")return{};try{return structuredClone(r)}catch{return JSON.parse(JSON.stringify(r))}},getClassObject(r){return typeof r=="function"?r.prototype:r},extendClass(r,t){let e=this.getClassObject(r),s=this.getClassObject(t);if(typeof e!="object"||typeof s!="object")return!1;let n=Object.create(e);for(let i in s)n[i]=s[i];return n},hasOwnProp(r,t){return yt.call(r,t)},isPlainObject(r){return!!r&&xs.call(r)==="[object Object]"},isEmpty(r){if(!r||typeof r!="object"||Array.isArray(r))return!0;for(let t in r)if(yt.call(r,t))return!1;return!0}};var S=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 rt={types:{},add(r,t){this.types[r]=t},get(r){return this.types[r]||!1},remove(r){delete this.types[r]}};var bt=class{constructor(){this.types=new Map}add(t,e){let s=this.types.get(t);s||(s=[],this.types.set(t,s)),s.push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeType(t){let e=this.types.get(t);if(!e||!e.length)return;let s,n=rt.get(t);if(n){for(let i=0,o=e.length;i<o;i++)s=e[i],s&&(e[i]=null,typeof n=="function"&&n(s));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}let e=this.types.keys();for(let s of e)s&&this.removeType(s);this.types.clear()}};var W=new WeakMap,p=class{static trackers=new Map;static trackingCount=0;static addType(t,e){rt.add(t,e)}static removeType(t){rt.remove(t)}static getTrackingId(t){if(!t||typeof t!="object")return"";let e=W.get(t);return e||(e="dt"+this.trackingCount++,W.set(t,e)),e}static add(t,e,s){let n=this.getTrackingId(t);this.find(n).add(e,s)}static get(t,e){let s=W.get(t),n=this.trackers.get(s);return n?e?n.get(e):n:!1}static has(t,e){let s=this.getTrackingId(t);if(!s)return!1;let n=this.trackers.get(s);return n&&e?n.has(e):!1}static find(t){let e=this.trackers.get(t);return e||(e=new bt,this.trackers.set(t,e)),e}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let s=W.get(t);if(!s)return;let n=this.trackers.get(s);if(n){if(!e){n.remove(),this.trackers.delete(s),W.delete(t);return}n.remove(e),this.isEmpty(n.types)&&(this.trackers.delete(s),W.delete(t))}}};var f={getEvents(r){return typeof r!="object"||r===null?[]:p.get(r,"events")},create(r,t,e,s=!1,n=!1,i=null){return{event:r,obj:t,fn:e,capture:s,swapped:n,originalFn:i}},on(r,t,e,s){if(Array.isArray(r))for(let n=0,i=r.length;n<i;n++)this.add(r[n],t,e,s);else this.add(r,t,e,s);return this},off(r,t,e,s){if(Array.isArray(r))for(let n=0,i=r.length;n<i;n++)this.remove(r[n],t,e,s);else this.remove(r,t,e,s);return this},add(r,t,e,s=!1,n=!1,i=null){if(typeof t!="object"||t===null)return this;let o=this.create(r,t,e,s,n,i);return p.add(t,"events",o),t.addEventListener(r,e,s),this},remove(r,t,e,s=!1){let n=this.getEvent(r,t,e,s);return n===!1?this:(typeof n=="object"&&this.removeEvent(n),this)},removeEvent(r){return typeof r=="object"&&r.obj.removeEventListener(r.event,r.fn,r.capture),this},getEvent(r,t,e,s){if(typeof t!="object")return!1;let n=this.getEvents(t);if(!n||n.length<1)return!1;let i=this.create(r,t,e,s);return this.search(i,n)},search(r,t){let e,s=this.isSwappable(r.event);for(let n=0,i=t.length;n<i;n++)if(e=t[n],!(e.event!==r.event||e.obj!==r.obj)&&(e.fn===r.fn||s===!0&&e.originalFn===r.fn))return e;return!1},removeEvents(r){return typeof r!="object"||r===null?this:(p.remove(r,"events"),this)},swap:new Set(["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"]),addSwapped(r){this.swap.add(r)},isSwappable(r){return this.swap.has(r)}};p.addType("events",r=>{f.removeEvent(r)});var ae={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},oe=Object.keys(ae),Ss={events:f,addListener(r,t,e,s){return this.events.add(r,t,e,s),this},on(r,t,e,s){let n=this.events;if(Array.isArray(r))for(let i=0,o=r.length;i<o;i++)n.add(r[i],t,e,s);else n.add(r,t,e,s);return this},off(r,t,e,s){let n=this.events;if(Array.isArray(r))for(let i=0,o=r.length;i<o;i++)n.remove(r[i],t,e,s);else n.remove(r,t,e,s);return this},removeListener(r,t,e,s){return this.events.remove(r,t,e,s),this},_createEvent(r,t,e,s){let n;switch(t){case"HTMLEvents":n=new Event(r,e);break;case"MouseEvents":n=new MouseEvent(r,e);break;default:n=new CustomEvent(r,s);break}return n},createEvent(r,t,e,s){if(typeof t!="object"||t===null)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};typeof e=="object"&&e!==null&&(n=Object.assign(n,e));let i=this._getEventType(r);return this._createEvent(r,i,n,s)},_getEventType(r){for(let t=0,e=oe.length;t<e;t++){let s=oe[t];if(ae[s].test(r))return s}return"CustomEvent"},trigger(r,t,e){if(typeof t!="object"||t===null)return this;let s=typeof r=="string"?this.createEvent(r,t,null,e):r;return t.dispatchEvent(s),this},mouseWheelEventType:null,getWheelEventType(){let r=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=r())},onMouseWheel(r,t,e,s=!1){typeof t>"u"&&(t=window);let n=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof r=="function"&&r(a,o),e===!0&&o.preventDefault()},i=this.getWheelEventType();return this.events.add(i,t,n,s,!0,r),this},offMouseWheel(r,t,e=!1){typeof t>"u"&&(t=window);let s=this.getWheelEventType();return this.off(s,t,r,e),this},preventDefault(r){return typeof r.preventDefault=="function"?r.preventDefault():r.returnValue=!1,this},stopPropagation(r){return typeof r.stopPropagation=="function"?r.stopPropagation():r.cancelBubble=!0,this}};var nt=class{constructor(){this.errors=[],this.dataTracker=p}augment(t){if(!S.isObject(t))return this;let e=this.constructor.prototype;for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return this}override(t,e,s,n){return(t[e]=s).apply(t,st.toArray(n))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,s){if(S.isObject(t)===!1)return"";let n=t[e];return typeof n<"u"?n:typeof s<"u"?s:""}createCallBack(t,e,s=[],n=!1){return typeof e!="function"?!1:(...i)=>(n===!0&&(s=s.concat(i)),e.apply(t,s))}bind(t,e){return e.bind(t)}};nt.prototype.extend=(function(){return nt.prototype})();var R=new nt;var it={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 ce=()=>{R.augment({xhrSettings:it,addFixedParams(r){this.xhrSettings.fixedParams=r},beforeSend(r){this.xhrSettings.beforeSend.push(r)},ajaxSettings(r){typeof r=="object"&&(this.xhrSettings=b.extendClass(R.xhrSettings,r))},resetAjaxSettings(){this.xhrSettings=it}})};var w=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,s=!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,s=>s[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let s=/([A-Z]{1,})/g;return t.replace(s,n=>e+n.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,s=>s.charAt(0).toUpperCase()+s.substring(1).toLowerCase())}};var xt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:s,url:n,async:i}=this.settings;e.open(s,n,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=it.beforeSend;if(t.length<1)return;let e=this.xhr,s=this.settings;for(var n=0,i=t.length;n<i;n++){var o=t[n];o&&o(e,s)}}objectToString(t){let e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.push(s+"="+encodeURIComponent(t[s]));return e.join("&")}setupParams(t,e=null){let s=typeof t;if(!e)return!(t instanceof FormData)&&s==="object"&&(t=this.objectToString(t)),t;let n=typeof e;if(s==="string")return n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(n==="string"&&(e=w.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else s==="object"&&(t=b.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,s=t.params;return s?s=this.setupParams(s,e):e&&(s=this.setupParams(e)),s}getXhrSettings(t){let e=this.settings={...R.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var s=0,n=t.length;s<n;s++){var i=t[s];switch(s){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=b.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 s in e)Object.prototype.hasOwnProperty.call(e,s)&&this.xhr?.setRequestHeader(s,e[s])}update(t,e){let s=this.xhr,n=()=>{f.removeEvents(s?.upload),f.removeEvents(s)},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;if(!t)return null;let e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr;if(!e)return;let s=this.update.bind(this);f.on(["load","error","abort"],e,s),f.on("progress",e.upload,s)}};ce();var zt=(...r)=>new xt(r).xhr;var ws=r=>typeof r!="string"?r:ue(r),ue=r=>[{tag:"text",textContent:r}],le=()=>({props:{},children:[]}),he=r=>({props:{},children:ue(r)}),fe=r=>({props:{},children:r}),de=r=>({props:r[0]||{},children:ws(r[1])});var St=class{constructor(){this.connections=new Map}add(t,e,s){let n=this.getOrCreate(t),i=n.get(e);return i?Array.isArray(i)?i.push(s):n.set(e,[i,s]):n.set(e,s),s}get(t,e){let s=this.connections.get(t)?.get(e);return s?Array.isArray(s)?s[s.length-1]||!1:s:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let s=this.connections.get(t);if(s)if(e)this.unsubscribe(s.get(e)),s.delete(e),s.size===0&&this.connections.delete(t);else{for(let n of s.values())this.unsubscribe(n);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var q=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var wt=class extends q{constructor(t){super(),this.data=t}subscribe(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribe - data source is null or does not have an "on" method. Make sure your component has data, state, or context.data initialized.',t,this.data);return}this.msg=t,this.token=this.data.on(t,e)}subscribeMany(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribeMany - data source is null or does not have an "on" method.',t,this.data);return}let s=t.length,n=new Array(s);for(let i=0;i<s;i++){let o=t[i];n[i]={msg:o,token:this.data.on(o,e)}}this.subscriptions=n}unsubscribe(){if(this.data){let t=this.subscriptions;if(t){for(let e=0,s=t.length;e<s;e++)this.data.off(t[e].msg,t[e].token);this.subscriptions=null}else this.msg&&this.token&&this.data.off(this.msg,this.token)}this.data=null,this.msg=null,this.token=null}};var V=class{unsubscribe(){}};var ot=class extends V{constructor(){super(),this.source=null}addSource(t){return this.source=new wt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var G=class extends q{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 kt=class extends G{constructor(t,e,s){super(s),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 z=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?Array.from(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let s=document.querySelectorAll(t);return s?s.length===1?s[0]:Array.from(s):!1}static html(t,e){return!t||typeof t!="object"?!1:typeof e<"u"?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,s){return!t||typeof t!="object"||typeof e>"u"?this:(e=w.uncamelCase(e),t.style[e]=s,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=w.uncamelCase(e);let s=t.style[e];if(s!=="")return s;let n=null,i=t.currentStyle;if(i&&(n=i[e]))return n;let o=window.getComputedStyle(t,null);return o?o[e]:s}static css(t,e,s){return typeof s<"u"?(this.setCss(t,e,s),this):this.getCss(t,e)}static removeAttr(t,e){return typeof t=="object"&&t!==null&&t.removeAttribute(e),this}static setAttr(t,e,s){t.setAttribute(e,s)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,s){return!t||typeof t!="object"?!1:typeof s<"u"?(this.setAttr(t,e,s),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=w.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,s){e=this.removeDataPrefix(e),e=w.camelCase(e),t.dataset[e]=s}static getData(t,e){return e=w.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,s){return!t||typeof t!="object"?!1:typeof s<"u"?(this.setData(t,e,s),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(!t||typeof t!="object")return this;let e=this.data(t,"style-display"),s=typeof e=="string"?e:"";return this.css(t,"display",s),this}static hide(t){if(!t||typeof t!="object")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!t||typeof t!="object"?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return!t||typeof t!="object"?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return typeof t=="object"&&t!==null?t.offsetWidth:!1}static getHeight(t){return typeof t=="object"&&t!==null?t.offsetHeight:!1}static getScrollPosition(t){let e=0,s=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,s=t.scrollTop;break;case"object":e=t.scrollLeft,s=t.scrollTop;break}return!t||typeof t!="object"?!1:{left:e-(t.clientLeft||0),top:s-(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,s=e.documentElement,n=e.getElementsByTagName("body")[0],i=t.innerWidth||s.clientWidth||n.clientWidth,o=t.innerHeight||s.clientHeight||n.clientHeight;return{width:i,height:o}}static getDocumentSize(){let t=document,e=t.body,s=t.documentElement,n=Math.max(e.scrollHeight,e.offsetHeight,s.clientHeight,s.scrollHeight,s.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,s.clientWidth,s.scrollWidth,s.offsetWidth),height:n}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let s={x:0,y:0};if(!t||typeof t!="object")return s;let n=0;for(;t&&(e===0||n<e);)n++,s.x+=t.offsetLeft+t.clientLeft,s.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return s}static addClass(t,e){if(!t||typeof t!="object"||e==="")return this;if(typeof e=="string"){let s=e.split(" ");for(let n=0,i=s.length;n<i;n++)t.classList.add(s[n])}return this}static removeClass(t,e){return!t||typeof t!="object"||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return!t||typeof t!="object"||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return!t||typeof t!="object"?this:(t.classList.toggle(e),this)}};var vt=r=>{let t="textContent";if(!r||typeof r!="object")return t;let e=r.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let s=r.type;if(!s)return t="value",t;switch(s){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var ks=(r,t,e)=>{z.setAttr(r,t,e)},vs=(r,t,e)=>{r.checked=r.value==e},Cs=(r,t,e)=>{e=e==1,pe(r,t,e)},pe=(r,t,e)=>{r[t]=e},Ts=(r,t)=>z.getAttr(r,t),As=(r,t)=>r[t],Ct=class extends G{constructor(t,e,s,n){super(n),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof s=="string"?this.setupFilter(s):s}addSetMethod(t,e){if(e.charAt(4)==="-")return this.setValue=ks,this.getValue=Ts,this;this.getValue=As;let s=t.type;if(s)switch(s){case"checkbox":return this.setValue=Cs,this;case"radio":return this.setValue=vs,this}return this.setValue=pe,this}getAttrBind(t){return t||vt(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return s=>t.replace(e,s)}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={},this.attr="",this.filter=null,this.setValue=null,this.getValue=null}};var Tt=class extends V{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,s){return this.element=new Ct(t,e,s,this.pubSub)}addData(t,e){return this.data=new kt(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 me=-1,$=class{constructor(){this.callBacks=new Map,this.updateQueue=new Map,this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this.maxFlushIterations=2e3,this.batchingEnabled=!0,this.debugMode=!1,this.flushCompleteResolvers=[],this.flushCallbacks=[]}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,me=-1}on(t,e){let s=(++me).toString();return this.get(t).set(s,e),s}off(t,e){let s=this.callBacks.get(t);s&&(e=String(e),s.delete(e),s.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,e,s){if(!this.batchingEnabled){this.publishImmediate(t,e,s);return}this.updateQueue.set(t,[e,s]),this.debugMode&&console.log("[DataPubSub] Queued update:",t,e),this.scheduleFlush()}scheduleFlush(){this.isFlushing||this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){if(this.updateQueue.size===0){this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete();return}if(this.isFlushing||(this.flushIterations=0),this.isFlushing=!0,this.flushScheduled=!1,this.flushIterations++,this.flushIterations>this.maxFlushIterations){console.error("[DataPubSub] Infinite loop detected! Flush iterations exceeded",this.maxFlushIterations,"- Breaking to prevent memory exhaustion."),console.error("[DataPubSub] Queue size:",this.updateQueue.size),console.error("[DataPubSub] Queued messages:",Array.from(this.updateQueue.keys())),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this._resolveFlushComplete(),this.flushIterations=0;return}this.debugMode&&console.log("[DataPubSub] Flushing",this.updateQueue.size,"updates (iteration",this.flushIterations+")");let t=this.updateQueue;this.updateQueue=new Map;try{for(let[e,s]of t)this.publishImmediate(e,s[0],s[1])}finally{this.debugMode&&console.log("[DataPubSub] Flush complete (iteration",this.flushIterations+")"),this.updateQueue.size>0?(this.debugMode&&console.log("[DataPubSub] New updates queued during flush, re-flushing..."),this.flush()):(this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete())}}_resolveFlushComplete(){if(this.flushCompleteResolvers.length>0){let t=this.flushCompleteResolvers;this.flushCompleteResolvers=[];let e=t.length;for(let s=0;s<e;s++)t[s]()}if(this.flushCallbacks.length>0){let t=this.flushCallbacks;this.flushCallbacks=[];let e=t.length;for(let s=0;s<e;s++)t[s]()}}nextFlush(){return new Promise(t=>{this.flushCompleteResolvers.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>t())})}onFlush(t){if(typeof t!="function"){console.warn("[DataPubSub] onFlush requires a function callback");return}this.flushCallbacks.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>{if(this.flushCallbacks.length>0){let e=this.flushCallbacks;this.flushCallbacks=[];let s=e.length;for(let n=0;n<s;n++)e[n]()}})}flushSync(){this.flush()}publishImmediate(t,e,s){let n=this.callBacks.get(t);if(n){for(let i of n.values())if(i)try{i(e,s)}catch(o){console.error('[DataPubSub] Subscriber error for "'+t+'":',o)}}}};var $t=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=new Set([20,37,38,39,40]),this.connections=new St,this.pubSub=new $,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,s,n){let i=s,o=null,a=s.indexOf(":");a!==-1&&(o=s.substring(0,a),i=s.substring(a+1));let c=o??"",u=this.setupConnection(t,e,i,c,n),l=u.element,h=e.get(i);return typeof h<"u"?l.set(h):(h=l.get(),h!==""&&u.data.set(h)),this}setupConnection(t,e,s,n,i){let o=this.getBindId(t),a=new Tt(this.pubSub);a.addData(e,s).subscribe(o);let l=`${e.getDataId()}:${s}`;return a.addElement(t,n,i).subscribe(l),this.addConnection(o,"bind",a),a}addConnection(t,e,s){return this.connections.add(t,e,s),this}setBindId(t){let e="db-"+this.idCount++;return 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,s,n){if(S.isObject(t)===!1)return this;let i=new ot,o=e.get(s),a=!0,c=g=>{a&&(a=!1,g===o)||n(g)};i.addSource(e).subscribe(s,c);let l=this.getBindId(t),h=e.getDataId()+":"+s;return this.addConnection(l,h,i),n(o),this}watchMany(t,e,s,n){if(S.isObject(t)===!1)return this;let i=s?s.length:0;if(i===0)return this;if(i===1)return this.watch(t,e,s[0],n);let o=new ot,a=o.addSource(e),c=new Array(i),u=new Array(i);for(let d=0;d<i;d++)c[d]=e.get(s[d]),u[d]=!0;let l=new Array(i);for(let d=0;d<i;d++){let C=d,E=c[d];l[d]=gt=>{u[C]&&(u[C]=!1,gt===E)||n(gt)}}if(typeof e.on!="function")return console.warn('DataBinder.watchMany: data source has no "on" method.',e),this;let h=new Array(i);for(let d=0;d<i;d++)h[d]={msg:s[d],token:e.on(s[d],l[d])};a.subscriptions=h;let g=this.getBindId(t),y=e.getDataId()+":"+s.join(",");return this.addConnection(g,y,o),n(c[0]),this}unwatch(t,e,s){if(S.isObject(t)===!1)return this;let n=t[this.attr];if(n){let i=e.getDataId()+":"+s;this.connections.remove(n,i)}return this}publish(t,e,s){return this.pubSub.publish(t,e,s),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.has(t.keyCode)}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,s=this.isDataBound(e);if(s!==null){let n=this.connections.get(s,"bind");if(n){let i=n.element.get();this.pubSub.publish(s,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 $t;var A=r=>r.data?r.data:r.context&&r.context.data?r.context.data:r.state?r.state:null;var Ds=new Map([["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"]]),at=r=>Ds.get(r)||r,ct=r=>typeof r=="string"&&r.charCodeAt(0)===111&&r.charCodeAt(1)===110?r.substring(2):r,Ps=/(?:<[a-z][\s\S]*>)/i,D=class{static create(t,e,s,n){let i=document.createElement(t);return this.addAttributes(i,e),n===!0?this.prepend(s,i):this.append(s,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return;let s=e.type;s!==void 0&&t.setAttribute("type",s);let n=Object.keys(e);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=e[a];a==="innerHTML"?t.innerHTML=c:a.indexOf("-")!==-1?t.setAttribute(a,c):this.addAttr(t,a,c)}}static addHtml(t,e){return typeof e>"u"||e===""?this:(Ps.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,s){if(s===""||!e)return;if(typeof s==="function")e=ct(e),s.originalCallback?f.add(e,t,s,!1,!0,s.originalCallback):f.add(e,t,s);else{let i=at(e);t[i]=s}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let s=document.createTextNode(t);return e&&this.append(e,s),s}static createComment(t,e){let s=document.createComment(t);return e&&this.append(e,s),s}static setupSelectOptions(t,e,s){if(!t||typeof t!="object"||!Array.isArray(e))return!1;e.forEach(n=>{let i=new Option(n.label,n.value);t.options.add(i),s!==null&&i.value==s&&(i.selected=!0)})}static removeElementData(t){let e=[t];for(;e.length>0;){let s=e.pop(),n=s.childNodes;if(n&&n.length>0)for(let i=n.length-1;i>=0;i--)e.push(n[i]);p.remove(s),s.bindId&&x.unbind(s)}}static removeElement(t){if(!t)return this;let e=p.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(!t||typeof t!="object")return this;let e;for(;e=t.firstChild;)this.removeElementData(e),t.removeChild(e);return this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,s){let n=s||t.firstChild;return t.insertBefore(e,n),this}static clone(t,e=!1){return!t||typeof t!="object"?!1:t.cloneNode(e)}};var k=class extends D{static create(t,e,s,n){let i=document.createElement(t);return this.addAttributes(i,e,n),s.appendChild(i),i}static addAttributes(t,e,s){if(!(!e||e.length<1))for(let n=0,i=e.length;n<i;n++){let o=e[n];this.addAttr(t,o.key,o.value,s)}}static addAttr(t,e,s,n){if(s===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=s;return}if(typeof s==="function"){if(e=ct(e),s.originalCallback)f.add(e,t,s,!1,!0,s.originalCallback);else{let a=s,c=function(u){a.call(this,u,n)};f.add(e,t,c,!1,!0,a)}return}if(e.charCodeAt(4)===45){t.setAttribute(e,s);return}let o=at(e);t[o]=s}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 ge=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,ye=new Map,T={isWatching(r){if(Array.isArray(r)){let t=r[0];return typeof t=="string"&&t.includes("[[")}return this.hasParams(r)},hasParams(r){return typeof r=="string"&&r.includes("[[")},_getWatcherProps(r){let t=ye.get(r);if(t!==void 0)return t;let e=r.match(ge),s=e?e.map(n=>n.slice(2,-2)):null;return ye.set(r,s),s},updateAttr(r,t,e){switch(t){case"text":case"textContent":r.textContent=e;break;case"disabled":r.disabled=!e;break;case"checked":r.checked=!!e;break;case"required":r.required=!!e;break;case"src":if(r.tagName==="IMG"){r.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}r.src=e;break;default:k.addAttr(r,t,e);break}},replaceParams(r,t,e=!1){let s=0;return r.replace(ge,function(n,i,o){let a=e?t[s]:t;s++;let c=a.get(o);return c??""})},_getWatcherCallBack(r,t,e,s,n){return()=>{let i=this.replaceParams(e,t,n);this.updateAttr(r,s,i)}},getValue(r,t){let e=r.value;return Array.isArray(e)===!1?[e,A(t)]:(e.length<2&&e.push(A(t)),e)},getPropValues(r,t,e){let s=[];for(let n=0,i=t.length;n<i;n++){let a=(e?r[n]:r).get(t[n])??"";s.push(a)}return s},getCallBack(r,t,e,s,n,i){let o=r.attr||"textContent",a=r.callBack;if(typeof a=="function"){let c=i||this._getWatcherProps(s)||[],u=c.length>1;return(l,h)=>{l=u!==!0?l:this.getPropValues(e,c,n);let g=a(l,t,h);typeof g<"u"&&this.updateAttr(t,o,g)}}return this._getWatcherCallBack(t,e,s,o,n)},addDataWatcher(r,t,e){let s=this.getValue(t,e),n=s[1]??e?.data??e?.context?.data??e?.state??null;if(!n)return;let i=s[0],o=Array.isArray(n),a=this._getWatcherProps(i),c=this.getCallBack(t,r,n,i,o,a);if(!o)a.length>1?x.watchMany(r,n,a,c):this.addWatcher(r,n,a[0],c);else for(let u=0,l=a.length;u<l;u++)this.addWatcher(r,n[u],a[u],c)},getWatcherSettings(r,t=null){if(typeof r=="string")return{attr:t,value:r};if(Array.isArray(r)){let e=r[r.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let s=r[1]&&typeof r[1]=="object"?[r[0],r[1]]:[r[0]];return typeof e=="function"?{attr:t,value:s,callBack:e}:{attr:e||"textContent",value:s}}return r},setup(r,t,e){t&&this.addDataWatcher(r,this.getWatcherSettings(t),e)},addWatcher(r,t,e,s){x.watch(r,t,e,s)}};var Es=r=>({props:{watch:r},children:[]}),Ms=r=>{if(r.length===0)return le();let t=r[0],e=typeof t;if(e==="string"||e==="number")return he(t);if(Array.isArray(t))return T.isWatching(t)?Es(t):fe(t);let s=r[1]??r[0]??[];return s&&Array.isArray(s)&&T.isWatching(s)&&(r[0]=Array.isArray(r[0])?{}:r[0],r[0].watch=s,r[1]=[]),de(r)},Is=r=>(...t)=>{let{props:e,children:s}=Ms(t);return r(e,s)};var be=new WeakMap,jt=new WeakMap;function we(r){if(!r||typeof r!="object")return r;let t=jt.get(r);return t!==void 0?t:r}var xe=new WeakMap;function Os(r,t,e,s){let n=be.get(r);n||(n=new Map,be.set(r,n));let i=n.get(e);if(i)return i;let o=new Proxy(r,ke(t,e,s));return n.set(e,o),jt.set(o,r),o}function Se(r,t){let e=t.charCodeAt(0),s=e>=48&&e<=57;return r===""?s?"["+t+"]":t:s?r+"["+t+"]":r+"."+t}function ke(r,t="",e=""){return{get(s,n,i){let o=s[n];if(t===""&&n in s){if(typeof o=="function"){let c=xe.get(s);c||(c=new Map,xe.set(s,c));let u=c.get(n);if(u)return u;let l=o.bind(s);return c.set(n,l),l}return o}if(o=(s[e]||s)[n],o!==null&&typeof o=="object"){let c=Se(t,n);return Os(o,r,c,e)}return o},set(s,n,i,o){if(t===""&&n in s)return s[n]=i,!0;let a=Se(t,n);return r.set(a,i),!0}}}var At=(r,t="stage")=>{let e=new Proxy(r,ke(r,"",t));return jt.set(e,r),e};var ut=class{static resume(t,e){if(!t)return null;let s,n=localStorage.getItem(t);return n===null?e&&(s=e):s=JSON.parse(n),s}static store(t,e){if(!t||!e)return!1;let s=JSON.stringify(e);return localStorage.setItem(t,s),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var Dt=(r={})=>{let t={};if(!S.isObject(r))return t;let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i];typeof o!="function"&&(t[i]=o)}return t};var _s=0,ve=new Map,H={CHANGE:"change",DELETE:"delete"},Qt=(r,t)=>{let e=ve.get(r);return e||(e={change:`${r}:change`,delete:`${r}:delete`},ve.set(r,e)),t==="change"?e.change:e.delete},M=class{constructor(t={}){this.dirty=!1,this._retainState=!1,this._refreshState=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new $;let e=Dt(t);this.set(e);let s=At(this);return this._proxy=s,s}retainState(){return this._retainState=!0,this._proxy||this}refreshState(){return this._refreshState=!0,this._proxy||this}setup(){this.stage={}}_init(){let t=++_s;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}onFlush(t){this.eventSub.onFlush(t)}flushPending(){this.eventSub.flush()}getDataId(){return String(this._id)}remove(){}on(t,e){let s=Qt(t,H.CHANGE);return this.eventSub.on(s,e)}off(t,e){let s=Qt(t,H.CHANGE);this.eventSub.off(s,e)}_setAttr(t,e,s=this,n=!1){let i=this.stage[t];e!==i&&(this.stage[t]=e,this._publish(t,e,s,H.CHANGE))}publishLocalEvent(t,e,s,n){let i=Qt(t,n);this.eventSub.publish(i,e,s)}_publish(t,e,s,n){this.publishLocalEvent(t,e,s,n),s=s||this,x.publish(this._dataId+t,e,s)}set(t,e,s){if(typeof t!="object")return this._setAttr(t,e,s),this;let n=Object.keys(t);for(let i=0;i<n.length;i++){let o=n[i],a=t[o];typeof a!="function"&&this._setAttr(o,a,e,s)}return this}_silentSet(t){let e=this.stage,s=Object.keys(t);for(let n=0,i=s.length;n<i;n++){let o=s[n];e[o]=t[o]}}getModelData(){return this.stage}_deleteAttr(t,e,s=this){delete t[e],this.publishLocalEvent(e,null,s,H.DELETE)}toggle(t){return typeof t>"u"?this:(this.set(t,!this.get(t)),this)}increment(t,e=null){if(typeof t>"u")return this;e=e!==null&&typeof e=="number"?e:1;let s=this.get(t);return this.set(t,s+e),this}decrement(t,e=null){if(typeof t>"u")return this;e=e!==null&&typeof e=="number"?e:1;let s=this.get(t);return this.set(t,s-e),this}concat(t,e){if(typeof t>"u")return this;let s=this.get(t);return this.set(t,s+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=ut.resume(String(this.key),t);return e?(this.set(e),this):this}store(){let t=this.get();return ut.store(String(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,s){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,s);let n=[];return Object.entries(e).forEach(([i])=>{n.push(this.remoteLink(t,i))}),n}remoteLink(t,e,s){let n=s||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;b.isEmpty(e)||(e.forEach((s,n)=>{this.removeLink(n,!1)}),this.links=new Map)}removeLink(t,e=!0){let s=this.links.get(t);s&&s.off(t),e!==!1&&this.links.delete(t)}};M.prototype.isData=!0;var Yt=class{constructor(t=1e3){this.cache=new Map,this.maxSize=t}get(t){return this.cache.get(t)}set(t,e){if(this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.maxSize){let s=this.cache.keys().next().value;this.cache.delete(s)}}clear(){this.cache.clear()}},P={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,segmentCache:new Yt(1e3),hasDeepData(r){return r.indexOf(".")!==-1||r.indexOf("[")!==-1},getSegments(r){let t=this.segmentCache.get(r);if(t!==void 0)return t;let e=this.deepDataPattern;return t=r.match(e),this.segmentCache.set(r,t),t}};var N=class{static set(t,e,s){if(!P.hasDeepData(e)){t[e]=s;return}let n,i=P.getSegments(e);if(!i)return;let o=i.length,a=o-1;for(let c=0;c<o;c++){let u=i[c];if(c===a){t[u]=s;break}if(t[u]===void 0){let l=u.charCodeAt(0);t[u]=l<48||l>57?{}:[]}t=t[u]}}static delete(t,e){if(!P.hasDeepData(e)){delete t[e];return}let s=P.getSegments(e);if(!s)return;let n=s.length,i=n-1;for(let o=0;o<n;o++){let a=s[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(!P.hasDeepData(e))return t[e]??void 0;let s=P.getSegments(e);if(!s)return;let n=s.length,i=n-1;for(let o=0;o<n;o++){let a=s[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===i)return t}}};var Ce=new Set,lt=class{static MAX_DEPTH=50;static publishDeep(t,e,s,n){if(!P.hasDeepData(e)){this.publish(e,s,n);return}let i,o=P.getSegments(e);if(!o)return;let a=o.length,c=a-1,u="";for(let l=0;l<a;l++){let h=o[l];t=t[h];let g=h.charCodeAt(0);l>0?(g<48||g>57)&&(u+="."+h):u=h;let y;if(l===c)y=s;else{let d=o[l+1],C=d.charCodeAt(0);if(C>=48&&C<=57){u+="["+d+"]";continue}let E={};E[d]=t[d],y=E}this.publish(u,y,n)}}static publish(t,e,s,n=null,i=0){if(t=t||"",s(t,e),!(!e||typeof e!="object"||(e=we(e),n===null&&(Ce.clear(),n=Ce),!n))){if(n.has(e)){console.warn("[Publisher] Circular reference detected at path:",t);return}if(i>=this.MAX_DEPTH){console.warn("[Publisher] Max depth exceeded at path:",t,"- stopping recursion");return}n.add(e),Array.isArray(e)?this.publishArray(t,e,s,n,i):this.publishObject(t,e,s,n,i)}}static publishArray(t,e,s,n,i){let o=e.length;for(let a=0;a<o;a++){let c=e[a],u=t+"["+a+"]";this._checkPublish(u,c,s,n,i)}}static publishObject(t,e,s,n,i){let o=Object.keys(e);for(let a=0,c=o.length;a<c;a++){let u=o[a],l=e[u],h=t+"."+u;this._checkPublish(h,l,s,n,i)}}static _checkPublish(t,e,s,n,i){if(!e||typeof e!="object"){s(t,e);return}this.publish(t,e,s,n,i+1)}};var B=class extends M{setup(){this.attributes={},this.stage={}}_setAttr(t,e,s,n){typeof e!="object"&&e===this.get(t)||(!s&&n!==!0?N.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),N.set(this.stage,t,e),s=s||this,this._publish(t,e,s,H.CHANGE))}_silentSet(t){let e=this.stage,s=this.attributes,n=Object.keys(t);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=t[a];e[a]=c,s[a]=c}}linkAttr(t,e){let s=t.get(e);if(!s)return;let n=Object.keys(s);for(let i=0,o=n.length;i<o;i++){let a=n[i];this.link(t,e+"."+a,a)}}scope(t,e){let s=this.get(t);if(!s)return!1;e=e||this.constructor;let n=new e(s);return n.linkAttr(this,t),n}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s.push(e),this.set(t,s),this}concat(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s=s.concat(e),this.set(t,s),this}unshift(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s.unshift(e),this.set(t,s),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let s=e.shift();return this.set(t,e),s}getIndex(t,e,s){let n=this.get(t);return Array.isArray(n)===!1?-1:typeof n[0]!="object"?n.indexOf(e):n.findIndex(o=>o[e]===s)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let s=e.pop();return this.set(t,e),s}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,s,n){this._pubCommitter=s,this._pubEvent=n;let i=this._publishCb||(this._publishCb=(o,a)=>this._publishAttr(o,a,this._pubCommitter,this._pubEvent));lt.publish(t,e,i)}_publishAttr(t,e,s,n){let i=this._dataId+t;x.publish(i,e,s),this.publishLocalEvent(t,e,s,n)}mergeStage(){this.attributes=b.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,s=this){N.delete(t,e),this._delCommitter=s;let n=this._deleteCb||(this._deleteCb=(i,o)=>this.publishLocalEvent(i,o,this._delCommitter,H.DELETE));lt.publish(e,e,n)}_getAttr(t,e){return N.get(t,e)}};var Rs={"\n":"\\n","\r":"\\n"," ":"\\t"},Bs=(r,t)=>{typeof r!="string"&&(r=String(r));let e=t?/[\n\r\t]/g:/\t/g;return r.replace(e,s=>Rs[s])},Te=(r,t)=>{if(typeof r!="string")return r;r=Bs(r,t),r=encodeURIComponent(r);let e=/%22/g;return r.replace(e,'"')},Jt=(r,t)=>{let e=typeof r;return e==="undefined"?r:e!=="object"?(r=Te(r),r):(Object.keys(r).forEach(s=>{let n=r[s];n!==null&&(r[s]=typeof n=="string"?Jt(n,t):Te(n,t))}),r)};function Ae(r){return typeof r<"u"&&r.length>0?JSON.parse(r):!1}function Xt(r){return typeof r<"u"?JSON.stringify(r):null}var ht=class{static prepareJsonUrl(t,e=!1){let s=typeof t=="object"?b.clone(t):t,n=Jt(s,e);return Xt(n)}static json={encode:Xt,decode:Ae};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Pt=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 s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.push(s+"="+t[s]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=w.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=w.parseQueryString(e,!1)),this._isFormData(t))for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.append(s,e[s]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let s=this.model.get("id"),n="id="+s,i=s?`/${s}`:"",o=this.model;return this._get(i,n,t,e,a=>{if(a){let c=this.getObject(a);c&&o.set(c)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ht.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._put(i,s,t,e)}add(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._post(i,s,t,e)}update(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._patch(i,s,t,e)}delete(t,e){let s=this.model.get("id"),n=typeof s<"u"?"id="+s:this.setupObjectData(),i=s!=null?`/${s}`:"";return this._delete(i,n,t,e)}getAllParams(t,e,s,n){let i=this.model.get();t=isNaN(Number(t))?0:t,e=isNaN(Number(e))?50:e;let o=i.search||"",a=i.filter||"";typeof a=="object"&&(a=JSON.stringify(a));let c=i.dates||"";typeof c=="object"&&(c=JSON.stringify(c));let u=i.orderBy||"";typeof u=="object"&&(u=JSON.stringify(u));let l=i.groupBy||"";return Array.isArray(l)&&(l=JSON.stringify(l)),"&filter="+a+"&offset="+t+"&limit="+e+"&dates="+c+"&orderBy="+u+"&groupBy="+l+"&search="+o+"&lastCursor="+(typeof s<"u"&&s!==null?s:"")+"&since="+(typeof n<"u"&&n!==null?n:"")}all(t,e,s,n,i=null,o=null){let a=this.getAllParams(s,n,i,o);return this._get("",a,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let s=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(s)}setupRequest(t,e,s,n,i){let o={url:this.getUrl(t),method:e,params:s,completed:(c,u)=>{typeof i=="function"&&i(c),this.getResponse(c,n,u)}};return this._isFormData(s)&&(o.headers={}),zt(o)}setupEventSource(t,e,s,n,i=!0){let o=null,a,c=!1,u=!1,l=()=>{a&&(clearTimeout(a),a=void 0)},h=()=>{if(c||!i||u)return;l(),a=setTimeout(()=>{a=void 0,g()},3e3)},g=()=>{if(c||u)return;if(o){try{o.close()}catch{}o=null}u=!0;let y=this.getUrl(t),d=e?"?"+e:"";o=new EventSource(y+d,{withCredentials:!0}),o.onopen=()=>{u=!1,l(),n&&n()},o.onerror=()=>{u=!1,o&&o.readyState===EventSource.CLOSED&&(o=null,h())},o.onmessage=C=>{try{let E=JSON.parse(C.data);s&&s(E)}catch{}}};return g(),{get source(){return o},close:()=>{if(c=!0,u=!1,l(),o){try{o.close()}catch{}o=null}}}}replaceUrl(t){return T.isWatching(t)&&(t=T.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,s,n){return this._request("","POST",t,e,s,n)}_get(t,e,s,n,i){return e=this.setupParams(e),e=this.addParams(e,s),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",n,i)}_post(t,e,s,n,i){return this._request(t,"POST",e,s,n,i)}_put(t,e,s,n,i){return this._request(t,"PUT",e,s,n,i)}_patch(t,e,s,n,i){return this._request(t,"PATCH",e,s,n,i)}_delete(t,e,s,n,i){return this._request(t,"DELETE",e,s,n,i)}_request(t,e,s,n,i,o){return s=this.setupParams(s),s=this.addParams(s,n),this.setupRequest(t,e,s,i,o)}getResponse(t,e,s){typeof e=="function"&&e(t,s)}static extend(t){if(!t)return{};let e=this;class s extends e{constructor(i){super(i)}}return Object.assign(s.prototype,t),s}};var Ls=r=>{let t={};if(!S.isObject(r)||!r.defaults)return t;let{defaults:e}=r;return Object.keys(e).forEach(s=>{let n=e[s];typeof n!="function"&&(t[s]=n)}),delete r.defaults,t},Hs=r=>{if(!r||typeof r.xhr!="object")return{};let t={...r.xhr};return delete r.xhr,t},Ns=0,ft=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,s=Hs(t),n=e.prototype.service.extend(s),i=Ls(t);class o extends e{constructor(c){let u={...i,...Dt(c)};super(u),this.xhr=new n(this)}dataTypeId=`bm${Ns++}`}return Object.assign(o.prototype,t),o.prototype.service=n,o}};ft.prototype.service=Pt;var j=class extends M{};var dt=class extends j{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 s=this.stage;return typeof s[t]<"u"&&delete s[t],this}};var Et=class extends dt{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=""}};var I=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 Et(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,s){let n=this.getTarget(t);return e&&n.addAction(e,s),n}static addAction(t,e,s){return this.add(t,e,s)}static removeAction(t,e,s){s&&this.off(t,e,s)}static on(t,e,s){let n=this.getTarget(t);return e?n.on(e,s):null}static off(t,e,s){this.remove(t,e,s)}static remove(t,e,s){let n=this.targets,i=n.get(t);if(i){if(e){i.off(e,s);return}this.targets.delete(t)}}static set(t,e,s){this.getTarget(t).set(e,s)}};var Q=class{static resume(t,e){if(t._externalData){this._resumeExternal(t,e);return}this._resumeOwned(t,e)}static refresh(t){let e=t.setData();e&&t.data&&t.data.set(e.stage),this.refreshContext(t)}static refreshContext(t){let e=t.context;if(!e||!e.data)return;let s=t.getParentContext();if(!s||!s.data)return;let n=s.data.stage,i=e.data.stage,o=null;for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;let c=n[a];c!==i[a]&&(o===null&&(o={}),o[a]=c)}o!==null&&(typeof e.data._silentSet=="function"?e.data._silentSet(o):e.data.set(o))}static _resumeExternal(t,e){let s=t.setData();if(!s){t.data=e;return}if(e&&e.stage){let n=e._retainState||s._retainState,i=!n&&(e._refreshState||s._refreshState),o=this._buildExternalUpdates(e.stage,s.stage,n,i);b.isEmpty(o)||s._silentSet(o)}typeof s.flushPending=="function"&&s.flushPending(),t.data=s}static _buildExternalUpdates(t,e,s,n){let i={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;if(n){Object.prototype.hasOwnProperty.call(e,o)||(i[o]=t[o]);continue}let a=t[o];!s&&a==null||a!==e[o]&&(i[o]=a)}return i}static _resumeOwned(t,e){if(!t.data){t.data=e;return}if(e&&e._retainState){t.data=e;return}if(e&&e.stage){let s=e._refreshState||t.data._refreshState,n=this._buildOwnedUpdates(e.stage,t.data.stage,s);b.isEmpty(n)||t.data._silentSet(n)}t.data&&typeof t.data.flushPending=="function"&&t.data.flushPending()}static _buildOwnedUpdates(t,e,s){let n={};for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(s){Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);continue}let o=t[i];o!=null&&o!==e[i]&&(n[i]=o)}return n}};var Mt=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(!(e<1))for(let s=0;s<e;s++){let n=t[s];this.on(n[0],n[1],n[2],n[3])}}on(t,e,s,n){f.on(t,e,s,n),this.events.push({event:t,obj:e,callBack:s,capture:n})}off(t,e,s,n){f.off(t,e,s,n);let i,o=this.events;for(let a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.obj===e){o.splice(a,1);break}}set(){let t=this.events;for(let e=0,s=t.length;e<s;e++){let n=t[e];f.on(n.event,n.obj,n.callBack,n.capture)}}unset(){let t=this.events;for(let e=0,s=t.length;e<s;e++){let n=t[e];f.off(n.event,n.obj,n.callBack,n.capture)}}reset(){this.unset(),this.events=[]}};var It=class{constructor(t,e){this.remoteStates=[];let s=this.convertStates(e);this.addStatesToTarget(t,s)}addStates(t,e){let s=this.convertStates(e);this.addStatesToTarget(t,s)}createState(t,e,s,n){return{action:t,state:e,callBack:s,targetId:n,token:null}}convertStates(t){let e=[];for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;if(s==="remotes"){this.setupRemoteStates(t[s],e);continue}let n=null,i=null,o=t[s];o&&typeof o=="object"&&(i=o.callBack,n=o.id||o.targetId,o=o.state),e.push(this.createState(s,o,i,n))}return e}setupRemoteStates(t,e){for(let s=0,n=t.length;s<n;s++){let i=t[s];if(i)for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o)||o==="id")continue;let a=null,c=i[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,i.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(let s=0,n=e.length;s<n;s++){let i=e[s];i.token&&this.unbindRemoteState(t,i.token),i.targetId&&I.remove(i.targetId,i.action,i.token)}}restore(t){I.restore(t.id,t);let e=this.remoteStates;if(e)for(let s=0,n=e.length;s<n;s++){let i=e[s];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,s){let n=I.getTarget(s);return t.link(n,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let s=this.remoteStates;for(let n=0,i=e.length;n<i;n++){let o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,s.push(o))}}addAction(t,e){let s,n=e.action,i=e.targetId;i&&(s=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),s||null}};p.addType("components",r=>{if(!r)return;let t=r.component;!t||!t.isUnit||(t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken),t.rendered===!0&&(t.prepareDestroy(),t.cleanUpAfterDestroy()))});var Us=0,pt=class{constructor(t,e,s){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._classId,this.id="",this.cached=[],this.init();let n,i;if(t==null)n={},i=[];else{let o=typeof t;o==="string"||o==="number"?(n={},i=[{tag:"text",textContent:t}]):Array.isArray(t)?(n={},i=t):(n=t||{},i=typeof e=="string"?[{tag:"text",textContent:e}]:e)}this.setupProps(n),this.children=i||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Us++,this.unitType=this._classId||this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=t.key,s=t.cache,n;s!=null&&e!=null?n="pk:"+s+":"+e:s!=null?n="pk:"+s:e!=null?n="pk:"+e:n="pc"+this.persistedCount++;let i=this.persistedChildren[n];return i&&t.unitType===i.unitType&&t.resumeScope(i),t.persistToken=n,this.persistedChildren[n]=t,n}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e],e==="data"&&(this._externalData=!0))}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){if(this._contextResumed)return;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 s=e[0];s&&(this.addingContext=!0,this.contextBranchName=s,this.addContextBranch(s,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(){p.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 s=[];if(!t||t.length<1)return s;for(let n=0,i=t.length;n<i;n++){let o=e(t[n],n);s.push(o)}return s}removeAll(t){return D.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}cacheEle(t,e){e&&(this[e]=t,this.cached.push(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;t&&D.removeElement(t),this.cleanUpAfterDestroy()}cleanUpAfterDestroy(){this.panel=null,this.container=null;let t=this.cached;for(let e=0,s=t.length;e<s;e++)this[t[e]]=null;this.cached=[],this.persist!==!0&&(this.persistedChildren={},this.persistToken=null)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var v=class extends pt{constructor(t,e,s){super(t,e,s),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._externalData=this._externalData??!1,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this._resumeData(t.data),this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,t.context&&(this.context=t.context),this.id=t.id,this._refreshContextData()}_resumeData(t){Q.resume(this,t)}_refreshData(){Q.refresh(this)}_refreshContextData(){Q.refreshContext(this)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=I.getTarget(String(e))}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();b.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new It(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)}onFlush(t){let e=this.data??this?.context?.data??null;e&&e.onFlush(t)}setEventHelper(){this.events||(this.events=new Mt)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events&&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!==!0&&this.data.unlink()}};var Ot={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var Fs=(r,t)=>typeof r!="function"&&t==="setupStates"?()=>r:r,Kt=(r,t)=>{if(!r)return t;let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i],a=Ot[i]||i;t[a]=Fs(o,a)}return t},Ws=r=>Kt(r,{}),qs=0,De=(r,t)=>{class e extends r{}return Object.assign(e.prototype,t),e.prototype._classId="jot"+qs++,e},U=(r,t=v)=>{r||(r={});let e,s=typeof r;return s==="object"&&r.render?(e=Ws(r),De(t,e)):(e={render:s==="function"?r:()=>r},De(t,e))};var Vs=(r,t)=>{let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i],a=Ot[i]||i;t.prototype[a]=o}return t},Gs=0,zs=r=>{let t=class extends r{};return t.prototype._classId="pod"+Gs++,t},$s=(r,t=v)=>{if(!r)return null;let e=zs(t),s={},n=r(s);return Vs(s,e),e.prototype.render=n,e};var js={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(r=new Date().getDay(),t=!1){if(typeof Intl<"u"){let n=new Date(2004,0,4+r);return new Intl.DateTimeFormat(void 0,{weekday:t?"short":"long"}).format(n)}let e=this.dayNames;if(r>e.length)return null;let s=e[r];return t?s.substring(0,3):s},convertJsMonth(r){return this.padNumber(r+1)},convertDate(r,t=!1){r=r?r.replace(/\s/,"T"):"";let e=new Date(r);if(typeof Intl<"u"){let n={weekday:"long",month:"short",day:"2-digit"};return t&&(n.year="numeric"),new Intl.DateTimeFormat(void 0,n).format(e)}let s=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+s},padNumber(r){return r<=9?"0"+r:String(r)},createDate(r){return r?(typeof r=="string"&&r.indexOf("-")>-1&&(r=r.replace(/\s/,"T"),r=r.indexOf(":")>-1?r:r+"T00:00:00"),new Date(r)):new Date},format(r,t){let e=this.createDate(t);return r!=="sql"&&typeof Intl<"u"?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}).format(e):this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),r)},formatTime(r,t){let e=this.createDate(r);if(t!==24&&typeof Intl<"u")return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}).format(e);let s=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),s)},getMeridian(r){return r=Number(r),r>=12?"PM":"AM"},convert24To12(r){return r=Number(r),r>12&&(r=r-12),r},convert12To24(r,t){return r=Number(r),t.toLowerCase()==="pm"&&(r=r+12),r},renderDate(r,t,e,s="sql"){return t=Number(t),e=Number(e),s==="sql"?`${r}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${r}`},renderTime(r,t,e=0,s="sql"){if(s==="sql")return`${this.padNumber(r)}:${this.padNumber(t)}:${this.padNumber(e)}`;let n=this.getMeridian(r);return r=this.convert24To12(r),`${r}:${this.padNumber(t)} ${n}`},leapYear(r){return r%400===0||r%100!==0&&r%4===0},getMonthName(r=new Date().getMonth(),t=!1){if(typeof Intl<"u"){let n=new Date(2e3,r,1);return new Intl.DateTimeFormat(void 0,{month:t?"short":"long"}).format(n)}let e=this.monthNames;if(r>e.length)return"";let s=e[r];return s?t?s.substring(0,3):s:""},getMonthLength(r,t){let e=new Date;return r=typeof r<"u"?r:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[r]},getMonthsLength(r=new Date().getFullYear()){return this.leapYear(r)===!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(r,t="America/Denver"){let e=new Date(r);if(Number.isNaN(e.getMonth())===!0){let i=/[- :]/,o=r.split(i);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let s=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),n=e.getTime()-s.getTime();return new Date(e.getTime()+n)},getLocalTime(r,t=!1,e=!1,s="America/Denver"){if(!r)return"";let n=this.getLocalDate(r,s);if(!t&&typeof Intl<"u"){let c={hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0};return e===!1&&(c.year="numeric",c.month="2-digit",c.day="2-digit"),new Intl.DateTimeFormat(void 0,c).format(n)}let 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(r,t=!1){r=r.replace(/\s/,"T");let e=new Date(r),s=new Date;return t===!0&&s.setHours(0,0,0,0),s.getTime()-e.getTime()},getAge(r){let t=this.getDiffFromNow(r),e,s;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:s=this.toDays(t),e=s+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:s=this.toDays(t);var n=Math.floor(s/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(r){let t=this.getDiffFromNow(r);return this.convertToEstimate(t)},convertToEstimate(r){let t="",e,s,n,i,o,a,c;if(r<=0)switch(!0){case r<-63072e6:n=this.toYears(Math.abs(r)),t="in "+n+" y";break;case r<-31536e6:t="in 1y";break;case r<-5184e6:i=this.toMonths(Math.abs(r)),t="in "+i+"mo";break;case r<-2592e6:t="in 1mo";break;case r<-12096e5:e=this.toDays(Math.abs(r)),s=Math.floor(e/7),t="in "+s+"w";break;case r<-6048e5:t="in 1w";break;case r<-1728e5:e=this.toDays(Math.abs(r)),t="in "+e+"d";break;case r<-864e5:t="tomorrow";break;case r<-72e5:o=this.toHours(Math.abs(r)),t="in "+o+" h";break;case r<=-36e5:t="in 1h";break;case r<-12e4:a=this.toMinutes(Math.abs(r)),t="in "+a+"m";break;case r<-6e4:t="in 1m";break;case r<-2e3:c=this.toSeconds(Math.abs(r)),t="in "+c+"s";break;case r<-1:t="in 1s";break;default:t="now"}else switch(!0){case r<1e3:t="1s ago";break;case r<6e4:c=this.toSeconds(r),t=c+"s ago";break;case r<12e4:t="1m ago";break;case r<36e5:a=this.toMinutes(r),t=a+"m ago";break;case r<72e5:t="1h ago";break;case r<864e5:o=this.toHours(r),t=o+"h ago";break;case r<1728e5:t="yesterday";break;case r<6048e5:e=this.toDays(r),t=e+"d ago";break;case r<12096e5:t="1w ago";break;case r<2592e6:e=this.toDays(r),s=Math.floor(e/7),t=s+"w ago";break;case r<5184e6:t="1mo ago";break;case r<31536e6:i=this.toMonths(r),t=i+"mo ago";break;case r<63072e6:t="1y ago";break;default:n=this.toYears(r),t=n+"y ago"}return t},toYears(r){return typeof r!="number"?0:Math.floor(r/31558464e3)},toMonths(r){return typeof r=="number"?Math.floor(r/2592e6):0},toDays(r){return typeof r!="number"?0:Math.floor(r/864e5*1)},toHours(r){return typeof r!="number"?0:Math.floor(r%864e5/36e5*1)},toMinutes(r){return typeof r!="number"?0:Math.floor(r%864e5%36e5/6e4*1)},toSeconds(r){return typeof r!="number"?0:Math.floor(r%864e5%36e5%6e4/1e3*1)},getDifference(r,t){let e=new Date(r),s=new Date(t),n=s.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 Y={items:new Map,add(r,t){return this.items.set(r,t),this},get(r){return this.items.get(r)??null}};var Zt=(r,t)=>({attr:r,directive:t});var O=(r,t)=>({key:r,value:t});var Pe=(r,t,e,s)=>({tag:r,attr:t,directives:e,children:s});var Ee=null,Qs=()=>Ee||(Ee=Y.get("watch")),L=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,s,n){return t==="text"?(n.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(s.push(O("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,s){t.push(Zt(O(e,T.getWatcherSettings(s,at(e))),Qs()))}static setButtonType(t,e,s){if(t==="button"){let n=e.type||"button";s.push(O("type",n))}}static parse(t,e){let s=[],n=[],i=t.tag||"div";i==="button"&&s.push(O("type",t.type||"button"));let o=[],a,c;for(let u in t){if(!Object.prototype.hasOwnProperty.call(t,u)||u==="tag"||(a=t[u],a==null))continue;if(u==="children"||u==="nest"){if(Array.isArray(a))for(let h=0;h<a.length;h++)o.push(a[h]);else o.push(a);continue}if((c=Y.get(u))!==null){n.push(Zt(O(u,a),c));continue}let l=typeof a;if(l==="object"){if(T.isWatching(a)){this.setTextAsWatcher(n,u,a);continue}o.push(a);continue}if(l==="function"){let h=a,g=function(y){h.call(this,y,e)};g.originalCallback=h,s.push(O(u,g));continue}if(l==="string"&&a.includes("[[")){this.setTextAsWatcher(n,u,a);continue}if(u==="text"){o.push({tag:"text",textContent:a});continue}if(u==="html"||u==="innerHTML"){s.push(O("innerHTML",a));continue}s.push(O(u,a))}return Pe(i,s,n,o)}};var J=class{build(t,e,s){}setupComponent(t,e,s){let n=s?.getChildScope();t.parent=n,n&&n.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&n&&(n[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),s=this.build(e,t.container,t);return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),s}createComponent(t,e,s){return this.setupComponent(t,e,s),this.buildComponent(t),t}setDirectives(t,e,s){}removeNode(t){}removeAll(t){}};var _t=class extends J{build(t,e,s){let n=k.createDocFragment();if(Array.isArray(t))for(let i=0,o=t.length;i<o;i++)this.buildElement(t[i],n,s);else this.buildElement(t,n,s);return e&&typeof e=="object"&&e.appendChild(n),n}buildElement(t,e,s){if(t){if(t.isUnit===!0){this.createComponent(t,e,s);return}this.createElement(t,e,s)}}createElement(t,e,s){let n=s?.getChildScope();if(t.data||t.state){this.createTempComponent(t,e,n);return}let i=L.parse(t,n),o=this.createNode(i,e,n);this.cache(o,t.cache,s);let a=i.children;for(let u=0,l=a.length;u<l;u++){let h=a[u];h!==null&&this.buildElement(h,o,s)}let c=i.directives;c.length&&this.setDirectives(o,c,n)}createTempComponent(t,e,s){let n={cache:t.cache,key:t.key,_externalData:!0,setData:()=>t.data,...Kt(t.methods||{},{}),render(){return{...t,data:null,state:null,methods:null,key:null}}};t.state&&(n.setupStateTarget=function(o){this.state=t.state});let i=new v(n);this.createComponent(i,e,s)}setDirectives(t,e,s){for(let n=0,i=e.length;n<i;n++)this.handleDirective(t,e[n],s)}handleDirective(t,e,s){e.directive(t,e.attr.value,s)}cache(t,e,s){s&&e&&s.cacheEle(t,e)}createNode(t,e,s){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:"";return k.createText(o,e)}else if(n==="comment"){let i=t.attr[0],o=i?i.value:"";return k.createComment(o,e)}return k.create(n,t.attr,e,s)}removeNode(t){k.removeElement(t)}removeAll(t){k.removeAll(t)}};var Ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source"]),X=class{static create(t,e=[],s=""){let n="",i="";for(let o=0,a=e.length;o<a;o++){let c=e[o],u=c.key,l=c.value;if(u==="text"||u==="textContent"){n+=l;continue}if(u==="html"||u==="innerHTML"){n+=l;continue}if(typeof l=="function"){let h="on"+ct(u);i?i+=" "+h+'="'+l+'"':i=h+'="'+l+'"';continue}i?i+=" "+u+'="'+l+'"':i=u+'="'+l+'"'}return Ys.has(t)?"<"+t+" "+i+" />":"<"+t+" "+i+">"+n+s+"</"+t+">"}static createText(t){return t}static createComment(t){return"<!-- "+t+" -->"}};var Rt=class extends J{build(t,e,s){if(Array.isArray(t)){let n="";for(let i=0,o=t.length;i<o;i++)n+=this.buildElement(t[i],s);return n}return this.buildElement(t,s)}createComponent(t,e,s){return this.setupComponent(t,e,s),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,{},e):this.createElement(t,e):""}createElement(t,e){let s=L.parse(t,e),n=s.children,i="";for(let o=0,a=n.length;o<a;o++){let c=n[o];c!==null&&(i+=this.buildElement(c,e))}return this.createNode(s,i)}createNode(t,e){let s=t.tag;if(s==="text"){let n=t.attr[0],i=n?n.value:"";return X.createText(i)}else if(s==="comment"){let n=t.attr[0],i=n?n.value:"";return X.createComment(i)}return X.create(s,t.attr,e)}removeAll(t){}};var Bt=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new _t:new Rt}};var F=Bt.setup(),Js=r=>typeof r=="object"&&r.isUnit===!0,Xs=r=>{let t=U(r);return t?new t:null},m=class{static render(t,e,s){return!t||(Js(t)||(t=Xs(t)),!t)?null:F.createComponent(t,e,s)}static build(t,e,s){return F.build(t,e,s)}static rebuild(t,e,s){return F.removeAll(e),this.build(t,e,s)}static setDirectives(t,e,s){F.setDirectives(t,e,s)}static createNode(t,e,s){return F.createNode(t,e,s)}static removeNode(t){F.removeNode(t)}static removeAll(t){F.removeAll(t)}};R.augment({buildLayout(r,t,e){m.build(r,t,e)}});var te=[],Ks=r=>te.indexOf(r)!==-1,Zs=r=>({tag:"script",src:r.src,async:!1,load(t){te.push(r.src);let e=r.load;e&&e()}}),tr=r=>({tag:"link",rel:"stylesheet",type:"text/css",href:r.src,load(t){te.push(r.src);let e=r.load;e&&e()}}),Lt=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,s=this.update.bind(this);t.indexOf(".css")!==-1?e=tr({load:s,src:t}):e=Zs({load:s,src:t}),m.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{Ks(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 er=r=>r?typeof r?.prototype?.constructor=="function":!1,K=class{static process(t,e){let s=t.default;return s?e.callback?e.callback(s):(er(s)?s=new s:s=s(),s.isUnit===!0&&(s.route=e.route,e.persist&&(s.persist=!0)),s):null}static render(t,e,s){let n=m.build(t,null,s),i=n.firstChild||t?.panel;return e.after(n),i}};var Ht=class{static load(t,e,s){return t.then(n=>(e&&e(n),n)).catch(n=>{console.error("Error loading module:",n),s&&s(n)})}};var sr=r=>({tag:"comment",textContent:"import placeholder",onCreated:r.onCreated}),Z=new Map,rr=r=>{if(Z.has(r)){let s=Z.get(r);return s&&typeof s.then!="function"?Promise.resolve(s):s}let t=typeof r,e;if(t==="string")e=import(r);else if(t==="function")e=r();else return r;return e.then(s=>{Z.set(r,s)}),Z.set(r,e),e},nr=r=>{if(!Z.has(r))return null;let t=Z.get(r);return t&&typeof t.then=="function"?null:t||null},Me=U({declareProps(){this.loaded=!1,this.generation=0},render(){return sr({onCreated:r=>{if(this.src){if(this.layout){this.layoutRoot=K.render(this.layout,this.panel,this.parent);return}if(this.depends){new Lt(()=>{this.loadAndRender(r)}).addFiles(this.depends);return}this.loadAndRender(r)}}})},loadAndRender(r){let t=this.generation,e=nr(this.src);if(e){this.renderModule(r,e);return}Ht.load(rr(this.src),s=>{t===this.generation&&this.renderModule(r,s)},s=>{t===this.generation&&(this.loaded=!1)})},renderModule(r,t){this.loaded=!0;let e=this.layout||K.process(t,{callback:this.callback,route:this.route,persist:this.persist});this.layout=e,this.layoutRoot=K.render(e,r,this.parent)},shouldUpdate(r){return this.updateLayout===!0?!0:this.updateLayout=r&&r.isUnit&&typeof r.update=="function"},updateModuleLayout(r){let t=this.layout;this.shouldUpdate(t)&&t&&t.update(r)},update(r){this.loaded===!0&&this.updateModuleLayout(r)},destroy(){this.generation++,this.layoutRoot&&(m.removeNode(this.layoutRoot),this.persist!==!0&&(this.layoutRoot=null,this.layout=null,this.loaded=!1,this.updateLayout=!1))}});var ee=r=>{let t=typeof r;return(t==="string"||t==="function"||r instanceof Promise)&&(r={src:r}),new Me(r)};var Ie=(r,t,e=null)=>{if(!r)return;let s=null,n=!1,i=()=>{n||(n=!0,s&&(clearTimeout(s),s=null),f.off("animationend",r,o),r&&r.classList.remove(t),e&&e())},o=a=>{a.target===r&&i()};f.on("animationend",r,o),requestAnimationFrame(()=>{if(!r){i();return}r.classList.add(t);try{let a=window.getComputedStyle(r),c=parseFloat(a.animationDuration)*1e3||1e3,u=parseFloat(a.animationDelay)*1e3||0;s=setTimeout(i,c+u+100)}catch{s=setTimeout(i,1e3)}})},Oe=(r,t,e)=>{Ie(r,t)},_e=(r,t,e)=>{let s=()=>{r&&r.remove&&r.remove()};ir(r,()=>Ie(r,t,s),e)};p.addType("manual-destroy",r=>{if(!r)return!1;r.callBack(r.ele,r.parent)});var ir=(r,t,e)=>{p.add(r,"manual-destroy",{ele:r,callBack:t,parent:e})};var mt=(r,t,e,s)=>{if(Array.isArray(e[0])){e.forEach(n=>{n&&mt(r,t,n,s)});return}or(r,t,e,s)},or=(r,t,e,s)=>{let n,i;if(e.length<3?[n,i]=e:[t,n,i]=e,!t||!n)return;if(typeof t.on!="function"){console.warn('Watcher directive: Data source does not have an "on" method. Make sure your component has data, state, or context.data initialized before using watchers like onSet, watch, or [[prop]] syntax.',r,t);return}let o=ar(r,n,i,s);x.watch(r,t,n,o)},ar=(r,t,e,s)=>typeof e=="object"?n=>{lr(r,e,n)}:n=>{ur(r,e,t,n,s)},Re=new WeakSet,cr=(r,t,e)=>{!r||!r.isUnit&&!r.isComponent||Re.has(e)||(Re.add(e),console.warn('[Watcher] Reactive callback for "'+t+'" returned a Component/Unit instance. The entire subtree will be destroyed and recreated on every change, which can trigger expensive deep publishes during persistence/resume. Consider mounting the component once and exposing a refresh()/update() method, or returning a plain layout object instead.',e))},ur=(r,t,e,s,n)=>{let i=t(s,r,n);switch(typeof i){case"object":cr(i,e,r),m.rebuild(i,r,n);break;case"string":let o=vt(r);if(o!=="textContent"){r.setAttribute(o,i);break}D.addHtml(r,i);break}},lr=(r,t,e)=>{let s=Object.keys(t);for(let n=0,i=s.length;n<i;n++){let o=s[n];o&&(t[o]===e?r.classList.add(o):r.classList.remove(o))}};var tt=(r,t,e)=>{let s=A(e);mt(r,s,t,e)};var Be=(r,t,e)=>{t&&r.setAttribute("role",t)},hr=r=>(t,e)=>{let s=t?"true":"false";e.setAttribute(r,s)},Le=(r,t,e)=>{if(!t)return;let s=t.role;s&&(r.setAttribute("role",s),t.role=null);let n=Object.keys(t);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=t[a];if(c===null)continue;let u="aria-"+a;if(Array.isArray(c)){let l=c.slice();l.push(hr(u)),tt(r,l,e)}else r.setAttribute(u,c)}};var He=(r,t,e)=>{if(!t)return;let s=L.parse(t,e);k.addAttributes(r,s.attr,e),m.setDirectives(r,s.directives,e)};p.addType("context",r=>{if(!r)return!1;r.parent.removeContextBranch(r.branch)});var se=r=>r?r.getContext():null,Ne=(r,t,e)=>{if(typeof t!="function")return;let s=se(e),n=t(s);He(r,n,e)},Ue=(r,t,e)=>{if(typeof t!="function")return;let s=se(e);t(s)},Fe=(r,t,e)=>{if(typeof t!="function"||!e)return;let s=se(e),n=t(s);n&&e.addContextBranch(n[0],n[1])};var We=(r,t,e)=>{};var qe=(r,t,e)=>{if(!e)return;let s=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",r),console.log("Data: ",t),console.log("Layout: ",s),console.log("parent: ",e)};var Ve=(r,t,e)=>{},Ge=(r,t,e)=>{if(!t||!e)return;let s=t(e,r);s&&m.build(s,r,e)},ze=(r,t,e)=>{if(!t||!e)return;let s=e.getId(t);r.id=s},$e=(r,t,e)=>{if(!t||!e)return;let s=t(e.data,r);s&&m.build(s,r,e)},je=(r,t,e)=>{if(!t||!e)return;let s=t(e.state,r);s&&m.build(s,r,e)},Qe=(r,t,e)=>{if(!t||!e)return;let s=e.state,n=t(s);if(!e.state){e.setStateHelper(n);return}e.addState(n)},Ye=(r,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let s=t[2];t[2]=n=>{s(n,e)}}e.events.on(t[0],t[1],t[2],t[3])}};var Je=(r,t,e)=>{let s,n,i;if(typeof t=="string"){if(s=A(e),!s)return;n=t}else if(Array.isArray(t))if(typeof t[0]!="object"){let o=A(e);if(!o)return;s=o,n=t[0],i=t[1]}else[s,n,i]=t;x.bind(r,s,n,i)};var Nt=(r,t,e)=>{mt(r,e.state,t,e)};var Xe=r=>(t,e)=>{let[s,n,i="active"]=r,o=t===n?i:"";e.dataset[s]=o},Ke=(r,t,e)=>{if(!t)return;let s=t.length-1,n=t[s],i=t.slice(0,s);i.push(Xe(n)),tt(r,i,e)},Ze=(r,t,e)=>{if(!t)return;let s=t.length-1,n=t[s],i=t.slice(0,s);i.push(Xe(n)),Nt(r,i,e)};var ts=(r,t,e)=>{let s,n,i,o;if(t.length<3){let c=A(e);if(!c)return;s=c,[n,i,o]=t}else[s,n,i,o]=t;let a=o!==!1;x.watch(r,s,n,c=>{if(m.removeAll(r),!c||c.length<1)return;let u=[];for(let l=0,h=c.length;l<h;l++){let g=a?s.scope(n+"["+l+"]"):null,y=i(c[l],l,g,u);y!==null&&u.push(y)}return m.build(u,r,e)})};var es=(r,t,e)=>{let s=t[0];if(!s||s.length<1)return;let n=t[1],i=[];for(let o=0,a=s.length;o<a;o++){let c=s[o];if(!c)continue;let u=n(c,o);u!==null&&i.push(u)}m.build(i,r,e)};var ss=(r,t,e)=>{t(r,e)};p.addType("destroyed",r=>{if(!r)return!1;r.callBack(r.ele,r.parent)});var rs=(r,t,e)=>{fr(r,t,e)},fr=(r,t,e)=>{p.add(r,"destroyed",{ele:r,callBack:t,parent:e})};var ns=(r,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(let s=0,n=t.length;s<n;s++)T.setup(r,t[s],e);else T.setup(r,t,e)};var dr=0,et=class{constructor(t){this.router=t,this.locationId="base-app-router-"+dr++,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 os=typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent||"")&&!window.MSStream,is=()=>{os&&requestAnimationFrame(()=>requestAnimationFrame(()=>{let r=window.scrollX,t=window.scrollY;window.scrollTo(0,t+1),document.documentElement.offsetHeight,window.scrollTo(r,t)}))},Ut=class extends et{addEvent(){return f.on("popstate",window,this.callBack),os&&(this.pageShowCallBack=this.onPageShow.bind(this),f.on("pageshow",window,this.pageShowCallBack)),this}removeEvent(){return f.off("popstate",window,this.callBack),this.pageShowCallBack&&f.off("pageshow",window,this.pageShowCallBack),this}onPageShow(t){t.persisted&&is()}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let s=e.scrollPosition;s&&this.scrollTo(s),is()}createState(t,e={}){let s=this.getScrollPosition();return e=e===null?{}:e,{location:this.locationId,...e,scrollPosition:s,uri:t}}addState(t,e,s=!1){let n=window.history,i=n.state;if(i&&i.uri===t)return this;!s&&i&&i.location===this.locationId&&(i.scrollPosition=this.getScrollPosition(),n.replaceState(i,"",window.location.href));let o=this.createState(t,e);return s||(o.scrollPosition={x:0,y:0}),n[s===!1?"pushState":"replaceState"](o,null,t),this}};var Ft=class extends et{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,s){return window.location.hash=t,this}};var Wt=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new Ut(t).setup():new Ft(t).setup()}};var re=class extends v{getChildScope(){return this.parent}},as=r=>U(r,re);var qt=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.route&&typeof this.route.flushPending=="function"&&this.route.flushPending(),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){this.template=this.template(),this.initializeTemplateObject()}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){let t=this.template;if(!t)return;t.isUnit||(this.template=new(as(t)));let e=this.template;this.transferSettings(e)}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 cs=r=>{if(!r.length)return null;let t={};for(let e=0,s=r.length;e<s;e++)t[r[e]]=null;return t},us=r=>{let t=[];if(!r)return t;let e=/[*?]/g;r=r.replace(e,"");let s=/:(.[^./?&($]+)\?*/g,n=r.match(s);if(n===null)return t;for(let i=0,o=n.length;i<o;i++){let a=n[i];a&&t.push(a.replace(":",""))}return t};var pr=/(\/):[^/(]*?\?/g,mr=/\//g,gr=/(\?\/+\*?)/g,yr=/(:[^/?&($]+)/g,br=/(\*)/g,xr=r=>r.replace(pr,t=>t.replace(mr,"(?:$|/)")),Sr=r=>(r=r.replace(gr,"?/*"),r.replace(yr,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),wr=r=>r.replace(br,".*"),kr=(r,t)=>r+=t[t.length-1]==="*"?"":"$",ls=r=>{if(!r)return"";let t=r;return t=xr(t),t=Sr(t),t=wr(t),t=kr(t,r),t};var vr=0,hs=(r,t="")=>{let e=r||"",s=typeof t=="string"&&t?t:e,n=null,i=[],o=s.match(/#\{([^}]+)\}/);o&&o[1]&&(n=o[1].trim(),s=s.replace(o[0],""),e=e.replace(o[0],""));let a=s.indexOf("?");if(a>-1){let l=s.substring(a+1);if(l.indexOf("=")>-1){let h=l.split("&");for(let y=0,d=h.length;y<d;y++){let C=h[y];if(!C)continue;let[E,gt=""]=C.split("="),ie=(E||"").trim();ie&&i.push({key:ie,value:(gt||"").trim()})}s=s.substring(0,a);let g=e.indexOf("?");g>-1&&(e=e.substring(0,g))}}let c=n!==null||i.length>0;return c&&!s&&(e="*"),{uriPath:e,requiredHash:n,requiredQuery:i,hasConditions:c}},Cr=r=>{if(!r)return"";let t=r.indexOf("?"),e=r.indexOf("#"),s=r.length;return t>-1&&(s=t),e>-1&&e<s&&(s=e),r.substring(0,s)},Tr=r=>{if(!r)return"";let t=r.indexOf("#");return t===-1?"":r.substring(t+1)},Ar=r=>{if(!r)return"";let t=r.indexOf("?");if(t===-1)return"";let e=r.indexOf("#",t);return e===-1?r.substring(t+1):r.substring(t+1,e)},Vt=class extends M{constructor(t,e){let s=t.baseUri,i=hs(s,t.rawUri).uriPath,o=us(i),a=cs(o),c=super(a);return this.uri=s,this.matchUri=i,this.paramKeys=o,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),c}setup(){this.stage={},this.routeId=null,this.uri=null,this.rawUri=null,this.matchUri="",this.uriQuery=/$^/,this.controller=null,this.paramKeys=[],this.requiredHash=null,this.requiredQuery=[],this.hasConditions=!1,this.titleCallBack=()=>{},this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1,this.scrollTo=null}setupRoute(t){this.routeId=t.id||"bs-rte-"+vr++,this.rawUri=t.rawUri||null,this.path=null,this.referralPath=null;let e=hs(this.uri,this.rawUri||"");this.matchUri=e.uriPath,this.requiredHash=e.requiredHash,this.requiredQuery=e.requiredQuery,this.hasConditions=e.hasConditions;let s=ls(this.matchUri);this.uriQuery=new RegExp("^"+s),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1,this.scrollTo=t.scrollTo||null}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?ee(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:s,persist:n,parent:i}=t,o={component:e,container:s,persist:n,parent:i},a=At(this);this.controller=new qt(a,o)}resumeRoute(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 s=this.controller;s&&s.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,s=this.hasConditions?Cr(t):t,n=this.uriQuery||/$^/,i=s.match(n);return i===null?(this.resetParams(),e):Array.isArray(i)?this.matchConditions(t)?(this.setParams(i,1),e=i,e):(this.resetParams(),!1):e}matchConditions(t){if(!this.hasConditions)return!0;if(this.requiredHash!==null&&Tr(t)!==this.requiredHash)return!1;let e=this.requiredQuery||[];if(e.length>0){let s=Ar(t);if(!s)return!1;let n=new URLSearchParams(s);for(let i=0,o=e.length;i<o;i++){let a=e[i];if(!n.has(a.key)||n.get(a.key)!==a.value)return!1}}return!0}resetParams(){this.stage={}}setParams(t,e=0){if(!Array.isArray(t))return;let s=this.paramKeys;if(!s)return;let n={};for(let i=0,o=s.length;i<o;i++){let a=s[i];typeof a<"u"&&(n[a]=t[i+e])}this.set(n)}getParams(){return this.stage}};var Dr=r=>{let t=/\w\S*/;return r.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},Pr=(r,t)=>{if(r.indexOf(":")===-1)return r;let e=t.stage;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let n=new RegExp(":"+s,"gi");r=r.replace(n,e[s])}return r},Er=(r,t)=>t&&(typeof t=="function"&&(t=t(r.stage)),t=Pr(t,r),Dr(t)),Mr=(r,t)=>(t!==""&&(r+=" - "+t),r),fs=(r,t,e)=>t&&(t=Er(r,t),Mr(t,e));var ds={removeSlashes(r){return typeof r!="string"?"":(r[0]==="/"&&(r=r.substring(1)),r[r.length-1]==="/"&&(r=r.substring(0,r.length-1)),r)}};var ps=(r,t)=>({attr:r,value:t}),Ir=(r,t)=>{if(!t.startsWith(r))return!1;let e=t[r.length];return e===void 0||e==="/"||e==="#"||e==="."||e==="?"},Gt=class extends v{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,s=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,"data-replace":this.replace?"true":null,watch:s}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let s=this.exact===!0,n=_.data,i=[];return t&&typeof t=="object"&&i.push(ps("href",t)),e&&typeof e=="object"&&i.push(ps("text",e)),i.push({value:["[[path]]",n],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.search+a.hash,u=a.hash||a.search?c:a.pathname,l=s?o===c:Ir(u,o);this.update(l)}}),i}setupStates(){return{selected:!1}}update(t){this.state&&(this.state.selected=t)}};var Or=()=>typeof window<"u"?window.location:{},ne=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.lastMatchedRoute=null,this.lastScrollGroup=null,this.currentGroupId=null,this.scrollWaitToken=0,this.history=null,this.callBackLink=null,this.location=Or(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new B({path:""})}setupHistory(){this.history=Wt.setup(this)}createRoute(t){let e=t.uri||"*";return t.rawUri=e,t.baseUri=this.createURI(e),new Vt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let s=arguments;t={uri:s[0],component:s[1],callBack:s[2],title:s[3],id:s[4],container:s[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.resumeRoute(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()+ds.removeSlashes(t)}getRoute(t){let e=this.routes,s=e.length;if(s>0)for(let n=0;n<s;n++){let i=e[n];if(i.uri===t)return i}return null}getRouteById(t){let e=this.routes,s=e.length;if(s>0)for(let n=0;n<s;n++){let i=e[n];if(i.routeId===t)return i}return!1}removeRoute(t){let e=this.routes,s=e.indexOf(t);s>-1&&e.splice(s,1),this.lastMatchedRoute===t&&(this.lastMatchedRoute=null)}addSwitch(t){let e=this.switchCount++,s=this.getSwitchGroup(e);for(let n=0,i=t.length;n<i;n++){let o=t[n];if(!o)continue;let a=this.createRoute(o);s.push(a)}return this.checkGroupForRegistration(e,s),e}resumeSwitch(t,e){let s=this.switchCount++,n=this.getSwitchGroup(s);for(let i=0,o=t.length;i<o;i++){let c=t[i].component.route;c.resumeRoute(e),n.push(c)}return this.checkGroupForRegistration(s,n),s}checkGroupForRegistration(t,e){let s=this.scrollIntent,n=this.currentGroupId;this.scrollIntent=null,this.currentGroupId=t,this.checkGroup(e,this.getPath()),this.currentGroupId=n;let i=this.scrollIntent;i&&i.type==="target"&&i.groupId!==null&&i.groupId!==void 0&&(this.lastScrollGroup=i.groupId),this.scrollIntent=s}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let s=[];return this.switches.set(t,s),s}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e&&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 s=this.getEndPoint();return this.navigate(s,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){return t.closest("a")}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target.closest("a");if(!e||e.target==="_blank"||e.dataset.cancelRoute)return!0;let s=e.getAttribute("href");if(s!==null){let n=this.baseURI,i=n!=="/"?s.replace(n,""):s,o=e.dataset.replace==="true";return this.navigate(i,null,o),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,s=t.length;e<s;e++){let n=t[e];n&&typeof n.deactivate=="function"&&n.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this.lastMatchedRoute=null,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,s){return t=this.createURI(t),this.history.addState(t,e,s),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;return document.title=fs(t,e,this.title),this}checkActiveRoutes(t){if(this.lastPath=this.path,t=t||this.getPath(),this.path=t,this.scrollIntent=null,this.scrollWaitToken++,this.lastMatchedRoute&&this.check(this.lastMatchedRoute,t))this.select(this.lastMatchedRoute);else{let e=this.routes,s=e.length;for(let n=0;n<s;n++){let i=e[n];typeof i>"u"||this.checkRoute(i,t)}}this.checkSwitches(t),this.applyScrollIntent(),this.updatePath()}checkSwitches(t){let e=this.switches;for(let[s,n]of e.entries())this.currentGroupId=s,this.checkGroup(n,t);this.currentGroupId=null}checkGroup(t,e){let s=t.length;if(!s)return;let n=null;for(let a=0;a<s;a++)if(t[a].get("active")){n=t[a];break}n&&n.match(e)===!1&&n.deactivate();let i;for(let a=0;a<s;a++){let c=t[a];if(typeof c>"u")continue;if(i){c.deactivate();continue}c.match(e)!==!1&&i===void 0&&c.controller&&(i=c,this.select(c))}let o=t[0];i||this.select(o,!0)}checkRoute(t,e){let s=this.check(t,e);return s!==!1?(this.select(t),this.lastMatchedRoute=t):t.deactivate(),s}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t,e){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),e!==!0&&(t.scrollTo?this.scrollIntent={type:"target",selector:t.scrollTo,groupId:this.currentGroupId}:t.preventScroll!==!0&&!this.scrollIntent&&(this.scrollIntent={type:"top"})))}applyScrollIntent(){let t=this.scrollIntent;if(this.scrollIntent=null,!t)return;if(t.type==="top"){this.lastScrollGroup=null,this.checkToScroll(),this.reassertScrollTop();return}if(t.type!=="target")return;let e=t.groupId!==null&&t.groupId!==void 0,s=e&&this.lastScrollGroup===t.groupId;s||(typeof window<"u"&&window.scrollTo(0,0),this.reassertScrollTop()),this.lastScrollGroup=e?t.groupId:null,s&&this.scrollToTarget(t.selector)}reassertScrollTop(){if(typeof window>"u"||typeof requestAnimationFrame>"u")return;let t=++this.scrollWaitToken;requestAnimationFrame(()=>{t===this.scrollWaitToken&&(window.scrollY>0||window.pageYOffset>0)&&window.scrollTo(0,0)})}scrollToTarget(t){if(typeof t!="string"||typeof document>"u")return;let e=c=>{let u=window.getComputedStyle(c),l=u.position==="sticky",h;if(l){let d=c.style.position;c.style.position="static",h=c.getBoundingClientRect().top+window.scrollY,c.style.position=d}else h=c.getBoundingClientRect().top+window.scrollY;let g=l&&parseFloat(u.top)||0,y=h-g;window.scrollY>y&&window.scrollTo(0,y)},s=document.querySelector(t);if(s){e(s);return}if(typeof requestAnimationFrame>"u")return;let n=++this.scrollWaitToken,i=30,o=0,a=()=>{if(n!==this.scrollWaitToken)return;let c=document.querySelector(t);if(c){e(c);return}++o<i&&requestAnimationFrame(a)};requestAnimationFrame(a)}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),s=this.cleanPath(this.lastPath).split("/"),n=t.split("/");if(s.length!==n.length)return!0;let i=s[s.length-1],o=n[n.length-1];return i!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){typeof this.callBackLink=="function"&&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}},_=new ne;p.addType("routes",r=>{if(!r)return!1;let t=r.route;t&&_.removeRoute(t)});var gs=(r,t,e)=>{if(t)if(Array.isArray(t))for(let s=0,n=t.length;s<n;s++){let i=t[s];i&&ms(r,i,e)}else ms(r,t,e)},ms=(r,t,e)=>{t.container=r,t.parent=e;let s=_.add(t);_r(r,s)},_r=(r,t)=>{p.add(r,"routes",{route:t})};var ys=(r,t,e)=>{};p.addType("switch",r=>{if(!r)return!1;let t=r.id;_.removeSwitch(t)});var bs=(r,t,e)=>{let s=t[0];for(let i=0,o=t.length;i<o;i++){let a=t[i];a&&(a.container=r,a.parent=e)}let n=_.addSwitch(t);Rr(r,n)},Rr=(r,t)=>{p.add(r,"switch",{id:t})};Y.add("cache",Ve).add("onCreated",ss).add("onDestroyed",rs).add("bind",Je).add("data",We).add("state",ys).add("onSet",tt).add("onState",Nt).add("animateIn",Oe).add("animateOut",_e).add("watch",ns).add("useParent",Ge).add("useData",$e).add("useState",je).add("getId",ze).add("addState",Qe).add("addEvent",Ye).add("map",es).add("for",ts).add("useContext",Ue).add("addContext",Fe).add("context",Ne).add("role",Be).add("aria",Le).add("route",gs).add("debug",qe).add("dataSet",Ke).add("dataStateSet",Ze).add("switch",bs);export{zt as Ajax,st as Arrays,Is as Atom,m as Builder,v as Component,B as Data,p as DataTracker,js as DateTime,Y as Directives,z as Dom,ht as Encode,Ss as Events,D as Html,ee as Import,U as Jot,ft as Model,Gt as NavLink,b as Objects,$s as Pod,j as SimpleData,dt as State,I as Store,w as Strings,S as Types,pt as Unit,R as base,x as dataBinder,_ as router};
1
+ var st=class{static toArray(t){return Array.from(t)}static inArray(t,e,s){return Array.isArray(t)?t.indexOf(e,s):-1}};var xs=Object.prototype.toString,yt=Object.prototype.hasOwnProperty,b={create(r){return Object.create(r||null)},extendObject(r,t){if(!r||typeof r!="object"||!t||typeof t!="object")return!1;for(let e in r)yt.call(r,e)&&!yt.call(t,e)&&(t[e]=r[e]);return t},clone(r){if(!r||typeof r!="object")return{};try{return structuredClone(r)}catch{return JSON.parse(JSON.stringify(r))}},getClassObject(r){return typeof r=="function"?r.prototype:r},extendClass(r,t){let e=this.getClassObject(r),s=this.getClassObject(t);if(typeof e!="object"||typeof s!="object")return!1;let n=Object.create(e);for(let i in s)n[i]=s[i];return n},hasOwnProp(r,t){return yt.call(r,t)},isPlainObject(r){return!!r&&xs.call(r)==="[object Object]"},isEmpty(r){if(!r||typeof r!="object"||Array.isArray(r))return!0;for(let t in r)if(yt.call(r,t))return!1;return!0}};var S=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 rt={types:{},add(r,t){this.types[r]=t},get(r){return this.types[r]||!1},remove(r){delete this.types[r]}};var bt=class{constructor(){this.types=new Map}add(t,e){let s=this.types.get(t);s||(s=[],this.types.set(t,s)),s.push(e)}get(t){return this.types.get(t)||!1}has(t){return this.types.has(t)}removeType(t){let e=this.types.get(t);if(!e||!e.length)return;let s,n=rt.get(t);if(n){for(let i=0,o=e.length;i<o;i++)s=e[i],s&&(e[i]=null,typeof n=="function"&&n(s));this.types.delete(t)}}remove(t){if(t){this.removeType(t);return}let e=this.types.keys();for(let s of e)s&&this.removeType(s);this.types.clear()}};var W=new WeakMap,p=class{static trackers=new Map;static trackingCount=0;static addType(t,e){rt.add(t,e)}static removeType(t){rt.remove(t)}static getTrackingId(t){if(!t||typeof t!="object")return"";let e=W.get(t);return e||(e="dt"+this.trackingCount++,W.set(t,e)),e}static add(t,e,s){let n=this.getTrackingId(t);this.find(n).add(e,s)}static get(t,e){let s=W.get(t),n=this.trackers.get(s);return n?e?n.get(e):n:!1}static has(t,e){let s=this.getTrackingId(t);if(!s)return!1;let n=this.trackers.get(s);return n&&e?n.has(e):!1}static find(t){let e=this.trackers.get(t);return e||(e=new bt,this.trackers.set(t,e)),e}static isEmpty(t){return!t||typeof t!="object"?!0:t.size===0}static remove(t,e){let s=W.get(t);if(!s)return;let n=this.trackers.get(s);if(n){if(!e){n.remove(),this.trackers.delete(s),W.delete(t);return}n.remove(e),this.isEmpty(n.types)&&(this.trackers.delete(s),W.delete(t))}}};var f={getEvents(r){return typeof r!="object"||r===null?[]:p.get(r,"events")},create(r,t,e,s=!1,n=!1,i=null){return{event:r,obj:t,fn:e,capture:s,swapped:n,originalFn:i}},on(r,t,e,s){if(Array.isArray(r))for(let n=0,i=r.length;n<i;n++)this.add(r[n],t,e,s);else this.add(r,t,e,s);return this},off(r,t,e,s){if(Array.isArray(r))for(let n=0,i=r.length;n<i;n++)this.remove(r[n],t,e,s);else this.remove(r,t,e,s);return this},add(r,t,e,s=!1,n=!1,i=null){if(typeof t!="object"||t===null)return this;let o=this.create(r,t,e,s,n,i);return p.add(t,"events",o),t.addEventListener(r,e,s),this},remove(r,t,e,s=!1){let n=this.getEvent(r,t,e,s);return n===!1?this:(typeof n=="object"&&this.removeEvent(n),this)},removeEvent(r){return typeof r=="object"&&r.obj.removeEventListener(r.event,r.fn,r.capture),this},getEvent(r,t,e,s){if(typeof t!="object")return!1;let n=this.getEvents(t);if(!n||n.length<1)return!1;let i=this.create(r,t,e,s);return this.search(i,n)},search(r,t){let e,s=this.isSwappable(r.event);for(let n=0,i=t.length;n<i;n++)if(e=t[n],!(e.event!==r.event||e.obj!==r.obj)&&(e.fn===r.fn||s===!0&&e.originalFn===r.fn))return e;return!1},removeEvents(r){return typeof r!="object"||r===null?this:(p.remove(r,"events"),this)},swap:new Set(["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"]),addSwapped(r){this.swap.add(r)},isSwappable(r){return this.swap.has(r)}};p.addType("events",r=>{f.removeEvent(r)});var ae={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},oe=Object.keys(ae),Ss={events:f,addListener(r,t,e,s){return this.events.add(r,t,e,s),this},on(r,t,e,s){let n=this.events;if(Array.isArray(r))for(let i=0,o=r.length;i<o;i++)n.add(r[i],t,e,s);else n.add(r,t,e,s);return this},off(r,t,e,s){let n=this.events;if(Array.isArray(r))for(let i=0,o=r.length;i<o;i++)n.remove(r[i],t,e,s);else n.remove(r,t,e,s);return this},removeListener(r,t,e,s){return this.events.remove(r,t,e,s),this},_createEvent(r,t,e,s){let n;switch(t){case"HTMLEvents":n=new Event(r,e);break;case"MouseEvents":n=new MouseEvent(r,e);break;default:n=new CustomEvent(r,s);break}return n},createEvent(r,t,e,s){if(typeof t!="object"||t===null)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};typeof e=="object"&&e!==null&&(n=Object.assign(n,e));let i=this._getEventType(r);return this._createEvent(r,i,n,s)},_getEventType(r){for(let t=0,e=oe.length;t<e;t++){let s=oe[t];if(ae[s].test(r))return s}return"CustomEvent"},trigger(r,t,e){if(typeof t!="object"||t===null)return this;let s=typeof r=="string"?this.createEvent(r,t,null,e):r;return t.dispatchEvent(s),this},mouseWheelEventType:null,getWheelEventType(){let r=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=r())},onMouseWheel(r,t,e,s=!1){typeof t>"u"&&(t=window);let n=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof r=="function"&&r(a,o),e===!0&&o.preventDefault()},i=this.getWheelEventType();return this.events.add(i,t,n,s,!0,r),this},offMouseWheel(r,t,e=!1){typeof t>"u"&&(t=window);let s=this.getWheelEventType();return this.off(s,t,r,e),this},preventDefault(r){return typeof r.preventDefault=="function"?r.preventDefault():r.returnValue=!1,this},stopPropagation(r){return typeof r.stopPropagation=="function"?r.stopPropagation():r.cancelBubble=!0,this}};var nt=class{constructor(){this.errors=[],this.dataTracker=p}augment(t){if(!S.isObject(t))return this;let e=this.constructor.prototype;for(let s in t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return this}override(t,e,s,n){return(t[e]=s).apply(t,st.toArray(n))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,s){if(S.isObject(t)===!1)return"";let n=t[e];return typeof n<"u"?n:typeof s<"u"?s:""}createCallBack(t,e,s=[],n=!1){return typeof e!="function"?!1:(...i)=>(n===!0&&(s=s.concat(i)),e.apply(t,s))}bind(t,e){return e.bind(t)}};nt.prototype.extend=(function(){return nt.prototype})();var R=new nt;var it={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 ce=()=>{R.augment({xhrSettings:it,addFixedParams(r){this.xhrSettings.fixedParams=r},beforeSend(r){this.xhrSettings.beforeSend.push(r)},ajaxSettings(r){typeof r=="object"&&(this.xhrSettings=b.extendClass(R.xhrSettings,r))},resetAjaxSettings(){this.xhrSettings=it}})};var w=class{static limit(t,e=1e6){return typeof t!="string"?"":t.substring(0,e)}static parseQueryString(t,e,s=!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,s=>s[1].toUpperCase())}static uncamelCase(t,e="-"){t=this.limit(t);let s=/([A-Z]{1,})/g;return t.replace(s,n=>e+n.toLowerCase()).toLowerCase()}static titleCase(t){if(!t)return"";t=this.limit(t);let e=/\w\S*/;return t.replace(e,s=>s.charAt(0).toUpperCase()+s.substring(1).toLowerCase())}};var xt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR(),{method:s,url:n,async:i}=this.settings;e.open(s,n,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=it.beforeSend;if(t.length<1)return;let e=this.xhr,s=this.settings;for(var n=0,i=t.length;n<i;n++){var o=t[n];o&&o(e,s)}}objectToString(t){let e=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.push(s+"="+encodeURIComponent(t[s]));return e.join("&")}setupParams(t,e=null){let s=typeof t;if(!e)return!(t instanceof FormData)&&s==="object"&&(t=this.objectToString(t)),t;let n=typeof e;if(s==="string")return n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(n==="string"&&(e=w.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else s==="object"&&(t=b.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,s=t.params;return s?s=this.setupParams(s,e):e&&(s=this.setupParams(e)),s}getXhrSettings(t){let e=this.settings={...R.xhrSettings};if(t.length>=2&&typeof t[0]!="object")for(var s=0,n=t.length;s<n;s++){var i=t[s];switch(s){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=b.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 s in e)Object.prototype.hasOwnProperty.call(e,s)&&this.xhr?.setRequestHeader(s,e[s])}update(t,e){let s=this.xhr,n=()=>{f.removeEvents(s?.upload),f.removeEvents(s)},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;if(!t)return null;let e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr;if(!e)return;let s=this.update.bind(this);f.on(["load","error","abort"],e,s),f.on("progress",e.upload,s)}};ce();var zt=(...r)=>new xt(r).xhr;var ws=r=>typeof r!="string"?r:ue(r),ue=r=>[{tag:"text",textContent:r}],le=()=>({props:{},children:[]}),he=r=>({props:{},children:ue(r)}),fe=r=>({props:{},children:r}),de=r=>({props:r[0]||{},children:ws(r[1])});var St=class{constructor(){this.connections=new Map}add(t,e,s){let n=this.getOrCreate(t),i=n.get(e);return i?Array.isArray(i)?i.push(s):n.set(e,[i,s]):n.set(e,s),s}get(t,e){let s=this.connections.get(t)?.get(e);return s?Array.isArray(s)?s[s.length-1]||!1:s:!1}getOrCreate(t){let e=this.connections.get(t);return e||(e=new Map,this.connections.set(t,e)),e}remove(t,e){let s=this.connections.get(t);if(s)if(e)this.unsubscribe(s.get(e)),s.delete(e),s.size===0&&this.connections.delete(t);else{for(let n of s.values())this.unsubscribe(n);this.connections.delete(t)}}unsubscribe(t){if(t)if(Array.isArray(t))for(let e=0,s=t.length;e<s;e++)t[e]?.unsubscribe();else t.unsubscribe()}};var q=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var wt=class extends q{constructor(t){super(),this.data=t}subscribe(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribe - data source is null or does not have an "on" method. Make sure your component has data, state, or context.data initialized.',t,this.data);return}this.msg=t,this.token=this.data.on(t,e)}subscribeMany(t,e){if(!this.data||typeof this.data.on!="function"){console.warn('OneWaySource: Cannot subscribeMany - data source is null or does not have an "on" method.',t,this.data);return}let s=t.length,n=new Array(s);for(let i=0;i<s;i++){let o=t[i];n[i]={msg:o,token:this.data.on(o,e)}}this.subscriptions=n}unsubscribe(){if(this.data){let t=this.subscriptions;if(t){for(let e=0,s=t.length;e<s;e++)this.data.off(t[e].msg,t[e].token);this.subscriptions=null}else this.msg&&this.token&&this.data.off(this.msg,this.token)}this.data=null,this.msg=null,this.token=null}};var V=class{unsubscribe(){}};var ot=class extends V{constructor(){super(),this.source=null}addSource(t){return this.source=new wt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var G=class extends q{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 kt=class extends G{constructor(t,e,s){super(s),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 z=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?Array.from(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let s=document.querySelectorAll(t);return s?s.length===1?s[0]:Array.from(s):!1}static html(t,e){return!t||typeof t!="object"?!1:typeof e<"u"?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,s){return!t||typeof t!="object"||typeof e>"u"?this:(e=w.uncamelCase(e),t.style[e]=s,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=w.uncamelCase(e);let s=t.style[e];if(s!=="")return s;let n=null,i=t.currentStyle;if(i&&(n=i[e]))return n;let o=window.getComputedStyle(t,null);return o?o[e]:s}static css(t,e,s){return typeof s<"u"?(this.setCss(t,e,s),this):this.getCss(t,e)}static removeAttr(t,e){return typeof t=="object"&&t!==null&&t.removeAttribute(e),this}static setAttr(t,e,s){t.setAttribute(e,s)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,s){return!t||typeof t!="object"?!1:typeof s<"u"?(this.setAttr(t,e,s),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=w.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,s){e=this.removeDataPrefix(e),e=w.camelCase(e),t.dataset[e]=s}static getData(t,e){return e=w.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,s){return!t||typeof t!="object"?!1:typeof s<"u"?(this.setData(t,e,s),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?[]:t.querySelectorAll(e)}static show(t){if(!t||typeof t!="object")return this;let e=this.data(t,"style-display"),s=typeof e=="string"?e:"";return this.css(t,"display",s),this}static hide(t){if(!t||typeof t!="object")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!t||typeof t!="object"?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return!t||typeof t!="object"?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return typeof t=="object"&&t!==null?t.offsetWidth:!1}static getHeight(t){return typeof t=="object"&&t!==null?t.offsetHeight:!1}static getScrollPosition(t){let e=0,s=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,s=t.scrollTop;break;case"object":e=t.scrollLeft,s=t.scrollTop;break}return!t||typeof t!="object"?!1:{left:e-(t.clientLeft||0),top:s-(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,s=e.documentElement,n=e.getElementsByTagName("body")[0],i=t.innerWidth||s.clientWidth||n.clientWidth,o=t.innerHeight||s.clientHeight||n.clientHeight;return{width:i,height:o}}static getDocumentSize(){let t=document,e=t.body,s=t.documentElement,n=Math.max(e.scrollHeight,e.offsetHeight,s.clientHeight,s.scrollHeight,s.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,s.clientWidth,s.scrollWidth,s.offsetWidth),height:n}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let s={x:0,y:0};if(!t||typeof t!="object")return s;let n=0;for(;t&&(e===0||n<e);)n++,s.x+=t.offsetLeft+t.clientLeft,s.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return s}static addClass(t,e){if(!t||typeof t!="object"||e==="")return this;if(typeof e=="string"){let s=e.split(" ");for(let n=0,i=s.length;n<i;n++)t.classList.add(s[n])}return this}static removeClass(t,e){return!t||typeof t!="object"||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return!t||typeof t!="object"||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return!t||typeof t!="object"?this:(t.classList.toggle(e),this)}};var vt=r=>{let t="textContent";if(!r||typeof r!="object")return t;let e=r.tagName.toLowerCase();if(e==="input"||e==="textarea"||e==="select"){let s=r.type;if(!s)return t="value",t;switch(s){case"checkbox":t="checked";break;case"file":t="files";break;default:t="value"}}return t};var ks=(r,t,e)=>{z.setAttr(r,t,e)},vs=(r,t,e)=>{r.checked=r.value==e},Cs=(r,t,e)=>{e=e==1,pe(r,t,e)},pe=(r,t,e)=>{r[t]=e},Ts=(r,t)=>z.getAttr(r,t),As=(r,t)=>r[t],Ct=class extends G{constructor(t,e,s,n){super(n),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof s=="string"?this.setupFilter(s):s}addSetMethod(t,e){if(e.charAt(4)==="-")return this.setValue=ks,this.getValue=Ts,this;this.getValue=As;let s=t.type;if(s)switch(s){case"checkbox":return this.setValue=Cs,this;case"radio":return this.setValue=vs,this}return this.setValue=pe,this}getAttrBind(t){return t||vt(this.element)}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return s=>t.replace(e,s)}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={},this.attr="",this.filter=null,this.setValue=null,this.getValue=null}};var Tt=class extends V{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,s){return this.element=new Ct(t,e,s,this.pubSub)}addData(t,e){return this.data=new kt(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 me=-1,$=class{constructor(){this.callBacks=new Map,this.updateQueue=new Map,this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this.maxFlushIterations=2e3,this.batchingEnabled=!0,this.debugMode=!1,this.flushCompleteResolvers=[],this.flushCallbacks=[]}get(t){return this.callBacks.has(t)||this.callBacks.set(t,new Map),this.callBacks.get(t)}reset(){this.callBacks.clear(),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,me=-1}on(t,e){let s=(++me).toString();return this.get(t).set(s,e),s}off(t,e){let s=this.callBacks.get(t);s&&(e=String(e),s.delete(e),s.size===0&&this.callBacks.delete(t))}remove(t){this.callBacks.delete(t)}publish(t,e,s){if(!this.batchingEnabled){this.publishImmediate(t,e,s);return}this.updateQueue.set(t,[e,s]),this.debugMode&&console.log("[DataPubSub] Queued update:",t,e),this.scheduleFlush()}scheduleFlush(){this.isFlushing||this.flushScheduled||(this.flushScheduled=!0,queueMicrotask(()=>{this.flush()}))}flush(){if(this.updateQueue.size===0){this.flushScheduled=!1,this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete();return}if(this.isFlushing||(this.flushIterations=0),this.isFlushing=!0,this.flushScheduled=!1,this.flushIterations++,this.flushIterations>this.maxFlushIterations){console.error("[DataPubSub] Infinite loop detected! Flush iterations exceeded",this.maxFlushIterations,"- Breaking to prevent memory exhaustion."),console.error("[DataPubSub] Queue size:",this.updateQueue.size),console.error("[DataPubSub] Queued messages:",Array.from(this.updateQueue.keys())),this.updateQueue.clear(),this.flushScheduled=!1,this.isFlushing=!1,this._resolveFlushComplete(),this.flushIterations=0;return}this.debugMode&&console.log("[DataPubSub] Flushing",this.updateQueue.size,"updates (iteration",this.flushIterations+")");let t=this.updateQueue;this.updateQueue=new Map;try{for(let[e,s]of t)this.publishImmediate(e,s[0],s[1])}finally{this.debugMode&&console.log("[DataPubSub] Flush complete (iteration",this.flushIterations+")"),this.updateQueue.size>0?(this.debugMode&&console.log("[DataPubSub] New updates queued during flush, re-flushing..."),this.flush()):(this.isFlushing=!1,this.flushIterations=0,this._resolveFlushComplete())}}_resolveFlushComplete(){if(this.flushCompleteResolvers.length>0){let t=this.flushCompleteResolvers;this.flushCompleteResolvers=[];let e=t.length;for(let s=0;s<e;s++)t[s]()}if(this.flushCallbacks.length>0){let t=this.flushCallbacks;this.flushCallbacks=[];let e=t.length;for(let s=0;s<e;s++)t[s]()}}nextFlush(){return new Promise(t=>{this.flushCompleteResolvers.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>t())})}onFlush(t){if(typeof t!="function"){console.warn("[DataPubSub] onFlush requires a function callback");return}this.flushCallbacks.push(t),!this.flushScheduled&&!this.isFlushing&&queueMicrotask(()=>{if(this.flushCallbacks.length>0){let e=this.flushCallbacks;this.flushCallbacks=[];let s=e.length;for(let n=0;n<s;n++)e[n]()}})}flushSync(){this.flush()}publishImmediate(t,e,s){let n=this.callBacks.get(t);if(n){for(let i of n.values())if(i)try{i(e,s)}catch(o){console.error('[DataPubSub] Subscriber error for "'+t+'":',o)}}}};var $t=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=new Set([20,37,38,39,40]),this.connections=new St,this.pubSub=new $,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,s,n){let i=s,o=null,a=s.indexOf(":");a!==-1&&(o=s.substring(0,a),i=s.substring(a+1));let c=o??"",u=this.setupConnection(t,e,i,c,n),l=u.element,h=e.get(i);return typeof h<"u"?l.set(h):(h=l.get(),h!==""&&u.data.set(h)),this}setupConnection(t,e,s,n,i){let o=this.getBindId(t),a=new Tt(this.pubSub);a.addData(e,s).subscribe(o);let l=`${e.getDataId()}:${s}`;return a.addElement(t,n,i).subscribe(l),this.addConnection(o,"bind",a),a}addConnection(t,e,s){return this.connections.add(t,e,s),this}setBindId(t){let e="db-"+this.idCount++;return 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,s,n){if(S.isObject(t)===!1)return this;let i=new ot,o=e.get(s),a=!0,c=g=>{a&&(a=!1,g===o)||n(g)};i.addSource(e).subscribe(s,c);let l=this.getBindId(t),h=e.getDataId()+":"+s;return this.addConnection(l,h,i),n(o),this}watchMany(t,e,s,n){if(S.isObject(t)===!1)return this;let i=s?s.length:0;if(i===0)return this;if(i===1)return this.watch(t,e,s[0],n);let o=new ot,a=o.addSource(e),c=new Array(i),u=new Array(i);for(let d=0;d<i;d++)c[d]=e.get(s[d]),u[d]=!0;let l=new Array(i);for(let d=0;d<i;d++){let C=d,E=c[d];l[d]=gt=>{u[C]&&(u[C]=!1,gt===E)||n(gt)}}if(typeof e.on!="function")return console.warn('DataBinder.watchMany: data source has no "on" method.',e),this;let h=new Array(i);for(let d=0;d<i;d++)h[d]={msg:s[d],token:e.on(s[d],l[d])};a.subscriptions=h;let g=this.getBindId(t),y=e.getDataId()+":"+s.join(",");return this.addConnection(g,y,o),n(c[0]),this}unwatch(t,e,s){if(S.isObject(t)===!1)return this;let n=t[this.attr];if(n){let i=e.getDataId()+":"+s;this.connections.remove(n,i)}return this}publish(t,e,s){return this.pubSub.publish(t,e,s),this}isDataBound(t){if(!t)return null;let e=t[this.attr];return e||null}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.has(t.keyCode)}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,s=this.isDataBound(e);if(s!==null){let n=this.connections.get(s,"bind");if(n){let i=n.element.get();this.pubSub.publish(s,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 $t;var A=r=>r.data?r.data:r.context&&r.context.data?r.context.data:r.state?r.state:null;var Ds=new Map([["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"]]),at=r=>Ds.get(r)||r,ct=r=>typeof r=="string"&&r.charCodeAt(0)===111&&r.charCodeAt(1)===110?r.substring(2):r,Ps=/(?:<[a-z][\s\S]*>)/i,D=class{static create(t,e,s,n){let i=document.createElement(t);return this.addAttributes(i,e),n===!0?this.prepend(s,i):this.append(s,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return;let s=e.type;s!==void 0&&t.setAttribute("type",s);let n=Object.keys(e);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=e[a];a==="innerHTML"?t.innerHTML=c:a.indexOf("-")!==-1?t.setAttribute(a,c):this.addAttr(t,a,c)}}static addHtml(t,e){return typeof e>"u"||e===""?this:(Ps.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,s){if(s===""||!e)return;if(typeof s==="function")e=ct(e),s.originalCallback?f.add(e,t,s,!1,!0,s.originalCallback):f.add(e,t,s);else{let i=at(e);t[i]=s}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let s=document.createTextNode(t);return e&&this.append(e,s),s}static createComment(t,e){let s=document.createComment(t);return e&&this.append(e,s),s}static setupSelectOptions(t,e,s){if(!t||typeof t!="object"||!Array.isArray(e))return!1;e.forEach(n=>{let i=new Option(n.label,n.value);t.options.add(i),s!==null&&i.value==s&&(i.selected=!0)})}static removeElementData(t){let e=[t];for(;e.length>0;){let s=e.pop(),n=s.childNodes;if(n&&n.length>0)for(let i=n.length-1;i>=0;i--)e.push(n[i]);p.remove(s),s.bindId&&x.unbind(s)}}static removeElement(t){if(!t)return this;let e=p.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(!t||typeof t!="object")return this;let e;for(;e=t.firstChild;)this.removeElementData(e),t.removeChild(e);return this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,s){let n=s||t.firstChild;return t.insertBefore(e,n),this}static clone(t,e=!1){return!t||typeof t!="object"?!1:t.cloneNode(e)}};var k=class extends D{static create(t,e,s,n){let i=document.createElement(t);return this.addAttributes(i,e,n),s.appendChild(i),i}static addAttributes(t,e,s){if(!(!e||e.length<1))for(let n=0,i=e.length;n<i;n++){let o=e[n];this.addAttr(t,o.key,o.value,s)}}static addAttr(t,e,s,n){if(s===""||!e||e==="children")return;if(e==="innerHTML"){t.innerHTML=s;return}if(typeof s==="function"){if(e=ct(e),s.originalCallback)f.add(e,t,s,!1,!0,s.originalCallback);else{let a=s,c=function(u){a.call(this,u,n)};f.add(e,t,c,!1,!0,a)}return}if(e.charCodeAt(4)===45){t.setAttribute(e,s);return}let o=at(e);t[o]=s}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 ge=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,ye=new Map,T={isWatching(r){if(Array.isArray(r)){let t=r[0];return typeof t=="string"&&t.includes("[[")}return this.hasParams(r)},hasParams(r){return typeof r=="string"&&r.includes("[[")},_getWatcherProps(r){let t=ye.get(r);if(t!==void 0)return t;let e=r.match(ge),s=e?e.map(n=>n.slice(2,-2)):null;return ye.set(r,s),s},updateAttr(r,t,e){switch(t){case"text":case"textContent":r.textContent=e;break;case"disabled":r.disabled=!e;break;case"checked":r.checked=!!e;break;case"required":r.required=!!e;break;case"src":if(r.tagName==="IMG"){r.src=e&&(e.indexOf(".")!==-1||e.indexOf("blob:")!==-1)?e:"";break}r.src=e;break;default:k.addAttr(r,t,e);break}},replaceParams(r,t,e=!1){let s=0;return r.replace(ge,function(n,i,o){let a=e?t[s]:t;s++;let c=a.get(o);return c??""})},_getWatcherCallBack(r,t,e,s,n){return()=>{let i=this.replaceParams(e,t,n);this.updateAttr(r,s,i)}},getValue(r,t){let e=r.value;return Array.isArray(e)===!1?[e,A(t)]:(e.length<2&&e.push(A(t)),e)},getPropValues(r,t,e){let s=[];for(let n=0,i=t.length;n<i;n++){let a=(e?r[n]:r).get(t[n])??"";s.push(a)}return s},getCallBack(r,t,e,s,n,i){let o=r.attr||"textContent",a=r.callBack;if(typeof a=="function"){let c=i||this._getWatcherProps(s)||[],u=c.length>1;return(l,h)=>{l=u!==!0?l:this.getPropValues(e,c,n);let g=a(l,t,h);typeof g<"u"&&this.updateAttr(t,o,g)}}return this._getWatcherCallBack(t,e,s,o,n)},addDataWatcher(r,t,e){let s=this.getValue(t,e),n=s[1]??e?.data??e?.context?.data??e?.state??null;if(!n)return;let i=s[0],o=Array.isArray(n),a=this._getWatcherProps(i),c=this.getCallBack(t,r,n,i,o,a);if(!o)a.length>1?x.watchMany(r,n,a,c):this.addWatcher(r,n,a[0],c);else for(let u=0,l=a.length;u<l;u++)this.addWatcher(r,n[u],a[u],c)},getWatcherSettings(r,t=null){if(typeof r=="string")return{attr:t,value:r};if(Array.isArray(r)){let e=r[r.length-1];e&&typeof e=="object"&&(e=t!==null?t:null);let s=r[1]&&typeof r[1]=="object"?[r[0],r[1]]:[r[0]];return typeof e=="function"?{attr:t,value:s,callBack:e}:{attr:e||"textContent",value:s}}return r},setup(r,t,e){t&&this.addDataWatcher(r,this.getWatcherSettings(t),e)},addWatcher(r,t,e,s){x.watch(r,t,e,s)}};var Es=r=>({props:{watch:r},children:[]}),Ms=r=>{if(r.length===0)return le();let t=r[0],e=typeof t;if(e==="string"||e==="number")return he(t);if(Array.isArray(t))return T.isWatching(t)?Es(t):fe(t);let s=r[1]??r[0]??[];return s&&Array.isArray(s)&&T.isWatching(s)&&(r[0]=Array.isArray(r[0])?{}:r[0],r[0].watch=s,r[1]=[]),de(r)},Is=r=>(...t)=>{let{props:e,children:s}=Ms(t);return r(e,s)};var be=new WeakMap,jt=new WeakMap;function we(r){if(!r||typeof r!="object")return r;let t=jt.get(r);return t!==void 0?t:r}var xe=new WeakMap;function Os(r,t,e,s){let n=be.get(r);n||(n=new Map,be.set(r,n));let i=n.get(e);if(i)return i;let o=new Proxy(r,ke(t,e,s));return n.set(e,o),jt.set(o,r),o}function Se(r,t){let e=t.charCodeAt(0),s=e>=48&&e<=57;return r===""?s?"["+t+"]":t:s?r+"["+t+"]":r+"."+t}function ke(r,t="",e=""){return{get(s,n,i){let o=s[n];if(t===""&&n in s){if(typeof o=="function"){let c=xe.get(s);c||(c=new Map,xe.set(s,c));let u=c.get(n);if(u)return u;let l=o.bind(s);return c.set(n,l),l}return o}if(o=(s[e]||s)[n],o!==null&&typeof o=="object"){let c=Se(t,n);return Os(o,r,c,e)}return o},set(s,n,i,o){if(t===""&&n in s)return s[n]=i,!0;let a=Se(t,n);return r.set(a,i),!0}}}var At=(r,t="stage")=>{let e=new Proxy(r,ke(r,"",t));return jt.set(e,r),e};var ut=class{static resume(t,e){if(!t)return null;let s,n=localStorage.getItem(t);return n===null?e&&(s=e):s=JSON.parse(n),s}static store(t,e){if(!t||!e)return!1;let s=JSON.stringify(e);return localStorage.setItem(t,s),!0}static remove(t){return t?(localStorage.removeItem(t),!0):!1}};var Dt=(r={})=>{let t={};if(!S.isObject(r))return t;let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i];typeof o!="function"&&(t[i]=o)}return t};var _s=0,ve=new Map,H={CHANGE:"change",DELETE:"delete"},Qt=(r,t)=>{let e=ve.get(r);return e||(e={change:`${r}:change`,delete:`${r}:delete`},ve.set(r,e)),t==="change"?e.change:e.delete},M=class{constructor(t={}){this.dirty=!1,this._retainState=!1,this._refreshState=!1,this.links=new Map,this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new $;let e=Dt(t);this.set(e);let s=At(this);return this._proxy=s,s}retainState(){return this._retainState=!0,this._proxy||this}refreshState(){return this._refreshState=!0,this._proxy||this}setup(){this.stage={}}_init(){let t=++_s;this._dataNumber=t,this._id=`dt-${t}`,this._dataId=`${this._id}:`}onFlush(t){this.eventSub.onFlush(t)}flushPending(){this.eventSub.flush()}getDataId(){return String(this._id)}remove(){}on(t,e){let s=Qt(t,H.CHANGE);return this.eventSub.on(s,e)}off(t,e){let s=Qt(t,H.CHANGE);this.eventSub.off(s,e)}_setAttr(t,e,s=this,n=!1){let i=this.stage[t];e!==i&&(this.stage[t]=e,this._publish(t,e,s,H.CHANGE))}publishLocalEvent(t,e,s,n){let i=Qt(t,n);this.eventSub.publish(i,e,s)}_publish(t,e,s,n){this.publishLocalEvent(t,e,s,n),s=s||this,x.publish(this._dataId+t,e,s)}set(t,e,s){if(typeof t!="object")return this._setAttr(t,e,s),this;let n=Object.keys(t);for(let i=0;i<n.length;i++){let o=n[i],a=t[o];typeof a!="function"&&this._setAttr(o,a,e,s)}return this}_silentSet(t){let e=this.stage,s=Object.keys(t);for(let n=0,i=s.length;n<i;n++){let o=s[n];e[o]=t[o]}}getModelData(){return this.stage}_deleteAttr(t,e,s=this){delete t[e],this.publishLocalEvent(e,null,s,H.DELETE)}toggle(t){return typeof t>"u"?this:(this.set(t,!this.get(t)),this)}increment(t,e=null){if(typeof t>"u")return this;e=e!==null&&typeof e=="number"?e:1;let s=this.get(t);return this.set(t,s+e),this}decrement(t,e=null){if(typeof t>"u")return this;e=e!==null&&typeof e=="number"?e:1;let s=this.get(t);return this.set(t,s-e),this}concat(t,e){if(typeof t>"u")return this;let s=this.get(t);return this.set(t,s+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=ut.resume(String(this.key),t);return e?(this.set(e),this):this}store(){let t=this.get();return ut.store(String(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,s){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,s);let n=[];return Object.entries(e).forEach(([i])=>{n.push(this.remoteLink(t,i))}),n}remoteLink(t,e,s){let n=s||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;b.isEmpty(e)||(e.forEach((s,n)=>{this.removeLink(n,!1)}),this.links=new Map)}removeLink(t,e=!0){let s=this.links.get(t);s&&s.off(t),e!==!1&&this.links.delete(t)}};M.prototype.isData=!0;var Yt=class{constructor(t=1e3){this.cache=new Map,this.maxSize=t}get(t){return this.cache.get(t)}set(t,e){if(this.cache.delete(t),this.cache.set(t,e),this.cache.size>this.maxSize){let s=this.cache.keys().next().value;this.cache.delete(s)}}clear(){this.cache.clear()}},P={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,segmentCache:new Yt(1e3),hasDeepData(r){return r.indexOf(".")!==-1||r.indexOf("[")!==-1},getSegments(r){let t=this.segmentCache.get(r);if(t!==void 0)return t;let e=this.deepDataPattern;return t=r.match(e),this.segmentCache.set(r,t),t}};var N=class{static set(t,e,s){if(!P.hasDeepData(e)){t[e]=s;return}let n,i=P.getSegments(e);if(!i)return;let o=i.length,a=o-1;for(let c=0;c<o;c++){let u=i[c];if(c===a){t[u]=s;break}if(t[u]===void 0){let l=u.charCodeAt(0);t[u]=l<48||l>57?{}:[]}t=t[u]}}static delete(t,e){if(!P.hasDeepData(e)){delete t[e];return}let s=P.getSegments(e);if(!s)return;let n=s.length,i=n-1;for(let o=0;o<n;o++){let a=s[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(!P.hasDeepData(e))return t[e]??void 0;let s=P.getSegments(e);if(!s)return;let n=s.length,i=n-1;for(let o=0;o<n;o++){let a=s[o],c=t[a]??void 0;if(c===void 0)break;if(t=c,o===i)return t}}};var Ce=new Set,lt=class{static MAX_DEPTH=50;static publishDeep(t,e,s,n){if(!P.hasDeepData(e)){this.publish(e,s,n);return}let i,o=P.getSegments(e);if(!o)return;let a=o.length,c=a-1,u="";for(let l=0;l<a;l++){let h=o[l];t=t[h];let g=h.charCodeAt(0);l>0?(g<48||g>57)&&(u+="."+h):u=h;let y;if(l===c)y=s;else{let d=o[l+1],C=d.charCodeAt(0);if(C>=48&&C<=57){u+="["+d+"]";continue}let E={};E[d]=t[d],y=E}this.publish(u,y,n)}}static publish(t,e,s,n=null,i=0){if(t=t||"",s(t,e),!(!e||typeof e!="object"||(e=we(e),n===null&&(Ce.clear(),n=Ce),!n))){if(n.has(e)){console.warn("[Publisher] Circular reference detected at path:",t);return}if(i>=this.MAX_DEPTH){console.warn("[Publisher] Max depth exceeded at path:",t,"- stopping recursion");return}n.add(e),Array.isArray(e)?this.publishArray(t,e,s,n,i):this.publishObject(t,e,s,n,i)}}static publishArray(t,e,s,n,i){let o=e.length;for(let a=0;a<o;a++){let c=e[a],u=t+"["+a+"]";this._checkPublish(u,c,s,n,i)}}static publishObject(t,e,s,n,i){let o=Object.keys(e);for(let a=0,c=o.length;a<c;a++){let u=o[a],l=e[u],h=t+"."+u;this._checkPublish(h,l,s,n,i)}}static _checkPublish(t,e,s,n,i){if(!e||typeof e!="object"){s(t,e);return}this.publish(t,e,s,n,i+1)}};var B=class extends M{setup(){this.attributes={},this.stage={}}_setAttr(t,e,s,n){typeof e!="object"&&e===this.get(t)||(!s&&n!==!0?N.set(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),N.set(this.stage,t,e),s=s||this,this._publish(t,e,s,H.CHANGE))}_silentSet(t){let e=this.stage,s=this.attributes,n=Object.keys(t);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=t[a];e[a]=c,s[a]=c}}linkAttr(t,e){let s=t.get(e);if(!s)return;let n=Object.keys(s);for(let i=0,o=n.length;i<o;i++){let a=n[i];this.link(t,e+"."+a,a)}}scope(t,e){let s=this.get(t);if(!s)return!1;e=e||this.constructor;let n=new e(s);return n.linkAttr(this,t),n}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s.push(e),this.set(t,s),this}concat(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s=s.concat(e),this.set(t,s),this}unshift(t,e){let s=this.get(t);return Array.isArray(s)===!1&&(s=[]),s.unshift(e),this.set(t,s),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let s=e.shift();return this.set(t,e),s}getIndex(t,e,s){let n=this.get(t);return Array.isArray(n)===!1?-1:typeof n[0]!="object"?n.indexOf(e):n.findIndex(o=>o[e]===s)}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let s=e.pop();return this.set(t,e),s}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,s,n){this._pubCommitter=s,this._pubEvent=n;let i=this._publishCb||(this._publishCb=(o,a)=>this._publishAttr(o,a,this._pubCommitter,this._pubEvent));lt.publish(t,e,i)}_publishAttr(t,e,s,n){let i=this._dataId+t;x.publish(i,e,s),this.publishLocalEvent(t,e,s,n)}mergeStage(){this.attributes=b.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e,s=this){N.delete(t,e),this._delCommitter=s;let n=this._deleteCb||(this._deleteCb=(i,o)=>this.publishLocalEvent(i,o,this._delCommitter,H.DELETE));lt.publish(e,e,n)}_getAttr(t,e){return N.get(t,e)}};var Rs={"\n":"\\n","\r":"\\n"," ":"\\t"},Bs=(r,t)=>{typeof r!="string"&&(r=String(r));let e=t?/[\n\r\t]/g:/\t/g;return r.replace(e,s=>Rs[s])},Te=(r,t)=>{if(typeof r!="string")return r;r=Bs(r,t),r=encodeURIComponent(r);let e=/%22/g;return r.replace(e,'"')},Jt=(r,t)=>{let e=typeof r;return e==="undefined"?r:e!=="object"?(r=Te(r),r):(Object.keys(r).forEach(s=>{let n=r[s];n!==null&&(r[s]=typeof n=="string"?Jt(n,t):Te(n,t))}),r)};function Ae(r){return typeof r<"u"&&r.length>0?JSON.parse(r):!1}function Xt(r){return typeof r<"u"?JSON.stringify(r):null}var ht=class{static prepareJsonUrl(t,e=!1){let s=typeof t=="object"?b.clone(t):t,n=Jt(s,e);return Xt(n)}static json={encode:Xt,decode:Ae};static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};var Pt=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 s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.push(s+"="+t[s]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=w.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=w.parseQueryString(e,!1)),this._isFormData(t))for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.append(s,e[s]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let s=this.model.get("id"),n="id="+s,i=s?`/${s}`:"",o=this.model;return this._get(i,n,t,e,a=>{if(a){let c=this.getObject(a);c&&o.set(c)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+ht.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._put(i,s,t,e)}add(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._post(i,s,t,e)}update(t,e){if(!this.isValid())return;let s=this.setupObjectData(),n=this.model.id,i=n!=null?`/${n}`:"";return this._patch(i,s,t,e)}delete(t,e){let s=this.model.get("id"),n=typeof s<"u"?"id="+s:this.setupObjectData(),i=s!=null?`/${s}`:"";return this._delete(i,n,t,e)}getAllParams(t,e,s,n){let i=this.model.get();t=isNaN(Number(t))?0:t,e=isNaN(Number(e))?50:e;let o=i.search||"",a=i.filter||"";typeof a=="object"&&(a=JSON.stringify(a));let c=i.dates||"";typeof c=="object"&&(c=JSON.stringify(c));let u=i.orderBy||"";typeof u=="object"&&(u=JSON.stringify(u));let l=i.groupBy||"";return Array.isArray(l)&&(l=JSON.stringify(l)),"&filter="+a+"&offset="+t+"&limit="+e+"&dates="+c+"&orderBy="+u+"&groupBy="+l+"&search="+o+"&lastCursor="+(typeof s<"u"&&s!==null?s:"")+"&since="+(typeof n<"u"&&n!==null?n:"")}all(t,e,s,n,i=null,o=null){let a=this.getAllParams(s,n,i,o);return this._get("",a,t,e)}getUrl(t){let e=this.url;if(!t)return this.replaceUrl(e);t[0]==="/"&&(t=t.substring(1));let s=t[0]==="?"?e+t:e+"/"+t;return this.replaceUrl(s)}setupRequest(t,e,s,n,i){let o={url:this.getUrl(t),method:e,params:s,completed:(c,u)=>{typeof i=="function"&&i(c),this.getResponse(c,n,u)}};return this._isFormData(s)&&(o.headers={}),zt(o)}setupEventSource(t,e,s,n,i=!0){let o=null,a,c=!1,u=!1,l=()=>{a&&(clearTimeout(a),a=void 0)},h=()=>{if(c||!i||u)return;l(),a=setTimeout(()=>{a=void 0,g()},3e3)},g=()=>{if(c||u)return;if(o){try{o.close()}catch{}o=null}u=!0;let y=this.getUrl(t),d=e?"?"+e:"";o=new EventSource(y+d,{withCredentials:!0}),o.onopen=()=>{u=!1,l(),n&&n()},o.onerror=()=>{u=!1,o&&o.readyState===EventSource.CLOSED&&(o=null,h())},o.onmessage=C=>{try{let E=JSON.parse(C.data);s&&s(E)}catch{}}};return g(),{get source(){return o},close:()=>{if(c=!0,u=!1,l(),o){try{o.close()}catch{}o=null}}}}replaceUrl(t){return T.isWatching(t)&&(t=T.replaceParams(t,this.model)),t.endsWith("/")&&(t=t.substring(0,t.length-1)),t}_isFormData(t){return t instanceof FormData}request(t,e,s,n){return this._request("","POST",t,e,s,n)}_get(t,e,s,n,i){return e=this.setupParams(e),e=this.addParams(e,s),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",n,i)}_post(t,e,s,n,i){return this._request(t,"POST",e,s,n,i)}_put(t,e,s,n,i){return this._request(t,"PUT",e,s,n,i)}_patch(t,e,s,n,i){return this._request(t,"PATCH",e,s,n,i)}_delete(t,e,s,n,i){return this._request(t,"DELETE",e,s,n,i)}_request(t,e,s,n,i,o){return s=this.setupParams(s),s=this.addParams(s,n),this.setupRequest(t,e,s,i,o)}getResponse(t,e,s){typeof e=="function"&&e(t,s)}static extend(t){if(!t)return{};let e=this;class s extends e{constructor(i){super(i)}}return Object.assign(s.prototype,t),s}};var Ls=r=>{let t={};if(!S.isObject(r)||!r.defaults)return t;let{defaults:e}=r;return Object.keys(e).forEach(s=>{let n=e[s];typeof n!="function"&&(t[s]=n)}),delete r.defaults,t},Hs=r=>{if(!r||typeof r.xhr!="object")return{};let t={...r.xhr};return delete r.xhr,t},Ns=0,ft=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,s=Hs(t),n=e.prototype.service.extend(s),i=Ls(t);class o extends e{constructor(c){let u={...i,...Dt(c)};super(u),this.xhr=new n(this)}dataTypeId=`bm${Ns++}`}return Object.assign(o.prototype,t),o.prototype.service=n,o}};ft.prototype.service=Pt;var j=class extends M{};var dt=class extends j{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 s=this.stage;return typeof s[t]<"u"&&delete s[t],this}};var Et=class extends dt{constructor(t){super(),this.id=t}setup(){this.stage={},this.id=""}};var I=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 Et(t)),this.targets.get(t)}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,s){let n=this.getTarget(t);return e&&n.addAction(e,s),n}static addAction(t,e,s){return this.add(t,e,s)}static removeAction(t,e,s){s&&this.off(t,e,s)}static on(t,e,s){let n=this.getTarget(t);return e?n.on(e,s):null}static off(t,e,s){this.remove(t,e,s)}static remove(t,e,s){let n=this.targets,i=n.get(t);if(i){if(e){i.off(e,s);return}this.targets.delete(t)}}static set(t,e,s){this.getTarget(t).set(e,s)}};var Q=class{static resume(t,e){if(t._externalData){this._resumeExternal(t,e);return}this._resumeOwned(t,e)}static refresh(t){let e=t.setData();e&&t.data&&t.data.set(e.stage),this.refreshContext(t)}static refreshContext(t){let e=t.context;if(!e||!e.data)return;let s=t.getParentContext();if(!s||!s.data)return;let n=s.data.stage,i=e.data.stage,o=null;for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;let c=n[a];c!==i[a]&&(o===null&&(o={}),o[a]=c)}o!==null&&(typeof e.data._silentSet=="function"?e.data._silentSet(o):e.data.set(o))}static _resumeExternal(t,e){let s=t.setData();if(!s){t.data=e;return}if(e&&e.stage){let n=e._retainState||s._retainState,i=!n&&(e._refreshState||s._refreshState),o=this._buildExternalUpdates(e.stage,s.stage,n,i);b.isEmpty(o)||s._silentSet(o)}typeof s.flushPending=="function"&&s.flushPending(),t.data=s}static _buildExternalUpdates(t,e,s,n){let i={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;if(n){Object.prototype.hasOwnProperty.call(e,o)||(i[o]=t[o]);continue}let a=t[o];!s&&a==null||a!==e[o]&&(i[o]=a)}return i}static _resumeOwned(t,e){if(!t.data){t.data=e;return}if(e&&e._retainState){t.data=e;return}if(e&&e.stage){let s=e._refreshState||t.data._refreshState,n=this._buildOwnedUpdates(e.stage,t.data.stage,s);b.isEmpty(n)||t.data._silentSet(n)}t.data&&typeof t.data.flushPending=="function"&&t.data.flushPending()}static _buildOwnedUpdates(t,e,s){let n={};for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(s){Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);continue}let o=t[i];o!=null&&o!==e[i]&&(n[i]=o)}return n}};var Mt=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(!(e<1))for(let s=0;s<e;s++){let n=t[s];this.on(n[0],n[1],n[2],n[3])}}on(t,e,s,n){f.on(t,e,s,n),this.events.push({event:t,obj:e,callBack:s,capture:n})}off(t,e,s,n){f.off(t,e,s,n);let i,o=this.events;for(let a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.obj===e){o.splice(a,1);break}}set(){let t=this.events;for(let e=0,s=t.length;e<s;e++){let n=t[e];f.on(n.event,n.obj,n.callBack,n.capture)}}unset(){let t=this.events;for(let e=0,s=t.length;e<s;e++){let n=t[e];f.off(n.event,n.obj,n.callBack,n.capture)}}reset(){this.unset(),this.events=[]}};var It=class{constructor(t,e){this.remoteStates=[];let s=this.convertStates(e);this.addStatesToTarget(t,s)}addStates(t,e){let s=this.convertStates(e);this.addStatesToTarget(t,s)}createState(t,e,s,n){return{action:t,state:e,callBack:s,targetId:n,token:null}}convertStates(t){let e=[];for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;if(s==="remotes"){this.setupRemoteStates(t[s],e);continue}let n=null,i=null,o=t[s];o&&typeof o=="object"&&(i=o.callBack,n=o.id||o.targetId,o=o.state),e.push(this.createState(s,o,i,n))}return e}setupRemoteStates(t,e){for(let s=0,n=t.length;s<n;s++){let i=t[s];if(i)for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o)||o==="id")continue;let a=null,c=i[o],u=c!==null?c:void 0;u&&typeof u=="object"&&(a=u.callBack,u=u.state),e.push(this.createState(o,u,a,i.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(let s=0,n=e.length;s<n;s++){let i=e[s];i.token&&this.unbindRemoteState(t,i.token),i.targetId&&I.remove(i.targetId,i.action,i.token)}}restore(t){I.restore(t.id,t);let e=this.remoteStates;if(e)for(let s=0,n=e.length;s<n;s++){let i=e[s];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,s){let n=I.getTarget(s);return t.link(n,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let s=this.remoteStates;for(let n=0,i=e.length;n<i;n++){let o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,s.push(o))}}addAction(t,e){let s,n=e.action,i=e.targetId;i&&(s=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),s||null}};p.addType("components",r=>{if(!r)return;let t=r.component;!t||!t.isUnit||(t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken),t.rendered===!0&&(t.prepareDestroy(),t.cleanUpAfterDestroy()))});var Us=0,pt=class{constructor(t,e,s){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._classId,this.id="",this.cached=[],this.init();let n,i;if(t==null)n={},i=[];else{let o=typeof t;o==="string"||o==="number"?(n={},i=[{tag:"text",textContent:t}]):Array.isArray(t)?(n={},i=t):(n=t||{},i=typeof e=="string"?[{tag:"text",textContent:e}]:e)}this.setupProps(n),this.children=i||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Us++,this.unitType=this._classId||this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=t.key,s=t.cache,n;s!=null&&e!=null?n="pk:"+s+":"+e:s!=null?n="pk:"+s:e!=null?n="pk:"+e:n="pc"+this.persistedCount++;let i=this.persistedChildren[n];return i&&t.unitType===i.unitType&&t.resumeScope(i),t.persistToken=n,this.persistedChildren[n]=t,n}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e],e==="data"&&(this._externalData=!0))}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){if(this._contextResumed)return;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 s=e[0];s&&(this.addingContext=!0,this.contextBranchName=s,this.addContextBranch(s,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(){p.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 s=[];if(!t||t.length<1)return s;for(let n=0,i=t.length;n<i;n++){let o=e(t[n],n);s.push(o)}return s}removeAll(t){return D.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}cacheEle(t,e){e&&(this[e]=t,this.cached.push(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;t&&D.removeElement(t),this.cleanUpAfterDestroy()}cleanUpAfterDestroy(){this.panel=null,this.container=null;let t=this.cached;for(let e=0,s=t.length;e<s;e++)this[t[e]]=null;this.cached=[],this.persist!==!0&&(this.persistedChildren={},this.persistToken=null)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var v=class extends pt{constructor(t,e,s){super(t,e,s),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._externalData=this._externalData??!1,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this._resumeData(t.data),this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,t.context&&(this.context=t.context,this._contextResumed=!0),this.id=t.id,this._refreshContextData()}_resumeData(t){Q.resume(this,t)}_refreshData(){Q.refresh(this)}_refreshContextData(){Q.refreshContext(this)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=I.getTarget(String(e))}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();b.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new It(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)}onFlush(t){let e=this.data??this?.context?.data??null;e&&e.onFlush(t)}setEventHelper(){this.events||(this.events=new Mt)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events&&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!==!0&&this.data.unlink()}};var Ot={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var Fs=(r,t)=>typeof r!="function"&&t==="setupStates"?()=>r:r,Kt=(r,t)=>{if(!r)return t;let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i],a=Ot[i]||i;t[a]=Fs(o,a)}return t},Ws=r=>Kt(r,{}),qs=0,De=(r,t)=>{class e extends r{}return Object.assign(e.prototype,t),e.prototype._classId="jot"+qs++,e},U=(r,t=v)=>{r||(r={});let e,s=typeof r;return s==="object"&&r.render?(e=Ws(r),De(t,e)):(e={render:s==="function"?r:()=>r},De(t,e))};var Vs=(r,t)=>{let e=Object.keys(r);for(let s=0,n=e.length;s<n;s++){let i=e[s],o=r[i],a=Ot[i]||i;t.prototype[a]=o}return t},Gs=0,zs=r=>{let t=class extends r{};return t.prototype._classId="pod"+Gs++,t},$s=(r,t=v)=>{if(!r)return null;let e=zs(t),s={},n=r(s);return Vs(s,e),e.prototype.render=n,e};var js={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],getDayName(r=new Date().getDay(),t=!1){if(typeof Intl<"u"){let n=new Date(2004,0,4+r);return new Intl.DateTimeFormat(void 0,{weekday:t?"short":"long"}).format(n)}let e=this.dayNames;if(r>e.length)return null;let s=e[r];return t?s.substring(0,3):s},convertJsMonth(r){return this.padNumber(r+1)},convertDate(r,t=!1){r=r?r.replace(/\s/,"T"):"";let e=new Date(r);if(typeof Intl<"u"){let n={weekday:"long",month:"short",day:"2-digit"};return t&&(n.year="numeric"),new Intl.DateTimeFormat(void 0,n).format(e)}let s=t===!0?" "+e.getFullYear():"";return this.getDayName(e.getDay())+", "+this.getMonthName(e.getMonth(),!0)+" "+this.padNumber(e.getDate())+s},padNumber(r){return r<=9?"0"+r:String(r)},createDate(r){return r?(typeof r=="string"&&r.indexOf("-")>-1&&(r=r.replace(/\s/,"T"),r=r.indexOf(":")>-1?r:r+"T00:00:00"),new Date(r)):new Date},format(r,t){let e=this.createDate(t);return r!=="sql"&&typeof Intl<"u"?new Intl.DateTimeFormat(void 0,{year:"numeric",month:"2-digit",day:"2-digit"}).format(e):this.renderDate(e.getFullYear(),e.getMonth()+1,e.getDate(),r)},formatTime(r,t){let e=this.createDate(r);if(t!==24&&typeof Intl<"u")return new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit",hour12:!0}).format(e);let s=t===24?"sql":"standard";return this.renderTime(e.getHours(),e.getMinutes(),e.getSeconds(),s)},getMeridian(r){return r=Number(r),r>=12?"PM":"AM"},convert24To12(r){return r=Number(r),r>12&&(r=r-12),r},convert12To24(r,t){return r=Number(r),t.toLowerCase()==="pm"&&(r=r+12),r},renderDate(r,t,e,s="sql"){return t=Number(t),e=Number(e),s==="sql"?`${r}-${this.padNumber(t)}-${this.padNumber(e)}`:`${this.padNumber(t)}/${this.padNumber(e)}/${r}`},renderTime(r,t,e=0,s="sql"){if(s==="sql")return`${this.padNumber(r)}:${this.padNumber(t)}:${this.padNumber(e)}`;let n=this.getMeridian(r);return r=this.convert24To12(r),`${r}:${this.padNumber(t)} ${n}`},leapYear(r){return r%400===0||r%100!==0&&r%4===0},getMonthName(r=new Date().getMonth(),t=!1){if(typeof Intl<"u"){let n=new Date(2e3,r,1);return new Intl.DateTimeFormat(void 0,{month:t?"short":"long"}).format(n)}let e=this.monthNames;if(r>e.length)return"";let s=e[r];return s?t?s.substring(0,3):s:""},getMonthLength(r,t){let e=new Date;return r=typeof r<"u"?r:e.getMonth(),t=typeof t<"u"?t:e.getFullYear(),this.getMonthsLength(t)[r]},getMonthsLength(r=new Date().getFullYear()){return this.leapYear(r)===!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(r,t="America/Denver"){let e=new Date(r);if(Number.isNaN(e.getMonth())===!0){let i=/[- :]/,o=r.split(i);e=new Date(o[0],o[1]-1,o[2],o[3],o[4],o[5])}let s=new Date(Date.parse(e.toLocaleString("en-US",{timeZone:t}))),n=e.getTime()-s.getTime();return new Date(e.getTime()+n)},getLocalTime(r,t=!1,e=!1,s="America/Denver"){if(!r)return"";let n=this.getLocalDate(r,s);if(!t&&typeof Intl<"u"){let c={hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0};return e===!1&&(c.year="numeric",c.month="2-digit",c.day="2-digit"),new Intl.DateTimeFormat(void 0,c).format(n)}let 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(r,t=!1){r=r.replace(/\s/,"T");let e=new Date(r),s=new Date;return t===!0&&s.setHours(0,0,0,0),s.getTime()-e.getTime()},getAge(r){let t=this.getDiffFromNow(r),e,s;switch(!0){case t<864e5:e="1 day";break;case t<6048e5:s=this.toDays(t),e=s+" days";break;case t<12096e5:e="1 week";break;case t<2592e6:s=this.toDays(t);var n=Math.floor(s/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(r){let t=this.getDiffFromNow(r);return this.convertToEstimate(t)},convertToEstimate(r){let t="",e,s,n,i,o,a,c;if(r<=0)switch(!0){case r<-63072e6:n=this.toYears(Math.abs(r)),t="in "+n+" y";break;case r<-31536e6:t="in 1y";break;case r<-5184e6:i=this.toMonths(Math.abs(r)),t="in "+i+"mo";break;case r<-2592e6:t="in 1mo";break;case r<-12096e5:e=this.toDays(Math.abs(r)),s=Math.floor(e/7),t="in "+s+"w";break;case r<-6048e5:t="in 1w";break;case r<-1728e5:e=this.toDays(Math.abs(r)),t="in "+e+"d";break;case r<-864e5:t="tomorrow";break;case r<-72e5:o=this.toHours(Math.abs(r)),t="in "+o+" h";break;case r<=-36e5:t="in 1h";break;case r<-12e4:a=this.toMinutes(Math.abs(r)),t="in "+a+"m";break;case r<-6e4:t="in 1m";break;case r<-2e3:c=this.toSeconds(Math.abs(r)),t="in "+c+"s";break;case r<-1:t="in 1s";break;default:t="now"}else switch(!0){case r<1e3:t="1s ago";break;case r<6e4:c=this.toSeconds(r),t=c+"s ago";break;case r<12e4:t="1m ago";break;case r<36e5:a=this.toMinutes(r),t=a+"m ago";break;case r<72e5:t="1h ago";break;case r<864e5:o=this.toHours(r),t=o+"h ago";break;case r<1728e5:t="yesterday";break;case r<6048e5:e=this.toDays(r),t=e+"d ago";break;case r<12096e5:t="1w ago";break;case r<2592e6:e=this.toDays(r),s=Math.floor(e/7),t=s+"w ago";break;case r<5184e6:t="1mo ago";break;case r<31536e6:i=this.toMonths(r),t=i+"mo ago";break;case r<63072e6:t="1y ago";break;default:n=this.toYears(r),t=n+"y ago"}return t},toYears(r){return typeof r!="number"?0:Math.floor(r/31558464e3)},toMonths(r){return typeof r=="number"?Math.floor(r/2592e6):0},toDays(r){return typeof r!="number"?0:Math.floor(r/864e5*1)},toHours(r){return typeof r!="number"?0:Math.floor(r%864e5/36e5*1)},toMinutes(r){return typeof r!="number"?0:Math.floor(r%864e5%36e5/6e4*1)},toSeconds(r){return typeof r!="number"?0:Math.floor(r%864e5%36e5%6e4/1e3*1)},getDifference(r,t){let e=new Date(r),s=new Date(t),n=s.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 Y={items:new Map,add(r,t){return this.items.set(r,t),this},get(r){return this.items.get(r)??null}};var Zt=(r,t)=>({attr:r,directive:t});var O=(r,t)=>({key:r,value:t});var Pe=(r,t,e,s)=>({tag:r,attr:t,directives:e,children:s});var Ee=null,Qs=()=>Ee||(Ee=Y.get("watch")),L=class{static getTag(t){return t.tag||"div"}static setupChildren(t){t.nest&&(t.children=t.nest,delete t.nest)}static setElementContent(t,e,s,n){return t==="text"?(n.push({tag:"text",textContent:e}),!0):t==="html"||t==="innerHTML"?(s.push(O("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,s){t.push(Zt(O(e,T.getWatcherSettings(s,at(e))),Qs()))}static setButtonType(t,e,s){if(t==="button"){let n=e.type||"button";s.push(O("type",n))}}static parse(t,e){let s=[],n=[],i=t.tag||"div";i==="button"&&s.push(O("type",t.type||"button"));let o=[],a,c;for(let u in t){if(!Object.prototype.hasOwnProperty.call(t,u)||u==="tag"||(a=t[u],a==null))continue;if(u==="children"||u==="nest"){if(Array.isArray(a))for(let h=0;h<a.length;h++)o.push(a[h]);else o.push(a);continue}if((c=Y.get(u))!==null){n.push(Zt(O(u,a),c));continue}let l=typeof a;if(l==="object"){if(T.isWatching(a)){this.setTextAsWatcher(n,u,a);continue}o.push(a);continue}if(l==="function"){let h=a,g=function(y){h.call(this,y,e)};g.originalCallback=h,s.push(O(u,g));continue}if(l==="string"&&a.includes("[[")){this.setTextAsWatcher(n,u,a);continue}if(u==="text"){o.push({tag:"text",textContent:a});continue}if(u==="html"||u==="innerHTML"){s.push(O("innerHTML",a));continue}s.push(O(u,a))}return Pe(i,s,n,o)}};var J=class{build(t,e,s){}setupComponent(t,e,s){let n=s?.getChildScope();t.parent=n,n&&n.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&n&&(n[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),s=this.build(e,t.container,t);return t.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(t),s}createComponent(t,e,s){return this.setupComponent(t,e,s),this.buildComponent(t),t}setDirectives(t,e,s){}removeNode(t){}removeAll(t){}};var _t=class extends J{build(t,e,s){let n=k.createDocFragment();if(Array.isArray(t))for(let i=0,o=t.length;i<o;i++)this.buildElement(t[i],n,s);else this.buildElement(t,n,s);return e&&typeof e=="object"&&e.appendChild(n),n}buildElement(t,e,s){if(t){if(t.isUnit===!0){this.createComponent(t,e,s);return}this.createElement(t,e,s)}}createElement(t,e,s){let n=s?.getChildScope();if(t.data||t.state){this.createTempComponent(t,e,n);return}let i=L.parse(t,n),o=this.createNode(i,e,n);this.cache(o,t.cache,s);let a=i.children;for(let u=0,l=a.length;u<l;u++){let h=a[u];h!==null&&this.buildElement(h,o,s)}let c=i.directives;c.length&&this.setDirectives(o,c,n)}createTempComponent(t,e,s){let n={cache:t.cache,key:t.key,_externalData:!0,setData:()=>t.data,...Kt(t.methods||{},{}),render(){return{...t,data:null,state:null,methods:null,key:null}}};t.state&&(n.setupStateTarget=function(o){this.state=t.state});let i=new v(n);this.createComponent(i,e,s)}setDirectives(t,e,s){for(let n=0,i=e.length;n<i;n++)this.handleDirective(t,e[n],s)}handleDirective(t,e,s){e.directive(t,e.attr.value,s)}cache(t,e,s){s&&e&&s.cacheEle(t,e)}createNode(t,e,s){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:"";return k.createText(o,e)}else if(n==="comment"){let i=t.attr[0],o=i?i.value:"";return k.createComment(o,e)}return k.create(n,t.attr,e,s)}removeNode(t){k.removeElement(t)}removeAll(t){k.removeAll(t)}};var Ys=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source"]),X=class{static create(t,e=[],s=""){let n="",i="";for(let o=0,a=e.length;o<a;o++){let c=e[o],u=c.key,l=c.value;if(u==="text"||u==="textContent"){n+=l;continue}if(u==="html"||u==="innerHTML"){n+=l;continue}if(typeof l=="function"){let h="on"+ct(u);i?i+=" "+h+'="'+l+'"':i=h+'="'+l+'"';continue}i?i+=" "+u+'="'+l+'"':i=u+'="'+l+'"'}return Ys.has(t)?"<"+t+" "+i+" />":"<"+t+" "+i+">"+n+s+"</"+t+">"}static createText(t){return t}static createComment(t){return"<!-- "+t+" -->"}};var Rt=class extends J{build(t,e,s){if(Array.isArray(t)){let n="";for(let i=0,o=t.length;i<o;i++)n+=this.buildElement(t[i],s);return n}return this.buildElement(t,s)}createComponent(t,e,s){return this.setupComponent(t,e,s),this.buildComponent(t)}buildElement(t,e){return t?t.isUnit===!0?this.createComponent(t,{},e):this.createElement(t,e):""}createElement(t,e){let s=L.parse(t,e),n=s.children,i="";for(let o=0,a=n.length;o<a;o++){let c=n[o];c!==null&&(i+=this.buildElement(c,e))}return this.createNode(s,i)}createNode(t,e){let s=t.tag;if(s==="text"){let n=t.attr[0],i=n?n.value:"";return X.createText(i)}else if(s==="comment"){let n=t.attr[0],i=n?n.value:"";return X.createComment(i)}return X.create(s,t.attr,e)}removeAll(t){}};var Bt=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new _t:new Rt}};var F=Bt.setup(),Js=r=>typeof r=="object"&&r.isUnit===!0,Xs=r=>{let t=U(r);return t?new t:null},m=class{static render(t,e,s){return!t||(Js(t)||(t=Xs(t)),!t)?null:F.createComponent(t,e,s)}static build(t,e,s){return F.build(t,e,s)}static rebuild(t,e,s){return F.removeAll(e),this.build(t,e,s)}static setDirectives(t,e,s){F.setDirectives(t,e,s)}static createNode(t,e,s){return F.createNode(t,e,s)}static removeNode(t){F.removeNode(t)}static removeAll(t){F.removeAll(t)}};R.augment({buildLayout(r,t,e){m.build(r,t,e)}});var te=[],Ks=r=>te.indexOf(r)!==-1,Zs=r=>({tag:"script",src:r.src,async:!1,load(t){te.push(r.src);let e=r.load;e&&e()}}),tr=r=>({tag:"link",rel:"stylesheet",type:"text/css",href:r.src,load(t){te.push(r.src);let e=r.load;e&&e()}}),Lt=class{constructor(t){this.percent=0,this.loaded=0,this.total=0,this.callBack=t||null}add(t){this.total++;let e,s=this.update.bind(this);t.indexOf(".css")!==-1?e=tr({load:s,src:t}):e=Zs({load:s,src:t}),m.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{Ks(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 er=r=>r?typeof r?.prototype?.constructor=="function":!1,K=class{static process(t,e){let s=t.default;return s?e.callback?e.callback(s):(er(s)?s=new s:s=s(),s.isUnit===!0&&(s.route=e.route,e.persist&&(s.persist=!0)),s):null}static render(t,e,s){let n=m.build(t,null,s),i=n.firstChild||t?.panel;return e.after(n),i}};var Ht=class{static load(t,e,s){return t.then(n=>(e&&e(n),n)).catch(n=>{console.error("Error loading module:",n),s&&s(n)})}};var sr=r=>({tag:"comment",textContent:"import placeholder",onCreated:r.onCreated}),Z=new Map,rr=r=>{if(Z.has(r)){let s=Z.get(r);return s&&typeof s.then!="function"?Promise.resolve(s):s}let t=typeof r,e;if(t==="string")e=import(r);else if(t==="function")e=r();else return r;return e.then(s=>{Z.set(r,s)}),Z.set(r,e),e},nr=r=>{if(!Z.has(r))return null;let t=Z.get(r);return t&&typeof t.then=="function"?null:t||null},Me=U({declareProps(){this.loaded=!1,this.generation=0},render(){return sr({onCreated:r=>{if(this.src){if(this.layout){this.layoutRoot=K.render(this.layout,this.panel,this.parent);return}if(this.depends){new Lt(()=>{this.loadAndRender(r)}).addFiles(this.depends);return}this.loadAndRender(r)}}})},loadAndRender(r){let t=this.generation,e=nr(this.src);if(e){this.renderModule(r,e);return}Ht.load(rr(this.src),s=>{t===this.generation&&this.renderModule(r,s)},s=>{t===this.generation&&(this.loaded=!1)})},renderModule(r,t){this.loaded=!0;let e=this.layout||K.process(t,{callback:this.callback,route:this.route,persist:this.persist});this.layout=e,this.layoutRoot=K.render(e,r,this.parent)},shouldUpdate(r){return this.updateLayout===!0?!0:this.updateLayout=r&&r.isUnit&&typeof r.update=="function"},updateModuleLayout(r){let t=this.layout;this.shouldUpdate(t)&&t&&t.update(r)},update(r){this.loaded===!0&&this.updateModuleLayout(r)},destroy(){this.generation++,this.layoutRoot&&(m.removeNode(this.layoutRoot),this.persist!==!0&&(this.layoutRoot=null,this.layout=null,this.loaded=!1,this.updateLayout=!1))}});var ee=r=>{let t=typeof r;return(t==="string"||t==="function"||r instanceof Promise)&&(r={src:r}),new Me(r)};var Ie=(r,t,e=null)=>{if(!r)return;let s=null,n=!1,i=()=>{n||(n=!0,s&&(clearTimeout(s),s=null),f.off("animationend",r,o),r&&r.classList.remove(t),e&&e())},o=a=>{a.target===r&&i()};f.on("animationend",r,o),requestAnimationFrame(()=>{if(!r){i();return}r.classList.add(t);try{let a=window.getComputedStyle(r),c=parseFloat(a.animationDuration)*1e3||1e3,u=parseFloat(a.animationDelay)*1e3||0;s=setTimeout(i,c+u+100)}catch{s=setTimeout(i,1e3)}})},Oe=(r,t,e)=>{Ie(r,t)},_e=(r,t,e)=>{let s=()=>{r&&r.remove&&r.remove()};ir(r,()=>Ie(r,t,s),e)};p.addType("manual-destroy",r=>{if(!r)return!1;r.callBack(r.ele,r.parent)});var ir=(r,t,e)=>{p.add(r,"manual-destroy",{ele:r,callBack:t,parent:e})};var mt=(r,t,e,s)=>{if(Array.isArray(e[0])){e.forEach(n=>{n&&mt(r,t,n,s)});return}or(r,t,e,s)},or=(r,t,e,s)=>{let n,i;if(e.length<3?[n,i]=e:[t,n,i]=e,!t||!n)return;if(typeof t.on!="function"){console.warn('Watcher directive: Data source does not have an "on" method. Make sure your component has data, state, or context.data initialized before using watchers like onSet, watch, or [[prop]] syntax.',r,t);return}let o=ar(r,n,i,s);x.watch(r,t,n,o)},ar=(r,t,e,s)=>typeof e=="object"?n=>{lr(r,e,n)}:n=>{ur(r,e,t,n,s)},Re=new WeakSet,cr=(r,t,e)=>{!r||!r.isUnit&&!r.isComponent||Re.has(e)||(Re.add(e),console.warn('[Watcher] Reactive callback for "'+t+'" returned a Component/Unit instance. The entire subtree will be destroyed and recreated on every change, which can trigger expensive deep publishes during persistence/resume. Consider mounting the component once and exposing a refresh()/update() method, or returning a plain layout object instead.',e))},ur=(r,t,e,s,n)=>{let i=t(s,r,n);switch(typeof i){case"object":cr(i,e,r),m.rebuild(i,r,n);break;case"string":let o=vt(r);if(o!=="textContent"){r.setAttribute(o,i);break}D.addHtml(r,i);break}},lr=(r,t,e)=>{let s=Object.keys(t);for(let n=0,i=s.length;n<i;n++){let o=s[n];o&&(t[o]===e?r.classList.add(o):r.classList.remove(o))}};var tt=(r,t,e)=>{let s=A(e);mt(r,s,t,e)};var Be=(r,t,e)=>{t&&r.setAttribute("role",t)},hr=r=>(t,e)=>{let s=t?"true":"false";e.setAttribute(r,s)},Le=(r,t,e)=>{if(!t)return;let s=t.role;s&&(r.setAttribute("role",s),t.role=null);let n=Object.keys(t);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=t[a];if(c===null)continue;let u="aria-"+a;if(Array.isArray(c)){let l=c.slice();l.push(hr(u)),tt(r,l,e)}else r.setAttribute(u,c)}};var He=(r,t,e)=>{if(!t)return;let s=L.parse(t,e);k.addAttributes(r,s.attr,e),m.setDirectives(r,s.directives,e)};p.addType("context",r=>{if(!r)return!1;r.parent.removeContextBranch(r.branch)});var se=r=>r?r.getContext():null,Ne=(r,t,e)=>{if(typeof t!="function")return;let s=se(e),n=t(s);He(r,n,e)},Ue=(r,t,e)=>{if(typeof t!="function")return;let s=se(e);t(s)},Fe=(r,t,e)=>{if(typeof t!="function"||!e)return;let s=se(e),n=t(s);n&&e.addContextBranch(n[0],n[1])};var We=(r,t,e)=>{};var qe=(r,t,e)=>{if(!e)return;let s=e._layout?e._layout:e.render();console.log("Debug: ","ele: ",r),console.log("Data: ",t),console.log("Layout: ",s),console.log("parent: ",e)};var Ve=(r,t,e)=>{},Ge=(r,t,e)=>{if(!t||!e)return;let s=t(e,r);s&&m.build(s,r,e)},ze=(r,t,e)=>{if(!t||!e)return;let s=e.getId(t);r.id=s},$e=(r,t,e)=>{if(!t||!e)return;let s=t(e.data,r);s&&m.build(s,r,e)},je=(r,t,e)=>{if(!t||!e)return;let s=t(e.state,r);s&&m.build(s,r,e)},Qe=(r,t,e)=>{if(!t||!e)return;let s=e.state,n=t(s);if(!e.state){e.setStateHelper(n);return}e.addState(n)},Ye=(r,t,e)=>{if(!(!t||!e)){if(e.events||e.setEventHelper(),t[2]){let s=t[2];t[2]=n=>{s(n,e)}}e.events.on(t[0],t[1],t[2],t[3])}};var Je=(r,t,e)=>{let s,n,i;if(typeof t=="string"){if(s=A(e),!s)return;n=t}else if(Array.isArray(t))if(typeof t[0]!="object"){let o=A(e);if(!o)return;s=o,n=t[0],i=t[1]}else[s,n,i]=t;x.bind(r,s,n,i)};var Nt=(r,t,e)=>{mt(r,e.state,t,e)};var Xe=r=>(t,e)=>{let[s,n,i="active"]=r,o=t===n?i:"";e.dataset[s]=o},Ke=(r,t,e)=>{if(!t)return;let s=t.length-1,n=t[s],i=t.slice(0,s);i.push(Xe(n)),tt(r,i,e)},Ze=(r,t,e)=>{if(!t)return;let s=t.length-1,n=t[s],i=t.slice(0,s);i.push(Xe(n)),Nt(r,i,e)};var ts=(r,t,e)=>{let s,n,i,o;if(t.length<3){let c=A(e);if(!c)return;s=c,[n,i,o]=t}else[s,n,i,o]=t;let a=o!==!1;x.watch(r,s,n,c=>{if(m.removeAll(r),!c||c.length<1)return;let u=[];for(let l=0,h=c.length;l<h;l++){let g=a?s.scope(n+"["+l+"]"):null,y=i(c[l],l,g,u);y!==null&&u.push(y)}return m.build(u,r,e)})};var es=(r,t,e)=>{let s=t[0];if(!s||s.length<1)return;let n=t[1],i=[];for(let o=0,a=s.length;o<a;o++){let c=s[o];if(!c)continue;let u=n(c,o);u!==null&&i.push(u)}m.build(i,r,e)};var ss=(r,t,e)=>{t(r,e)};p.addType("destroyed",r=>{if(!r)return!1;r.callBack(r.ele,r.parent)});var rs=(r,t,e)=>{fr(r,t,e)},fr=(r,t,e)=>{p.add(r,"destroyed",{ele:r,callBack:t,parent:e})};var ns=(r,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(let s=0,n=t.length;s<n;s++)T.setup(r,t[s],e);else T.setup(r,t,e)};var dr=0,et=class{constructor(t){this.router=t,this.locationId="base-app-router-"+dr++,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 os=typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent||"")&&!window.MSStream,is=()=>{os&&requestAnimationFrame(()=>requestAnimationFrame(()=>{let r=window.scrollX,t=window.scrollY;window.scrollTo(0,t+1),document.documentElement.offsetHeight,window.scrollTo(r,t)}))},Ut=class extends et{addEvent(){return f.on("popstate",window,this.callBack),os&&(this.pageShowCallBack=this.onPageShow.bind(this),f.on("pageshow",window,this.pageShowCallBack)),this}removeEvent(){return f.off("popstate",window,this.callBack),this.pageShowCallBack&&f.off("pageshow",window,this.pageShowCallBack),this}onPageShow(t){t.persisted&&is()}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri);let s=e.scrollPosition;s&&this.scrollTo(s),is()}createState(t,e={}){let s=this.getScrollPosition();return e=e===null?{}:e,{location:this.locationId,...e,scrollPosition:s,uri:t}}addState(t,e,s=!1){let n=window.history,i=n.state;if(i&&i.uri===t)return this;!s&&i&&i.location===this.locationId&&(i.scrollPosition=this.getScrollPosition(),n.replaceState(i,"",window.location.href));let o=this.createState(t,e);return s||(o.scrollPosition={x:0,y:0}),n[s===!1?"pushState":"replaceState"](o,null,t),this}};var Ft=class extends et{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,s){return window.location.hash=t,this}};var Wt=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new Ut(t).setup():new Ft(t).setup()}};var re=class extends v{getChildScope(){return this.parent}},as=r=>U(r,re);var qt=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.route&&typeof this.route.flushPending=="function"&&this.route.flushPending(),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){this.template=this.template(),this.initializeTemplateObject()}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){let t=this.template;if(!t)return;t.isUnit||(this.template=new(as(t)));let e=this.template;this.transferSettings(e)}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 cs=r=>{if(!r.length)return null;let t={};for(let e=0,s=r.length;e<s;e++)t[r[e]]=null;return t},us=r=>{let t=[];if(!r)return t;let e=/[*?]/g;r=r.replace(e,"");let s=/:(.[^./?&($]+)\?*/g,n=r.match(s);if(n===null)return t;for(let i=0,o=n.length;i<o;i++){let a=n[i];a&&t.push(a.replace(":",""))}return t};var pr=/(\/):[^/(]*?\?/g,mr=/\//g,gr=/(\?\/+\*?)/g,yr=/(:[^/?&($]+)/g,br=/(\*)/g,xr=r=>r.replace(pr,t=>t.replace(mr,"(?:$|/)")),Sr=r=>(r=r.replace(gr,"?/*"),r.replace(yr,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),wr=r=>r.replace(br,".*"),kr=(r,t)=>r+=t[t.length-1]==="*"?"":"$",ls=r=>{if(!r)return"";let t=r;return t=xr(t),t=Sr(t),t=wr(t),t=kr(t,r),t};var vr=0,hs=(r,t="")=>{let e=r||"",s=typeof t=="string"&&t?t:e,n=null,i=[],o=s.match(/#\{([^}]+)\}/);o&&o[1]&&(n=o[1].trim(),s=s.replace(o[0],""),e=e.replace(o[0],""));let a=s.indexOf("?");if(a>-1){let l=s.substring(a+1);if(l.indexOf("=")>-1){let h=l.split("&");for(let y=0,d=h.length;y<d;y++){let C=h[y];if(!C)continue;let[E,gt=""]=C.split("="),ie=(E||"").trim();ie&&i.push({key:ie,value:(gt||"").trim()})}s=s.substring(0,a);let g=e.indexOf("?");g>-1&&(e=e.substring(0,g))}}let c=n!==null||i.length>0;return c&&!s&&(e="*"),{uriPath:e,requiredHash:n,requiredQuery:i,hasConditions:c}},Cr=r=>{if(!r)return"";let t=r.indexOf("?"),e=r.indexOf("#"),s=r.length;return t>-1&&(s=t),e>-1&&e<s&&(s=e),r.substring(0,s)},Tr=r=>{if(!r)return"";let t=r.indexOf("#");return t===-1?"":r.substring(t+1)},Ar=r=>{if(!r)return"";let t=r.indexOf("?");if(t===-1)return"";let e=r.indexOf("#",t);return e===-1?r.substring(t+1):r.substring(t+1,e)},Vt=class extends M{constructor(t,e){let s=t.baseUri,i=hs(s,t.rawUri).uriPath,o=us(i),a=cs(o),c=super(a);return this.uri=s,this.matchUri=i,this.paramKeys=o,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),c}setup(){this.stage={},this.routeId=null,this.uri=null,this.rawUri=null,this.matchUri="",this.uriQuery=/$^/,this.controller=null,this.paramKeys=[],this.requiredHash=null,this.requiredQuery=[],this.hasConditions=!1,this.titleCallBack=()=>{},this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1,this.scrollTo=null}setupRoute(t){this.routeId=t.id||"bs-rte-"+vr++,this.rawUri=t.rawUri||null,this.path=null,this.referralPath=null;let e=hs(this.uri,this.rawUri||"");this.matchUri=e.uriPath,this.requiredHash=e.requiredHash,this.requiredQuery=e.requiredQuery,this.hasConditions=e.hasConditions;let s=ls(this.matchUri);this.uriQuery=new RegExp("^"+s),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1,this.scrollTo=t.scrollTo||null}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?ee(e):null}setupComponentHelper(t){let e=this.getLayout(t);if(!e)return;let{container:s,persist:n,parent:i}=t,o={component:e,container:s,persist:n,parent:i},a=At(this);this.controller=new qt(a,o)}resumeRoute(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 s=this.controller;s&&s.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,s=this.hasConditions?Cr(t):t,n=this.uriQuery||/$^/,i=s.match(n);return i===null?(this.resetParams(),e):Array.isArray(i)?this.matchConditions(t)?(this.setParams(i,1),e=i,e):(this.resetParams(),!1):e}matchConditions(t){if(!this.hasConditions)return!0;if(this.requiredHash!==null&&Tr(t)!==this.requiredHash)return!1;let e=this.requiredQuery||[];if(e.length>0){let s=Ar(t);if(!s)return!1;let n=new URLSearchParams(s);for(let i=0,o=e.length;i<o;i++){let a=e[i];if(!n.has(a.key)||n.get(a.key)!==a.value)return!1}}return!0}resetParams(){this.stage={}}setParams(t,e=0){if(!Array.isArray(t))return;let s=this.paramKeys;if(!s)return;let n={};for(let i=0,o=s.length;i<o;i++){let a=s[i];typeof a<"u"&&(n[a]=t[i+e])}this.set(n)}getParams(){return this.stage}};var Dr=r=>{let t=/\w\S*/;return r.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},Pr=(r,t)=>{if(r.indexOf(":")===-1)return r;let e=t.stage;for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s)){let n=new RegExp(":"+s,"gi");r=r.replace(n,e[s])}return r},Er=(r,t)=>t&&(typeof t=="function"&&(t=t(r.stage)),t=Pr(t,r),Dr(t)),Mr=(r,t)=>(t!==""&&(r+=" - "+t),r),fs=(r,t,e)=>t&&(t=Er(r,t),Mr(t,e));var ds={removeSlashes(r){return typeof r!="string"?"":(r[0]==="/"&&(r=r.substring(1)),r[r.length-1]==="/"&&(r=r.substring(0,r.length-1)),r)}};var ps=(r,t)=>({attr:r,value:t}),Ir=(r,t)=>{if(!t.startsWith(r))return!1;let e=t[r.length];return e===void 0||e==="/"||e==="#"||e==="."||e==="?"},Gt=class extends v{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,s=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,"data-replace":this.replace?"true":null,watch:s}}getLinkPath(){return this?.panel?.pathname||null}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let s=this.exact===!0,n=_.data,i=[];return t&&typeof t=="object"&&i.push(ps("href",t)),e&&typeof e=="object"&&i.push(ps("text",e)),i.push({value:["[[path]]",n],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.search+a.hash,u=a.hash||a.search?c:a.pathname,l=s?o===c:Ir(u,o);this.update(l)}}),i}setupStates(){return{selected:!1}}update(t){this.state&&(this.state.selected=t)}};var Or=()=>typeof window<"u"?window.location:{},ne=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.lastMatchedRoute=null,this.lastScrollGroup=null,this.currentGroupId=null,this.scrollWaitToken=0,this.history=null,this.callBackLink=null,this.location=Or(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new B({path:""})}setupHistory(){this.history=Wt.setup(this)}createRoute(t){let e=t.uri||"*";return t.rawUri=e,t.baseUri=this.createURI(e),new Vt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let s=arguments;t={uri:s[0],component:s[1],callBack:s[2],title:s[3],id:s[4],container:s[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.resumeRoute(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()+ds.removeSlashes(t)}getRoute(t){let e=this.routes,s=e.length;if(s>0)for(let n=0;n<s;n++){let i=e[n];if(i.uri===t)return i}return null}getRouteById(t){let e=this.routes,s=e.length;if(s>0)for(let n=0;n<s;n++){let i=e[n];if(i.routeId===t)return i}return!1}removeRoute(t){let e=this.routes,s=e.indexOf(t);s>-1&&e.splice(s,1),this.lastMatchedRoute===t&&(this.lastMatchedRoute=null)}addSwitch(t){let e=this.switchCount++,s=this.getSwitchGroup(e);for(let n=0,i=t.length;n<i;n++){let o=t[n];if(!o)continue;let a=this.createRoute(o);s.push(a)}return this.checkGroupForRegistration(e,s),e}resumeSwitch(t,e){let s=this.switchCount++,n=this.getSwitchGroup(s);for(let i=0,o=t.length;i<o;i++){let c=t[i].component.route;c.resumeRoute(e),n.push(c)}return this.checkGroupForRegistration(s,n),s}checkGroupForRegistration(t,e){let s=this.scrollIntent,n=this.currentGroupId;this.scrollIntent=null,this.currentGroupId=t,this.checkGroup(e,this.getPath()),this.currentGroupId=n;let i=this.scrollIntent;i&&i.type==="target"&&i.groupId!==null&&i.groupId!==void 0&&(this.lastScrollGroup=i.groupId),this.scrollIntent=s}getSwitchGroup(t){let e=this.switches.get(t);if(e)return e;let s=[];return this.switches.set(t,s),s}removeSwitch(t){this.switches.delete(t)}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e&&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 s=this.getEndPoint();return this.navigate(s,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){return t.closest("a")}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target.closest("a");if(!e||e.target==="_blank"||e.dataset.cancelRoute)return!0;let s=e.getAttribute("href");if(s!==null){let n=this.baseURI,i=n!=="/"?s.replace(n,""):s,o=e.dataset.replace==="true";return this.navigate(i,null,o),t.preventDefault(),t.stopPropagation(),!1}}reset(){let t=this.routes;for(let e=0,s=t.length;e<s;e++){let n=t[e];n&&typeof n.deactivate=="function"&&n.deactivate()}return this.routes=[],this.switches=new Map,this.switchCount=0,this.lastMatchedRoute=null,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,s){return t=this.createURI(t),this.history.addState(t,e,s),this.activate(),this}updatePath(){let t=this.getPath();this.data.path=t}updateTitle(t){if(!t||!t.title)return this;let e=t.title;return document.title=fs(t,e,this.title),this}checkActiveRoutes(t){if(this.lastPath=this.path,t=t||this.getPath(),this.path=t,this.scrollIntent=null,this.scrollWaitToken++,this.lastMatchedRoute&&this.check(this.lastMatchedRoute,t))this.select(this.lastMatchedRoute);else{let e=this.routes,s=e.length;for(let n=0;n<s;n++){let i=e[n];typeof i>"u"||this.checkRoute(i,t)}}this.checkSwitches(t),this.applyScrollIntent(),this.updatePath()}checkSwitches(t){let e=this.switches;for(let[s,n]of e.entries())this.currentGroupId=s,this.checkGroup(n,t);this.currentGroupId=null}checkGroup(t,e){let s=t.length;if(!s)return;let n=null;for(let a=0;a<s;a++)if(t[a].get("active")){n=t[a];break}n&&n.match(e)===!1&&n.deactivate();let i;for(let a=0;a<s;a++){let c=t[a];if(typeof c>"u")continue;if(i){c.deactivate();continue}c.match(e)!==!1&&i===void 0&&c.controller&&(i=c,this.select(c))}let o=t[0];i||this.select(o,!0)}checkRoute(t,e){let s=this.check(t,e);return s!==!1?(this.select(t),this.lastMatchedRoute=t):t.deactivate(),s}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t,e){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),e!==!0&&(t.scrollTo?this.scrollIntent={type:"target",selector:t.scrollTo,groupId:this.currentGroupId}:t.preventScroll!==!0&&!this.scrollIntent&&(this.scrollIntent={type:"top"})))}applyScrollIntent(){let t=this.scrollIntent;if(this.scrollIntent=null,!t)return;if(t.type==="top"){this.lastScrollGroup=null,this.checkToScroll(),this.reassertScrollTop();return}if(t.type!=="target")return;let e=t.groupId!==null&&t.groupId!==void 0,s=e&&this.lastScrollGroup===t.groupId;s||(typeof window<"u"&&window.scrollTo(0,0),this.reassertScrollTop()),this.lastScrollGroup=e?t.groupId:null,s&&this.scrollToTarget(t.selector)}reassertScrollTop(){if(typeof window>"u"||typeof requestAnimationFrame>"u")return;let t=++this.scrollWaitToken;requestAnimationFrame(()=>{t===this.scrollWaitToken&&(window.scrollY>0||window.pageYOffset>0)&&window.scrollTo(0,0)})}scrollToTarget(t){if(typeof t!="string"||typeof document>"u")return;let e=c=>{let u=window.getComputedStyle(c),l=u.position==="sticky",h;if(l){let d=c.style.position;c.style.position="static",h=c.getBoundingClientRect().top+window.scrollY,c.style.position=d}else h=c.getBoundingClientRect().top+window.scrollY;let g=l&&parseFloat(u.top)||0,y=h-g;window.scrollY>y&&window.scrollTo(0,y)},s=document.querySelector(t);if(s){e(s);return}if(typeof requestAnimationFrame>"u")return;let n=++this.scrollWaitToken,i=30,o=0,a=()=>{if(n!==this.scrollWaitToken)return;let c=document.querySelector(t);if(c){e(c);return}++o<i&&requestAnimationFrame(a)};requestAnimationFrame(a)}checkToScroll(){this.shouldScrollToTop()&&window.scrollTo(0,0)}cleanPath(t){return t?t.split("?")[0].split("#")[0]:"/"}shouldScrollToTop(){let t=this.cleanPath(this.getPath()),s=this.cleanPath(this.lastPath).split("/"),n=t.split("/");if(s.length!==n.length)return!0;let i=s[s.length-1],o=n[n.length-1];return i!==o}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){typeof this.callBackLink=="function"&&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}},_=new ne;p.addType("routes",r=>{if(!r)return!1;let t=r.route;t&&_.removeRoute(t)});var gs=(r,t,e)=>{if(t)if(Array.isArray(t))for(let s=0,n=t.length;s<n;s++){let i=t[s];i&&ms(r,i,e)}else ms(r,t,e)},ms=(r,t,e)=>{t.container=r,t.parent=e;let s=_.add(t);_r(r,s)},_r=(r,t)=>{p.add(r,"routes",{route:t})};var ys=(r,t,e)=>{};p.addType("switch",r=>{if(!r)return!1;let t=r.id;_.removeSwitch(t)});var bs=(r,t,e)=>{let s=t[0];for(let i=0,o=t.length;i<o;i++){let a=t[i];a&&(a.container=r,a.parent=e)}let n=_.addSwitch(t);Rr(r,n)},Rr=(r,t)=>{p.add(r,"switch",{id:t})};Y.add("cache",Ve).add("onCreated",ss).add("onDestroyed",rs).add("bind",Je).add("data",We).add("state",ys).add("onSet",tt).add("onState",Nt).add("animateIn",Oe).add("animateOut",_e).add("watch",ns).add("useParent",Ge).add("useData",$e).add("useState",je).add("getId",ze).add("addState",Qe).add("addEvent",Ye).add("map",es).add("for",ts).add("useContext",Ue).add("addContext",Fe).add("context",Ne).add("role",Be).add("aria",Le).add("route",gs).add("debug",qe).add("dataSet",Ke).add("dataStateSet",Ze).add("switch",bs);export{zt as Ajax,st as Arrays,Is as Atom,m as Builder,v as Component,B as Data,p as DataTracker,js as DateTime,Y as Directives,z as Dom,ht as Encode,Ss as Events,D as Html,ee as Import,U as Jot,ft as Model,Gt as NavLink,b as Objects,$s as Pod,j as SimpleData,dt as State,I as Store,w as Strings,S as Types,pt as Unit,R as base,x as dataBinder,_ as router};
2
2
  //# sourceMappingURL=base.js.map
@@ -0,0 +1,2 @@
1
+ import{b as P}from"./chunk-DZCEWMDW.js";import{a as ft,b as pt,c as mt,d as C,e as x,f as T}from"./chunk-UQGSGBNZ.js";import{a as U,b as lt}from"./chunk-SN4TNKC2.js";import{a as ht,c as b,d as ut,e as dt,f as H}from"./chunk-EJIWXHRN.js";import{b as p,c as f}from"./chunk-QPFMAZXH.js";var L={items:new Map,add(s,t){return this.items.set(s,t),this},get(s){return this.items.get(s)??null}};p.addType("components",s=>{if(!s)return;let t=s.component;!t||!t.isUnit||(t.persistToken&&t.parent&&t.parent.removePersistedChild(t.persistToken),t.rendered===!0&&(t.prepareDestroy(),t.cleanUpAfterDestroy()))});var de=0,W=class{constructor(t,e,r){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._classId,this.id="",this.cached=[],this.init();let n,i;if(t==null)n={},i=[];else{let o=typeof t;o==="string"||o==="number"?(n={},i=[{tag:"text",textContent:t}]):Array.isArray(t)?(n={},i=t):(n=t||{},i=typeof e=="string"?[{tag:"text",textContent:e}]:e)}this.setupProps(n),this.children=i||[],this.persistedChildren={},this.persistedCount=0,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+de++,this.unitType=this._classId||this.constructor.name.toLowerCase()}declareProps(){}addPersistedChild(t){let e=t.key,r=t.cache,n;r!=null&&e!=null?n="pk:"+r+":"+e:r!=null?n="pk:"+r:e!=null?n="pk:"+e:n="pc"+this.persistedCount++;let i=this.persistedChildren[n];return i&&t.unitType===i.unitType&&t.resumeScope(i),t.persistToken=n,this.persistedChildren[n]=t,n}removePersistedChild(t){this.rendered&&(!t||!this.persistedChildren[t]||delete this.persistedChildren[t])}setupProps(t){if(this.declareProps(),!(!t||typeof t!="object"))for(let e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e],e==="data"&&(this._externalData=!0))}getChildScope(){return this}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){if(this._contextResumed)return;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(){p.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(let n=0,i=t.length;n<i;n++){let o=e(t[n],n);r.push(o)}return r}removeAll(t){return H.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}cacheEle(t,e){e&&(this[e]=t,this.cached.push(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;t&&H.removeElement(t),this.cleanUpAfterDestroy()}cleanUpAfterDestroy(){this.panel=null,this.container=null;let t=this.cached;for(let e=0,r=t.length;e<r;e++)this[t[e]]=null;this.cached=[],this.persist!==!0&&(this.persistedChildren={},this.persistToken=null)}prepareDestroy(){this.persistedCount=0,this.rendered=!1,this.beforeDestroy(),this.data&&typeof this.data.unlink=="function"&&this.data.unlink()}beforeDestroy(){}destroy(){this._remove()}};var I=class{static resume(t,e){if(t._externalData){this._resumeExternal(t,e);return}this._resumeOwned(t,e)}static refresh(t){let e=t.setData();e&&t.data&&t.data.set(e.stage),this.refreshContext(t)}static refreshContext(t){let e=t.context;if(!e||!e.data)return;let r=t.getParentContext();if(!r||!r.data)return;let n=r.data.stage,i=e.data.stage,o=null;for(let a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;let c=n[a];c!==i[a]&&(o===null&&(o={}),o[a]=c)}o!==null&&(typeof e.data._silentSet=="function"?e.data._silentSet(o):e.data.set(o))}static _resumeExternal(t,e){let r=t.setData();if(!r){t.data=e;return}if(e&&e.stage){let n=e._retainState||r._retainState,i=!n&&(e._refreshState||r._refreshState),o=this._buildExternalUpdates(e.stage,r.stage,n,i);U.isEmpty(o)||r._silentSet(o)}typeof r.flushPending=="function"&&r.flushPending(),t.data=r}static _buildExternalUpdates(t,e,r,n){let i={};for(let o in t){if(!Object.prototype.hasOwnProperty.call(t,o))continue;if(n){Object.prototype.hasOwnProperty.call(e,o)||(i[o]=t[o]);continue}let a=t[o];!r&&a==null||a!==e[o]&&(i[o]=a)}return i}static _resumeOwned(t,e){if(!t.data){t.data=e;return}if(e&&e._retainState){t.data=e;return}if(e&&e.stage){let r=e._refreshState||t.data._refreshState,n=this._buildOwnedUpdates(e.stage,t.data.stage,r);U.isEmpty(n)||t.data._silentSet(n)}t.data&&typeof t.data.flushPending=="function"&&t.data.flushPending()}static _buildOwnedUpdates(t,e,r){let n={};for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;if(r){Object.prototype.hasOwnProperty.call(e,i)||(n[i]=t[i]);continue}let o=t[i];o!=null&&o!==e[i]&&(n[i]=o)}return n}};var G=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(!(e<1))for(let r=0;r<e;r++){let n=t[r];this.on(n[0],n[1],n[2],n[3])}}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(let a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.obj===e){o.splice(a,1);break}}set(){let t=this.events;for(let e=0,r=t.length;e<r;e++){let n=t[e];f.on(n.event,n.obj,n.callBack,n.capture)}}unset(){let t=this.events;for(let e=0,r=t.length;e<r;e++){let n=t[e];f.off(n.event,n.obj,n.callBack,n.capture)}}reset(){this.unset(),this.events=[]}};var F=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(let r in t){if(!Object.prototype.hasOwnProperty.call(t,r))continue;if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}let 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){for(let r=0,n=t.length;r<n;r++){let i=t[r];if(i)for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o)||o==="id")continue;let a=null,c=i[o],l=c!==null?c:void 0;l&&typeof l=="object"&&(a=l.callBack,l=l.state),e.push(this.createState(o,l,a,i.id))}}}removeRemoteStates(t){let e=this.remoteStates;e&&this.removeActions(t,e)}removeActions(t,e){if(!(e.length<1))for(let r=0,n=e.length;r<n;r++){let i=e[r];i.token&&this.unbindRemoteState(t,i.token),i.targetId&&P.remove(i.targetId,i.action,i.token)}}restore(t){P.restore(t.id,t);let e=this.remoteStates;if(e)for(let r=0,n=e.length;r<n;r++){let i=e[r];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,r){let n=P.getTarget(r);return t.link(n,e)}unbindRemoteState(t,e){t.unlink(e)}addStatesToTarget(t,e){let r=this.remoteStates;for(let n=0,i=e.length;n<i;n++){let o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}}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||null}};var g=class extends W{constructor(t,e,r){super(t,e,r),this.isComponent=!0,this.stateResumed=!1,this.stateTargetId=null,this._externalData=this._externalData??!1,this._setupData()}setData(){return null}_setupData(){if(this.data)return;let t=this.setData();t&&(this.data=t)}resumeScope(t){this._resumeData(t.data),this.state=t.state,this.stateHelper=t.stateHelper,this.persistedChildren=t.persistedChildren,t.context&&(this.context=t.context,this._contextResumed=!0),this.id=t.id,this._refreshContextData()}_resumeData(t){I.resume(this,t)}_refreshData(){I.refresh(this)}_refreshContextData(){I.refreshContext(this)}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=P.getTarget(String(e))}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateResumed=!0,this.stateHelper.restore(t);return}let e=this.setupStates();U.isEmpty(e)||this.setStateHelper(e)}setStateHelper(t={}){this.state||(this.setupStateTarget(),this.stateHelper=new F(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)}onFlush(t){let e=this.data??this?.context?.data??null;e&&e.onFlush(t)}setEventHelper(){this.events||(this.events=new G)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();t.length<1||(this.setEventHelper(),this.events&&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!==!0&&this.data.unlink()}};var gt={created:"onCreated",setStates:"setupStates",state:"setupStates",events:"setupEvents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"};var fe=(s,t)=>typeof s!="function"&&t==="setupStates"?()=>s:s,et=(s,t)=>{if(!s)return t;let e=Object.keys(s);for(let r=0,n=e.length;r<n;r++){let i=e[r],o=s[i],a=gt[i]||i;t[a]=fe(o,a)}return t},pe=s=>et(s,{}),me=0,yt=(s,t)=>{class e extends s{}return Object.assign(e.prototype,t),e.prototype._classId="jot"+me++,e},R=(s,t=g)=>{s||(s={});let e,r=typeof s;return r==="object"&&s.render?(e=pe(s),yt(t,e)):(e={render:r==="function"?s:()=>s},yt(t,e))};var rt=(s,t)=>({attr:s,directive:t});var S=(s,t)=>({key:s,value:t});var xt=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var St=null,ge=()=>St||(St=L.get("watch")),w=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(S("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){t.push(rt(S(e,T.getWatcherSettings(r,ut(e))),ge()))}static setButtonType(t,e,r){if(t==="button"){let n=e.type||"button";r.push(S("type",n))}}static parse(t,e){let r=[],n=[],i=t.tag||"div";i==="button"&&r.push(S("type",t.type||"button"));let o=[],a,c;for(let l in t){if(!Object.prototype.hasOwnProperty.call(t,l)||l==="tag"||(a=t[l],a==null))continue;if(l==="children"||l==="nest"){if(Array.isArray(a))for(let d=0;d<a.length;d++)o.push(a[d]);else o.push(a);continue}if((c=L.get(l))!==null){n.push(rt(S(l,a),c));continue}let h=typeof a;if(h==="object"){if(T.isWatching(a)){this.setTextAsWatcher(n,l,a);continue}o.push(a);continue}if(h==="function"){let d=a,y=function(m){d.call(this,m,e)};y.originalCallback=d,r.push(S(l,y));continue}if(h==="string"&&a.includes("[[")){this.setTextAsWatcher(n,l,a);continue}if(l==="text"){o.push({tag:"text",textContent:a});continue}if(l==="html"||l==="innerHTML"){r.push(S("innerHTML",a));continue}r.push(S(l,a))}return xt(i,r,n,o)}};var A=class{build(t,e,r){}setupComponent(t,e,r){let n=r?.getChildScope();t.parent=n,n&&n.persist===!0&&t.persist!==!1&&(t.persist=!0,t.parent.addPersistedChild(t)),t.cache&&n&&(n[t.cache]=t),t.setup(e)}buildComponent(t){let e=t.prepareLayout(),r=this.build(e,t.container,t);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 N=class extends A{build(t,e,r){let n=x.createDocFragment();if(Array.isArray(t))for(let i=0,o=t.length;i<o;i++)this.buildElement(t[i],n,r);else this.buildElement(t,n,r);return 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){let n=r?.getChildScope();if(t.data||t.state){this.createTempComponent(t,e,n);return}let i=w.parse(t,n),o=this.createNode(i,e,n);this.cache(o,t.cache,r);let a=i.children;for(let l=0,h=a.length;l<h;l++){let d=a[l];d!==null&&this.buildElement(d,o,r)}let c=i.directives;c.length&&this.setDirectives(o,c,n)}createTempComponent(t,e,r){let n={cache:t.cache,key:t.key,_externalData:!0,setData:()=>t.data,...et(t.methods||{},{}),render(){return{...t,data:null,state:null,methods:null,key:null}}};t.state&&(n.setupStateTarget=function(o){this.state=t.state});let i=new g(n);this.createComponent(i,e,r)}setDirectives(t,e,r){for(let n=0,i=e.length;n<i;n++)this.handleDirective(t,e[n],r)}handleDirective(t,e,r){e.directive(t,e.attr.value,r)}cache(t,e,r){r&&e&&r.cacheEle(t,e)}createNode(t,e,r){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:"";return x.createText(o,e)}else if(n==="comment"){let i=t.attr[0],o=i?i.value:"";return x.createComment(o,e)}return x.create(n,t.attr,e,r)}removeNode(t){x.removeElement(t)}removeAll(t){x.removeAll(t)}};var ye=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source"]),E=class{static create(t,e=[],r=""){let n="",i="";for(let o=0,a=e.length;o<a;o++){let c=e[o],l=c.key,h=c.value;if(l==="text"||l==="textContent"){n+=h;continue}if(l==="html"||l==="innerHTML"){n+=h;continue}if(typeof h=="function"){let d="on"+dt(l);i?i+=" "+d+'="'+h+'"':i=d+'="'+h+'"';continue}i?i+=" "+l+'="'+h+'"':i=l+'="'+h+'"'}return ye.has(t)?"<"+t+" "+i+" />":"<"+t+" "+i+">"+n+r+"</"+t+">"}static createText(t){return t}static createComment(t){return"<!-- "+t+" -->"}};var j=class extends A{build(t,e,r){if(Array.isArray(t)){let n="";for(let i=0,o=t.length;i<o;i++)n+=this.buildElement(t[i],r);return n}return this.buildElement(t,r)}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=w.parse(t,e),n=r.children,i="";for(let o=0,a=n.length;o<a;o++){let c=n[o];c!==null&&(i+=this.buildElement(c,e))}return this.createNode(r,i)}createNode(t,e){let r=t.tag;if(r==="text"){let n=t.attr[0],i=n?n.value:"";return E.createText(i)}else if(r==="comment"){let n=t.attr[0],i=n?n.value:"";return E.createComment(i)}return E.create(r,t.attr,e)}removeAll(t){}};var Q=class{static browserIsSupported(){return typeof window<"u"&&typeof document=="object"}static setup(){return this.browserIsSupported()?new N:new j}};var k=Q.setup(),xe=s=>typeof s=="object"&&s.isUnit===!0,Se=s=>{let t=R(s);return t?new t:null},u=class{static render(t,e,r){return!t||(xe(t)||(t=Se(t)),!t)?null:k.createComponent(t,e,r)}static build(t,e,r){return k.build(t,e,r)}static rebuild(t,e,r){return k.removeAll(e),this.build(t,e,r)}static setDirectives(t,e,r){k.setDirectives(t,e,r)}static createNode(t,e,r){return k.createNode(t,e,r)}static removeNode(t){k.removeNode(t)}static removeAll(t){k.removeAll(t)}};lt.augment({buildLayout(s,t,e){u.build(s,t,e)}});var st=[],we=s=>st.indexOf(s)!==-1,ve=s=>({tag:"script",src:s.src,async:!1,load(t){st.push(s.src);let e=s.load;e&&e()}}),Ce=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){st.push(s.src);let e=s.load;e&&e()}}),z=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=Ce({load:r,src:t}):e=ve({load:r,src:t}),u.build(e,document.head)}addFiles(t){t&&t.forEach(e=>{we(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 ke=s=>s?typeof s?.prototype?.constructor=="function":!1,D=class{static process(t,e){let r=t.default;return r?e.callback?e.callback(r):(ke(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=u.build(t,null,r),i=n.firstChild||t?.panel;return e.after(n),i}};var J=class{static load(t,e,r){return t.then(n=>(e&&e(n),n)).catch(n=>{console.error("Error loading module:",n),r&&r(n)})}};var be=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),O=new Map,Te=s=>{if(O.has(s)){let r=O.get(s);return r&&typeof r.then!="function"?Promise.resolve(r):r}let t=typeof s,e;if(t==="string")e=import(s);else if(t==="function")e=s();else return s;return e.then(r=>{O.set(s,r)}),O.set(s,e),e},Pe=s=>{if(!O.has(s))return null;let t=O.get(s);return t&&typeof t.then=="function"?null:t||null},wt=R({declareProps(){this.loaded=!1,this.generation=0},render(){return be({onCreated:s=>{if(this.src){if(this.layout){this.layoutRoot=D.render(this.layout,this.panel,this.parent);return}if(this.depends){new z(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},loadAndRender(s){let t=this.generation,e=Pe(this.src);if(e){this.renderModule(s,e);return}J.load(Te(this.src),r=>{t===this.generation&&this.renderModule(s,r)},r=>{t===this.generation&&(this.loaded=!1)})},renderModule(s,t){this.loaded=!0;let e=this.layout||D.process(t,{callback:this.callback,route:this.route,persist:this.persist});this.layout=e,this.layoutRoot=D.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&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},destroy(){this.generation++,this.layoutRoot&&(u.removeNode(this.layoutRoot),this.persist!==!0&&(this.layoutRoot=null,this.layout=null,this.loaded=!1,this.updateLayout=!1))}});var vt=s=>{let t=typeof s;return(t==="string"||t==="function"||s instanceof Promise)&&(s={src:s}),new wt(s)};var Ie=0,B=class{constructor(t){this.router=t,this.locationId="base-app-router-"+Ie++,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 kt=typeof navigator<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent||"")&&!window.MSStream,Ct=()=>{kt&&requestAnimationFrame(()=>requestAnimationFrame(()=>{let s=window.scrollX,t=window.scrollY;window.scrollTo(0,t+1),document.documentElement.offsetHeight,window.scrollTo(s,t)}))},Y=class extends B{addEvent(){return f.on("popstate",window,this.callBack),kt&&(this.pageShowCallBack=this.onPageShow.bind(this),f.on("pageshow",window,this.pageShowCallBack)),this}removeEvent(){return f.off("popstate",window,this.callBack),this.pageShowCallBack&&f.off("pageshow",window,this.pageShowCallBack),this}onPageShow(t){t.persisted&&Ct()}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),Ct()}createState(t,e={}){let r=this.getScrollPosition();return e=e===null?{}:e,{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;!r&&i&&i.location===this.locationId&&(i.scrollPosition=this.getScrollPosition(),n.replaceState(i,"",window.location.href));let o=this.createState(t,e);return r||(o.scrollPosition={x:0,y:0}),n[r===!1?"pushState":"replaceState"](o,null,t),this}};var K=class extends B{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 V=class{static browserIsSupported(){return typeof window=="object"&&"history"in window&&"pushState"in window.history}static setup(t){return this.browserIsSupported()?new Y(t).setup():new K(t).setup()}};var nt=class extends g{getChildScope(){return this.parent}},bt=s=>R(s,nt);var $=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.route&&typeof this.route.flushPending=="function"&&this.route.flushPending(),this.create()),this.update(t)}setupTemplate(){let e=typeof this.template;e==="function"?this.initializeComponent():e==="object"&&this.initializeTemplateObject(),this.hasTemplate=!0}initializeComponent(){this.template=this.template(),this.initializeTemplateObject()}transferSettings(t){this.persist=this.persist&&t.persist!==!1,Object.assign(t,{route:this.route,persist:this.persist}),this.component=t}initializeTemplateObject(){let t=this.template;if(!t)return;t.isUnit||(this.template=new(bt(t)));let e=this.template;this.transferSettings(e)}create(){if(this.setupTemplate(),!this.hasTemplate)return;this.setup=!0;let t=this.component;u.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 Tt=s=>{if(!s.length)return null;let t={};for(let e=0,r=s.length;e<r;e++)t[s[e]]=null;return t},Pt=s=>{let t=[];if(!s)return t;let e=/[*?]/g;s=s.replace(e,"");let r=/:(.[^./?&($]+)\?*/g,n=s.match(r);if(n===null)return t;for(let i=0,o=n.length;i<o;i++){let a=n[i];a&&t.push(a.replace(":",""))}return t};var Re=/(\/):[^/(]*?\?/g,Ae=/\//g,Ee=/(\?\/+\*?)/g,De=/(:[^/?&($]+)/g,Oe=/(\*)/g,Be=s=>s.replace(Re,t=>t.replace(Ae,"(?:$|/)")),_e=s=>(s=s.replace(Ee,"?/*"),s.replace(De,t=>t.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)")),Ue=s=>s.replace(Oe,".*"),He=(s,t)=>s+=t[t.length-1]==="*"?"":"$",It=s=>{if(!s)return"";let t=s;return t=Be(t),t=_e(t),t=Ue(t),t=He(t,s),t};var Le=0,Rt=(s,t="")=>{let e=s||"",r=typeof t=="string"&&t?t:e,n=null,i=[],o=r.match(/#\{([^}]+)\}/);o&&o[1]&&(n=o[1].trim(),r=r.replace(o[0],""),e=e.replace(o[0],""));let a=r.indexOf("?");if(a>-1){let h=r.substring(a+1);if(h.indexOf("=")>-1){let d=h.split("&");for(let m=0,q=d.length;m<q;m++){let tt=d[m];if(!tt)continue;let[he,ue=""]=tt.split("="),ct=(he||"").trim();ct&&i.push({key:ct,value:(ue||"").trim()})}r=r.substring(0,a);let y=e.indexOf("?");y>-1&&(e=e.substring(0,y))}}let c=n!==null||i.length>0;return c&&!r&&(e="*"),{uriPath:e,requiredHash:n,requiredQuery:i,hasConditions:c}},Me=s=>{if(!s)return"";let t=s.indexOf("?"),e=s.indexOf("#"),r=s.length;return t>-1&&(r=t),e>-1&&e<r&&(r=e),s.substring(0,r)},qe=s=>{if(!s)return"";let t=s.indexOf("#");return t===-1?"":s.substring(t+1)},We=s=>{if(!s)return"";let t=s.indexOf("?");if(t===-1)return"";let e=s.indexOf("#",t);return e===-1?s.substring(t+1):s.substring(t+1,e)},X=class extends pt{constructor(t,e){let r=t.baseUri,i=Rt(r,t.rawUri).uriPath,o=Pt(i),a=Tt(o),c=super(a);return this.uri=r,this.matchUri=i,this.paramKeys=o,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),c}setup(){this.stage={},this.routeId=null,this.uri=null,this.rawUri=null,this.matchUri="",this.uriQuery=/$^/,this.controller=null,this.paramKeys=[],this.requiredHash=null,this.requiredQuery=[],this.hasConditions=!1,this.titleCallBack=()=>{},this.path=null,this.referralPath=null,this.params=null,this.callBack=null,this.title=null,this.preventScroll=!1,this.scrollTo=null}setupRoute(t){this.routeId=t.id||"bs-rte-"+Le++,this.rawUri=t.rawUri||null,this.path=null,this.referralPath=null;let e=Rt(this.uri,this.rawUri||"");this.matchUri=e.uriPath,this.requiredHash=e.requiredHash,this.requiredQuery=e.requiredQuery,this.hasConditions=e.hasConditions;let r=It(this.matchUri);this.uriQuery=new RegExp("^"+r),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title,this.preventScroll=t.preventScroll||!1,this.scrollTo=t.scrollTo||null}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?vt(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=ft(this);this.controller=new $(a,o)}resumeRoute(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=this.hasConditions?Me(t):t,n=this.uriQuery||/$^/,i=r.match(n);return i===null?(this.resetParams(),e):Array.isArray(i)?this.matchConditions(t)?(this.setParams(i,1),e=i,e):(this.resetParams(),!1):e}matchConditions(t){if(!this.hasConditions)return!0;if(this.requiredHash!==null&&qe(t)!==this.requiredHash)return!1;let e=this.requiredQuery||[];if(e.length>0){let r=We(t);if(!r)return!1;let n=new URLSearchParams(r);for(let i=0,o=e.length;i<o;i++){let a=e[i];if(!n.has(a.key)||n.get(a.key)!==a.value)return!1}}return!0}resetParams(){this.stage={}}setParams(t,e=0){if(!Array.isArray(t))return;let r=this.paramKeys;if(!r)return;let n={};for(let i=0,o=r.length;i<o;i++){let a=r[i];typeof a<"u"&&(n[a]=t[i+e])}this.set(n)}getParams(){return this.stage}};var Ge=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},Fe=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){let n=new RegExp(":"+r,"gi");s=s.replace(n,e[r])}return s},Ne=(s,t)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=Fe(t,s),Ge(t)),je=(s,t)=>(t!==""&&(s+=" - "+t),s),At=(s,t,e)=>t&&(t=Ne(s,t),je(t,e));var Et={removeSlashes(s){return typeof s!="string"?"":(s[0]==="/"&&(s=s.substring(1)),s[s.length-1]==="/"&&(s=s.substring(0,s.length-1)),s)}};var Qe=()=>typeof window<"u"?window.location:{},it=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.lastMatchedRoute=null,this.lastScrollGroup=null,this.currentGroupId=null,this.scrollWaitToken=0,this.history=null,this.callBackLink=null,this.location=Qe(),this.routes=[],this.switches=new Map,this.switchCount=0,this.data=new mt({path:""})}setupHistory(){this.history=V.setup(this)}createRoute(t){let e=t.uri||"*";return t.rawUri=e,t.baseUri=this.createURI(e),new X(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.resumeRoute(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()+Et.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(let n=0;n<r;n++){let i=e[n];if(i.uri===t)return i}return null}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(let n=0;n<r;n++){let i=e[n];if(i.routeId===t)return i}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1),this.lastMatchedRoute===t&&(this.lastMatchedRoute=null)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);for(let n=0,i=t.length;n<i;n++){let o=t[n];if(!o)continue;let a=this.createRoute(o);r.push(a)}return this.checkGroupForRegistration(e,r),e}resumeSwitch(t,e){let r=this.switchCount++,n=this.getSwitchGroup(r);for(let i=0,o=t.length;i<o;i++){let c=t[i].component.route;c.resumeRoute(e),n.push(c)}return this.checkGroupForRegistration(r,n),r}checkGroupForRegistration(t,e){let r=this.scrollIntent,n=this.currentGroupId;this.scrollIntent=null,this.currentGroupId=t,this.checkGroup(e,this.getPath()),this.currentGroupId=n;let i=this.scrollIntent;i&&i.type==="target"&&i.groupId!==null&&i.groupId!==void 0&&(this.lastScrollGroup=i.groupId),this.scrollIntent=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&&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){return t.closest("a")}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target.closest("a");if(!e||e.target==="_blank"||e.dataset.cancelRoute)return!0;let r=e.getAttribute("href");if(r!==null){let n=this.baseURI,i=n!=="/"?r.replace(n,""):r,o=e.dataset.replace==="true";return this.navigate(i,null,o),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.lastMatchedRoute=null,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;return document.title=At(t,e,this.title),this}checkActiveRoutes(t){if(this.lastPath=this.path,t=t||this.getPath(),this.path=t,this.scrollIntent=null,this.scrollWaitToken++,this.lastMatchedRoute&&this.check(this.lastMatchedRoute,t))this.select(this.lastMatchedRoute);else{let e=this.routes,r=e.length;for(let n=0;n<r;n++){let i=e[n];typeof i>"u"||this.checkRoute(i,t)}}this.checkSwitches(t),this.applyScrollIntent(),this.updatePath()}checkSwitches(t){let e=this.switches;for(let[r,n]of e.entries())this.currentGroupId=r,this.checkGroup(n,t);this.currentGroupId=null}checkGroup(t,e){let r=t.length;if(!r)return;let n=null;for(let a=0;a<r;a++)if(t[a].get("active")){n=t[a];break}n&&n.match(e)===!1&&n.deactivate();let i;for(let a=0;a<r;a++){let c=t[a];if(typeof c>"u")continue;if(i){c.deactivate();continue}c.match(e)!==!1&&i===void 0&&c.controller&&(i=c,this.select(c))}let o=t[0];i||this.select(o,!0)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?(this.select(t),this.lastMatchedRoute=t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t,e){t&&(t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t),e!==!0&&(t.scrollTo?this.scrollIntent={type:"target",selector:t.scrollTo,groupId:this.currentGroupId}:t.preventScroll!==!0&&!this.scrollIntent&&(this.scrollIntent={type:"top"})))}applyScrollIntent(){let t=this.scrollIntent;if(this.scrollIntent=null,!t)return;if(t.type==="top"){this.lastScrollGroup=null,this.checkToScroll(),this.reassertScrollTop();return}if(t.type!=="target")return;let e=t.groupId!==null&&t.groupId!==void 0,r=e&&this.lastScrollGroup===t.groupId;r||(typeof window<"u"&&window.scrollTo(0,0),this.reassertScrollTop()),this.lastScrollGroup=e?t.groupId:null,r&&this.scrollToTarget(t.selector)}reassertScrollTop(){if(typeof window>"u"||typeof requestAnimationFrame>"u")return;let t=++this.scrollWaitToken;requestAnimationFrame(()=>{t===this.scrollWaitToken&&(window.scrollY>0||window.pageYOffset>0)&&window.scrollTo(0,0)})}scrollToTarget(t){if(typeof t!="string"||typeof document>"u")return;let e=c=>{let l=window.getComputedStyle(c),h=l.position==="sticky",d;if(h){let q=c.style.position;c.style.position="static",d=c.getBoundingClientRect().top+window.scrollY,c.style.position=q}else d=c.getBoundingClientRect().top+window.scrollY;let y=h&&parseFloat(l.top)||0,m=d-y;window.scrollY>m&&window.scrollTo(0,m)},r=document.querySelector(t);if(r){e(r);return}if(typeof requestAnimationFrame>"u")return;let n=++this.scrollWaitToken,i=30,o=0,a=()=>{if(n!==this.scrollWaitToken)return;let c=document.querySelector(t);if(c){e(c);return}++o<i&&requestAnimationFrame(a)};requestAnimationFrame(a)}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(){typeof this.callBackLink=="function"&&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}},v=new it;var Dt=(s,t)=>({attr:s,value:t}),ze=(s,t)=>{if(!t.startsWith(s))return!1;let e=t[s.length];return e===void 0||e==="/"||e==="#"||e==="."||e==="?"},ot=class extends g{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,"data-replace":this.replace?"true":null,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=v.data,i=[];return t&&typeof t=="object"&&i.push(Dt("href",t)),e&&typeof e=="object"&&i.push(Dt("text",e)),i.push({value:["[[path]]",n],callBack:(o,a)=>{if(typeof a.pathname>"u")return;let c=a.pathname+a.search+a.hash,l=a.hash||a.search?c:a.pathname,h=r?o===c:ze(l,o);this.update(h)}}),i}setupStates(){return{selected:!1}}update(t){this.state&&(this.state.selected=t)}};var Ot=(s,t,e=null)=>{if(!s)return;let r=null,n=!1,i=()=>{n||(n=!0,r&&(clearTimeout(r),r=null),f.off("animationend",s,o),s&&s.classList.remove(t),e&&e())},o=a=>{a.target===s&&i()};f.on("animationend",s,o),requestAnimationFrame(()=>{if(!s){i();return}s.classList.add(t);try{let a=window.getComputedStyle(s),c=parseFloat(a.animationDuration)*1e3||1e3,l=parseFloat(a.animationDelay)*1e3||0;r=setTimeout(i,c+l+100)}catch{r=setTimeout(i,1e3)}})},Bt=(s,t,e)=>{Ot(s,t)},_t=(s,t,e)=>{let r=()=>{s&&s.remove&&s.remove()};Je(s,()=>Ot(s,t,r),e)};p.addType("manual-destroy",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var Je=(s,t,e)=>{p.add(s,"manual-destroy",{ele:s,callBack:t,parent:e})};var M=(s,t,e,r)=>{if(Array.isArray(e[0])){e.forEach(n=>{n&&M(s,t,n,r)});return}Ye(s,t,e,r)},Ye=(s,t,e,r)=>{let n,i;if(e.length<3?[n,i]=e:[t,n,i]=e,!t||!n)return;if(typeof t.on!="function"){console.warn('Watcher directive: Data source does not have an "on" method. Make sure your component has data, state, or context.data initialized before using watchers like onSet, watch, or [[prop]] syntax.',s,t);return}let o=Ke(s,n,i,r);b.watch(s,t,n,o)},Ke=(s,t,e,r)=>typeof e=="object"?n=>{Xe(s,e,n)}:n=>{$e(s,e,t,n,r)},Ut=new WeakSet,Ve=(s,t,e)=>{!s||!s.isUnit&&!s.isComponent||Ut.has(e)||(Ut.add(e),console.warn('[Watcher] Reactive callback for "'+t+'" returned a Component/Unit instance. The entire subtree will be destroyed and recreated on every change, which can trigger expensive deep publishes during persistence/resume. Consider mounting the component once and exposing a refresh()/update() method, or returning a plain layout object instead.',e))},$e=(s,t,e,r,n)=>{let i=t(r,s,n);switch(typeof i){case"object":Ve(i,e,s),u.rebuild(i,s,n);break;case"string":let o=ht(s);if(o!=="textContent"){s.setAttribute(o,i);break}H.addHtml(s,i);break}},Xe=(s,t,e)=>{let r=Object.keys(t);for(let n=0,i=r.length;n<i;n++){let o=r[n];o&&(t[o]===e?s.classList.add(o):s.classList.remove(o))}};var _=(s,t,e)=>{let r=C(e);M(s,r,t,e)};var Ht=(s,t,e)=>{t&&s.setAttribute("role",t)},Ze=s=>(t,e)=>{let r=t?"true":"false";e.setAttribute(s,r)},Lt=(s,t,e)=>{if(!t)return;let r=t.role;r&&(s.setAttribute("role",r),t.role=null);let n=Object.keys(t);for(let i=0,o=n.length;i<o;i++){let a=n[i],c=t[a];if(c===null)continue;let l="aria-"+a;if(Array.isArray(c)){let h=c.slice();h.push(Ze(l)),_(s,h,e)}else s.setAttribute(l,c)}};var Mt=(s,t,e)=>{if(!t)return;let r=w.parse(t,e);x.addAttributes(s,r.attr,e),u.setDirectives(s,r.directives,e)};p.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var at=s=>s?s.getContext():null,qt=(s,t,e)=>{if(typeof t!="function")return;let r=at(e),n=t(r);Mt(s,n,e)},Wt=(s,t,e)=>{if(typeof t!="function")return;let r=at(e);t(r)},Gt=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=at(e),n=t(r);n&&e.addContextBranch(n[0],n[1])};var Ft=(s,t,e)=>{};var Nt=(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 jt=(s,t,e)=>{},Qt=(s,t,e)=>{if(!t||!e)return;let r=t(e,s);r&&u.build(r,s,e)},zt=(s,t,e)=>{if(!t||!e)return;let r=e.getId(t);s.id=r},Jt=(s,t,e)=>{if(!t||!e)return;let r=t(e.data,s);r&&u.build(r,s,e)},Yt=(s,t,e)=>{if(!t||!e)return;let r=t(e.state,s);r&&u.build(r,s,e)},Kt=(s,t,e)=>{if(!t||!e)return;let r=e.state,n=t(r);if(!e.state){e.setStateHelper(n);return}e.addState(n)},Vt=(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[0],t[1],t[2],t[3])}};var $t=(s,t,e)=>{let r,n,i;if(typeof t=="string"){if(r=C(e),!r)return;n=t}else if(Array.isArray(t))if(typeof t[0]!="object"){let o=C(e);if(!o)return;r=o,n=t[0],i=t[1]}else[r,n,i]=t;b.bind(s,r,n,i)};var Z=(s,t,e)=>{M(s,e.state,t,e)};var Xt=s=>(t,e)=>{let[r,n,i="active"]=s,o=t===n?i:"";e.dataset[r]=o},Zt=(s,t,e)=>{if(!t)return;let r=t.length-1,n=t[r],i=t.slice(0,r);i.push(Xt(n)),_(s,i,e)},te=(s,t,e)=>{if(!t)return;let r=t.length-1,n=t[r],i=t.slice(0,r);i.push(Xt(n)),Z(s,i,e)};var ee=(s,t,e)=>{let r,n,i,o;if(t.length<3){let c=C(e);if(!c)return;r=c,[n,i,o]=t}else[r,n,i,o]=t;let a=o!==!1;b.watch(s,r,n,c=>{if(u.removeAll(s),!c||c.length<1)return;let l=[];for(let h=0,d=c.length;h<d;h++){let y=a?r.scope(n+"["+h+"]"):null,m=i(c[h],h,y,l);m!==null&&l.push(m)}return u.build(l,s,e)})};var re=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let n=t[1],i=[];for(let o=0,a=r.length;o<a;o++){let c=r[o];if(!c)continue;let l=n(c,o);l!==null&&i.push(l)}u.build(i,s,e)};var se=(s,t,e)=>{t(s,e)};p.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele,s.parent)});var ne=(s,t,e)=>{tr(s,t,e)},tr=(s,t,e)=>{p.add(s,"destroyed",{ele:s,callBack:t,parent:e})};var ie=(s,t,e)=>{if(t)if(Array.isArray(t)&&typeof t[0]!="string")for(let r=0,n=t.length;r<n;r++)T.setup(s,t[r],e);else T.setup(s,t,e)};p.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&v.removeRoute(t)});var ae=(s,t,e)=>{if(t)if(Array.isArray(t))for(let r=0,n=t.length;r<n;r++){let i=t[r];i&&oe(s,i,e)}else oe(s,t,e)},oe=(s,t,e)=>{t.container=s,t.parent=e;let r=v.add(t);er(s,r)},er=(s,t)=>{p.add(s,"routes",{route:t})};var ce=(s,t,e)=>{};p.addType("switch",s=>{if(!s)return!1;let t=s.id;v.removeSwitch(t)});var le=(s,t,e)=>{let r=t[0];for(let i=0,o=t.length;i<o;i++){let a=t[i];a&&(a.container=s,a.parent=e)}let n=v.addSwitch(t);rr(s,n)},rr=(s,t)=>{p.add(s,"switch",{id:t})};L.add("cache",jt).add("onCreated",se).add("onDestroyed",ne).add("bind",$t).add("data",Ft).add("state",ce).add("onSet",_).add("onState",Z).add("animateIn",Bt).add("animateOut",_t).add("watch",ie).add("useParent",Qt).add("useData",Jt).add("useState",Yt).add("getId",zt).add("addState",Kt).add("addEvent",Vt).add("map",re).add("for",ee).add("useContext",Wt).add("addContext",Gt).add("context",qt).add("role",Ht).add("aria",Lt).add("route",ae).add("debug",Nt).add("dataSet",Zt).add("dataStateSet",te).add("switch",le);export{L as a,W as b,g as c,gt as d,R as e,u as f,vt as g,ot as h,it as i,v as j};
2
+ //# sourceMappingURL=chunk-53IY3DRV.js.map
@@ -1,2 +1,2 @@
1
- import{a as h,b as A,c as i,d as c,e as a,f as P,g as C}from"../chunks/chunk-GRUPEAJC.js";import"../chunks/chunk-DZCEWMDW.js";import{f as s}from"../chunks/chunk-UQGSGBNZ.js";import"../chunks/chunk-SN4TNKC2.js";import"../chunks/chunk-EJIWXHRN.js";import"../chunks/chunk-QPFMAZXH.js";var D=r=>typeof r!="string"?r:f(r),f=r=>[{tag:"text",textContent:r}],m=()=>({props:{},children:[]}),d=r=>({props:{},children:f(r)}),l=r=>({props:{},children:r}),u=r=>({props:r[0]||{},children:D(r[1])});var O=r=>({props:{watch:r},children:[]}),S=r=>{if(r.length===0)return m();let t=r[0],e=typeof t;if(e==="string"||e==="number")return d(t);if(Array.isArray(t))return s.isWatching(t)?O(t):l(t);let o=r[1]??r[0]??[];return o&&Array.isArray(o)&&s.isWatching(o)&&(r[0]=Array.isArray(r[0])?{}:r[0],r[0].watch=o,r[1]=[]),u(r)},b=r=>(...t)=>{let{props:e,children:o}=S(t);return r(e,o)};var H=(r,t)=>{let e=Object.keys(r);for(let o=0,n=e.length;o<n;o++){let p=e[o],x=r[p],y=c[p]||p;t.prototype[y]=x}return t},T=0,W=r=>{let t=class extends r{};return t.prototype._classId="pod"+T++,t},j=(r,t=i)=>{if(!r)return null;let e=W(t),o={},n=r(o);return H(o,e),e.prototype.render=n,e};export{b as Atom,P as Builder,i as Component,h as Directives,C as Import,a as Jot,j as Pod,A as Unit};
1
+ import{a as h,b as A,c as i,d as c,e as a,f as P,g as C}from"../chunks/chunk-53IY3DRV.js";import"../chunks/chunk-DZCEWMDW.js";import{f as s}from"../chunks/chunk-UQGSGBNZ.js";import"../chunks/chunk-SN4TNKC2.js";import"../chunks/chunk-EJIWXHRN.js";import"../chunks/chunk-QPFMAZXH.js";var D=r=>typeof r!="string"?r:f(r),f=r=>[{tag:"text",textContent:r}],m=()=>({props:{},children:[]}),d=r=>({props:{},children:f(r)}),l=r=>({props:{},children:r}),u=r=>({props:r[0]||{},children:D(r[1])});var O=r=>({props:{watch:r},children:[]}),S=r=>{if(r.length===0)return m();let t=r[0],e=typeof t;if(e==="string"||e==="number")return d(t);if(Array.isArray(t))return s.isWatching(t)?O(t):l(t);let o=r[1]??r[0]??[];return o&&Array.isArray(o)&&s.isWatching(o)&&(r[0]=Array.isArray(r[0])?{}:r[0],r[0].watch=o,r[1]=[]),u(r)},b=r=>(...t)=>{let{props:e,children:o}=S(t);return r(e,o)};var H=(r,t)=>{let e=Object.keys(r);for(let o=0,n=e.length;o<n;o++){let p=e[o],x=r[p],y=c[p]||p;t.prototype[y]=x}return t},T=0,W=r=>{let t=class extends r{};return t.prototype._classId="pod"+T++,t},j=(r,t=i)=>{if(!r)return null;let e=W(t),o={},n=r(o);return H(o,e),e.prototype.render=n,e};export{b as Atom,P as Builder,i as Component,h as Directives,C as Import,a as Jot,j as Pod,A as Unit};
2
2
  //# sourceMappingURL=component.js.map
@@ -1,2 +1,2 @@
1
- import{h as r,i as o,j as t}from"../chunks/chunk-GRUPEAJC.js";import"../chunks/chunk-DZCEWMDW.js";import"../chunks/chunk-UQGSGBNZ.js";import"../chunks/chunk-SN4TNKC2.js";import"../chunks/chunk-EJIWXHRN.js";import"../chunks/chunk-QPFMAZXH.js";export{r as NavLink,o as Router,t as router};
1
+ import{h as r,i as o,j as t}from"../chunks/chunk-53IY3DRV.js";import"../chunks/chunk-DZCEWMDW.js";import"../chunks/chunk-UQGSGBNZ.js";import"../chunks/chunk-SN4TNKC2.js";import"../chunks/chunk-EJIWXHRN.js";import"../chunks/chunk-QPFMAZXH.js";export{r as NavLink,o as Router,t as router};
2
2
  //# sourceMappingURL=router.js.map
@@ -61,6 +61,14 @@ export class Component extends Unit {
61
61
  id: string;
62
62
  }): void;
63
63
  stateHelper: any;
64
+ /**
65
+ * Mark the context as resumed so setupContext() keeps
66
+ * this persisted instance instead of re-running the
67
+ * user's setContext(), which would allocate a fresh
68
+ * Data object and orphan every binding (watchers, xhr
69
+ * writes) still subscribed to the persisted one.
70
+ */
71
+ _contextResumed: boolean;
64
72
  /**
65
73
  * This will resume the data during persistence.
66
74
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base-framework/base",
3
- "version": "3.7.84",
3
+ "version": "3.7.85",
4
4
  "description": "This is a javascript framework.",
5
5
  "main": "./dist/base.js",
6
6
  "type": "module",