@base-framework/base 2.6.9 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +165 -1
- package/dist/base.js +1 -1
- package/dist/base.js.map +4 -4
- package/package.json +34 -34
package/README.md
CHANGED
|
@@ -1 +1,165 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Base Framework
|
|
2
|
+
|
|
3
|
+
**Last Updated**: December 4, 2023
|
|
4
|
+
**Version**: 2.6.0
|
|
5
|
+
|
|
6
|
+
## Framework Overview
|
|
7
|
+
|
|
8
|
+
Our goal with Base is to solve many client-side rendering issues. Base focuses on reusability, scalability, polymorphism, and performance.
|
|
9
|
+
|
|
10
|
+
Base has a core that supports adding and removing events, custom events, data-tracking, element class and attribute modifying, object and type utils, etc.
|
|
11
|
+
|
|
12
|
+
The framework is modular and has additional modules to help with ajax, HTML, layouts, data, data-binding, states, dates, routing, components, atoms, etc.
|
|
13
|
+
|
|
14
|
+
## Layouts
|
|
15
|
+
|
|
16
|
+
Base framework uses components to render an application. Base creates and renders components using native JavaScript. Layouts are scaffolded using JavaScript object literals. Because the layouts are rendered client-side using native JavaScript, the framework does not require a compiling or build process.
|
|
17
|
+
|
|
18
|
+
[Learn about layouts](#)
|
|
19
|
+
|
|
20
|
+
## Components and Atoms
|
|
21
|
+
|
|
22
|
+
Components are encapsulated layouts that contain the presentation and functionality. They are reusable and extensible, helping to reduce redundant code through abstract types.
|
|
23
|
+
|
|
24
|
+
Components have lifecycle methods for actions during creation, setup, and destruction.
|
|
25
|
+
|
|
26
|
+
Atoms are the building blocks for reusable layouts, allowing common design patterns and elements to be shared between multiple components and other atoms.
|
|
27
|
+
|
|
28
|
+
[Learn about components](#)
|
|
29
|
+
|
|
30
|
+
## Element Directives
|
|
31
|
+
|
|
32
|
+
Elements created by Base have access to custom directives, enabling more functionalities than standard HTML elements. These include caching, adding states, binding and watching data, re-rendering contents, declarative routing and switching, array mapping and binding, event listeners, and more.
|
|
33
|
+
|
|
34
|
+
[Learn about directives](#)
|
|
35
|
+
|
|
36
|
+
## Data Binding, Watching, and Linking
|
|
37
|
+
|
|
38
|
+
Base supports "bindables" for creating and using data, supporting both shallow and deep nested data. Bindables can be one-way or two-way bindings.
|
|
39
|
+
|
|
40
|
+
Types of bindables include:
|
|
41
|
+
- **Data**: A generic object with complex, deep nested data.
|
|
42
|
+
- **SimpleData**: A shallow data object.
|
|
43
|
+
- **Models**: Child of Data, with default attributes and server resource connectivity.
|
|
44
|
+
|
|
45
|
+
[Learn about data binding](#)
|
|
46
|
+
|
|
47
|
+
## Performance
|
|
48
|
+
|
|
49
|
+
Components are static by default, rendering only once per instance. They become dynamic when bound to bindable data sources, allowing for content re-rendering, value changes, function calls, and class additions on data change.
|
|
50
|
+
|
|
51
|
+
## Getting Started
|
|
52
|
+
|
|
53
|
+
To begin using the Base Framework, follow these steps:
|
|
54
|
+
|
|
55
|
+
1. **Clone the repository**:
|
|
56
|
+
```bash
|
|
57
|
+
git clone https://github.com/yourrepository/base-framework.git
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
2. Navigate to the project directory:
|
|
61
|
+
```bash
|
|
62
|
+
cd base-framework
|
|
63
|
+
```
|
|
64
|
+
3. Install dependencies (ensure Node.js is installed):
|
|
65
|
+
```bash
|
|
66
|
+
npm install @base-framework/base
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
4. Import the framework into your project:
|
|
70
|
+
```javascript
|
|
71
|
+
import { base } from '@base-framework/base';
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Usage
|
|
75
|
+
|
|
76
|
+
Basic Component Creation
|
|
77
|
+
Create a new component:
|
|
78
|
+
|
|
79
|
+
```javascript
|
|
80
|
+
import { base, Component } from '@base-framework/base';
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Page
|
|
84
|
+
*
|
|
85
|
+
* This will create a page component.
|
|
86
|
+
*
|
|
87
|
+
* @class Page
|
|
88
|
+
* @extends {Component}
|
|
89
|
+
*/
|
|
90
|
+
export class Page extends Component
|
|
91
|
+
{
|
|
92
|
+
render()
|
|
93
|
+
{
|
|
94
|
+
/**
|
|
95
|
+
* This will render an empty div and assign a className
|
|
96
|
+
* of "value".
|
|
97
|
+
*/
|
|
98
|
+
return {
|
|
99
|
+
class: this.key
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
User the builder to create a new instance of the component:
|
|
106
|
+
|
|
107
|
+
```javascript
|
|
108
|
+
import { Builder } from '@base-framework/base';
|
|
109
|
+
import { Page } from './components/page.js';
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* This will create a new instance of the Page component.
|
|
113
|
+
*/
|
|
114
|
+
const page = new Page(
|
|
115
|
+
{
|
|
116
|
+
/**
|
|
117
|
+
* Props can be passed to the component and accessed by their key names.
|
|
118
|
+
*
|
|
119
|
+
* You can name the props anything you want, but it is recommended to
|
|
120
|
+
* use camel case and avoid using reserved keywords.
|
|
121
|
+
*/
|
|
122
|
+
key: 'value'
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// The props passed can now be accessed by the component class.
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Render the component to the DOM:
|
|
129
|
+
|
|
130
|
+
```javascript
|
|
131
|
+
import { Builder } from '@base-framework/base';
|
|
132
|
+
import { Page } from './components/page.js';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* This will create a new instance of the Page component.
|
|
136
|
+
*/
|
|
137
|
+
const page = new Page();
|
|
138
|
+
|
|
139
|
+
// Render the component to the DOM.
|
|
140
|
+
const container = document.body;
|
|
141
|
+
Builder.render(page, container);
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Contributing
|
|
145
|
+
|
|
146
|
+
Contributions to Base Framework are welcome. Follow these steps to contribute:
|
|
147
|
+
|
|
148
|
+
- Fork the repository.
|
|
149
|
+
- Create a new branch for your feature or bug fix.
|
|
150
|
+
- Commit your changes with clear, descriptive messages.
|
|
151
|
+
- Push your branch and submit a pull request.
|
|
152
|
+
- Before contributing, read our CONTRIBUTING.md for coding standards and community guidelines.
|
|
153
|
+
|
|
154
|
+
## License
|
|
155
|
+
|
|
156
|
+
Base Framework is licensed under the MIT License. See the LICENSE file for details.
|
|
157
|
+
|
|
158
|
+
## Contact
|
|
159
|
+
|
|
160
|
+
For questions, suggestions, or issues, contact us:
|
|
161
|
+
|
|
162
|
+
Email:
|
|
163
|
+
GitHub Issues: github.com/chrisdurfee/base/issues
|
|
164
|
+
Community Chat: Discord coming soon
|
|
165
|
+
Follow us on Social Media:
|
package/dist/base.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var R={createObject(i){return Object.create(i)},extendObject(i,t){if(typeof i>"u"||typeof t>"u")return!1;for(var e in i)i.hasOwnProperty(e)&&typeof t[e]>"u"&&(t[e]=i[e]);return t},cloneObject(i){return i?JSON.parse(JSON.stringify(i)):{}},_getClassObject(i){return typeof i=="function"?i.prototype:i},extendClass(i,t){let e=this._getClassObject(i),r=this._getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let s=Object.create(e);for(var n in r)s[n]=r[n];return s}};var et={types:{},add(i,t){this.types[i]=t},get(i){return this.types[i]||!1},remove(i){delete this.types[i]}},rt=class{constructor(){this.types={}}add(t,e){(this.types[t]||(this.types[t]=[])).push(e)}get(t){return this.types[t]||!1}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){let e=this.types;if(e){let n=e[t];if(n.length){let a,o=et.get(t);for(var r=0,s=n.length;r<s;r++)a=n[r],a&&(n[r]=null,this.removeByCallBack(o,a));delete e[n]}}}remove(t){if(t)this.removeType(t);else{let r=this.types;for(var e in r)if(r.hasOwnProperty(e)){if(t=r[e],!t)continue;this.removeType(e)}delete this.types}}},I=class{constructor(){this.trackers={},this.trackingCount=0}addType(t,e){et.add(t,e)}removeType(t){et.remove(t)}getTrackingId(t){return t.trackingId||(t.trackingId="dt"+this.trackingCount++)}add(t,e,r){let s=this.getTrackingId(t);this.find(s).add(e,r)}get(t,e){let r=t.trackingId,s=this.trackers[r];return s?e?s.get(e):s:!1}find(t){let e=this.trackers;return e[t]||(e[t]=new rt)}isEmpty(t){if(!t||typeof t!="object")return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}remove(t,e){let r=t.trackingId;if(!r)return!0;let s=this.trackers[r];if(!s)return!1;e?(s.remove(e),this.isEmpty(s.types)&&delete this.trackers[r]):(s.remove(),delete this.trackers[r])}};var Dt=window,L=class{constructor(){this.version="2.6.0",this.errors=[],this.dataTracker=new I}augment(t){if(!t||typeof t!="object")return this;let e=this.constructor.prototype;for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);return this}listToArray(t){return Array.prototype.slice.call(t)}override(t,e,r,s){return(t[e]=r).apply(t,this.listToArray(s))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}parseQueryString(t,e){typeof t!="string"&&(t=Dt.location.search);let r={},s=/([^?=&]+)(=([^&]*))?/g;return t.replace(s,function(n,a,o,l){r[a]=e!==!1?decodeURIComponent(l):l}),r}isEmpty(t){if(this.isObject(t)===!1)return!0;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0}getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?this.listToArray(e):!1}getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:this.listToArray(r):!1}html(t,e){return this.isObject(t)===!1?!1:this.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}setCss(t,e,r){return this.isObject(t)===!1||this.isUndefined(e)?this:(e=this.uncamelCase(e),t.style[e]=r,this)}getCss(t,e){if(!t||typeof e>"u")return!1;e=this.uncamelCase(e);var r=t.style[e];if(r!=="")return r;var s=null,n=t.currentStyle;if(n&&(s=n[e]))r=s;else{var a=window.getComputedStyle(t,null);a&&(r=a[e])}return r}css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}removeAttr(t,e){return this.isObject(t)&&t.removeAttribute(e),this}setAttr(t,e,r){t.setAttribute(e,r)}getAttr(t,e){return t.getAttribute(e)}attr(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}_checkDataPrefix(t){return typeof t!="string"||(t=h.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}_removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}setData(t,e,r){e=this._removeDataPrefix(e),e=h.camelCase(e),t.dataset[e]=r}getData(t,e){return e=h.camelCase(this._removeDataPrefix(e)),t.dataset[e]}data(t,e,r){return this.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}find(t,e){return!t||typeof e!="string"?!1:t.querySelectorAll(e)}show(t){if(this.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}hide(t){if(this.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}toggle(t){return this.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}camelCase(t){if(typeof t!="string")return!1;let e=/(-|\s|\_)+\w{1}/g;return t.replace(e,function(r){return r[1].toUpperCase()})}uncamelCase(t,e){if(typeof t!="string")return!1;e=e||"-";let r=/([A-Z]{1,})/g;return t.replace(r,function(s){return e+s.toLowerCase()}).toLowerCase()}getSize(t){return this.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}getWidth(t){return this.isObject(t)?t.offsetWidth:!1}getHeight(t){return this.isObject(t)?t.offsetHeight:!1}getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=window.pageXOffset||t.scrollLeft,r=window.pageYOffset||t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return this.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}getScrollTop(t){return this.getScrollPosition(t).top}getScrollLeft(t){return this.getScrollPosition(t).left}getWindowSize(){let t=window,e=document,r=e.documentElement,s=e.getElementsByTagName("body")[0],n=t.innerWidth||r.clientWidth||s.clientWidth,a=t.innerHeight||r.clientHeight||s.clientHeight;return{width:n,height:a}}getDocumentSize(){let t=document,e=t.body,r=t.documentElement,s=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:s}}getDocumentHeight(){return this.getDocumentSize().height}getProperty(t,e,r){if(this.isObject(t)===!1)return"";let s=t[e];return typeof s<"u"?s:typeof r<"u"?r:""}position(t,e=1){let r={x:0,y:0};if(this.isObject(t)===!1)return r;let s=0;for(;t&&(e===0||s<e);)s++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}addClass(t,e){if(this.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let n=e.split(" ");for(var r=0,s=n.length;r<s;r++)t.classList.add(e)}return this}removeClass(t,e){return this.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}hasClass(t,e){return this.isObject(t)===!1||e===""?!1:t.classList.contains(e)}toggleClass(t,e){return this.isObject(t)===!1?this:(t.classList.toggle(e),this)}getType(t){let e=typeof t;return e!=="object"?e:this.isArray(t)?"array":e}isUndefined(t){return typeof t>"u"}isObject(t){return!(!t||typeof t!="object")}isArray(t){return Array.isArray(t)}inArray(t,e,r){return!t||typeof t!="object"?-1:t.indexOf(e,r)}createCallBack(t,e,r,s){return typeof e!="function"?!1:(r=r||[],function(...n){return s===!0&&(r=r.concat(n)),e.apply(t,r)})}bind(t,e){return e.bind(t)}prepareJsonUrl(t,e=!1){var r=l=>{if(typeof l!="string"&&(l=String(l)),e){let u=/(\n|\r\n)/g;l=l.replace(u,"\\n")}let f=/\t/g;return l.replace(f,"\\t")},s=l=>{if(typeof l!="string")return l;l=r(l),l=encodeURIComponent(l);let f=/\%22/g;return l.replace(f,'"')},n=l=>{let f=typeof l;if(f==="undefined")return l;if(f!=="object")return l=s(l),l;let u;for(var c in l)if(l.hasOwnProperty(c)){if(u=l[c],u===null)continue;l[c]=n(u)}return l};let a=typeof t=="object"?this.cloneObject(t):t,o=n(a);return this.jsonEncode(o)}jsonDecode(t){return typeof t<"u"&&t.length>0?JSON.parse(t):!1}jsonEncode(t){return typeof t<"u"?JSON.stringify(t):!1}xmlParse(t){if(typeof t>"u")return!1;var e=new DOMParser;return e.parseFromString(t,"text/xml")}};L.prototype.extend=function(){return L.prototype}();var h=new L;h.augment(R);var st=i=>{let t=0;for(var e in i)i.hasOwnProperty(e)&&(t++,typeof i[e]=="object"&&(t+=st(i[e])));return t},vt=(i,t)=>{let e=!1;if(typeof i!="object"||typeof t!="object")return e;for(var r in i){if(!i.hasOwnProperty(r)||!t.hasOwnProperty(r))break;let s=i[r],n=t[r];if(typeof s!=typeof n)break;if(typeof s=="object"){if(e=vt(s,n),e!==!0)break}else if(s===n)e=!0;else break}return e},Ot=(i,t)=>{let e=st(i),r=st(t);return e!==r?!1:vt(i,t)};h.augment({equals(i,t){let e=typeof i;return e!==typeof t?!1:e==="object"?Ot(i,t):i===t}});var U=h.dataTracker,xt={getEvents(i){return h.isObject(i)===!1?!1:U.get(i,"events")},create(i,t,e,r=!1,s=!1,n=null){return s=s===!0,{event:i,obj:t,fn:e,capture:r,swapped:s,originalFn:n}},add(i,t,e,r=!1,s=!1,n=null){if(h.isObject(t)===!1)return this;let a=this.create(i,t,e,r,s,n);return U.add(t,"events",a),t.addEventListener(i,e,r),this},remove(i,t,e,r=!1){let s=this.getEvent(i,t,e,r);return s===!1?this:(typeof s=="object"&&this.removeEvent(s),this)},removeEvent(i){return typeof i=="object"&&i.obj.removeEventListener(i.event,i.fn,i.capture),this},getEvent(i,t,e,r){if(typeof t!="object")return!1;let s=this.getEvents(t);if(!s||s.length<1)return!1;let n=this.create(i,t,e,r);return this.search(n,s)},search(i,t){let e,r=this.isSwappable(i.event);for(var s=0,n=t.length;s<n;s++)if(e=t[s],!(e.event!==i.event||e.obj!==i.obj)&&(e.fn===i.fn||r===!0&&e.originalFn===i.fn))return e;return!1},removeEvents(i){return h.isObject(i)===!1?this:(U.remove(i,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(i){this.swap.push(i)},isSwappable(i){return h.inArray(this.swap,i)>-1}};U.addType("events",i=>{xt.removeEvent(i)});h.augment({events:xt,addListener(i,t,e,r){return this.events.add(i,t,e,r),this},on(i,t,e,r){let s=this.events;if(this.isArray(i)){let o;for(var n=0,a=i.length;n<a;n++)o=i[n],s.add(o,t,e,r)}else s.add(i,t,e,r);return this},off(i,t,e,r){let s=this.events;if(this.isArray(i))for(var n,a=0,o=i.length;a<o;a++)n=i[a],s.remove(n,t,e,r);else s.remove(i,t,e,r);return this},removeListener(i,t,e,r){return this.events.remove(i,t,e,r),this},_createEvent(i,t,e,r){let s;return t==="HTMLEvents"?s=new Event(i):t==="MouseEvents"?s=new MouseEvent(i,e):s=new CustomEvent(i,r),s},createEvent(i,t,e,r){if(this.isObject(t)===!1)return!1;let s={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};h.isObject(e)&&(s=Object.assign(s,e));let n=this._getEventType(i);return this._createEvent(i,n,s,r)},_getEventType(i){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e,r="CustomEvent";for(var s in t)if(t.hasOwnProperty(s)&&(e=t[s],i.match(e))){r=s;break}return r},trigger(i,t,e){if(this.isObject(t)===!1)return this;let r=typeof i=="string"?this.createEvent(i,t,null,e):i;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let i=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=i())},onMouseWheel(i,t,e,r){typeof t>"u"&&(t=window);let s=a=>{a=a||window.event;let o=Math.max(-1,Math.min(1,-a.deltaY||a.wheelDelta||-a.detail));typeof i=="function"&&i(o,a),e===!0&&a.preventDefault()},n=this.getWheelEventType();return this.events.add(n,t,s,r,!0,i),this},offMouseWheel(i,t,e){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,i,e),this},preventDefault(i){return i=i||window.event,typeof i.preventDefault=="function"?i.preventDefault():i.returnValue=!1,this},stopPropagation(i){return i=i||window.event,typeof i.stopPropagation=="function"?i.stopPropagation():i.cancelBubble=!0,this}});var bt={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};h.augment({xhrSettings:bt,addFixedParams(i){this.xhrSettings.fixedParams=i},beforeSend(i){this.xhrSettings.beforeSend.push(i)},ajaxSettings(i){typeof i=="object"&&(this.xhrSettings=this.extendClass(h.xhrSettings,i))},resetAjaxSettings(){this.xhrSettings=bt}});var N=(...i)=>new it(i).xhr,it=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR();if(e===!1)return!1;let{method:r,url:s,async:n}=this.settings;e.open(r,s,n),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=h.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var s=0,n=t.length;s<n;s++){var a=t[s];a&&a(e,r)}}objectToString(t){let e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}setupParams(t,e){let r=typeof t;if(e){let n=typeof e;if(r==="string")n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e;else if(n==="string"&&(e=h.parseQueryString(e,!1)),t instanceof FormData)for(var s in e)e.hasOwnProperty(s)&&t.append(s,e[s]);else r==="object"&&(t=h.cloneObject(t),t=Object.assign(e,t),t=this.objectToString(t))}else!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.params,r=t.fixedParams;return e?e=this.setupParams(e,r):r&&(e=this.setupParams(r)),e}getXhrSettings(t){let e=this.settings=Object.create(h.xhrSettings);if(t.length>=2&&typeof t[0]!="object")for(var r=0,s=t.length;r<s;r++){var n=t[r];switch(r){case 0:e.url=n;break;case 1:e.params=n;break;case 2:e.completed=n,e.failed=n;break;case 3:e.responseType=n||"json";break;case 4:e.method=n?n.toUpperCase():"POST";break;case 5:e.async=typeof n<"u"?n:!0;break}}else e=this.settings=h.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"){let r=t.headers;for(var e in r)r.hasOwnProperty(e)&&this.xhr.setRequestHeader(e,r[e])}}update(t,e){let r=this.xhr,s=()=>{let o=h.events;o.removeEvents(r.upload),o.removeEvents(r)},n=this.settings;if(!n)return!1;switch(e||t.type){case"load":if(typeof n.completed=="function"){let o=this.getResponseData();n.completed(o,this.xhr)}s();break;case"error":typeof n.failed=="function"&&n.failed(!1,this.xhr),s();break;case"progress":typeof n.progress=="function"&&n.progress(t);break;case"abort":typeof n.aborted=="function"&&n.aborted(!1,this.xhr),s();break}}getResponseData(){let t=this.xhr,e=t.response,r=t.responseType;return!r||r==="text"?t.responseText:e}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=h.bind(this,this.update);h.on(["load","error","abort"],e,r),h.on("progress",e.upload,r)}};var wt=-1,k=class{constructor(){this.callBacks={},this.lastToken=-1}get(t){let e=this.callBacks;return e[t]||(e[t]=[])}reset(){this.callBacks={},this.lastToken=-1,wt=-1}on(t,e){let r=++wt;return this.get(t).push({token:r,callBack:e}),r}off(t,e){let r=this.callBacks[t]||!1;if(r===!1)return!1;let s=r.length;for(var n=0;n<s;n++){var a=r[n];if(a.token===e){r.splice(n,1);break}}}remove(t){let e=this.callBacks;e[t]&&delete e[t]}publish(t){let e,r,s=this.callBacks[t]||!1;if(s===!1)return!1;let n=Array.prototype.slice.call(arguments,1);for(r=s.length,e=0;e<r;e++){var a=s[e];!a||a.callBack.apply(this,n)}}},C=new k;var T=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var H=class extends T{constructor(t){super(),this.data=t}subscribe(t,e){this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data.off(this.msg,this.token)}};var A=class{unsubscribe(){}};var M=class extends A{constructor(){super(),this.source=null}addSource(t){return this.source=new H(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var E=class extends T{subscribe(t){this.msg=t;let e=this.callBack.bind(this);this.token=C.on(t,e)}unsubscribe(){C.off(this.msg,this.token)}callBack(){}};var W=class extends E{constructor(t,e){super(),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)}};var _t=(i,t,e)=>{h.setAttr(i,t,e)},Bt=(i,t,e)=>{i.checked=i.value===e},Rt=(i,t,e)=>{e=e==1,St(i,t,e)},St=(i,t,e)=>{i[t]=e},Lt=(i,t)=>h.getAttr(i,t),It=(i,t)=>i[t],J=class extends E{constructor(t,e,r){super(),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.substring(4,1)==="-")this.setValue=_t,this.getValue=Lt;else{this.getValue=It;var r=t.type;if(r)switch(r){case"checkbox":this.setValue=Rt;return;case"radio":this.setValue=Bt;return}this.setValue=St}}getAttrBind(t){if(t)return t;let e="textContent",r=this.element;if(!(r&&typeof r=="object"))return e;let s=r.tagName.toLowerCase();if(s==="input"||s==="textarea"||s==="select"){let n=r.type;if(n)switch(n){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}else e="value"}return e}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;if(!e||typeof e!="object")return!1;this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t)}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){e!==this.element&&this.set(t)}};var F=class extends A{constructor(){super(),this.element=null,this.data=null}addElement(t,e,r){return this.element=new J(t,e,r)}addData(t,e){return this.data=new W(t,e)}unsubscribeSource(t){t&&t.unsubscribe()}unsubscribe(){this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null}};var V=class{constructor(){this.connections={}}add(t,e,r){let s=this.find(t);return s[e]=r}get(t,e){let r=this.connections[t];return r&&r[e]||!1}find(t){let e=this.connections;return e[t]||(e[t]={})}remove(t,e){let r=this.connections[t];if(!r)return!1;let s;if(e)s=r[e],s&&(s.unsubscribe(),delete r[e]),h.isEmpty(r)&&delete this.connections[t];else{for(var n in r)r.hasOwnProperty(n)&&(s=r[n],s&&s.unsubscribe());delete this.connections[t]}}};var nt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new V,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,s){let n=r,a=null;if(r.indexOf(":")!==-1){let u=r.split(":");u.length>1&&(n=u[1],a=u[0])}let o=this.setupConnection(t,e,n,a,s),l=o.element,f=e.get(n);return typeof f<"u"?l.set(f):(f=l.get(),f!==""&&o.data.set(f)),this}setupConnection(t,e,r,s,n){let a=this.getBindId(t),o=new F;o.addData(e,r).subscribe(a);let f=e.getDataId(),u=f+":"+r;return o.addElement(t,s,n).subscribe(u),this.addConnection(a,"bind",o),o}addConnection(t,e,r){this.connections.add(t,e,r)}setBindId(t){let e="db-"+this.idCount++;return t.dataset[this.attr]=e,t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,s){if(!t||typeof t!="object")return!1;let n=new M;n.addSource(e).subscribe(r,s);let o=this.getBindId(t),l=e.getDataId()+":"+r;this.addConnection(o,l,n);let f=e.get(r);typeof f<"u"&&s(f)}unwatch(t,e,r){if(!t||typeof t!="object")return!1;let s=t[this.attr];if(s){let n=e.getDataId()+":"+r;this.connections.remove(s,n)}}publish(t,e,r){return C.publish(t,e,r),this}isDataBound(t){if(t){let e=t[this.attr];if(e)return e}return!1}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.indexOf(t.keyCode)!==-1}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r){let s=this.connections.get(r,"bind");if(s){let n=s.element.get();C.publish(r,n,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){h.on(["change","keyup"],document,this.changeHandler,!1)}removeEvents(){h.off(["change","keyup"],document,this.changeHandler,!1)}},d=new nt;var at=i=>JSON.parse(JSON.stringify(i)),z=i=>{let t={};if(!i&&typeof i!="object")return t;i=at(i);for(var e in i)if(i.hasOwnProperty(e)){var r=i[e];typeof r!="function"&&(t[e]=r,delete i[e])}return t};var S=class{constructor(t){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new k;let e=z(t);this.set(e)}setup(){this.stage={}}_init(){let t=this.constructor;this._dataNumber=typeof t._dataNumber>"u"?t._dataNumber=0:++t._dataNumber,this._id="dt-"+this._dataNumber,this._dataId=this._id+":"}getDataId(){return this._id}remove(){}on(t,e){let r=t+":change";return this.eventSub.on(r,e)}off(t,e){let r=t+":change";this.eventSub.off(r,e)}_setAttr(t,e,r){let s=this.stage[t];if(e===s)return!1;this.stage[t]=e,r=r||this,this._publish(t,e,r,s)}set(...t){if(typeof t[0]=="object"){let[s,n,a]=t;for(var e in s)if(s.hasOwnProperty(e)){var r=s[e];if(typeof r=="function")continue;this._setAttr(e,r,n,a)}}else this._setAttr(...t);return this}getModelData(){return this.stage}_deleteAttr(t,e){delete t[e]}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,++e),this}decrement(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,--e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){this.key=t}resume(t){let e=this.key;if(!e)return!1;let r,s=localStorage.getItem(e);s===null?t&&(r=t):r=JSON.parse(s),this.set(r)}store(){let t=this.key;if(!t)return!1;let e=this.get();if(!e)return!1;let r=JSON.stringify(e);localStorage.setItem(t,r)}delete(t){if(typeof t<"u"){this._deleteAttr(this.stage,t);return}this.setup()}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let s=[];for(var n in e)e.hasOwnProperty(n)!==!1&&s.push(this.remoteLink(t,n));return s}remoteLink(t,e,r){let s=r||e,n=t.get(e);typeof n<"u"&&this.get(e)!==n&&this.set(e,n);let a=t.on(e,(l,f)=>{if(f===this)return!1;this.set(s,l,t)});this.addLink(a,t);let o=this.on(s,(l,f)=>{if(f===t)return!1;t.set(e,l,this)});return t.addLink(o,this),a}addLink(t,e){this.links[t]=e}unlink(t){if(t){this.removeLink(t);return}let e=this.links;if(e.length){for(var r=0,s=e.length;r<s;r++)this.removeLink(e[r],!1);this.links=[]}}removeLink(t,e){let r=this.links[t];r&&r.off(t),e!==!1&&delete this.links[t]}};S.prototype.isData=!0;var y={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(i){return i.indexOf(".")!==-1||i.indexOf("[")!==-1},getSegments(i){var t=this.deepDataPattern;return i.match(t)}};var v=class extends S{setup(){this.attributes={},this.stage={}}_updateAttr(t,e,r){if(y.hasDeepData(e)){let n,a=y.getSegments(e),o=a.length,l=o-1;for(var s=0;s<o;s++){if(n=a[s],s===l){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}else t[e]=r}_setAttr(t,e,r,s){typeof e!="object"&&e===this.get(t)||(!r&&s!==!0?this._updateAttr(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),this._updateAttr(this.stage,t,e),r=r||this,this._publish(t,e,r))}linkAttr(t,e){let r=t.get(e);if(r)for(var s in r)r.hasOwnProperty(s)&&this.link(t,e+"."+s,s)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let s=new e(r);return s.linkAttr(this,t),s}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r){this.publish(t,e,r)}publishDeep(t,e,r){if(y.hasDeepData(t)){let l,f=y.getSegments(t),u=f.length,c=u-1,m="",B=this.stage;for(var s=0;s<u;s++){l=f[s],B=B[l],s>0?isNaN(l)&&(m+="."+l):m=l;var n;if(s===c)n=e;else{var a=f[s+1];if(isNaN(a)===!1){m+="["+a+"]";continue}var o={};o[a]=B[a],n=o}this.publish(m,n,r)}}else this.publish(t,e,r)}publish(t,e,r){if(t=t||"",this._publishAttr(t,e,r),e&&typeof e=="object"){let a,o;if(Array.isArray(e)){let l=e.length;for(var s=0;s<l;s++)o=e[s],a=t+"["+s+"]",this._checkPublish(a,o,r)}else for(var n in e)e.hasOwnProperty(n)&&(o=e[n],a=t+"."+n,this._checkPublish(a,o,r))}}_checkPublish(t,e,r){!e||typeof e!="object"?this._publishAttr(t,e,r):this.publish(t,e,r)}_publishAttr(t,e,r){d.publish(this._dataId+t,e,r);let s=t+":change";this.eventSub.publish(s,e,r)}mergeStage(){this.attributes=at(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(r===l){if(Array.isArray(t)){t.splice(s,1);break}delete t[s];break}t=n}else break}}else delete t[e]}_getAttr(t,e){if(y.hasDeepData(e)){let a=y.getSegments(e),o=a.length,l=o-1;for(var r=0;r<o;r++){var s=a[r],n=t[s];if(n!==void 0){if(t=n,r===l)return t}else break}return}else return t[e]}};var x=class extends S{_publish(t,e,r,s){let n=t+":change";this.eventSub.publish(n,e,r),r=r||this,d.publish(this._dataId+t,e,r)}};var q=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)t.hasOwnProperty(r)&&e.push(r+"="+t[r]);return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=h.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=h.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)e.hasOwnProperty(r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),s="op=get&id="+r,n=this.model;return this._get("",s,t,e,a=>{if(a){let o=this.getObject(a);o&&n.set(o)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+h.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return!1;let r="op=setup&"+this.setupObjectData();return this._put("",r,t,e)}add(t,e){if(!this.isValid())return!1;let r="op=add&"+this.setupObjectData();return this._post("",r,t,e)}update(t,e){if(!this.isValid())return!1;let r="op=update&"+this.setupObjectData();return this._patch("",r,t,e)}delete(t,e){let r=this.model.get("id"),s="op=delete&id="+r;return this._delete("",s,t,e)}all(t,e,r,s,n){n=n||"",r=isNaN(r)?0:r,s=isNaN(s)?50:s;let a="op=all&option="+n+"&start="+r+"&stop="+s;return this._get("",a,t,e)}getUrl(t){let e=this.url;return t?t[0]==="?"?e+t:e+="/"+t:e}setupRequest(t,e,r,s,n){let a={url:this.getUrl(t),method:e,params:r,completed:(l,f)=>{typeof n=="function"&&n(l),this.getResponse(l,s,f)}};return this._isFormData(r)&&(a.headers={}),N(a)}_isFormData(t){return t instanceof FormData}request(t,e,r,s){return this._request("","POST",t,e,r,s)}_get(t,e,r,s,n){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",s,n)}_post(t,e,r,s,n){return this._request(t,"POST",e,r,s,n)}_put(t,e,r,s,n){return this._request(t,"PUT",e,r,s,n)}_patch(t,e,r,s,n){return this._request(t,"PATCH",e,r,s,n)}_delete(t,e,r,s,n){return this._request(t,"DELETE",e,r,s,n)}_request(t,e,r,s,n,a){return r=this.setupParams(r),r=this.addParams(r,s),this.setupRequest(t,e,r,n,a)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;var e=this;class r extends e{constructor(n){super(n)}}return Object.assign(r.prototype,t),r}};var Ut=i=>{let t={};if(!i||typeof i!="object")return t;let e=i.defaults;if(!e)return t;for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];typeof s!="function"&&(t[r]=s)}return delete i.defaults,t},Nt=i=>{if(!i||typeof i.xhr!="object")return{};let t=i.xhr,e=Object.assign({},t);return delete i.xhr,e},Ht=0,P=class extends v{constructor(t){super(t),this.initialize()}initialize(){}static extend(t={}){let e=this,r=Nt(t),s=this.prototype.service.extend(r),n=Ut(t);class a extends e{constructor(l){let f=z(l);f=Object.assign({},n,f),super(f),this.xhr=new s(this)}dataTypeId="bm"+Ht++}return Object.assign(a.prototype,t),a.prototype.service=s,a}};P.prototype.service=q;var X=class extends x{constructor(t){super(),this.id=t}restore(){g.restore(this.id,this)}remove(){g.remove(this.id)}addAction(t,e){typeof e<"u"&&this.set(t,e)}getState(t){return this.get(t)}removeAction(t,e){if(e)this.off(t,e);else{let r=this.stage;typeof r[t]<"u"&&delete r[t]}}};var ot=class{constructor(){this.targets={}}restore(t,e){this.targets[t]=e}getTarget(t){let e=this.targets;return e[t]||(e[t]=new X(t))}getActionState(t,e){return this.getTarget(t).get(e)}add(t,e,r){let s=this.getTarget(t);return e&&s.addAction(e,r),s}addAction(t,e,r){return this.add(t,e,r)}removeAction(t,e,r){this.off(t,e,r)}on(t,e,r){let s=this.getTarget(t);return e?s.on(e,r):!1}off(t,e,r){this.remove(t,e,r)}remove(t,e,r){let s=this.targets,n=s[t];if(!n)return!1;e?n.off(e,r):delete s[t]}set(t,e,r){var s=this.getTarget(t);s.set(e,r)}},g=new ot;var K=class{constructor(){this._reserved=["tag","bind","onCreated","route","switch","useParent","useState","useData","addState","map","for","html","onSet","onState","watch","context","useContext","addContext","role","aria","cache"]}getElementTag(t){let e="div",r=t.tag||t.t;return typeof r<"u"&&(e=t.tag=r),e}setupChildren(t){t.nest&&(t.children=t.nest,t.nest=null)}parseElement(t){let e={},r=[],s=this.getElementTag(t);s==="button"&&(e.type=e.type||"button"),this.setupChildren(t);let n=this._reserved;for(var a in t)if(t.hasOwnProperty(a)){var o=t[a];if(o==null||n.indexOf(a)!==-1)continue;typeof o!="object"?e[a]=o:a==="children"?r=r.concat(o):r.push(o)}return{tag:s,attr:e,children:r}}};var Mt=h.dataTracker,Wt={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"},lt=i=>Wt[i]||i,ht=i=>typeof i=="string"&&i.substring(0,2)==="on"?i.substring(2):i,G=class{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e),s===!0?this.prepend(r,n):this.append(r,n),n}_addElementAttrs(t,e){if(!e||typeof e!="object")return!1;let r=e.type;typeof r<"u"&&h.setAttr(t,"type",r);for(var s in e)if(!(e.hasOwnProperty(s)===!1||s==="type")){var n=e[s];s==="innerHTML"?t.innerHTML=n:s.substring(4,1)==="-"?h.setAttr(t,s,n):this.addAttr(t,s,n)}}addHtml(t,e){typeof e<"u"&&e!==""&&(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e)}addAttr(t,e,r){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,r);else{let n=lt(e);t[n]=r}}createDocFragment(){return document.createDocumentFragment()}createTextNode(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}createCommentNode(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!e||!e.length)return!1;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=t.options[s]=new Option(a.label,a.value);r!==null&&o.value==r&&(o.selected=!0)}}removeElementData(t){let e=t.childNodes;if(e){let a=e.length-1;for(var r=a;r>=0;r--){var s=e[r];s&&this.removeElementData(s)}}Mt.remove(t),t.bindId&&d.unbind(t)}removeElement(t){let e;return!t||!(e=t.parentNode)?this:(this.removeElementData(t),e.removeChild(t),this)}removeChild(t){this.removeElement(t)}removeAll(t){if(typeof t=="object"){let r=t.childNodes;for(var e in r)r.hasOwnProperty(e)&&this.removeElementData(r[e]);t.innerHTML=""}}changeParent(t,e){e.appendChild(t)}append(t,e){switch(typeof t){case"object":break;case"undefined":t=document.body;break}t.appendChild(e)}prepend(t,e,r){switch(typeof t){case"object":break;case"undefined":t=document.body;break}var s=r||t.firstChild;t.insertBefore(e,s)}clone(t,e){return!t||typeof t!="object"?!1:(e=e||!1,t.cloneNode(e))}};var kt=/(\[\[(.*?)\]\])/g,ft={_getWatcherProps(i){let t=/\[\[(.*?)\]\]/g,e=i.match(t);if(e){t=/(\[\[|\]\])/g;for(var r=0,s=e.length;r<s;r++)e[r]=e[r].replace(t,"")}return e},updateAttr(i,t,e){t==="text"||t==="textContent"?i.textContent=e:t==="innerHTML"?i.innerHTML=e:t.substring(4,1)==="-"?h.setAttr(i,t,e):i[t]=e},_getWatcherCallBack(i,t,e,r,s){return()=>{let n=0,a=e.replace(kt,function(){let o=s?t[n]:t;n++;let l=o.get(arguments[2]);return typeof l<"u"?l:""});this.updateAttr(i,r,a)}},getParentData(i){return i.data?i.data:i.context&&i.context.data?i.context.data:i.state?i.state:null},getValue(i,t){typeof i=="string"&&(i={value:i});let e=i.value;return Array.isArray(e)===!1?e=[e,this.getParentData(t)]:e.length<2&&e.push(this.getParentData(t)),e},getPropValues(i,t,e){let r=[];for(var s=0,n=t.length;s<n;s++){var a=e?i[s]:i,o=a.get(t[s]);o=typeof o<"u"?o:"",r.push(o)}return r},getCallBack(i,t,e,r,s){let n,a=i.callBack;if(typeof a=="function"){let o=r.match(kt),l=o&&o.length>1;n=(f,u)=>{f=l!==!0?f:this.getPropValues(e,o,s),a(t,f,u)}}else{let o=i.attr||"textContent";n=this._getWatcherCallBack(t,e,r,o,s)}return n},addDataWatcher(i,t,e){let r=this.getValue(t,e),s=r[1];if(!s)return;let n=r[0],a=Array.isArray(s),o=this.getCallBack(t,i,s,n,a),l=this._getWatcherProps(n);for(var f=0,u=l.length;f<u;f++){var c=a?s[f]:s;this.addWatcher(i,c,l[f],o)}},setup(i,t,e){!t||(Array.isArray(t)&&(t={attr:t[2],value:[t[0],t[1]]}),this.addDataWatcher(i,t,e))},addWatcher(i,t,e,r){d.watch(i,t,e,r)}};var Jt={created:"onCreated",state:"setupStates",events:"setupEevents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"},Ft=i=>typeof i==="function"?i:function(){return i},Vt=i=>{let t={};if(!i)return t;for(var e in i){if(i.hasOwnProperty(e)===!1)continue;let r=i[e],s=Jt[e];if(s){t[s]=Ft(r);continue}t[e]=r}return t},zt=i=>{class t extends w{}return Object.assign(t.prototype,i),t},Ct=i=>{class t extends b{}return Object.assign(t.prototype,i),t},D=function(i){if(!i)return null;let t;switch(typeof i){case"object":return i.render?(t=Vt(i),zt(t)):(t={render:function(){return i}},Ct(t));case"function":return t={render:i},Ct(t)}};var Tt=function(i,t){return function(e){return{onSet:[i,t,(r,s)=>e(s)]}}};h.dataTracker.addType("context",function(i){if(!i)return!1;i.parent.removeContextBranch(i.branch)});var qt=new K,ut=class extends G{create(t,e,r,s){let n=document.createElement(t);return this._addElementAttrs(n,e,s),this.append(r,n),n}_addElementAttrs(t,e,r){if(!e||typeof e!="object")return!1;let s=e.type;typeof s<"u"&&h.setAttr(t,"type",s);for(var n in e)if(!(e.hasOwnProperty(n)===!1||n==="type")){var a=e[n];n==="innerHTML"?t.innerHTML=a:n.indexOf("-")!==-1?h.setAttr(t,n,a):this.addAttr(t,n,a,r)}}addAttr(t,e,r,s){if(r===""||!e)return!1;if(typeof r==="function")e=ht(e),h.addListener(e,t,function(a){r.call(this,a,s)});else{let a=lt(e);t[a]=r}}render(t,e,r){if(!!t)switch(typeof t){case"object":if(t.isUnit===!0)return this.createComponent(t,e,r),t;default:let s=D(t),n=new s;return this.createComponent(n,e,r),n}}build(t,e,r){let s=this.createDocFragment();if(Array.isArray(t)){let o;for(var n=0,a=t.length;n<a;n++)o=t[n],this.buildElement(o,s,r)}else this.buildElement(t,s,r);return e&&typeof e=="object"&&e.appendChild(s),s}buildElement(t,e,r){!t||(t.component||t.isUnit===!0?this.createComponent(t,e,r):this.createElement(t,e,r))}append(t,e){t.appendChild(e)}createElement(t,e,r){let s=qt.parseElement(t),n=this.createNode(s,e,r),a=t.cache;r&&a&&(r[a]=n);let o=s.children;if(o.length>0){let u;for(var l=0,f=o.length;l<f;l++)u=o[l],u!==null&&this.buildElement(u,n,r)}this.addElementDirectives(n,t,r)}addElementDirectives(t,e,r){typeof e.onCreated=="function"&&e.onCreated(t,r);let s=e.bind;if(s&&this.bindElement(t,s,r),e.route&&this.addRoute(t,e.route,r),e.switch&&this.addSwitch(t,e.switch,r),e.html&&this.addHtml(t,e.html),e.useContext&&this.useContext(t,e.useContext,r),e.addContext&&this.addContext(t,e.addContext,r),e.context&&this.context(t,e.context,r),e.role&&this.addRole(t,e.role,r),e.aria&&this.addAria(t,e.aria,r),r){let n=e.onState;n&&n.length&&this.onState(t,n,r);let a=e.onSet;a&&a.length&&this.onSet(t,a,r);let o=e.map;o&&o.length&&this.map(t,o,r);let l=e.for;l&&l.length&&this.for(t,l,r);let f=e.useParent;f&&this.useParent(t,f,r);let u=e.useData;u&&this.useData(t,u,r);let c=e.useState;c&&this.useState(t,c,r);let m=e.addState;m&&this.addState(t,m,r)}e.watch&&this.watch(t,e.watch,r)}_getDataSource(t){return t?t.data?t.data:t.context&&t.context.data?t.context.data:t.state?t.state:!1:!1}bindElement(t,e,r){let s,n,a;if(typeof e=="string"){if(s=this._getDataSource(r),!s)return!1;n=e}else if(Array.isArray(e)){if(typeof e[0]!="object"){let o=this._getDataSource(r);if(o)e.unshift(o);else return!1}[s,n,a]=e}d.bind(t,s,n,a)}addRoute(t,e,r){if(!e)return!1;if(h.isArray(e))for(var s=0,n=e.length;s<n;s++)this.setupRoute(t,e[s],r);else this.setupRoute(t,e,r)}setupRoute(t,e,r){e.container=t,e.parent=r;let s=h.router.add(e);this.trackRoute(t,s)}checkResume(t){return t&&t.component&&t.component.route}resumeRoute(t,e){h.router.resume(e,t),this.trackRoute(t,e)}trackRoute(t,e){h.dataTracker.add(t,"routes",{route:e})}addSwitch(t,e,r){let s=e[0];for(var n=0,a=e.length;n<a;n++)s=e[n],s.container=t,s.parent=r;let o=h.router.addSwitch(e);this.trackSwitch(t,o)}resumeSwitch(t,e){let r=h.router.resumeSwitch(e,t);this.trackSwitch(t,r)}trackSwitch(t,e){h.dataTracker.add(t,"switch",{id:e})}addRole(t,e,r){!e||e&&h.setAttr(t,"role",e)}addAria(t,e,r){if(!e)return;let s=e.role;s&&(h.setAttr(t,"role",s),e.role=null);let n=f=>(u,c)=>{var m=c?"true":"false";h.setAttr(u,f,m)};for(var a in e)if(!(e.hasOwnProperty(a)===!1||e[a]===null)){var o=e[a],l="aria-"+a;Array.isArray(o)?(o.push(n(l)),this.onSet(t,o,r)):h.setAttr(t,l,o)}}getParentContext(t){return t?t.getContext():null}context(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r),n=e(s);!n||(this._addElementAttrs(t,n,r),this.addElementDirectives(t,n,r))}useContext(t,e,r){if(typeof e!="function")return;let s=this.getParentContext(r);e(s)}addContext(t,e,r){if(typeof e!="function"||!r)return;let s=this.getParentContext(r),n=e(s);!n||r.addContextBranch(n[0],n[1])}trackContext(t,e,r){h.dataTracker.add(t,"context",{branch:e,parent:r})}watch(t,e,r){if(!e)return!1;if(Array.isArray(e)&&typeof e[0]!="string")for(var s=0,n=e.length;s<n;s++)ft.setup(t,e[s],r);else ft.setup(t,e,r)}useParent(t,e,r){if(!e||!r)return!1;e(r,t)}useData(t,e,r){if(!e||!r)return!1;e(r.data,t)}useState(t,e,r){if(!e||!r)return!1;e(r.state,t)}addState(t,e,r){if(!e||!r)return!1;if(r.stateHelper){let s=r.state,n=e(s);r.stateHelper.addStates(n)}}map(t,e,r){let s=e[0];if(!s||s.length<1)return;let n=e[1],a=[];for(var o=0,l=s.length;o<l;o++){var f=s[o];if(!!f){var u=n(f,o);u!==null&&a.push(u)}}return this.build(a,t,r)}for(t,e,r){let s,n,a,o;if(e.length<3){let f=this.getParentSetData(r);if(!f)return;s=f,n=e[0],a=e[1],o=e[2]}else s=e[0],n=e[1],a=e[2],o=e[3];let l=o!==!1;d.watch(t,s,n,f=>{if(this.removeAll(t),!f||f.length<1)return;let u=[];for(var c=0,m=f.length;c<m;c++){var B=l?s.scope(n+"["+c+"]"):null,yt=a(f[c],c,B);yt!==null&&u.push(yt)}return this.build(u,t,r)})}onState(t,e,r){this.onUpdate(t,r.state,e,r)}getParentSetData(t){return t.data?t.data:t.context&&t.context.data?t.context.data:null}onSet(t,e,r){let s=this.getParentSetData(r);this.onUpdate(t,s,e,r)}onUpdate(t,e,r,s){let n,a,o;if(h.isArray(r[0])){for(var l=0,f=r.length;l<f;l++){var u=r[l];!u||this.onUpdate(t,e,u,s)}return}if(r.length<3?[n,a]=r:[e,n,a]=r,!e||!n)return!1;switch(typeof a){case"object":o=c=>{this.addClass(t,a,c)};break;case"function":o=c=>{this.updateElement(t,a,n,c,s)};break}d.watch(t,e,n,o)}updateElement(t,e,r,s,n){let a=e(t,s,n);switch(typeof a){case"object":if(n&&a&&a.isUnit===!0&&n.persist===!0&&n.state){let o=r+":"+s,l=n.state,f=l.get(o);typeof f<"u"&&(a=f),l.set(o,a)}this.rebuild(t,a,n);break;case"string":this.addHtml(t,a);break}}addClass(t,e,r){for(var s in e)!e.hasOwnProperty(s)||!s||(e[s]===r?h.addClass(t,s):h.removeClass(t,s))}rebuild(t,e,r){this.removeAll(t),this.build(e,t,r)}createComponent(t,e,r){let s=t.component||t;s.parent=r,r&&r.persist===!0&&s.persist!==!1&&(s.persist=!0),s.cacheable&&r&&(r[s.cacheable]=s),s.setup(e),t.component&&typeof t.onCreated=="function"&&t.onCreated(s)}createNode(t,e,r){let s=t.tag;if(s==="text"){let n=t.attr,a=n.textContent||n.text;return this.createTextNode(a,e)}else if(s==="comment"){let a=t.attr.text;return this.createCommentNode(a,e)}return this.create(s,t.attr,e,r)}},p=new ut;h.augment({buildLayout(i,t,e){p.build(i,t,e)}});h.dataTracker.addType("components",i=>{if(!i)return;let t=i.component;t&&t.rendered===!0&&t.prepareDestroy()});var Xt=0,b=class{constructor(t){this.isUnit=!0,this.init(),this.setupProps(t),this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Xt++}setupProps(t){if(!t||typeof t!="object")return!1;for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e])}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];!r||(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context=this.context||{},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.persist?this._layout||(this._layout=this.render()):this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}buildLayout(){let t=this.prepareLayout();this.build(t,this.container),h.dataTracker.add(this.panel,"components",{component:this}),this.rendered=!0}build(t,e){return p.build(t,e,this)}prepend(t,e,r){var s=this.build(t,null);p.prepend(e,s,r)}rebuild(t,e){return p.rebuild(e,t,this)}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var s=0,n=t.length;s<n;s++){var a=e(t[s],s);r.push(a)}return r}removeAll(t){return p.removeAll(t)}cache(t,e,r){return!e||typeof e!="object"?!1:(e.isUnit===!0&&(e={component:e}),e.onCreated=s=>{this[t]=s,typeof r=="function"&&r(s)},e)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup(),this.buildLayout(),this.afterSetup()}beforeSetup(){}afterSetup(){}setup(t){this.container=t,this.initialize()}remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;p.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this.remove()}bindElement(t,e,r,s){t&&d.bind(t,e,r,s)}};var Q=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(e<1)return!1;let r;for(var s=0;s<e;s++)r=t[s],this.on(...r)}on(t,e,r,s){h.on(t,e,r,s),this.events.push({event:t,obj:e,callBack:r,capture:s})}off(t,e,r,s){h.off(t,e,r,s);let n,a=this.events;for(var o=0,l=a.length;o<l;o++)if(n=a[o],n.event===t&&n.obj===e){a.splice(o,1);break}}set(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.on(t.event,t.obj,t.callBack,t.capture)}unset(){let t,e=this.events;for(var r=0,s=e.length;r<s;r++)t=e[r],h.off(t.event,t.obj,t.callBack,t.capture)}reset(){this.unset(),this.events=[]}};var $=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,s){return{action:t,state:e,callBack:r,targetId:s,token:null}}convertStates(t){let e=[];for(var r in t)if(t.hasOwnProperty(r)!==!1){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var s=null,n=null,a=t[r];a&&typeof a=="object"&&(n=a.callBack,s=a.id||a.targetId,a=a.state),e.push(this.createState(r,a,n,s))}return e}setupRemoteStates(t,e){let r;for(var s=0,n=t.length;s<n;s++)if(r=t[s],!!r){for(var a in r)if(!(r.hasOwnProperty(a)===!1||a==="id")){var o=null,l=r[a],f=l!==null?l:void 0;f&&typeof f=="object"&&(o=f.callBack,f=f.state),e.push(this.createState(a,f,o,r.id))}}}removeRemoteStates(){let t=this.remoteStates;t&&this.removeActions(t)}removeActions(t){if(!(t.length<1))for(var e=0,r=t.length;e<r;e++){var s=t[e];g.remove(s.targetId,s.action,s.token)}}restore(t){t.restore();let e=this.remoteStates;if(!!e)for(var r=0,s=e.length;r<s;r++){var n=e[r];n.token=this.bindRemoteState(t,n.action,n.targetId)}}bindRemoteState(t,e,r){let s=g.getTarget(r);return t.link(s,e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var s=0,n=e.length;s<n;s++){var a=e[s],o=this.addAction(t,a);a.targetId&&(a.token=o,r.push(a))}r.length<1&&(this.remoteStates=null)}addAction(t,e){let r,s=e.action,n=e.targetId;n&&(r=this.bindRemoteState(t,s,n)),typeof e.state<"u"&&t.addAction(s,e.state);let a=e.callBack;return typeof a=="function"&&t.on(s,a),r}};var w=class extends b{constructor(t){super(t),this.isComponent=!0,this.stateTargetId=null}initialize(){this.setupContext(),this.beforeSetup(),this.addStates(),this.buildLayout(),this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=g.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateHelper.restore(t);return}let e=this.setupStates();h.isEmpty(e)||(this.setupStateTarget(),this.stateHelper=new $(this.state,e))}removeStates(){let t=this.state;if(!t)return!1;this.stateHelper.removeRemoteStates(),t.remove()}setupEventHelper(){this.events||(this.events=new Q)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();if(t.length<1)return!1;this.setupEventHelper(),this.events.addEvents(t)}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist===!1&&this.data.unlink()}};var Y=class extends w{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",className:this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),children:this.children,watch:r}}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact!==!1,s=O.data,n=[];return t&&typeof t=="object"&&n.push({attr:"href",value:t}),e&&typeof e=="object"&&n.push({attr:"text",value:e}),n.push({value:["[[path]]",s],callBack:(a,o)=>{let l=a.pathname+a.hash,f=r?o===l:new RegExp("^"+a.pathname+"($|#|/|\\.).*").test(o);this.update(a,f)}}),n}setupStates(){return{selected:!1}}update(t,e){this.state.set("selected",e)}};var At={removeSlashes(i){return typeof i=="string"&&(i.substring(0,1)==="/"&&(i=i.substring(1)),i.substring(-1)==="/"&&(i=i.substring(0,i.length-1))),i}};var Z=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,this.setupTemplate()}focus(t){this.setup===!1&&this.create(),this.update(t)}setupTemplate(){let t=this.template;if(typeof t=="string"&&(t=this.template=window[t],!t))return;let e=typeof t;if(e==="function")this.component=new this.template({route:this.route,persist:this.persist,parent:this.parent});else if(e==="object"){this.template.isUnit||(this.template=Jot(this.template));let r=this.component=this.template,s=r.persist!==!1;r.route=this.route,r.persist=s,r.parent=this.parent,this.persist=s}this.hasTemplate=!0}create(){if(!this.hasTemplate)return!1;this.setup=!0;let t=this.component;(!this.persist||!t)&&(t=this.component=this.template),p.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return!1;this.setup=!1;let t=this.component;if(!t)return!1;typeof t.destroy=="function"&&t.destroy(),this.persist===!1&&(this.component=null)}update(t){let e=this.component;if(!e)return!1;typeof e.update=="function"&&e.update(t)}};var dt=[],Kt=i=>dt.indexOf(i)!==-1,Gt=i=>({tag:"script",src:i.src,async:!1,load(t){dt.push(i.src);let e=i.load;e&&e()}}),Qt=i=>({tag:"link",rel:"stylesheet",type:"text/css",href:i.src,load(t){dt.push(i.src);let e=i.load;e&&e()}}),ct=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=Qt({load:r,src:t}):e=Gt({load:r,src:t}),p.build(e,document.head)}addFiles(t){if(!!t)for(var e=0,r=t.length;e<r;e++){var s=t[e];Kt(s)||this.add(s)}}update(){if(this.updateProgress()>=100){var e=this.callBack;e&&e()}}updateProgress(){return++this.loaded,this.percent=Math.floor(this.loaded/this.total*100)}},$t=(i,t)=>{import(i).then(e=>{t&&t(e)})},Yt=i=>i?typeof i?.prototype?.constructor=="function":!1,Zt=(i,t,e)=>{let r=p.build(i,null,e),s=r.firstChild;return t.after(r),s},jt=i=>({tag:"comment",text:"import placeholder",onCreated:i.onCreated}),te=D({render(){return jt({onCreated:i=>{if(!!this.src){if(this.depends){new ct(()=>{this.loadAndRender(i)}).addFiles(this.depends);return}this.loadAndRender(i)}}})},getLayout(i){let t=i.default;if(!t)return null;let e=this.callBack;return e?t=e(t):Yt(t)?(t=new t,t.route=this.route,this.persist&&(t.persist=!0)):t=t(),this.layout=t},loadAndRender(i){$t(this.src,t=>{this.loaded=!0;let e=this.layout||this.getLayout(t);this.layoutRoot=Zt(e,i,this.parent)})},shouldUpdate(i){return this.updateLayout===!0?!0:this.updateLayout=i&&i.isUnit&&typeof i.update=="function"},updateModuleLayout(i){let t=this.layout;this.shouldUpdate(t)&&t.update(i)},update(i){this.loaded===!0&&this.updateModuleLayout(i)},beforeDestroy(){!this.layoutRoot||p.removeElement(this.layoutRoot)}}),Et=i=>new te(i);var ee=i=>{let t="";if(i){let e=/\//g;t=i.replace(e,"/");let r=/(\/):[^\/(]*?\?/g;t=t.replace(r,o=>{let l=/\//g;return o.replace(l,"(?:$|/)")});let s=/(:[^\/?&($]+)/g,n=/(\?\/+\*?)/g;t=t.replace(n,"?/*"),t=t.replace(s,o=>o.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)");let a=/(\*)/g;t=t.replace(a,".*")}return t+=i[i.length-1]==="*"?"":"$",t},re=i=>{if(i.length){let r={};for(var t=0,e=i.length;t<e;t++)r[i[t]]=null;return r}return null},se=i=>{let t=[];if(!i)return t;let e=/[\*?]/g;i=i.replace(e,"");let r=/:(.[^.\/?&($]+)\?*/g,s=i.match(r);if(s===null)return t;for(var n=0,a=s.length;n<a;n++){var o=s[n];o&&(o=o.replace(":",""),t.push(o))}return t},ie=0,j=class extends x{constructor(t){let e=t.baseUri,r=se(e),s=re(r);super(s),this.uri=e,this.paramKeys=r,this.setupRoute(t),this.set("active",!1)}setupRoute(t){this.id=t.id||"bs-rte-"+ie++,this.path=null,this.referralPath=null;let e=ee(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title}setTitle(t){base.router.updateTitle({title:t,stage:this.stage})}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?(typeof e=="string"&&(e={src:e}),Et(e)):null}setupComponentHelper(t){let e=this.getLayout(t);if(e){let{container:r,persist:s=!1,parent:n}=t,a={component:e,container:r,persist:s,parent:n};this.controller=new Z(this,a)}}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let s=this.path;if(!s)return;let n=s.split("#")[1];!n||this.scrollToId(n)}scrollToId(t){if(!t)return;let e=document.getElementById(t);!e||e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(r&&typeof r=="object"&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(t&&typeof t=="object"){let n=this.paramKeys;if(n){let a={};for(var e=0,r=n.length;e<r;e++){var s=n[e];typeof s<"u"&&(a[s]=t[e])}this.set(a)}}}getParams(){return this.stage}};var _=class{static browserIsSupported(){return"history"in window&&"pushState"in window.history}static setup(t){return _.browserIsSupported()?new pt(t).setup():new mt(t).setup()}},ne=0,tt=class{constructor(t){this.router=t,this.locationId="base-app-router-"+ne++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}},pt=class extends tt{addEvent(){return h.on("popstate",window,this.callBack),this}removeEvent(){return h.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri)}createState(t,e){let r={location:this.locationId,uri:t};return e&&typeof e=="object"&&(r=Object.assign(r,e)),r}addState(t,e,r){let s=window.history,n=s.state;if(n&&n.uri===t)return this;let a=this.createState(t,e);return r=r===!0,s[r===!1?"pushState":"replaceState"](a,null,t),this}},mt=class extends tt{addEvent(){return h.on("hashchange",window,this.callBack),this}removeEvent(){return h.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};h.dataTracker.addType("routes",i=>{if(!i)return!1;let t=i.route;t&&O.removeRoute(t)});h.dataTracker.addType("switch",i=>{if(!i)return!1;let t=i.id;O.removeSwitch(t)});var gt=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=window.location,this.routes=[],this.switches={},this.switchCount=0,this.data=new v({path:""})}setupHistory(){this.history=_.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new j(t)}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+At.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.uri===t)return n}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var s=0;s<r;s++){var n=e[s];if(n.id===t)return n}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);for(var s=0,n=t.length;s<n;s++){var a=this.createRoute(t[s]);r.push(a)}return this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,s=this.getSwitchGroup(r);for(var n=0,a=t.length;n<a;n++){var o=t[n].component.route;o.resume(e),s.push(o)}return this.checkGroup(s,this.getPath()),r}getSwitchGroup(t){return this.switches[t]=[]}removeSwitch(t){let e=this.switches;e[t]&&delete e[t]}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.set("path",this.getPath()),this.callBackLink=this.checkLink.bind(this),h.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||h.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let s=this.baseURI,n=s!=="/"?r.replace(s,""):r;return this.navigate(n),t.preventDefault(),t.stopPropagation(),!1}}reset(){return this.routes=[],this.switches=[],this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.set("path",t)}updateTitle(t){if(!t||!t.title)return this;let e=s=>{let n=o=>{let l=/\w\S*/;return o.replace(l,f=>f.charAt(0).toUpperCase()+f.substring(1).toLowerCase())},a=o=>{if(o.indexOf(":")>-1){let c=t.stage;for(var l in c)if(c.hasOwnProperty(l)){var f=c[l],u=new RegExp(":"+l,"gi");o=o.replace(u,f)}}return o};return s&&(typeof s=="function"&&(s=s(t.stage)),s=a(s),s=n(s),this.title!==""&&(s+=" - "+this.title)),s},r=t.title;document.title=e(r)}checkActiveRoutes(t){this.lastPath=t,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,s;for(var n=0;n<r;n++)s=e[n],!(typeof s>"u")&&this.checkRoute(s,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(var r in e)if(e.hasOwnProperty(r)!==!1){var s=e[r];this.checkGroup(s,t)}}checkGroup(t,e){let r=!1,s,n,a,o,l=!1;for(var f=0,u=t.length;f<u;f++)if(s=t[f],!(typeof s>"u")){if(f===0&&(n=s),!a&&s.get("active")&&(a=s),r!==!1){l&&s.deactivate();continue}r=s.match(e),r!==!1&&(o=s,s.controller&&(this.select(s),l=!0))}o===void 0?(this.select(n),a&&n!==a&&a.deactivate()):a?l&&o!==a&&a.deactivate():n&&l===!1&&this.select(n)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){if(!t)return!1;t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t)}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){h.off("click",document,this.callBackLink)}getPath(){let t=this.location,e=this.path=t.pathname;return this.history.type==="hash"?t.hash.replace("#",""):e+t.search+t.hash}},O=new gt;var Pt=function(){};Pt.extend=function i(t){let e=this;if(typeof t=="object"){let s=t;t=n=>R.cloneObject(s)}let r=(s={})=>{s=s||{};let n=t(s),a=e(s);return typeof a=="object"&&(n=R.extendObject(a,n)),n};return r.extend=i,r};h.augment({ajax:N,dataBinder:d,Data:v,SimpleData:x,Model:P,state:g,builder:p,router:O,Component:w});export{Pt as Atom,w as Component,v as Data,D as Jot,P as Model,Y as NavLink,x as SimpleData,b as Unit,Tt as Watch,N as ajax,h as base,p as builder,d as dataBinder,O as router,g as state};
|
|
1
|
+
var be=Object.defineProperty;var Se=(s,t,e)=>t in s?be(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e;var L=(s,t,e)=>(Se(s,typeof t!="symbol"?t+"":t,e),e);var C=class{static toArray(t){return Array.prototype.slice.call(t)}static inArray(t,e,r){return!t||typeof t!="object"?-1:t.indexOf(e,r)}};var u=class{static getType(t){let e=typeof t;return e!=="object"?e:this.isArray(t)?"array":e}static isUndefined(t){return typeof t>"u"}static isObject(t){return t&&typeof t=="object"&&this.isArray(t)===!1}static isString(t){return typeof t=="string"}static isArray(t){return Array.isArray(t)}};var m={create(s){return Object.create(s)},extendObject(s,t){if(typeof s>"u"||typeof t>"u")return!1;for(var e in s)Object.prototype.hasOwnProperty.call(s,e)&&typeof t[e]>"u"&&(t[e]=s[e]);return t},clone(s){return s?JSON.parse(JSON.stringify(s)):{}},getClassObject(s){return typeof s=="function"?s.prototype:s},extendClass(s,t){let e=this.getClassObject(s),r=this.getClassObject(t);if(typeof e!="object"||typeof r!="object")return!1;let n=Object.create(e);for(var i in r)n[i]=r[i];return n},isEmpty(s){if(u.isObject(s)===!1)return!0;for(var t in s)if(Object.prototype.hasOwnProperty.call(s,t))return!1;return!0}};var $={types:{},add(s,t){this.types[s]=t},get(s){return this.types[s]||!1},remove(s){delete this.types[s]}};var Z=class{constructor(){this.types={}}add(t,e){(this.types[t]||(this.types[t]=[])).push(e)}get(t){return this.types[t]||!1}removeByCallBack(t,e){typeof t=="function"&&t(e)}removeType(t){let e=this.types;if(!e)return;let r=e[t];if(!r.length)return;let n,i=$.get(t);for(var o=0,a=r.length;o<a;o++)n=r[o],n&&(r[o]=null,this.removeByCallBack(i,n));delete e[r]}remove(t){if(t)this.removeType(t);else{let r=this.types;for(var e in r)if(Object.prototype.hasOwnProperty.call(r,e)){if(t=r[e],!t)continue;this.removeType(e)}delete this.types}}};var l=class{static addType(t,e){$.add(t,e)}static removeType(t){$.remove(t)}static getTrackingId(t){return t.trackingId||(t.trackingId="dt"+this.trackingCount++)}static add(t,e,r){let n=this.getTrackingId(t);this.find(n).add(e,r)}static get(t,e){let r=t.trackingId,n=this.trackers[r];return n?e?n.get(e):n:!1}static find(t){let e=this.trackers;return e[t]||(e[t]=new Z)}static isEmpty(t){if(!t||typeof t!="object")return!0;for(var e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}static remove(t,e){let r=t.trackingId;if(!r)return!0;let n=this.trackers[r];if(!n)return!1;e?(n.remove(e),this.isEmpty(n.types)&&delete this.trackers[r]):(n.remove(),delete this.trackers[r])}};L(l,"trackers",{}),L(l,"trackingCount",0);var St=s=>{let t=0;for(var e in s)!Object.prototype.hasOwnProperty.call(s,e)||(t++,typeof s[e]=="object"&&(t+=St(s[e])));return t},Rt=(s,t)=>{let e=!1;if(typeof s!="object"||typeof t!="object")return e;for(var r in s){if(!Object.prototype.hasOwnProperty.call(s,r)||!Object.prototype.hasOwnProperty.call(t,r))break;let n=s[r],i=t[r];if(typeof n!=typeof i)break;if(typeof n=="object"){if(e=Rt(n,i),e!==!0)break}else if(n===i)e=!0;else break}return e},we=(s,t)=>{let e=St(s),r=St(t);return e!==r?!1:Rt(s,t)},Lt=(s,t)=>{let e=typeof s;return e!==typeof t?!1:e==="object"?we(s,t):s===t};var d={getEvents(s){return u.isObject(s)===!1?!1:l.get(s,"events")},create(s,t,e,r=!1,n=!1,i=null){return n=n===!0,{event:s,obj:t,fn:e,capture:r,swapped:n,originalFn:i}},on(s,t,e,r){if(Array.isArray(s)){let o;for(var n=0,i=s.length;n<i;n++)o=s[n],this.add(o,t,e,r)}else this.add(s,t,e,r);return this},off(s,t,e,r){if(Array.isArray(s))for(var n,i=0,o=s.length;i<o;i++)n=s[i],this.remove(n,t,e,r);else this.remove(s,t,e,r);return this},add(s,t,e,r=!1,n=!1,i=null){if(u.isObject(t)===!1)return this;let o=this.create(s,t,e,r,n,i);return l.add(t,"events",o),t.addEventListener(s,e,r),this},remove(s,t,e,r=!1){let n=this.getEvent(s,t,e,r);return n===!1?this:(typeof n=="object"&&this.removeEvent(n),this)},removeEvent(s){return typeof s=="object"&&s.obj.removeEventListener(s.event,s.fn,s.capture),this},getEvent(s,t,e,r){if(typeof t!="object")return!1;let n=this.getEvents(t);if(!n||n.length<1)return!1;let i=this.create(s,t,e,r);return this.search(i,n)},search(s,t){let e,r=this.isSwappable(s.event);for(var n=0,i=t.length;n<i;n++)if(e=t[n],!(e.event!==s.event||e.obj!==s.obj)&&(e.fn===s.fn||r===!0&&e.originalFn===s.fn))return e;return!1},removeEvents(s){return u.isObject(s)===!1?this:(l.remove(s,"events"),this)},swap:["DOMMouseScroll","wheel","mousewheel","mousemove","popstate"],addSwapped(s){this.swap.push(s)},isSwappable(s){return C.inArray(this.swap,s)>-1}};l.addType("events",s=>{d.removeEvent(s)});var _t={events:d,addListener(s,t,e,r){return this.events.add(s,t,e,r),this},on(s,t,e,r){let n=this.events;if(Array.isArray(s)){let a;for(var i=0,o=s.length;i<o;i++)a=s[i],n.add(a,t,e,r)}else n.add(s,t,e,r);return this},off(s,t,e,r){let n=this.events;if(Array.isArray(s))for(var i,o=0,a=s.length;o<a;o++)i=s[o],n.remove(i,t,e,r);else n.remove(s,t,e,r);return this},removeListener(s,t,e,r){return this.events.remove(s,t,e,r),this},_createEvent(s,t,e,r){let n;return t==="HTMLEvents"?n=new Event(s):t==="MouseEvents"?n=new MouseEvent(s,e):n=new CustomEvent(s,r),n},createEvent(s,t,e,r){if(u.isObject(t)===!1)return!1;let n={pointerX:0,pointerY:0,button:0,view:window,detail:1,screenX:0,screenY:0,clientX:0,clientY:0,ctrlKey:!1,altKey:!1,shiftKey:!1,metaKey:!1,bubbles:!0,cancelable:!0,relatedTarget:null};u.isObject(e)&&(n=Object.assign(n,e));let i=this._getEventType(s);return this._createEvent(s,i,n,r)},_getEventType(s){let t={HTMLEvents:/^(?:load|unload|abort|error|select|change|submit|reset|focus|blur|resize|scroll)$/,MouseEvents:/^(?:click|dblclick|mouse(?:down|up|over|move|out))$/},e,r="CustomEvent";for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&(e=t[n],s.match(e))){r=n;break}return r},trigger(s,t,e){if(u.isObject(t)===!1)return this;let r=typeof s=="string"?this.createEvent(s,t,null,e):s;return t.dispatchEvent(r),this},mouseWheelEventType:null,getWheelEventType(){let s=()=>{let t="wheel";return"onmousewheel"in self?t="mousewheel":"DOMMouseScroll"in self&&(t="DOMMouseScroll"),t};return this.mouseWheelEventType||(this.mouseWheelEventType=s())},onMouseWheel(s,t,e,r){typeof t>"u"&&(t=window);let n=o=>{let a=Math.max(-1,Math.min(1,-o.deltaY||o.wheelDelta||-o.detail));typeof s=="function"&&s(a,o),e===!0&&o.preventDefault()},i=this.getWheelEventType();return this.events.add(i,t,n,r,!0,s),this},offMouseWheel(s,t,e){typeof t>"u"&&(t=window);let r=this.getWheelEventType();return this.off(r,t,s,e),this},preventDefault(s){return typeof s.preventDefault=="function"?s.preventDefault():s.returnValue=!1,this},stopPropagation(s){return typeof s.stopPropagation=="function"?s.stopPropagation():s.cancelBubble=!0,this}};var K=class{constructor(){this.version="3.0.0",this.errors=[],this.dataTracker=l}augment(t){if(!t||typeof t!="object")return this;let e=this.constructor.prototype;for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return this}override(t,e,r,n){return(t[e]=r).apply(t,C.toArray(n))}getLastError(){let t=this.errors;return t.length?t.pop():!1}addError(t){this.errors.push(t)}getProperty(t,e,r){if(u.isObject(t)===!1)return"";let n=t[e];return typeof n<"u"?n:typeof r<"u"?r:""}createCallBack(t,e,r,n){return typeof e!="function"?!1:(r=r||[],function(...i){return n===!0&&(r=r.concat(i)),e.apply(t,r)})}bind(t,e){return e.bind(t)}};K.prototype.extend=function(){return K.prototype}();var S=new K;S.augment({...m,..._t,...u,equals:Lt});var x=class{static parseQueryString(t,e){typeof t!="string"&&(t=window.location.search);let r={},n=/([^?=&]+)(=([^&]*))?/g;return t.replace(n,function(i,o,a,c){r[o]=e!==!1?decodeURIComponent(c):c}),r}static camelCase(t){if(typeof t!="string")return!1;let e=/(-|\s|_)+\w{1}/g;return t.replace(e,r=>r[1].toUpperCase())}static uncamelCase(t,e){if(typeof t!="string")return!1;e=e||"-";let r=/([A-Z]{1,})/g;return t.replace(r,n=>e+n.toLowerCase()).toLowerCase()}};var Ht={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};S.augment({xhrSettings:Ht,addFixedParams(s){this.xhrSettings.fixedParams=s},beforeSend(s){this.xhrSettings.beforeSend.push(s)},ajaxSettings(s){typeof s=="object"&&(this.xhrSettings=m.extendClass(S.xhrSettings,s))},resetAjaxSettings(){this.xhrSettings=Ht}});var tt=(...s)=>new wt(s).xhr,wt=class{constructor(t){this.settings=null,this.xhr=null,this.setup(t)}setup(t){this.getXhrSettings(t);let e=this.xhr=this.createXHR();if(e===!1)return!1;let{method:r,url:n,async:i}=this.settings;e.open(r,n,i),this.setupHeaders(),this.addXhrEvents(),this.beforeSend(),e.send(this.getParams())}beforeSend(){let t=S.xhrSettings.beforeSend;if(t.length<1)return;let e=this.xhr,r=this.settings;for(var n=0,i=t.length;n<i;n++){var o=t[n];o&&o(e,r)}}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}setupParams(t,e){let r=typeof t;if(!e)return!(t instanceof FormData)&&r==="object"&&(t=this.objectToString(t)),t;let n=typeof e;if(r==="string")return n!=="string"&&(e=this.objectToString(e)),t+=(t===""?"?":"&")+e,t;if(n==="string"&&(e=x.parseQueryString(e,!1)),t instanceof FormData)for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.append(i,e[i]);else r==="object"&&(t=m.clone(t),t=Object.assign(e,t),t=this.objectToString(t));return t}getParams(){let t=this.settings,e=t.fixedParams,r=t.params;return r?r=this.setupParams(r,e):e&&(r=this.setupParams(e)),r}getXhrSettings(t){let e=this.settings=Object.create(S.xhrSettings);if(t.length>=2&&typeof t[0]!="object")for(var r=0,n=t.length;r<n;r++){var i=t[r];switch(r){case 0:e.url=i;break;case 1:e.params=i;break;case 2:e.completed=i,e.failed=i;break;case 3:e.responseType=i||"json";break;case 4:e.method=i?i.toUpperCase():"POST";break;case 5:e.async=typeof i<"u"?i:!0;break}}else e=this.settings=m.extendClass(this.settings,t[0]),typeof e.completed=="function"&&(typeof e.failed!="function"&&(e.failed=e.completed),typeof e.aborted!="function"&&(e.aborted=e.failed))}createXHR(){let t=this.settings,e=new XMLHttpRequest;return e.responseType=t.responseType,t.withCredentials===!0&&(e.withCredentials=!0),e}setupHeaders(){let t=this.settings;if(!t&&typeof t.headers!="object")return;let e=t.headers;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.xhr.setRequestHeader(r,e[r])}update(t,e){let r=this.xhr,n=()=>{d.removeEvents(r.upload),d.removeEvents(r)},i=this.settings;if(!i)return!1;switch(e||t.type){case"load":if(typeof i.completed=="function"){let a=this.getResponseData();i.completed(a,this.xhr)}n();break;case"error":typeof i.failed=="function"&&i.failed(!1,this.xhr),n();break;case"progress":typeof i.progress=="function"&&i.progress(t);break;case"abort":typeof i.aborted=="function"&&i.aborted(!1,this.xhr),n();break}}getResponseData(){let t=this.xhr,e=t.responseType;return!e||e==="text"?t.responseText:t.response}addXhrEvents(){if(!this.settings)return;let e=this.xhr,r=this.update.bind(this);d.on(["load","error","abort"],e,r),d.on("progress",e.upload,r)}};var p=class{static getById(t){return typeof t!="string"?!1:document.getElementById(t)||!1}static getByName(t){if(typeof t!="string")return!1;let e=document.getElementsByName(t);return e?C.toArray(e):!1}static getBySelector(t,e){if(typeof t!="string")return!1;if(e=e||!1,e===!0)return document.querySelector(t)||!1;let r=document.querySelectorAll(t);return r?r.length===1?r[0]:C.toArray(r):!1}static html(t,e){return u.isObject(t)===!1?!1:u.isUndefined(e)===!1?(t.innerHTML=e,this):t.innerHTML}static setCss(t,e,r){return u.isObject(t)===!1||u.isUndefined(e)?this:(e=x.uncamelCase(e),t.style[e]=r,this)}static getCss(t,e){if(!t||typeof e>"u")return!1;e=x.uncamelCase(e);let r=t.style[e];if(r!=="")return r;let n=null,i=t.currentStyle;if(i&&(n=i[e]))r=n;else{let o=window.getComputedStyle(t,null);o&&(r=o[e])}return r}static css(t,e,r){return typeof r<"u"?(this.setCss(t,e,r),this):this.getCss(t,e)}static removeAttr(t,e){return u.isObject(t)&&t.removeAttribute(e),this}static setAttr(t,e,r){t.setAttribute(e,r)}static getAttr(t,e){return t.getAttribute(e)}static attr(t,e,r){return u.isObject(t)===!1?!1:typeof r<"u"?(this.setAttr(t,e,r),this):this.getAttr(t,e)}static _checkDataPrefix(t){return typeof t!="string"||(t=x.uncamelCase(t),t.substring(0,5)!=="data-"&&(t="data-"+t)),t}static removeDataPrefix(t){return typeof t=="string"&&t.substring(0,5)==="data-"&&(t=t.substring(5)),t}static setData(t,e,r){e=this.removeDataPrefix(e),e=x.camelCase(e),t.dataset[e]=r}static getData(t,e){return e=x.camelCase(this.removeDataPrefix(e)),t.dataset[e]}static data(t,e,r){return u.isObject(t)===!1?!1:typeof r<"u"?(this.setData(t,e,r),this):this.getData(t,e)}static find(t,e){return!t||typeof e!="string"?!1:t.querySelectorAll(e)}static show(t){if(u.isObject(t)===!1)return this;let e=this.data(t,"style-display"),r=typeof e=="string"?e:"";return this.css(t,"display",r),this}static hide(t){if(u.isObject(t)===!1)return this;let e=this.css(t,"display");return e!=="none"&&e&&this.data(t,"style-display",e),this.css(t,"display","none"),this}static toggle(t){return u.isObject(t)===!1?this:(this.css(t,"display")!=="none"?this.hide(t):this.show(t),this)}static getSize(t){return u.isObject(t)===!1?!1:{width:this.getWidth(t),height:this.getHeight(t)}}static getWidth(t){return u.isObject(t)?t.offsetWidth:!1}static getHeight(t){return u.isObject(t)?t.offsetHeight:!1}static getScrollPosition(t){let e=0,r=0;switch(typeof t){case"undefined":t=document.documentElement,e=t.scrollLeft,r=t.scrollTop;break;case"object":e=t.scrollLeft,r=t.scrollTop;break}return u.isObject(t)===!1?!1:{left:e-(t.clientLeft||0),top:r-(t.clientTop||0)}}static getScrollTop(t){return this.getScrollPosition(t).top}static getScrollLeft(t){return this.getScrollPosition(t).left}static getWindowSize(){let t=window,e=document,r=e.documentElement,n=e.getElementsByTagName("body")[0],i=t.innerWidth||r.clientWidth||n.clientWidth,o=t.innerHeight||r.clientHeight||n.clientHeight;return{width:i,height:o}}static getDocumentSize(){let t=document,e=t.body,r=t.documentElement,n=Math.max(e.scrollHeight,e.offsetHeight,r.clientHeight,r.scrollHeight,r.offsetHeight);return{width:Math.max(e.scrollWidth,e.offsetWidth,r.clientWidth,r.scrollWidth,r.offsetWidth),height:n}}static getDocumentHeight(){return this.getDocumentSize().height}static position(t,e=1){let r={x:0,y:0};if(u.isObject(t)===!1)return r;let n=0;for(;t&&(e===0||n<e);)n++,r.x+=t.offsetLeft+t.clientLeft,r.y+=t.offsetTop+t.clientTop,t=t.offsetParent;return r}static addClass(t,e){if(u.isObject(t)===!1||e==="")return this;if(typeof e=="string"){let i=e.split(" ");for(var r=0,n=i.length;r<n;r++)t.classList.add(e)}return this}static removeClass(t,e){return u.isObject(t)===!1||e===""?this:(typeof e>"u"?t.className="":t.classList.remove(e),this)}static hasClass(t,e){return u.isObject(t)===!1||e===""?!1:t.classList.contains(e)}static toggleClass(t,e){return u.isObject(t)===!1?this:(t.classList.toggle(e),this)}};var et=class{constructor(){this.connections={}}add(t,e,r){let n=this.find(t);return n[e]=r}get(t,e){let r=this.connections[t];return r&&r[e]||!1}find(t){let e=this.connections;return e[t]||(e[t]={})}remove(t,e){let r=this.connections[t];if(!r)return!1;let n;if(e)n=r[e],n&&(n.unsubscribe(),delete r[e]),m.isEmpty(r)&&delete this.connections[t];else{for(var i in r)!Object.prototype.hasOwnProperty.call(r,i)||(n=r[i],n&&n.unsubscribe());delete this.connections[t]}}};var N=class{constructor(){this.msg=null,this.token=null}setToken(t){this.token=t}};var rt=class extends N{constructor(t){super(),this.data=t}subscribe(t,e){this.msg=t,this.token=this.data.on(t,e)}unsubscribe(){this.data.off(this.msg,this.token)}};var j=class{unsubscribe(){}};var st=class extends j{constructor(){super(),this.source=null}addSource(t){return this.source=new rt(t)}unsubscribe(){this.source.unsubscribe(),this.source=null}};var W=class extends N{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.off(this.msg,this.token)}callBack(){}};var nt=class extends W{constructor(t,e,r){super(r),this.data=t,this.prop=e}set(t){this.data.set(this.prop,t)}get(){return this.data.get(this.prop)}callBack(t,e){this.data!==e&&this.data.set(this.prop,t,e)}};var ke=(s,t,e)=>{p.setAttr(s,t,e)},Ce=(s,t,e)=>{s.checked=s.value==e},Ae=(s,t,e)=>{e=e==1,It(s,t,e)},It=(s,t,e)=>{s[t]=e},Te=(s,t)=>p.getAttr(s,t),Oe=(s,t)=>s[t],it=class extends W{constructor(t,e,r,n){super(n),this.element=t,this.attr=this.getAttrBind(e),this.addSetMethod(t,this.attr),this.filter=typeof r=="string"?this.setupFilter(r):r}addSetMethod(t,e){if(e.substring(4,1)==="-"){this.setValue=ke,this.getValue=Te;return}this.getValue=Oe;let r=t.type;if(r)switch(r){case"checkbox":this.setValue=Ae;return;case"radio":this.setValue=Ce;return}this.setValue=It}getAttrBind(t){if(t)return t;let e="textContent",r=this.element;if(!r||typeof r!="object")return e;let n=r.tagName.toLowerCase();if(n==="input"||n==="textarea"||n==="select"){let i=r.type;if(!i)return e="value",e;switch(i){case"checkbox":e="checked";break;case"file":e="files";break;default:e="value"}}return e}setupFilter(t){let e=/(\[\[[^\]]+\]\])/;return r=>t.replace(e,r)}set(t){let e=this.element;!e||typeof e!="object"||(this.filter&&(t=this.filter(t)),this.setValue(e,this.attr,t))}get(){let t=this.element;return!t||typeof t!="object"?"":this.getValue(t,this.attr)}callBack(t,e){e!==this.element&&this.set(t)}};var ot=class extends j{constructor(t){super(),this.element=null,this.data=null,this.pubSub=t}addElement(t,e,r){return this.element=new it(t,e,r,this.pubSub)}addData(t,e){return this.data=new nt(t,e,this.pubSub)}unsubscribeSource(t){t&&t.unsubscribe()}unsubscribe(){this.unsubscribeSource(this.element),this.unsubscribeSource(this.data),this.element=null,this.data=null}};var Ut=-1,_=class{constructor(){this.callBacks={},this.lastToken=-1}get(t){let e=this.callBacks;return e[t]||(e[t]=[])}reset(){this.callBacks={},this.lastToken=-1,Ut=-1}on(t,e){let r=++Ut;return this.get(t).push({token:r,callBack:e}),r}off(t,e){let r=this.callBacks[t];if(!r)return;let n=r.length;for(var i=0;i<n;i++){var o=r[i];if(o.token===e){r.splice(i,1);break}}}remove(t){let e=this.callBacks;e[t]&&delete e[t]}publish(t){let e=this.callBacks[t]||!1;if(e===!1)return;let r=Array.prototype.slice.call(arguments,1),n=e.length;for(var i=0;i<n;i++){var o=e[i];!o||o.callBack.apply(this,r)}}};var kt=class{constructor(){this.version="1.0.1",this.attr="bindId",this.blockedKeys=[20,37,38,39,40],this.connections=new et,this.pubSub=new _,this.idCount=0,this.setup()}setup(){this.setupEvents()}bind(t,e,r,n){let i=r,o=null;if(r.indexOf(":")!==-1){let f=r.split(":");f.length>1&&(i=f[1],o=f[0])}let a=this.setupConnection(t,e,i,o,n),c=a.element,h=e.get(i);return typeof h<"u"?c.set(h):(h=c.get(),h!==""&&a.data.set(h)),this}setupConnection(t,e,r,n,i){let o=this.getBindId(t),a=new ot(this.pubSub);a.addData(e,r).subscribe(o);let h=e.getDataId(),f=h+":"+r;return a.addElement(t,n,i).subscribe(f),this.addConnection(o,"bind",a),a}addConnection(t,e,r){this.connections.add(t,e,r)}setBindId(t){let e="db-"+this.idCount++;return t.dataset&&(t.dataset[this.attr]=e),t[this.attr]=e,e}getBindId(t){return t[this.attr]||this.setBindId(t)}unbind(t){let e=t[this.attr];return e&&this.connections.remove(e),this}watch(t,e,r,n){if(u.isObject(t)===!1)return;let i=new st;i.addSource(e).subscribe(r,n);let a=this.getBindId(t),c=e.getDataId()+":"+r;this.addConnection(a,c,i);let h=e.get(r);typeof h<"u"&&n(h)}unwatch(t,e,r){if(u.isObject(t)===!1)return;let n=t[this.attr];if(n){let i=e.getDataId()+":"+r;this.connections.remove(n,i)}}publish(t,e,r){return this.pubSub.publish(t,e,r),this}isDataBound(t){if(!t)return!1;let e=t[this.attr];return e||!1}isBlocked(t){return t.type!=="keyup"?!1:this.blockedKeys.indexOf(t.keyCode)!==-1}bindHandler(t){if(this.isBlocked(t))return!0;let e=t.target||t.srcElement,r=this.isDataBound(e);if(r){let n=this.connections.get(r,"bind");if(n){let i=n.element.get();this.pubSub.publish(r,i,e)}}t.stopPropagation()}setupEvents(){this.changeHandler=this.bindHandler.bind(this),this.addEvents()}addEvents(){d.on(["change","paste","input"],document,this.changeHandler,!1)}removeEvents(){d.off(["change","paste","input"],document,this.changeHandler,!1)}},g=new kt;var Mt=/(\[\[(.*?(?:\[\d+\])?)\]\])/g,E={isWatching(s){return Array.isArray(s)?typeof s[0]!="string"?!1:!!this.hasParams(s[0]):this.hasParams(s)},hasParams(s){return!s||u.isString(s)===!1?!1:s.indexOf("[[")!==-1},_getWatcherProps(s){let t=/\[\[(.*?)(\[\d+\])?\]\]/g,e=s.match(t);if(e){t=/(\[\[|\]\])/g;for(var r=0,n=e.length;r<n;r++)e[r]=e[r].replace(t,"")}return e},updateAttr(s,t,e){t==="text"||t==="textContent"?s.textContent=e:t==="innerHTML"?s.innerHTML=e:t.substring(4,1)==="-"?p.setAttr(s,t,e):s[t]=e},_getWatcherCallBack(s,t,e,r,n){return()=>{let i=0,o=e.replace(Mt,function(){let a=n?t[i]:t;i++;let c=a.get(arguments[2]);return typeof c<"u"?c:""});this.updateAttr(s,r,o)}},getParentData(s){return s.data?s.data:s.context&&s.context.data?s.context.data:s.state?s.state:null},getValue(s,t){typeof s=="string"&&(s={value:s});let e=s.value;return Array.isArray(e)===!1?[e,this.getParentData(t)]:(e.length<2&&e.push(this.getParentData(t)),e)},getPropValues(s,t,e){let r=[];for(var n=0,i=t.length;n<i;n++){var o=e?s[n]:s,a=o.get(t[n]);a=typeof a<"u"?a:"",r.push(a)}return r},getCallBack(s,t,e,r,n){let i,o=s.callBack;if(typeof o=="function"){let a=r.match(Mt),c=a&&a.length>1;i=(h,f)=>{h=c!==!0?h:this.getPropValues(e,a,n),o(h,t,f)}}else{let a=s.attr||"textContent";i=this._getWatcherCallBack(t,e,r,a,n)}return i},addDataWatcher(s,t,e){let r=this.getValue(t,e),n=r[1];if(!n)return;let i=r[0],o=Array.isArray(n),a=this.getCallBack(t,s,n,i,o),c=this._getWatcherProps(i);for(var h=0,f=c.length;h<f;h++){var k=o?n[h]:n;this.addWatcher(s,k,c[h],a)}},setup(s,t,e){if(!!t){if(Array.isArray(t)){let r=[t[0],t[1]],n=t[2];typeof n=="function"?t={value:r,callBack:n}:t={attr:n,value:[t[0],t[1]]}}this.addDataWatcher(s,t,e)}},addWatcher(s,t,e,r){g.watch(s,t,e,r)}};var De=s=>typeof s!="string"?s:Nt(s),Nt=s=>[{tag:"text",textContent:s}],Pe=s=>{if(!s)return{props:{},children:[]};let t=s[0];return typeof t=="string"?{props:{},children:Nt(t)}:Array.isArray(t)?E.isWatching(t)===!1?{props:{},children:t}:{props:{watch:t},children:[]}:{props:t||{},children:De(s[1])}},Ee=s=>(...t)=>{let{props:e,children:r}=Pe(t);return s(e,r)};var at=s=>{let t={};if(!s||typeof s!="object")return t;s=m.clone(s);for(var e in s)if(!!Object.prototype.hasOwnProperty.call(s,e)){var r=s[e];typeof r!="function"&&(t[e]=r,delete s[e])}return t};function jt(s,t){return s===""?(s=t,isNaN(s)?s:`[${t}]`):isNaN(t)?`${s}.${t}`:`${s}[${t}]`}function Wt(s,t="",e=""){return{get(r,n,i){if(t===""&&n in r)return r[n];let o=r[e]||r,a=Reflect.get(o,n,i);if(!u.isObject(a))return a;let c=jt(t,n);return new Proxy(a,Wt(s,c,e))},set(r,n,i,o){if(t===""&&n in r)return r[n]=i,!0;let a=r[e]||r,c=jt(t,n);return s.set(c,i),Reflect.set(a,n,i,o)}}}var Vt=(s,t="stage")=>new Proxy(s,Wt(s,"",t));var Be=0,H=class{constructor(t){this.dirty=!1,this.links={},this._init(),this.setup(),this.dataTypeId="bd",this.eventSub=new _;let e=at(t);return this.set(e),Vt(this)}setup(){this.stage={}}_init(){let t=++Be;this._dataNumber=t,this._id="dt-"+t,this._dataId=this._id+":"}getDataId(){return this._id}remove(){}on(t,e){let r=t+":change";return this.eventSub.on(r,e)}off(t,e){let r=t+":change";this.eventSub.off(r,e)}_setAttr(t,e,r=this){let n=this.stage[t];if(e===n)return!1;this.stage[t]=e,this._publish(t,e,r,n)}set(...t){if(typeof t[0]!="object")return this._setAttr(...t),this;let[e,r,n]=t;for(var i in e)if(!!Object.prototype.hasOwnProperty.call(e,i)){var o=e[i];typeof o!="function"&&this._setAttr(i,o,r,n)}return this}getModelData(){return this.stage}_deleteAttr(t,e){delete t[e]}toggle(t){if(!(typeof t>"u"))return this.set(t,!this.get(t)),this}increment(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,++e),this}decrement(t){if(typeof t>"u")return;let e=this.get(t);return this.set(t,--e),this}concat(t,e){if(typeof t>"u")return;let r=this.get(t);return this.set(t,r+e),this}ifNull(t,e){return this.get(t)===null&&this.set(t,e),this}setKey(t){return this.key=t,this}resume(t){let e=this.key;if(!e)return this;let r,n=localStorage.getItem(e);return n===null?t&&(r=t):r=JSON.parse(n),r?(this.set(r),this):this}store(){let t=this.key;if(!t)return!1;let e=this.get();if(!e)return!1;let r=JSON.stringify(e);return localStorage.setItem(t,r),!0}delete(t){if(typeof t<"u"){this._deleteAttr(this.stage,t);return}this.setup()}_getAttr(t,e){return t[e]}get(t){return typeof t<"u"?this._getAttr(this.stage,t):this.getModelData()}link(t,e,r){if(arguments.length===1&&t.isData===!0&&(e=t.get()),typeof e!="object")return this.remoteLink(t,e,r);let n=[];for(var i in e)!Object.prototype.hasOwnProperty.call(e,i)||n.push(this.remoteLink(t,i));return n}remoteLink(t,e,r){let n=r||e,i=t.get(e);typeof i<"u"&&this.get(e)!==i&&this.set(e,i);let o=t.on(e,(c,h)=>{if(h===this)return!1;this.set(n,c,t)});this.addLink(o,t);let a=this.on(n,(c,h)=>{if(h===t)return!1;t.set(e,c,this)});return t.addLink(a,this),o}addLink(t,e){this.links[t]=e}unlink(t){if(t){this.removeLink(t);return}let e=this.links;if(e.length){for(var r=0,n=e.length;r<n;r++)this.removeLink(e[r],!1);this.links=[]}}removeLink(t,e){let r=this.links[t];r&&r.off(t),e!==!1&&delete this.links[t]}};H.prototype.isData=!0;var A={deepDataPattern:/(\w+)|(?:\[(\d)\))/g,hasDeepData(s){return s.indexOf(".")!==-1||s.indexOf("[")!==-1},getSegments(s){let t=this.deepDataPattern;return s.match(t)}};var T=class extends H{setup(){this.attributes={},this.stage={}}_updateAttr(t,e,r){if(!A.hasDeepData(e)){t[e]=r;return}let n,i=A.getSegments(e),o=i.length,a=o-1;for(var c=0;c<o;c++){if(n=i[c],c===a){t[n]=r;break}t[n]===void 0&&(t[n]=isNaN(n)?{}:[]),t=t[n]}}_setAttr(t,e,r,n){typeof e!="object"&&e===this.get(t)||(!r&&n!==!0?this._updateAttr(this.attributes,t,e):this.dirty===!1&&(this.dirty=!0),this._updateAttr(this.stage,t,e),r=r||this,this._publish(t,e,r))}linkAttr(t,e){let r=t.get(e);if(!!r)for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&this.link(t,e+"."+n,n)}scope(t,e){let r=this.get(t);if(!r)return!1;e=e||this.constructor;let n=new e(r);return n.linkAttr(this,t),n}splice(t,e){return this.delete(t+"["+e+"]"),this.refresh(t),this}push(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.push(e),this.set(t,r),this}unshift(t,e){let r=this.get(t);return Array.isArray(r)===!1&&(r=[]),r.unshift(e),this.set(t,r),this}shift(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.shift();return this.set(t,e),r}pop(t){let e=this.get(t);if(Array.isArray(e)===!1)return null;let r=e.pop();return this.set(t,e),r}refresh(t){return this.set(t,this.get(t)),this}_publish(t,e,r){this.publish(t,e,r)}publishDeep(t,e,r){if(!A.hasDeepData(t)){this.publish(t,e,r);return}let n,i=A.getSegments(t),o=i.length,a=o-1,c="",h=this.stage;for(var f=0;f<o;f++){n=i[f],h=h[n],f>0?isNaN(n)&&(c+="."+n):c=n;var k;if(f===a)k=e;else{var P=i[f+1];if(isNaN(P)===!1){c+="["+P+"]";continue}var R={};R[P]=h[P],k=R}this.publish(c,k,r)}}publish(t,e,r){if(t=t||"",this._publishAttr(t,e,r),!e||typeof e!="object")return;let n,i;if(Array.isArray(e)){let c=e.length;for(var o=0;o<c;o++)i=e[o],n=t+"["+o+"]",this._checkPublish(n,i,r)}else for(var a in e)!Object.prototype.hasOwnProperty.call(e,a)||(i=e[a],n=t+"."+a,this._checkPublish(n,i,r))}_checkPublish(t,e,r){!e||typeof e!="object"?this._publishAttr(t,e,r):this.publish(t,e,r)}_publishAttr(t,e,r){g.publish(this._dataId+t,e,r);let n=t+":change";this.eventSub.publish(n,e,r)}mergeStage(){this.attributes=m.clone(this.stage),this.dirty=!1}getModelData(){return this.mergeStage(),this.attributes}revert(){this.set(this.attributes),this.dirty=!1}_deleteAttr(t,e){A.hasDeepData(e)||delete t[e];let r=A.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a];if(c===void 0)break;if(o===i){if(Array.isArray(t)){t.splice(a,1);break}delete t[a];break}t=c}}_getAttr(t,e){if(!A.hasDeepData(e))return t[e];let r=A.getSegments(e),n=r.length,i=n-1;for(var o=0;o<n;o++){var a=r[o],c=t[a];if(c===void 0)break;if(t=c,o===i)return t}}};var Re=(s,t)=>{if(typeof s!="string"&&(s=String(s)),t){let r=/(\n|\r\n)/g;s=s.replace(r,"\\n")}let e=/\t/g;return s.replace(e,"\\t")},Ft=(s,t)=>{if(typeof s!="string")return s;s=Re(s,t),s=encodeURIComponent(s);let e=/%22/g;return s.replace(e,'"')},Ct=(s,t)=>{let e=typeof s;if(e==="undefined")return s;if(e!=="object")return s=Ft(s),s;let r;for(var n in s)!Object.prototype.hasOwnProperty.call(s,n)||(r=s[n],r!==null&&(s[n]=typeof r=="string"?Ct(r,t):Ft(r,t)));return s};function Jt(s){return typeof s<"u"&&s.length>0?JSON.parse(s):!1}function At(s){return typeof s<"u"?JSON.stringify(s):!1}var G=class{static prepareJsonUrl(t,e=!1){let r=typeof t=="object"?m.clone(t):t,n=Ct(r,e);return At(n)}static xmlParse(t){return typeof t>"u"?!1:new DOMParser().parseFromString(t,"text/xml")}};L(G,"json",{encode:At,decode:Jt});var ct=class{constructor(t){this.model=t,this.objectType=this.objectType||"item",this.url="",this.validateCallBack=null,this.init()}init(){let t=this.model;t&&t.url&&(this.url=t.url)}isValid(){let t=this.validate();if(t!==!1){let e=this.validateCallBack;typeof e=="function"&&e(t)}return t}validate(){return!0}getDefaultParams(){return""}setupParams(t){let e=this.getDefaultParams();return t=this.addParams(t,e),t}objectToString(t){let e=[];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.push(r+"="+encodeURIComponent(t[r]));return e.join("&")}addParams(t,e){if(t=t||{},typeof t=="string"&&(t=x.parseQueryString(t,!1)),!e)return this._isFormData(t)?t:this.objectToString(t);if(typeof e=="string"&&(e=x.parseQueryString(e,!1)),this._isFormData(t))for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.append(r,e[r]);else t=Object.assign(t,e),t=this.objectToString(t);return t}get(t,e){let r=this.model.get("id"),n="op=get&id="+r,i=this.model;return this._get("",n,t,e,o=>{if(o){let a=this.getObject(o);a&&i.set(a)}})}getObject(t){return t[this.objectType]||t||!1}setupObjectData(){let t=this.model.get();return this.objectType+"="+G.prepareJsonUrl(t)}setup(t,e){if(!this.isValid())return!1;let r="op=setup&"+this.setupObjectData();return this._put("",r,t,e)}add(t,e){if(!this.isValid())return!1;let r="op=add&"+this.setupObjectData();return this._post("",r,t,e)}update(t,e){if(!this.isValid())return!1;let r="op=update&"+this.setupObjectData();return this._patch("",r,t,e)}delete(t,e){let r=this.model.get("id"),n="op=delete&id="+r;return this._delete("",n,t,e)}all(t,e,r,n,i){i=i||"",r=isNaN(r)?0:r,n=isNaN(n)?50:n;let o="op=all&option="+i+"&start="+r+"&stop="+n;return this._get("",o,t,e)}getUrl(t){let e=this.url;return t?t[0]==="?"?e+t:e+="/"+t:e}setupRequest(t,e,r,n,i){let o={url:this.getUrl(t),method:e,params:r,completed:(c,h)=>{typeof i=="function"&&i(c),this.getResponse(c,n,h)}};return this._isFormData(r)&&(o.headers={}),tt(o)}_isFormData(t){return t instanceof FormData}request(t,e,r,n){return this._request("","POST",t,e,r,n)}_get(t,e,r,n,i){return e=this.setupParams(e),e=this.addParams(e,r),t=t||"",e&&(t+="?"+e),this.setupRequest(t,"GET","",n,i)}_post(t,e,r,n,i){return this._request(t,"POST",e,r,n,i)}_put(t,e,r,n,i){return this._request(t,"PUT",e,r,n,i)}_patch(t,e,r,n,i){return this._request(t,"PATCH",e,r,n,i)}_delete(t,e,r,n,i){return this._request(t,"DELETE",e,r,n,i)}_request(t,e,r,n,i,o){return r=this.setupParams(r),r=this.addParams(r,n),this.setupRequest(t,e,r,i,o)}getResponse(t,e,r){typeof e=="function"&&e(t,r)}static extend(t){if(!t)return!1;let e=this;class r extends e{constructor(i){super(i)}}return Object.assign(r.prototype,t),r}};var Le=s=>{let t={};if(!s||typeof s!="object")return t;let e=s.defaults;if(!e)return t;for(var r in e)if(!!Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];typeof n!="function"&&(t[r]=n)}return delete s.defaults,t},_e=s=>{if(!s||typeof s.xhr!="object")return{};let t=s.xhr,e=Object.assign({},t);return delete s.xhr,e},He=0,V=class extends T{constructor(t){let e=super(t);return this.initialize(),e}initialize(){}static extend(t={}){let e=this,r=_e(t),n=this.prototype.service.extend(r),i=Le(t);class o extends e{constructor(c){let h=at(c);h=Object.assign({},i,h),super(h),this.xhr=new n(this)}dataTypeId="bm"+He++}return Object.assign(o.prototype,t),o.prototype.service=n,o}};V.prototype.service=ct;var O=class extends H{_publish(t,e,r,n){let i=t+":change";this.eventSub.publish(i,e,r),r=r||this,g.publish(this._dataId+t,e,r)}};var ht=class extends O{constructor(t){super(),this.id=t}addAction(t,e){typeof e<"u"&&this.set(t,e)}getState(t){return this.get(t)}removeAction(t,e){if(e){this.off(t,e);return}let r=this.stage;typeof r[t]<"u"&&delete r[t]}};var b=class{static restore(t,e){this.targets[t]=e}static getTarget(t){let e=this.targets;return e[t]||(e[t]=new ht(t))}static getActionState(t,e){return this.getTarget(t).get(e)}static add(t,e,r){let n=this.getTarget(t);return e&&n.addAction(e,r),n}static addAction(t,e,r){return this.add(t,e,r)}static removeAction(t,e,r){this.off(t,e,r)}static on(t,e,r){let n=this.getTarget(t);return e?n.on(e,r):!1}static off(t,e,r){this.remove(t,e,r)}static remove(t,e,r){let n=this.targets,i=n[t];if(!!i){if(e){i.off(e,r);return}delete n[t]}}static set(t,e,r){this.getTarget(t).set(e,r)}};L(b,"targets",{});var ut=class{constructor(){this.events=[]}addEvents(t){let e=t.length;if(e<1)return!1;let r;for(var n=0;n<e;n++)r=t[n],this.on(...r)}on(t,e,r,n){d.on(t,e,r,n),this.events.push({event:t,obj:e,callBack:r,capture:n})}off(t,e,r,n){d.off(t,e,r,n);let i,o=this.events;for(var a=0,c=o.length;a<c;a++)if(i=o[a],i.event===t&&i.obj===e){o.splice(a,1);break}}set(){let t,e=this.events;for(var r=0,n=e.length;r<n;r++)t=e[r],d.on(t.event,t.obj,t.callBack,t.capture)}unset(){let t,e=this.events;for(var r=0,n=e.length;r<n;r++)t=e[r],d.off(t.event,t.obj,t.callBack,t.capture)}reset(){this.unset(),this.events=[]}};var ft=class{constructor(t,e){this.remoteStates=[];let r=this.convertStates(e);this.addStatesToTarget(t,r)}addStates(t,e){let r=this.convertStates(e);this.addStatesToTarget(t,r)}createState(t,e,r,n){return{action:t,state:e,callBack:r,targetId:n,token:null}}convertStates(t){let e=[];for(var r in t)if(!!Object.prototype.hasOwnProperty.call(t,r)){if(r==="remotes"){this.setupRemoteStates(t[r],e);continue}var n=null,i=null,o=t[r];o&&typeof o=="object"&&(i=o.callBack,n=o.id||o.targetId,o=o.state),e.push(this.createState(r,o,i,n))}return e}setupRemoteStates(t,e){let r;for(var n=0,i=t.length;n<i;n++)if(r=t[n],!!r){for(var o in r)if(!(!Object.prototype.hasOwnProperty.call(r,o)||o==="id")){var a=null,c=r[o],h=c!==null?c:void 0;h&&typeof h=="object"&&(a=h.callBack,h=h.state),e.push(this.createState(o,h,a,r.id))}}}removeRemoteStates(){let t=this.remoteStates;t&&this.removeActions(t)}removeActions(t){if(!(t.length<1))for(var e=0,r=t.length;e<r;e++){var n=t[e];b.remove(n.targetId,n.action,n.token)}}restore(t){b.restore();let e=this.remoteStates;if(!!e)for(var r=0,n=e.length;r<n;r++){var i=e[r];i.token=this.bindRemoteState(t,i.action,i.targetId)}}bindRemoteState(t,e,r){let n=b.getTarget(r);return t.link(n,e)}addStatesToTarget(t,e){let r=this.remoteStates;for(var n=0,i=e.length;n<i;n++){var o=e[n],a=this.addAction(t,o);o.targetId&&(o.token=a,r.push(o))}r.length<1&&(this.remoteStates=null)}addAction(t,e){let r,n=e.action,i=e.targetId;i&&(r=this.bindRemoteState(t,n,i)),typeof e.state<"u"&&t.addAction(n,e.state);let o=e.callBack;return typeof o=="function"&&t.on(n,o),r}};var Ie={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"},Q=s=>Ie[s]||s,Tt=s=>typeof s=="string"&&s.substring(0,2)==="on"?s.substring(2):s,y=class{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e),n===!0?this.prepend(r,i):this.append(r,i),i}static addAttributes(t,e){if(!e||typeof e!="object")return!1;let r=e.type;typeof r<"u"&&p.setAttr(t,"type",r);for(var n in e)if(!(!Object.prototype.hasOwnProperty.call(e,n)||n==="type")){var i=e[n];n==="innerHTML"?t.innerHTML=i:n.indexOf("-")!==-1?p.setAttr(t,n,i):this.addAttr(t,n,i)}}static addHtml(t,e){return typeof e>"u"||e===""?this:(/(?:<[a-z][\s\S]*>)/i.test(e)?t.innerHTML=e:t.textContent=e,this)}static addAttr(t,e,r){if(r===""||!e)return;if(typeof r==="function")e=Tt(e),d.add(e,t,r);else{let i=Q(e);t[i]=r}}static createDocFragment(){return document.createDocumentFragment()}static createText(t,e){let r=document.createTextNode(t);return e&&this.append(e,r),r}static createComment(t,e){let r=document.createComment(t);return e&&this.append(e,r),r}static setupSelectOptions(t,e,r){if(!t||typeof t!="object"||!e||!e.length)return!1;for(var n=0,i=e.length;n<i;n++){var o=e[n],a=t.options[n]=new Option(o.label,o.value);r!==null&&a.value==r&&(a.selected=!0)}}static removeElementData(t){let e=t.childNodes;if(e){let o=e.length-1;for(var r=o;r>=0;r--){var n=e[r];!n||this.removeElementData(n)}}l.remove(t),t.bindId&&g.unbind(t)}static removeElement(t){let e;return!t||!(e=t.parentNode)?this:(this.removeElementData(t),e.removeChild(t),this)}static removeChild(t){return this.removeElement(t),this}static removeAll(t){if(typeof t!="object")return this;let e=t.childNodes;for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&this.removeElementData(e[r]);return t.innerHTML="",this}static changeParent(t,e){return e.appendChild(t),this}static append(t,e){return t.appendChild(e),this}static prepend(t,e,r){let n=r||t.firstChild;return t.insertBefore(e,n),this}static clone(t,e=!1){return!t||typeof t!="object"?!1:t.cloneNode(e)}};var Ue=s=>typeof s!="string"?s:zt(s),zt=s=>[{tag:"text",textContent:s}],qt=s=>{if(!s)return{props:{},children:[]};let t=s[0];return typeof t=="string"?{props:{},children:zt(t)}:Array.isArray(t)?{props:{},children:t}:{props:t||{},children:Ue(s[1])}};l.addType("components",s=>{if(!s)return;let t=s.component;t&&t.rendered===!0&&t.prepareDestroy()});var Me=0,I=class{constructor(...t){this.isUnit=!0,this.init();let{props:e,children:r}=qt(t);this.setupProps(e),this.children??=r,this.onCreated(),this.rendered=!1,this.container=null}init(){this.id="cp-"+Me++}setupProps(t){if(!(!t||typeof t!="object"))for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(this[e]=t[e])}getParentContext(){return this.parent?this.parent.getContext():null}setupContext(){let t=this.getParentContext(),e=this.setContext(t);if(e){this.context=e;return}this.context=t,this.setupAddingContext()}setupAddingContext(){let t=this.context,e=this.addContext(t);if(!e)return;let r=e[0];!r||(this.addingContext=!0,this.contextBranchName=r,this.addContextBranch(r,e[1]))}addContextBranch(t,e){this.context=this.context||{},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.persist?this._layout||(this._layout=this.render()):this.render()}prepareLayout(){let t=this._createLayout();return this._cacheRoot(t)}afterBuild(){l.add(this.panel,"components",{component:this}),this.rendered=!0,this.afterLayout()}afterLayout(){this.afterSetup()}if(t,e){return t?e||t:null}map(t,e){let r=[];if(!t||t.length<1)return r;for(var n=0,i=t.length;n<i;n++){let o=e(t[n],n);r.push(o)}return r}removeAll(t){return y.removeAll(t)}getId(t){let e=this.id;return typeof t=="string"&&(e+="-"+t),e}initialize(){this.setupContext(),this.beforeSetup()}beforeSetup(){}afterSetup(){}setup(t){this.container=t,this.initialize()}remove(){this.prepareDestroy(),this.removeContext();let t=this.panel||this.id;y.removeElement(t)}prepareDestroy(){this.rendered=!1,this.beforeDestroy()}beforeDestroy(){}destroy(){this.remove()}};var B=class extends I{constructor(...t){super(...t),this.isComponent=!0,this.stateTargetId=null}initialize(){this.setupContext(),this.addStates(),this.beforeSetup()}afterLayout(){this.addEvents(),this.afterSetup()}setupStateTarget(t){let e=t||this.stateTargetId||this.id;this.state=b.getTarget(e)}setupStates(){return{}}addStates(){let t=this.state;if(t){this.stateHelper.restore(t);return}let e=this.setupStates();m.isEmpty(e)||(this.setupStateTarget(),this.stateHelper=new ft(this.state,e))}removeStates(){if(!this.state)return!1;this.stateHelper.removeRemoteStates(),b.remove()}setupEventHelper(){this.events||(this.events=new ut)}setupEvents(){return[]}addEvents(){let t=this.setupEvents();if(t.length<1)return!1;this.setupEventHelper(),this.events.addEvents(t)}removeEvents(){let t=this.events;t&&t.reset()}prepareDestroy(){this.rendered=!1,this.beforeDestroy(),this.removeEvents(),this.removeStates(),this.removeContext(),this.data&&this.persist===!1&&this.data.unlink()}};var Ne={created:"onCreated",state:"setupStates",events:"setupEevents",before:"beforeSetup",render:"render",after:"afterSetup",destroy:"beforeDestroy"},je=s=>typeof s==="function"?s:function(){return s},We=s=>{let t={};if(!s)return t;for(var e in s){if(!Object.prototype.hasOwnProperty.call(s,e))continue;let r=s[e],n=Ne[e];if(n){t[n]=je(r);continue}t[e]=r}return t},Ve=s=>{class t extends B{}return Object.assign(t.prototype,s),t},Xt=s=>{class t extends I{}return Object.assign(t.prototype,s),t},U=function(s){if(!s)return null;let t;switch(typeof s){case"object":return s.render?(t=We(s),Ve(t)):(t={render(){return s}},Xt(t));case"function":return t={render:s},Xt(t)}};var $t=(s,t)=>({name:s,callBack:t});var F={keys:[],items:{},add(s,t){return this.keys.push(s),this.items[s]=$t(s,t),this},get(s){return this.items[s]||null},all(){return this.keys}};var Ot=(s,t)=>({attr:s,directive:t});var J=(s,t)=>({key:s,value:t});var Kt=(s,t,e,r)=>({tag:s,attr:t,directives:e,children:r});var lt=class{static getTag(t){let e="div",r=t.tag;return typeof r<"u"&&(e=r),e}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(J("innerHTML",e)),!0):!1}static setTextAsWatcher(t,e,r){r={attr:Q(e),value:r},t.push(Ot(J(e,r),F.get("watch")))}static setButtonType(t,e,r){if(t==="button"){let n=e.type||"button";r.push(J("type",n))}}static parse(t,e){let r=[],n=[],i=this.getTag(t);this.setButtonType(i,t,r),this.setupChildren(t);let o=[];var a,c;for(var h in t){if(!Object.prototype.hasOwnProperty.call(t,h)||h==="tag"||(a=t[h],a==null))continue;if((c=F.get(h))!==null){n.push(Ot(J(h,a),c));continue}let f=typeof a;if(f==="object"){if(h==="children"){o=o.concat(a);continue}if(E.isWatching(a)){this.setTextAsWatcher(n,h,a);continue}o.push(a);continue}if(f==="function"){let P=a;a=function(R){P.call(this,R,e)}}if(E.isWatching(a)){this.setTextAsWatcher(n,h,a);continue}this.setElementContent(h,a,r,o)||r.push(J(h,a))}return Kt(i,r,n,o)}};var D=class extends y{static create(t,e,r,n){let i=document.createElement(t);return this.addAttributes(i,e,n),r.appendChild(i),i}static addAttributes(t,e,r){let n;if(!(!e||(n=e.length)<1))for(var i=0;i<n;i++){var o=e[i],a=o.key,c=o.value;if(a==="innerHTML"){t.innerHTML=c;continue}if(a.substr(4,1)==="-"){p.setAttr(t,a,c);continue}this.addAttr(t,a,c,r)}}static addAttr(t,e,r,n){if(r===""||!e)return!1;if(typeof r==="function")e=Tt(e),d.add(e,t,function(o){r.call(this,o,n)});else{let o=Q(e);t[o]=r}}static addContent(t,e){!e||(e.textContent!==null?t.textContent=e.textContent:e.innerHTML&&(t.innerHTML=e.innerHTML))}static append(t,e){t.appendChild(e)}};var z=class{createNode(t,e,r){}};var dt=class extends z{createNode(t,e,r){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:"";return D.createText(o,e)}else if(n==="comment"){let i=t.attr[0],o=i?i.value:"";return D.createComment(o,e)}return D.create(n,t.attr,e,r)}};var pt=class extends z{createNode(t,e,r){let n=t.tag;if(n==="text"){let i=t.attr[0],o=i?i.value:""}else if(n==="comment"){let i=t.attr[0],o=i?i.value:""}}};var mt=class{static browserIsSupported(){return window}static setup(){return this.browserIsSupported()?new dt:new pt}};var Fe=mt.setup(),v=class{static render(t,e,r){if(!t)return;let n,i;switch(typeof t){case"object":if(t.isUnit===!0)return this.createComponent(t,e,r),t;default:return n=U(t),i=new n,this.createComponent(i,e,r),i}}static build(t,e,r){let n=D.createDocFragment();if(Array.isArray(t))for(var 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}static rebuild(t,e,r){return D.removeAll(e),this.build(t,e,r)}static buildElement(t,e,r){if(!!t){if(t.isUnit===!0){this.createComponent(t,e,r);return}this.createElement(t,e,r)}}static createElement(t,e,r){let n=lt.parse(t,r),i=this.createNode(n,e,r);this.cache(i,t.cache,r);let o=n.children;if(o.length>0){let f;for(var a=0,c=o.length;a<c;a++)f=o[a],f!==null&&this.buildElement(f,i,r)}let h=n.directives;h&&h.length&&this.setDirectives(i,h,r)}static setDirectives(t,e,r){for(var n=0,i=e.length;n<i;n++)this.handleDirective(t,e[n],r)}static handleDirective(t,e,r){e.directive.callBack(t,e.attr.value,r)}static cache(t,e,r){r&&e&&(r[e]=t)}static createComponent(t,e,r){let n=t;n.parent=r,r&&r.persist===!0&&n.persist!==!1&&(n.persist=!0),n.cache&&r&&(r[n.cache]=n),n.setup(e);let i=n.prepareLayout();this.build(i,n.container,n),n.afterBuild(),t.component&&typeof t.onCreated=="function"&&t.onCreated(n)}static createNode(t,e,r){return Fe.createNode(t,e,r)}};S.augment({buildLayout(s,t,e){v.build(s,t,e)}});var Gt=(s,t,e)=>{!t||t&&p.setAttr(s,"role",t)},Je=s=>(t,e)=>{let r=e?"true":"false";p.setAttr(t,s,r)},Qt=(s,t,e)=>{if(!t)return;let r=t.role;r&&(p.setAttr(s,"role",r),t.role=null);for(var n in t)if(!(!Object.prototype.hasOwnProperty.call(t,n)||t[n]===null)){var i=t[n],o="aria-"+n;Array.isArray(i)?(i.push(Je(o)),(void 0).onSet(s,i,e)):p.setAttr(s,o,i)}};l.addType("context",s=>{if(!s)return!1;s.parent.removeContextBranch(s.branch)});var Dt=s=>s?s.getContext():null,Yt=(s,t,e)=>{if(typeof t!="function")return;let r=Dt(e),n=t(r);!n||((void 0)._addElementAttrs(s,n,e),(void 0).addElementDirectives(s,n,e))},Zt=(s,t,e)=>{if(typeof t!="function")return;let r=Dt(e);t(r)},te=(s,t,e)=>{if(typeof t!="function"||!e)return;let r=Dt(e),n=t(r);!n||e.addContextBranch(n[0],n[1])};var ee=(s,t,e)=>{!t||!e||(e[t]=s)},re=(s,t,e)=>{if(!t||!e)return!1;t(e,s)},se=(s,t,e)=>{if(!t||!e)return!1;t(e.data,s)},ne=(s,t,e)=>{if(!t||!e)return!1;t(e.state,s)},ie=(s,t,e)=>{if(!t||!e)return!1;if(e.stateHelper){let r=e.state,n=t(r);e.stateHelper.addStates(n)}};var M=s=>s.data?s.data:s.context&&s.context.data?s.context.data:null;var oe=(s,t,e)=>{let r,n,i;if(typeof t=="string"){if(r=M(e),!r)return!1;n=t}else if(Array.isArray(t)){if(typeof t[0]!="object"){let o=M(e);if(o)t.unshift(o);else return!1}[r,n,i]=t}g.bind(s,r,n,i)};var ae=(s,t,e)=>{let r,n,i,o;if(t.length<3){let c=M(e);if(!c)return;r=c,n=t[0],i=t[1],o=t[2]}else r=t[0],n=t[1],i=t[2],o=t[3];let a=o!==!1;g.watch(s,r,n,c=>{if(y.removeAll(s),!c||c.length<1)return;let h=[];for(var f=0,k=c.length;f<k;f++){var P=a?r.scope(n+"["+f+"]"):null,R=i(c[f],f,P);R!==null&&h.push(R)}return(void 0).build(h,s,e)})};var ce=(s,t,e)=>{let r=t[0];if(!r||r.length<1)return;let n=t[1],i=[];for(var o=0,a=r.length;o<a;o++){var c=r[o];if(!!c){var h=n(c,o);h!==null&&i.push(h)}}return v.build(i,s,e)};var he=(s,t,e)=>{t(s)};l.addType("destroyed",s=>{if(!s)return!1;s.callBack(s.ele)});var ue=(s,t,e)=>{ze(s,t)},ze=(s,t)=>{l.add(s,"destroyed",{ele:s,callBack:t})};var Y=(s,t,e,r)=>{let n,i,o;if(Array.isArray(e[0])){for(var a=0,c=e.length;a<c;a++){var h=e[a];!h||Y(s,t,h,r)}return}if(e.length<3?[n,i]=e:[t,n,i]=e,!t||!n)return!1;switch(typeof i){case"object":o=f=>{$e(s,i,f)};break;case"function":o=f=>{qe(s,i,n,f,r)};break}g.watch(s,t,n,o)},qe=(s,t,e,r,n)=>{let i=t(r,s,n);switch(typeof i){case"object":if(n&&i&&i.isUnit===!0&&n.persist===!0&&n.state){let o=e+":"+r,a=n.state,c=a.get(o);typeof c<"u"&&(i=c),a.set(o,i)}Xe(i,s,n);break;case"string":y.addHtml(s,i);break}},Xe=(s,t,e)=>{v.rebuild(s,t,e)},$e=(s,t,e)=>{for(var r in t)!Object.prototype.hasOwnProperty.call(t,r)||!r||(t[r]===e?p.addClass(s,r):p.removeClass(s,r))};var fe=(s,t,e)=>{let r=M(e);Y(s,r,t,e)};var le=(s,t,e)=>{Y(s,e.state,t,e)};var de=(s,t,e)=>{if(!t)return!1;if(Array.isArray(t)&&typeof t[0]!="string")for(var r=0,n=t.length;r<n;r++)E.setup(s,t[r],e);else E.setup(s,t,e)};var Ke=0,q=class{constructor(t){this.router=t,this.locationId="base-app-router-"+Ke++,this.callBack=this.check.bind(this)}setup(){return this.addEvent(),this}};var gt=class extends q{addEvent(){return d.on("popstate",window,this.callBack),this}removeEvent(){return d.off("popstate",window,this.callBack),this}check(t){let e=t.state;if(!e||e.location!==this.locationId)return!1;t.preventDefault(),t.stopPropagation(),this.router.checkActiveRoutes(e.uri)}createState(t,e){let r={location:this.locationId,uri:t};return e&&typeof e=="object"&&(r=Object.assign(r,e)),r}addState(t,e,r=!1){let n=window.history,i=n.state;if(i&&i.uri===t)return this;let o=this.createState(t,e);return n[r===!1?"pushState":"replaceState"](o,null,t),this}};var yt=class extends q{addEvent(){return d.on("hashchange",window,this.callBack),this}removeEvent(){return d.off("hashchange",window,this.callBack),this}check(t){this.router.checkActiveRoutes(t.newURL)}addState(t,e,r){return window.location.hash=t,this}};var X=class{static browserIsSupported(){return"history"in window&&"pushState"in window.history}static setup(t){return X.browserIsSupported()?new gt(t).setup():new yt(t).setup()}};var Et=[],Ge=s=>Et.indexOf(s)!==-1,Qe=s=>({tag:"script",src:s.src,async:!1,load(t){Et.push(s.src);let e=s.load;e&&e()}}),Ye=s=>({tag:"link",rel:"stylesheet",type:"text/css",href:s.src,load(t){Et.push(s.src);let e=s.load;e&&e()}}),Pt=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=Ye({load:r,src:t}):e=Qe({load:r,src:t}),v.build(e,document.head)}addFiles(t){if(!!t)for(var e=0,r=t.length;e<r;e++){var n=t[e];Ge(n)||this.add(n)}}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)}},Ze=(s,t)=>{import(s).then(e=>{t&&t(e)})},tr=s=>s?typeof s?.prototype?.constructor=="function":!1,er=(s,t,e)=>{let r=v.build(s,null,e),n=r.firstChild;return t.after(r),n},rr=s=>({tag:"comment",textContent:"import placeholder",onCreated:s.onCreated}),sr=U({render(){return rr({onCreated:s=>{if(!!this.src){if(this.depends){new Pt(()=>{this.loadAndRender(s)}).addFiles(this.depends);return}this.loadAndRender(s)}}})},getLayout(s){let t=s.default;if(!t)return null;let e=this.callBack;return e?t=e(t):tr(t)?(t=new t,t.route=this.route,this.persist&&(t.persist=!0)):t=t(),this.layout=t},loadAndRender(s){Ze(this.src,t=>{this.loaded=!0;let e=this.layout||this.getLayout(t);this.layoutRoot=er(e,s,this.parent)})},shouldUpdate(s){return this.updateLayout===!0?!0:this.updateLayout=s&&s.isUnit&&typeof s.update=="function"},updateModuleLayout(s){let t=this.layout;this.shouldUpdate(t)&&t.update(s)},update(s){this.loaded===!0&&this.updateModuleLayout(s)},beforeDestroy(){!this.layoutRoot||y.removeElement(this.layoutRoot)}}),pe=s=>new sr(s);var vt=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,this.setupTemplate()}focus(t){this.setup===!1&&this.create(),this.update(t)}setupTemplate(){let t=this.template;if(typeof t=="string"&&(t=this.template=window[t],!t))return;let e=typeof t;if(e==="function")this.component=new this.template({route:this.route,persist:this.persist,parent:this.parent});else if(e==="object"){this.template.isUnit||(this.template=U(this.template));let r=this.component=this.template,n=r.persist!==!1;r.route=this.route,r.persist=n,r.parent=this.parent,this.persist=n}this.hasTemplate=!0}create(){if(!this.hasTemplate)return!1;this.setup=!0;let t=this.component;(!this.persist||!t)&&(t=this.component=this.template),v.render(t,this.container,this.parent)}remove(){if(this.setup!==!0)return!1;this.setup=!1;let t=this.component;if(!t)return!1;typeof t.destroy=="function"&&t.destroy(),this.persist===!1&&(this.component=null)}update(t){let e=this.component;if(!e)return!1;typeof e.update=="function"&&e.update(t)}};var nr=s=>{let t="";if(s){let e=/\//g;t=s.replace(e,"/");let r=/(\/):[^/(]*?\?/g;t=t.replace(r,a=>{let c=/\//g;return a.replace(c,"(?:$|/)")});let n=/(:[^/?&($]+)/g,i=/(\?\/+\*?)/g;t=t.replace(i,"?/*"),t=t.replace(n,a=>a.indexOf(".")<0?"([^/|?]+)":"([^/|?]+.*)");let o=/(\*)/g;t=t.replace(o,".*")}return t+=s[s.length-1]==="*"?"":"$",t},ir=s=>{if(!s.length)return null;let t={};for(var e=0,r=s.length;e<r;e++)t[s[e]]=null;return t},or=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(var i=0,o=n.length;i<o;i++){var a=n[i];a&&(a=a.replace(":",""),t.push(a))}return t},ar=0,xt=class extends O{constructor(t,e){let r=t.baseUri,n=or(r),i=ir(n),o=super(i);return this.uri=r,this.paramKeys=n,this.titleCallBack=e,this.setupRoute(t),this.set("active",!1),o}setupRoute(t){this.id=t.id||"bs-rte-"+ar++,this.path=null,this.referralPath=null;let e=nr(this.uri);this.uriQuery=new RegExp("^"+e),this.params=null,this.setupComponentHelper(t),this.callBack=t.callBack,this.title=t.title}setTitle(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?(typeof e=="string"&&(e={src:e}),pe(e)):null}setupComponentHelper(t){let e=this.getLayout(t);if(e){let{container:r,persist:n=!1,parent:i}=t,o={component:e,container:r,persist:n,parent:i};this.controller=new vt(this,o)}}resume(t){let e=this.controller;e&&(e.container=t)}setPath(t,e){this.path=t,this.referralPath=e}select(){this.set("active",!0);let t=this.stage,e=this.callBack;typeof e=="function"&&e(t);let r=this.controller;r&&r.focus(t);let n=this.path;if(!n)return;let i=n.split("#")[1];!i||this.scrollToId(i)}scrollToId(t){if(!t)return;let e=document.getElementById(t);!e||e.scrollIntoView(!0)}match(t){let e=!1,r=t.match(this.uriQuery);return r===null?(this.resetParams(),e):(r&&typeof r=="object"&&(r.shift(),e=r,this.setParams(r)),e)}resetParams(){this.stage={}}setParams(t){if(!t||typeof t!="object")return;let e=this.paramKeys;if(!e)return;let r={};for(var n=0,i=e.length;n<i;n++){var o=e[n];typeof o<"u"&&(r[o]=t[n])}this.set(r)}getParams(){return this.stage}};var cr=s=>{let t=/\w\S*/;return s.replace(t,e=>e.charAt(0).toUpperCase()+e.substring(1).toLowerCase())},hr=(s,t)=>{if(s.indexOf(":")===-1)return s;let e=t.stage;for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=e[r],i=new RegExp(":"+r,"gi");s=s.replace(i,n)}return s},me=(s,t,e)=>t&&(typeof t=="function"&&(t=t(s.stage)),t=hr(t,s),t=cr(t),e!==""&&(t+=" - "+e),t);var ge={removeSlashes(s){return typeof s=="string"&&(s.substring(0,1)==="/"&&(s=s.substring(1)),s.substring(-1)==="/"&&(s=s.substring(0,s.length-1))),s}};var bt=class extends B{beforeSetup(){this.selectedClass=this.activeClass||"active"}render(){let t=this.href,e=this.text,r=this.setupWatchers(t,e);return{tag:"a",className:this.className||null,onState:["selected",{[this.selectedClass]:!0}],href:this.getString(t),text:this.getString(e),children:this.children,watch:r}}getString(t){let e=typeof t;return e!=="object"&&e!=="undefined"?t:null}setupWatchers(t,e){let r=this.exact!==!1,n=w.data,i=[];return t&&typeof t=="object"&&i.push({attr:"href",value:t}),e&&typeof e=="object"&&i.push({attr:"text",value:e}),i.push({value:["[[path]]",n],callBack:(o,a)=>{let c=a.pathname+a.hash,h=r?o===c:new RegExp("^"+a.pathname+"($|#|/|\\.).*").test(o);this.update(a,h)}}),i}setupStates(){return{selected:!1}}update(t,e){this.state.set("selected",e)}};l.addType("routes",s=>{if(!s)return!1;let t=s.route;t&&w.removeRoute(t)});l.addType("switch",s=>{if(!s)return!1;let t=s.id;w.removeSwitch(t)});var Bt=class{constructor(){this.version="1.0.2",this.baseURI="/",this.title="",this.lastPath=null,this.path=null,this.history=null,this.callBackLink=null,this.location=window.location,this.routes=[],this.switches={},this.switchCount=0,this.data=new T({path:""})}setupHistory(){this.history=X.setup(this)}createRoute(t){let e=t.uri||"*";return t.baseUri=this.createURI(e),new xt(t,this.updateTitle.bind(this))}add(t){if(typeof t!="object"){let r=arguments;t={uri:r[0],component:r[1],callBack:r[2],title:r[3],id:r[4],container:r[5]}}let e=this.createRoute(t);return this.addRoute(e),e}addRoute(t){this.routes.push(t),this.checkRoute(t,this.getPath())}resume(t,e){t.resume(e),this.addRoute(t)}getBasePath(){if(!this.basePath){let t=this.baseURI||"";t[t.length-1]!=="/"&&(t+="/"),this.basePath=t}return this.basePath}createURI(t){return this.getBasePath()+ge.removeSlashes(t)}getRoute(t){let e=this.routes,r=e.length;if(r>0)for(var n=0;n<r;n++){var i=e[n];if(i.uri===t)return i}return!1}getRouteById(t){let e=this.routes,r=e.length;if(r>0)for(var n=0;n<r;n++){var i=e[n];if(i.id===t)return i}return!1}removeRoute(t){let e=this.routes,r=e.indexOf(t);r>-1&&e.splice(r,1)}addSwitch(t){let e=this.switchCount++,r=this.getSwitchGroup(e);for(var n=0,i=t.length;n<i;n++){var o=this.createRoute(t[n]);r.push(o)}return this.checkGroup(r,this.getPath()),e}resumeSwitch(t,e){let r=this.switchCount++,n=this.getSwitchGroup(r);for(var i=0,o=t.length;i<o;i++){var a=t[i].component.route;a.resume(e),n.push(a)}return this.checkGroup(n,this.getPath()),r}getSwitchGroup(t){return this.switches[t]=[]}removeSwitch(t){let e=this.switches;e[t]&&delete e[t]}remove(t){t=this.createURI(t);let e=this.getRoute(t);return e!==!1&&this.removeRoute(e),this}setup(t,e){this.baseURI=t||"/",this.updateBaseTag(this.baseURI),this.title=typeof e<"u"?e:"",this.setupHistory(),this.data.set("path",this.getPath()),this.callBackLink=this.checkLink.bind(this),d.on("click",document,this.callBackLink);let r=this.getEndPoint();return this.navigate(r,null,!0),this}updateBaseTag(t){let e=document.getElementsByTagName("base");e.length&&(e[0].href=t)}getParentLink(t){let e=t.parentNode;for(;e!==null;){if(e.nodeName.toLowerCase()==="a")return e;e=e.parentNode}return!1}checkLink(t){if(t.ctrlKey===!0)return!0;let e=t.target||t.srcElement;if(e.nodeName.toLowerCase()!=="a"&&(e=this.getParentLink(e),e===!1)||e.target==="_blank"||p.data(e,"cancel-route"))return!0;let r=e.getAttribute("href");if(typeof r<"u"){let n=this.baseURI,i=n!=="/"?r.replace(n,""):r;return this.navigate(i),t.preventDefault(),t.stopPropagation(),!1}}reset(){return this.routes=[],this.switches=[],this.switchCount=0,this}activate(){return this.checkActiveRoutes(),this}navigate(t,e,r){return t=this.createURI(t),this.history.addState(t,e,r),this.activate(),this}updatePath(){let t=this.getPath();this.data.set("path",t)}updateTitle(t){if(!t||!t.title)return this;let e=t.title;document.title=me(t,e,this.title)}checkActiveRoutes(t){this.lastPath=this.path,t=t||this.getPath(),this.path=t;let e=this.routes,r=e.length,n;for(var i=0;i<r;i++)n=e[i],!(typeof n>"u")&&this.checkRoute(n,t);this.checkSwitches(t),this.updatePath()}checkSwitches(t){let e=this.switches;for(var r in e)if(!!Object.prototype.hasOwnProperty.call(e,r)){var n=e[r];this.checkGroup(n,t)}}checkGroup(t,e){let r=!1,n,i,o,a,c=!1;for(var h=0,f=t.length;h<f;h++)if(n=t[h],!(typeof n>"u")){if(h===0&&(i=n),!o&&n.get("active")&&(o=n),r!==!1){c&&n.deactivate();continue}r=n.match(e),r!==!1&&(a=n,n.controller&&(this.select(n),c=!0))}if(a===void 0){this.select(i),o&&i!==o&&o.deactivate();return}o?c&&a!==o&&o.deactivate():i&&c===!1&&this.select(i)}checkRoute(t,e){let r=this.check(t,e);return r!==!1?this.select(t):t.deactivate(),r}check(t,e){return t?(e=e||this.getPath(),t.match(e)!==!1):!1}select(t){if(!t)return!1;t.setPath(this.path,this.lastPath),t.select(),this.updateTitle(t)}getEndPoint(){return this.getPath().replace(this.baseURI,"")||"/"}destroy(){d.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}},w=new Bt;var ve=(s,t,e)=>{if(!t)return!1;if(Array.isArray(t))for(var r=0,n=t.length;r<n;r++)ye(s,t[r],e);else ye(s,t,e)},ye=(s,t,e)=>{t.container=s,t.parent=e;let r=w.add(t);ur(s,r)},ur=(s,t)=>{l.add(s,"routes",{route:t})};var xe=(s,t,e)=>{let r=t[0];for(var n=0,i=t.length;n<i;n++)r=t[n],r.container=s,r.parent=e;let o=w.addSwitch(t);fr(s,o)},fr=(s,t)=>{l.add(s,"switch",{id:t})};F.add("cache",ee).add("onCreated",he).add("onDestroyed",ue).add("bind",oe).add("onSet",fe).add("onState",le).add("watch",de).add("useParent",re).add("useData",se).add("useState",ne).add("addState",ie).add("map",ce).add("for",ae).add("useContext",Zt).add("addContext",te).add("context",Yt).add("role",Gt).add("aria",Qt).add("route",ve).add("switch",xe);S.augment({Ajax:tt,Html:y,dataBinder:g,Data:T,SimpleData:O,Model:V,State:b,Builder:v,router:w,Component:B});export{tt as Ajax,Ee as Atom,v as Builder,B as Component,T as Data,l as DataTracker,F as Directives,y as Html,U as Jot,V as Model,bt as NavLink,O as SimpleData,b as State,I as Unit,S as base,g as dataBinder,w as router};
|
|
2
2
|
//# sourceMappingURL=base.js.map
|