function LRUCache(e){this.size=e||50,this.cache=[],this.map={}}window.hydra={},DOMParser||(window.DOMParser=function(){},DOMParser.prototype.parseFromString=function(e,t){if(/^\s*text\/html\s*(?:;|$)/i.test(t)){var n=document.implementation.createHTMLDocument("");return e.toLowerCase().indexOf("-1?n.documentElement.innerHTML=e:n.body.innerHTML=e,n}});var _=function(){var e={};return e.loadCache={},e.uid=0,typeof /./!="function"&&(e.isFunction=function(e){return typeof e=="function"}),e.isObject=function(e){return e===Object(e)},e.isArray=function(e){return e.length!==undefined?!0:toString.call(e)=="[object Array]"},e.isEmptyObject=function(t){if(t==null)return!0;for(var n in t)if(e.has(t,n))return!1;return!0},e.trim=function(e){return e?e.replace(/^\s*|\s*$/g,""):""},e.has=function(e,t){return e!=null&&Object.prototype.hasOwnProperty.call(e,t)},e.keys=function(t){if(!e.isObject(t))return[];if(Object.keys)return Object.keys(t);var n=[];for(var r in t)e.has(t,r)&&n.push(r);return n},e.each=function(t,n,r){if(t==null)return t;if(t.length===+t.length){for(var i=0,s=t.length;i0){var a=i.split("|");s=e.trim(a[0]),u=e.trim(a[1])}else s=e.trim(i);var f;if(s.indexOf(".")!=-1){var f=s.split("."),o=n[f[0]];e.each(f,function(e,t){e>0&&o&&(o=o[t])})}else o=n[s];if(u){var l=u.match(/\s*in(\{.*?\})/);if(l&&l.length>1){var c=(new Function("","return "+l[1]))();c&&(o=c[o]?c[o]:"")}else r.filter&&r.filter[u]?o=r.filter[u](o):console.error("filter["+u+"] not exist")}return o})},e.recurse=function(t,n){var r=t.children;r.length>0&&e.each(r,function(t,r){r.nodeType==1&&(n(r),e.recurse(r,n))})},e.upFirstLetter=function(e){return e.replace(/(\w)/,function(e){return e.toUpperCase()})},e.downFirstLetter=function(e){return e.replace(/(\w)/,function(e){return e.toLowerCase()})},e.loadCss=function(t){if(t){if(e.loadCache[t])return;e.loadCache[t]=!0;var n=document.getElementsByTagName("head")[0],r=document.createElement("link");r.href=t,r.rel="stylesheet",r.type="text/css",n.appendChild(r)}},e.loadJs=function(t,n,r){if(e.loadCache[t]){n&&n();return}e.loadCache[t]=!0;var i=document.getElementsByTagName("head")[0],s=document.createElement("script");return s.onload=function(){n&&n()},s.onerror=function(){r&&r()},s.type="text/javascript",s.src=t,i.appendChild(s),s},e.runJs=function(t,n,r){if(e.loadCache[t])return;e.loadCache[t]=!0;var i=document.getElementsByTagName("head")[0],s=document.createElement("script");return s.onload=function(){n&&n()},s.onerror=function(){r&&r()},s.type="text/javascript",s.src=t,i.appendChild(s),s},e.ajax=function(){function t(t,n,r,i,s){var o=null;window.XMLHttpRequest?o=new XMLHttpRequest:window.ActiveXObject&&(o=new ActiveXObject("Microsoft.XMLHTTP"));if(o!=null){var u=t,a=e.param(r);a&&(u=t+"?"+a),o.open(n,u,!0),o.onreadystatechange=function(){if(o.readyState==4&&o.status==200){var e=o.responseText;s&&s(e)}}}var f;if(i){var l=[];for(var c in i)l.push(c+"="+encodeURIComponent(i[c]));f=l.join("&"),f.length&&o.setRequestHeader("Content-type","application/x-www-form-urlencoded")}o.send(f)}return{get:function(e,n,r){t(e,"GET",n,null,r)},post:function(e,n,r,i){t(e,"POST",n,r,i)}}}(),e}(),DomEvent={on:function(e,t,n,r){var i="",s=r===undefined?!0:r,o=null;return window.addEventListener===undefined?(i="on"+e,o=function(e,n){return t.attachEvent(e,n),n}):(i=e,o=function(e,n,r){return t.addEventListener(e,n,r),n}),o.apply(t,[i,function(e){var t=e||event,r=t.srcElement||t.target;n(t,r)},s])},delegate:function(e,t,n,r){var i=this;i._events||(i._events={});var s=e.id;i._events[s]||(i._events[s]={});var o=!1;if(n=="blur"||n=="focus")n=n=="blur"?"focusout":n=="focus"?"focusin":n;i._events[s][n]?i._events[s][n].push({selector:t,fn:r}):(i._events[s][n]=[{selector:t,fn:r}],e.addEventListener(n,function(t){var r=i._events[s][n],o=t.target;for(var u=0,a=r.length;u=this.size?(this.cache[thi.size-1]=t,this.map[e]=thi.size-1):(this.cache.push(t),this.map[e]=this.cache.length-1)},LRUCache.prototype.get=function(e){if(this.map[e])return this.cache[this.map[e]]};function newState(e,t){var n={name:e,state:{},setState:function(e){for(var n in e)this.state[n]=e[n];t()},getState:function(){return this.state}};return n}var StoreUtil={get:function(e,t,n){_.ajax.get(e,t,n)},post:function(e,t,n){_.ajax.post(e,t,n)}};!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.virtualDom=e()}}(function(){var e,t,n;return function r(e,t,n){function i(o,u){if(!t[o]){if(!e[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return i(n?n:t)},l,l.exports,r,e,t,n)}return t[o].exports}var s=typeof require=="function"&&require;for(var o=0;o>>0:s>>>0;while(l=i.exec(e)){c=l.index+l[0].length;if(c>a){o.push(e.slice(a,l.index)),!r&&l.length>1&&l[0].replace(f,function(){for(var e=1;e1&&l.index=s)break}i.lastIndex===l.index&&i.lastIndex++}return a===e.length?(h||!i.test(""))&&o.push(""):o.push(e.slice(a)),o.length>s?o.slice(0,s):o},i}()},{}],6:[function(e,t,n){},{}],7:[function(e,t,n){"use strict";function o(e){var t=e[s];return t||(t=e[s]={}),t}var r=e("individual/one-version"),i="7";r("ev-store",i);var s="__EV_STORE_KEY@"+i;t.exports=o},{"individual/one-version":9}],8:[function(e,t,n){(function(e){"use strict";function r(e,t){return e in n?n[e]:(n[e]=t,t)}var n=typeof window!="undefined"?window:typeof e!="undefined"?e:{};t.exports=r}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],9:[function(e,t,n){"use strict";function i(e,t,n){var i="__INDIVIDUAL_ONE_VERSION_"+e,s=i+"_ENFORCE_SINGLETON",o=r(s,t);if(o!==t)throw new Error("Can only have one copy of "+e+".\n"+"You already have version "+o+" installed.\n"+"This means you cannot install version "+t);return r(i,n)}var r=e("./index.js");t.exports=i},{"./index.js":8}],10:[function(e,t,n){(function(n){var r=typeof n!="undefined"?n:typeof window!="undefined"?window:{},i=e("min-document");if(typeof document!="undefined")t.exports=document;else{var s=r["__GLOBAL_DOCUMENT_CACHE@4"];s||(s=r["__GLOBAL_DOCUMENT_CACHE@4"]=i),t.exports=s}}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{"min-document":6}],11:[function(e,t,n){"use strict";t.exports=function(t){return typeof t=="object"&&t!==null}},{}],12:[function(e,t,n){function s(e){return i.call(e)==="[object Array]"}var r=Array.isArray,i=Object.prototype.toString;t.exports=r||s},{}],13:[function(e,t,n){var r=e("./vdom/patch.js");t.exports=r},{"./vdom/patch.js":18}],14:[function(e,t,n){function s(e,t,n){for(var s in t){var a=t[s];a===undefined?o(e,s,a,n):i(a)?(o(e,s,a,n),a.hook&&a.hook(e,s,n?n[s]:undefined)):r(a)?u(e,t,n,s,a):e[s]=a}}function o(e,t,n,r){if(r){var s=r[t];if(!i(s))if(t==="attributes")for(var o in s)e.removeAttribute(o);else if(t==="style")for(var u in s)e.style[u]="";else typeof s=="string"?e[t]="":e[t]=null;else s.unhook&&s.unhook(e,t,n)}}function u(e,t,n,i,s){var o=n?n[i]:undefined;if(i==="attributes"){for(var u in s){var f=s[u];f===undefined?e.removeAttribute(u):e.setAttribute(u,f)}return}if(o&&r(o)&&a(o)!==a(s)){e[i]=s;return}r(e[i])||(e[i]={});var l=i==="style"?"":undefined;for(var c in s){var h=s[c];e[i][c]=h===undefined?l:h}}function a(e){if(Object.getPrototypeOf)return Object.getPrototypeOf(e);if(e.__proto__)return e.__proto__;if(e.constructor)return e.constructor.prototype}var r=e("is-object"),i=e("../vnode/is-vhook.js");t.exports=s},{"../vnode/is-vhook.js":26,"is-object":11}],15:[function(e,t,n){function f(e,t){var n=t?t.document||r:r,l=t?t.warn:null;e=a(e).a;if(u(e))return e.init();if(o(e))return n.createTextNode(e.text);if(!s(e))return l&&l("Item is not a valid virtual dom node",e),null;var c=e.namespace===null?n.createElement(e.tagName):n.createElementNS(e.namespace,e.tagName),h=e.properties;i(c,h);var p=e.children;for(var d=0;d>0,o=e[s];if(r===i)return o>=t&&o<=n;if(on))return!0;i=s-1}}return!1}function u(e,t){return e>t?1:-1}var r={};t.exports=i},{}],17:[function(e,t,n){function u(e,t,n){var i=e.type,o=e.vNode,u=e.patch;switch(i){case s.REMOVE:return a(t,o);case s.INSERT:return f(t,u,n);case s.VTEXT:return l(t,o,u,n);case s.WIDGET:return c(t,o,u,n);case s.VNODE:return h(t,o,u,n);case s.ORDER:return d(t,u),t;case s.PROPS:return r(t,u,o.properties),t;case s.THUNK:return v(t,n.patch(t,u,n));default:return t}}function a(e,t){var n=e.parentNode;return n&&n.removeChild(e),p(e,t),null}function f(e,t,n){var r=n.render(t,n);return e&&e.appendChild(r),e}function l(e,t,n,r){var i;if(e.nodeType===3)e.replaceData(0,e.length,n.text),i=e;else{var s=e.parentNode;i=r.render(n,r),s&&i!==e&&s.replaceChild(i,e)}return i}function c(e,t,n,r){var i=o(t,n),s;i?s=n.update(t,e)||e:s=r.render(n,r);var u=e.parentNode;return u&&s!==e&&u.replaceChild(s,e),i||p(e,t),s}function h(e,t,n,r){var i=e.parentNode,s=r.render(n,r);return i&&s!==e&&i.replaceChild(s,e),s}function p(e,t){typeof t.destroy=="function"&&i(t)&&t.destroy(e)}function d(e,t){var n=e.childNodes,r={},i,s,o;for(var u=0;u=a++?null:n[o.to])}function v(e,t){return e&&t&&e!==t&&e.parentNode&&e.parentNode.replaceChild(t,e),t}var r=e("./apply-properties"),i=e("../vnode/is-widget.js"),s=e("../vnode/vpatch.js"),o=e("./update-widget");t.exports=u},{"../vnode/is-widget.js":29,"../vnode/vpatch.js":32,"./apply-properties":14,"./update-widget":19}],18:[function(e,t,n){function a(e,t,n){return n=n||{},n.patch=n.patch&&n.patch!==a?n.patch:f,n.render=n.render||s,n.patch(e,t,n)}function f(e,t,n){var i=c(t);if(i.length===0)return e;var s=o(e,t.a,i),u=e.ownerDocument;!n.document&&u!==r&&(n.document=u);for(var a=0;ac?l:c;for(var d=0;d=i.length?t.length:i[f];for(var m=0;m=v&&a.push(g)}var y=a.slice(),b=0,w=[],x=[],T;for(var N=0;N-1?r.documentElement.innerHTML=e:r.body.innerHTML=e,r}return n.apply(this,arguments)}})(DOMParser),function(e){if(typeof exports=="object"&&typeof module!="undefined")module.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window!="undefined"?t=window:typeof global!="undefined"?t=global:typeof self!="undefined"?t=self:t=this,t.vdomParser=e()}}(function(){var e,t,n;return function r(e,t,n){function i(o,u){if(!t[o]){if(!e[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(s)return s(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[o]={exports:{}};e[o][0].call(l.exports,function(t){var n=e[o][1][t];return i(n?n:t)},l,l.exports,r,e,t,n)}return t[o].exports}var s=typeof require=="function"&&require;for(var o=0;o/);return t&&t.length>1?t[1]:""}var e="|template|a|b|body|br|button|center|cite|code|comment|dd|div|dl|dt|em|embed|fieldset|font|form|frame|head|hr|html|i|iframe|img|input|label|legend|li|link|meta|ol|option|p|pre|script|select|span|strong|style|sub|sup|table|tbody|td|textarea|th|thead|tr|ul|h1|h2|h3|h4|h5|h6|",t=/(((?!<\/template>).)*)<\/template>/g,n=/\{\{#>\s*(.*?)\}\}/,r=/\{\{>transclude\}\}/,i=/\{\{#if\s*(.*?)\}\}(((?!\{\{#if).)*)\{\{\/if\}\}/,s=/\{\{#each\s*(\w+)\}\}(((?!\{\{#each\}\}).)*)\{\{\/each\}\}/,o=/\{\{#transclude\}\}(((?!\{\{#transclude\}\}).)*)\{\{\/transclude\}\}/,u=/\{\{#component\s*(.*?)\}\}(((?!\{\{#component\}\}).)*)\{\{\/component\}\}/,a={},f=!0;a.load=function(e){return new l(e)},a.render=function(e,t,n){var r=d(e);Template[r]||(Template[r]=new XTemplate(r));var i=new l;i.loadedText=e,i.renderData=t,i._renderComplete=function(e){n(e)},i._render(e,t)},l.prototype.render=function(e,t){var n=this;n.toRender=!0,n.renderData=t,n.view||(n.view={});if(n.view.template!=e.template){var r=document.querySelector(e.seletor),i=document.createElement("div");i.style.width="100%",i.style.height="100%",r.innerHTML="",r.appendChild(i),n.view=e,n.view.container=i,n.viewChange=!0}else n.viewChange=!1;n.loaded&&n._loadDone()},l.prototype._loadDone=function(){var e=this;e.toRender&&(e.binded||(e.binded=!0,Template[e.tplName].bindEvent(e.view.container)),e._render(e.loadedText,e.renderData))},l.prototype._render=function(e,n){var r=this;e=p(e),r.queue.length=0,t.lastIndex=0;var i=t.exec(e),s=_.md5();r.queue.push({id:s,tplName:i[1],placeholder:i[0],content:i[2],data:n,global:r.renderData,parent:null}),r._getComponent(i[2]),r._renderTemplate()},l.prototype._getComponent=function(t){var n=this;n.componentTag=[];var r=document.createElement("div");r.innerHTML=t,_.recurse(r,function(t){var r=t.tagName.toLowerCase();if(e.indexOf("|"+r+"|")==-1){var i=/<(\w+)(?:(\s|.)*?)>/.exec(t.outerHTML);n.componentTag.push(i[1])}})},l.prototype._renderComplete=function(e){var t=this;if(f)if(!t.view.vTree||t.viewChange)t.view.vTree=c(e),t.view.container.appendChild(virtualDom.create(t.view.vTree)),pipe.write("renderComplete");else{var n=c(e),r=virtualDom.diff(t.view.vTree,n);virtualDom.patch(t.view.container.firstChild,r),t.view.vTree=n,pipe.write("renderComplete")}else t.view.container.innerHTML=e},l.prototype._synchronizeDom=function(){var e=this;e.view.vTree=c(e.view.container.innerHTML)},l.prototype._renderTemplate=function(){var e=this;if(e.queue.length>0){var t=e.queue.pop();e._renderCommon(t)}},l.prototype._renderCommon=function(e,t){var r=this,a=e.id,f=e.tplName,l=e.placeholder,c=e.content,h=e.data,p=e.parent;o.lastIndex=0,u.lastIndex=0,s.lastIndex=0,n.lastIndex=0,console.time("match");if(o.test(c))r._renderTransclude(e);else if(u.test(c))r._renderComponent(e);else if(r.componentTag.length>0&&!t){var d=r.componentTag.shift(),v=new RegExp("<("+d+")s*([^>]*)>(((?!<"+d+").)*)","i");v.test(c)?r._renderComponentTag(v,e):(r.componentTag.push(d),r._renderCommon(e,!0))}else if(s.test(c))r._renderEach(e);else if(i.test(c))r._renderIf(e);else if(n.test(c))r._renderInclude(e);else{var m=r._renderNormal(e);r.queue.length>0?(r._setQueueItemContent(p,e.placeholder,m),r._renderTemplate()):r._renderComplete(m)}console.timeEnd("match")},l.prototype._renderComponentTag=function(e,t){var n=this;n.queue.push(t);var r=t.id,i=t.tplName,s=t.content,o=t.data;e.lastIndex=0;var u=e.exec(s),a=u[0],f=u[1],l=u[3];if(l){var c=_.md5();n.queue.push({id:c,tplName:i,placeholder:a,content:"{{#component "+f+"}}"+a+"{{/component}}",data:o,global:n.renderData,parent:r});var h=_.md5();n.queue.push({id:h,tplName:i,placeholder:l,content:"{{#transclude}}"+l+"{{/transclude}}",data:o,global:n.renderData,parent:c})}else{var c=_.md5();n.queue.push({id:c,tplName:i,placeholder:a,content:"{{#component "+f+"}}"+a+"{{/component}}",data:o,global:n.renderData,parent:r})}n._renderTemplate()},l.prototype._renderComponent=function(e){function m(){for(var e in d){var r=d[e],i=/\{\{(.*?)\}\}/.exec(r);i&&(d[e]=s[i[1]])}d.name||(d.name=_.md5()),v&&(d.transclude=v);var o="com_"+_.md5();Component[l].new(o,d.name,d,t.tplName,function(e){e.render(function(e){t._setQueueItem(n,{content:''+e+""}),t._renderTemplate()})})}var t=this;t.queue.push(e);var n=e.id,r=e.tplName,i=e.content,s=e.data;u.lastIndex=0;var o=u.exec(i),f=o[0],l=o[1],c=o[2],p=new RegExp("<("+l+")s*([^>]*)>(((?!<"+l+").)*)","i"),o=p.exec(c),f=o[0],l=_.upFirstLetter(o[1]),d=h(o[2]),v=o[3];Component[l]?Component[l].opts&&m():a.loadComponent(l,function(){m()})},l.prototype._renderTransclude=function(e){var t=this,n=e.id,r=e.tplName,i=e.content,s=e.data;o.lastIndex=0;var u=o.exec(i),a=u[0],f=u[1],l=_.md5();t.queue.push({id:l,tplName:r,placeholder:a,content:f,data:s,global:t.renderData,parent:n}),t._renderTemplate()},l.prototype._renderEach=function(e){var t=this;t.queue.push(e);var n=e.id,r=e.tplName,i=e.content,o=e.data,u=[],a=[];s.lastIndex=0;var f=s.exec(i),l=f[0],c=f[2],h;Array.isArray(o)?h=o:h=o[f[1]],h=h||[];var p=_.md5();t.queue.push({id:p,tplName:r,placeholder:l,content:c,data:h,global:t.renderData,parent:n}),h.forEach(function(e,n){u.push(c);var i=_.md5();t.queue.push({id:i,tplName:r,placeholder:c,content:c,data:e,global:t.renderData,parent:p})}),t._setQueueItem(p,{content:u.join("")}),t._renderTemplate()},l.prototype._renderIf=function(e){var t=this;t.queue.push(e);var n=e.id,r=e.tplName,s=e.content,o=e.data;i.lastIndex=0;var u=i.exec(s),a=u[1],f=u[2],l,c,h;if(f.indexOf("{{#else}}")!=-1){var p=f.split("{{#else}}");l=p[0],c=p[1]}else l=f;h=Template[r].eval(a,o,t.renderData)?l:c||"";var d=_.md5();t.queue.push({id:d,tplName:r,placeholder:u[0],content:h,data:o,global:t.renderData,parent:n}),t._renderTemplate()},l.prototype._renderInclude=function(e){function h(e){t.lastIndex=0;var n=t.exec(e),s=_.md5();r.queue.push({id:s,tplName:n[1],placeholder:f[0],content:n[2],data:a,global:r.renderData,parent:i}),r._renderTemplate()}var r=this;r.queue.push(e);var i=e.id,s=e.tplName,o=e.placeholder,u=e.content,a=e.data;n.lastIndex=0;var f=n.exec(u),l=f[1]+".tpl",c=f[1]+".js";resourceMap&&resourceMap["/"+c]&&(c=resourceMap["/"+c].slice(1)),r.tplCache[l]?h(r.tplCache[l]):_.ajax.get(l,{t:(new Date).getTime()},function(e){function n(){h(e)}e=p(e),r.tplCache[l]=e;var t=d(e);Template[t]||(Template[t]=new XTemplate(t)),_.loadJs(c,n,n)})},l.prototype._renderNormal=function(e){var t=this,n=e.tplName;return Template[n].compile(e)},l.prototype._getQueueItem=function(e){var t=this,n=t.queue.filter(function(t){return t.id===e});return n},l.prototype._setQueueItem=function(e,t){var n=this,r=n.queue.filter(function(t){return t.id===e});if(r.length==1){r=r[0];for(var i in t)r[i]=t[i]}},l.prototype._setQueueItemContent=function(e,t,n){var r=this,i=r.queue.filter(function(t){return t.id===e});i.length==1&&(i=i[0],i.content=i.content.replace(t,n))},hydra.load=a.load,hydra.render=a.render,window.Mustang=a})();var XTemplate=function(){function XTemplate(e){this.name=e,this._fields={},this._filters={},this._events={}}return XTemplate.prototype.helpers=function(e){for(var t in e)this._fields[t]=e[t]},XTemplate.prototype.filters=function(e){for(var t in e)this._filters[t]=e[t]},XTemplate.prototype.events=function(e){for(var t in e)this._events[t.replace("^s*|s*$","")]=e[t]},XTemplate.prototype._mixin=function(e){var t=this._fields,n=this._filters;for(var r in t){var i=t[r];typeof i=="function"?e[r]=i.apply(e):e[r]=i}},XTemplate.prototype.compile=function(e){this._mixin(e.data);var t=e.content,n=e.data,r=e.global,i=this._filters,s=t.replace(/\{\{(.*?)\}\}/g,function(e,t){var s,o,u;if(t.indexOf("|")>0){var a=t.split("|");s=_.trim(a[0]),u=_.trim(a[1])}else t.indexOf(">")==0?s=t.slice(1):s=_.trim(t);var f;if(s.indexOf(".")!=-1){var f=s.split("."),o;f[0]=="top"?o=r:o=n[f[0]],_.each(f,function(e,t){e>0&&o&&(o=o[t])})}else s=="$item"?o=n:o=n[s];return u&&(i[u]?o=i[u](o):console.error("filter ["+u+"] is not exist")),o===undefined&&(o=""),o});return s},XTemplate.prototype.eval=function(exp,data,global){this._mixin(data),exp=exp.replace(/\s/g,"");var mats=/(\w+)(<|>|==|\!=)(.*)$/.exec(exp);return eval("'"+(data[mats[1]]||global[mats[1]]||mats[1])+"'"+mats[2]+mats[3])},XTemplate.prototype.bindEvent=function(e){e||console.error("[node] can't be null");for(var t in this._events){var n=this._events[t],r=t.split(" "),i=r.pop();DomEvent.delegate(e,r.join(" "),i,n)}},XTemplate}();(function(e){function t(e){this.name=e}function n(e,t,n,r){this.id=e,this.name=t,this.opts=n,this.template=r;var i=this;pipe.receive({renderComplete:function(){console.log(i.id,"pipe receive");var e=document.querySelector("#"+i.id);if(!e)return;i.opts.$el=e,i.opts.name=i.name;var t=app.getCurrentTemplate();i.opts.eventPipe=EventPipe.pipe(t.tplName+"_innerPipe");var n=i.opts.render;n.call(i.opts),t._synchronizeDom(),i.bindEvent()}})}e.component=function(e,n){console.log("[",e,"] loaded",n),e=_.upFirstLetter(e),Component[e]||(Component[e]=new t(e)),Component[e].opts=n},e.loadComponent=function(e,n){if(e){Component[e]||(Component[e]=new t(e));var r=_.downFirstLetter(e),i="component/"+r+"/"+r+".js";resourceMap&&resourceMap["/js/"+i]&&(i=resourceMap["/js/"+i].slice(1));var s="component/"+r+"/"+r+".css";resourceMap&&resourceMap["/js/"+s]&&(s=resourceMap["/js/"+s].slice(1)),_.loadJs(i,function(){n&&n(Component[e])}),_.loadCss(s)}},t.prototype.new=function(e,t,r,i,s){var o=_.upFirstLetter(this.name),u=Component[o].opts;console.log(">",this.name);if(u.initState)u.initState.call(u,function(){r&&_.extend(u.props,r);var o=Template[i],a=new n(e,t,u,o);s&&s(a)});else{r&&_.extend(u.props,r);var a=Template[i],f=new n(e,t,u,a);s&&s(f)}},t.prototype.newInstance=function(e){var t=_.upFirstLetter(this.name),r=Component[t].opts;console.log(">",this.name),e&&_.extend(r.props,e);var i="com_"+_.md5(),s=_.md5(),o=app.getCurrentTemplate(),u=Template[o.tplName],a=new n(i,s,r,u);a.render(function(e){var t=document.createElement("div");t.innerHTML=''+e+"",o._node.appendChild(t.children[0])})},n.prototype.bindEvent=function(){var e=this;if(e.binded)return;e.binded=!0;var t=e.opts,n=t.events.call(t),r={};for(var i in n)r[i]=n[i];var s=document.querySelector("#"+e.id);e.template.events(r),e.template.bindEvent(s)},n.prototype.render=function(t){var n=this.opts,r=e.render(n.template,n.props,function(e){t(e)})},hydra.component=e.component,hydra.loadComponent=e.loadComponent})(Mustang)})();(function(window){function Mvc(e){this.name=e,this._routParms={},_.extend(this,Event)}function View(e,t,n){this.template=t,this.seletor=e}function Scope(e,t,n){this._id=e,this._tpl=t,this._controller=n,this.eventPipe=EventPipe.pipe(t.tplName+"_innerPipe")}function newInstance(strClass){function F(){return clsClass.apply(this,args)}var args=Array.prototype.slice.call(arguments,1),clsClass=eval(strClass);return F.prototype=clsClass.prototype,new F}function newFunction(e){function n(){return e.apply(this,t)}var t=Array.prototype.slice.call(arguments,1);return n.prototype=e.prototype,new n}function loadController(e){var t="/controllers/"+e+".js",n=_config.base+t;resourceMap&&resourceMap["/js"+t]&&(n=_config.base+resourceMap["/js"+t].slice(3)),_.loadJs(n)}function loadModule(e){if(e.length>0)for(var t=0,n=e.length;t0&&_.each(n,function(e,t){var n=_moduleBus[t];if(!n||n.state!=STATE.LOADED)r=!1}),r&&(t.state=STATE.LOADED,globalDependenceCheck())}}function globalDependenceCheck(){for(var e in _moduleBus){var t=_moduleBus[e];if(t&&t.state!=STATE.LOADED){var n=t.dependences,r=!0;n.length>0&&_.each(n,function(e,t){var i=_moduleBus[n[e]];if(!i||i.state!=STATE.LOADED)r=!1}),r&&(t.state=STATE.LOADED,checkRunStack(t.name),globalDependenceCheck())}else t&&t.state==STATE.LOADED&&checkRunStack(t.name)}}function checkRunStack(e){if(_runStack.length>0&&_runStack[0].controller==e){var t=_runStack.pop();runController(t.controller,t.tpl,t.view)}}function runController(e,t,n){var r=_moduleBus[e];if(r&&r.state==STATE.LOADED){var i=_.md5()+"_"+_.uuid(),s=new Scope(i,t,e);_controllerBus[e]={scope:s,view:n,states:{}};var o=newState(e,function(){_controllerBus[e].scope.apply()});_controllerBus[e].states[e]=o;if(r.dependences){var u=[];_.each(r.dependences,function(t,n){var r=injectModule(e,_moduleBus[n]);u.push(r)})}r.fn.apply(s,u),_currentController=e,s.apply()}else _runStack.push({controller:e,tpl:t,view:n}),loadController(e)}function injectModule(e,t){if(t&&t.state==STATE.LOADED){var n=[];t.dependences&&_.each(t.dependences,function(t,r){var i=_moduleBus[r];switch(i.type){case"plugin":n.push(injectModule(i));break;case"store":var s=newState(i.name,function(){_controllerBus[e].scope.apply()});_controllerBus[e].states[i.name]=s,n.push(i.fn.apply(StoreUtil,[s]))}});switch(t.type){case"plugin":var r=t.fn.apply(newDataScope({}),n);return _.copy(r,Event);case"store":var i=_controllerBus[e],s=newState(t.name,function(){i.scope.apply()});return i.states||(i.states={}),i.states[t.name]=s,t.fn.apply(StoreUtil,[s])}}}var _moduleBus={},_controllerBus={},_viewBus={},_runStack=[],_parseTree={},_parseBus={},_config=null,_uid=1,_currentController=null,_cssBus={},_currentPath,STATE={INIT:0,LOADED:1,RUN:2};Mvc.prototype.controller=function(e){var t,n,r=Array.prototype.slice.call(arguments,1);r.length==2?(t=r[0],n=r[1]):(t="",n=r[0]),_.isFunction(n)||console.error("controller [",e,"], arguments error.");var i=e;if(_moduleBus[i]){console.error("controller [",e,"] already exist.");return}var s=getDependence(t)||[];_moduleBus[i]={name:i,type:"controller",state:STATE.INIT,states:{},dependences:s,fn:n},loadModule(s),checkDependence(i)},Mvc.prototype.store=function(e){var t,n,r=Array.prototype.slice.call(arguments,1);r.length==2?(t=r[0],n=r[1]):(t="",n=r[0]),_.isFunction(n)||console.error("store [",e,"], arguments error.");var i="stores/"+e;if(_moduleBus[i]){console.error("store [",e,"] already exist.");return}var s=getDependence(t)||[];_moduleBus[i]={name:i,type:"store",state:STATE.INIT,states:{},dependences:s,fn:n},loadModule(s),checkDependence(i)},Mvc.prototype.config=function(e){function r(e){var r=n[e];/^\//.test(e)&&Path.map("#"+e).to(function(){r.redirect?Path.dispatch(r.redirect):(r.css&&(_cssBus[r.css]||(_.loadCss(r.css),_cssBus[r.css]=!0)),t._route(e),t.dispatchEvent("pathChange","#"+e))})}var t=this;_config=e;var n=e.router;runController("AppController"),_.each(n,function(e,t){r(e)}),Path.listen(),location.hash==""&&t.redirect("/")},Mvc.prototype.redirect=function(e){_currentPath=e,location.href=location.href.split("#")[0]+"#"+e},Mvc.prototype.setRouteParam=function(e){var t=this;_.each(e,function(e,n){t._routParms[e]=n})},Mvc.prototype.getRouteParam=function(e){return this._routParms[e]},Mvc.prototype.removeRouteParam=function(e){delete this._routParms[e]},Mvc.prototype.emptyRouteParam=function(e){this._routParms={}},Mvc.prototype._route=function(e){var t=_config.router[e];if(t&&t.template){if(_currentController){var n=_controllerBus[_currentController];n&&n.scope&&n.scope.finalize&&n.scope.finalize()}_currentPath=e;var r=t.view||_config.view;_viewBus[r]&&delete _viewBus[r],_viewBus[r]=new View(r,t.template);var i=Mustang.load(_config.base+"/"+t.template);runController(t.controller,i,_viewBus[r])}},Mvc.prototype.getCurrentRoute=function(){return _currentPath},Mvc.prototype.getCurrentTemplate=function(){return _controllerBus[_currentController].scope._tpl},Scope.prototype.on=function(){},Scope.prototype.dispatch=function(){},Scope.prototype.getState=function(){var e=_controllerBus[this._controller].states;return e[this._controller]},Scope.prototype.getMergedState=function(){var e=_controllerBus[this._controller].states,t={};for(var n in e)_.extend(t,e[n].state);return t},Scope.prototype.setState=function(e){var t=_controllerBus[this._controller].states;_.extend(t[this._controller].state,e),this.apply()},Scope.prototype.apply=function(){var e=this._tpl,t=_moduleBus[this._controller];if(t&&t.state==STATE.LOADED&&_controllerBus[t.name]){var n=_controllerBus[t.name].view,r=this.getMergedState();r&&e.render(n,r)}};var Path={map:function(e){return Path.routes.defined.hasOwnProperty(e)?Path.routes.defined[e]:new Path.core.route(e)},root:function(e){Path.routes.root=e},rescue:function(e){Path.routes.rescue=e},match:function(e,t){var n={},r=null,i,s,o,u,a;for(r in Path.routes.defined)if(r!==null&&r!==undefined){r=Path.routes.defined[r],i=r.partition();for(u=0;u0)for(o=0;o=8)?window.onhashchange=e:setInterval(e,100),location.hash!==""&&Path.dispatch(location.hash)},core:{route:function(e){this.path=e,this.action=null,this.do_enter=[],this.do_exit=null,this.params={},Path.routes.defined[e]=this}},routes:{current:null,root:null,rescue:null,previous:null,defined:{}}};Path.core.route.prototype={to:function(e){return this.action=e,this},enter:function(e){return e instanceof Array?this.do_enter=this.do_enter.concat(e):this.do_enter.push(e),this},exit:function(e){return this.do_exit=e,this},partition:function(){var e=[],t=[],n=/\(([^}]+?)\)/g,r,i;while(r=n.exec(this.path))e.push(r[1]);t.push(this.path.split("(")[0]);for(i=0;i0)for(t=0;t