spyne
Version:
Reactive Real-DOM Framework for Advanced Javascript applications
1 lines • 117 kB
JavaScript
import{fromEventPattern as e,Observable as t,Subject as n,bindCallback as r,fromEvent as o,of as s,ReplaySubject as i,forkJoin as a,EMPTY as c,merge as l,from as d}from"rxjs";import{compose as u,complement as h,isEmpty as E,head as p,values as N,isNil as _,allPass as f,reject as m,equals as T,keys as A,find as C,is as y,assoc as g,prop as v,when as I,__ as b,join as S,replace as L,flatten as O,map as D,toPairs as H,ifElse as R,always as V,concat as w,either as P,propEq as U,test as M,findLastIndex as W,last as F,filter as x,invert as $,defaultTo as k,reduce as j,zipObj as G,split as Y,fromPairs as B,has as z,path as K,uniq as q,chain as Q,includes as X,mergeRight as J,pickAll as Z,pick as ee,mergeDeepRight as te,clone as ne,not as re,mergeAll as oe,lte as se,match as ie,without as ae,mapObjIndexed as ce,pipe as le,forEachObjIndexed as de,flip as ue,propSatisfies as he,forEach as Ee,props as pe,omit as Ne,any as _e,curry as fe,where as me,F as Te,all as Ae,slice as Ce,toLower as ye,findIndex as ge,apply as ve,identity as Ie,objOf as be,view as Se,lensIndex as Le,lensProp as Oe,over as De,reverse as He,curryN as Re,toUpper as Ve,partialRight as we,pluck as Pe,pathEq as Ue,propIs as Me,pathSatisfies as We}from"ramda";import Fe from"dompurify";class xe{constructor(){this.checkIfObjIsNotEmptyOrNil=xe.checkIfObjIsNotEmptyOrNil.bind(this)}static checkIfObjIsNotEmptyOrNil(e){const t=u(h(E),p,N),n=u(h(_),p,N);return f([t,n])(e)}static checkIfParamValueMatchesRegex(e,t){const n=m(T("routeName")),r=u(n,A),o=u(C((t=>M(new RegExp(t),e))),r)(t);return y(String,o)&&(t=g(e,v(o,t),t)),t}static formatStrAsWindowLocation(e){return{hash:e,search:e,pathname:e}}static getLocationStrByType(e,t=!1,n=window.location){return v({slash:"pathname",query:"search",hash:"hash"}[!0===t?"hash":e],n).replace(/^(\/)?(#)?(\/)?(.*)$/,"$4")}static createRouteArrayFromParams(e,t,n="slash",r){const o=[],s=t=>{const n={},i=t.routeName;let a=void 0!==e[i]?e[i]:v(i,r);const c=typeof t[a];"string"===c?a=t[a]:"undefined"===c&&(t=this.checkIfParamValueMatchesRegex(a,t)),n[i]=a,this.checkIfObjIsNotEmptyOrNil(n)&&o.push(n);const l=y(Object,t),d=z(a,t),u=z("routePath",t);if(!0===(d&&l)){const e=t[a];z("routePath",e)&&s(e.routePath)}else!0===u&&void 0!==a&&s(t.routePath)};return s(t),o}static createSlashString(e){const t=m(_),n=I(h(_,b),S("/")),r=L(/^(\^*)(.*|^\$)(\$)$/,"$2");return u(r,n,t,O,D(N))(e)}static createQueryString(e){const t=m(_),n=this.checkIfObjIsNotEmptyOrNil,r=u(S("="),O,H),o=R(n,r,V(void 0)),s=D(o),i=I(h(E),w("?"));return u(i,S("&"),t,s)(e)}static checkPayloadForRegexOverrides(e,t,n="Value"){const r=u((e=>v(`${e}${n}`,t)),p,A);return D((e=>{const t=r(e);return void 0!==t?g(u(p,A)(e),t,e):e}),e)}static checkForRouteValWithMultipleVals(e){const t=e=>{const t=(t,n)=>(t[n]=(e=>{const t=e.match(/^[^|]*/);return t?"^$"===t[0]?"":t[0]:e})(e[n]),t);return"object"==typeof e&&(e=Object.keys(e).reduce(t,{})),e};return!0===Array.isArray(e)?e.map(t):e}static checkForRouteValsPartMatch(e,t={}){const n=(e,t)=>t.split("|").some((t=>((e,t)=>{const n=e.replace(/[-/\\^$+?.()|[\]{}]/g,"\\$&").replace(/\*/g,"[\\w\\d_-]*");return new RegExp(`^${n}$`).test(t)})(t,e)))?e:t;return e.map((e=>{const r={...e};return Object.keys(r).forEach((e=>{Object.prototype.hasOwnProperty.call(r,e)&&t[e]&&(r[e]=n(t[e],r[e]))})),r}))}static convertParamsToRoute(e,t=it.config.channels.ROUTE,n,r){const o=void 0!==n?n:t.type,s=t.isHash,i=t.routes.routePath,a=void 0!==r?r:this.getLocationStrByType(o,s),c=this.convertRouteToParams(a,t,o).routeData;let l=this.createRouteArrayFromParams(e,i,o,c);return l=xe.checkPayloadForRegexOverrides(l,e),l=xe.checkForRouteValWithMultipleVals(l),"query"===o?this.createQueryString(l):this.createSlashString(l)}static findIndexOfMatchedStringOrRegex(e,t){const n=t.includes(".+"),r=L(/^$/,"^$"),o=P(U(e,"str"),u(M(b,e),v("re")));return u(W(T(!0)),D(o),D((e=>{return{str:e,re:(t=e,n&&(t.startsWith("^")||(t="^"+t),t.endsWith("$")||(t+="$")),new RegExp(t))};var t})),D(r))(t)}static checkIfValueShouldMapToParam(e,t,n){const r=u(D(F),D(x(y(String))),H)(e),o=xe.findIndexOfMatchedStringOrRegex(t,r);let s=t;if(o>=0){const t=r[o],n=$(e),i=u(p,k([]),v(t))(n);!0===/^([-$\w]*)$/.test(i)&&!0===y(String,i)&&(s=i)}return s}static createArrFromSlashStr(e){return e.replace(/^([/])?(.*)$/,"$2").split("/")}static convertSlashRouteStrToParamsObj(e,t,n){const r=t,o=this.createArrFromSlashStr(t),s=[],i=[];let a=e;j(((e,t)=>{const r=this.checkIfValueShouldMapToParam(a,t,n);a=this.checkIfParamValueMatchesRegex(t,a);const o=P(E,_);void 0!==a&&(e=>e!==F(s))(a.routeName)&&!1===o(r)&&(s.push(a.routeName),i.push(r));const c=K([t,"routePath"],a),l=K(["routePath"],a);void 0!==c?a=c:void 0!==l&&(a=l)}),0,o);const c=G(s,i),l=this.getLastArrVal(s);return{paths:s,pathInnermost:l,routeData:c,routeValue:r}}static getLastArrVal(e){return void 0!==F(t=e)?F(t):"";var t}static createDefaultParamFromEmptyStr(e,t){const n={};return n[e.routeName]=this.checkIfValueShouldMapToParam(e,t),n}static convertQueryStrToParams(e,t,n){const r=t,o=t.replace(/^([?])?(.*)$/,"$2"),s=u(D(Y("=")),Y("&"))(o);let i=B(s),a=D(p,s);!0===E(t)&&(i=this.createDefaultParamFromEmptyStr(e,t,n),a=A(i));return{paths:a,pathInnermost:this.getLastArrVal(a),routeData:i,routeValue:r}}static convertRouteToParams(e,t,n){if(void 0===t)return{};const r=void 0!==n?n:t.type,o=k({},v("regexTokens",t)),s=t.routes.routePath;return"query"===r?this.convertQueryStrToParams(s,e):(e=e.replace(/\/$|$/,"/"),this.convertSlashRouteStrToParamsObj(s,e,o))}}class $e{constructor(){this.createPopStateStream=$e.createPopStateStream.bind(this)}static createPopStateStream(t){e((function(e){window.onpopstate=e}),(function(){window.onpopstate=function(){}})).subscribe(t)}static getLastArrVal(e){return void 0!==F(t=e)?F(t):"";var t}static compareRouteKeywords(e={},t){const n=(e,t)=>void 0!==t?ee(t,e):e;let r=n(e,t);return{pickValues:n,compare:(e={},t)=>{const o=n(e,t),s=e=>u(A,x(U(!0,e))),i=u(D((e=>{const t=v(e,r),n=v(e,o),s=T(t,n),i=void 0!==t,a=void 0!==n,c=!s,l=!1===i&&!0===a,d=!0===i&&!1===a,u={};return u[e]={same:s,changed:c,added:l,removed:d,previousExists:i,nextExists:a},u})),q,Q(A))([r,o]),a=Q(s("changed"),i),c=Q(s("added"),i),l=Q(s("removed"),i);return r=o,{pathsAdded:c,pathsRemoved:l,pathsChanged:a}},getComparer:()=>r}}static getRouteArrData(e,t){const n=x(X(b,e),t);return{paths:n,pathInnermost:$e.getLastArrVal(n)}}static flattenConfigObject(e){const t=e=>Q((([e,n])=>"object"!=typeof n||null===n||Array.isArray(n)?[[e,n]]:D((([t,n])=>[`${e}.${t}`,n]),t(n))),H(e));return N(B(t(e)))}static addRouteDatasets(e){const{type:t,isHash:n}=e,r=r=>{const o="query"===t?"":!0===n?"#":"/",s=xe.convertParamsToRoute(r,e);return o+s.replace(/^(.*\/)([\w-]*\/?)(.*)$/gm,"$1$2")},o=/^([A-Za-z0-9_-])+$/m,s=(e=[],t,n={})=>{let{routeName:i}=t;return H(t).reduce(((t,a)=>{const[c,l]=a,d=y(Object,l),u=e=>M(o,e)?(e=>String(e).replace(/([-_])/g," ").toUpperCase())(e):c;if("routeName"===c||"404"===c)return t;i=i||v("routeName",l);let h=ne(n);if(h[i]=String(c).replace(/([^A-Za-z0-9-_])/g,""),!0===d){if(1===A(h).length){const e=K(["routePath","routeName"],l);if(e){const o=ne(h);o[e]="",o.navLevel=A(n).length,o.title=u(c),o.href=r(o),t.push(o)}}h=s(e,l,h)}else h.title=u(c),h.href=r(h);return h.navLevel=A(n).length,t.push(h),t}),[])},i=s([],e.routes),a=O(i);return{routeDatasetsArr:a,routeNamesArr:(e=>{const t=m(X(b,["title","href","navLevel"]));return u(q,t,O,D(A))(e)})(a)}}static conformRouteObject(e={},t=!1){const n=K(["channels","ROUTE"],e);let{add404s:r}=void 0!==n?n:e;r=r||t;const o=e=>{const t=e[1],n=y(Array,t);return""===t?e[1]="^$":n&&(e[1]=t.join("|")),e},s=u(B,D((e=>{const[t,n]=e,i=r?{404:".+"}:{},a=y(Object,n),c=y(Array,n),l="routePath"===t;return!0===a&&!1===c&&(e[1]=s(e[1]),l&&(e[1]=u(te(i),B,D(o),H)(e[1]))),e})),H);if(void 0!==n){e.channels.ROUTE=s(e.channels.ROUTE);const t=$e.addRouteDatasets(e.channels.ROUTE);return e.channels.ROUTE=J(e.channels.ROUTE,t),e}return s(e)}static getLocationData(){return Z(["href","origin","protocol","host","hostname","port","pathname","search","hash"],window.location)}}const ke=Object.create({}),je=u(re,y(Array)),Ge=u(f([je,y(Object)]));function Ye(e){return e&&"object"==typeof e&&"[object RegExp]"!==Object.prototype.toString.call(e)&&"[object Date]"!==Object.prototype.toString.call(e)}function Be(e,t){return t&&!0===t.clone&&Ye(e)?Ke((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function ze(e,t,n){const r=e.slice();return t.forEach((function(t,o){void 0===r[o]?r[o]=Be(t,n):Ye(t)?r[o]=Ke(e[o],t,n):-1===e.indexOf(t)&&r.push(Be(t,n))})),r}function Ke(e,t,n){const r=Array.isArray(t),o=(n||{arrayMerge:ze}).arrayMerge||ze;return r?Array.isArray(e)?o(e,t,n):Be(t,n):function(e,t,n){const r={};return Ye(e)&&Object.keys(e).forEach((function(t){r[t]=Be(e[t],n)})),Object.keys(t).forEach((function(o){Ye(t[o])&&e[o]?r[o]=Ke(e[o],t[o],n):r[o]=Be(t[o],n)})),r}(e,t,n)}let qe,Qe,Xe,Je;Ke.all=function(e,t){if(!Array.isArray(e)||e.length<2)throw new Error("first argument should be an array with at least two elements");return e.reduce((function(e,n){return Ke(e,n,t)}))};let Ze=!0;const et=[];let tt,nt;const rt=[],ot=new Map;const st=new class{constructor(){ke.foo=()=>console.log("used for testing purposes.")}addMethod(e,t,n=!1){if(!0===Object.prototype.hasOwnProperty.call(ke,e)){const t=`Spyne Warning: the method name, ${e}, already exists.`;if(n)return t;console.warn(t)}else ke[e]=t}addMethods(e={},t=!1){let n;if(!1===Ge(e))return n=`Spyne Warning: the pluginMethods property, ${JSON.stringify(e)} needs to be an object.`,t?n:void console.warn(n);return A(e).map((r=>{const o=v(r,e);if("function"==typeof o)this.addMethod(r,o,t);else{if(n=`the value for ${r} is not a valid function.`,t)return n;console.warn(n)}})).join(",")}checkIfMethodExists(e){}get pluginMethodsObj(){return ke}};const it=new class{constructor(){Je=!1}get channelsMap(){return Xe}get initialized(){return Je}get config(){return qe}get debug(){return Ze}static listChannels(){return Array.from(Qe.map.keys())}initialize(e={},t={},n,r){return Qe=n,qe=Ke(e,t),qe.channels&&qe.channels.ROUTE&&(qe=r.conformRouteObject(qe)),nt=qe?.IMG_PATH,Ze=void 0!==qe.debug?qe.debug:Ze,this.getChannelActions=Qe.getChannelActions.bind(Qe),this.listRegisteredChannels=Qe.listRegisteredChannels.bind(Qe),Je=!0,this._initialized=Je,this.setChannelsMap(),t?.baseHref&&this.setHeadBaseHref(t.baseHref),qe}setHeadBaseHref(e){const t=document.createElement("base");t.href=e,document.head.appendChild(t)}conformRouteConfig(e=!1){qe=$e.conformRouteObject(qe,e)}setChannelsMap(){const e=Qe.getStream.bind(Qe),t=Qe.testStream.bind(Qe),n=Qe.getProxySubject.bind(Qe);Xe={getStream:e,testStream:t,getProxySubject:n}}setProp(e,t,n=!1){return n?(qe.ephemeralProps[e]=t,t):(qe.tmpProps[e]=t,e)}getProp(e){if(qe.ephemeralProps.hasOwnProperty(e)){const t=qe.ephemeralProps[e];return delete qe.ephemeralProps[e],t}return qe?.tmpProps?.[e]}createTempProp(e){const t=Math.random().toString(36).slice(2,8);return this.setProp(t,e,!0),t}setChannelConfig(e,t){return qe.channels[e]=t,qe.channels[e]}getChannelConfig(e,t=qe){if("CHANNEL_ROUTE"===e?e="ROUTE":"CHANNEL_WINDOW"===e&&(e="WINDOW"),void 0===t||void 0===qe.channels)return void console.warn("Spyne warning: Spyne config object is empty!");const n=qe.channels[e];if(void 0!==n)return n;console.warn(`Spyne warning: Spyne configuration for channel, ${e} is empty!`)}registerChannel(){}addPluginConfig(e,t={}){void 0===qe.plugins&&(qe.plugins={}),this.addPluginMethods(t.pluginMethods),qe.plugins[e]=t}getPluginsMethodObj(e){return e&&this.addPluginMethods(e),st.pluginMethodsObj}addPluginMethods(e){e&&st.addMethods(e)}doNotTrackChannel(e){rt.push(e)}getUntrackedChannelsList(){return rt}registerProxyReviver(e,t){ot.set(e,t)}registerPlugin(e){this._initialized||console.warn("SpyneApp is not initialized yet. Plugin will not be fully registered."),e.register(this)}getProxyReviver(e){return ot.get(e)}getPluginConfigByPluginName(e){return qe.plugins[e]}get IMG_PATH(){return nt}get excludeChannelsFromConsole(){return et}set excludeChannelsFromConsole(e){"string"==typeof e?et.includes(e)||et.push(e):Array.isArray(e)?e.forEach((e=>{"string"!=typeof e||et.includes(e)||et.push(e)})):console.warn("Invalid value provided to excludeChannelsFromConsole. Only strings or arrays are allowed.")}get linksData(){return console.warn("get links data in SpyneAppProperties is deprecated, use navLinks"),tt}set linksData(e){console.warn("set links data in SpyneAppProperties is deprecated, use navLinks")}get navLinks(){return tt}set navLinks(e){tt=e}tempGetChannelsInstance(){}tempGetConfig(){}},at=()=>({includes:()=>!0===it.initialized?it.listRegisteredChannels():["CHANNEL_ROUTE","CHANNEL_UI","CHANNEL_WINDOW","DISPATCHER"]});void 0!==u&&void 0!==t&&(u(y(String),K(["data","srcElement","vsid"])),u(y(String),K(["data","srcElement","id"])));const ct=(e,t)=>{const{__proxy__proxyName:n}=e;void 0===n&&console.error("object is not proxy object ",e);const r=(n,r)=>{const o=K(r,e),{__proxy__isProxy:s,__proxy__props:i}=o;return s?t(n,i):n},o=r(ne(e),[]),s=(e,t)=>{const n=t||[];Object.entries(e).forEach((([t,o])=>{const i=(e=>{let t=typeof e;return["number","boolean","string"].includes(t)?t="primitive":"object"===t&&(Array.isArray(e)?t="array":null===e&&(t="undefined")),t})(o),a=[...n];a.push(t),"object"!==i&&"array"!==i||(e[t]=r(o,a),s(o,a))}))};return s(o),o},lt=function(e){const{__proxy__proxyName:t}=e;if(void 0!==t){const n=it.getProxyReviver(t);if("function"==typeof n)return ct(e,n)}const n=y(Array),r=y(Object);var o;return!1===n(o=e)&&!0===r(o)?u(B,H,ne)(e):ne(e)};class dt{constructor(e,t,n,r,o,s){const i=e;s&&console.time(s);const a={channelName:e,action:t,srcElement:r,event:o},c=dt.deepFreeze(n);if(a.payload=c,!0===it.debug){if(Object.prototype.hasOwnProperty.call(n,"payload")){const e=JSON.stringify(n);console.warn(`Spyne Warning: the following payload contains a nested payload property which may create conflicts: Action: ${t}, ${e}`)}const e=it.getChannelActions(i);dt.validateAction(t,i,e)}a.clone=()=>oe([{payload:lt(a.payload)},a.payload,{channel:ne(i)},{event:ne(o)},{srcElement:r},ne(a.srcElement),{action:ne(a.action)}]);const l={$dir:{get:()=>a._dir,set:e=>(a._dir=e,e)}};return"CHANNEL_ROUTE"===i&&(l.location={get:()=>dt.getLocationData()}),a._dir=void 0,Object.defineProperties(a,l),s&&console.timeEnd(s),a}static validateAction(e,t,n){const r=X(e,n);return!1===r&&!0===it.initialized&&console.warn(`warning: Action: '${e}' is not registered within the ${t} channel!`),r}static getLocationData(){return Z(["href","origin","protocol","host","hostname","port","pathname","search","hash"],window.location)}static getStreamItem(){}static deepClone(e){const t=y(Array),n=y(Object);var r;return!1===t(r=e)&&!0===n(r)?u(B,H,ne)(e):ne(e)}static deepFreeze(e){const t=u(se(0),k(-1),v("nodeType"));try{Object.freeze(e),Object.getOwnPropertyNames(e).forEach((function(n){!Object.prototype.hasOwnProperty.call(e,n)||!1!==t(e[n])||null===e[n]||"object"!=typeof e[n]&&"function"!=typeof e[n]||Object.isFrozen(e[n])||dt.deepFreeze(e[n])}))}catch(t){return e}return e}static getMouseEventKeys(){return["altKey","bubbles","cancelBubble","cancelable","clientX","clientY","composed","ctrlKey","currentTarget","defaultPrevented","detail","eventPhase","fromElement","isTrusted","layerX","layerY","metaKey","movementX","movementY","offsetX","offsetY","pageX","pageY","path","relatedTarget","returnValue","screenX","screenY","shiftKey","sourceCapabilities","srcElement","target","timeStamp","toElement","type","view","which","x","y"]}}function ut(){return{createpropsMap:function(){const e=new WeakMap,t={vsid:this.props.vsid};return e.set(t,this.props),{key:t,weakMap:e}},gc:function(){for(const e in this)delete this[e]},createId:function(){return Math.random().toString(36).replace(/\d/gm,"").substring(1,8)},setTraceFunc:function(e){return!0===e?console.log:()=>{}}}}const ht=async(e,t)=>{window.setTimeout((async()=>{var t;await(t=1,new Promise((e=>setTimeout(e,t)))),window.requestAnimationFrame(e)}),t)},Et=e=>{if(void 0!==e.constructor.name)return e.constructor.name;const t=e.toString();return k(String(t).substr(0,12),ie(/^(function\s)(\w+)(\(.*)$/,t)[2])},pt=e=>{const t=u(h(E),p,N),n=u(h(_),p,N);return f([t,n])(e)};let Nt,_t=!1;class ft{constructor(e,t={},n={}){this.template=this.formatTemplate(e),this.isProxyData=!0===t.__cms__isProxy,this.testMode=n?.testMode;(()=>{!0===y(Array,t)&&(t={spyneData:t},this.template=this.template.replace("{{/}}","{{/spyneData}}"),this.template=this.template.replace("{{#}}","{{#spyneData}}"))})(),this.templateData=t;const r=ft.getStringArray(this.template);let o=this.template.match(ft.findTmplLoopsRE());o=null===o?[]:o;const s=ft.parseTmplLoopsRE(),i=this.parseTheTmplLoop.bind(this),a=X(b,o),c=R(a,((e,t)=>e.replace(s,i)),this.addParams.bind(this));this.finalArr=r.map(c)}static isPrimitiveTag(e){return/({{\.\*?}})/.test(e)}static getNestedDataReducer(e={},t=""){return/(\.)/gm.test(String(t))?String(t).split(".").reduce(((e,t)=>e[t]?e[t]:"string"==typeof e?e:""),e):e[t]??""}static getStringArray(e){const t=e.split(ft.findTmplLoopsRE()),n=/^([\\n\s\W]+)$/;return m((e=>e.match(n)),t)}static findTmplLoopsRE(){return/({{#[\w.]+}}[\w\n\s\W]+?{{\/[\w.]+}})/gm}static parseTmplLoopsRE(){return/({{#([\w.]+)}})([\w\n\s\W]+?)({{\/\2}})/gm}static swapParamsForTagsRE(){return/({{)(.*?)(}})/gm}removeThis(){void 0!==this&&(this.finalArr=void 0,this.templateData=void 0,this.template=void 0)}renderDocFrag(){let e=ft.replaceImgPath(this.finalArr.join(""));!0!==this.testMode&&(e=(e=>{if(!_t)throw new Error("sanitizeHTML is not configured. Call sanitizeHTMLConfigure() with appropriate config.");return Nt(e)})(e));const t=/^([^>]*?)(<){1}(\b)(thead|col|colgroup|tbody|td|tfoot|tr|th)(\b)([^\0]*)$/.test(e)?e:document.createRange().createContextualFragment(e);return window.setTimeout(this.removeThis,2),t}renderToString(){let e=this.finalArr.join("");return e=ft.replaceImgPath(e),window.setTimeout(this.removeThis,2),e}getTemplateString(){return this.finalArr.join("")}formatTemplate(e){return!0===["SCRIPT","TEMPLATE"].includes(v("nodeName",e))?e.innerHTML:e}getDataValFromPathStr(e,t){const n=String(e).split(".");return K(n,t)||""}addParams(e){return e.replace(ft.swapParamsForTagsRE(),((e,t,n,r)=>ft.getNestedDataReducer(this.templateData,n)))}static replaceImgPath(e){const{IMG_PATH:t}=it;return void 0!==t?(e=e.replaceAll(/src\s*=\s*(['"])imgs\//g,`src=$1${t}`)).replaceAll(/url\(\s*(['"]?)imgs\//g,`url($1${t}`):e}parseTheTmplLoop(e,t,n,r){const o=/(\.)/gm,s=r;let i=ft.getNestedDataReducer(this.templateData,n);const a=(e,t,n)=>{if(ft.isPrimitiveTag(t))return c(e,t);return l((()=>{const t=e,r=n,o=n+1;if(this.isProxyData){return{spyneLoopKey:t,__cms__dataId:i.__cms__dataId,origKey:i[`__cms__keyFor_${e}`],loopIndex:r,loopNum:o,d:e}}return{spyneLoopKey:t,loopIndex:r,loopNum:o}})(),t,n)},c=(e,t,n,r)=>(e=e.replace(/\$/g,"$$$$"),t.replace(ft.swapParamsForTagsRE(),e)),l=(e,t,n)=>t.replace(ft.swapParamsForTagsRE(),((t,r,s)=>{const i={loopIndex:n,loopNum:n+1};if(!1===o.test(s)&&void 0!==e[s])return void 0!==i[s]?i[s]:e[s];const a=this.getDataValFromPathStr(s,e);return void 0!==i[s]?i[s]:a}));return!0===_(i)||E(i)?"":(void 0===i.length&&(i=[i]),i=Array.isArray(i)?i:[i],i.map(((e,t)=>"string"==typeof e?a(e,s,t):l(e,s,t))).join(""))}}class mt{constructor(e={},t=!1){var n,r;e.tagName=(n="div",r=e.tagName,k(n)(r)),e.attributes=void 0!==e.attributes?e.attributes:this.getDomAttributes(e),e.attrs=this.updateAttrs(e.attributes),e.fragment=document.createDocumentFragment(),this.testMode=t,this.props=e,this.addMixins()}setProp(e,t){this.props[e]=t}getProp(e){return this.props[e]}get el(){return this.props.el}setElAttrs(e,t){return this.getProp("attrs").forEach(((t,n)=>{const r=(t,n)=>{e.dataset[n]=t};"dataset"===n?de(r,t):e.setAttribute(n,t)})),e}updateAttrs(e,t){const n=void 0!==t?t:new Map;return ce(((e,t)=>n.set(t,e)),e),n}addTemplate(e){const t=this.getProp("template");return void 0!==t?(t=>{let n=this.getProp("data");n=y(Object,n)?n:{};const r=new ft(t,n,{testMode:this?.testMode}).renderDocFrag();return y(String,r)?e.innerHTML=r:e.appendChild(r),e})(t):e}createElement(e="div"){return document.createElement(e)}addContent(e){const t=this.getProp("data");if(!0===y(String,t)){const n=document.createTextNode(t);e.appendChild(n)}return e}execute(){const e=le(this.createElement.bind(this),this.setElAttrs.bind(this),this.addTemplate.bind(this),this.addContent.bind(this))(this.getProp("tagName"));this.props.el=e}render(){return this.execute(),this.props.template=void 0,this.props.data=void 0,this.props.attributes=void 0,this.getProp("el")}renderToHTMLString(){return this.execute(),this.props.template=void 0,this.props.data=void 0,this.props.attributes=void 0,this.getProp("el").outerHTML}returnIfDefined(e,t){if(void 0!==t){const n=void 0===t;e[t]=!1===n?t:Ke(e[t],t)}}updateprops(e){return this.returnIfDefined(this.props,e),this}updatepropsAndRun(e){return this.updateprops(e),this.execute(),this.getProp("fragment")}unmount(){void 0!==this.props&&(this.getProp("el").remove(),this.props=void 0,this.gc())}updateTag(e="div"){this.updateprops(e)}updateAttributes(e={}){this.updateprops(e)}updateTemplate(e){this.updateprops(e)}updateData(e={}){this.updateprops(e)}addTagAndRender(e="div"){this.updatepropsAndRun(e)}addAttrsibutesAndRender(e={}){this.updatepropsAndRun(e)}addTemplateAndRender(e){this.updatepropsAndRun(e)}addDataAndRender(e={}){this.updatepropsAndRun(e)}addMixins(){const e=ut();this.gc=e.gc.bind(this)}getDomAttributes(e){return ee(this.attributesArray,e)}get attributesArray(){return["accept","accept-charset","accesskey","action","align","allow","alt","async","autocapitalize","autocomplete","autofocus","autoplay","bgcolor","border","buffered","challenge","charset","checked","cite","class","code","codebase","color","cols","colspan","content","contenteditable","contextmenu","controls","coords","crossorigin","csp","dataset","datetime","decoding","default","defer","dir","dirname","disabled","download","draggable","dropzone","enctype","for","form","formaction","headers","height","hidden","high","href","hreflang","http-equiv","icon","id","importance","integrity","ismap","itemprop","keytype","kind","label","lang","language","lazyload","list","loop","low","manifest","max","maxlength","minlength","media","method","min","multiple","muted","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","radiogroup","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","sandbox","scope","scoped","selected","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","style","summary","tabindex","target","title","translate","type","usemap","value","width","wrap"]}}const Tt=(e=!1,t=1,n="ease",r=!1)=>`${!0===r?"opacity:0;":""}transition: opacity ${t}s ${n}; opacity: ${!0===e?1:0};`;function At(e){return"function"==typeof e}function Ct(e){return At(null==e?void 0:e.lift)}function yt(e){return function(t){if(Ct(t))return t.lift((function(t){try{return e(t,this)}catch(e){this.error(e)}}));throw new TypeError("Unable to lift unknown Observable type")}}var gt=function(e,t){return gt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},gt(e,t)};function vt(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}gt(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}function It(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function bt(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function St(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Lt(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function Ot(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}function Dt(e){return this instanceof Dt?(this.v=e,this):new Dt(e)}function Ht(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r;function i(e){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=o[e](t)).value instanceof Dt?Promise.resolve(n.value.v).then(c,l):d(s[0][2],n)}catch(e){d(s[0][3],e)}var n}function c(e){a("next",e)}function l(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function Rt(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=St(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}}"function"==typeof SuppressedError&&SuppressedError;var Vt=function(e){return e&&"number"==typeof e.length&&"function"!=typeof e};function wt(e){return At(null==e?void 0:e.then)}function Pt(e){var t=e((function(e){Error.call(e),e.stack=(new Error).stack}));return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Ut=Pt((function(e){return function(t){e(this),this.message=t?t.length+" errors occurred during unsubscription:\n"+t.map((function(e,t){return t+1+") "+e.toString()})).join("\n "):"",this.name="UnsubscriptionError",this.errors=t}}));function Mt(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Wt=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}var t;return e.prototype.unsubscribe=function(){var e,t,n,r,o;if(!this.closed){this.closed=!0;var s=this._parentage;if(s)if(this._parentage=null,Array.isArray(s))try{for(var i=St(s),a=i.next();!a.done;a=i.next()){a.value.remove(this)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(t=i.return)&&t.call(i)}finally{if(e)throw e.error}}else s.remove(this);var c=this.initialTeardown;if(At(c))try{c()}catch(e){o=e instanceof Ut?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var d=St(l),u=d.next();!u.done;u=d.next()){var h=u.value;try{$t(h)}catch(e){o=null!=o?o:[],e instanceof Ut?o=Ot(Ot([],Lt(o)),Lt(e.errors)):o.push(e)}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}}if(o)throw new Ut(o)}},e.prototype.add=function(t){var n;if(t&&t!==this)if(this.closed)$t(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=null!==(n=this._finalizers)&&void 0!==n?n:[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Mt(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&Mt(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=((t=new e).closed=!0,t),e}(),Ft=Wt.EMPTY;function xt(e){return e instanceof Wt||e&&"closed"in e&&At(e.remove)&&At(e.add)&&At(e.unsubscribe)}function $t(e){At(e)?e():e.unsubscribe()}var kt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},jt={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=jt.delegate;return(null==o?void 0:o.setTimeout)?o.setTimeout.apply(o,Ot([e,t],Lt(n))):setTimeout.apply(void 0,Ot([e,t],Lt(n)))},clearTimeout:function(e){var t=jt.delegate;return((null==t?void 0:t.clearTimeout)||clearTimeout)(e)},delegate:void 0};function Gt(e){jt.setTimeout((function(){throw e}))}function Yt(){}var Bt=null;function zt(e){if(kt.useDeprecatedSynchronousErrorHandling){var t=!Bt;if(t&&(Bt={errorThrown:!1,error:null}),e(),t){var n=Bt,r=n.errorThrown,o=n.error;if(Bt=null,r)throw o}}else e()}var Kt=function(e){function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,xt(t)&&t.add(n)):n.destination=en,n}return vt(t,e),t.create=function(e,t,n){return new Jt(e,t,n)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Wt),qt=Function.prototype.bind;function Qt(e,t){return qt.call(e,t)}var Xt=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Zt(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Zt(e)}else Zt(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Zt(e)}},e}(),Jt=function(e){function t(t,n,r){var o,s,i=e.call(this)||this;At(t)||!t?o={next:null!=t?t:void 0,error:null!=n?n:void 0,complete:null!=r?r:void 0}:i&&kt.useDeprecatedNextContext?((s=Object.create(t)).unsubscribe=function(){return i.unsubscribe()},o={next:t.next&&Qt(t.next,s),error:t.error&&Qt(t.error,s),complete:t.complete&&Qt(t.complete,s)}):o=t;return i.destination=new Xt(o),i}return vt(t,e),t}(Kt);function Zt(e){Gt(e)}var en={closed:!0,next:Yt,error:function(e){throw e},complete:Yt},tn="function"==typeof Symbol&&Symbol.observable||"@@observable";function nn(e){return e}function rn(e){return 0===e.length?nn:1===e.length?e[0]:function(t){return e.reduce((function(e,t){return t(e)}),t)}}var on=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r,o=this,s=(r=e)&&r instanceof Kt||function(e){return e&&At(e.next)&&At(e.error)&&At(e.complete)}(r)&&xt(r)?e:new Jt(e,t,n);return zt((function(){var e=o,t=e.operator,n=e.source;s.add(t?t.call(s,n):n?o._subscribe(s):o._trySubscribe(s))})),s},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return new(t=sn(t))((function(t,r){var o=new Jt({next:function(t){try{e(t)}catch(e){r(e),o.unsubscribe()}},error:r,complete:t});n.subscribe(o)}))},e.prototype._subscribe=function(e){var t;return null===(t=this.source)||void 0===t?void 0:t.subscribe(e)},e.prototype[tn]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rn(e)(this)},e.prototype.toPromise=function(e){var t=this;return new(e=sn(e))((function(e,n){var r;t.subscribe((function(e){return r=e}),(function(e){return n(e)}),(function(){return e(r)}))}))},e.create=function(t){return new e(t)},e}();function sn(e){var t;return null!==(t=null!=e?e:kt.Promise)&&void 0!==t?t:Promise}function an(e){return At(e[tn])}function cn(e){return Symbol.asyncIterator&&At(null==e?void 0:e[Symbol.asyncIterator])}function ln(e){return new TypeError("You provided "+(null!==e&&"object"==typeof e?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}var dn="function"==typeof Symbol&&Symbol.iterator?Symbol.iterator:"@@iterator";function un(e){return At(null==e?void 0:e[dn])}function hn(e){return Ht(this,arguments,(function(){var t,n,r;return bt(this,(function(o){switch(o.label){case 0:t=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return[4,Dt(t.read())];case 3:return n=o.sent(),r=n.value,n.done?[4,Dt(void 0)]:[3,5];case 4:return[2,o.sent()];case 5:return[4,Dt(r)];case 6:return[4,o.sent()];case 7:return o.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}}))}))}function En(e){return At(null==e?void 0:e.getReader)}function pn(e){if(e instanceof on)return e;if(null!=e){if(an(e))return o=e,new on((function(e){var t=o[tn]();if(At(t.subscribe))return t.subscribe(e);throw new TypeError("Provided object does not correctly implement Symbol.observable")}));if(Vt(e))return r=e,new on((function(e){for(var t=0;t<r.length&&!e.closed;t++)e.next(r[t]);e.complete()}));if(wt(e))return n=e,new on((function(e){n.then((function(t){e.closed||(e.next(t),e.complete())}),(function(t){return e.error(t)})).then(null,Gt)}));if(cn(e))return Nn(e);if(un(e))return t=e,new on((function(e){var n,r;try{for(var o=St(t),s=o.next();!s.done;s=o.next()){var i=s.value;if(e.next(i),e.closed)return}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}e.complete()}));if(En(e))return Nn(hn(e))}var t,n,r,o;throw ln(e)}function Nn(e){return new on((function(t){(function(e,t){var n,r,o,s;return It(this,void 0,void 0,(function(){var i,a;return bt(this,(function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=Rt(e),c.label=1;case 1:return[4,n.next()];case 2:if((r=c.sent()).done)return[3,4];if(i=r.value,t.next(i),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return a=c.sent(),o={error:a},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(s=n.return)?[4,s.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}}))}))})(e,t).catch((function(e){return t.error(e)}))}))}function _n(e,t,n,r,o){return new fn(e,t,n,r,o)}var fn=function(e){function t(t,n,r,o,s,i){var a=e.call(this,t)||this;return a.onFinalize=s,a.shouldUnsubscribe=i,a._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,a._error=o?function(e){try{o(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,a._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,a}return vt(t,e),t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&(null===(t=this.onFinalize)||void 0===t||t.call(this))}},t}(Kt),mn=function(e){function t(t,n){return e.call(this)||this}return vt(t,e),t.prototype.schedule=function(e,t){return this},t}(Wt),Tn={setInterval:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var o=Tn.delegate;return(null==o?void 0:o.setInterval)?o.setInterval.apply(o,Ot([e,t],Lt(n))):setInterval.apply(void 0,Ot([e,t],Lt(n)))},clearInterval:function(e){var t=Tn.delegate;return((null==t?void 0:t.clearInterval)||clearInterval)(e)},delegate:void 0},An=function(e){function t(t,n){var r=e.call(this,t,n)||this;return r.scheduler=t,r.work=n,r.pending=!1,r}return vt(t,e),t.prototype.schedule=function(e,t){var n;if(void 0===t&&(t=0),this.closed)return this;this.state=e;var r=this.id,o=this.scheduler;return null!=r&&(this.id=this.recycleAsyncId(o,r,t)),this.pending=!0,this.delay=t,this.id=null!==(n=this.id)&&void 0!==n?n:this.requestAsyncId(o,this.id,t),this},t.prototype.requestAsyncId=function(e,t,n){return void 0===n&&(n=0),Tn.setInterval(e.flush.bind(e,this),n)},t.prototype.recycleAsyncId=function(e,t,n){if(void 0===n&&(n=0),null!=n&&this.delay===n&&!1===this.pending)return t;null!=t&&Tn.clearInterval(t)},t.prototype.execute=function(e,t){if(this.closed)return new Error("executing a cancelled action");this.pending=!1;var n=this._execute(e,t);if(n)return n;!1===this.pending&&null!=this.id&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null))},t.prototype._execute=function(e,t){var n,r=!1;try{this.work(e)}catch(e){r=!0,n=e||new Error("Scheduled action threw falsy error")}if(r)return this.unsubscribe(),n},t.prototype.unsubscribe=function(){if(!this.closed){var t=this.id,n=this.scheduler,r=n.actions;this.work=this.state=this.scheduler=null,this.pending=!1,Mt(r,this),null!=t&&(this.id=this.recycleAsyncId(n,t,null)),this.delay=null,e.prototype.unsubscribe.call(this)}},t}(mn),Cn={now:function(){return(Cn.delegate||Date).now()},delegate:void 0},yn=function(){function e(t,n){void 0===n&&(n=e.now),this.schedulerActionCtor=t,this.now=n}return e.prototype.schedule=function(e,t,n){return void 0===t&&(t=0),new this.schedulerActionCtor(this,e).schedule(n,t)},e.now=Cn.now,e}(),gn=new(function(e){function t(t,n){void 0===n&&(n=yn.now);var r=e.call(this,t,n)||this;return r.actions=[],r._active=!1,r}return vt(t,e),t.prototype.flush=function(e){var t=this.actions;if(this._active)t.push(e);else{var n;this._active=!0;do{if(n=e.execute(e.state,e.delay))break}while(e=t.shift());if(this._active=!1,n){for(;e=t.shift();)e.unsubscribe();throw n}}},t}(yn))(An);function vn(e,t,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!1);var s=t.schedule((function(){n(),o?e.add(this.schedule(null,r)):this.unsubscribe()}),r);if(e.add(s),!o)return s}function In(e,t){return void 0===t&&(t=0),yt((function(n,r){n.subscribe(_n(r,(function(n){return vn(r,e,(function(){return r.next(n)}),t)}),(function(){return vn(r,e,(function(){return r.complete()}),t)}),(function(n){return vn(r,e,(function(){return r.error(n)}),t)})))}))}function bn(e,t){return void 0===t&&(t=0),yt((function(n,r){r.add(e.schedule((function(){return n.subscribe(r)}),t))}))}function Sn(e,t){if(!e)throw new Error("Iterable cannot be null");return new on((function(n){vn(n,t,(function(){var r=e[Symbol.asyncIterator]();vn(n,t,(function(){r.next().then((function(e){e.done?n.complete():n.next(e.value)}))}),0,!0)}))}))}function Ln(e,t){if(null!=e){if(an(e))return function(e,t){return pn(e).pipe(bn(t),In(t))}(e,t);if(Vt(e))return function(e,t){return new on((function(n){var r=0;return t.schedule((function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())}))}))}(e,t);if(wt(e))return function(e,t){return pn(e).pipe(bn(t),In(t))}(e,t);if(cn(e))return Sn(e,t);if(un(e))return function(e,t){return new on((function(n){var r;return vn(n,t,(function(){r=e[dn](),vn(n,t,(function(){var e,t,o;try{t=(e=r.next()).value,o=e.done}catch(e){return void n.error(e)}o?n.complete():n.next(t)}),0,!0)})),function(){return At(null==r?void 0:r.return)&&r.return()}}))}(e,t);if(En(e))return function(e,t){return Sn(hn(e),t)}(e,t)}throw ln(e)}function On(e,t){return yt((function(n,r){var o=0;n.subscribe(_n(r,(function(n){r.next(e.call(t,n,o++))})))}))}var Dn=Array.isArray;function Hn(e){return On((function(t){return function(e,t){return Dn(t)?e.apply(void 0,Ot([],Lt(t))):e(t)}(e,t)}))}function Rn(e,t,n){return void 0===n&&(n=nn),function(r){Vn(t,(function(){for(var o=e.length,s=new Array(o),i=o,a=o,c=function(o){Vn(t,(function(){var c=function(e,t){return t?Ln(e,t):pn(e)}(e[o],t),l=!1;c.subscribe(_n(r,(function(e){s[o]=e,l||(l=!0,a--),a||r.next(n(s.slice()))}),(function(){--i||r.complete()})))}),r)},l=0;l<o;l++)c(l)}),r)}}function Vn(e,t,n){e?vn(n,e,t):t()}function wn(e,t,n){return void 0===n&&(n=1/0),At(t)?wn((function(n,r){return On((function(e,o){return t(n,e,r,o)}))(pn(e(n,r)))}),n):("number"==typeof t&&(n=t),yt((function(t,r){return function(e,t,n,r,o,s,i,a){var c=[],l=0,d=0,u=!1,h=function(){!u||c.length||l||t.complete()},E=function(e){return l<r?p(e):c.push(e)},p=function(e){s&&t.next(e),l++;var a=!1;pn(n(e,d++)).subscribe(_n(t,(function(e){null==o||o(e),s?E(e):t.next(e)}),(function(){a=!0}),void 0,(function(){if(a)try{l--;for(var e=function(){var e=c.shift();i?vn(t,i,(function(){return p(e)})):p(e)};c.length&&l<r;)e();h()}catch(e){t.error(e)}})))};return e.subscribe(_n(t,E,(function(){u=!0,h()}))),function(){null==a||a()}}(t,r,e,n)})))}var Pn=Array.isArray;function Un(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=function(e){return At((t=e)[t.length-1])?e.pop():void 0;var t}(e);return n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return rn(e)}(Un.apply(void 0,Ot([],Lt(e))),Hn(n)):yt((function(t,n){Rn(Ot([t],Lt(function(e){return 1===e.length&&Pn(e[0])?e[0]:e}(e))))(n)}))}var Mn=Pt((function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})),Wn=function(e){function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return vt(t,e),t.prototype.lift=function(e){var t=new Fn(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Mn},t.prototype.next=function(e){var t=this;zt((function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||(t.currentObservers=Array.from(t.observers));try{for(var o=St(t.currentObservers),s=o.next();!s.done;s=o.next()){s.value.next(e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}}))},t.prototype.error=function(e){var t=this;zt((function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}}))},t.prototype.complete=function(){var e=this;zt((function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}}))},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return(null===(e=this.observers)||void 0===e?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,o=n.isStopped,s=n.observers;return r||o?Ft:(this.currentObservers=null,s.push(e),new Wt((function(){t.currentObservers=null,Mt(s,e)})))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,o=t.isStopped;n?e.error(r):o&&e.complete()},t.prototype.asObservable=function(){var e=new on;return e.source=this,e},t.create=function(e,t){return new Fn(e,t)},t}(on),Fn=function(e){function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return vt(t,e),t.prototype.next=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.next)||void 0===n||n.call(t,e)},t.prototype.error=function(e){var t,n;null===(n=null===(t=this.destination)||void 0===t?void 0:t.error)||void 0===n||n.call(t,e)},t.prototype.complete=function(){var e,t;null===(t=null===(e=this.destination)||void 0===e?void 0:e.complete)||void 0===t||t.call(e)},t.prototype._subscribe=function(e){var t,n;return null!==(n=null===(t=this.source)||void 0===t?void 0:t.subscribe(e))&&void 0!==n?n:Ft},t}(Wn);var xn={connector:function(){return new Wn}};function $n(e,t){void 0===t&&(t=xn);var n=t.connector;return yt((function(t,r){var o,s=n();pn(e((o=s,new on((function(e){return o.subscribe(e)}))))).subscribe(r),r.add(t.subscribe(s))}))}function kn(e,t){return void 0===t&&(t=gn),yt((function(n,r){var o=null,s=null,i=null,a=function(){if(o){o.unsubscribe(),o=null;var e=s;s=null,r.next(e)}};function c(){var n=i+e,s=t.now();if(s<n)return o=this.schedule(void 0,n-s),void r.add(o);a()}n.subscribe(_n(r,(function(n){s=n,i=t.now(),o||(o=t.schedule(c,e),r.add(o))}),(function(){a(),r.complete()}),void 0,(function(){s=o=null})))}))}var jn=new on((function(e){return e.complete()}));function Gn(e){return e<=0?function(){return jn}:yt((function(t,n){var r=0;t.subscribe(_n(n,(function(t){++r<=e&&(n.next(t),e<=r&&n.complete())})))}))}function Yn(e,t){return yt((function(n,r){var o=0;n.subscribe(_n(r,(function(n){return e.call(t,n,o++)&&r.next(n)})))}))}function Bn(e){return yt((function(t,n){try{t.subscribe(n)}finally{n.add(e)}}))}var zn=wn;var Kn=function(e){function t(t,n){var r=e.call(this)||this;return r.source=t,r.subjectFactory=n,r._subject=null,r._refCount=0,r._connection=null,Ct(t)&&(r.lift=t.lift),r}return vt(t,e),t.prototype._subscribe=function(e){return this.getSubject().subscribe(e)},t.prototype.getSubject=function(){var e=this._subject;return e&&!e.isStopped||(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var e=this._connection;this._subject=this._connection=null,null==e||e.unsubscribe()},t.prototype.connect=function(){var e=this,t=this._connection;if(!t){t=this._connection=new Wt;var n=this.getSubject();t.add(this.source.subscribe(_n(n,void 0,(function(){e._teardown(),n.complete()}),(function(t){e._teardown(),n.error(t)}),(function(){return e._teardown()})))),t.closed&&(this._connection=null,t=Wt.EMPTY)}return t},t.prototype.refCount=function(){return yt((function(e,t){var n=null;e._refCount++;var r=_n(t,void 0,void 0,void 0,(function(){if(!e||e._refCount<=0||0<--e._refCount)n=null;else{var r=e._connection,o=n;n=null,!r||o&&r!==o||r.unsubscribe(),t.unsubscribe()}}));e.subscribe(r),r.closed||(n=e.connect())}))(this)},t}(on);function qn(e){return e?function(t){return $n(e)(t)}:function(e){return function(e,t){var n=At(e)?e:function(){return e};return At(t)?$n(t,{connector:n}):function(e){return new Kn(e,n)}}(new Wn)(e)}}function Qn(e,t){return void 0===t&&(t=!1),yt((function(n,r){var o=0;n.subscribe(_n(r,(function(n){var s=e(n,o++);(s||t)&&r.next(n),!s&&r.complete()})))}))}function Xn(e,t,n){var r=At(e)||t||n?{next:e,error:t,complete:n}:e;return r?yt((function(e,t){var n;null===(n=r.subscribe)||void 0===n||n.call(r);var o=!0;e.subscribe(_n(t,(function(e){var n;null===(n=r.next)||void 0===n||n.call(r,e),t.next(e)}),(function(){var e;o=!1,null===(e=r.complete)||void 0===e||e.call(r),t.complete()}),(function(e){var n;o=!1,null===(n=r.error)||void 0===n||n.call(r,e),t.error(e)}),(function(){var e,t;o&&(null===(e=r.unsubscribe)||void 0===e||e.call(r)),null===(t=r.finalize)||void 0===t||t.call(r)})))})):nn}class Jn{constructor(e){this.props.observableStreams=Jn.createDirectionalObservables()}static createDirectionalFiltersObject(){const e="internal",t="parent",n="child";return{P:[t],C:[n],PCI:[t,e,n],CI:[n,e],PI:[t,e],PC:[t,n]}}static addDefaultDir(e){return ue(J)({$dir:["internal"]},ne(e))}static addDownInternalDir(e,t=["internal","down"]){return ue(J)(ne(e),{$dir:t})}static addChildAndInternalDir(e,t=["child","down"]){return ue(J)(ne(e),{$dir:t})}static mapToDefaultDir(e){return this.addDefaultDir(e)}static createDirectionalObservables(e=new n,t,r){void 0!==t&&void 0!==r&&(e.viewName=t,e.vsid=r);const o=e=>he((t=>t.includes(e)),"$dir"),s=o("parent"),i=o("child"),a=o("internal"),c=e=>J({from$:e}),l=c("child"),d=c("internal"),u=c("parent"),h=e.pipe(Yn((e=>void 0!==e&&void 0!==e.action))),E=e.pipe(Yn(a),On(d)),p=e.pipe(Yn(s),On(l)),N=e.pipe(Yn(i),On(u)),_={parent:p,internal:E,child:N};return{raw$:h,toInternal$:E,toParent$:p,toChild$:N,completeAll:()=>{Ee((e=>{e.complete(),e.isStopped=!0}),[h,E,p,N])},completeStream:(e=[])=>{const t=e=>{if(void 0!==_[e]){(t=_[e]).complete(),t.isStopped=!0}var t};void 0!==e&&e.length>=1&&e.forEach(t)}}}}class Zn{constructor(e,t={},r="",o="theName"){this.addMixins(),this._state="INIT",this.vsid=r,this.el=t.el,this.vsName=o,this.defaults={debug:!1,extendedHashMethods:{}},this.options=Ke(this.defaults,t);this.addActionListeners().forEach((e=>{const[t,n]=e;this.options.extendedHashMethods[t]=e=>this[n](e)})),this.options.hashMethods=this.setHashMethods(this.options.extendedHashMethods),this.sink$=e,this.sink$.subscribe(this.onObsSinkSubscribe.bind(this)),this.$dirs=Jn.createDirectionalFiltersObject(),this.addDefaultDir=Jn.addDefaultDir,this.sourceStreams=Jn.createDirectionalObservables(new n,this.vsName,this.vsid),this._source$=this.sourceStreams.toInternal$}addActionListeners(){return[]}setHashMethods(e={}){return Ke({VS_DETRITUS_COLLECT:e=>this.onGarbageCollect(e),READY_FOR_VS_DETRITUS_COLLECT:e=>this.onReadyForGC(e),EXTIRPATE:e=>this.onDispose(e),VS_SPAWN:e=>this.onRender(e),VS_SPAWN_AND_ATTACH_TO_PAREN