crs-binding
Advanced tools
Comparing version 0.0.116 to 0.0.118
@@ -1,1 +0,1 @@ | ||
function t(t,i){const s=`_${i}`;return null!=t[s]?t[s]:crsbinding.data.getValue(t._dataId,i)}class i extends HTMLElement{constructor(){super(),this._dataId=crsbinding.data.addObject(this.constructor.name),crsbinding.data.addContext(this._dataId,this),crsbinding.dom.enableEvents(this),this.__properties=new Map}dispose(){this._disposing=!0,crsbinding.dom.disableEvents(this)}async connectedCallback(){null!=this.html&&(this.innerHTML=await fetch(this.html).then(t=>t.text()),crsbinding.parsers.parseElements(this.children,this._dataId)),this.isReady=!0,this.dispatchEvent(new CustomEvent("ready")),requestAnimationFrame(()=>{const t=this.getAttribute("name");null!=t&&crsbinding.data.setName(this._dataId,t)}),this.__properties.forEach((t,i)=>crsbinding.data.setProperty(this._dataId,i,t)),this.__properties.clear(),delete this.__properties,null!=this.load&&this.load()}async disconnectedCallback(){this.dispose(),crsbinding.utils.disposeProperties(this),crsbinding.observation.releaseBinding(this),crsbinding.data.removeObject(this._dataId)}getProperty(i){return t(this,i)}setProperty(i,s){if(1!=this.isReady)return this.__properties.set(i,s);!function(i,s,e){let n;e&&null!=e.__uid&&(n=t(i,s),n&&crsbinding.data.unlinkArrayItem(n)),crsbinding.data.setProperty(i._dataId,s,e),Array.isArray(e)&&(i[`_${s}`]=crsbinding.data.array(i._dataId,s)),e&&e.__uid&&crsbinding.data.linkToArrayItem(i._dataId,s,e.__uid);const a=`${s}Changed`,d=crsbinding.data.getContext(i._dataId);null!=d[a]&&d[a](e,n)}(this,i,s)}}export{i as BindableElement}; | ||
function t(t,i){const s=`_${i}`;return null!=t[s]?t[s]:crsbinding.data.getValue(t._dataId,i)}class i extends HTMLElement{constructor(){super(),this._dataId=crsbinding.data.addObject(this.constructor.name),crsbinding.data.addContext(this._dataId,this),crsbinding.dom.enableEvents(this),this.__properties=new Map}dispose(){this._disposing=!0,crsbinding.dom.disableEvents(this)}async connectedCallback(){if(null!=this.preLoad){const t=(t,i)=>{crsbinding.data.setProperty(this._dataId,t,i)};this.preLoad(t)}null!=this.html&&(this.innerHTML=await fetch(this.html).then(t=>t.text()),crsbinding.parsers.parseElements(this.children,this._dataId)),this.isReady=!0,this.dispatchEvent(new CustomEvent("ready")),requestAnimationFrame(()=>{const t=this.getAttribute("name");null!=t&&crsbinding.data.setName(this._dataId,t)}),this.__properties.forEach((t,i)=>crsbinding.data.setProperty(this._dataId,i,t)),this.__properties.clear(),delete this.__properties,null!=this.load&&this.load()}async disconnectedCallback(){this.dispose(),crsbinding.utils.disposeProperties(this),crsbinding.observation.releaseBinding(this),crsbinding.data.removeObject(this._dataId)}getProperty(i){return t(this,i)}setProperty(i,s,e=!1){if(1!=this.isReady&&!1===e)return this.__properties.set(i,s);!function(i,s,e){let a;e&&null!=e.__uid&&(a=t(i,s),a&&crsbinding.data.unlinkArrayItem(a)),crsbinding.data.setProperty(i._dataId,s,e),Array.isArray(e)&&(i[`_${s}`]=crsbinding.data.array(i._dataId,s)),e&&e.__uid&&crsbinding.data.linkToArrayItem(i._dataId,s,e.__uid);const n=`${s}Changed`,d=crsbinding.data.getContext(i._dataId);null!=d[n]&&d[n](e,a)}(this,i,s)}}export{i as BindableElement}; |
@@ -1,1 +0,1 @@ | ||
const e=Object.getPrototypeOf((async function(){})).constructor;function t(e){if(-1==e.indexOf("("))return e;const t=[];for(let n of e.split(".")){if(-1!=n.indexOf("("))break;t.push(n)}return t.join(".")}const n=["true","false","-","+","=","<",">","(",")","{","}","/","&","|","=","!","'","`",'"'," ","$",".",",","?",":","null","undefined"],i=[".","(",")",","],s=["'",'"',"`"],r=["'",'"'];function l(e,t,n){return t.length>0&&(e.push(t.join("")),t.length=0),e.push(n),!1}class o{get data(){return crsbinding.data.getValue(this._context)}constructor(e,t,n,i,s,r){this._element=e,this._context=t,this._property=n,this._value=i,this._ctxName=s||"context",this._eventsToRemove=[],this._isNamedContext="context"!=this._ctxName,this._value&&-1!=this._value.indexOf("$parent")&&(this._value=this._value.split("$parent.").join(""),this._context=r),this.init&&this.init(),crsbinding.providerManager.register(this),this.initialize().catch(e=>{throw e}),-1!=this._element.nodeName.indexOf("-")&&this._property==this._ctxName&&(this._element[this._property]=this._context)}dispose(){this._eventsToRemove.forEach(e=>{crsbinding.events.removeOn(this._context,e.value,e.callback)}),this._eventsToRemove.length=0,this._eventsToRemove=null,this._element=null,this._context=null,this._property=null,this._value=null,this._ctxName=null}async initialize(){}listenOnPath(e,t){const n=1==Array.isArray(e)?e:[e];for(let e of n)crsbinding.data.addCallback(this._context,e,t)}removeOn(e,t){crsbinding.events.removeOn(this._context,e,t)}}const a='element.dataset["__property__"] = value == null ? "" : value',c="\nif (element.__classList!=null) {\n const remove = Array.isArray(element.__classList) ? element.__classList : [element.__classList];\n remove.forEach(cls => element.classList.remove(cls));\n}",h="\nelement.__classList = value;\nconst add = Array.isArray(value) ? value : [value];\nadd.forEach(cls => element.classList.add(cls));",_=`${c} ${h}`,d=`\n ${c}\n\n if (__exp__) {\n ${h.split("value").join("__true__")}\n }\n else {\n ${h.split("value").join("__false__")}\n }\n`;class u extends o{dispose(){const e=`${this._ctxName}.`;0==this._value.indexOf(e)&&(this._value=this._value.replace(e,"")),this.removeOn(this._value,this._eventHandler),null!=this._expObj&&(crsbinding.expression.release(this._expObj),delete this._expObj),this._exp=null,this._eventHandler=null,super.dispose()}async initialize(){if("$context"==this._value||this._value==this._ctxName)return this.setContext();this._eventHandler=this.propertyChanged.bind(this),this._exp=function(e){let t;if("classlist"==e._property.toLocaleLowerCase())return _;if(-1!=e._property.indexOf("data-")){const t=e._property.replace("data-","");return a.split("__property__").join(t)}return t="value"==e._property?'requestAnimationFrame(() => element.__property__ = value == null ? "" : value);':"requestAnimationFrame(() => element.__property__ = value);",e._property=crsbinding.utils.capitalizePropertyPath(e._property),t.split("__property__").join(e._property)}(this),this._expObj=crsbinding.expression.compile(this._exp,["element","value"],{sanitize:!1,ctxName:this._ctxName});let e=this._value;1==this._isNamedContext&&(e=this._value.split(`${this._ctxName}.`).join("")),this.listenOnPath(e,this._eventHandler);const t=crsbinding.data.getValue(this._context,e);null!=t&&this.propertyChanged(e,t)}setContext(){if(null!=this._element&&null!=this._property){const e=()=>{this._element.removeEventListener("ready",e),this._element[this._property]=crsbinding.data.getValue(this._context)};1==this._element.isReady?e():this._element.addEventListener("ready",e)}}propertyChanged(e,t){null!=this._expObj&&(1!=this._isLinked&&null!=this._element._dataId&&(crsbinding.data.link(this._context,e,this._element._dataId,this._property,t),this._isLinked=!0),crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element,t)))}}const p=["INPUT","SELECT","TEXTAREA"];class f extends u{dispose(){this._element.removeEventListener(this._eventName,this._changeHandler),this._eventName=null,this._changeHandler=null,super.dispose()}async initialize(){await super.initialize(),this._changeHandler=this._change.bind(this),this._eventName=-1!==p.indexOf(this._element.nodeName)?"change":`${this._property}Change`,this._element.addEventListener(this._eventName,this._changeHandler)}_change(e){let t=e.target[this._property];const n=e.target.type||"text",i=`_${n}`;null!=this[i]&&(t=this[i](t,e.target)),crsbinding.data.setProperty(this._context,this._value,t,this._ctxName,"text"==n?"string":n),e.stopPropagation()}_number(e){return Number(e)}_date(e){return new Date(e)}_checkbox(e,t){return 1==t.checked}}function m(e,t){let n=e;if(-1==t.indexOf("."))return n[t];const i=t.split(".");for(let e=0;e<i.length-1;e++){if(n=n[i[e]],null==n)return null}return n[i[i.length-1]]}function x(e,t,n,i,s="context",r){return"context"==s?function(e,t,n,i){g(e,n,crsbinding.data.getValue(t,i))}(e,t,n,i):function(e,t,n,i,s){"context"!=s&&(i=i.split(`${s}.`).join(""));const r=crsbinding.data.getValue(t,i);g(e,n,r)}(e,t,n,i,s),null}function g(e,t,n){if(-1==t.indexOf("data-")){t=crsbinding.utils.capitalizePropertyPath(t),new Function("element","value",`element.${t} = value`)(e,n)}else{const i=t.replace("data-","");e.dataset[i]=n}}class v extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),this._eventHandler=this.event.bind(this),this._element.addEventListener(this._property,this._eventHandler)}dispose(){this._element.removeEventListener(this._property,this._eventHandler),this._eventHandler=null,this._fn=null,super.dispose()}async initialize(){let e=`context.${this._value}`.split("$event").join("event");-1==e.indexOf(")")&&(e=`${e}.call(context)`),this._fn=new Function("context",e)}event(e){const t=crsbinding.data.getContext(this._context);crsbinding.idleTaskManager.add(this._fn(t)),e.stopPropagation()}}class b extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),-1!=e.innerText.indexOf("$parent.")&&(e.innerText=e.innerText.split("$parent.").join(""),this._context=r),-1!=e.textContent.indexOf("$parent.")&&(e.textContent=e.textContent.split("$parent.").join(""),this._context=r),this._eventHandler=this._change.bind(this),this._expObj=crsbinding.expression.compile(e.innerText||e.textContent,null,{ctxName:this._ctxName});for(let e of this._expObj.parameters.properties)this.listenOnPath(e,this._eventHandler);this._change()}dispose(){crsbinding.expression.release(this._expObj),this._expObj=null,super.dispose(),this._eventHandler=null}_change(){if(null==this._expObj)return;const e=this._element.textContent?"textContent":"innerText";this._element[e]=this._expObj.function(this.data)}}class y extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),this._eventHandler=this._change.bind(this),this._expObj=crsbinding.expression.compile(this._value,null,{ctxName:this._ctxName});for(let e of this._expObj.parameters.properties)this.listenOnPath(e,this._eventHandler);this._change()}dispose(){crsbinding.expression.release(this._expObj),this._expObj=null,super.dispose(),this._eventHandler=null}_change(){const e=this._expObj.function(this.data);this._element.setAttribute(this._property,e)}}class O extends o{dispose(){this._singular=null,this._plural=null,this._container=null,this._collectionChangedHandler=null,this.positionStruct.addAction=null,this.positionStruct.removeAction=null,this.positionStruct=null,super.dispose()}async initialize(){this._container=this._element.parentElement,this._shouldClearAll=1==this._container.children.length,this._determineInsertParameters();const e=this._value.split("of");this._singular=e[0].trim(),this._plural=e[1].trim(),this._collectionChangedHandler=this._collectionChanged.bind(this),this.listenOnPath(this._plural,this._collectionChangedHandler)}async _collectionChanged(e,t){if(null==t)return this._clear();this._renderItems(t)}_determineInsertParameters(){const e=this._element.nextElementSibling,t=this._element.previousElementSibling;this.positionStruct={startIndex:Array.from(this._container.children).indexOf(this._element),addAction:null!=e?this._insertBefore.bind(e):this._appendItems.bind(this._element),removeAction:()=>this._removeBetween.call(this._element,t,e)}}_appendItems(e){this.parentElement.appendChild(e)}_insertBefore(e){this.parentElement.insertBefore(e,this)}_removeBetween(e,t){const n=Array.from(this.parentElement.children);let i=n.indexOf(e),s=n.indexOf(t);-1==i&&(i=0),-1==s&&(s=n.length);const r=[];for(let e=i+1;e<s;e++)"TEMPLATE"!=n[e].nodeName&&r.push(n[e]);for(let e of r)e.parentElement.removeChild(e)}_clear(){1==this._shouldClearAll?this._clearAll():this._clearPartial()}_clearAll(){const e=Array.from(this._container.children).filter(e=>"TEMPLATE"!=e.nodeName);for(let t of e)t.parentElement.removeChild(t),crsbinding.observation.releaseBinding(t)}_clearPartial(){this.positionStruct.removeAction()}async _renderItems(){this._clear()}createElement(e,t){const n=crsbinding.data.createReferenceTo(this._context,`${this._context}-array-item-${t}`,this._plural,t),i=this._element.content.cloneNode(!0);crsbinding.parsers.parseElement(i,n,this._singular,this._context),e.__uid=n;for(let e of i.children)e.dataset.uid=n;return i}}class $ extends O{init(){this._itemsAddedHandler=this._itemsAdded.bind(this),this._itemsDeletedHandler=this._itemsDeleted.bind(this)}dispose(){crsbinding.expression.release(this._forExp),this._forExp=null,this._itemsAddedHandler=null,this._itemsDeletedHandler=null,super.dispose()}async initialize(){super.initialize();this._forExp=crsbinding.expression.compile("for (let i = 0; i < context.length; i++) { callback(context[i], i) }",["callback"],{sanitize:!1,async:!0,ctxName:this._ctxName}),crsbinding.data.setArrayEvents(this._context,this._plural,this._itemsAddedHandler,this._itemsDeletedHandler)}async _renderItems(e){super._renderItems();const t=document.createDocumentFragment();await this._forExp.function(e,e=>{e.__aId=crsbinding.data.nextArrayId();const n=this.createElement(e,e.__aId);t.appendChild(n)}),this.positionStruct.addAction(t),null==this._container.__providers&&(this._container.__providers=[]),-1==this._container.__providers.indexOf(this.id)&&this._container.__providers.push(this.id)}_itemsAdded(e,t){for(let n=0;n<e.length;n++){const i=e[n],s=t.indexOf(i);i.__aId=crsbinding.data.nextArrayId();const r=this.createElement(i,i.__aId),l=r.children[0],o=this._container.children[s+this.positionStruct.startIndex+1];this._container.insertBefore(r,o);for(let e of l.__providers||[]){const t=crsbinding.providerManager.items.get(e);t instanceof y&&t._change()}}}_itemsDeleted(e,t){if(null==e)return;const n=[],i=Array.isArray(e)?e:[e];for(let e of i){const t=e.__uid;this._container.querySelectorAll([`[data-uid="${t}"]`]).forEach(e=>n.push(e)),crsbinding.data.removeObject(t)}for(let e of n)null!=e&&(e.parentElement.removeChild(e),crsbinding.observation.releaseBinding(e))}}class A extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._sanitizeProperties=["fill","stroke"],this._eventHandler=this.propertyChanged.bind(this),-1==this._value.indexOf("?")?this._initCndAttr():-1!=this._value.indexOf(":")?this._initCndValue():this._initCndAttrValue(),this.propertyChanged()}_initCndAttr(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=j.split("__exp__").join(e.expression).split("__attr__").join(this._property).split("__attr-value__").join(this._property);this._expObj=crsbinding.expression.compile(t,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler)}_initCndValue(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=t[1].split(":"),i=this._sanitizeValue(n[0].trim()),s=this._sanitizeValue(n[1].trim()),r=E.split("__exp__").join(t[0].trim()).split("__attr__").join(this._property).split("__true__").join(i).split("__false__").join(s);this._expObj=crsbinding.expression.compile(r,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler)}_initCndAttrValue(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=j.split("__exp__").join(t[0].trim()).split("__attr__").join(this._property).split("__attr-value__").join(t[1].trim());this._expObj=crsbinding.expression.compile(n,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler),this.propertyChanged()}_sanitizeValue(e){return-1==this._sanitizeProperties.indexOf(this._property)?e:e.split("'").join("")}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}const j='\nif (__exp__) {\n element.setAttribute("__attr__", "__attr-value__");\n}\nelse {\n element.removeAttribute("__attr__");\n}\n',E='\nif (__exp__) {\n element.setAttribute("__attr__", "__true__");\n}\nelse {\n element.setAttribute("__attr__", "__false__");\n}\n';class C extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._eventHandler=this.propertyChanged.bind(this);const e=this._value.split("?"),t=crsbinding.expression.sanitize(e[0],this._ctxName),n=t.expression,i=e[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():"[]",l=d.split("__property__").join(this._property).split("__exp__").join(n).split("__true__").join(s).split("__false__").join(r);this._expObj=crsbinding.expression.compile(l,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(t.properties,this._eventHandler),this.propertyChanged()}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}class N extends o{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._eventHandler=this.propertyChanged.bind(this);const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=t[0].trim(),i=t[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():'""',l="requestAnimationFrame(() => element.__property__ = (__exp__) ? __true__ : __false__)".split("__property__").join(this._property).split("__exp__").join(n).split("__true__").join(s).split("__false__").join(r);this._expObj=crsbinding.expression.compile(l,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler),this.propertyChanged()}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}class I{static bind(e,t,n,i,s,r,l){return-1!=["value","checked"].indexOf(n)?new f(e,t,n,i,s,l):this["one-way"](e,t,n,i,s,l)}static"two-way"(e,t,n,i,s,r,l){return new f(e,t,n,i,s,l)}static"one-way"(e,t,n,i,s,r,l){return new u(e,t,n,i,s,l)}static once(e,t,n,i,s,r,l){return x(e,t,n,i,s)}static call(e,t,n,i,s,r,l){return new v(e,t,n,i,s,l)}static delegate(e,t,n,i,s,r,l){return new v(e,t,n,i,s,l)}static inner(e,t,n,i,s,r,l){return new b(e,t,n,i,s,l)}static for(e,t,n,i,s,r,l){return r&&-1!=r.name.indexOf(".once")?function(e,t,n,i,s="context",r){-1!=i.indexOf("$parent.")&&(i=i.split("$parent.").join(""),t=r);const l=i.split("of"),o=l[0].trim(),a=l[1].trim();crsbinding.inflationManager.register("for-once",e,o);const c=crsbinding.data.getValue(t,a),h=crsbinding.inflationManager.get("for-once",c);e.parentElement.appendChild(h),e.parentElement.removeChild(e),crsbinding.inflationManager.unregister("for-once")}(e,t,0,i,s,l):new $(e,t,n,i,s,l)}static if(e,t,n,i,s,r,l){return"classlist"==n.toLowerCase()?new C(e,t,n,i,s,l):-1!=n.toLowerCase().indexOf("style.")?new N(e,t,n,i,s,l):new A(e,t,n,i,s,l)}static attr(e,t,n,i,s,r,l){return new y(e,t,n,i,s,l)}}const w=["STYLE"];function z(e,t,n="context",i){for(let s of e||[])-1==w.indexOf(s.nodeName)&&T(s,t,n,i)}function T(e,t,n="context",i){z(e.children,t,n,i),function(e,t,n,i){for(let s of e)P(s,t,n,i)}(Array.from(e.attributes||[]).filter(e=>"TEMPLATE"==e.ownerElement.tagName&&"for"==e.name||-1!=e.name.indexOf(".")||0==(e.value||"").indexOf("${")),t,n,i),e.children&&0==e.children.length&&-1!=(e.innerText||e.textContent||"").indexOf("${")&&I.inner(e,t,null,null,n,null,i)}function P(e,t,n,i){const s=e.name.split(".");let r=2==s.length?s[0]:s.slice(0,s.length-1).join("."),l="for"==r?r:s[s.length-1];0==r.length&&"$"==e.value[0]&&(r=l,l="attr");const o=I[l](e.ownerElement,t,r,e.value,n,e,i);return null!=o&&"AttrProvider"==o.constructor.name||e.ownerElement.removeAttribute(e.nodeName),o}function k(e){crsbinding.providerManager.releaseElement(e)}globalThis.requestIdleCallback=globalThis.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1)},globalThis.cancelIdleCallback=globalThis.cancelIdleCallback||function(e){clearTimeout(e)};function H(e,t){this.addEventListener(e,t),this._domEvents.push({event:e,callback:t})}function L(e,t){const n=this._domEvents.find(n=>n.event==e&&n.callback==t);null!=n&&(this.removeEventListener(n.event,n.callback),this._domEvents.splice(this._domEvents.indexOf(n),1),n.callback=null,n.event=null)}class S{constructor(e){this.inflateSrc=[],this.deflateSrc=[],this._ctxName=e}dispose(){this.inflateSrc=null,this.deflateSrc=null}generateCodeFor(e){const t=e.content.children[0];this.path="element",this._processElement(t);const n=this.inflateSrc.join("\n"),i=this.deflateSrc.join("\n");return{inflate:new Function("element",this._ctxName,n),deflate:new Function("element",this._ctxName,i)}}_processElement(e){this._processInnerText(e),this._processAttributes(e);const t=this.path;for(let n=0;n<e.children.length;n++)this.path=`${t}.children[${n}]`,this._processElement(e.children[n])}_processInnerText(e){const t=(e.innerHTML||"").trim(),n=e.textContent?"textContent":"innerText";if(0==t.indexOf("${")){let e=t.substr(2,t.length-3);e=crsbinding.expression.sanitize(e,this._ctxName).expression,this.inflateSrc.push(`${this.path}.${n} = ${e};`),this.deflateSrc.push(`${this.path}.${n} = "";`)}}_processAttributes(e){const t=Array.from(e.attributes).filter(e=>-1!=e.value.indexOf("${")||-1!=e.name.indexOf(".if"));for(let e of t)-1!=e.value.indexOf("${")?this._processAttrValue(e):this._processAttrCondition(e)}_processAttrValue(e){const t=e.value.trim();let n=t.substr(2,t.length-3);if(n=crsbinding.expression.sanitize(n,this._ctxName).expression,"xlink:href"==e.name)this.inflateSrc.push(`${this.path}.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", ${n});`);else{const t=n.split("?");this.inflateSrc.push(`if (${t[0].trim()} != null) {${this.path}.setAttribute("${e.name}", ${n});}`)}this.deflateSrc.push(`${this.path}.removeAttribute("${e.name}");`),e.ownerElement.removeAttribute(e.name)}_processAttrCondition(e){return 0==e.name.trim().indexOf("style")?this._processStyle(e):0==e.name.trim().indexOf("classlist")?this._processClassList(e):-1!=e.name.trim().indexOf(".if")?this._processConditional(e):void 0}_processStyle(e){const t=e.name.split(".")[1],n=crsbinding.expression.sanitize(e.value.trim(),this._ctxName).expression;this.inflateSrc.push(`${this.path}.style.${t} = ${n};`),this.deflateSrc.push(`${this.path}.style.${t} = "";`),e.ownerElement.removeAttribute(e.name)}_processClassList(e){const t=e.value.split("?"),n=crsbinding.expression.sanitize(t[0],this._ctxName).expression,i=t[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():"",l=-1==s.indexOf("[")?s:`...${s}`;let o=`if (${n}) {${this.path}.classList.add(${l});}`;if(r.length>0){let e=-1==r.indexOf("[")?r:`...${r}`;o+=`else {${this.path}.classList.add(${e});}`}const a=`while (${this.path}.classList.length > 0) {${this.path}.classList.remove(${this.path}.classList.item(0));}`;this.inflateSrc.push(o),this.deflateSrc.push(a),e.ownerElement.removeAttribute(e.name)}_processConditional(e){const t=e.name.split(".if")[0].trim(),n=e.value.split("?");let i=[`if(${crsbinding.expression.sanitize(n[0].trim(),this._ctxName).expression})`];const s=n.length>1?n[1].trim():`"${t}"`;if(-1==s.indexOf(":"))i.push("{"),i.push(`${this.path}.setAttribute("${t}", ${s});`),i.push("}"),i.push(`else {${this.path}.removeAttribute("${t}")}`);else{const e=n[1].split(":");i.push("{"),i.push(`${this.path}.setAttribute("${t}", ${e[0].trim()});`),i.push("}"),i.push(`else {${this.path}.setAttribute("${t}", ${e[1].trim()})}`)}this.inflateSrc.push(i.join("")),this.deflateSrc.push(`${this.path}.removeAttribute("${t}")`),e.ownerElement.removeAttribute(e.name)}}const M=["pop","splice"],V=["push"];function F(e,t){const n=e[t];return"function"==typeof n?(...n)=>{const i=e[t](...n);return-1!=M.indexOf(t)?(!function(e,t){const n=e.__id,i=e.__property;crsbinding.data.arrayItemsRemoved(n,i,t,e)}(e,i),"splice"==t&&n.length>2&&(n=n.splice(2,n.length),R(e,n))):-1!=V.indexOf(t)&&R(e,n),i}:n}function R(e,t){const n=e.__id,i=e.__property;crsbinding.data.arrayItemsAdded(n,i,t,e)}const D=new Map,B=new Map,q=new Map,U=new Map,Q=new Map,W={nextId:0,nextTriggerId:0,nextArrayId:0};function X(){return G("nextId")}function Y(){return G("nextTriggerId")}function G(e){const t=W[e];return W[e]+=1,t}function J(e,t){Z(m(B.get(e),t),e,t)}function K(e,t){"object"==typeof e&&(e=e.__uid||e._dataId);const n=B.get(e);if(null==t){const t=oe(n);for(let i of t)Z(n[i],e,i)}else{if(-1!=t.indexOf("."))return J(e,t);if(null==n)return;if(null==n[t])return;Z(n[t],e,t)}}function Z(e,t,n){if(null!=e.__functions)for(let i of e.__functions){i(n,ce.getValue(t,n))}if(null!=e.__trigger){const i=U.get(e.__trigger);if(1!=i.frozen){i.frozen=!0;for(let e of i.values)e.id==t&&e.path==n||crsbinding.data.updateUI(e.id,e.path);delete i.frozen}}const i=oe(e);for(let s of i)Z(e[s],t,`${n}.${s}`)}function ee(e,t,n){e[t]=e[t]||{},e[t].__functions=e[t].__functions||[],e[t].__functions.push(n)}function te(e,t,n){let i=e;const s=t.split(".");for(let e=0;e<s.length-1;e++){const t=s[e];null==i[t]&&(i[t]={}),i=i[t]}n&&n(i,s[s.length-1])}function ne(e,t,n){return e[t]!=n&&(e[t]=n,!0)}function ie(e,t,n){let i=!0;return te(e,t,(e,t)=>i=ne(e,t,n)),i}function se(e,t,n,i){const s=q.get(n)||{},r=s[i]||{};r.originId==e&&r.originProperty==t||(r.originId=e,r.originProperty=t,s[i]=r,q.set(n,s))}function re(e,t){const n=U.get(t),i=n.values.filter(t=>t.id==e);for(let e of i){const t=n.values.indexOf(e);n.values.splice(t,1)}}function le(e,t,n,i,s,r){const l=e[t],o=n[i]=n[i]||{};if(null!=l.__trigger){o.__trigger=l.__trigger,U.get(l.__trigger).values.push({id:s,path:r})}const a=oe(l);for(let e of a)le(l,e,o,e,s,`${r}.${e}`)}function oe(e){return Object.getOwnPropertyNames(e).filter(e=>-1==e.indexOf("__"))}function ae(e){Q.delete(e),function(e){(function(e){const t=Array.from(D).filter(t=>t[1].refId==e);for(let e of t)ae(e[1].id)})(e),D.delete(e),0==D.size&&(W.nextId=0,W.nextArrayId=0)}(e),function(e){B.delete(e)}(e),function(e){const t=Array.from(q).filter(t=>t[0]==e||t[1].value.originId==e);for(let e of t)q.delete(e[0])}(e),function(e){const t=Array.from(U);for(let n of t){const t=n[1].values.findIndex(t=>t.id==e);-1!=t&&(n[1].values.splice(t,1),0==n.values.length&&U.delete(n[0]))}0==U.size&&(W.nextTriggerId=0)}(e)}const ce={details:{data:D,callbacks:B,updates:q,triggers:U,context:Q},link:function(e,t,n,i,s){"object"!=typeof s||null===s?(se(e,t,n,i),se(n,i,e,t),function(e,t,n,i){let s=B.get(e),r=B.get(n);const l=m(s,`${t}.__trigger`);if(null!=l){r[i]=r[i]||{},r[i].__trigger=l,U.get(l).values.push({id:n,path:i})}}(e,t,n,i)):function(e,t,n,i){let s=B.get(e),r=B.get(n);-1==t.indexOf(".")?le(s,t,r,i,n,i):te(r,i,(e,r)=>{e[r]=e[r]||{};const l=t.split("."),o=l[l.length-1],a=l.splice(0,l.length-1).join();le(m(s,a),o,e,r,n,i)})}(e,t,n,i)},setName(e,t){D.get(e).name=t},addObject(e,t={}){const n=X();return D.set(n,{id:n,name:e,type:"data",data:t}),B.set(n,{}),n},removeObject:ae,addContext(e,t){Q.set(e,t)},addCallback(e,t,n){const i=B.get(e);return-1==t.indexOf(".")?ee(i,t,n):function(e,t,n){te(e,t,(e,t)=>{ee(e,t,n)})}(i,t,n)},setProperty(e,t,n,i,s){"object"==typeof e&&(e=e.__uid||e._dataId);let r=D.get(e);if(("number"==s||null==s&&0==isNaN(n)&&0==Array.isArray(n))&&(n=Number(n)),"data"==r.type){r=D.get(e).data,1==(-1==t.indexOf(".")?ne(r,t,n):ie(r,t,n))&&(!function(e,t,n){const i=q.get(e);null!=i&&null!=i[t]&&ce.setProperty(i[t].originId,i[t].originProperty,n)}(e,t,n),K(e,t))}else this.setReferenceValue(e,t,n,r.refId,r.path,r.aId,i)},getValue(e,t){const n=D.get(e);if("data"==n.type){const e=n.data;return null==t?e:-1==t.indexOf(".")?function(e,t){return e[t]}(e,t):function(e,t){return new Function("context",`try {return context.${t}} catch {return null}`)(e)}(e,t)}{const e=n.refId;return this.getReferenceValue(e,t,n.path,n.aId)}},getContext:e=>Q.get(e),getReferenceValue(e,t,n,i){const s=D.get(e);if("data"==s.type){if(void 0===i){const i=null==t?n:`${n}.${t}`;return this.getValue(e,i)}{const s=this.getValue(e,n).find(e=>e.__aId==i);return null==t?s:m(s,t)}}{let e=`${s.path}.${n}`;return this.getReferenceValue(s.refId,t,e)}},setReferenceValue(e,t,n,i,s,r,l){const o=D.get(i);if("data"!=o.type){let e=`${o.path}.${path}`;return this.getReferenceValue(o.refId,t,e)}{let i=m(o.data,s);null!=r&&(i=i.find(e=>e.__aId==r)),"context"!=l&&(t=t.split(`${l}.`).join("")),ie(i,t,n),J(e,t)}},createReferenceTo:function(e,t,n,i){const s=X(),r={id:s,name:t,type:"ref",refId:e,path:n};return void 0!==i&&(r.aId=i),D.set(s,r),B.set(s,{}),s},clear(){D.forEach((e,t)=>{delete e.data}),D.clear(),W.nextId=0,W.nextArrayId=0},makeShared:function(e,t,n){const i=B.get(e);for(let s of n){const n=`${t}.${s}`;te(i,n,(t,i)=>{null==t[i]&&(t[i]={});const s=Y();U.set(s,{values:[{id:e,path:n}]}),t[i].__trigger=s})}},updateUI:K,array(e,t){return"object"==typeof e&&(e=e._dataId),function(e,t,n){return null==e?null:(e.__id=t,e.__property=n,new Proxy(e,{get:F}))}(this.getValue(e,t),e,t)},setArrayEvents:function(e,t,n,i){te(B.get(e),t,(e,t)=>{e[t]=e[t]||{},e[t].__itemsAdded=e[t].itemsAdded||[],e[t].__itemsAdded.push(n),e[t].__itemsDeleted=e[t].itemsDeleted||[],e[t].__itemsDeleted.push(i)})},arrayItemsAdded:function(e,t,n,i){const s=m(B.get(e),t);for(let e of s.__itemsAdded||[])e(n,i)},arrayItemsRemoved:function(e,t,n,i){const s=m(B.get(e),t);for(let e of s.__itemsDeleted||[])e(n,i)},linkToArrayItem:function(e,t,n){let i=m(B.get(e),t);if(null==i)return;let s=B.get(n);const r=oe(i);for(let e of r)le(i,e,s,e,n,e)},unlinkArrayItem:function(e){!function e(t,n){const i=oe(t);for(let s of i){const i=t[s].__trigger;null!=i&&(delete t[s].__trigger,re(n,i)),"object"==typeof t[s]&&e(t[s])}}(B.get(e.__uid),e.__uid)},nextArrayId:function(){return G("nextArrayId")}};String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};const he={_expFn:new Map,data:ce,idleTaskManager:new class{constructor(){this.processing=!1,this._list=[]}dispose(){this._list=null}add(e){e&&this._list.push(e),!this.processing&&this._processQueue()}_processQueue(){if(null==requestIdleCallback)return this._runNextFunction();this.processing=!0,requestIdleCallback(e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&this._list.length;)this._runNextFunction();this.processing=!1},{timeout:1e3})}_runNextFunction(){let e=this._list.shift();e&&e()}},providerManager:new class{constructor(){this._nextId=0,this.items=new Map}async register(e){e.id=this._nextId,null==e._element.__providers&&Reflect.set(e._element,"__providers",[]),e._element.__providers.push(this._nextId),this.items.set(this._nextId,e),this._nextId+=1}async releaseElement(e){for(let t of e.children||[])await this.releaseElement(t);if(null!=e.__providers){for(let t of e.__providers){const e=this.items.get(t);this.items.delete(t),e&&e.dispose()}e.__providers=null,0==this.items.size&&(this._nextId=0)}}},inflationManager:new class{constructor(){this._items=new Map}dispose(){this._items.clear(),this._items=null}register(e,t,n="context"){const i=new S(n),s=i.generateCodeFor(t);i.dispose(),this._items.set(e,{template:t,inflate:s.inflate,deflate:s.deflate})}unregister(e){const t=this._items.get(e);null!=t&&(t.template=null,t.inflate=null,t.defaulte=null,this._items.delete(e))}get(e,t){const n=this._items.get(e);if(null==n)return null;const i=document.createDocumentFragment();for(let s of t){const t=n.template.content.cloneNode(!0);this.inflate(e,t.children[0],s,n.inflate),i.appendChild(t)}return i}inflate(e,t,n,i=null){(i||this._items.get(e).inflate)(t,n)}deflate(e,t){const n=this._items.get(e).deflate;if(Array.isArray(t))for(let e of t)n(e);else n(t)}},valueConverters:new class{constructor(){this._converters=new Map}dispose(){this._converters.clear(),this._converters=null}register(e,t){this._converters.set(e,t)}unregister(e){this._converters.delete(e)}convertTo(e,t){const n=this._converters.get(e);return null==n?t:n.convertTo(t)}convertBack(e,t){const n=this._converters.get(e);return null==n?t:n.convertBack(t)}},expression:{sanitize:function(e,o="context"){const a="context"!=o,c=`${o}.`,h=function(e,t){let i=[],s=[],o=!1;for(let t=0;t<e.length;t++){const a=e[t];1==o&&"$"==a&&"{"==e[t+1]&&(o=!1),1==o?-1==r.indexOf(a)?s.push(a):(l(i,s,a),o=!1):-1!=n.indexOf(a)?(l(i,s,a),-1!=r.indexOf(a)&&(o=!0)):s.push(a)}s.length>0&&i.push(s.join(""));null!=t&&(i=function e(t,n){const i=t.indexOf(n);if(-1==i)return t;"."==t[i+1]&&(t.splice(i,2),-1!=t.indexOf(n)&&e(t,n));return t}(i,t));return i}(e,a?o:null);if(1==h.length)return{isLiteral:!1,expression:`${c}${h[0]}`,properties:[e]};const _=[],d=-1!=e.indexOf("${");let u=null,p=[],f=[];for(let e=0;e<h.length;e++){const r=h[e];-1!=s.indexOf(u)||-1!=n.indexOf(r)&&-1==i.indexOf(r)?(u=r,p.length>0&&(0!=d&&"}"!=u||isNaN(p)&&(f.push(e-p.length),_.push(t(`${p.join("")}`))),p.length=0)):(p.push(r),u=r)}a&&p.length>0&&(0!=d&&"}"!=u||isNaN(p)&&(f.push(h.length-1),_.push(t(`${p.join("")}`)))),0==f.length&&-1!=e.indexOf(".")&&f.push(0);for(let e=0;e<f.length;e++)h.splice(e+f[e],0,c);return{isLiteral:d,expression:h.join(""),properties:_}},compile:function(t,n,i){n=n||[];let s=!0,r=!1,l="context";if(null!=i&&(null!=i.sanitize&&(s=i.sanitize),null!=i.async&&(r=i.async),null!=i.ctxName&&(l=i.ctxName)),crsbinding._expFn.has(t)){const e=crsbinding._expFn.get(t);return e.count+=1,e}let o,a=t;if(1==s){if(o=crsbinding.expression.sanitize(t,l),crsbinding._expFn.has(o.expression)){const e=crsbinding._expFn.get(o.expression);return e.count+=1,e}a=!0===o.isLiteral?["return `",o.expression,"`"].join(""):`return ${o.expression}`,o.expression.split(".").length>2&&(a=`try { ${a} } catch(error) { return null }`)}else o={expression:t};const c={function:1==r?new e(l,...n,a):new Function(l,...n,a),parameters:o,count:1};return crsbinding._expFn.set(o.expression,c),c},release:function(e){if(null==e||"object"!=typeof e)return;const t=e.parameters.expression;if(crsbinding._expFn.has(t)){const e=crsbinding._expFn.get(t);e.count-=1,0==e.count&&(e.function=null,e.parameters=null,crsbinding._expFn.delete(t))}}},observation:{releaseBinding:k,releaseChildBinding:function(e){for(let t of e.children)k(t)}},parsers:{parseElement:T,parseElements:z},events:{when:function(e,t,n){},on:function(e,t,n){},removeOn:function(e,t,n){},removeWhen:function(e,t,n){},listenOn:function(e,t,n){-1==t.indexOf(".")?crsbinding.events.on(e,t.trim(),n):crsbinding.events.listenOnPath(e,t,n)},listenOnPath:function(e,t,n){t.split(".")}},dom:{enableEvents:function(e){e._domEvents=[],e.registerEvent=H,e.unregisterEvent=L},disableEvents:function(e){if(null!=e._domEvents){for(let t of e._domEvents)t.callback=null,t.event=null;e._domEvents.length=0,delete e._domEvents,delete e.registerEvent,delete e.unregisterEvent}}},utils:{capitalizePropertyPath:function(e){const t=e.split("-");for(let e=1;e<t.length;e++)t[e]=t[e].capitalize();return t.join("")},clone:function(e){return null==e?e:function e(t){let n=Object.getOwnPropertyNames(t).filter(e=>0==e.indexOf("__"));for(let e of n)delete t[e];n=Object.getOwnPropertyNames(t).filter(e=>-1==e.indexOf("__")&&"object"==typeof t[e]);for(let i of n)e(t[i]);return t}(Object.assign({},e))},disposeProperties:function e(t){const n=Object.getOwnPropertyNames(t).filter(e=>t[e]&&1==t[e].__isProxy);for(let i of n){const n=t[i];1!=Array.isArray(n)&&e(n),delete t[i]}}}};globalThis.crsbinding=he;export{he as crsbinding}; | ||
const e=Object.getPrototypeOf((async function(){})).constructor;function t(e){if(-1==e.indexOf("("))return e;const t=[];for(let n of e.split(".")){if(-1!=n.indexOf("("))break;t.push(n)}return t.join(".")}const n=["true","false","-","+","=","<",">","(",")","{","}","/","&","|","=","!","'","`",'"'," ","$",".",",","?",":","null","undefined"],i=[".","(",")",","],s=["'",'"',"`"],r=["'",'"'];function l(e,t,n){return t.length>0&&(e.push(t.join("")),t.length=0),e.push(n),!1}class a{get data(){return crsbinding.data.getValue(this._context)}constructor(e,t,n,i,s,r){this._element=e,this._context=t,this._property=n,this._value=i,this._ctxName=s||"context",this._eventsToRemove=[],this._isNamedContext="context"!=this._ctxName,this._value&&-1!=this._value.indexOf("$parent")&&(this._value=this._value.split("$parent.").join(""),this._context=r),this.init&&this.init(),crsbinding.providerManager.register(this),this.initialize().catch(e=>{throw e}),-1!=this._element.nodeName.indexOf("-")&&this._property==this._ctxName&&(this._element[this._property]=this._context)}dispose(){this._eventsToRemove.length=0,this._eventsToRemove=null,this._element=null,this._context=null,this._property=null,this._value=null,this._ctxName=null}async initialize(){}listenOnPath(e,t){const n=1==Array.isArray(e)?e:[e];for(let e of n)crsbinding.data.addCallback(this._context,e,t)}}const o='element.dataset["__property__"] = value == null ? "" : value',c="\nif (element.__classList!=null) {\n const remove = Array.isArray(element.__classList) ? element.__classList : [element.__classList];\n remove.forEach(cls => element.classList.remove(cls));\n}",_="\nelement.__classList = value;\nconst add = Array.isArray(value) ? value : [value];\nadd.forEach(cls => element.classList.add(cls));",h=`${c} ${_}`,d=`\n ${c}\n\n if (__exp__) {\n ${_.split("value").join("__true__")}\n }\n else {\n ${_.split("value").join("__false__")}\n }\n`;class p extends a{dispose(){const e=`${this._ctxName}.`;0==this._value.indexOf(e)&&(this._value=this._value.replace(e,"")),null!=this._expObj&&(crsbinding.expression.release(this._expObj),delete this._expObj),this._exp=null,this._eventHandler=null,super.dispose()}async initialize(){if("$context"==this._value||this._value==this._ctxName)return this.setContext();this._eventHandler=this.propertyChanged.bind(this),this._exp=function(e){let t;if("classlist"==e._property.toLocaleLowerCase())return h;if(-1!=e._property.indexOf("data-")){const t=e._property.replace("data-","");return o.split("__property__").join(t)}return t="value"==e._property||"placeholder"==e._property?'requestAnimationFrame(() => element.__property__ = value == null ? "" : value);':"requestAnimationFrame(() => element.__property__ = value);",e._property=crsbinding.utils.capitalizePropertyPath(e._property),t.split("__property__").join(e._property)}(this),this._expObj=crsbinding.expression.compile(this._exp,["element","value"],{sanitize:!1,ctxName:this._ctxName});let e=this._value;1==this._isNamedContext&&(e=this._value.split(`${this._ctxName}.`).join("")),this.listenOnPath(e,this._eventHandler);const t=crsbinding.data.getValue(this._context,e);null!=t&&this.propertyChanged(e,t)}setContext(){if(null!=this._element&&null!=this._property){const e=()=>{this._element.removeEventListener("ready",e),this._element[this._property]=crsbinding.data.getValue(this._context)};1==this._element.isReady?e():this._element.addEventListener("ready",e)}}propertyChanged(e,t){null!=this._expObj&&(1!=this._isLinked&&null!=this._element._dataId&&(crsbinding.data.link(this._context,e,this._element._dataId,this._property,t),this._isLinked=!0),crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element,t)))}}const u=["INPUT","SELECT","TEXTAREA"];class f extends p{dispose(){this._element.removeEventListener(this._eventName,this._changeHandler),this._eventName=null,this._changeHandler=null,super.dispose()}async initialize(){await super.initialize(),this._changeHandler=this._change.bind(this),this._eventName=-1!==u.indexOf(this._element.nodeName)?"change":`${this._property}Change`,this._element.addEventListener(this._eventName,this._changeHandler)}_change(e){let t=e.target[this._property];const n=e.target.type||"text",i=`_${n}`;null!=this[i]&&(t=this[i](t,e.target)),crsbinding.data.setProperty(this._context,this._value,t,this._ctxName,"text"==n?"string":n),e.stopPropagation()}_number(e){return Number(e)}_date(e){return new Date(e)}_checkbox(e,t){return 1==t.checked}}function m(e,t){let n=e;if(-1==t.indexOf("."))return n[t];const i=t.split(".");for(let e=0;e<i.length-1;e++){if(n=n[i[e]],null==n)return null}return n[i[i.length-1]]}function x(e,t,n,i,s="context",r){return"context"==s?function(e,t,n,i){g(e,n,crsbinding.data.getValue(t,i))}(e,t,n,i):function(e,t,n,i,s){"context"!=s&&(i=i.split(`${s}.`).join(""));const r=crsbinding.data.getValue(t,i);g(e,n,r)}(e,t,n,i,s),null}function g(e,t,n){if(-1==t.indexOf("data-")){if("value"===(t=crsbinding.utils.capitalizePropertyPath(t))||"placeholder"===t)return;new Function("element","value",`element.${t} = value`)(e,n)}else{const i=t.replace("data-","");e.dataset[i]=n}}class v extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),this._eventHandler=this.event.bind(this),this._element.addEventListener(this._property,this._eventHandler)}dispose(){this._element.removeEventListener(this._property,this._eventHandler),this._eventHandler=null,this._fn=null,super.dispose()}async initialize(){let e=`context.${this._value}`.split("$event").join("event");-1==e.indexOf(")")&&(e=`${e}.call(context)`),this._fn=new Function("context",e)}event(e){const t=crsbinding.data.getContext(this._context);crsbinding.idleTaskManager.add(this._fn(t)),e.stopPropagation()}}class b extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),-1!=e.innerText.indexOf("$parent.")&&(e.innerText=e.innerText.split("$parent.").join(""),this._context=r),-1!=e.textContent.indexOf("$parent.")&&(e.textContent=e.textContent.split("$parent.").join(""),this._context=r),this._eventHandler=this._change.bind(this),this._expObj=crsbinding.expression.compile(e.innerText||e.textContent,null,{ctxName:this._ctxName});for(let e of this._expObj.parameters.properties)this.listenOnPath(e,this._eventHandler);this._change()}dispose(){crsbinding.expression.release(this._expObj),this._expObj=null,super.dispose(),this._eventHandler=null}_change(){if(null==this._expObj)return;const e=this._element.textContent?"textContent":"innerText";this._element[e]=this._expObj.function(this.data)}}class y extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r),this._eventHandler=this._change.bind(this),this._expObj=crsbinding.expression.compile(this._value,null,{ctxName:this._ctxName});for(let e of this._expObj.parameters.properties)this.listenOnPath(e,this._eventHandler);this._change()}dispose(){crsbinding.expression.release(this._expObj),this._expObj=null,super.dispose(),this._eventHandler=null}_change(){const e=this._expObj.function(this.data);this._element.setAttribute(this._property,e)}}class O extends a{dispose(){this._singular=null,this._plural=null,this._container=null,this._collectionChangedHandler=null,this.positionStruct.addAction=null,this.positionStruct.removeAction=null,this.positionStruct=null,super.dispose()}async initialize(){this._container=this._element.parentElement,this._shouldClearAll=1==this._container.children.length,this._determineInsertParameters();const e=this._value.split("of");this._singular=e[0].trim(),this._plural=e[1].trim(),this._collectionChangedHandler=this._collectionChanged.bind(this),this.listenOnPath(this._plural,this._collectionChangedHandler)}async _collectionChanged(e,t){if(null==t)return this._clear();this._renderItems(t)}_determineInsertParameters(){const e=this._element.nextElementSibling,t=this._element.previousElementSibling;this.positionStruct={startIndex:Array.from(this._container.children).indexOf(this._element),addAction:null!=e?this._insertBefore.bind(e):this._appendItems.bind(this._element),removeAction:()=>this._removeBetween.call(this._element,t,e)}}_appendItems(e){this.parentElement.appendChild(e)}_insertBefore(e){this.parentElement.insertBefore(e,this)}_removeBetween(e,t){const n=Array.from(this.parentElement.children);let i=n.indexOf(e),s=n.indexOf(t);-1==i&&(i=0),-1==s&&(s=n.length);const r=[];for(let e=i+1;e<s;e++)"TEMPLATE"!=n[e].nodeName&&r.push(n[e]);for(let e of r)e.parentElement.removeChild(e)}_clear(){1==this._shouldClearAll?this._clearAll():this._clearPartial()}_clearAll(){const e=Array.from(this._container.children).filter(e=>"TEMPLATE"!=e.nodeName);for(let t of e)t.parentElement.removeChild(t),crsbinding.observation.releaseBinding(t)}_clearPartial(){this.positionStruct.removeAction()}async _renderItems(){this._clear()}createElement(e,t){const n=crsbinding.data.createReferenceTo(this._context,`${this._context}-array-item-${t}`,this._plural,t),i=this._element.content.cloneNode(!0);crsbinding.parsers.parseElement(i,n,this._singular,this._context),e.__uid=n;for(let e of i.children)e.dataset.uid=n;return i}}class A extends O{init(){this._itemsAddedHandler=this._itemsAdded.bind(this),this._itemsDeletedHandler=this._itemsDeleted.bind(this)}dispose(){crsbinding.expression.release(this._forExp),this._forExp=null,this._itemsAddedHandler=null,this._itemsDeletedHandler=null,super.dispose()}async initialize(){super.initialize();this._forExp=crsbinding.expression.compile("for (let i = 0; i < context.length; i++) { callback(context[i], i) }",["callback"],{sanitize:!1,async:!0,ctxName:this._ctxName}),crsbinding.data.setArrayEvents(this._context,this._plural,this._itemsAddedHandler,this._itemsDeletedHandler)}async _renderItems(e){super._renderItems();const t=document.createDocumentFragment();await this._forExp.function(e,e=>{e.__aId=crsbinding.data.nextArrayId();const n=this.createElement(e,e.__aId);t.appendChild(n)}),this.positionStruct.addAction(t),null==this._container.__providers&&(this._container.__providers=[]),-1==this._container.__providers.indexOf(this.id)&&this._container.__providers.push(this.id)}_itemsAdded(e,t){for(let n=0;n<e.length;n++){const i=e[n],s=t.indexOf(i);i.__aId=crsbinding.data.nextArrayId();const r=this.createElement(i,i.__aId),l=r.children[0],a=this._container.children[s+this.positionStruct.startIndex+1];this._container.insertBefore(r,a);for(let e of l.__providers||[]){const t=crsbinding.providerManager.items.get(e);t instanceof y&&t._change()}}}_itemsDeleted(e,t){if(null==e)return;const n=[],i=Array.isArray(e)?e:[e];for(let e of i){const t=e.__uid;this._container.querySelectorAll([`[data-uid="${t}"]`]).forEach(e=>n.push(e)),crsbinding.data.removeObject(t)}for(let e of n)null!=e&&(e.parentElement.removeChild(e),crsbinding.observation.releaseBinding(e))}}class $ extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._sanitizeProperties=["fill","stroke"],this._eventHandler=this.propertyChanged.bind(this),-1==this._value.indexOf("?")?this._initCndAttr():-1!=this._value.indexOf(":")?this._initCndValue():this._initCndAttrValue(),this.propertyChanged()}_initCndAttr(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=j.split("__exp__").join(e.expression).split("__attr__").join(this._property).split("__attr-value__").join(this._property);this._expObj=crsbinding.expression.compile(t,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler)}_initCndValue(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=t[1].split(":"),i=this._sanitizeValue(n[0].trim()),s=this._sanitizeValue(n[1].trim()),r=I.split("__exp__").join(t[0].trim()).split("__attr__").join(this._property).split("__true__").join(i).split("__false__").join(s);this._expObj=crsbinding.expression.compile(r,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler)}_initCndAttrValue(){const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=j.split("__exp__").join(t[0].trim()).split("__attr__").join(this._property).split("__attr-value__").join(t[1].trim());this._expObj=crsbinding.expression.compile(n,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler),this.propertyChanged()}_sanitizeValue(e){return-1==this._sanitizeProperties.indexOf(this._property)?e:e.split("'").join("")}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}const j='\nif (__exp__) {\n element.setAttribute("__attr__", "__attr-value__");\n}\nelse {\n element.removeAttribute("__attr__");\n}\n',I='\nif (__exp__) {\n element.setAttribute("__attr__", "__true__");\n}\nelse {\n element.setAttribute("__attr__", "__false__");\n}\n';class E extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._eventHandler=this.propertyChanged.bind(this);const e=this._value.split("?"),t=crsbinding.expression.sanitize(e[0],this._ctxName),n=t.expression,i=e[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():"[]",l=d.split("__property__").join(this._property).split("__exp__").join(n).split("__true__").join(s).split("__false__").join(r);this._expObj=crsbinding.expression.compile(l,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(t.properties,this._eventHandler),this.propertyChanged()}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}class C extends a{constructor(e,t,n,i,s,r){super(e,t,n,i,s,r)}dispose(){crsbinding.expression.release(this._expObj),delete this._expObj,this._eventHandler=null,super.dispose()}async initialize(){this._eventHandler=this.propertyChanged.bind(this);const e=crsbinding.expression.sanitize(this._value,this._ctxName),t=e.expression.split("?"),n=t[0].trim(),i=t[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():'""',l="requestAnimationFrame(() => element.__property__ = (__exp__) ? __true__ : __false__)".split("__property__").join(crsbinding.utils.capitalizePropertyPath(this._property)).split("__exp__").join(n).split("__true__").join(s).split("__false__").join(r);this._expObj=crsbinding.expression.compile(l,["element"],{sanitize:!1,ctxName:this._ctxName}),this.listenOnPath(e.properties,this._eventHandler),this.propertyChanged()}propertyChanged(){try{crsbinding.idleTaskManager.add(this._expObj.function(this.data,this._element))}catch{return}}}class N extends O{dispose(){super.dispose()}async _renderItems(e){super._renderItems();const t=document.createDocumentFragment();e.forEach((e,n)=>{const i=this.createElement(e,n);e.__aId=n,t.appendChild(i)}),this.positionStruct.addAction(t),null==this._container.__providers&&(this._container.__providers=[]),-1==this._container.__providers.indexOf(this.id)&&this._container.__providers.push(this.id)}}class w{static bind(e,t,n,i,s,r,l){return-1!=["value","checked"].indexOf(n)?new f(e,t,n,i,s,l):this["one-way"](e,t,n,i,s,l)}static"two-way"(e,t,n,i,s,r,l){return new f(e,t,n,i,s,l)}static"one-way"(e,t,n,i,s,r,l){return new p(e,t,n,i,s,l)}static once(e,t,n,i,s,r,l){return x(e,t,n,i,s)}static call(e,t,n,i,s,r,l){return new v(e,t,n,i,s,l)}static delegate(e,t,n,i,s,r,l){return new v(e,t,n,i,s,l)}static inner(e,t,n,i,s,r,l){return new b(e,t,n,i,s,l)}static for(e,t,n,i,s,r,l){return r&&-1!=r.name.indexOf(".map")?new N(e,t,n,i,s,l):r&&-1!=r.name.indexOf(".once")?function(e,t,n,i,s="context",r){-1!=i.indexOf("$parent.")&&(i=i.split("$parent.").join(""),t=r);const l=i.split("of"),a=l[0].trim(),o=l[1].trim();crsbinding.inflationManager.register("for-once",e,a);const c=crsbinding.data.getValue(t,o),_=crsbinding.inflationManager.get("for-once",c);e.parentElement.appendChild(_),e.parentElement.removeChild(e),crsbinding.inflationManager.unregister("for-once")}(e,t,0,i,s,l):new A(e,t,n,i,s,l)}static if(e,t,n,i,s,r,l){return"classlist"==n.toLowerCase()?new E(e,t,n,i,s,l):-1!=n.toLowerCase().indexOf("style.")?new C(e,t,n,i,s,l):new $(e,t,n,i,s,l)}static attr(e,t,n,i,s,r,l){return new y(e,t,n,i,s,l)}}const z=["STYLE"];function P(e,t,n="context",i){for(let s of e||[])-1==z.indexOf(s.nodeName)&&T(s,t,n,i)}function T(e,t,n="context",i){P(e.children,t,n,i),function(e,t,n,i){for(let s of e)k(s,t,n,i)}(Array.from(e.attributes||[]).filter(e=>"TEMPLATE"==e.ownerElement.tagName&&"for"==e.name||-1!=e.name.indexOf(".")||0==(e.value||"").indexOf("${")),t,n,i),e.children&&0==e.children.length&&-1!=(e.innerText||e.textContent||"").indexOf("${")&&w.inner(e,t,null,null,n,null,i)}function k(e,t,n,i){const s=e.name.split(".");let r=2==s.length?s[0]:s.slice(0,s.length-1).join("."),l="for"==r?r:s[s.length-1];0==r.length&&"$"==e.value[0]&&(r=l,l="attr");const a=w[l](e.ownerElement,t,r,e.value,n,e,i);return null!=a&&"AttrProvider"==a.constructor.name||e.ownerElement.removeAttribute(e.nodeName),a}function H(e){crsbinding.providerManager.releaseElement(e)}globalThis.requestIdleCallback=globalThis.requestIdleCallback||function(e){const t=Date.now();return setTimeout((function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})}),1)},globalThis.cancelIdleCallback=globalThis.cancelIdleCallback||function(e){clearTimeout(e)};function L(e,t){this.addEventListener(e,t),this._domEvents.push({event:e,callback:t})}function S(e,t){const n=this._domEvents.find(n=>n.event==e&&n.callback==t);null!=n&&(this.removeEventListener(n.event,n.callback),this._domEvents.splice(this._domEvents.indexOf(n),1),n.callback=null,n.event=null)}class M{constructor(e){this.inflateSrc=[],this.deflateSrc=[],this._ctxName=e}dispose(){this.inflateSrc=null,this.deflateSrc=null}generateCodeFor(e){const t=e.content.children[0];this.path="element",this._processElement(t);const n=this.inflateSrc.join("\n"),i=this.deflateSrc.join("\n");return{inflate:new Function("element",this._ctxName,n),deflate:new Function("element",this._ctxName,i)}}_processElement(e){this._processInnerText(e),this._processAttributes(e);const t=this.path;for(let n=0;n<e.children.length;n++)this.path=`${t}.children[${n}]`,this._processElement(e.children[n])}_processInnerText(e){const t=(e.innerHTML||"").trim(),n=e.textContent?"textContent":"innerText";if(0==t.indexOf("${")){let e=t.substr(2,t.length-3);e=crsbinding.expression.sanitize(e,this._ctxName).expression,this.inflateSrc.push(`${this.path}.${n} = ${e};`),this.deflateSrc.push(`${this.path}.${n} = "";`)}}_processAttributes(e){const t=Array.from(e.attributes).filter(e=>-1!=e.value.indexOf("${")||-1!=e.name.indexOf(".if"));for(let e of t)-1!=e.value.indexOf("${")?this._processAttrValue(e):this._processAttrCondition(e)}_processAttrValue(e){const t=e.value.trim();let n=t.substr(2,t.length-3);if(n=crsbinding.expression.sanitize(n,this._ctxName).expression,"xlink:href"==e.name)this.inflateSrc.push(`${this.path}.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", ${n});`);else{const t=n.split("?");this.inflateSrc.push(`if (${t[0].trim()} != null) {${this.path}.setAttribute("${e.name}", ${n});}`)}this.deflateSrc.push(`${this.path}.removeAttribute("${e.name}");`),e.ownerElement.removeAttribute(e.name)}_processAttrCondition(e){return 0==e.name.trim().indexOf("style")?this._processStyle(e):0==e.name.trim().indexOf("classlist")?this._processClassList(e):-1!=e.name.trim().indexOf(".if")?this._processConditional(e):void 0}_processStyle(e){const t=e.name.split(".")[1],n=crsbinding.expression.sanitize(e.value.trim(),this._ctxName).expression;this.inflateSrc.push(`${this.path}.style.${t} = ${n};`),this.deflateSrc.push(`${this.path}.style.${t} = "";`),e.ownerElement.removeAttribute(e.name)}_processClassList(e){const t=e.value.split("?"),n=crsbinding.expression.sanitize(t[0],this._ctxName).expression,i=t[1].split(":"),s=i[0].trim(),r=i.length>1?i[1].trim():"",l=-1==s.indexOf("[")?s:`...${s}`;let a=`if (${n}) {${this.path}.classList.add(${l});}`;if(r.length>0){let e=-1==r.indexOf("[")?r:`...${r}`;a+=`else {${this.path}.classList.add(${e});}`}const o=`while (${this.path}.classList.length > 0) {${this.path}.classList.remove(${this.path}.classList.item(0));}`;this.inflateSrc.push(a),this.deflateSrc.push(o),e.ownerElement.removeAttribute(e.name)}_processConditional(e){const t=e.name.split(".if")[0].trim(),n=e.value.split("?");let i=[`if(${crsbinding.expression.sanitize(n[0].trim(),this._ctxName).expression})`];const s=n.length>1?n[1].trim():`"${t}"`;if(-1==s.indexOf(":"))i.push("{"),i.push(`${this.path}.setAttribute("${t}", ${s});`),i.push("}"),i.push(`else {${this.path}.removeAttribute("${t}")}`);else{const e=n[1].split(":");i.push("{"),i.push(`${this.path}.setAttribute("${t}", ${e[0].trim()});`),i.push("}"),i.push(`else {${this.path}.setAttribute("${t}", ${e[1].trim()})}`)}this.inflateSrc.push(i.join("")),this.deflateSrc.push(`${this.path}.removeAttribute("${t}")`),e.ownerElement.removeAttribute(e.name)}}const F=["pop","splice"],V=["push"];function R(e,t){const n=e[t];return"function"==typeof n?(...n)=>{const i=e[t](...n);return-1!=F.indexOf(t)?(!function(e,t){const n=e.__id,i=e.__property;crsbinding.data.arrayItemsRemoved(n,i,t,e)}(e,i),"splice"==t&&n.length>2&&(n=n.splice(2,n.length),D(e,n))):-1!=V.indexOf(t)&&D(e,n),i}:n}function D(e,t){const n=e.__id,i=e.__property;crsbinding.data.arrayItemsAdded(n,i,t,e)}const B=new Map,q=new Map,U=new Map,Q=new Map,X=new Map,Y={nextId:0,nextTriggerId:0,nextArrayId:0};function G(){return K("nextId")}function J(){return K("nextTriggerId")}function K(e){const t=Y[e];return Y[e]+=1,t}function W(e,t){ee(m(q.get(e),t),e,t)}function Z(e,t){"object"==typeof e&&(e=e.__uid||e._dataId);const n=q.get(e);if(null==t){const t=oe(n);for(let i of t)ee(n[i],e,i)}else{if(-1!=t.indexOf("."))return W(e,t);if(null==n)return;if(null==n[t])return;ee(n[t],e,t)}}function ee(e,t,n){if(null!=e.__functions)for(let i of e.__functions){i(n,_e.getValue(t,n))}if(null!=e.__trigger){const i=Q.get(e.__trigger);if(1!=i.frozen){i.frozen=!0;for(let e of i.values)e.id==t&&e.path==n||crsbinding.data.updateUI(e.id,e.path);delete i.frozen}}const i=oe(e);for(let s of i)ee(e[s],t,`${n}.${s}`)}function te(e,t,n){e[t]=e[t]||{},e[t].__functions=e[t].__functions||[],e[t].__functions.push(n)}function ne(e,t,n){let i=e;const s=t.split(".");for(let e=0;e<s.length-1;e++){const t=s[e];null==i[t]&&(i[t]={}),i=i[t]}n&&n(i,s[s.length-1])}function ie(e,t,n){return e[t]!==n&&(e[t]=n,!0)}function se(e,t,n){let i=!0;return ne(e,t,(e,t)=>i=ie(e,t,n)),i}function re(e,t,n,i){const s=U.get(n)||{},r=s[i]||{};r.originId==e&&r.originProperty==t||(r.originId=e,r.originProperty=t,s[i]=r,U.set(n,s))}function le(e,t){const n=Q.get(t),i=n.values.filter(t=>t.id==e);for(let e of i){const t=n.values.indexOf(e);n.values.splice(t,1)}}function ae(e,t,n,i,s,r){const l=e[t],a=n[i]=n[i]||{};if(null!=l.__trigger){a.__trigger=l.__trigger,Q.get(l.__trigger).values.push({id:s,path:r})}const o=oe(l);for(let e of o)ae(l,e,a,e,s,`${r}.${e}`)}function oe(e){return Object.getOwnPropertyNames(e).filter(e=>-1==e.indexOf("__"))}function ce(e){X.delete(e),function(e){(function(e){const t=Array.from(B).filter(t=>t[1].refId==e);for(let e of t)ce(e[1].id)})(e),B.delete(e),0==B.size&&(Y.nextId=0,Y.nextArrayId=0)}(e),function(e){q.delete(e)}(e),function(e){const t=Array.from(U).filter(t=>t[0]==e||t[1].value&&t[1].value.originId==e);for(let e of t)U.delete(e[0])}(e),function(e){const t=Array.from(Q);for(let n of t){const t=n[1].values.findIndex(t=>t.id==e);-1!=t&&(n[1].values.splice(t,1),0==n.values.length&&Q.delete(n[0]))}0==Q.size&&(Y.nextTriggerId=0)}(e)}const _e={details:{data:B,callbacks:q,updates:U,triggers:Q,context:X},link:function(e,t,n,i,s){"object"!=typeof s||null===s?(re(e,t,n,i),re(n,i,e,t),function(e,t,n,i){let s=q.get(e),r=q.get(n);const l=m(s,`${t}.__trigger`);if(null!=l){r[i]=r[i]||{},r[i].__trigger=l,Q.get(l).values.push({id:n,path:i})}}(e,t,n,i)):function(e,t,n,i){let s=q.get(e),r=q.get(n);-1==t.indexOf(".")?ae(s,t,r,i,n,i):ne(r,i,(e,r)=>{e[r]=e[r]||{};const l=t.split("."),a=l[l.length-1],o=l.splice(0,l.length-1).join();ae(m(s,o),a,e,r,n,i)})}(e,t,n,i)},setName(e,t){B.get(e).name=t},addObject(e,t={}){const n=G();return B.set(n,{id:n,name:e,type:"data",data:t}),q.set(n,{}),n},removeObject:ce,addContext(e,t){X.set(e,t)},addCallback(e,t,n){const i=q.get(e);return-1==t.indexOf(".")?te(i,t,n):function(e,t,n){ne(e,t,(e,t)=>{te(e,t,n)})}(i,t,n)},setProperty(e,t,n,i,s){"object"==typeof e&&(e=e.__uid||e._dataId);let r=B.get(e);if(("number"==s||null==s&&"object"!=typeof n&&0==isNaN(n))&&(n=Number(n)),"data"==r.type){r=B.get(e).data,1==(-1==t.indexOf(".")?ie(r,t,n):se(r,t,n))&&(!function(e,t,n){const i=U.get(e);null!=i&&null!=i[t]&&_e.setProperty(i[t].originId,i[t].originProperty,n)}(e,t,n),Z(e,t))}else this.setReferenceValue(e,t,n,r.refId,r.path,r.aId,i)},getValue(e,t){const n=B.get(e);if("data"==n.type){const e=n.data;return null==t?e:-1==t.indexOf(".")?function(e,t){return e[t]}(e,t):function(e,t){return new Function("context",`try {return context.${t}} catch {return null}`)(e)}(e,t)}{const e=n.refId;return this.getReferenceValue(e,t,n.path,n.aId)}},getContext:e=>X.get(e),getReferenceValue(e,t,n,i){const s=B.get(e);if("data"==s.type){if(void 0===i){const i=null==t?n:`${n}.${t}`;return this.getValue(e,i)}{const s=this.getValue(e,n);let r;if(Array.isArray(s))r=s.find(e=>e.__aId==i);else{const e=s.get(i);r={key:i,value:e}}return null==t||null==r?r:m(r,t)}}{let e=`${s.path}.${n}`;return this.getReferenceValue(s.refId,t,e)}},setReferenceValue(e,t,n,i,s,r,l){const a=B.get(i);if("data"!=a.type){let e=`${a.path}.${path}`;return this.getReferenceValue(a.refId,t,e)}{let i=m(a.data,s);null!=r&&(i=i.find(e=>e.__aId==r)),"context"!=l&&(t=t.split(`${l}.`).join("")),se(i,t,n),W(e,t)}},createReferenceTo:function(e,t,n,i){const s=G(),r={id:s,name:t,type:"ref",refId:e,path:n};return void 0!==i&&(r.aId=i),B.set(s,r),q.set(s,{}),s},clear(){B.forEach((e,t)=>{delete e.data}),B.clear(),Y.nextId=0,Y.nextArrayId=0},makeShared:function(e,t,n){const i=q.get(e);for(let s of n){const n=`${t}.${s}`;ne(i,n,(t,i)=>{null==t[i]&&(t[i]={});const s=J();Q.set(s,{values:[{id:e,path:n}]}),t[i].__trigger=s})}},updateUI:Z,array(e,t){return"object"==typeof e&&(e=e._dataId),function(e,t,n){return null==e?null:(e.__id=t,e.__property=n,new Proxy(e,{get:R}))}(this.getValue(e,t),e,t)},setArrayEvents:function(e,t,n,i){ne(q.get(e),t,(e,t)=>{e[t]=e[t]||{},e[t].__itemsAdded=e[t].itemsAdded||[],e[t].__itemsAdded.push(n),e[t].__itemsDeleted=e[t].itemsDeleted||[],e[t].__itemsDeleted.push(i)})},notifyArrayItemsAdded:function(e,t){crsbinding.data.arrayItemsAdded(e.__id,e.__property,Array.isArray(t)?t:[t],e)},notifyArrayItemsRemoved:function(e,t){crsbinding.data.arrayItemsRemoved(e.__id,e.__property,Array.isArray(t)?t:[t],e)},arrayItemsAdded:function(e,t,n,i){const s=m(q.get(e),t);for(let e of s.__itemsAdded||[])e(n,i)},arrayItemsRemoved:function(e,t,n,i){const s=m(q.get(e),t);for(let e of s.__itemsDeleted||[])e(n,i)},linkToArrayItem:function(e,t,n){let i=m(q.get(e),t);if(null==i)return;let s=q.get(n);const r=oe(i);for(let e of r)ae(i,e,s,e,n,e)},unlinkArrayItem:function(e){!function e(t,n){const i=oe(t);for(let s of i){const i=t[s].__trigger;null!=i&&(delete t[s].__trigger,le(n,i)),"object"==typeof t[s]&&e(t[s])}}(q.get(e.__uid),e.__uid)},nextArrayId:function(){return K("nextArrayId")}};String.prototype.capitalize=function(){return this.charAt(0).toUpperCase()+this.slice(1)};const he={_expFn:new Map,data:_e,idleTaskManager:new class{constructor(){this.processing=!1,this._list=[]}dispose(){this._list=null}add(e){e&&this._list.push(e),!this.processing&&this._processQueue()}_processQueue(){if(null==requestIdleCallback)return this._runNextFunction();this.processing=!0,requestIdleCallback(e=>{for(;(e.timeRemaining()>0||e.didTimeout)&&this._list.length;)this._runNextFunction();this.processing=!1},{timeout:1e3})}_runNextFunction(){let e=this._list.shift();e&&e()}},providerManager:new class{constructor(){this._nextId=0,this.items=new Map}async register(e){e.id=this._nextId,null==e._element.__providers&&Reflect.set(e._element,"__providers",[]),e._element.__providers.push(this._nextId),this.items.set(this._nextId,e),this._nextId+=1}async releaseElement(e){for(let t of e.children||[])await this.releaseElement(t);if(null!=e.__providers){for(let t of e.__providers){const e=this.items.get(t);this.items.delete(t),e&&e.dispose()}e.__providers=null,0==this.items.size&&(this._nextId=0)}}},inflationManager:new class{constructor(){this._items=new Map}dispose(){this._items.clear(),this._items=null}register(e,t,n="context"){const i=new M(n),s=i.generateCodeFor(t);i.dispose(),this._items.set(e,{template:t,inflate:s.inflate,deflate:s.deflate})}unregister(e){const t=this._items.get(e);null!=t&&(t.template=null,t.inflate=null,t.defaulte=null,this._items.delete(e))}get(e,t){const n=this._items.get(e);if(null==n)return null;const i=document.createDocumentFragment();for(let s of t){const t=n.template.content.cloneNode(!0);this.inflate(e,t.children[0],s,n.inflate),i.appendChild(t)}return i}inflate(e,t,n,i=null){(i||this._items.get(e).inflate)(t,n)}deflate(e,t){const n=this._items.get(e).deflate;if(Array.isArray(t))for(let e of t)n(e);else n(t)}},valueConverters:new class{constructor(){this._converters=new Map}dispose(){this._converters.clear(),this._converters=null}register(e,t){this._converters.set(e,t)}unregister(e){this._converters.delete(e)}convertTo(e,t){const n=this._converters.get(e);return null==n?t:n.convertTo(t)}convertBack(e,t){const n=this._converters.get(e);return null==n?t:n.convertBack(t)}},expression:{sanitize:function(e,a="context"){const o="context"!=a,c=`${a}.`,_=function(e,t){let i=[],s=[],a=!1;for(let t=0;t<e.length;t++){const o=e[t];1==a&&"$"==o&&"{"==e[t+1]&&(a=!1),1==a?-1==r.indexOf(o)?s.push(o):(l(i,s,o),a=!1):-1!=n.indexOf(o)?(l(i,s,o),-1!=r.indexOf(o)&&(a=!0)):s.push(o)}s.length>0&&i.push(s.join(""));null!=t&&(i=function e(t,n){const i=t.indexOf(n);if(-1==i)return t;"."==t[i+1]&&(t.splice(i,2),-1!=t.indexOf(n)&&e(t,n));return t}(i,t));return i}(e,o?a:null);if(1==_.length)return{isLiteral:!1,expression:`${c}${_[0]}`,properties:[e]};const h=[],d=-1!=e.indexOf("${");let p=null,u=[],f=[];for(let e=0;e<_.length;e++){const r=_[e];-1!=s.indexOf(p)||-1!=n.indexOf(r)&&-1==i.indexOf(r)?(p=r,u.length>0&&(0!=d&&"}"!=p||isNaN(u)&&(f.push(e-u.length),h.push(t(`${u.join("")}`))),u.length=0)):(u.push(r),p=r)}o&&u.length>0&&(0!=d&&"}"!=p||isNaN(u)&&(f.push(_.length-1),h.push(t(`${u.join("")}`)))),0==f.length&&-1!=e.indexOf(".")&&f.push(0);for(let e=0;e<f.length;e++)_.splice(e+f[e],0,c);return{isLiteral:d,expression:_.join(""),properties:h}},compile:function(t,n,i){n=n||[];let s=!0,r=!1,l="context";if(null!=i&&(null!=i.sanitize&&(s=i.sanitize),null!=i.async&&(r=i.async),null!=i.ctxName&&(l=i.ctxName)),crsbinding._expFn.has(t)){const e=crsbinding._expFn.get(t);return e.count+=1,e}let a,o=t;if(1==s){if(a=crsbinding.expression.sanitize(t,l),crsbinding._expFn.has(a.expression)){const e=crsbinding._expFn.get(a.expression);return e.count+=1,e}o=!0===a.isLiteral?["return `",a.expression,"`"].join(""):`return ${a.expression}`,a.expression.split(".").length>2&&(o=`try { ${o} } catch(error) { return null }`)}else a={expression:t};const c={function:1==r?new e(l,...n,o):new Function(l,...n,o),parameters:a,count:1};return crsbinding._expFn.set(a.expression,c),c},release:function(e){if(null==e||"object"!=typeof e)return;const t=e.parameters.expression;if(crsbinding._expFn.has(t)){const e=crsbinding._expFn.get(t);e.count-=1,0==e.count&&(e.function=null,e.parameters=null,crsbinding._expFn.delete(t))}}},observation:{releaseBinding:H,releaseChildBinding:function(e){for(let t of e.children)H(t)}},parsers:{parseElement:T,parseElements:P},events:{listenOn:function(e,t,n){-1==t.indexOf(".")?crsbinding.events.on(e,t.trim(),n):crsbinding.events.listenOnPath(e,t,n)},listenOnPath:function(e,t,n){t.split(".")}},dom:{enableEvents:function(e){e._domEvents=[],e.registerEvent=L,e.unregisterEvent=S},disableEvents:function(e){if(null!=e._domEvents){for(let t of e._domEvents)t.callback=null,t.event=null;e._domEvents.length=0,delete e._domEvents,delete e.registerEvent,delete e.unregisterEvent}}},utils:{capitalizePropertyPath:function(e){const t=e.split("-");for(let e=1;e<t.length;e++)t[e]=t[e].capitalize();return t.join("")},clone:function(e){return null==e?e:function e(t){let n=Object.getOwnPropertyNames(t).filter(e=>0==e.indexOf("__"));for(let e of n)delete t[e];n=Object.getOwnPropertyNames(t).filter(e=>-1==e.indexOf("__")&&"object"==typeof t[e]);for(let i of n)e(t[i]);return t}(Object.assign({},e))},disposeProperties:function e(t){const n=Object.getOwnPropertyNames(t).filter(e=>t[e]&&1==t[e].__isProxy);for(let i of n){const n=t[i];1!=Array.isArray(n)&&e(n),delete t[i]}}}};globalThis.crsbinding=he;export{he as crsbinding}; |
{ | ||
"name": "crs-binding", | ||
"version": "0.0.116", | ||
"version": "0.0.118", | ||
"description": "zero dependency binding engine", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
36985
139
5