diff --git a/README.md b/README.md
index d9e84e9..c6556a8 100644
--- a/README.md
+++ b/README.md
@@ -10,9 +10,9 @@ Links
Download
-----
-- [https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.js](https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.js)
-- [https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.es5.js](https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.es5.js)
-- [https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.es5.min.js](https://github.com/JamiLu/RME/releases/download/v2.0.11/rme.es5.min.js)
+- [https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.js](https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.js)
+- [https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.es5.js](https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.es5.js)
+- [https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.es5.min.js](https://github.com/JamiLu/RME/releases/download/v2.0.12/rme.es5.min.js)
NPM
---
@@ -51,7 +51,7 @@ Basics
Download a script file and place it to a project folder or simply use a github online url as follows.
-``
+``
__Or use NPM__
diff --git a/package.json b/package.json
index a6f229c..a9a06a7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rme.js",
- "version": "2.0.11",
+ "version": "2.0.12",
"description": "Functional JavaScript library for HTML 5 web sites.",
"main": "./src/index.js",
"keywords": [
diff --git a/rme-build-current/rme.es5.js b/rme-build-current/rme.es5.js
index 38946e0..3509e4c 100644
--- a/rme-build-current/rme.es5.js
+++ b/rme-build-current/rme.es5.js
@@ -5104,13 +5104,10 @@ var useHashRouter = function () {
*/
return function (routes) {
var scrollTop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- Component(RMEHashRouter);
- return {
- RMEHashRouter: {
- routes: routes,
- globalScrollTop: scrollTop
- }
- };
+ return _defineProperty({}, Component(RMEHashRouter).valueOf().name, {
+ routes: routes,
+ globalScrollTop: scrollTop
+ });
};
}();
var useOnLoadUrlRouter = function () {
@@ -5120,12 +5117,9 @@ var useOnLoadUrlRouter = function () {
* @param {array} routes router routes
*/
return function (routes) {
- Component(RMEOnLoadUrlRouter);
- return {
- RMEOnLoadUrlRouter: {
- routes: routes
- }
- };
+ return _defineProperty({}, Component(RMEOnLoadUrlRouter).valueOf().name, {
+ routes: routes
+ });
};
}();
@@ -5138,13 +5132,10 @@ var useOnLoadUrlRouter = function () {
var useUrlRouter = function () {
return function (routes) {
var scrollTop = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
- Component(RMEUrlRouter);
- return {
- RMEUrlRouter: {
- routes: routes,
- globalScrollTop: scrollTop
- }
- };
+ return _defineProperty({}, Component(RMEUrlRouter).valueOf().name, {
+ routes: routes,
+ globalScrollTop: scrollTop
+ });
};
}();
var useRouter = function () {
@@ -5443,6 +5434,11 @@ RMETemplateElement.Util = /*#__PURE__*/function () {
if (attr.key !== 'class') {
return attr;
}
+ }).map(function (attr) {
+ if (attr.key === 'message') {
+ attr.val = RMEMessagesResolver.message(RMETemplateResolver.normalizeMessageString(attr.val), RMETemplateResolver.getMessageParams(attr.val));
+ }
+ return attr;
});
elem.attributeString = elem.attributes.map(function (attr) {
return "".concat(attr.key, ":").concat(attr.val);
@@ -6123,10 +6119,10 @@ var RMETemplateResolver = function () {
key: "updateElemProps",
value: function updateElemProps(elem, props, oldProps) {
var combined = Template.combineProps(props, oldProps);
- Object.entries(combined).forEach(function (_ref9) {
- var _ref10 = _slicedToArray(_ref9, 2),
- prop = _ref10[0],
- value = _ref10[1];
+ Object.entries(combined).forEach(function (_ref12) {
+ var _ref13 = _slicedToArray(_ref12, 2),
+ prop = _ref13[0],
+ value = _ref13[1];
if (prop === 'text') {
value ? elem.setText(value) : elem.setText('');
} else if (Template.isEventKeyVal(prop, value)) {
diff --git a/rme-build-current/rme.es5.min.js b/rme-build-current/rme.es5.min.js
index 6972df0..3736a3d 100644
--- a/rme-build-current/rme.es5.min.js
+++ b/rme-build-current/rme.es5.min.js
@@ -1 +1 @@
-"use strict";function _get(){if(typeof Reflect!=="undefined"&&Reflect.get){_get=Reflect.get.bind()}else{_get=function _get(target,property,receiver){var base=_superPropBase(target,property);if(!base)return;var desc=Object.getOwnPropertyDescriptor(base,property);if(desc.get){return desc.get.call(arguments.length<3?target:receiver)}return desc.value}}return _get.apply(this,arguments)}function _superPropBase(object,property){while(!Object.prototype.hasOwnProperty.call(object,property)){object=_getPrototypeOf(object);if(object===null)break}return object}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});Object.defineProperty(subClass,"prototype",{writable:false});if(superClass)_setPrototypeOf(subClass,superClass)}function _setPrototypeOf(o,p){_setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function _setPrototypeOf(o,p){o.__proto__=p;return o};return _setPrototypeOf(o,p)}function _createSuper(Derived){var hasNativeReflectConstruct=_isNativeReflectConstruct();return function _createSuperInternal(){var Super=_getPrototypeOf(Derived),result;if(hasNativeReflectConstruct){var NewTarget=_getPrototypeOf(this).constructor;result=Reflect.construct(Super,arguments,NewTarget)}else{result=Super.apply(this,arguments)}return _possibleConstructorReturn(this,result)}}function _possibleConstructorReturn(self,call){if(call&&(_typeof(call)==="object"||typeof call==="function")){return call}else if(call!==void 0){throw new TypeError("Derived constructors may only return object or undefined")}return _assertThisInitialized(self)}function _assertThisInitialized(self){if(self===void 0){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return self}function _isNativeReflectConstruct(){if(typeof Reflect==="undefined"||!Reflect.construct)return false;if(Reflect.construct.sham)return false;if(typeof Proxy==="function")return true;try{Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}));return true}catch(e){return false}}function _getPrototypeOf(o){_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function _getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _getPrototypeOf(o)}function _regeneratorRuntime(){"use strict";_regeneratorRuntime=function _regeneratorRuntime(){return exports};var exports={},Op=Object.prototype,hasOwn=Op.hasOwnProperty,defineProperty=Object.defineProperty||function(obj,key,desc){obj[key]=desc.value},$Symbol="function"==typeof Symbol?Symbol:{},iteratorSymbol=$Symbol.iterator||"@@iterator",asyncIteratorSymbol=$Symbol.asyncIterator||"@@asyncIterator",toStringTagSymbol=$Symbol.toStringTag||"@@toStringTag";function define(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:!0,configurable:!0,writable:!0}),obj[key]}try{define({},"")}catch(err){define=function define(obj,key,value){return obj[key]=value}}function wrap(innerFn,outerFn,self,tryLocsList){var protoGenerator=outerFn&&outerFn.prototype instanceof Generator?outerFn:Generator,generator=Object.create(protoGenerator.prototype),context=new Context(tryLocsList||[]);return defineProperty(generator,"_invoke",{value:makeInvokeMethod(innerFn,self,context)}),generator}function tryCatch(fn,obj,arg){try{return{type:"normal",arg:fn.call(obj,arg)}}catch(err){return{type:"throw",arg:err}}}exports.wrap=wrap;var ContinueSentinel={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}var IteratorPrototype={};define(IteratorPrototype,iteratorSymbol,function(){return this});var getProto=Object.getPrototypeOf,NativeIteratorPrototype=getProto&&getProto(getProto(values([])));NativeIteratorPrototype&&NativeIteratorPrototype!==Op&&hasOwn.call(NativeIteratorPrototype,iteratorSymbol)&&(IteratorPrototype=NativeIteratorPrototype);var Gp=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(IteratorPrototype);function defineIteratorMethods(prototype){["next","throw","return"].forEach(function(method){define(prototype,method,function(arg){return this._invoke(method,arg)})})}function AsyncIterator(generator,PromiseImpl){function invoke(method,arg,resolve,reject){var record=tryCatch(generator[method],generator,arg);if("throw"!==record.type){var result=record.arg,value=result.value;return value&&"object"==_typeof(value)&&hasOwn.call(value,"__await")?PromiseImpl.resolve(value.__await).then(function(value){invoke("next",value,resolve,reject)},function(err){invoke("throw",err,resolve,reject)}):PromiseImpl.resolve(value).then(function(unwrapped){result.value=unwrapped,resolve(result)},function(error){return invoke("throw",error,resolve,reject)})}reject(record.arg)}var previousPromise;defineProperty(this,"_invoke",{value:function value(method,arg){function callInvokeWithMethodAndArg(){return new PromiseImpl(function(resolve,reject){invoke(method,arg,resolve,reject)})}return previousPromise=previousPromise?previousPromise.then(callInvokeWithMethodAndArg,callInvokeWithMethodAndArg):callInvokeWithMethodAndArg()}})}function makeInvokeMethod(innerFn,self,context){var state="suspendedStart";return function(method,arg){if("executing"===state)throw new Error("Generator is already running");if("completed"===state){if("throw"===method)throw arg;return doneResult()}for(context.method=method,context.arg=arg;;){var delegate=context.delegate;if(delegate){var delegateResult=maybeInvokeDelegate(delegate,context);if(delegateResult){if(delegateResult===ContinueSentinel)continue;return delegateResult}}if("next"===context.method)context.sent=context._sent=context.arg;else if("throw"===context.method){if("suspendedStart"===state)throw state="completed",context.arg;context.dispatchException(context.arg)}else"return"===context.method&&context.abrupt("return",context.arg);state="executing";var record=tryCatch(innerFn,self,context);if("normal"===record.type){if(state=context.done?"completed":"suspendedYield",record.arg===ContinueSentinel)continue;return{value:record.arg,done:context.done}}"throw"===record.type&&(state="completed",context.method="throw",context.arg=record.arg)}}}function maybeInvokeDelegate(delegate,context){var methodName=context.method,method=delegate.iterator[methodName];if(undefined===method)return context.delegate=null,"throw"===methodName&&delegate.iterator["return"]&&(context.method="return",context.arg=undefined,maybeInvokeDelegate(delegate,context),"throw"===context.method)||"return"!==methodName&&(context.method="throw",context.arg=new TypeError("The iterator does not provide a '"+methodName+"' method")),ContinueSentinel;var record=tryCatch(method,delegate.iterator,context.arg);if("throw"===record.type)return context.method="throw",context.arg=record.arg,context.delegate=null,ContinueSentinel;var info=record.arg;return info?info.done?(context[delegate.resultName]=info.value,context.next=delegate.nextLoc,"return"!==context.method&&(context.method="next",context.arg=undefined),context.delegate=null,ContinueSentinel):info:(context.method="throw",context.arg=new TypeError("iterator result is not an object"),context.delegate=null,ContinueSentinel)}function pushTryEntry(locs){var entry={tryLoc:locs[0]};1 in locs&&(entry.catchLoc=locs[1]),2 in locs&&(entry.finallyLoc=locs[2],entry.afterLoc=locs[3]),this.tryEntries.push(entry)}function resetTryEntry(entry){var record=entry.completion||{};record.type="normal",delete record.arg,entry.completion=record}function Context(tryLocsList){this.tryEntries=[{tryLoc:"root"}],tryLocsList.forEach(pushTryEntry,this),this.reset(!0)}function values(iterable){if(iterable){var iteratorMethod=iterable[iteratorSymbol];if(iteratorMethod)return iteratorMethod.call(iterable);if("function"==typeof iterable.next)return iterable;if(!isNaN(iterable.length)){var i=-1,next=function next(){for(;++i=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel}},"catch":function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry)}return thrown}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel}},exports}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){var lastIdx=this.pendingRemove.length-1;while(lastIdx>=0){this.pendingRemove[lastIdx].parent.remove(this.pendingRemove[lastIdx].index,this.pendingRemove[lastIdx].child);lastIdx--}this.pendingRemove.length=0}}}]);return RMEElemRenderer}();var Browser=function(){function Browser(){_classCallCheck(this,Browser)}_createClass(Browser,null,[{key:"setTimeout",value:function setTimeout(callback,milliseconds){for(var _len=arguments.length,params=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){params[_key-2]=arguments[_key]}return window.setTimeout(callback,milliseconds,params)}},{key:"clearTimeout",value:function clearTimeout(timeoutObject){window.clearTimeout(timeoutObject)}},{key:"setInterval",value:function setInterval(callback,milliseconds){for(var _len2=arguments.length,params=new Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){params[_key2-2]=arguments[_key2]}return window.setInterval(callback,milliseconds,params)}},{key:"clearInterval",value:function clearInterval(intervalObject){window.clearInterval(intervalObject)}},{key:"toBase64",value:function toBase64(string){return window.btoa(string)}},{key:"fromBase64",value:function fromBase64(string){return window.atob(string)}},{key:"scrollTo",value:function scrollTo(xPos,yPos){window.scrollTo(xPos,yPos)}},{key:"scrollBy",value:function scrollBy(xPx,yPx){window.scrollBy(xPx,yPx)}},{key:"open",value:function open(url,name,specs,replace){return window.open(url,name,specs,replace)}},{key:"close",value:function close(openedWindow){openedWindow.close()}},{key:"print",value:function print(){window.print()}},{key:"alert",value:function alert(message){window.alert(message)}},{key:"confirm",value:function confirm(message){return window.confirm(message)}},{key:"prompt",value:function prompt(message,defaultText){return window.prompt(message,defaultText)}},{key:"mediaMatcher",value:function mediaMatcher(mediaString){if(mediaString.indexOf("(")!==0)mediaString="("+mediaString;if(mediaString.indexOf(")")!==mediaString.length-1)mediaString=mediaString+")";return window.matchMedia(mediaString)}},{key:"pageBack",value:function pageBack(){history.back()}},{key:"pageForward",value:function pageForward(){history.forward()}},{key:"pageGo",value:function pageGo(numberOfPagesOrUrl){history.go(numberOfPagesOrUrl)}},{key:"pushState",value:function pushState(stateObject,title,newURL){history.pushState(stateObject,title,newURL)}},{key:"replaceState",value:function replaceState(stateObject,title,newURL){history.replaceState(stateObject,title,newURL)}},{key:"newPage",value:function newPage(newURL){location.assign(newURL)}},{key:"reloadPage",value:function reloadPage(force){location.reload(force)}},{key:"replacePage",value:function replacePage(newURL){location.replace(newURL)}},{key:"getAnchorHash",value:function getAnchorHash(){return location.hash}},{key:"setAnchorHash",value:function setAnchorHash(hash){location.hash=hash}},{key:"getHostnamePort",value:function getHostnamePort(){return location.host}},{key:"setHostnamePort",value:function setHostnamePort(hostPort){location.host=hostPort}},{key:"getHostname",value:function getHostname(){return location.hostname}},{key:"setHostname",value:function setHostname(hostname){location.hostname=hostname}},{key:"getURL",value:function getURL(){return location.href}},{key:"setURL",value:function setURL(newURL){location.href=newURL}},{key:"getOrigin",value:function getOrigin(){return location.origin}},{key:"getPathname",value:function getPathname(){return location.pathname}},{key:"setPathname",value:function setPathname(pathname){location.pathname=pathname}},{key:"getPort",value:function getPort(){return location.port}},{key:"setPort",value:function setPort(portNumber){location.port=portNumber}},{key:"getProtocol",value:function getProtocol(){return location.protocol}},{key:"setProtocol",value:function setProtocol(protocol){location.protocol=protocol}},{key:"getSearchString",value:function getSearchString(){return location.search}},{key:"setSearchString",value:function setSearchString(searchString){location.search=searchString}},{key:"getCodename",value:function getCodename(){return navigator.appCodeName}},{key:"getName",value:function getName(){return navigator.appName}},{key:"getVersion",value:function getVersion(){return navigator.appVersion}},{key:"isCookiesEnabled",value:function isCookiesEnabled(){return navigator.cookieEnabled}},{key:"getGeoLocation",value:function getGeoLocation(){return navigator.geolocation}},{key:"getLanguage",value:function getLanguage(){return navigator.language}},{key:"getPlatform",value:function getPlatform(){return navigator.platform}},{key:"getProduct",value:function getProduct(){return navigator.product}},{key:"getUserAgentHeader",value:function getUserAgentHeader(){return navigator.userAgent}},{key:"getColorDepth",value:function getColorDepth(){return screen.colorDepth}},{key:"getFullScreenHeight",value:function getFullScreenHeight(){return screen.height}},{key:"getFullScreenWidth",value:function getFullScreenWidth(){return screen.width}},{key:"getAvailableScreenHeight",value:function getAvailableScreenHeight(){return screen.availHeight}},{key:"getAvailableScreenWidth",value:function getAvailableScreenWidth(){return screen.availWidth}}]);return Browser}();var RMEAppComponent=function(){function RMEAppComponent(renderHook,appName,parentContext){_classCallCheck(this,RMEAppComponent);this.store=useValue({},appName);this.appName=appName;this.parentContext=parentContext;this.shouldUpdate=true;this.renderHook=renderHook;this.afterRenderTasks=[];this.prevProps={};this.prevResult}_createClass(RMEAppComponent,[{key:"render",value:function render(props,parent,componentLiteral){var _this4=this;var _this$store=_slicedToArray(this.store,2),getState=_this$store[0],setState=_this$store[1];var nextProps=_objectSpread(_objectSpread({},props),getState());var ops={setState:setState,updateState:function updateState(next,update){setState(function(state){return _objectSpread(_objectSpread({},state),Util.isFunction(next)?next(getState()):next)},update)},isStateEmpty:function isStateEmpty(){return Object.keys(getState()).length===0},shouldComponentUpdate:function shouldComponentUpdate(shouldUpdateHook){if(Util.isFunction(shouldUpdateHook)){_this4.shouldUpdate=shouldUpdateHook(nextProps,_this4.prevProps)!==false}},asyncTask:function asyncTask(asyncTaskHook){if(Util.isFunction(asyncTaskHook)){_this4.afterRenderTasks.push(asyncTaskHook)}}};var result;if(this.shouldUpdate){result=this.renderHook(nextProps,ops);result=RMETemplateResolver.isTemplate(result)?RMETemplateResolver.resolve(result,parent,this.appName,this.parentContext,componentLiteral):result}else{result=this.prevResult}this.prevResult=result;this.prevProps=nextProps;if(this.afterRenderTasks.length>0){Browser.setTimeout(_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_this4.afterRenderTasks.forEach(function(){var _ref2=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(hook){return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",hook());case 1:case"end":return _context.stop()}},_callee)}));return function(_x2){return _ref2.apply(this,arguments)}}());_this4.afterRenderTasks.length=0;case 2:case"end":return _context2.stop()}},_callee2)})))}return result}}]);return RMEAppComponent}();var Component=function(){var resolveComponent=function resolveComponent(component){if(Util.isFunction(component)){RMEComponentManagerV2.addComponent(component.valueOf().name,component)}};return function(){for(var _len3=arguments.length,components=new Array(_len3),_key3=0;_key3<_len3;_key3++){components[_key3]=arguments[_key3]}components.forEach(function(component){return!Util.isEmpty(component.valueOf().name)&&resolveComponent(component)});return components.length===1?components[0]:components}}();var RMEComponentManagerV2=function(){var RMEComponentManager=function(){function RMEComponentManager(){_classCallCheck(this,RMEComponentManager);this.componentFunctionMap={};this.componentInstanceMap={}}_createClass(RMEComponentManager,[{key:"hasComponent",value:function hasComponent(name){return this.componentFunctionMap[name]!==undefined}},{key:"addComponent",value:function addComponent(name,renderHook){if(!this.hasComponent(name)){this.componentFunctionMap[name]=renderHook}}},{key:"getComponent",value:function getComponent(name,props,parent,componentLiteral){var parentContext=arguments.length>4&&arguments[4]!==undefined?arguments[4]:"";var appName=arguments.length>5&&arguments[5]!==undefined?arguments[5]:"";var component=this.componentInstanceMap[appName+name+parentContext];if(!component){component=new RMEAppComponent(this.componentFunctionMap[name],appName,parentContext);this.componentInstanceMap[appName+name+parentContext]=component}return component.render(props,parent,componentLiteral)}}]);return RMEComponentManager}();return new RMEComponentManager}();var CSS=function(){var getStyles=function getStyles(config){var styles=Tree.getHead().getByTag("style");if(Util.isEmpty(config)&&!Util.isArray(styles)){return styles}else if(Util.isArray(styles)){return styles.find(function(style){return arePropertiesSame(style.getProps(),config)})}else if(!Util.isEmpty(styles)&&arePropertiesSame(styles.getProps(),config)){return styles}};var propsWithoutContent=function propsWithoutContent(props){var newProps=_objectSpread({},props);delete newProps.text;return newProps};var arePropertiesSame=function arePropertiesSame(oldProps,newProps){return JSON.stringify(propsWithoutContent(oldProps))===JSON.stringify(newProps||{})};var hasStyles=function hasStyles(config){return!Util.isEmpty(getStyles(config))};var hasContent=function hasContent(content,config){var styles=getStyles(config);if(!Util.isEmpty(styles)){return styles.getContent().match(content)!==null}};return function(content,config){if(!hasStyles(config)){Tree.getHead().append(RMETemplateResolver.resolve({style:_objectSpread({content:content},config)}))}else if(!hasContent(content,config)){var style=getStyles(config);if(!Util.isEmpty(style)){var prevContent=style.getContent();style.setContent(prevContent+content)}}}}();var Elem=function(){function Elem(type){_classCallCheck(this,Elem);if(Util.isString(type)){this.html=document.createElement(type)}else if(type.nodeType!==undefined&&type.ownerDocument!==undefined&&type.nodeType>=1&&type.ownerDocument instanceof Document){this.html=type}else{throw"type must be a string or a Document"}}_createClass(Elem,[{key:"setText",value:function setText(text){if(this.html.hasChildNodes()){this.html.replaceChild(document.createTextNode(text),this.html.childNodes[0])}else{this.html.appendChild(document.createTextNode(text))}return this}},{key:"getText",value:function getText(){var text="";this.html.childNodes.forEach(function(node){if(node.nodeType===3){text=node.nodeValue}});return text}},{key:"getContent",value:function getContent(){return this.html.innerHTML}},{key:"setContent",value:function setContent(html){this.html.innerHTML=html;return this}},{key:"setValue",value:function setValue(value){this.html.value=value;return this}},{key:"getValue",value:function getValue(){return this.html.value}},{key:"setId",value:function setId(id){this.html.id=id;return this}},{key:"getId",value:function getId(){return this.html.id}},{key:"append",value:function append(elem){elem&&this.html.appendChild(elem.dom());return this}},{key:"remove",value:function remove(elem){this.html.removeChild(elem.dom());return this}},{key:"replace",value:function replace(newElem){this.html.parentElement.replaceChild(newElem.dom(),this.html);return this}},{key:"before",value:function before(newElem){this.html.parentElement.insertBefore(newElem.dom(),this.html);return this}},{key:"after",value:function after(newElem){if(this.html.nextElementSibling!==null)this.html.parentElement.insertBefore(newElem.dom(),this.html.nextElementSibling);else this.html.parentElement.appendChild(newElem.dom());return this}},{key:"toString",value:function toString(){return"<"+this.getTagName().toLowerCase()+">"+this.getContent()+""+this.getTagName().toLowerCase()+">"}},{key:"toLiteralString",value:function toLiteralString(){return RMEElemTemplater.toLiteralString(this)}},{key:"toTemplate",value:function toTemplate(deep){return RMEElemTemplater.toTemplate(this,deep)}},{key:"getProps",value:function getProps(json){if(json===true)return JSON.stringify(RMEElemTemplater.getElementProps(this));else return RMEElemTemplater.getElementProps(this)}},{key:"setProps",value:function setProps(props){RMETemplateResolver.updateElemProps(this,props,this.getProps());return this}},{key:"render",value:function render(){var newState=[];var i=0;for(var _len4=arguments.length,elems=new Array(_len4),_key4=0;_key4<_len4;_key4++){elems[_key4]=arguments[_key4]}var max=elems.length;while(i0)updateClassesArray.push(clazz)});this.html.className=updateClassesArray.join(" ").trim();return this}},{key:"removeClasses",value:function removeClasses(classes){var toRm=classes.trim().split(" ");var origClass="".concat(this.getClasses());var i=0;while(i1?_len5-1:0),_key5=1;_key5<_len5;_key5++){params[_key5-1]=arguments[_key5]}while(i0&&this.deep){children.forEach(function(child){return _this8.resolve(child,resolved)})}this.template=resolved}},{key:"extendMap",value:function extendMap(map,next){for(var v in next){if(next.hasOwnProperty(v)){map[v]=next[v]}}}},{key:"resolveElem",value:function resolveElem(elem,props){var el={};var children=elem.getChildren();if(Util.isArray(children)&&children.length>1){var elTag=elem.getTagName().toLowerCase();var elName=this.resolveId(elTag,props);elName=this.resolveClass(elName,props);elName=this.resolveAttrs(elName,props);el[elName]=_objectSpread(_objectSpread({},props),{},{_:[]})}else{el[elem.getTagName().toLowerCase()]=props}return el}},{key:"resolveId",value:function resolveId(tag,props){if(props.id)return tag+"#"+props.id;else return tag}},{key:"resolveClass",value:function resolveClass(tag,props){if(props["class"])return tag+"."+props["class"].replace(/ /g,".");else return tag}},{key:"resolveAttrs",value:function resolveAttrs(tag,props){var tagName=tag;for(var p in props){if(props.hasOwnProperty(p)&&p!=="id"&&p!=="class"&&p.indexOf("on")!==0){tagName+="[".concat(p,"=").concat(props[p],"]")}}return tagName}},{key:"resolveProps",value:function resolveProps(elem){var props={};var attributes=elem.dom().attributes;var a=0;if(attributes){while(a"data".length){while(attrName.search("-")>-1){attrName=attrName.replace(/-\w/,attrName.charAt(attrName.search("-")+1).toUpperCase())}return attrName}else if(attrName.indexOf("aria")===0){return attrName.replace(attrName.charAt("aria".length),attrName.charAt("aria".length).toUpperCase())}else{return attrName}}},{key:"resolveListeners",value:function resolveListeners(name){switch(name){case"onanimationstart":return"onAnimationStart";case"onanimationiteration":return"onAnimationIteration";case"onanimationend":return"onAnimationEnd";case"ontransitionend":return"onTransitionEnd";case"ondrag":return"onDrag";case"ondragend":return"onDragEnd";case"ondragenter":return"onDragEnter";case"ondragover":return"onDragOver";case"ondragstart":return"onDragStart";case"ondrop":return"onDrop";case"onclick":return"onClick";case"ondblclick":return"onDoubleClick";case"oncontextmenu":return"onContextMenu";case"onmousedown":return"onMouseDown";case"onmouseenter":return"onMouseEnter";case"onmouseleave":return"onMouseLeave";case"onmousemove":return"onMouseMove";case"onmouseover":return"onMouseOver";case"onmouseout":return"onMouseOut";case"onmouseup":return"onMouseUp";case"onwheel":return"onWheel";case"onscroll":return"onScroll";case"onresize":return"onResize";case"onerror":return"onError";case"onload":return"onLoad";case"onunload":return"onUnload";case"onbeforeunload":return"onBeforeUnload";case"onkeyup":return"onKeyUp";case"onkeydown":return"onKeyDown";case"onkeypress":return"onKeyPress";case"oninput":return"onInput";case"onchange":return"onChange";case"onsubmit":return"onSubmit";case"onselect":return"onSelect";case"onreset":return"onReset";case"onfocus":return"onFocus";case"onfocusin":return"onFocusIn";case"onfocusout":return"onFocusOut";case"onblur":return"onBlur";case"oncopy":return"onCopy";case"oncut":return"onCut";case"onpaste":return"onPaste";case"onabort":return"onAbort";case"onwaiting":return"onWaiting";case"onvolumechange":return"onVolumeChange";case"ontimeupdate":return"onTimeUpdate";case"onseeking":return"onSeeking";case"onseekend":return"onSeekEnd";case"onratechange":return"onRateChange";case"onprogress":return"onProgress";case"onloadmetadata":return"onLoadMetadata";case"onloadeddata":return"onLoadedData";case"onloadstart":return"onLoadStart";case"onplaying":return"onPlaying";case"onplay":return"onPlay";case"onpause":return"onPause";case"onended":return"onEnded";case"ondurationchange":return"onDurationChange";case"oncanplay":return"onCanPlay";case"oncanplaythrough":return"onCanPlayThrough";case"onstalled":return"onStalled";case"onsuspend":return"onSuspend";case"onpopstate":return"onPopState";case"onstorage":return"onStorage";case"onhashchange":return"onHashChange";case"onafterprint":return"onAfterPrint";case"onbeforeprint":return"onBeforePrint";case"onpagehide":return"onPageHide";case"onpageshow":return"onPageShow"}}},{key:"toLiteralString",value:function toLiteralString(elem){var props=this.resolveProps(elem);var string=this.resolveId(elem.getTagName().toLowerCase(),props);string=this.resolveClass(string,props);string=this.resolveAttrs(string,props);return string}}],[{key:"toTemplate",value:function toTemplate(elem,deep){return RMEElemTemplater.getInstance().toTemplate(elem,deep)}},{key:"getElementProps",value:function getElementProps(elem){return RMEElemTemplater.getInstance().resolveProps(elem)}},{key:"toLiteralString",value:function toLiteralString(elem){return RMEElemTemplater.getInstance().toLiteralString(elem)}},{key:"getInstance",value:function getInstance(){if(!this.instance)this.instance=new RMEElemTemplater;return this.instance}}]);return RMEElemTemplater}();var Fetch=function(){var Fetch=function(){function Fetch(){_classCallCheck(this,Fetch)}_createClass(Fetch,[{key:"get",value:function get(url,contentType){return this["do"]({url:url,init:{method:"GET"},contentType:getDefaultContentType(contentType)})}},{key:"post",value:function post(url,body,contentType){return this["do"]({url:url,body:body,init:{method:"POST"},contentType:getDefaultContentType(contentType)})}},{key:"put",value:function put(url,body,contentType){return this["do"]({url:url,body:body,init:{method:"PUT"},contentType:getDefaultContentType(contentType)})}},{key:"delete",value:function _delete(url,contentType){return this["do"]({url:url,init:{method:"DELETE"},contentType:getDefaultContentType(contentType)})}},{key:"patch",value:function patch(url,body,contentType){var _this$do;return this["do"]((_this$do={url:url},_defineProperty(_this$do,"url",url),_defineProperty(_this$do,"body",body),_defineProperty(_this$do,"init",{method:"PATCH"}),_defineProperty(_this$do,"contentType",getDefaultContentType(contentType)),_this$do))}},{key:"do",value:function _do(config){if(Util.isEmpty(config)||!Util.isObject(config)||Util.isEmpty(config.url)){throw new Error("Error in fetch config object ".concat(JSON.stringify(config),", url must be set"))}if(!config.init)config.init={};if(config.contentType&&config.contentType!=="buffer"){if(!config.init.headers)config.init.headers=new Headers({});if(!config.init.headers.has("Content-Type"))config.init.headers.set("Content-Type",config.contentType)}if((config.body||config.init.body)&&isContentType(config.contentType,Http.JSON)){config.init.body=JSON.stringify(config.body||config.init.body)}else if(config.body){config.init.body=config.body}if(config.method){config.init.method=config.method}return fetch(config.url,config.init).then(function(){var _ref3=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(response){var res;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(response.ok){_context3.next=2;break}throw Error("Error in requesting url: ".concat(config.url,", method: ").concat(config.init.method));case 2:if(!isContentType(config.contentType,Http.JSON)){_context3.next=7;break}_context3.next=5;return response.text();case 5:res=_context3.sent;return _context3.abrupt("return",res.length>0?JSON.parse(res):res);case 7:if(!isContentType(config.contentType,Http.TEXT_PLAIN)){_context3.next=9;break}return _context3.abrupt("return",response.text());case 9:if(!isContentType(config.contentType,Http.FORM_DATA)){_context3.next=11;break}return _context3.abrupt("return",response.formData());case 11:if(!isContentType(config.contentType,Http.OCTET_STREAM)){_context3.next=13;break}return _context3.abrupt("return",response.blob());case 13:if(!(config.contentType==="buffer")){_context3.next=15;break}return _context3.abrupt("return",response.arrayBuffer());case 15:return _context3.abrupt("return",response);case 16:case"end":return _context3.stop()}},_callee3)}));return function(_x3){return _ref3.apply(this,arguments)}}())}}]);return Fetch}();var isContentType=function isContentType(contentTypeA,contentTypeB){return Util.notEmpty(contentTypeA)&&contentTypeA.search(contentTypeB)>-1};var getDefaultContentType=function getDefaultContentType(contentType){if(contentType===undefined){return Http.JSON}else if(contentType===null){return null}else{return contentType}};return new Fetch}();var Http=function(){var Http=function(){function Http(config){_classCallCheck(this,Http);config.contentType=config.contentType===undefined?Http.JSON:config.contentType;if(window.Promise){this.self=new HttpPromiseAjax(config).instance()}else{this.self=new HttpAjax(config)}}_createClass(Http,[{key:"instance",value:function instance(){return this.self}}],[{key:"get",value:function get(url,requestContentType){return new Http({method:"GET",url:url,data:undefined,contentType:requestContentType}).instance()}},{key:"post",value:function post(url,data,requestContentType){return new Http({method:"POST",url:url,data:data,contentType:requestContentType}).instance()}},{key:"put",value:function put(url,data,requestContentType){return new Http({method:"PUT",url:url,data:data,contentType:requestContentType}).instance()}},{key:"delete",value:function _delete(url,requestContentType){return new Http({method:"DELETE",url:url,data:undefined,contentType:requestContentType}).instance()}},{key:"patch",value:function patch(url,data,requestContentType){return new Http({method:"PATCH",url:url,data:data,contentType:requestContentType}).instance()}},{key:"do",value:function _do(config){return new Http(config).instance()}}]);return Http}();Http.JSON="application/json";Http.FORM_DATA="multipart/form-data";Http.TEXT_PLAIN="text/plain";Http.OCTET_STREAM="application/octet-stream";var HttpAjax=function(){function HttpAjax(config){_classCallCheck(this,HttpAjax);this.config=config;this.data=isContentTypeJson(config.contentType)?JSON.stringify(config.data):config.data;this.xhr=new XMLHttpRequest;this.xhr.open(config.method,config.url);if(config.contentType)this.xhr.setRequestHeader("Content-Type",config.contentType);if(config.headers)setXhrHeaders(this.xhr,config.headers)}_createClass(HttpAjax,[{key:"then",value:function then(successHandler,errorHandler){var _this9=this;this.xhr.onload=function(){_this9.xhr.responseJSON=tryParseJSON(_this9.xhr.responseText);isResponseOK(_this9.xhr.status)?successHandler(isContentTypeJson(_this9.config.contentType)?resolveResponse(_this9.xhr.response):_this9.xhr):errorHandler(_this9.xhr)};if(this.config.onProgress){this.xhr.onprogress=function(event){_this9.config.onProgress(event)}}if(this.config.onTimeout){this.xhr.ontimeout=function(event){_this9.config.onTimeout(event)}}this.xhr.onerror=function(){_this9.xhr.responseJSON=tryParseJSON(_this9.xhr.responseText);if(errorHandler)errorHandler(_this9.xhr)};this.data?this.xhr.send(this.data):this.xhr.send();return this}},{key:"catch",value:function _catch(errorHandler){var _this10=this;this.xhr.onerror=function(){_this10.xhr.responseJSON=tryParseJSON(_this10.xhr.responseText);if(errorHandler)errorHandler(_this10.xhr)}}}]);return HttpAjax}();var HttpPromiseAjax=function(){function HttpPromiseAjax(config){_classCallCheck(this,HttpPromiseAjax);this.promise=new Promise(function(resolve,reject){new HttpAjax(config).then(function(response){return resolve(response)},function(error){return reject(error)})})}_createClass(HttpPromiseAjax,[{key:"instance",value:function instance(){return this.promise}}]);return HttpPromiseAjax}();var resolveResponse=function resolveResponse(response){var resp=tryParseJSON(response);return Util.notEmpty(resp)?resp:response};var setXhrHeaders=function setXhrHeaders(xhr,headers){Object.keys(headers).forEach(function(header){return xhr.setRequestHeader(header,headers[header])})};var isResponseOK=function isResponseOK(status){return Boolean([200,201,202,203,204,205,206,207,208,226].find(function(num){return num===status}))};var isContentTypeJson=function isContentTypeJson(contentType){return contentType&&(Http.JSON.search(contentType.toLowerCase())>-1||contentType.toLowerCase().search(Http.JSON)>-1)};var tryParseJSON=function tryParseJSON(text){try{return JSON.parse(text)}catch(e){}};return Http}();var Key=_createClass(function Key(){_classCallCheck(this,Key)});Key.ENTER="Enter";Key.ESC="Escape";Key.TAB="Tab";Key.F1="F1";Key.F2="F2";Key.F3="F3";Key.F4="F4";Key.F5="F5";Key.F6="F6";Key.F7="F7";Key.F8="F8";Key.F9="F9";Key.F10="F10";Key.F11="F11";Key.F12="F12";Key.A="a";Key.B="b";Key.C="c";Key.D="d";Key.E="e";Key.F="f";Key.G="g";Key.H="h";Key.I="i";Key.J="j";Key.L="l";Key.M="m";Key.N="n";Key.O="o";Key.P="p";Key.Q="q";Key.R="r";Key.S="s";Key.T="t";Key.U="u";Key.V="v";Key.W="w";Key.X="x";Key.Y="y";Key.Z="z";Key.CAPS_LOCK="CapsLock";Key.NUM_LOCK="NumLock";Key.SCROLL_LOCK="ScrollLock";Key.PAUSE="Pause";Key.PRINT_SCREEN="PrintScreen";Key.PAGE_UP="PageUp";Key.PAGE_DOWN="PageDown";Key.END="End";Key.HOME="Home";Key.DELETE="Delete";Key.INSERT="Insert";Key.ALT="Alt";Key.CTRL="Control";Key.CONTEXT_MENU="ContextMenu";Key.OS="OS";Key.ALTGR="AltGraph";Key.SHIFT="Shift";Key.BACKSPACE="Backspace";Key.SECTION="\xA7";Key.ONE="1";Key.TWO="2";Key.THREE="3";Key.FOUR="4";Key.FIVE="5";Key.SIX="6";Key.SEVEN="7";Key.EIGHT="8";Key.NINE="9";Key.ZERO="0";Key.PLUS="+";Key.MINUS="-";Key.STAR="*";Key.SLASH="/";Key.ARROW_UP="ArrowUp";Key.ARROW_RIGHT="ArrowRight";Key.ARROW_DOWN="ArrowDown";Key.ARROW_LEFT="ArrowLeft";Key.COMMA=",";Key.DOT=".";var useMessages=function(){return function(locale,loader){if(Util.isFunction(loader)){RMEMessagesResolver.load(function(locale,setMessages){return setMessages(loader(locale))})}if(Util.isString(locale)||locale instanceof Event){RMEMessagesResolver.lang(locale)}return RMEMessagesResolver.locale()}}();var useMessage=function(){return function(key){for(var _len6=arguments.length,params=new Array(_len6>1?_len6-1:0),_key6=1;_key6<_len6;_key6++){params[_key6-1]=arguments[_key6]}return RMEMessagesResolver.message.apply(RMEMessagesResolver,[key].concat(params))}}();var RMEMessagesResolver=function(){var Messages=function(){function Messages(){var _this11=this;_classCallCheck(this,Messages);this.ins=this;this.messages=[];this.locale="";this.translated=[];this.load=function(){};this.messagesType;this.ready=false;ready(function(){_this11.ready=true;_this11.runTranslated()})}_createClass(Messages,[{key:"setLoad",value:function setLoad(loader){if(!Util.isFunction(loader)){throw new Error("Message loader must be a function")}this.load=loader}},{key:"setLocale",value:function setLocale(locale){this.locale=locale;return this}},{key:"setMessages",value:function setMessages(messages){if(Util.isArray(messages)){this.messagesType="array"}else if(Util.isObject(messages)){this.messagesType="map"}else{throw new Error("Given messages must be an array or an object")}this.messages=messages;this.runTranslated()}},{key:"getMessage",value:function getMessage(text){for(var _len7=arguments.length,params=new Array(_len7>1?_len7-1:0),_key7=1;_key7<_len7;_key7++){params[_key7-1]=arguments[_key7]}if(Util.isEmpty(params.flat(2))){return this.resolveMessage(text)}else{var msg=this.resolveMessage(text);return this.resolveParams(msg,params.flat(2))}}},{key:"resolveMessage",value:function resolveMessage(text){if(this.messagesType==="array"){return this.resolveMessagesArray(text)}else if(this.messagesType==="map"){return this.resolveMessagesMap(text)}}},{key:"resolveMessagesMap",value:function resolveMessagesMap(text){var msg=text;for(var i in this.messages){if(i===text){msg=this.messages[i];break}}return msg}},{key:"resolveMessagesArray",value:function resolveMessagesArray(text){var i=0;var msg=text;while(i1?_len8-1:0),_key8=1;_key8<_len8;_key8++){params[_key8-1]=arguments[_key8]}return Messages.instance.getMessage(text,params)}},{key:"load",value:function load(loader){Messages.instance.setLoad(loader)}},{key:"instance",get:function get(){if(!this.ins)this.ins=new Messages;return this.ins}}]);return Messages}();return{lang:Messages.lang,message:Messages.message,load:Messages.load,locale:Messages.locale}}();var script=function(){var addScript=function addScript(elem){var scripts=Tree.getHead().getByTag("script");if(scripts.length>0){var lastScript=scripts[scripts.length-1];lastScript.after(elem)}else{Tree.getHead().append(elem)}};return function(source,options){if(Util.notEmpty(source)){addScript(RMETemplateResolver.resolve({script:_objectSpread({src:source},options)}))}}}();var ready=function(){var callbacks=[];document.addEventListener("readystatechange",function(){if(document.readyState==="complete"){callbacks.forEach(function(callback){return callback()});callbacks.length=0}});return function(callback){callbacks.push(callback)}}();var RMEHashRouter=function RMEHashRouter(props,_ref4){var asyncTask=_ref4.asyncTask,updateState=_ref4.updateState;var routes=props.routes,_props$url=props.url,url=_props$url===void 0?location.hash:_props$url,prevUrl=props.prevUrl,prevRoute=props.prevRoute,didChange=props.didChange,globalScrollTop=props.globalScrollTop,init=props.init;if(!routes){return null}if(!init){RMERouterContext.setRouter(routes,function(url){updateState({url:url,didChange:true})});asyncTask(function(){window.addEventListener("hashchange",function(){updateState({init:true,url:location.hash,didChange:true})})})}var route;if(url!==prevUrl){route=RMERouterUtils.findRoute(url,routes,RMERouterUtils.hashMatch);asyncTask(function(){updateState({prevUrl:url,prevRoute:route},false)})}else{route=prevRoute}if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}if(route.hide){location.href=prevUrl}if(didChange&&window.scrollY>0&&(route.scrolltop===true||route.scrolltop===undefined&&globalScrollTop)){scrollTo(0,0)}asyncTask(function(){return updateState({didChange:false},false)})}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMEOnLoadUrlRouter=function RMEOnLoadUrlRouter(props,_ref5){var asyncTask=_ref5.asyncTask;var routes=props.routes;if(!routes){return null}var route=RMERouterUtils.findRoute(location.pathname,routes,RMERouterUtils.urlMatch);if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMEUrlRouter=function RMEUrlRouter(props,_ref6){var updateState=_ref6.updateState,asyncTask=_ref6.asyncTask;var routes=props.routes,url=props.url,prevUrl=props.prevUrl,prevRoute=props.prevRoute,skipPush=props.skipPush,init=props.init,didChange=props.didChange,globalScrollTop=props.globalScrollTop;if(!routes){return null}if(!init){var updateUrl=function updateUrl(url,skipPush,didChange){updateState({init:true,url:url?url:location.pathname,skipPush:skipPush,didChange:didChange})};RMERouterContext.setRouter(routes,function(url){return updateUrl(url,false,true)});asyncTask(function(){window.addEventListener("popstate",function(){return updateUrl(undefined,true,true)});updateUrl(undefined,true,true)})}var route;if(url!==prevUrl){route=RMERouterUtils.findRoute(url,routes,RMERouterUtils.urlMatch);asyncTask(function(){updateState({prevUrl:url,prevRoute:route},false)})}else{route=prevRoute}if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}if(!route.hide&&url!==prevUrl&&!skipPush){history.pushState(null,null,url)}if(didChange&&window.scrollY>0&&(route.scrolltop===true||route.scrolltop===undefined&&globalScrollTop)){scrollTo(0,0)}asyncTask(function(){return updateState({didChange:false},false)})}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMERouterContext=function(){var RouterContext=function(){function RouterContext(){_classCallCheck(this,RouterContext);this.ins;this.routers=[]}_createClass(RouterContext,[{key:"set",value:function set(key,value){if(!!key&&!!value&&!this.has(key)){this.routers.push(_objectSpread({key:key},value))}}},{key:"has",value:function has(key){return!!this.routers.find(function(route){return route.key===key})}},{key:"get",value:function get(url){var found;var prevFoundRouter;if(url.match(/^\/[^#]/)||url==="/"){var urlRouters=this.routers.filter(function(router){return router.key.match(/^:\//)});found=urlRouters.find(function(router,idx){var route=RMERouterUtils.findRoute(url,router.routes,RMERouterUtils.urlMatch);if(!!route){prevFoundRouter=router}return!!route&&idx===urlRouters.length-1});found=found||prevFoundRouter}else{var hashRouters=this.routers.filter(function(router){return router.key.match(/^:#?/)});found=hashRouters.find(function(router,idx){var route=RMERouterUtils.findRoute(url,router.routes,RMERouterUtils.hashMatch);if(!!route){prevFoundRouter=router}return!!route&&idx===hashRouters.length-1});found=found||prevFoundRouter}return!!found?found.navigateHook:function(){return undefined}}}],[{key:"createContextKey",value:function createContextKey(routes){return":".concat(routes.map(function(route){return route.route}).join(":"))}},{key:"navigateTo",value:function navigateTo(url){RouterContext.instance.get(RMERouterUtils.getUrlPath(url))(url)}},{key:"setRouter",value:function setRouter(routes,navigateHook){RouterContext.instance.set(RouterContext.createContextKey(routes),{routes:routes,navigateHook:navigateHook})}},{key:"instance",get:function get(){if(!this.ins){this.ins=new RouterContext}return this.ins}}]);return RouterContext}();return RouterContext}();var RMERouterUtils=function(){var getUrlPath=function getUrlPath(url){return url.replace(/\:{1}\/{2}/,"").match(/\/{1}.*/).join()};var urlMatch=function urlMatch(oldUrl,newUrl){oldUrl=Util.isString(oldUrl)?oldUrl.replace(/\*/g,".*").replace(/\/{2,}/g,"/"):oldUrl;var path=getUrlPath(newUrl);var found=path.match(oldUrl);if(Util.notEmpty(found)){found=found.join()}return found===path&&new RegExp(oldUrl).test(newUrl)};var hashMatch=function hashMatch(oldUrl,newUrl){if(Util.isString(oldUrl)){oldUrl=oldUrl.replace(/\*/g,".*");if(oldUrl.charAt(0)!=="#"){oldUrl="#".concat(oldUrl)}}var hash=newUrl.match(/\#{1}.*/).join();var found=hash.match(oldUrl);found=Util.notEmpty(found)?found.join():null;return found===hash&&new RegExp(oldUrl).test(newUrl)};var findRoute=function findRoute(url,routes,matcherHook){return url&&routes.find(function(route){return matcherHook(route.route,url)})};var resolveRouteElem=function resolveRouteElem(elem,props){if(Util.isFunction(elem)&&RMEComponentManagerV2.hasComponent(elem.valueOf().name)){return _defineProperty({},elem.valueOf().name,props)}else if(Util.isString(elem)&&RMEComponentManagerV2.hasComponent(elem)){return _defineProperty({},elem,props)}else{return{_:elem.toTemplate()}}};return{getUrlPath:getUrlPath,findRoute:findRoute,urlMatch:urlMatch,hashMatch:hashMatch,resolveRouteElem:resolveRouteElem}}();var useHashRouter=function(){return function(routes){var scrollTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;Component(RMEHashRouter);return{RMEHashRouter:{routes:routes,globalScrollTop:scrollTop}}}}();var useOnLoadUrlRouter=function(){return function(routes){Component(RMEOnLoadUrlRouter);return{RMEOnLoadUrlRouter:{routes:routes}}}}();var useUrlRouter=function(){return function(routes){var scrollTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;Component(RMEUrlRouter);return{RMEUrlRouter:{routes:routes,globalScrollTop:scrollTop}}}}();var useRouter=function(){return function(url){if(Util.isString(url)){RMERouterContext.navigateTo(url)}else if(url instanceof Event){url.preventDefault();RMERouterContext.navigateTo(url.target.href)}}}();var RMETemplateElement=function(_Elem){_inherits(RMETemplateElement,_Elem);var _super=_createSuper(RMETemplateElement);function RMETemplateElement(type){var _this12;_classCallCheck(this,RMETemplateElement);_this12=_super.call(this,type);_this12.props={};_this12.stringProps;_this12.listeners=[];_this12.attributes=[];_this12.attributeString="";_this12.listenerObj={};_this12.listenerString="";_this12.children=[];_this12.inlineProps={};return _this12}_createClass(RMETemplateElement,[{key:"hasListeners",value:function hasListeners(){return this.listeners.length>0}},{key:"updateListeners",value:function updateListeners(elem){var _this13=this;if(elem.hasListeners()){elem.listeners.forEach(function(listener){_this13[listener.parentProp.name].call(_this13,listener.func)});RMETemplateElement.Util.setListeners(this,elem.listeners)}}},{key:"removeDetachedChildren",value:function removeDetachedChildren(elem){var _this14=this;if(elem.children.length===0){this.children.forEach(function(child,idx){if(child.dom().parentElement===null){_this14.children.splice(idx,1)}})}}},{key:"setParams",value:function setParams(){var attrs=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var listeners=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];RMETemplateElement.Util.setAttributes(this,attrs);RMETemplateElement.Util.setListeners(this,listeners);RMETemplateElement.Util.formProps(this)}},{key:"updateAttributes",value:function updateAttributes(elem){RMETemplateElement.Util.setAttributes(this,elem.attributes,true);this.inlineProps=elem.inlineProps;RMETemplateElement.Util.formProps(this)}},{key:"setId",value:function setId(id){_get(_getPrototypeOf(RMETemplateElement.prototype),"setId",this).call(this,id);this.inlineProps.id=id;RMETemplateElement.Util.formProps(this);return this}},{key:"addClasses",value:function addClasses(classes){_get(_getPrototypeOf(RMETemplateElement.prototype),"addClasses",this).call(this,classes);this.inlineProps["class"]=_get(_getPrototypeOf(RMETemplateElement.prototype),"getClasses",this).call(this);RMETemplateElement.Util.formProps(this);return this}},{key:"addInlineAttr",value:function addInlineAttr(key,val){this.inlineProps[key]=val;RMETemplateElement.Util.formProps(this)}},{key:"append",value:function append(element){this.children.push(element);_get(_getPrototypeOf(RMETemplateElement.prototype),"append",this).call(this,element);return this}},{key:"remove",value:function remove(index,element){this.children.splice(index,1);_get(_getPrototypeOf(RMETemplateElement.prototype),"remove",this).call(this,element);return this}},{key:"replace",value:function replace(index,parent,element){parent.children.splice(index,1,element);this.inlineProps=element.inlineProps;RMETemplateElement.Util.formProps(element);_get(_getPrototypeOf(RMETemplateElement.prototype),"replace",this).call(this,element);return this}},{key:"setProps",value:function setProps(props){RMETemplateElement.Util.updateBrowserSetStyle(this,props);RMETemplateResolver.updateElemProps(this,props,this.props);return this}},{key:"equals",value:function equals(other){return this.stringProps===other.stringProps&&this.listenerString===other.listenerString}},{key:"getPropsString",value:function getPropsString(){return this.stringProps}},{key:"getPropsObj",value:function getPropsObj(){return this.props}},{key:"duplicate",value:function duplicate(){return RMETemplateElement.Util.duplicateElem(this)}}]);return RMETemplateElement}(Elem);RMETemplateElement.Util=function(){function RMETemplateElementUtil(){_classCallCheck(this,RMETemplateElementUtil)}_createClass(RMETemplateElementUtil,null,[{key:"duplicateElem",value:function duplicateElem(elem){var dup=new RMETemplateElement(elem.getTagName().toLowerCase());dup.inlineProps=elem.inlineProps;dup.setParams(elem.attributes,elem.listeners);RMETemplateResolver.updateElemProps(dup,elem.props,elem.props);if(elem.children.length>0){elem.children.map(function(child){return RMETemplateElement.Util.duplicateElem(child)}).forEach(function(child){return dup.append(child)})}return dup}},{key:"setListeners",value:function setListeners(elem,listeners){if(listeners.length>0){elem.listeners=listeners;elem.listenerObj=listeners.reduce(function(prev,curr){prev[curr.parentProp.name]=curr.func;return prev},{});elem.listenerString=listeners.map(function(listener){return listener.parentProp.name}).join()}}},{key:"setAttributes",value:function setAttributes(elem,attrs,override){if(attrs.length>0||override){elem.attributes=attrs.filter(function(attr){if(attr.key!=="class"){return attr}});elem.attributeString=elem.attributes.map(function(attr){return"".concat(attr.key,":").concat(attr.val)}).join().trim()}}},{key:"formProps",value:function formProps(elem){var props=elem.attributes.reduce(function(prev,curr){prev[curr.key]=curr.val;return prev},_objectSpread(_objectSpread({},elem.inlineProps),elem.listenerObj));elem.props=props;elem.stringProps=JSON.stringify(props)}},{key:"updateBrowserSetStyle",value:function updateBrowserSetStyle(elem,props){var style=elem.getAttribute("style");if(style){props.style=style}}}]);return RMETemplateElementUtil}();var RMETemplateFragmentHelper=function(){var FRAGMENT_REGEXP=/^_+$/g;var RMETemplateFragmentHelper=function(){function RMETemplateFragmentHelper(){_classCallCheck(this,RMETemplateFragmentHelper)}_createClass(RMETemplateFragmentHelper,[{key:"getFragmentKey",value:function getFragmentKey(template){return Object.keys(template).find(this.isFragmentKey)}},{key:"resolveFragmentValue",value:function resolveFragmentValue(template,templateValue){var fragmentKey=this.getFragmentKey(template);return template[fragmentKey]||template.fragment||templateValue}},{key:"isFragment",value:function isFragment(template){return Util.notEmpty(template)&&(template==="fragment"||Boolean(this.getFragmentKey(template)))}},{key:"isFragmentKey",value:function isFragmentKey(key){return key.match(FRAGMENT_REGEXP)||key.indexOf("fragment")===0}}]);return RMETemplateFragmentHelper}();return new RMETemplateFragmentHelper}();var RMETemplateResolver=function(){var Template=function(){function Template(){_classCallCheck(this,Template);this.template={};this.root=null;this.appName;this.context}_createClass(Template,[{key:"setTemplateAndResolve",value:function setTemplateAndResolve(template,parent){var appName=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"";var context=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"";var componentLiteral=arguments.length>4?arguments[4]:undefined;this.template=template;this.appName=appName;this.context=context;if(parent){this.root=parent;if(componentLiteral){var key=Object.keys(this.template).shift();this.template=_defineProperty({},"".concat(key).concat(componentLiteral),this.template[key])}this.resolveNextParent(this.template,this.root,1)}else{this.resolveRootAndTemplate();this.resolveNextParent(this.template,this.root,1)}return this.root}},{key:"resolveRootAndTemplate",value:function resolveRootAndTemplate(){var key=Object.keys(this.template).shift();this.root=Template.resolveStringNumber(this.resolveElement(key,this.template),this.template);if(Util.isFunction(this.template[key])){this.template=this.template[key].call(this.root,this.root)}else{this.template=this.template[key]}}},{key:"resolveTemplateProperties",value:function resolveTemplateProperties(template,parent){var attrs=[];var listeners=[];var children=[];if(Util.isString(template)||Util.isNumber(template)){if(Util.isString(template)&&Template.isMessage(template)){attrs.push({key:"message",val:template})}else{attrs.push({key:"text",val:template})}}else if(Util.isArray(template)){template.forEach(function(obj){var key=Object.keys(obj).shift();var val=Object.values(obj).shift();children.push({key:key,val:Template.isComponent(key)&&Util.isFunction(val)?{}:val})})}else if(Util.isObject(template)){Object.keys(template).forEach(function(key,i){if(Template.isAttr(key,parent)){attrs.push({key:key,val:template[key]})}else if(Template.isEventKeyVal(key,template[key])){listeners.push({parentProp:parent[key],func:template[key]})}else if(Template.isTag(Template.getElementName(key))){children.push({key:key,val:template[key]})}else if(Template.isComponent(key)){children.push({key:key,val:!Util.isFunction(template[key])?template[key]:{}})}else if(RMETemplateFragmentHelper.isFragmentKey(key)){children.push({key:key,val:template[key]})}})}parent.setParams(attrs,listeners);return[attrs,listeners,children]}},{key:"resolveTemplate",value:function resolveTemplate(template,parent,round,parentContext){var _this15=this;var _this$resolveTemplate=this.resolveTemplateProperties(template,parent),_this$resolveTemplate2=_slicedToArray(_this$resolveTemplate,3),attrs=_this$resolveTemplate2[0],listeners=_this$resolveTemplate2[1],children=_this$resolveTemplate2[2];attrs.forEach(function(attr){return Template.resolveAttributes(parent,attr.key,_this15.resolveFunctionValue(attr.val,parent))});listeners.forEach(function(listener){return _this15.bindEventToElement(parent,listener.func,listener.parentProp)});children.forEach(function(rawChild,idx){if(RMETemplateFragmentHelper.isFragmentKey(rawChild.key)){_this15.resolveNextParent(rawChild.val,parent,round,parentContext+rawChild.key)}else{_this15.resolveChild(rawChild.key,rawChild.val,parent,round,idx,parentContext)}});round++}},{key:"resolveChild",value:function resolveChild(key,val,parent,round,invoked){var parentContext=arguments.length>5&&arguments[5]!==undefined?arguments[5]:"";var name=Template.getElementName(key);if(RMEComponentManagerV2.hasComponent(name)){var component=RMEComponentManagerV2.getComponent(name,this.resolveComponentLiteralVal(val),parent,this.cutComponentLiteral(name,key),"".concat(parentContext).concat(round).concat(invoked),this.appName);if(RMETemplateFragmentHelper.isFragment(component)&&Util.notEmpty(component)){this.resolveNextParent(RMETemplateFragmentHelper.resolveFragmentValue(component,val),parent,round)}}else{var child=Template.resolveStringNumber(this.resolveElement(key,val),val);parent.append(child);this.resolveNextParent(val,child,round,parentContext)}}},{key:"cutComponentLiteral",value:function cutComponentLiteral(name,key){return key.match("[^".concat(name,"].*"))}},{key:"resolveComponentLiteralVal",value:function resolveComponentLiteralVal(val){if(Util.isString(val)&&Template.isMessage(val)){return{message:val}}else if(Util.isString(val)||Util.isNumber(val)){return{text:val}}else{return val}}},{key:"resolveNextParent",value:function resolveNextParent(obj,parent,round){var _this16=this;var parentContext=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"";var arr=Array.of(this.resolveFunctionValue(obj,parent)).flat();var parentTag=Util.isEmpty(parent)?parentContext:parentContext+parent.getTagName().toLowerCase();arr.forEach(function(item,i){return _this16.resolveTemplate(item,parent,round,"".concat(_this16.context).concat(parentTag,"[").concat(i,"]"))})}},{key:"bindEventToElement",value:function bindEventToElement(elemInstance,sourceFunction,targetFunction){targetFunction.call(elemInstance,sourceFunction)}},{key:"resolveFunctionValue",value:function resolveFunctionValue(value,parent){return Util.isFunction(value)?value.call(parent,parent):value}},{key:"resolveElement",value:function resolveElement(tag,obj){var resolved=null;var match=[];var el=Template.getElementName(tag);if(Util.isString(el)&&Template.isTag(el)){resolved=new RMETemplateElement(el)}else{resolved=obj}match=tag.match(/[a-z0-9]+\#[a-zA-Z0-9\-]+/);if(!Util.isEmpty(match))resolved.setId(match.join().replace(/[a-z0-9]+\#/g,""));match=this.cutAttributesIfFound(tag).match(/\.[a-zA-Z-0-9\-]+/g);if(!Util.isEmpty(match))resolved.addClasses(match.join(" ").replace(/\./g,""));match=tag.match(/\[[a-zA-Z0-9\= \:\(\)\#\-\_\/\.&%@!?£$+¤|;\\<\\>\\{}"]+\]/g);if(!Util.isEmpty(match))resolved=Template.addAttributes(resolved,match);return resolved}},{key:"cutAttributesIfFound",value:function cutAttributesIfFound(tag){return tag.replace(/\[.+\]/g,"")}}],[{key:"resolveStringNumber",value:function resolveStringNumber(elem,value){if(Util.isString(value)&&Template.isMessage(value)){Template.resolveMessage(elem,value)}else if(Util.isString(value)||Util.isNumber(value)){elem.setText(value)}return elem}},{key:"isMessage",value:function isMessage(message){message=Template.normalizeMessageString(message);return Util.notEmpty(RMEMessagesResolver.message(message))&&RMEMessagesResolver.message(message)!=message}},{key:"addAttributes",value:function addAttributes(elem,attrArray){var i=0;var start="[";var eq="=";var end="]";while(i"data".length)elem.setData(key.replace(/[A-Z]/,key.charAt(4).toLowerCase()).replace("data",""),val);else elem.setAttribute(key,val)}},{key:"resolveContent",value:function resolveContent(elem,key,val){if(elem.getTagName().toLowerCase()==="meta")elem.setAttribute(key,val);else elem.setContent(val)}},{key:"resolveMessage",value:function resolveMessage(elem,message){if(Util.isEmpty(message))throw"message must not be empty";elem.message(Template.normalizeMessageString(message),Template.getMessageParams(message))}},{key:"getMessageParams",value:function getMessageParams(message){var match=Template.getMessageParameterString(message);match=match&&match.join().replace(/({|}|:|;)/g,match.join()).split(match.join());return match&&match.filter(Util.notEmpty)}},{key:"getMessageParameterString",value:function getMessageParameterString(message){return message.match(/\:?(\{.*\}\;?)/g)}},{key:"normalizeMessageString",value:function normalizeMessageString(message){var params=Template.getMessageParameterString(message);return Util.notEmpty(params)?message.replace(params.join(),""):message}},{key:"isEventKeyVal",value:function isEventKeyVal(key,val){return key.indexOf("on")===0&&Util.isFunction(val)}},{key:"getElementName",value:function getElementName(str){if(Util.notEmpty(str))return str.match(/component:?[a-zA-Z0-9_]+|[a-zA-Z0-9_]+/).join()}},{key:"isComponent",value:function isComponent(key){return RMEComponentManagerV2.hasComponent(Template.getElementName(key))}},{key:"resolve",value:function resolve(template,parent,appName,context,componentLiteral){return Template.create().setTemplateAndResolve(template,parent,appName,context,componentLiteral)}},{key:"updateElemProps",value:function updateElemProps(elem,props,oldProps){var combined=Template.combineProps(props,oldProps);Object.entries(combined).forEach(function(_ref9){var _ref10=_slicedToArray(_ref9,2),prop=_ref10[0],value=_ref10[1];if(prop==="text"){value?elem.setText(value):elem.setText("")}else if(Template.isEventKeyVal(prop,value)){elem[prop].call(elem,value)}else if(prop==="class"){value?elem.updateClasses(value):elem.removeAttribute(prop)}else if(prop==="value"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop);elem.setValue(value)}else if(prop==="tabIndex"){value?elem.setTabIndex(value):elem.removeAttribute("tabindex")}else if(prop==="editable"){value?elem.setEditable(value):elem.removeAttribute("contenteditable")}else if(prop==="maxLength"){value?elem.setMaxLength(value):elem.removeAttribute("maxlength")}else if(prop==="minLength"){value?elem.setMinLength(value):elem.removeAttribute("minlength")}else if(prop==="data"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop)}else if(prop==="content"&&elem.getTagName().toLowerCase()==="meta"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop)}else if(prop==="content"){elem.setContent(value)}else{value?Template.resolveAttributes(elem,prop,value):elem.removeAttribute(prop)}})}},{key:"combineProps",value:function combineProps(newProps,oldProps){Object.keys(oldProps).forEach(function(prop){if(oldProps[prop]&&!newProps[prop]){oldProps[prop]=undefined}});return _objectSpread(_objectSpread({},oldProps),newProps)}},{key:"create",value:function create(){return new Template}},{key:"isTemplate",value:function isTemplate(object){var isTemplate=false;if(Util.isObject(object)&&!Util.isArray(object)&&!(object instanceof RMETemplateElement)){for(var p in object){isTemplate=object.hasOwnProperty(p)&&Template.isTagOrComponent(p);if(isTemplate)break}}return isTemplate}},{key:"isTagOrComponent",value:function isTagOrComponent(tag){return Template.isComponent(tag)||Template.isTag(Template.getElementName(tag))}},{key:"isTag",value:function isTag(tag){var tags={a:["a","abbr","acronym","address","applet","area","article","aside","audio"],b:["button","br","b","base","basefont","bdi","bdo","big","blockquote","body"],c:["canvas","caption","center","cite","code","col","colgroup"],d:["div","dd","dl","dt","data","datalist","del","details","dfn","dialog"],e:["em","embed"],f:["form","fieldset","figcaption","figure","font","footer","frame","frameset"],h:["h1","h2","h3","h4","h5","h6","head","header","hr","html"],i:["i","input","img","iframe","ins"],k:["kbd"],l:["label","li","legend","link"],m:["main","meta","map","mark","meter"],n:["nav","noframes","noscript"],o:["option","object","ol","optgroup","output"],p:["p","pre","param","picture","progress"],q:["q"],r:["rp","rt","ruby"],s:["span","select","s","samp","script","section","small","source","strike","strong","style","sub","summary","sup","svg"],t:["table","textarea","td","tr","tt","th","thead","tbody","tfoot","template","time","title","track"],u:["u","ul"],v:["var","video"],w:["wbr"]};var i=0;var tagArray=tags[tag.charAt(0)];if(tagArray){while(i-1?"".concat(key.substring(0,capital),"-").concat(key.substr(capital).toLowerCase()):key}},{key:"isElem",value:function isElem(elemTag,array){var i=0;while(i=0;--i){var entry=this.tryEntries[i],record=entry.completion;if("root"===entry.tryLoc)return handle("end");if(entry.tryLoc<=this.prev){var hasCatch=hasOwn.call(entry,"catchLoc"),hasFinally=hasOwn.call(entry,"finallyLoc");if(hasCatch&&hasFinally){if(this.prev=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc<=this.prev&&hasOwn.call(entry,"finallyLoc")&&this.prev=0;--i){var entry=this.tryEntries[i];if(entry.finallyLoc===finallyLoc)return this.complete(entry.completion,entry.afterLoc),resetTryEntry(entry),ContinueSentinel}},"catch":function _catch(tryLoc){for(var i=this.tryEntries.length-1;i>=0;--i){var entry=this.tryEntries[i];if(entry.tryLoc===tryLoc){var record=entry.completion;if("throw"===record.type){var thrown=record.arg;resetTryEntry(entry)}return thrown}}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(iterable,resultName,nextLoc){return this.delegate={iterator:values(iterable),resultName:resultName,nextLoc:nextLoc},"next"===this.method&&(this.arg=undefined),ContinueSentinel}},exports}function asyncGeneratorStep(gen,resolve,reject,_next,_throw,key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(_next,_throw)}}function _asyncToGenerator(fn){return function(){var self=this,args=arguments;return new Promise(function(resolve,reject){var gen=fn.apply(self,args);function _next(value){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"next",value)}function _throw(err){asyncGeneratorStep(gen,resolve,reject,_next,_throw,"throw",err)}_next(undefined)})}}function ownKeys(object,enumerableOnly){var keys=Object.keys(object);if(Object.getOwnPropertySymbols){var symbols=Object.getOwnPropertySymbols(object);enumerableOnly&&(symbols=symbols.filter(function(sym){return Object.getOwnPropertyDescriptor(object,sym).enumerable})),keys.push.apply(keys,symbols)}return keys}function _objectSpread(target){for(var i=1;iarr.length)len=arr.length;for(var i=0,arr2=new Array(len);i0){var lastIdx=this.pendingRemove.length-1;while(lastIdx>=0){this.pendingRemove[lastIdx].parent.remove(this.pendingRemove[lastIdx].index,this.pendingRemove[lastIdx].child);lastIdx--}this.pendingRemove.length=0}}}]);return RMEElemRenderer}();var Browser=function(){function Browser(){_classCallCheck(this,Browser)}_createClass(Browser,null,[{key:"setTimeout",value:function setTimeout(callback,milliseconds){for(var _len=arguments.length,params=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){params[_key-2]=arguments[_key]}return window.setTimeout(callback,milliseconds,params)}},{key:"clearTimeout",value:function clearTimeout(timeoutObject){window.clearTimeout(timeoutObject)}},{key:"setInterval",value:function setInterval(callback,milliseconds){for(var _len2=arguments.length,params=new Array(_len2>2?_len2-2:0),_key2=2;_key2<_len2;_key2++){params[_key2-2]=arguments[_key2]}return window.setInterval(callback,milliseconds,params)}},{key:"clearInterval",value:function clearInterval(intervalObject){window.clearInterval(intervalObject)}},{key:"toBase64",value:function toBase64(string){return window.btoa(string)}},{key:"fromBase64",value:function fromBase64(string){return window.atob(string)}},{key:"scrollTo",value:function scrollTo(xPos,yPos){window.scrollTo(xPos,yPos)}},{key:"scrollBy",value:function scrollBy(xPx,yPx){window.scrollBy(xPx,yPx)}},{key:"open",value:function open(url,name,specs,replace){return window.open(url,name,specs,replace)}},{key:"close",value:function close(openedWindow){openedWindow.close()}},{key:"print",value:function print(){window.print()}},{key:"alert",value:function alert(message){window.alert(message)}},{key:"confirm",value:function confirm(message){return window.confirm(message)}},{key:"prompt",value:function prompt(message,defaultText){return window.prompt(message,defaultText)}},{key:"mediaMatcher",value:function mediaMatcher(mediaString){if(mediaString.indexOf("(")!==0)mediaString="("+mediaString;if(mediaString.indexOf(")")!==mediaString.length-1)mediaString=mediaString+")";return window.matchMedia(mediaString)}},{key:"pageBack",value:function pageBack(){history.back()}},{key:"pageForward",value:function pageForward(){history.forward()}},{key:"pageGo",value:function pageGo(numberOfPagesOrUrl){history.go(numberOfPagesOrUrl)}},{key:"pushState",value:function pushState(stateObject,title,newURL){history.pushState(stateObject,title,newURL)}},{key:"replaceState",value:function replaceState(stateObject,title,newURL){history.replaceState(stateObject,title,newURL)}},{key:"newPage",value:function newPage(newURL){location.assign(newURL)}},{key:"reloadPage",value:function reloadPage(force){location.reload(force)}},{key:"replacePage",value:function replacePage(newURL){location.replace(newURL)}},{key:"getAnchorHash",value:function getAnchorHash(){return location.hash}},{key:"setAnchorHash",value:function setAnchorHash(hash){location.hash=hash}},{key:"getHostnamePort",value:function getHostnamePort(){return location.host}},{key:"setHostnamePort",value:function setHostnamePort(hostPort){location.host=hostPort}},{key:"getHostname",value:function getHostname(){return location.hostname}},{key:"setHostname",value:function setHostname(hostname){location.hostname=hostname}},{key:"getURL",value:function getURL(){return location.href}},{key:"setURL",value:function setURL(newURL){location.href=newURL}},{key:"getOrigin",value:function getOrigin(){return location.origin}},{key:"getPathname",value:function getPathname(){return location.pathname}},{key:"setPathname",value:function setPathname(pathname){location.pathname=pathname}},{key:"getPort",value:function getPort(){return location.port}},{key:"setPort",value:function setPort(portNumber){location.port=portNumber}},{key:"getProtocol",value:function getProtocol(){return location.protocol}},{key:"setProtocol",value:function setProtocol(protocol){location.protocol=protocol}},{key:"getSearchString",value:function getSearchString(){return location.search}},{key:"setSearchString",value:function setSearchString(searchString){location.search=searchString}},{key:"getCodename",value:function getCodename(){return navigator.appCodeName}},{key:"getName",value:function getName(){return navigator.appName}},{key:"getVersion",value:function getVersion(){return navigator.appVersion}},{key:"isCookiesEnabled",value:function isCookiesEnabled(){return navigator.cookieEnabled}},{key:"getGeoLocation",value:function getGeoLocation(){return navigator.geolocation}},{key:"getLanguage",value:function getLanguage(){return navigator.language}},{key:"getPlatform",value:function getPlatform(){return navigator.platform}},{key:"getProduct",value:function getProduct(){return navigator.product}},{key:"getUserAgentHeader",value:function getUserAgentHeader(){return navigator.userAgent}},{key:"getColorDepth",value:function getColorDepth(){return screen.colorDepth}},{key:"getFullScreenHeight",value:function getFullScreenHeight(){return screen.height}},{key:"getFullScreenWidth",value:function getFullScreenWidth(){return screen.width}},{key:"getAvailableScreenHeight",value:function getAvailableScreenHeight(){return screen.availHeight}},{key:"getAvailableScreenWidth",value:function getAvailableScreenWidth(){return screen.availWidth}}]);return Browser}();var RMEAppComponent=function(){function RMEAppComponent(renderHook,appName,parentContext){_classCallCheck(this,RMEAppComponent);this.store=useValue({},appName);this.appName=appName;this.parentContext=parentContext;this.shouldUpdate=true;this.renderHook=renderHook;this.afterRenderTasks=[];this.prevProps={};this.prevResult}_createClass(RMEAppComponent,[{key:"render",value:function render(props,parent,componentLiteral){var _this4=this;var _this$store=_slicedToArray(this.store,2),getState=_this$store[0],setState=_this$store[1];var nextProps=_objectSpread(_objectSpread({},props),getState());var ops={setState:setState,updateState:function updateState(next,update){setState(function(state){return _objectSpread(_objectSpread({},state),Util.isFunction(next)?next(getState()):next)},update)},isStateEmpty:function isStateEmpty(){return Object.keys(getState()).length===0},shouldComponentUpdate:function shouldComponentUpdate(shouldUpdateHook){if(Util.isFunction(shouldUpdateHook)){_this4.shouldUpdate=shouldUpdateHook(nextProps,_this4.prevProps)!==false}},asyncTask:function asyncTask(asyncTaskHook){if(Util.isFunction(asyncTaskHook)){_this4.afterRenderTasks.push(asyncTaskHook)}}};var result;if(this.shouldUpdate){result=this.renderHook(nextProps,ops);result=RMETemplateResolver.isTemplate(result)?RMETemplateResolver.resolve(result,parent,this.appName,this.parentContext,componentLiteral):result}else{result=this.prevResult}this.prevResult=result;this.prevProps=nextProps;if(this.afterRenderTasks.length>0){Browser.setTimeout(_asyncToGenerator(_regeneratorRuntime().mark(function _callee2(){return _regeneratorRuntime().wrap(function _callee2$(_context2){while(1)switch(_context2.prev=_context2.next){case 0:_this4.afterRenderTasks.forEach(function(){var _ref2=_asyncToGenerator(_regeneratorRuntime().mark(function _callee(hook){return _regeneratorRuntime().wrap(function _callee$(_context){while(1)switch(_context.prev=_context.next){case 0:return _context.abrupt("return",hook());case 1:case"end":return _context.stop()}},_callee)}));return function(_x2){return _ref2.apply(this,arguments)}}());_this4.afterRenderTasks.length=0;case 2:case"end":return _context2.stop()}},_callee2)})))}return result}}]);return RMEAppComponent}();var Component=function(){var resolveComponent=function resolveComponent(component){if(Util.isFunction(component)){RMEComponentManagerV2.addComponent(component.valueOf().name,component)}};return function(){for(var _len3=arguments.length,components=new Array(_len3),_key3=0;_key3<_len3;_key3++){components[_key3]=arguments[_key3]}components.forEach(function(component){return!Util.isEmpty(component.valueOf().name)&&resolveComponent(component)});return components.length===1?components[0]:components}}();var RMEComponentManagerV2=function(){var RMEComponentManager=function(){function RMEComponentManager(){_classCallCheck(this,RMEComponentManager);this.componentFunctionMap={};this.componentInstanceMap={}}_createClass(RMEComponentManager,[{key:"hasComponent",value:function hasComponent(name){return this.componentFunctionMap[name]!==undefined}},{key:"addComponent",value:function addComponent(name,renderHook){if(!this.hasComponent(name)){this.componentFunctionMap[name]=renderHook}}},{key:"getComponent",value:function getComponent(name,props,parent,componentLiteral){var parentContext=arguments.length>4&&arguments[4]!==undefined?arguments[4]:"";var appName=arguments.length>5&&arguments[5]!==undefined?arguments[5]:"";var component=this.componentInstanceMap[appName+name+parentContext];if(!component){component=new RMEAppComponent(this.componentFunctionMap[name],appName,parentContext);this.componentInstanceMap[appName+name+parentContext]=component}return component.render(props,parent,componentLiteral)}}]);return RMEComponentManager}();return new RMEComponentManager}();var CSS=function(){var getStyles=function getStyles(config){var styles=Tree.getHead().getByTag("style");if(Util.isEmpty(config)&&!Util.isArray(styles)){return styles}else if(Util.isArray(styles)){return styles.find(function(style){return arePropertiesSame(style.getProps(),config)})}else if(!Util.isEmpty(styles)&&arePropertiesSame(styles.getProps(),config)){return styles}};var propsWithoutContent=function propsWithoutContent(props){var newProps=_objectSpread({},props);delete newProps.text;return newProps};var arePropertiesSame=function arePropertiesSame(oldProps,newProps){return JSON.stringify(propsWithoutContent(oldProps))===JSON.stringify(newProps||{})};var hasStyles=function hasStyles(config){return!Util.isEmpty(getStyles(config))};var hasContent=function hasContent(content,config){var styles=getStyles(config);if(!Util.isEmpty(styles)){return styles.getContent().match(content)!==null}};return function(content,config){if(!hasStyles(config)){Tree.getHead().append(RMETemplateResolver.resolve({style:_objectSpread({content:content},config)}))}else if(!hasContent(content,config)){var style=getStyles(config);if(!Util.isEmpty(style)){var prevContent=style.getContent();style.setContent(prevContent+content)}}}}();var Elem=function(){function Elem(type){_classCallCheck(this,Elem);if(Util.isString(type)){this.html=document.createElement(type)}else if(type.nodeType!==undefined&&type.ownerDocument!==undefined&&type.nodeType>=1&&type.ownerDocument instanceof Document){this.html=type}else{throw"type must be a string or a Document"}}_createClass(Elem,[{key:"setText",value:function setText(text){if(this.html.hasChildNodes()){this.html.replaceChild(document.createTextNode(text),this.html.childNodes[0])}else{this.html.appendChild(document.createTextNode(text))}return this}},{key:"getText",value:function getText(){var text="";this.html.childNodes.forEach(function(node){if(node.nodeType===3){text=node.nodeValue}});return text}},{key:"getContent",value:function getContent(){return this.html.innerHTML}},{key:"setContent",value:function setContent(html){this.html.innerHTML=html;return this}},{key:"setValue",value:function setValue(value){this.html.value=value;return this}},{key:"getValue",value:function getValue(){return this.html.value}},{key:"setId",value:function setId(id){this.html.id=id;return this}},{key:"getId",value:function getId(){return this.html.id}},{key:"append",value:function append(elem){elem&&this.html.appendChild(elem.dom());return this}},{key:"remove",value:function remove(elem){this.html.removeChild(elem.dom());return this}},{key:"replace",value:function replace(newElem){this.html.parentElement.replaceChild(newElem.dom(),this.html);return this}},{key:"before",value:function before(newElem){this.html.parentElement.insertBefore(newElem.dom(),this.html);return this}},{key:"after",value:function after(newElem){if(this.html.nextElementSibling!==null)this.html.parentElement.insertBefore(newElem.dom(),this.html.nextElementSibling);else this.html.parentElement.appendChild(newElem.dom());return this}},{key:"toString",value:function toString(){return"<"+this.getTagName().toLowerCase()+">"+this.getContent()+""+this.getTagName().toLowerCase()+">"}},{key:"toLiteralString",value:function toLiteralString(){return RMEElemTemplater.toLiteralString(this)}},{key:"toTemplate",value:function toTemplate(deep){return RMEElemTemplater.toTemplate(this,deep)}},{key:"getProps",value:function getProps(json){if(json===true)return JSON.stringify(RMEElemTemplater.getElementProps(this));else return RMEElemTemplater.getElementProps(this)}},{key:"setProps",value:function setProps(props){RMETemplateResolver.updateElemProps(this,props,this.getProps());return this}},{key:"render",value:function render(){var newState=[];var i=0;for(var _len4=arguments.length,elems=new Array(_len4),_key4=0;_key4<_len4;_key4++){elems[_key4]=arguments[_key4]}var max=elems.length;while(i0)updateClassesArray.push(clazz)});this.html.className=updateClassesArray.join(" ").trim();return this}},{key:"removeClasses",value:function removeClasses(classes){var toRm=classes.trim().split(" ");var origClass="".concat(this.getClasses());var i=0;while(i1?_len5-1:0),_key5=1;_key5<_len5;_key5++){params[_key5-1]=arguments[_key5]}while(i0&&this.deep){children.forEach(function(child){return _this8.resolve(child,resolved)})}this.template=resolved}},{key:"extendMap",value:function extendMap(map,next){for(var v in next){if(next.hasOwnProperty(v)){map[v]=next[v]}}}},{key:"resolveElem",value:function resolveElem(elem,props){var el={};var children=elem.getChildren();if(Util.isArray(children)&&children.length>1){var elTag=elem.getTagName().toLowerCase();var elName=this.resolveId(elTag,props);elName=this.resolveClass(elName,props);elName=this.resolveAttrs(elName,props);el[elName]=_objectSpread(_objectSpread({},props),{},{_:[]})}else{el[elem.getTagName().toLowerCase()]=props}return el}},{key:"resolveId",value:function resolveId(tag,props){if(props.id)return tag+"#"+props.id;else return tag}},{key:"resolveClass",value:function resolveClass(tag,props){if(props["class"])return tag+"."+props["class"].replace(/ /g,".");else return tag}},{key:"resolveAttrs",value:function resolveAttrs(tag,props){var tagName=tag;for(var p in props){if(props.hasOwnProperty(p)&&p!=="id"&&p!=="class"&&p.indexOf("on")!==0){tagName+="[".concat(p,"=").concat(props[p],"]")}}return tagName}},{key:"resolveProps",value:function resolveProps(elem){var props={};var attributes=elem.dom().attributes;var a=0;if(attributes){while(a"data".length){while(attrName.search("-")>-1){attrName=attrName.replace(/-\w/,attrName.charAt(attrName.search("-")+1).toUpperCase())}return attrName}else if(attrName.indexOf("aria")===0){return attrName.replace(attrName.charAt("aria".length),attrName.charAt("aria".length).toUpperCase())}else{return attrName}}},{key:"resolveListeners",value:function resolveListeners(name){switch(name){case"onanimationstart":return"onAnimationStart";case"onanimationiteration":return"onAnimationIteration";case"onanimationend":return"onAnimationEnd";case"ontransitionend":return"onTransitionEnd";case"ondrag":return"onDrag";case"ondragend":return"onDragEnd";case"ondragenter":return"onDragEnter";case"ondragover":return"onDragOver";case"ondragstart":return"onDragStart";case"ondrop":return"onDrop";case"onclick":return"onClick";case"ondblclick":return"onDoubleClick";case"oncontextmenu":return"onContextMenu";case"onmousedown":return"onMouseDown";case"onmouseenter":return"onMouseEnter";case"onmouseleave":return"onMouseLeave";case"onmousemove":return"onMouseMove";case"onmouseover":return"onMouseOver";case"onmouseout":return"onMouseOut";case"onmouseup":return"onMouseUp";case"onwheel":return"onWheel";case"onscroll":return"onScroll";case"onresize":return"onResize";case"onerror":return"onError";case"onload":return"onLoad";case"onunload":return"onUnload";case"onbeforeunload":return"onBeforeUnload";case"onkeyup":return"onKeyUp";case"onkeydown":return"onKeyDown";case"onkeypress":return"onKeyPress";case"oninput":return"onInput";case"onchange":return"onChange";case"onsubmit":return"onSubmit";case"onselect":return"onSelect";case"onreset":return"onReset";case"onfocus":return"onFocus";case"onfocusin":return"onFocusIn";case"onfocusout":return"onFocusOut";case"onblur":return"onBlur";case"oncopy":return"onCopy";case"oncut":return"onCut";case"onpaste":return"onPaste";case"onabort":return"onAbort";case"onwaiting":return"onWaiting";case"onvolumechange":return"onVolumeChange";case"ontimeupdate":return"onTimeUpdate";case"onseeking":return"onSeeking";case"onseekend":return"onSeekEnd";case"onratechange":return"onRateChange";case"onprogress":return"onProgress";case"onloadmetadata":return"onLoadMetadata";case"onloadeddata":return"onLoadedData";case"onloadstart":return"onLoadStart";case"onplaying":return"onPlaying";case"onplay":return"onPlay";case"onpause":return"onPause";case"onended":return"onEnded";case"ondurationchange":return"onDurationChange";case"oncanplay":return"onCanPlay";case"oncanplaythrough":return"onCanPlayThrough";case"onstalled":return"onStalled";case"onsuspend":return"onSuspend";case"onpopstate":return"onPopState";case"onstorage":return"onStorage";case"onhashchange":return"onHashChange";case"onafterprint":return"onAfterPrint";case"onbeforeprint":return"onBeforePrint";case"onpagehide":return"onPageHide";case"onpageshow":return"onPageShow"}}},{key:"toLiteralString",value:function toLiteralString(elem){var props=this.resolveProps(elem);var string=this.resolveId(elem.getTagName().toLowerCase(),props);string=this.resolveClass(string,props);string=this.resolveAttrs(string,props);return string}}],[{key:"toTemplate",value:function toTemplate(elem,deep){return RMEElemTemplater.getInstance().toTemplate(elem,deep)}},{key:"getElementProps",value:function getElementProps(elem){return RMEElemTemplater.getInstance().resolveProps(elem)}},{key:"toLiteralString",value:function toLiteralString(elem){return RMEElemTemplater.getInstance().toLiteralString(elem)}},{key:"getInstance",value:function getInstance(){if(!this.instance)this.instance=new RMEElemTemplater;return this.instance}}]);return RMEElemTemplater}();var Fetch=function(){var Fetch=function(){function Fetch(){_classCallCheck(this,Fetch)}_createClass(Fetch,[{key:"get",value:function get(url,contentType){return this["do"]({url:url,init:{method:"GET"},contentType:getDefaultContentType(contentType)})}},{key:"post",value:function post(url,body,contentType){return this["do"]({url:url,body:body,init:{method:"POST"},contentType:getDefaultContentType(contentType)})}},{key:"put",value:function put(url,body,contentType){return this["do"]({url:url,body:body,init:{method:"PUT"},contentType:getDefaultContentType(contentType)})}},{key:"delete",value:function _delete(url,contentType){return this["do"]({url:url,init:{method:"DELETE"},contentType:getDefaultContentType(contentType)})}},{key:"patch",value:function patch(url,body,contentType){var _this$do;return this["do"]((_this$do={url:url},_defineProperty(_this$do,"url",url),_defineProperty(_this$do,"body",body),_defineProperty(_this$do,"init",{method:"PATCH"}),_defineProperty(_this$do,"contentType",getDefaultContentType(contentType)),_this$do))}},{key:"do",value:function _do(config){if(Util.isEmpty(config)||!Util.isObject(config)||Util.isEmpty(config.url)){throw new Error("Error in fetch config object ".concat(JSON.stringify(config),", url must be set"))}if(!config.init)config.init={};if(config.contentType&&config.contentType!=="buffer"){if(!config.init.headers)config.init.headers=new Headers({});if(!config.init.headers.has("Content-Type"))config.init.headers.set("Content-Type",config.contentType)}if((config.body||config.init.body)&&isContentType(config.contentType,Http.JSON)){config.init.body=JSON.stringify(config.body||config.init.body)}else if(config.body){config.init.body=config.body}if(config.method){config.init.method=config.method}return fetch(config.url,config.init).then(function(){var _ref3=_asyncToGenerator(_regeneratorRuntime().mark(function _callee3(response){var res;return _regeneratorRuntime().wrap(function _callee3$(_context3){while(1)switch(_context3.prev=_context3.next){case 0:if(response.ok){_context3.next=2;break}throw Error("Error in requesting url: ".concat(config.url,", method: ").concat(config.init.method));case 2:if(!isContentType(config.contentType,Http.JSON)){_context3.next=7;break}_context3.next=5;return response.text();case 5:res=_context3.sent;return _context3.abrupt("return",res.length>0?JSON.parse(res):res);case 7:if(!isContentType(config.contentType,Http.TEXT_PLAIN)){_context3.next=9;break}return _context3.abrupt("return",response.text());case 9:if(!isContentType(config.contentType,Http.FORM_DATA)){_context3.next=11;break}return _context3.abrupt("return",response.formData());case 11:if(!isContentType(config.contentType,Http.OCTET_STREAM)){_context3.next=13;break}return _context3.abrupt("return",response.blob());case 13:if(!(config.contentType==="buffer")){_context3.next=15;break}return _context3.abrupt("return",response.arrayBuffer());case 15:return _context3.abrupt("return",response);case 16:case"end":return _context3.stop()}},_callee3)}));return function(_x3){return _ref3.apply(this,arguments)}}())}}]);return Fetch}();var isContentType=function isContentType(contentTypeA,contentTypeB){return Util.notEmpty(contentTypeA)&&contentTypeA.search(contentTypeB)>-1};var getDefaultContentType=function getDefaultContentType(contentType){if(contentType===undefined){return Http.JSON}else if(contentType===null){return null}else{return contentType}};return new Fetch}();var Http=function(){var Http=function(){function Http(config){_classCallCheck(this,Http);config.contentType=config.contentType===undefined?Http.JSON:config.contentType;if(window.Promise){this.self=new HttpPromiseAjax(config).instance()}else{this.self=new HttpAjax(config)}}_createClass(Http,[{key:"instance",value:function instance(){return this.self}}],[{key:"get",value:function get(url,requestContentType){return new Http({method:"GET",url:url,data:undefined,contentType:requestContentType}).instance()}},{key:"post",value:function post(url,data,requestContentType){return new Http({method:"POST",url:url,data:data,contentType:requestContentType}).instance()}},{key:"put",value:function put(url,data,requestContentType){return new Http({method:"PUT",url:url,data:data,contentType:requestContentType}).instance()}},{key:"delete",value:function _delete(url,requestContentType){return new Http({method:"DELETE",url:url,data:undefined,contentType:requestContentType}).instance()}},{key:"patch",value:function patch(url,data,requestContentType){return new Http({method:"PATCH",url:url,data:data,contentType:requestContentType}).instance()}},{key:"do",value:function _do(config){return new Http(config).instance()}}]);return Http}();Http.JSON="application/json";Http.FORM_DATA="multipart/form-data";Http.TEXT_PLAIN="text/plain";Http.OCTET_STREAM="application/octet-stream";var HttpAjax=function(){function HttpAjax(config){_classCallCheck(this,HttpAjax);this.config=config;this.data=isContentTypeJson(config.contentType)?JSON.stringify(config.data):config.data;this.xhr=new XMLHttpRequest;this.xhr.open(config.method,config.url);if(config.contentType)this.xhr.setRequestHeader("Content-Type",config.contentType);if(config.headers)setXhrHeaders(this.xhr,config.headers)}_createClass(HttpAjax,[{key:"then",value:function then(successHandler,errorHandler){var _this9=this;this.xhr.onload=function(){_this9.xhr.responseJSON=tryParseJSON(_this9.xhr.responseText);isResponseOK(_this9.xhr.status)?successHandler(isContentTypeJson(_this9.config.contentType)?resolveResponse(_this9.xhr.response):_this9.xhr):errorHandler(_this9.xhr)};if(this.config.onProgress){this.xhr.onprogress=function(event){_this9.config.onProgress(event)}}if(this.config.onTimeout){this.xhr.ontimeout=function(event){_this9.config.onTimeout(event)}}this.xhr.onerror=function(){_this9.xhr.responseJSON=tryParseJSON(_this9.xhr.responseText);if(errorHandler)errorHandler(_this9.xhr)};this.data?this.xhr.send(this.data):this.xhr.send();return this}},{key:"catch",value:function _catch(errorHandler){var _this10=this;this.xhr.onerror=function(){_this10.xhr.responseJSON=tryParseJSON(_this10.xhr.responseText);if(errorHandler)errorHandler(_this10.xhr)}}}]);return HttpAjax}();var HttpPromiseAjax=function(){function HttpPromiseAjax(config){_classCallCheck(this,HttpPromiseAjax);this.promise=new Promise(function(resolve,reject){new HttpAjax(config).then(function(response){return resolve(response)},function(error){return reject(error)})})}_createClass(HttpPromiseAjax,[{key:"instance",value:function instance(){return this.promise}}]);return HttpPromiseAjax}();var resolveResponse=function resolveResponse(response){var resp=tryParseJSON(response);return Util.notEmpty(resp)?resp:response};var setXhrHeaders=function setXhrHeaders(xhr,headers){Object.keys(headers).forEach(function(header){return xhr.setRequestHeader(header,headers[header])})};var isResponseOK=function isResponseOK(status){return Boolean([200,201,202,203,204,205,206,207,208,226].find(function(num){return num===status}))};var isContentTypeJson=function isContentTypeJson(contentType){return contentType&&(Http.JSON.search(contentType.toLowerCase())>-1||contentType.toLowerCase().search(Http.JSON)>-1)};var tryParseJSON=function tryParseJSON(text){try{return JSON.parse(text)}catch(e){}};return Http}();var Key=_createClass(function Key(){_classCallCheck(this,Key)});Key.ENTER="Enter";Key.ESC="Escape";Key.TAB="Tab";Key.F1="F1";Key.F2="F2";Key.F3="F3";Key.F4="F4";Key.F5="F5";Key.F6="F6";Key.F7="F7";Key.F8="F8";Key.F9="F9";Key.F10="F10";Key.F11="F11";Key.F12="F12";Key.A="a";Key.B="b";Key.C="c";Key.D="d";Key.E="e";Key.F="f";Key.G="g";Key.H="h";Key.I="i";Key.J="j";Key.L="l";Key.M="m";Key.N="n";Key.O="o";Key.P="p";Key.Q="q";Key.R="r";Key.S="s";Key.T="t";Key.U="u";Key.V="v";Key.W="w";Key.X="x";Key.Y="y";Key.Z="z";Key.CAPS_LOCK="CapsLock";Key.NUM_LOCK="NumLock";Key.SCROLL_LOCK="ScrollLock";Key.PAUSE="Pause";Key.PRINT_SCREEN="PrintScreen";Key.PAGE_UP="PageUp";Key.PAGE_DOWN="PageDown";Key.END="End";Key.HOME="Home";Key.DELETE="Delete";Key.INSERT="Insert";Key.ALT="Alt";Key.CTRL="Control";Key.CONTEXT_MENU="ContextMenu";Key.OS="OS";Key.ALTGR="AltGraph";Key.SHIFT="Shift";Key.BACKSPACE="Backspace";Key.SECTION="\xA7";Key.ONE="1";Key.TWO="2";Key.THREE="3";Key.FOUR="4";Key.FIVE="5";Key.SIX="6";Key.SEVEN="7";Key.EIGHT="8";Key.NINE="9";Key.ZERO="0";Key.PLUS="+";Key.MINUS="-";Key.STAR="*";Key.SLASH="/";Key.ARROW_UP="ArrowUp";Key.ARROW_RIGHT="ArrowRight";Key.ARROW_DOWN="ArrowDown";Key.ARROW_LEFT="ArrowLeft";Key.COMMA=",";Key.DOT=".";var useMessages=function(){return function(locale,loader){if(Util.isFunction(loader)){RMEMessagesResolver.load(function(locale,setMessages){return setMessages(loader(locale))})}if(Util.isString(locale)||locale instanceof Event){RMEMessagesResolver.lang(locale)}return RMEMessagesResolver.locale()}}();var useMessage=function(){return function(key){for(var _len6=arguments.length,params=new Array(_len6>1?_len6-1:0),_key6=1;_key6<_len6;_key6++){params[_key6-1]=arguments[_key6]}return RMEMessagesResolver.message.apply(RMEMessagesResolver,[key].concat(params))}}();var RMEMessagesResolver=function(){var Messages=function(){function Messages(){var _this11=this;_classCallCheck(this,Messages);this.ins=this;this.messages=[];this.locale="";this.translated=[];this.load=function(){};this.messagesType;this.ready=false;ready(function(){_this11.ready=true;_this11.runTranslated()})}_createClass(Messages,[{key:"setLoad",value:function setLoad(loader){if(!Util.isFunction(loader)){throw new Error("Message loader must be a function")}this.load=loader}},{key:"setLocale",value:function setLocale(locale){this.locale=locale;return this}},{key:"setMessages",value:function setMessages(messages){if(Util.isArray(messages)){this.messagesType="array"}else if(Util.isObject(messages)){this.messagesType="map"}else{throw new Error("Given messages must be an array or an object")}this.messages=messages;this.runTranslated()}},{key:"getMessage",value:function getMessage(text){for(var _len7=arguments.length,params=new Array(_len7>1?_len7-1:0),_key7=1;_key7<_len7;_key7++){params[_key7-1]=arguments[_key7]}if(Util.isEmpty(params.flat(2))){return this.resolveMessage(text)}else{var msg=this.resolveMessage(text);return this.resolveParams(msg,params.flat(2))}}},{key:"resolveMessage",value:function resolveMessage(text){if(this.messagesType==="array"){return this.resolveMessagesArray(text)}else if(this.messagesType==="map"){return this.resolveMessagesMap(text)}}},{key:"resolveMessagesMap",value:function resolveMessagesMap(text){var msg=text;for(var i in this.messages){if(i===text){msg=this.messages[i];break}}return msg}},{key:"resolveMessagesArray",value:function resolveMessagesArray(text){var i=0;var msg=text;while(i1?_len8-1:0),_key8=1;_key8<_len8;_key8++){params[_key8-1]=arguments[_key8]}return Messages.instance.getMessage(text,params)}},{key:"load",value:function load(loader){Messages.instance.setLoad(loader)}},{key:"instance",get:function get(){if(!this.ins)this.ins=new Messages;return this.ins}}]);return Messages}();return{lang:Messages.lang,message:Messages.message,load:Messages.load,locale:Messages.locale}}();var script=function(){var addScript=function addScript(elem){var scripts=Tree.getHead().getByTag("script");if(scripts.length>0){var lastScript=scripts[scripts.length-1];lastScript.after(elem)}else{Tree.getHead().append(elem)}};return function(source,options){if(Util.notEmpty(source)){addScript(RMETemplateResolver.resolve({script:_objectSpread({src:source},options)}))}}}();var ready=function(){var callbacks=[];document.addEventListener("readystatechange",function(){if(document.readyState==="complete"){callbacks.forEach(function(callback){return callback()});callbacks.length=0}});return function(callback){callbacks.push(callback)}}();var RMEHashRouter=function RMEHashRouter(props,_ref4){var asyncTask=_ref4.asyncTask,updateState=_ref4.updateState;var routes=props.routes,_props$url=props.url,url=_props$url===void 0?location.hash:_props$url,prevUrl=props.prevUrl,prevRoute=props.prevRoute,didChange=props.didChange,globalScrollTop=props.globalScrollTop,init=props.init;if(!routes){return null}if(!init){RMERouterContext.setRouter(routes,function(url){updateState({url:url,didChange:true})});asyncTask(function(){window.addEventListener("hashchange",function(){updateState({init:true,url:location.hash,didChange:true})})})}var route;if(url!==prevUrl){route=RMERouterUtils.findRoute(url,routes,RMERouterUtils.hashMatch);asyncTask(function(){updateState({prevUrl:url,prevRoute:route},false)})}else{route=prevRoute}if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}if(route.hide){location.href=prevUrl}if(didChange&&window.scrollY>0&&(route.scrolltop===true||route.scrolltop===undefined&&globalScrollTop)){scrollTo(0,0)}asyncTask(function(){return updateState({didChange:false},false)})}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMEOnLoadUrlRouter=function RMEOnLoadUrlRouter(props,_ref5){var asyncTask=_ref5.asyncTask;var routes=props.routes;if(!routes){return null}var route=RMERouterUtils.findRoute(location.pathname,routes,RMERouterUtils.urlMatch);if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMEUrlRouter=function RMEUrlRouter(props,_ref6){var updateState=_ref6.updateState,asyncTask=_ref6.asyncTask;var routes=props.routes,url=props.url,prevUrl=props.prevUrl,prevRoute=props.prevRoute,skipPush=props.skipPush,init=props.init,didChange=props.didChange,globalScrollTop=props.globalScrollTop;if(!routes){return null}if(!init){var updateUrl=function updateUrl(url,skipPush,didChange){updateState({init:true,url:url?url:location.pathname,skipPush:skipPush,didChange:didChange})};RMERouterContext.setRouter(routes,function(url){return updateUrl(url,false,true)});asyncTask(function(){window.addEventListener("popstate",function(){return updateUrl(undefined,true,true)});updateUrl(undefined,true,true)})}var route;if(url!==prevUrl){route=RMERouterUtils.findRoute(url,routes,RMERouterUtils.urlMatch);asyncTask(function(){updateState({prevUrl:url,prevRoute:route},false)})}else{route=prevRoute}if(Util.notEmpty(route)){if(Util.isFunction(route.onBefore)){route.onBefore(route)}if(Util.isFunction(route.onAfter)){asyncTask(function(){return route.onAfter(route)})}if(!route.hide&&url!==prevUrl&&!skipPush){history.pushState(null,null,url)}if(didChange&&window.scrollY>0&&(route.scrolltop===true||route.scrolltop===undefined&&globalScrollTop)){scrollTo(0,0)}asyncTask(function(){return updateState({didChange:false},false)})}return{_:!!route?RMERouterUtils.resolveRouteElem(route.elem,route.props):null}};var RMERouterContext=function(){var RouterContext=function(){function RouterContext(){_classCallCheck(this,RouterContext);this.ins;this.routers=[]}_createClass(RouterContext,[{key:"set",value:function set(key,value){if(!!key&&!!value&&!this.has(key)){this.routers.push(_objectSpread({key:key},value))}}},{key:"has",value:function has(key){return!!this.routers.find(function(route){return route.key===key})}},{key:"get",value:function get(url){var found;var prevFoundRouter;if(url.match(/^\/[^#]/)||url==="/"){var urlRouters=this.routers.filter(function(router){return router.key.match(/^:\//)});found=urlRouters.find(function(router,idx){var route=RMERouterUtils.findRoute(url,router.routes,RMERouterUtils.urlMatch);if(!!route){prevFoundRouter=router}return!!route&&idx===urlRouters.length-1});found=found||prevFoundRouter}else{var hashRouters=this.routers.filter(function(router){return router.key.match(/^:#?/)});found=hashRouters.find(function(router,idx){var route=RMERouterUtils.findRoute(url,router.routes,RMERouterUtils.hashMatch);if(!!route){prevFoundRouter=router}return!!route&&idx===hashRouters.length-1});found=found||prevFoundRouter}return!!found?found.navigateHook:function(){return undefined}}}],[{key:"createContextKey",value:function createContextKey(routes){return":".concat(routes.map(function(route){return route.route}).join(":"))}},{key:"navigateTo",value:function navigateTo(url){RouterContext.instance.get(RMERouterUtils.getUrlPath(url))(url)}},{key:"setRouter",value:function setRouter(routes,navigateHook){RouterContext.instance.set(RouterContext.createContextKey(routes),{routes:routes,navigateHook:navigateHook})}},{key:"instance",get:function get(){if(!this.ins){this.ins=new RouterContext}return this.ins}}]);return RouterContext}();return RouterContext}();var RMERouterUtils=function(){var getUrlPath=function getUrlPath(url){return url.replace(/\:{1}\/{2}/,"").match(/\/{1}.*/).join()};var urlMatch=function urlMatch(oldUrl,newUrl){oldUrl=Util.isString(oldUrl)?oldUrl.replace(/\*/g,".*").replace(/\/{2,}/g,"/"):oldUrl;var path=getUrlPath(newUrl);var found=path.match(oldUrl);if(Util.notEmpty(found)){found=found.join()}return found===path&&new RegExp(oldUrl).test(newUrl)};var hashMatch=function hashMatch(oldUrl,newUrl){if(Util.isString(oldUrl)){oldUrl=oldUrl.replace(/\*/g,".*");if(oldUrl.charAt(0)!=="#"){oldUrl="#".concat(oldUrl)}}var hash=newUrl.match(/\#{1}.*/).join();var found=hash.match(oldUrl);found=Util.notEmpty(found)?found.join():null;return found===hash&&new RegExp(oldUrl).test(newUrl)};var findRoute=function findRoute(url,routes,matcherHook){return url&&routes.find(function(route){return matcherHook(route.route,url)})};var resolveRouteElem=function resolveRouteElem(elem,props){if(Util.isFunction(elem)&&RMEComponentManagerV2.hasComponent(elem.valueOf().name)){return _defineProperty({},elem.valueOf().name,props)}else if(Util.isString(elem)&&RMEComponentManagerV2.hasComponent(elem)){return _defineProperty({},elem,props)}else{return{_:elem.toTemplate()}}};return{getUrlPath:getUrlPath,findRoute:findRoute,urlMatch:urlMatch,hashMatch:hashMatch,resolveRouteElem:resolveRouteElem}}();var useHashRouter=function(){return function(routes){var scrollTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;return _defineProperty({},Component(RMEHashRouter).valueOf().name,{routes:routes,globalScrollTop:scrollTop})}}();var useOnLoadUrlRouter=function(){return function(routes){return _defineProperty({},Component(RMEOnLoadUrlRouter).valueOf().name,{routes:routes})}}();var useUrlRouter=function(){return function(routes){var scrollTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:true;return _defineProperty({},Component(RMEUrlRouter).valueOf().name,{routes:routes,globalScrollTop:scrollTop})}}();var useRouter=function(){return function(url){if(Util.isString(url)){RMERouterContext.navigateTo(url)}else if(url instanceof Event){url.preventDefault();RMERouterContext.navigateTo(url.target.href)}}}();var RMETemplateElement=function(_Elem){_inherits(RMETemplateElement,_Elem);var _super=_createSuper(RMETemplateElement);function RMETemplateElement(type){var _this12;_classCallCheck(this,RMETemplateElement);_this12=_super.call(this,type);_this12.props={};_this12.stringProps;_this12.listeners=[];_this12.attributes=[];_this12.attributeString="";_this12.listenerObj={};_this12.listenerString="";_this12.children=[];_this12.inlineProps={};return _this12}_createClass(RMETemplateElement,[{key:"hasListeners",value:function hasListeners(){return this.listeners.length>0}},{key:"updateListeners",value:function updateListeners(elem){var _this13=this;if(elem.hasListeners()){elem.listeners.forEach(function(listener){_this13[listener.parentProp.name].call(_this13,listener.func)});RMETemplateElement.Util.setListeners(this,elem.listeners)}}},{key:"removeDetachedChildren",value:function removeDetachedChildren(elem){var _this14=this;if(elem.children.length===0){this.children.forEach(function(child,idx){if(child.dom().parentElement===null){_this14.children.splice(idx,1)}})}}},{key:"setParams",value:function setParams(){var attrs=arguments.length>0&&arguments[0]!==undefined?arguments[0]:[];var listeners=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];RMETemplateElement.Util.setAttributes(this,attrs);RMETemplateElement.Util.setListeners(this,listeners);RMETemplateElement.Util.formProps(this)}},{key:"updateAttributes",value:function updateAttributes(elem){RMETemplateElement.Util.setAttributes(this,elem.attributes,true);this.inlineProps=elem.inlineProps;RMETemplateElement.Util.formProps(this)}},{key:"setId",value:function setId(id){_get(_getPrototypeOf(RMETemplateElement.prototype),"setId",this).call(this,id);this.inlineProps.id=id;RMETemplateElement.Util.formProps(this);return this}},{key:"addClasses",value:function addClasses(classes){_get(_getPrototypeOf(RMETemplateElement.prototype),"addClasses",this).call(this,classes);this.inlineProps["class"]=_get(_getPrototypeOf(RMETemplateElement.prototype),"getClasses",this).call(this);RMETemplateElement.Util.formProps(this);return this}},{key:"addInlineAttr",value:function addInlineAttr(key,val){this.inlineProps[key]=val;RMETemplateElement.Util.formProps(this)}},{key:"append",value:function append(element){this.children.push(element);_get(_getPrototypeOf(RMETemplateElement.prototype),"append",this).call(this,element);return this}},{key:"remove",value:function remove(index,element){this.children.splice(index,1);_get(_getPrototypeOf(RMETemplateElement.prototype),"remove",this).call(this,element);return this}},{key:"replace",value:function replace(index,parent,element){parent.children.splice(index,1,element);this.inlineProps=element.inlineProps;RMETemplateElement.Util.formProps(element);_get(_getPrototypeOf(RMETemplateElement.prototype),"replace",this).call(this,element);return this}},{key:"setProps",value:function setProps(props){RMETemplateElement.Util.updateBrowserSetStyle(this,props);RMETemplateResolver.updateElemProps(this,props,this.props);return this}},{key:"equals",value:function equals(other){return this.stringProps===other.stringProps&&this.listenerString===other.listenerString}},{key:"getPropsString",value:function getPropsString(){return this.stringProps}},{key:"getPropsObj",value:function getPropsObj(){return this.props}},{key:"duplicate",value:function duplicate(){return RMETemplateElement.Util.duplicateElem(this)}}]);return RMETemplateElement}(Elem);RMETemplateElement.Util=function(){function RMETemplateElementUtil(){_classCallCheck(this,RMETemplateElementUtil)}_createClass(RMETemplateElementUtil,null,[{key:"duplicateElem",value:function duplicateElem(elem){var dup=new RMETemplateElement(elem.getTagName().toLowerCase());dup.inlineProps=elem.inlineProps;dup.setParams(elem.attributes,elem.listeners);RMETemplateResolver.updateElemProps(dup,elem.props,elem.props);if(elem.children.length>0){elem.children.map(function(child){return RMETemplateElement.Util.duplicateElem(child)}).forEach(function(child){return dup.append(child)})}return dup}},{key:"setListeners",value:function setListeners(elem,listeners){if(listeners.length>0){elem.listeners=listeners;elem.listenerObj=listeners.reduce(function(prev,curr){prev[curr.parentProp.name]=curr.func;return prev},{});elem.listenerString=listeners.map(function(listener){return listener.parentProp.name}).join()}}},{key:"setAttributes",value:function setAttributes(elem,attrs,override){if(attrs.length>0||override){elem.attributes=attrs.filter(function(attr){if(attr.key!=="class"){return attr}}).map(function(attr){if(attr.key==="message"){attr.val=RMEMessagesResolver.message(RMETemplateResolver.normalizeMessageString(attr.val),RMETemplateResolver.getMessageParams(attr.val))}return attr});elem.attributeString=elem.attributes.map(function(attr){return"".concat(attr.key,":").concat(attr.val)}).join().trim()}}},{key:"formProps",value:function formProps(elem){var props=elem.attributes.reduce(function(prev,curr){prev[curr.key]=curr.val;return prev},_objectSpread(_objectSpread({},elem.inlineProps),elem.listenerObj));elem.props=props;elem.stringProps=JSON.stringify(props)}},{key:"updateBrowserSetStyle",value:function updateBrowserSetStyle(elem,props){var style=elem.getAttribute("style");if(style){props.style=style}}}]);return RMETemplateElementUtil}();var RMETemplateFragmentHelper=function(){var FRAGMENT_REGEXP=/^_+$/g;var RMETemplateFragmentHelper=function(){function RMETemplateFragmentHelper(){_classCallCheck(this,RMETemplateFragmentHelper)}_createClass(RMETemplateFragmentHelper,[{key:"getFragmentKey",value:function getFragmentKey(template){return Object.keys(template).find(this.isFragmentKey)}},{key:"resolveFragmentValue",value:function resolveFragmentValue(template,templateValue){var fragmentKey=this.getFragmentKey(template);return template[fragmentKey]||template.fragment||templateValue}},{key:"isFragment",value:function isFragment(template){return Util.notEmpty(template)&&(template==="fragment"||Boolean(this.getFragmentKey(template)))}},{key:"isFragmentKey",value:function isFragmentKey(key){return key.match(FRAGMENT_REGEXP)||key.indexOf("fragment")===0}}]);return RMETemplateFragmentHelper}();return new RMETemplateFragmentHelper}();var RMETemplateResolver=function(){var Template=function(){function Template(){_classCallCheck(this,Template);this.template={};this.root=null;this.appName;this.context}_createClass(Template,[{key:"setTemplateAndResolve",value:function setTemplateAndResolve(template,parent){var appName=arguments.length>2&&arguments[2]!==undefined?arguments[2]:"";var context=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"";var componentLiteral=arguments.length>4?arguments[4]:undefined;this.template=template;this.appName=appName;this.context=context;if(parent){this.root=parent;if(componentLiteral){var key=Object.keys(this.template).shift();this.template=_defineProperty({},"".concat(key).concat(componentLiteral),this.template[key])}this.resolveNextParent(this.template,this.root,1)}else{this.resolveRootAndTemplate();this.resolveNextParent(this.template,this.root,1)}return this.root}},{key:"resolveRootAndTemplate",value:function resolveRootAndTemplate(){var key=Object.keys(this.template).shift();this.root=Template.resolveStringNumber(this.resolveElement(key,this.template),this.template);if(Util.isFunction(this.template[key])){this.template=this.template[key].call(this.root,this.root)}else{this.template=this.template[key]}}},{key:"resolveTemplateProperties",value:function resolveTemplateProperties(template,parent){var attrs=[];var listeners=[];var children=[];if(Util.isString(template)||Util.isNumber(template)){if(Util.isString(template)&&Template.isMessage(template)){attrs.push({key:"message",val:template})}else{attrs.push({key:"text",val:template})}}else if(Util.isArray(template)){template.forEach(function(obj){var key=Object.keys(obj).shift();var val=Object.values(obj).shift();children.push({key:key,val:Template.isComponent(key)&&Util.isFunction(val)?{}:val})})}else if(Util.isObject(template)){Object.keys(template).forEach(function(key,i){if(Template.isAttr(key,parent)){attrs.push({key:key,val:template[key]})}else if(Template.isEventKeyVal(key,template[key])){listeners.push({parentProp:parent[key],func:template[key]})}else if(Template.isTag(Template.getElementName(key))){children.push({key:key,val:template[key]})}else if(Template.isComponent(key)){children.push({key:key,val:!Util.isFunction(template[key])?template[key]:{}})}else if(RMETemplateFragmentHelper.isFragmentKey(key)){children.push({key:key,val:template[key]})}})}parent.setParams(attrs,listeners);return[attrs,listeners,children]}},{key:"resolveTemplate",value:function resolveTemplate(template,parent,round,parentContext){var _this15=this;var _this$resolveTemplate=this.resolveTemplateProperties(template,parent),_this$resolveTemplate2=_slicedToArray(_this$resolveTemplate,3),attrs=_this$resolveTemplate2[0],listeners=_this$resolveTemplate2[1],children=_this$resolveTemplate2[2];attrs.forEach(function(attr){return Template.resolveAttributes(parent,attr.key,_this15.resolveFunctionValue(attr.val,parent))});listeners.forEach(function(listener){return _this15.bindEventToElement(parent,listener.func,listener.parentProp)});children.forEach(function(rawChild,idx){if(RMETemplateFragmentHelper.isFragmentKey(rawChild.key)){_this15.resolveNextParent(rawChild.val,parent,round,parentContext+rawChild.key)}else{_this15.resolveChild(rawChild.key,rawChild.val,parent,round,idx,parentContext)}});round++}},{key:"resolveChild",value:function resolveChild(key,val,parent,round,invoked){var parentContext=arguments.length>5&&arguments[5]!==undefined?arguments[5]:"";var name=Template.getElementName(key);if(RMEComponentManagerV2.hasComponent(name)){var component=RMEComponentManagerV2.getComponent(name,this.resolveComponentLiteralVal(val),parent,this.cutComponentLiteral(name,key),"".concat(parentContext).concat(round).concat(invoked),this.appName);if(RMETemplateFragmentHelper.isFragment(component)&&Util.notEmpty(component)){this.resolveNextParent(RMETemplateFragmentHelper.resolveFragmentValue(component,val),parent,round)}}else{var child=Template.resolveStringNumber(this.resolveElement(key,val),val);parent.append(child);this.resolveNextParent(val,child,round,parentContext)}}},{key:"cutComponentLiteral",value:function cutComponentLiteral(name,key){return key.match("[^".concat(name,"].*"))}},{key:"resolveComponentLiteralVal",value:function resolveComponentLiteralVal(val){if(Util.isString(val)&&Template.isMessage(val)){return{message:val}}else if(Util.isString(val)||Util.isNumber(val)){return{text:val}}else{return val}}},{key:"resolveNextParent",value:function resolveNextParent(obj,parent,round){var _this16=this;var parentContext=arguments.length>3&&arguments[3]!==undefined?arguments[3]:"";var arr=Array.of(this.resolveFunctionValue(obj,parent)).flat();var parentTag=Util.isEmpty(parent)?parentContext:parentContext+parent.getTagName().toLowerCase();arr.forEach(function(item,i){return _this16.resolveTemplate(item,parent,round,"".concat(_this16.context).concat(parentTag,"[").concat(i,"]"))})}},{key:"bindEventToElement",value:function bindEventToElement(elemInstance,sourceFunction,targetFunction){targetFunction.call(elemInstance,sourceFunction)}},{key:"resolveFunctionValue",value:function resolveFunctionValue(value,parent){return Util.isFunction(value)?value.call(parent,parent):value}},{key:"resolveElement",value:function resolveElement(tag,obj){var resolved=null;var match=[];var el=Template.getElementName(tag);if(Util.isString(el)&&Template.isTag(el)){resolved=new RMETemplateElement(el)}else{resolved=obj}match=tag.match(/[a-z0-9]+\#[a-zA-Z0-9\-]+/);if(!Util.isEmpty(match))resolved.setId(match.join().replace(/[a-z0-9]+\#/g,""));match=this.cutAttributesIfFound(tag).match(/\.[a-zA-Z-0-9\-]+/g);if(!Util.isEmpty(match))resolved.addClasses(match.join(" ").replace(/\./g,""));match=tag.match(/\[[a-zA-Z0-9\= \:\(\)\#\-\_\/\.&%@!?£$+¤|;\\<\\>\\{}"]+\]/g);if(!Util.isEmpty(match))resolved=Template.addAttributes(resolved,match);return resolved}},{key:"cutAttributesIfFound",value:function cutAttributesIfFound(tag){return tag.replace(/\[.+\]/g,"")}}],[{key:"resolveStringNumber",value:function resolveStringNumber(elem,value){if(Util.isString(value)&&Template.isMessage(value)){Template.resolveMessage(elem,value)}else if(Util.isString(value)||Util.isNumber(value)){elem.setText(value)}return elem}},{key:"isMessage",value:function isMessage(message){message=Template.normalizeMessageString(message);return Util.notEmpty(RMEMessagesResolver.message(message))&&RMEMessagesResolver.message(message)!=message}},{key:"addAttributes",value:function addAttributes(elem,attrArray){var i=0;var start="[";var eq="=";var end="]";while(i"data".length)elem.setData(key.replace(/[A-Z]/,key.charAt(4).toLowerCase()).replace("data",""),val);else elem.setAttribute(key,val)}},{key:"resolveContent",value:function resolveContent(elem,key,val){if(elem.getTagName().toLowerCase()==="meta")elem.setAttribute(key,val);else elem.setContent(val)}},{key:"resolveMessage",value:function resolveMessage(elem,message){if(Util.isEmpty(message))throw"message must not be empty";elem.message(Template.normalizeMessageString(message),Template.getMessageParams(message))}},{key:"getMessageParams",value:function getMessageParams(message){var match=Template.getMessageParameterString(message);match=match&&match.join().replace(/({|}|:|;)/g,match.join()).split(match.join());return match&&match.filter(Util.notEmpty)}},{key:"getMessageParameterString",value:function getMessageParameterString(message){return message.match(/\:?(\{.*\}\;?)/g)}},{key:"normalizeMessageString",value:function normalizeMessageString(message){var params=Template.getMessageParameterString(message);return Util.notEmpty(params)?message.replace(params.join(),""):message}},{key:"isEventKeyVal",value:function isEventKeyVal(key,val){return key.indexOf("on")===0&&Util.isFunction(val)}},{key:"getElementName",value:function getElementName(str){if(Util.notEmpty(str))return str.match(/component:?[a-zA-Z0-9_]+|[a-zA-Z0-9_]+/).join()}},{key:"isComponent",value:function isComponent(key){return RMEComponentManagerV2.hasComponent(Template.getElementName(key))}},{key:"resolve",value:function resolve(template,parent,appName,context,componentLiteral){return Template.create().setTemplateAndResolve(template,parent,appName,context,componentLiteral)}},{key:"updateElemProps",value:function updateElemProps(elem,props,oldProps){var combined=Template.combineProps(props,oldProps);Object.entries(combined).forEach(function(_ref12){var _ref13=_slicedToArray(_ref12,2),prop=_ref13[0],value=_ref13[1];if(prop==="text"){value?elem.setText(value):elem.setText("")}else if(Template.isEventKeyVal(prop,value)){elem[prop].call(elem,value)}else if(prop==="class"){value?elem.updateClasses(value):elem.removeAttribute(prop)}else if(prop==="value"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop);elem.setValue(value)}else if(prop==="tabIndex"){value?elem.setTabIndex(value):elem.removeAttribute("tabindex")}else if(prop==="editable"){value?elem.setEditable(value):elem.removeAttribute("contenteditable")}else if(prop==="maxLength"){value?elem.setMaxLength(value):elem.removeAttribute("maxlength")}else if(prop==="minLength"){value?elem.setMinLength(value):elem.removeAttribute("minlength")}else if(prop==="data"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop)}else if(prop==="content"&&elem.getTagName().toLowerCase()==="meta"){value?elem.setAttribute(prop,value):elem.removeAttribute(prop)}else if(prop==="content"){elem.setContent(value)}else{value?Template.resolveAttributes(elem,prop,value):elem.removeAttribute(prop)}})}},{key:"combineProps",value:function combineProps(newProps,oldProps){Object.keys(oldProps).forEach(function(prop){if(oldProps[prop]&&!newProps[prop]){oldProps[prop]=undefined}});return _objectSpread(_objectSpread({},oldProps),newProps)}},{key:"create",value:function create(){return new Template}},{key:"isTemplate",value:function isTemplate(object){var isTemplate=false;if(Util.isObject(object)&&!Util.isArray(object)&&!(object instanceof RMETemplateElement)){for(var p in object){isTemplate=object.hasOwnProperty(p)&&Template.isTagOrComponent(p);if(isTemplate)break}}return isTemplate}},{key:"isTagOrComponent",value:function isTagOrComponent(tag){return Template.isComponent(tag)||Template.isTag(Template.getElementName(tag))}},{key:"isTag",value:function isTag(tag){var tags={a:["a","abbr","acronym","address","applet","area","article","aside","audio"],b:["button","br","b","base","basefont","bdi","bdo","big","blockquote","body"],c:["canvas","caption","center","cite","code","col","colgroup"],d:["div","dd","dl","dt","data","datalist","del","details","dfn","dialog"],e:["em","embed"],f:["form","fieldset","figcaption","figure","font","footer","frame","frameset"],h:["h1","h2","h3","h4","h5","h6","head","header","hr","html"],i:["i","input","img","iframe","ins"],k:["kbd"],l:["label","li","legend","link"],m:["main","meta","map","mark","meter"],n:["nav","noframes","noscript"],o:["option","object","ol","optgroup","output"],p:["p","pre","param","picture","progress"],q:["q"],r:["rp","rt","ruby"],s:["span","select","s","samp","script","section","small","source","strike","strong","style","sub","summary","sup","svg"],t:["table","textarea","td","tr","tt","th","thead","tbody","tfoot","template","time","title","track"],u:["u","ul"],v:["var","video"],w:["wbr"]};var i=0;var tagArray=tags[tag.charAt(0)];if(tagArray){while(i-1?"".concat(key.substring(0,capital),"-").concat(key.substr(capital).toLowerCase()):key}},{key:"isElem",value:function isElem(elemTag,array){var i=0;while(i {
- Component(RMEHashRouter);
-
return {
- RMEHashRouter: {
+ [Component(RMEHashRouter).valueOf().name]: {
routes,
globalScrollTop: scrollTop
}
@@ -4468,10 +4466,8 @@ const useOnLoadUrlRouter = (function() {
* @param {array} routes router routes
*/
return (routes) => {
- Component(RMEOnLoadUrlRouter);
-
return {
- RMEOnLoadUrlRouter: {
+ [Component(RMEOnLoadUrlRouter).valueOf().name]: {
routes
}
}
@@ -4487,10 +4483,8 @@ const useOnLoadUrlRouter = (function() {
const useUrlRouter = (function() {
return (routes, scrollTop = true) => {
- Component(RMEUrlRouter);
-
return {
- RMEUrlRouter: {
+ [Component(RMEUrlRouter).valueOf().name]: {
routes,
globalScrollTop: scrollTop,
}
@@ -4748,6 +4742,13 @@ RMETemplateElement.Util = class RMETemplateElementUtil {
if (attr.key !== 'class') {
return attr;
}
+ }).map((attr) => {
+ if (attr.key === 'message') {
+ attr.val = RMEMessagesResolver.message(
+ RMETemplateResolver.normalizeMessageString(attr.val),
+ RMETemplateResolver.getMessageParams(attr.val));
+ }
+ return attr;
});
elem.attributeString = elem.attributes.map(attr => `${attr.key}:${attr.val}`).join().trim();
}