/**
 * @fileoverview
 * @suppress {checkPrototypalTypes}
 * @license Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
 * This code may only be used under the BSD style license found at
 * http://polymer.github.io/LICENSE.txt The complete set of authors may be found
 * at http://polymer.github.io/AUTHORS.txt The complete set of contributors may
 * be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by
 * Google as part of the polymer project is also subject to an additional IP
 * rights grant found at http://polymer.github.io/PATENTS.txt
 */
import"../utils/boot.js";import{wrap as t}from"../utils/wrap.js";import{dedupingMixin as e}from"../utils/mixin.js";import{root as r,isAncestor as i,isDescendant as n,get as s,translate as a,isPath as o,set as l,normalize as d}from"../utils/path.js";import{camelToDashCase as f,dashToCamelCase as h}from"../utils/case-map.js";import{PropertyAccessors as _}from"./property-accessors.js";import{TemplateStamp as p}from"./template-stamp.js";import{sanitizeDOMValue as c,legacyUndefined as u,orderedComputed as g,removeNestedTemplates as m,fastDomIf as P}from"../utils/settings.js";let y=0;const E=[],C={COMPUTE:"__computeEffects",REFLECT:"__reflectEffects",NOTIFY:"__notifyEffects",PROPAGATE:"__propagateEffects",OBSERVE:"__observeEffects",READ_ONLY:"__readOnly"},b="__computeInfo",O=/[A-Z]/;function ensureOwnEffectMap(t,e,r){let i=t[e];if(i){if(!t.hasOwnProperty(e)&&(i=t[e]=Object.create(t[e]),r))for(let t in i){let e=i[t],r=i[t]=Array(e.length);for(let t=0;t<e.length;t++)r[t]=e[t]}}else i=t[e]={};return i}function runEffects(t,e,i,n,s,a){if(e){let o=!1;const l=y++;for(let d in i){let f=e[s?r(d):d];if(f)for(let e,r=0,h=f.length;r<h&&(e=f[r]);r++)e.info&&e.info.lastRun===l||s&&!pathMatchesTrigger(d,e.trigger)||(e.info&&(e.info.lastRun=l),e.fn(t,d,i,n,e.info,s,a),o=!0)}return o}return!1}function runEffectsForProperty(t,e,i,n,s,a,o,l){let d=!1,f=e[o?r(n):n];if(f)for(let e,r=0,h=f.length;r<h&&(e=f[r]);r++)e.info&&e.info.lastRun===i||o&&!pathMatchesTrigger(n,e.trigger)||(e.info&&(e.info.lastRun=i),e.fn(t,n,s,a,e.info,o,l),d=!0);return d}function pathMatchesTrigger(t,e){if(e){let r=e.name;return r==t||!(!e.structured||!i(r,t))||!(!e.wildcard||!n(r,t))}return!0}function runObserverEffect(t,e,r,i,n){let s="string"==typeof n.method?t[n.method]:n.method,a=n.property;s?s.call(t,t.__data[a],i[a]):n.dynamicFn||console.warn("observer method `"+n.method+"` not defined")}function notifyPath(t,e,i){let n=r(e);if(n!==e){return dispatchNotifyEvent(t,f(n)+"-changed",i[e],e),!0}return!1}function dispatchNotifyEvent(e,r,i,n){let s={value:i,queueProperty:!0};n&&(s.path=n),t(e).dispatchEvent(new CustomEvent(r,{detail:s}))}function runNotifyEffect(t,e,i,n,a,o){let l=(o?r(e):e)!=e?e:null,d=l?s(t,l):t.__data[e];l&&void 0===d&&(d=i[e]),dispatchNotifyEvent(t,a.eventName,d,l)}function runReflectEffect(t,e,r,i,n){let s=t.__data[e];c&&(s=c(s,n.attrName,"attribute",t)),t._propertyToAttribute(e,n.attrName,s)}function runComputedEffects(t,e,r,i){let n=t[C.COMPUTE];if(n)if(g){y++;const s=function getComputedOrder(t){let e=t.constructor.__orderedComputedDeps;if(!e){e=new Map;const r=t[C.COMPUTE];let i,{counts:n,ready:s,total:a}=function dependencyCounts(t){const e=t[b],r={},i=t[C.COMPUTE],n=[];let s=0;for(let t in e){const i=e[t];s+=r[t]=i.args.filter((t=>!t.literal)).length+(i.dynamicFn?1:0)}for(let t in i)e[t]||n.push(t);return{counts:r,ready:n,total:s}}(t);for(;i=s.shift();){e.set(i,e.size);const t=r[i];t&&t.forEach((t=>{const e=t.info.methodInfo;--a,0==--n[e]&&s.push(e)}))}if(0!==a){const e=t;console.warn(`Computed graph for ${e.localName} incomplete; circular?`)}t.constructor.__orderedComputedDeps=e}return e}(t),a=[];for(let t in e)enqueueEffectsFor(t,n,a,s,i);let o;for(;o=a.shift();)runComputedEffect(t,"",e,r,o)&&enqueueEffectsFor(o.methodInfo,n,a,s,i);Object.assign(r,t.__dataOld),Object.assign(e,t.__dataPending),t.__dataPending=null}else{let s=e;for(;runEffects(t,n,s,r,i);)Object.assign(r,t.__dataOld),Object.assign(e,t.__dataPending),s=t.__dataPending,t.__dataPending=null}}const insertEffect=(t,e,r)=>{let i=0,n=e.length-1,s=-1;for(;i<=n;){const a=i+n>>1,o=r.get(e[a].methodInfo)-r.get(t.methodInfo);if(o<0)i=a+1;else{if(!(o>0)){s=a;break}n=a-1}}s<0&&(s=n+1),e.splice(s,0,t)},enqueueEffectsFor=(t,e,i,n,s)=>{const a=e[s?r(t):t];if(a)for(let e=0;e<a.length;e++){const r=a[e];r.info.lastRun===y||s&&!pathMatchesTrigger(t,r.trigger)||(r.info.lastRun=y,insertEffect(r.info,i,n))}};function runComputedEffect(t,e,r,i,n){let s=runMethodEffect(t,e,r,i,n);if(s===E)return!1;let a=n.methodInfo;return t.__dataHasAccessor&&t.__dataHasAccessor[a]?t._setPendingProperty(a,s,!0):(t[a]=s,!1)}function addBinding(t,e,r,i,n,s,a){r.bindings=r.bindings||[];let o={kind:i,target:n,parts:s,literal:a,isCompound:1!==s.length};if(r.bindings.push(o),function shouldAddListener(t){return Boolean(t.target)&&"attribute"!=t.kind&&"text"!=t.kind&&!t.isCompound&&"{"===t.parts[0].mode}(o)){let{event:t,negate:e}=o.parts[0];o.listenerEvent=t||f(n)+"-changed",o.listenerNegate=e}let l=e.nodeInfoList.length;for(let r=0;r<o.parts.length;r++){let i=o.parts[r];i.compoundIndex=r,addEffectForBindingPart(t,e,o,i,l)}}function addEffectForBindingPart(t,e,r,i,n){if(!i.literal)if("attribute"===r.kind&&"-"===r.target[0])console.warn("Cannot set attribute "+r.target+' because "-" is not a valid attribute starting character');else{let s=i.dependencies,a={index:n,binding:r,part:i,evaluator:t};for(let r=0;r<s.length;r++){let i=s[r];"string"==typeof i&&(i=parseArg(i),i.wildcard=!0),t._addTemplatePropertyEffect(e,i.rootProperty,{fn:runBindingEffect,info:a,trigger:i})}}}function runBindingEffect(t,e,r,i,n,s,o){let l=o[n.index],d=n.binding,f=n.part;if(s&&f.source&&e.length>f.source.length&&"property"==d.kind&&!d.isCompound&&l.__isPropertyEffectsClient&&l.__dataHasAccessor&&l.__dataHasAccessor[d.target]){let i=r[e];e=a(f.source,d.target,e),l._setPendingPropertyOrPath(e,i,!1,!0)&&t._enqueueClient(l)}else{let a=n.evaluator._evaluateBinding(t,f,e,r,i,s);a!==E&&function applyBindingValue(t,e,r,i,n){n=function computeBindingValue(t,e,r,i){if(r.isCompound){let n=t.__dataCompoundStorage[r.target];n[i.compoundIndex]=e,e=n.join("")}"attribute"!==r.kind&&("textContent"!==r.target&&("value"!==r.target||"input"!==t.localName&&"textarea"!==t.localName)||(e=null==e?"":e));return e}(e,n,r,i),c&&(n=c(n,r.target,r.kind,e));if("attribute"==r.kind)t._valueToNodeAttribute(e,n,r.target);else{let i=r.target;e.__isPropertyEffectsClient&&e.__dataHasAccessor&&e.__dataHasAccessor[i]?e[C.READ_ONLY]&&e[C.READ_ONLY][i]||e._setPendingProperty(i,n)&&t._enqueueClient(e):t._setUnmanagedPropertyToNode(e,i,n)}}(t,l,d,f,a)}}function setupCompoundStorage(e,r){if(r.isCompound){let i=e.__dataCompoundStorage||(e.__dataCompoundStorage={}),n=r.parts,s=new Array(n.length);for(let t=0;t<n.length;t++)s[t]=n[t].literal;let a=r.target;i[a]=s,r.literal&&"property"==r.kind&&("className"===a&&(e=t(e)),e[a]=r.literal)}}function addNotifyListener(t,e,r){if(r.listenerEvent){let i=r.parts[0];t.addEventListener(r.listenerEvent,(function(t){!function handleNotification(t,e,r,i,n){let s,o=t.detail,l=o&&o.path;l?(i=a(r,i,l),s=o&&o.value):s=t.currentTarget[r],s=n?!s:s,e[C.READ_ONLY]&&e[C.READ_ONLY][i]||!e._setPendingPropertyOrPath(i,s,!0,Boolean(l))||o&&o.queueProperty||e._invalidateProperties()}(t,e,r.target,i.source,i.negate)}))}}function createMethodEffect(t,e,r,i,n,s){s=e.static||s&&("object"!=typeof s||s[e.methodName]);let a={methodName:e.methodName,args:e.args,methodInfo:n,dynamicFn:s};for(let n,s=0;s<e.args.length&&(n=e.args[s]);s++)n.literal||t._addPropertyEffect(n.rootProperty,r,{fn:i,info:a,trigger:n});return s&&t._addPropertyEffect(e.methodName,r,{fn:i,info:a}),a}function runMethodEffect(t,e,r,i,n){let s=t._methodHost||t,a=s[n.methodName];if(a){let i=t._marshalArgs(n.args,e,r);return i===E?E:a.apply(s,i)}n.dynamicFn||console.warn("method `"+n.methodName+"` not defined")}const N=[],T="(?:[a-zA-Z_$][\\w.:$\\-*]*)",v="(?:("+T+"|(?:[-+]?[0-9]*\\.?[0-9]+(?:[eE][-+]?[0-9]+)?)|(?:(?:'(?:[^'\\\\]|\\\\.)*')|(?:\"(?:[^\"\\\\]|\\\\.)*\")))\\s*)",A=new RegExp("(\\[\\[|{{)\\s*(?:(!)\\s*)?"+("("+T+"\\s*"+("(?:\\(\\s*(?:"+("(?:"+v+"(?:,\\s*"+v+")*)")+"?)\\)\\s*)")+"?)")+"(?:]]|}})","g");function literalFromParts(t){let e="";for(let r=0;r<t.length;r++){e+=t[r].literal||""}return e}function parseMethod(t){let e=t.match(/([^\s]+?)\(([\s\S]*)\)/);if(e){let t={methodName:e[1],static:!0,args:N};if(e[2].trim()){return function parseArgs(t,e){return e.args=t.map((function(t){let r=parseArg(t);return r.literal||(e.static=!1),r}),this),e}(e[2].replace(/\\,/g,"&comma;").split(","),t)}return t}return null}function parseArg(t){let e=t.trim().replace(/&comma;/g,",").replace(/\\(.)/g,"$1"),i={name:e,value:"",literal:!1},n=e[0];switch("-"===n&&(n=e[1]),n>="0"&&n<="9"&&(n="#"),n){case"'":case'"':i.value=e.slice(1,-1),i.literal=!0;break;case"#":i.value=Number(e),i.literal=!0}return i.literal||(i.rootProperty=r(e),i.structured=o(e),i.structured&&(i.wildcard=".*"==e.slice(-2),i.wildcard&&(i.name=e.slice(0,-2)))),i}function getArgValue(t,e,r){let i=s(t,r);return void 0===i&&(i=e[r]),i}function notifySplices(t,e,r,i){const n={indexSplices:i};u&&!t._overrideLegacyUndefined&&(e.splices=n),t.notifyPath(r+".splices",n),t.notifyPath(r+".length",e.length),u&&!t._overrideLegacyUndefined&&(n.indexSplices=[])}function notifySplice(t,e,r,i,n,s){notifySplices(t,e,r,[{index:i,addedCount:n,removed:s,object:e,type:"splice"}])}export const PropertyEffects=e((e=>{const i=p(_(e));return class PropertyEffects extends i{constructor(){super(),this.__isPropertyEffectsClient=!0,this.__dataClientsReady,this.__dataPendingClients,this.__dataToNotify,this.__dataLinkedPaths,this.__dataHasPaths,this.__dataCompoundStorage,this.__dataHost,this.__dataTemp,this.__dataClientsInitialized,this.__data,this.__dataPending,this.__dataOld,this.__computeEffects,this.__computeInfo,this.__reflectEffects,this.__notifyEffects,this.__propagateEffects,this.__observeEffects,this.__readOnly,this.__templateInfo,this._overrideLegacyUndefined}get PROPERTY_EFFECT_TYPES(){return C}_initializeProperties(){super._initializeProperties(),this._registerHost(),this.__dataClientsReady=!1,this.__dataPendingClients=null,this.__dataToNotify=null,this.__dataLinkedPaths=null,this.__dataHasPaths=!1,this.__dataCompoundStorage=this.__dataCompoundStorage||null,this.__dataHost=this.__dataHost||null,this.__dataTemp={},this.__dataClientsInitialized=!1}_registerHost(){if(R.length){let t=R[R.length-1];t._enqueueClient(this),this.__dataHost=t}}_initializeProtoProperties(t){this.__data=Object.create(t),this.__dataPending=Object.create(t),this.__dataOld={}}_initializeInstanceProperties(t){let e=this[C.READ_ONLY];for(let r in t)e&&e[r]||(this.__dataPending=this.__dataPending||{},this.__dataOld=this.__dataOld||{},this.__data[r]=this.__dataPending[r]=t[r])}_addPropertyEffect(t,e,r){this._createPropertyAccessor(t,e==C.READ_ONLY);let i=ensureOwnEffectMap(this,e,!0)[t];i||(i=this[e][t]=[]),i.push(r)}_removePropertyEffect(t,e,r){let i=ensureOwnEffectMap(this,e,!0)[t],n=i.indexOf(r);n>=0&&i.splice(n,1)}_hasPropertyEffect(t,e){let r=this[e];return Boolean(r&&r[t])}_hasReadOnlyEffect(t){return this._hasPropertyEffect(t,C.READ_ONLY)}_hasNotifyEffect(t){return this._hasPropertyEffect(t,C.NOTIFY)}_hasReflectEffect(t){return this._hasPropertyEffect(t,C.REFLECT)}_hasComputedEffect(t){return this._hasPropertyEffect(t,C.COMPUTE)}_setPendingPropertyOrPath(t,e,i,o){if(o||r(Array.isArray(t)?t[0]:t)!==t){if(!o){let r=s(this,t);if(!(t=l(this,t,e))||!super._shouldPropertyChange(t,e,r))return!1}if(this.__dataHasPaths=!0,this._setPendingProperty(t,e,i))return function computeLinkedPaths(t,e,r){let i=t.__dataLinkedPaths;if(i){let s;for(let o in i){let l=i[o];n(o,e)?(s=a(o,l,e),t._setPendingPropertyOrPath(s,r,!0,!0)):n(l,e)&&(s=a(l,o,e),t._setPendingPropertyOrPath(s,r,!0,!0))}}}(this,t,e),!0}else{if(this.__dataHasAccessor&&this.__dataHasAccessor[t])return this._setPendingProperty(t,e,i);this[t]=e}return!1}_setUnmanagedPropertyToNode(e,r,i){i===e[r]&&"object"!=typeof i||("className"===r&&(e=t(e)),e[r]=i)}_setPendingProperty(t,e,r){let i=this.__dataHasPaths&&o(t),n=i?this.__dataTemp:this.__data;return!!this._shouldPropertyChange(t,e,n[t])&&(this.__dataPending||(this.__dataPending={},this.__dataOld={}),t in this.__dataOld||(this.__dataOld[t]=this.__data[t]),i?this.__dataTemp[t]=e:this.__data[t]=e,this.__dataPending[t]=e,(i||this[C.NOTIFY]&&this[C.NOTIFY][t])&&(this.__dataToNotify=this.__dataToNotify||{},this.__dataToNotify[t]=r),!0)}_setProperty(t,e){this._setPendingProperty(t,e,!0)&&this._invalidateProperties()}_invalidateProperties(){this.__dataReady&&this._flushProperties()}_enqueueClient(t){this.__dataPendingClients=this.__dataPendingClients||[],t!==this&&this.__dataPendingClients.push(t)}_flushClients(){this.__dataClientsReady?this.__enableOrFlushClients():(this.__dataClientsReady=!0,this._readyClients(),this.__dataReady=!0)}__enableOrFlushClients(){let t=this.__dataPendingClients;if(t){this.__dataPendingClients=null;for(let e=0;e<t.length;e++){let r=t[e];r.__dataEnabled?r.__dataPending&&r._flushProperties():r._enableProperties()}}}_readyClients(){this.__enableOrFlushClients()}setProperties(t,e){for(let r in t)!e&&this[C.READ_ONLY]&&this[C.READ_ONLY][r]||this._setPendingPropertyOrPath(r,t[r],!0);this._invalidateProperties()}ready(){this._flushProperties(),this.__dataClientsReady||this._flushClients(),this.__dataPending&&this._flushProperties()}_propertiesChanged(t,e,r){let i,n=this.__dataHasPaths;this.__dataHasPaths=!1,runComputedEffects(this,e,r,n),i=this.__dataToNotify,this.__dataToNotify=null,this._propagatePropertyChanges(e,r,n),this._flushClients(),runEffects(this,this[C.REFLECT],e,r,n),runEffects(this,this[C.OBSERVE],e,r,n),i&&function runNotifyEffects(t,e,r,i,n){let s,a,o=t[C.NOTIFY],l=y++;for(let a in e)e[a]&&(o&&runEffectsForProperty(t,o,l,a,r,i,n)||n&&notifyPath(t,a,r))&&(s=!0);s&&(a=t.__dataHost)&&a._invalidateProperties&&a._invalidateProperties()}(this,i,e,r,n),1==this.__dataCounter&&(this.__dataTemp={})}_propagatePropertyChanges(t,e,r){this[C.PROPAGATE]&&runEffects(this,this[C.PROPAGATE],t,e,r),this.__templateInfo&&this._runEffectsForTemplate(this.__templateInfo,t,e,r)}_runEffectsForTemplate(t,e,r,i){const baseRunEffects=(e,i)=>{runEffects(this,t.propertyEffects,e,r,i,t.nodeList);for(let n=t.firstChild;n;n=n.nextSibling)this._runEffectsForTemplate(n,e,r,i)};t.runEffects?t.runEffects(baseRunEffects,e,i):baseRunEffects(e,i)}linkPaths(t,e){t=d(t),e=d(e),this.__dataLinkedPaths=this.__dataLinkedPaths||{},this.__dataLinkedPaths[t]=e}unlinkPaths(t){t=d(t),this.__dataLinkedPaths&&delete this.__dataLinkedPaths[t]}notifySplices(t,e){let r={path:""};notifySplices(this,s(this,t,r),r.path,e)}get(t,e){return s(e||this,t)}set(t,e,r){r?l(r,t,e):this[C.READ_ONLY]&&this[C.READ_ONLY][t]||this._setPendingPropertyOrPath(t,e,!0)&&this._invalidateProperties()}push(t,...e){let r={path:""},i=s(this,t,r),n=i.length,a=i.push(...e);return e.length&&notifySplice(this,i,r.path,n,e.length,[]),a}pop(t){let e={path:""},r=s(this,t,e),i=Boolean(r.length),n=r.pop();return i&&notifySplice(this,r,e.path,r.length,0,[n]),n}splice(t,e,r,...i){let n,a={path:""},o=s(this,t,a);return e<0?e=o.length-Math.floor(-e):e&&(e=Math.floor(e)),n=2===arguments.length?o.splice(e):o.splice(e,r,...i),(i.length||n.length)&&notifySplice(this,o,a.path,e,i.length,n),n}shift(t){let e={path:""},r=s(this,t,e),i=Boolean(r.length),n=r.shift();return i&&notifySplice(this,r,e.path,0,0,[n]),n}unshift(t,...e){let r={path:""},i=s(this,t,r),n=i.unshift(...e);return e.length&&notifySplice(this,i,r.path,0,e.length,[]),n}notifyPath(t,e){let r;if(1==arguments.length){let i={path:""};e=s(this,t,i),r=i.path}else r=Array.isArray(t)?d(t):t;this._setPendingPropertyOrPath(r,e,!0,!0)&&this._invalidateProperties()}_createReadOnlyProperty(t,e){this._addPropertyEffect(t,C.READ_ONLY),e&&(this["_set"+function upper(t){return t[0].toUpperCase()+t.substring(1)}(t)]=function(e){this._setProperty(t,e)})}_createPropertyObserver(t,e,r){let i={property:t,method:e,dynamicFn:Boolean(r)};this._addPropertyEffect(t,C.OBSERVE,{fn:runObserverEffect,info:i,trigger:{name:t}}),r&&this._addPropertyEffect(e,C.OBSERVE,{fn:runObserverEffect,info:i,trigger:{name:e}})}_createMethodObserver(t,e){let r=parseMethod(t);if(!r)throw new Error("Malformed observer expression '"+t+"'");createMethodEffect(this,r,C.OBSERVE,runMethodEffect,null,e)}_createNotifyingProperty(t){this._addPropertyEffect(t,C.NOTIFY,{fn:runNotifyEffect,info:{eventName:f(t)+"-changed",property:t}})}_createReflectedProperty(t){let e=this.constructor.attributeNameForProperty(t);"-"===e[0]?console.warn("Property "+t+" cannot be reflected to attribute "+e+' because "-" is not a valid starting attribute name. Use a lowercase first letter for the property instead.'):this._addPropertyEffect(t,C.REFLECT,{fn:runReflectEffect,info:{attrName:e}})}_createComputedProperty(t,e,r){let i=parseMethod(e);if(!i)throw new Error("Malformed computed expression '"+e+"'");const n=createMethodEffect(this,i,C.COMPUTE,runComputedEffect,t,r);ensureOwnEffectMap(this,b)[t]=n}_marshalArgs(t,e,r){const i=this.__data,a=[];for(let o=0,l=t.length;o<l;o++){let{name:l,structured:d,wildcard:f,value:h,literal:_}=t[o];if(!_)if(f){const t=n(l,e),a=getArgValue(i,r,t?e:l);h={path:t?e:l,value:a,base:t?s(i,l):a}}else h=d?getArgValue(i,r,l):i[l];if(u&&!this._overrideLegacyUndefined&&void 0===h&&t.length>1)return E;a[o]=h}return a}static addPropertyEffect(t,e,r){this.prototype._addPropertyEffect(t,e,r)}static createPropertyObserver(t,e,r){this.prototype._createPropertyObserver(t,e,r)}static createMethodObserver(t,e){this.prototype._createMethodObserver(t,e)}static createNotifyingProperty(t){this.prototype._createNotifyingProperty(t)}static createReadOnlyProperty(t,e){this.prototype._createReadOnlyProperty(t,e)}static createReflectedProperty(t){this.prototype._createReflectedProperty(t)}static createComputedProperty(t,e,r){this.prototype._createComputedProperty(t,e,r)}static bindTemplate(t){return this.prototype._bindTemplate(t)}_bindTemplate(t,e){let r=this.constructor._parseTemplate(t),i=this.__preBoundTemplateInfo==r;if(!i)for(let t in r.propertyEffects)this._createPropertyAccessor(t);if(e)if(r=Object.create(r),r.wasPreBound=i,this.__templateInfo){const e=t._parentTemplateInfo||this.__templateInfo,i=e.lastChild;r.parent=e,e.lastChild=r,r.previousSibling=i,i?i.nextSibling=r:e.firstChild=r}else this.__templateInfo=r;else this.__preBoundTemplateInfo=r;return r}static _addTemplatePropertyEffect(t,e,r){(t.hostProps=t.hostProps||{})[e]=!0;let i=t.propertyEffects=t.propertyEffects||{};(i[e]=i[e]||[]).push(r)}_stampTemplate(t,e){e=e||this._bindTemplate(t,!0),R.push(this);let r=super._stampTemplate(t,e);if(R.pop(),e.nodeList=r.nodeList,!e.wasPreBound){let t=e.childNodes=[];for(let e=r.firstChild;e;e=e.nextSibling)t.push(e)}return r.templateInfo=e,function setupBindings(t,e){let{nodeList:r,nodeInfoList:i}=e;if(i.length)for(let e=0;e<i.length;e++){let n=i[e],s=r[e],a=n.bindings;if(a)for(let e=0;e<a.length;e++){let r=a[e];setupCompoundStorage(s,r),addNotifyListener(s,t,r)}s.__dataHost=t}}(this,e),this.__dataClientsReady&&(this._runEffectsForTemplate(e,this.__data,null,!1),this._flushClients()),r}_removeBoundDom(e){const r=e.templateInfo,{previousSibling:i,nextSibling:n,parent:s}=r;i?i.nextSibling=n:s&&(s.firstChild=n),n?n.previousSibling=i:s&&(s.lastChild=i),r.nextSibling=r.previousSibling=null;let a=r.childNodes;for(let e=0;e<a.length;e++){let r=a[e];t(t(r).parentNode).removeChild(r)}}static _parseTemplateNode(t,e,r){let n=i._parseTemplateNode.call(this,t,e,r);if(t.nodeType===Node.TEXT_NODE){let i=this._parseBindings(t.textContent,e);i&&(t.textContent=literalFromParts(i)||" ",addBinding(this,e,r,"text","textContent",i),n=!0)}return n}static _parseTemplateNodeAttribute(t,e,r,n,s){let a=this._parseBindings(s,e);if(a){let i=n,s="property";O.test(n)?s="attribute":"$"==n[n.length-1]&&(n=n.slice(0,-1),s="attribute");let o=literalFromParts(a);return o&&"attribute"==s&&("class"==n&&t.hasAttribute("class")&&(o+=" "+t.getAttribute(n)),t.setAttribute(n,o)),"attribute"==s&&"disable-upgrade$"==i&&t.setAttribute(n,""),"input"===t.localName&&"value"===i&&t.setAttribute(i,""),t.removeAttribute(i),"property"===s&&(n=h(n)),addBinding(this,e,r,s,n,a,o),!0}return i._parseTemplateNodeAttribute.call(this,t,e,r,n,s)}static _parseTemplateNestedTemplate(t,e,r){let n=i._parseTemplateNestedTemplate.call(this,t,e,r);const s=t.parentNode,a=r.templateInfo,o="dom-if"===s.localName,l="dom-repeat"===s.localName;m&&(o||l)&&(s.removeChild(t),(r=r.parentInfo).templateInfo=a,r.noted=!0,n=!1);let d=a.hostProps;if(P&&o)d&&(e.hostProps=Object.assign(e.hostProps||{},d),m||(r.parentInfo.noted=!0));else{let t="{";for(let i in d){addBinding(this,e,r,"property","_host_"+i,[{mode:t,source:i,dependencies:[i],hostProp:!0}])}}return n}static _parseBindings(t,e){let r,i=[],n=0;for(;null!==(r=A.exec(t));){r.index>n&&i.push({literal:t.slice(n,r.index)});let s=r[1][0],a=Boolean(r[2]),o=r[3].trim(),l=!1,d="",f=-1;"{"==s&&(f=o.indexOf("::"))>0&&(d=o.substring(f+2),o=o.substring(0,f),l=!0);let h=parseMethod(o),_=[];if(h){let{args:t,methodName:r}=h;for(let e=0;e<t.length;e++){let r=t[e];r.literal||_.push(r)}let i=e.dynamicFns;(i&&i[r]||h.static)&&(_.push(r),h.dynamicFn=!0)}else _.push(o);i.push({source:o,mode:s,negate:a,customEvent:l,signature:h,dependencies:_,event:d}),n=A.lastIndex}if(n&&n<t.length){let e=t.substring(n);e&&i.push({literal:e})}return i.length?i:null}static _evaluateBinding(t,e,r,i,n,a){let l;return l=e.signature?runMethodEffect(t,r,i,0,e.signature):r!=e.source?s(t,e.source):a&&o(r)?s(t,r):t.__data[r],e.negate&&(l=!l),l}}}));const R=[];