!function(t){function e(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t}function i(t,i){var n=t.prototype,s=new Function;s.prototype=i.prototype,t.prototype=new s,t.prototype.constructor=t,e(t.prototype,n)}function n(t,e,i){if(t&&t.length>0)for(var n=0,s=t.length;s>n&&e.call(i||t,t[n],n)!==!1;n++);}function s(t,e){var i;return n(t,function(t){return i=t===e,!i}),i}function r(t,e){var i=Function.prototype.bind,n=Array.prototype.slice;if(i&&t.bind===i)return i.apply(t,n.call(arguments,1));var s=n.call(arguments,2);return function(){return t.apply(e,s.concat(n.call(arguments)))}}function o(t,e,i){t.addEventListener?t.addEventListener(e,i,!1):t.attachEvent("on"+e,i)}function a(t,e,i){t.addEventListener?t.removeEventListener(e,i,!1):t.detachEvent("on"+e,i)}function p(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function h(t){return xe[t]?document.createElementNS("http://www.w3.org/2000/svg",t):document.createElement(t)}function c(){return"_san_"+Ne++}function u(t,e){if(e&&(t=r(t,e)),we.push(t),!Ce)if(Ce=function(){var t=we.slice(0);we=[],Ce=null,n(t,function(t){t()})},"function"==typeof MutationObserver){var i=1,s=new MutationObserver(Ce),o=document.createTextNode(i);s.observe(o,{characterData:!0}),o.data=++i}else"function"==typeof setImmediate?setImmediate(Ce):setTimeout(Ce,0)}function l(){this.raw=Ae?[]:"",this.length=0}function d(){this.raw=[],this.index={}}function f(t){return/^(area|base|br|col|embed|hr|img|input|keygen|param|source|track|wbr)$/i.test(t)}function v(t){this.source=t,this.len=this.source.length,this.index=0}function g(t){t&&t.isText||(this.directives=new d,this.props=new d,this.events=new d,this.childs=[]),e(this,t)}function y(t){function e(t){t&&a.childs.push(new g({isText:!0,text:t,textExpr:w(t),parent:a}))}var i=new g;if("string"!=typeof t)return i;t=t.replace(//gm,"").replace(/(^\s+|\s+$)/g,"");for(var n,s=new v(t),r=/<(\/)?([a-z0-9-]+)\s*/gi,o=/([-:0-9a-z\(\)\[\]]+)(=(['"])([^\3]*?)\3)?\s*/gi,a=i,p=0;null!=(n=s.match(r));){var h=n[1],c=n[2].toLowerCase();if(e(t.slice(p,s.index-n[0].length)),h&&62===s.currentCode()){for(var u=a;u&&u.tagName!==c;)u=u.parent;u&&(a=u.parent),s.go(1)}else if(!h){for(var l=new g({tagName:c,parent:a}),d=f(c);;){var y=s.currentCode();if(62===y){s.go(1);break}if(47===y&&62===s.charCode(s.index+1)){s.go(2),d=1;break}var x=s.match(o);x&&m(l,x[1],x[2]?x[4]:x[1])}a.childs.push(l),d||(a=l)}p=s.index}return e(s.cut(p)),i}function m(t,e,i,n){if("id"===e)return void(t.id=i);var s,r,o=e.indexOf("-");switch(o>0&&(r=e.slice(0,o),s=e.slice(o+1)),r){case"on":t.events.push({name:s,expr:A(i)});break;case"san":var a=N(s,i);a&&t.directives.push(a);break;case"prop":x(t,s,i);break;default:n||x(t,e,i)}}function x(t,e,i){var n=i.match(/^\{=\s*(.*?)\s*=\}$/);return n?void t.props.push({name:e,expr:E(n[1]),x:!0}):void t.props.push(C({name:e,expr:w(i),raw:i}))}function C(t){return"class"===t.name&&n(t.expr.segs,function(t){t.type===Te.INTERP&&t.filters.push({type:Te.CALL,name:"join",args:[{type:Te.STRING,value:" "}]})}),t}function N(t,e){var i=be[t];if(i){var n=i(e);return n.name=t,n}}function w(t){function e(t){t&&o.push({type:Te.STRING,value:t})}for(var i,n=/\{\{\s*([\s\S]+?)\s*\}\}/gi,s=new v(t),r=0,o=[];null!=(i=s.match(n));)e(s.cut(r,s.index-i[0].length)),o.push(_(i[1])),r=s.index;return e(s.cut(r)),{type:Te.TEXT,segs:o}}function _(t){for(var e=new v(t),i=R(e),n=[];e.goUntil(124);)n.push(B(e));return{type:Te.INTERP,expr:i,filters:n}}function E(t){return"object"==typeof t&&t.type?t:R(new v(t))}function A(t){return B(new v(t))}function S(t){var e,i=t.currentCode(),n=t.index;t:for(;e=t.nextCode();)switch(e){case 92:t.go(1);break;case i:t.go(1);break t}var s=t.cut(n,t.index);return{type:Te.STRING,value:new Function("return "+s)()}}function T(t){var e=t.match(/\s*([\$0-9a-z_]+)/gi);return e[1]}function b(t){var e=t.match(/\s*(-?[0-9]+(.[0-9]+)?)/g);return{type:Te.NUMBER,value:e[1]-0}}function k(t){var e={type:Te.ACCESSOR,paths:[{type:Te.STRING,value:T(t)}]};t:for(;;)switch(t.currentCode()){case 46:t.go(1),e.paths.push({type:Te.STRING,value:T(t)});break;case 91:t.go(1),e.paths.push(R(t)),t.goUntil(93);break;default:break t}return e}function R(t){var e=H(t);if(t.goUntil(),63===t.currentCode()){t.go(1);var i=R(t);if(t.goUntil(),58===t.currentCode())return t.go(1),{type:Te.TERTIARY,segs:[e,i,R(t)]}}return e}function H(t){var e=I(t);if(t.goUntil(),124===t.currentCode()){if(124===t.nextCode())return t.go(1),{type:Te.BINARY,operator:248,segs:[e,H(t)]};t.go(-1)}return e}function I(t){var e=L(t);if(t.goUntil(),38===t.currentCode()){if(38===t.nextCode())return t.go(1),{type:Te.BINARY,operator:76,segs:[e,I(t)]};t.go(-1)}return e}function L(t){var e=U(t);t.goUntil();var i=t.currentCode();switch(i){case 61:case 33:if(61===t.nextCode())return i+=61,61===t.nextCode()&&(i+=61,t.go(1)),{type:Te.BINARY,operator:i,segs:[e,L(t)]};t.go(-1)}return e}function U(t){var e=M(t);t.goUntil();var i=t.currentCode();switch(i){case 60:case 62:return 61===t.nextCode()&&(i+=61,t.go(1)),{type:Te.BINARY,operator:i,segs:[e,U(t)]}}return e}function M(t){var e=O(t);t.goUntil();var i=t.currentCode();switch(i){case 43:case 45:return t.go(1),{type:Te.BINARY,operator:i,segs:[e,M(t)]}}return e}function O(t){var e=D(t);t.goUntil();var i=t.currentCode();switch(i){case 42:case 47:return t.go(1),{type:Te.BINARY,operator:i,segs:[e,O(t)]}}return e}function D(t){switch(t.goUntil(),t.currentCode()){case 33:return t.go(1),{type:Te.UNARY,expr:D(t)};case 34:case 39:return S(t);case 45:case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return b(t);case 40:return P(t)}return k(t)}function P(t){t.go(1);var e=R(t);return t.goUntil(41),e}function B(t){t.goUntil();var e=T(t),i=[];if(t.goUntil(40))for(;!t.goUntil(41);)i.push(R(t)),t.goUntil(44);return{type:Te.CALL,name:e,args:i}}function Y(t,e,i){var s;return n(e,function(e){return s=V(t,e,i),!s}),s?1:0}function V(t,e,i){switch(e.type){case Te.ACCESSOR:for(var s=e.paths,r=s.length,o=t.paths,a=o.length,p=1,h=0;r>h;h++){var c=s[h];if(c.type===Te.ACCESSOR&&V(t,c,i))return 1;p&&a>h&&$(c,i)!=o[h].value&&(p=0)}return p&&(p=Math.max(1,a-r+2)),p;case Te.UNARY:return V(t,e.expr,i)?1:0;case Te.TEXT:case Te.BINARY:case Te.TERTIARY:return Y(t,e.segs,i);case Te.INTERP:if(!V(t,e.expr,i)){var u;return n(e.filters,function(e){return u=Y(t,e.args,i),!u}),u?1:0}return 1}return 0}function F(t){this.parent=t,this.listeners=[],this.data={}}function j(t){return He[t]}function G(t){return null==t?"":String(t).replace(/[&<>"']/g,j)}function $(t,e,i,s){switch(t.type){case Te.UNARY:return!$(t.expr,e,i);case Te.BINARY:var r=ke[t.operator];if("function"==typeof r)return r($(t.segs[0],e,i),$(t.segs[1],e,i));return;case Te.TERTIARY:var o=$(t.segs[0],e,i);return $(o?t.segs[1]:t.segs[2],e,i);case Te.STRING:case Te.NUMBER:return t.value;case Te.ACCESSOR:return e.get(t);case Te.INTERP:var a=$(t.expr,e,i);return i&&n(t.filters,function(t){var s=t.name,r=i.filters[s]||Ie[s];if("function"==typeof r){var o=[a];n(t.args,function(t){o.push($(t,e,i))}),a=r.apply(i,o)}}),null==a&&(a=""),a;case Te.TEXT:var p=new l;return n(t.segs,function(t){var n=$(t,e,i);s&&t.type===Te.INTERP&&!t.filters[0]&&(n=G(n)),p.push(n)}),p.toString()}}function z(){this.raw={}}function W(t){t=t||{},this.lifeCycle=new z,this.init(t)}function X(t){return''}function q(t){W.call(this,t)}function J(t){this.childs=[],this.listeners={},W.call(this,t)}function K(t,e){return t=t.toLowerCase(),{input:{attr:function(e,i,n){return n&&"false"!==n&&"0"!==n?" "+t+'="'+t+'"':void 0},prop:function(e,i,n){var s=Me[t]||t;e.el[s]=!(!n||"false"===n||"0"===n)}},choose:function(i){return s(e,i.tagName)?t:void 0}}}function Q(t,e){return t.propHandlers[e]||Oe}function Z(t){Q(this,t.name).output(this,t)}function te(t,e){var i=[],s=t.expr;n(s.args,function(t){i.push(t.type===Te.ACCESSOR&&1===t.paths.length&&"$event"===t.paths[0].value?this instanceof oe?e:e||window.event:this.evalExpr(t))},this);var r=this.owner;this instanceof oe&&t.isOwn&&(r=this);var o=r[s.name];"function"==typeof o&&o.apply(r,i)}function ee(t,e){t.tagName&&(e.push("<"),e.push(t.tagName),e.push(' id="'),e.push(t.id),e.push('"'),t.props.each(function(t){var i=this instanceof oe?$(t.expr,this.data,this):this.evalExpr(t.expr,1);e.push(Q(this,t.name).input.attr(this,t.name,i)||"")},t),e.push(">"))}function ie(t,e){var i=t.tagName;f(i)||(e.push(""),e.push(i),e.push(">"))}function ne(t){if("textarea"===t.tagName){var e=t.props.get("value");return e?G(t.evalExpr(e.expr)):""}var i=new l;return n(t.aNode.childs,function(e){var n=pe(e,t);t.childs.push(n),i.push(n.genHTML())}),i.toString()}function se(t,e,i){var n=t.option.target;return n&&n.id===e.id&&(!i||n.prop===i)}function re(t){this.childs=[],W.call(this,t)}function oe(t){this.slotChilds=[],this.data=new F,this.dataChanges=[],J.call(this,t)}function ae(t){for(var e,i=new le(t.el);e=i.current;){var n=he(e,t,i);n&&t.childs.push(n),i.goNext()}}function pe(t,e,i){var n=e instanceof oe?e:e.owner;i=i||(e instanceof oe?e.data:e.scope);var s={aNode:t,owner:n,scope:i,parent:e};if(t.isText)return new q(s);if(t.directives.get("if"))return new de(s);if(t.directives.get("else"))return new ve(s);if(t.directives.get("for"))return new ge(s);var r=n.components[t.tagName];return r?new r(s):"slot"===t.tagName?new re(s):new J(s)}function he(t,e,i){var n=e instanceof oe?e:e.owner,s=t.tagName.toLowerCase(),r=null;s.indexOf("-")>0&&(r=n.components[s]);var o=t.getAttribute("san-component");o&&(r=n.components[o]);var a={owner:n,scope:n.data,parent:e,el:t,elWalker:i};if(r)return new r(a);var p=ce(t),h=t.getAttribute("san-stump");return a.aNode=p,p.directives.get("if")||"if"===h?new de(a):p.directives.get("else")||"else"===h?new ve(a):p.directives.get("for")||"for"===h?new ge(a):ue(t)?new q(a):new J(a)}function ce(t){var e=new g;return e.tagName=t.tagName.toLowerCase(),n(t.attributes,function(t){m(e,t.name,t.value,!0)}),e}function ue(t){return"SCRIPT"===t.tagName&&"text/san"===t.type}function le(t){this.raw=[],this.index=0;for(var e=t.firstChild;e;)1===e.nodeType&&this.raw.push(e),e=e.nextSibling;this.current=this.raw[this.index],this.next=this.raw[this.index+1]}function de(t){J.call(this,t)}function fe(t){var e=t.aNode,i=new g({childs:e.childs,props:e.props,events:e.events,tagName:e.tagName,directives:(new d).concat(e.directives)});return i.directives.remove("if"),i.directives.remove("else"),pe(i,t)}function ve(t){for(var e=t.parent.childs,i=e.length;i--;){var n=e[i];if(n instanceof de){var s={name:"if",value:{type:Te.UNARY,expr:n.aNode.directives.get("if").value}};return t.aNode.directives.push(s),t.el&&(ue(t.el)?t.el.setAttribute("san-stump","if"):t.el.removeAttribute("san-else")),t.ifDirective=s,new de(t)}if(!(n instanceof q))throw new Error("[SAN FATEL] else not match if.")}}function ge(t){J.call(this,t)}function ye(t,e,i){function s(t){return t.paths[0].value===r.item?{type:Te.ACCESSOR,paths:r.list.paths.concat({type:Te.NUMBER,value:o.get(r.index)},t.paths.slice(1))}:t}var r=t.aNode.directives.get("for"),o=new F(t.scope);o.set(r.item,e),o.set(r.index,i),n(["set","remove","unshift","shift","push","pop","splice"],function(e){var i=t.scope[e];o[e]=function(e){e=s(E(e)),i.apply(t.scope,[e].concat(Array.prototype.slice.call(arguments,1)))}});var a=t.aNode,p=new g({childs:a.childs,props:a.props,events:a.events,tagName:a.tagName,directives:(new d).concat(a.directives)});return p.directives.remove("for"),pe(p,t,o)}function me(t){function e(t){oe.call(this,t)}return e.prototype=t,i(e,oe),e}var xe={};n("svg,g,defs,desc,metadata,symbol,use,image,path,rect,circle,line,ellipse,polyline,polygon,text,tspan,tref,textpath,marker,pattern,clippath,mask,filter,cursor,view,animate,font,font-face,glyph,missing-glyph".split(","),function(t){xe[t]=1});var Ce,Ne=1,we=[],_e="undefined"!=typeof navigator&&navigator.userAgent.match(/msie\s*([0-9]+)/i),Ee=_e?_e[1]-0:0,Ae=Ee&&8>Ee,Se=Ee&&9>Ee;l.prototype.toString=function(){return Ae?this.raw.join(""):this.raw},l.prototype.push=Ae?function(t){this.raw[this.length++]=t}:function(t){this.length++,this.raw+=t},d.prototype.push=function(t){if(!t.name)throw new Error('Miss "name" property');this.index[t.name]||(this.raw.push(t),this.index[t.name]=t)},d.prototype.getAt=function(t){return this.raw[t]},d.prototype.get=function(t){return this.index[t]},d.prototype.each=function(t,e){n(this.raw,r(t,e||this))},d.prototype.remove=function(t){this.index[t]=null;for(var e=this.raw.length;e--;)if(this.raw[e].name===t){this.raw.splice(e,1);break}},d.prototype.concat=function(t){var e=new d;return n(this.raw.concat(t.raw),function(t){e.push(t)}),e};var Te={STRING:1,NUMBER:2,ACCESSOR:3,INTERP:4,CALL:5,TEXT:6,BINARY:7,UNARY:8,TERTIARY:9};v.prototype.currentCode=function(){return this.charCode(this.index)},v.prototype.cut=function(t,e){return this.source.slice(t,e)},v.prototype.go=function(t){this.index+=t},v.prototype.nextCode=function(){return this.go(1),this.currentCode()},v.prototype.charCode=function(t){return this.source.charCodeAt(t)},v.prototype.goUntil=function(t){for(var e;this.indext},62:function(t,e){return t>e},76:function(t,e){return t&&e},94:function(t,e){return t!=e},121:function(t,e){return e>=t},122:function(t,e){return t==e},123:function(t,e){return t>=e},155:function(t,e){return t!==e},183:function(t,e){return t===e},248:function(t,e){return t||e}},Re={SET:1,SPLICE:2};F.prototype.onChange=function(t){"function"==typeof t&&this.listeners.push(t)},F.prototype.unChange=function(t){for(var e=this.listeners.length;e--;)t&&this.listeners[e]!==t||this.listeners.splice(e,1)},F.prototype.fireChange=function(t){n(this.listeners,function(e){e.call(this,t)},this)},F.prototype.get=function(t){if(t=E(t),t.type===Te.ACCESSOR){for(var e=t.paths,i=0,n=e.length;n>i&&null!=e[i].value;i++);for(var s=this.data,r=0;null!=s&&i>r;r++)s=s[e[r].value];for(null==s&&this.parent&&(s=this.parent.get({type:Te.ACCESSOR,paths:e.slice(0,i)})),r=i;null!=s&&n>r;r++)s=s[e[r].value||$(e[r],this)];return s}},F.prototype.set=function(t,e,i){if(i=i||{},t=E(t),t.type===Te.ACCESSOR){for(var n,s=this.data,r=t.paths,o=0,a=r.length;a-1>o;o++){var p=$(r[o],this);null==s[p]&&(s[p]={}),s=s[p]}n=$(r[o],this),null!=n&&(s[n]=e,!i.silence&&this.fireChange({type:Re.SET,expr:t,value:e,option:i}))}},F.prototype.push=function(t,e,i){var n=this.get(t);n instanceof Array&&this.splice(t,[n.length,0,e],i)},F.prototype.pop=function(t,e){var i=this.get(t);if(i instanceof Array){var n=i.length;if(n)return this.splice(t,[n-1,1],e)[0]}},F.prototype.shift=function(t,e){return this.splice(t,[0,1],e)[0]},F.prototype.unshift=function(t,e,i){this.splice(t,[0,0,e],i)},F.prototype.removeAt=function(t,e,i){this.splice(t,[e,1],i)},F.prototype.remove=function(t,e,i){var n=this.get(t);if(n instanceof Array)for(var s=n.length;s--;)if(n[s]===e){this.splice(t,[s,1],i);break}},F.prototype.splice=function(t,e,i){i=i||{},t=E(t);var n=this.get(t),s=[];if(n instanceof Array){var r=e[0];if(0>r||r>n.length)return;s=n.splice.apply(n,e),!i.silence&&this.fireChange({expr:t,type:Re.SPLICE,index:r,deleteCount:s.length,value:s,insertions:e.slice(2),option:i})}return s};var He={"&":"&","<":"<",">":">",'"':""","'":"'"},Ie={html:G,url:encodeURIComponent,raw:function(t){return t},join:function(t,e){return t instanceof Array?t.join(e):t}},Le={compiled:{value:1},inited:{value:2},created:{value:3},attached:{value:4,mutex:"detached"},detached:{value:5,mutex:"attached"},disposed:{value:6,mutex:"*"}};z.prototype.set=function(t){var e=Le[t];e&&("*"===e.mutex?this.raw={}:e.mutex&&(this.raw[Le[e.mutex].value]=0),this.raw[e.value]=1)},z.prototype.is=function(t){var e=Le[t];return e?!!this.raw[e.value]:!1},W.prototype._callHook=function(t){this.lifeCycle.is(t)||(this.lifeCycle.set(t),"function"==typeof this["_"+t]&&this["_"+t].call(this),"function"==typeof this[t]&&this[t].call(this))},W.prototype.init=function(t){this._init(t),this._callHook("inited")},W.prototype._init=function(t){this.owner=t.owner,this.parent=t.parent,this.parentComponent=this.parent instanceof oe?this.parent:this.parent&&this.parent.parentComponent,this.scope=t.scope,this.aNode=this.aNode||t.aNode,this.el=t.el,this.id=this.el&&this.el.id||this.aNode&&this.aNode.id||c()},W.prototype._created=function(){this.el||(this.el=document.getElementById(this.id))},W.prototype._noticeAttached=function(){n(this.childs,function(t){t._noticeAttached()}),this._callHook("created"),this._callHook("attached")},W.prototype.dispose=function(){this._dispose(),this._callHook("disposed")},W.prototype._dispose=function(){this.el=null,this.owner=null,this.scope=null,this.aNode=null,this.parent=null,this.parentComponent=null},W.prototype.evalExpr=function(t,e){return $(t,this.scope,this.owner,e)},i(q,W),q.prototype._init=function(t){W.prototype._init.call(this,t),this.el&&(this.aNode.isText=!0,this.aNode.textExpr=w(this.el.innerHTML),this.parent._pushChildANode(this.aNode))},q.prototype._inited=function(){this.el&&(this._callHook("created"),this.el.parentNode&&this._callHook("attached"))},q.prototype.genHTML=function(){var t=Se?"":"";return(this.evalExpr(this.aNode.textExpr,1)||t)+X(this)},q.prototype.update=function(){var t=this.el.previousSibling;if(t&&3===t.nodeType){var e="string"==typeof t.textContent?"textContent":"data";t[e]=this.evalExpr(this.aNode.textExpr)}else this.el.insertAdjacentHTML("beforebegin",this.evalExpr(this.aNode.textExpr,1))},q.prototype.updateView=function(t){n(t,function(t){return V(t.expr,this.aNode.textExpr,this.scope)?(this.update(),!1):void 0},this)},q.prototype.updateData=function(){};var Ue={};i(J,W),J.prototype._init=function(t){W.prototype._init.call(this,t),this.el&&this._initFromEl(t),Ue[this.id]=this,this.tagName=this.tagName||this.aNode.tagName||"div",Ee&&9>Ee&&/^[a-z0-9]+-[a-z0-9]+$/i.test(this.tagName)&&(this.tagName="div")},J.prototype._initFromEl=function(){this.aNode=ce(this.el),this.parent._pushChildANode(this.aNode),this.tagName=this.aNode.tagName},J.prototype._inited=function(){this.props=this.binds=this.aNode.props,this._initPropHandlers(),this.el&&(this.tagName=this.el.tagName.toLowerCase(),ae(this),this._callHook("created"),this.el.parentNode&&this._callHook("attached"))},J.prototype._create=function(){this.el||(this.el=h(this.tagName),this.el.id=this.id,this.props.each(function(t){var e=this instanceof oe?$(t.expr,this.data,this):this.evalExpr(t.expr,1),i=/^\s+([a-z0-9_-]+)="(.*)"$/.exec(Q(this,t.name).input.attr(this,t.name,e));i&&this.el.setAttribute(i[1],i[2])},this))},J.prototype.create=function(){this.lifeCycle.is("created")||(this._create(),this._callHook("created"))},J.prototype._created=function(){W.prototype._created.call(this),this._initSelfChanger(),this.bindEvents()},J.prototype._initSelfChanger=function(){this.binds&&this.binds.each(function(e){if(e.x){var i=r(Z,this,e);switch(e.name){case"value":switch(this.tagName){case"input":case"textarea":t.CompositionEvent&&(this.on("compositionstart",function(){this.composing=1}),this.on("compositionend",function(){this.composing=0;var t=document.createEvent("HTMLEvents");t.initEvent("input",!0,!0),this.dispatchEvent(t)})),this.on("oninput"in this.el?"input":"propertychange",function(t){this.composing||i(t)});break;case"select":this.on("change",i)}break;case"checked":switch(this.tagName){case"input":switch(this.el.type){case"checkbox":case"radio":this.on("click",i)}}}}},this)};var Me={readonly:"readOnly",cellpadding:"cellPadding",cellspacing:"cellSpacing",colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",usemap:"useMap",frameborder:"frameBorder","for":"htmlFor","class":"className"},Oe={input:{attr:function(t,e,i){return null!=i?" "+e+'="'+i+'"':void 0},prop:function(t,e,i){e=Me[e]||e,xe[t.tagName]?t.el.setAttribute(e,i):t.el[e]=i}},output:function(t,e){t.scope.set(e.expr,t.el[e.name],{target:{id:t.id,prop:e.name}})}},De=[K("disabled",["input","textarea","button","select"]),K("readonly",["input","textarea"]),K("mutiple",["input"]),{input:{attr:function(t,e,i){var n=t.props.get("value");return n&&s(i,t.evalExpr(n.expr))?' checked="checked"':void 0},prop:function(t,e,i){var n=t.props.get("value");return n&&s(i,t.evalExpr(n.expr))?void(t.el.checked=!0):void(t.el.checked=!1)}},output:function(t,e){var i=t.el;t.scope[i.checked?"push":"remove"](e.expr,i.value)},choose:function(t){if(t.aNode){var e=t.props.get("type");return"input"===t.tagName&&e&&"checkbox"===e.raw&&"checked"}}},{input:{attr:function(t,e,i){var n=t.props.get("value");return n&&i===t.evalExpr(n.expr)?' checked="checked"':void 0},prop:function(t,e,i){var n=t.props.get("value");return n&&i===t.evalExpr(n.expr)?void(t.el.checked=!0):void(t.el.checked=!1)}},output:function(t,e){var i=t.el;t.scope.set(e.expr,i.checked?i.value:"",{target:{id:t.id,prop:e.name}})},choose:function(t){if(t.aNode){var e=t.props.get("type");return"input"===t.tagName&&e&&"radio"===e.raw&&"checked"}}},{input:{attr:function(t,e,i){i&&u(function(){t.lifeCycle.is("created")&&(t.el[e]=i)})},prop:function(t,e,i){t.el[e]=i}},output:Oe.output,choose:function(t){return"select"===t.tagName&&"value"}},{input:{attr:function(){},prop:function(t,e,i){t.el[e]=i}},output:Oe.output,choose:function(t){return"textarea"===t.tagName&&"value"}},{input:{attr:function(t,e,i){return i?' style="'+i+'"':void 0},prop:function(t,e,i){t.el.style.cssText=i}},choose:function(){return"style"}}];J.prototype._initPropHandlers=function(){this.propHandlers={},n(De,function(t){var e=t.choose(this);e&&(this.propHandlers[e]=t)},this)},J.prototype.attach=function(t,e){this.lifeCycle.is("attached")||(this._attach(t,e),this._noticeAttached())},J.prototype._attach=function(t,e){this.create(),this.el.innerHTML=ne(this),t&&(e?t.insertBefore(this.el,e):t.appendChild(this.el))},J.prototype.bindEvents=function(){this.aNode.events.each(function(t){this.on(t.name,r(te,this,t))},this)},J.prototype.unbindEvents=function(){var t=this.listeners;for(var e in t)t.hasOwnProperty(e)&&this.un(e);this.listeners=null},J.prototype.fire=function(t,e){n(this.listeners[t],function(t){t.call(this,e)},this)},J.prototype.on=function(t,e){"function"==typeof e&&(this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),o(this.el,t,e))},J.prototype.un=function(t,e){for(var i=this.listeners[t],n=i&&i.length;n--;){var s=i[n];e&&e!==s||(i.splice(n,1),a(this.el,t,s))}},J.prototype.genHTML=function(){var t=new l;return ee(this,t),t.push(ne(this)),ie(this,t),t.toString()},J.prototype.setProp=function(t,e){this.lifeCycle.is("created")&&Q(this,t).input.prop(this,t,e)},J.prototype.updateView=function(t){this.props.each(function(e){n(t,function(t){return!se(t,this,e.name)&&V(t.expr,e.expr,this.scope)?(this.setProp(e.name,this.evalExpr(e.expr)),!1):void 0},this)},this),n(this.childs,function(e){e.updateView(t)})},J.prototype.updateData=function(t){n(this.childs,function(e){e.updateData(t)})},J.prototype.detach=function(){this.lifeCycle.is("attached")&&(this._detach(),this._callHook("detached"))},J.prototype._detach=function(){p(this.el)},J.prototype._dispose=function(){this._disposeChilds(),this.detach(),this.unbindEvents(),this.el=null,this.childs=null,this.propHandlers=null,this.props=null,this.binds=null,Ue[this.id]=null,W.prototype._dispose.call(this)},J.prototype._disposeChilds=function(){n(this.childs,function(t){t.dispose()}),this.childs.length=0},J.prototype.disposeSoon=function(){u(this.dispose,this)},J.prototype._pushChildANode=function(t){this.aNode.childs.push(t)},i(re,W),re.prototype._init=function(t){var e=t.aNode.props.get("name");this.name=e?e.raw:"____";var i=t.owner,n=i.aNode.givenSlots,s=n&&n[this.name],r=new g;s?(r.childs=s,t.owner=i.owner,t.scope=i.scope):r.childs=t.aNode.childs.slice(0),t.aNode=r,W.prototype._init.call(this,t)},re.prototype._inited=function(){this.owner.slotChilds.push(this)},re.prototype.genHTML=function(){return ne(this)},re.prototype.updateView=function(){},re.prototype.slotUpdateView=function(t){n(this.childs,function(e){e.updateView(t)})},re.prototype.updateData=J.prototype.updateData,re.prototype._dispose=function(){J.prototype._disposeChilds.call(this),W.prototype._dispose.call(this)},i(oe,J),oe.prototype.init=function(t){if(this.filters=t.filters||this.filters||{},this.messages=t.messages||this.messages||{},this._compile(),!t.el){var e=this.constructor.prototype.aNode;if(t.aNode){var i=t.aNode,s={};n(i.childs,function(t){var e="____",i=!t.isText&&t.props.get("slot");i&&(e=i.raw),s[e]||(s[e]=[]),s[e].push(t)},this),this.aNode=new g({tagName:e.tagName||i.tagName,givenSlots:s,childs:e.childs,props:e.props,binds:i.props,events:i.events.concat(e.events),directives:i.directives.concat(e.directives)})}}this._callHook("compiled"),J.prototype._init.call(this,t),this.binds=this.aNode.binds||new d,this.binds.each(function(t){var e=t.expr;e.type===Te.TEXT&&1===e.segs.length&&(e=t.expr=e.segs[0],e.type===Te.INTERP&&0===e.filters.length&&(t.expr=e.expr))}),this.props=this.aNode.props;var r=t.data||"function"==typeof this.initData&&this.initData();for(var o in r)r.hasOwnProperty(o)&&this.data.set(o,r[o]);this.scope&&this.binds.each(function(t){this.data.set(t.name,this.evalExpr(t.expr))},this),this.computedDeps={};for(var a in this.computed)this.computedDeps[a]||this._calcComputed(a);this._callHook("inited")},oe.prototype._calcComputed=function(t){var e=this.computedDeps[t];e||(e=this.computedDeps[t]={}),this.data.set(t,this.computed[t].call({data:{get:r(function(i){return e[i]||(e[i]=1,this.computed[i]&&this._calcComputed(i),this.watch(i,function(){this._calcComputed(t)})),this.data.get(i)},this)}}))},oe.prototype._inited=function(){this._initPropHandlers(),this._isInitFromEl&&(this._callHook("created"),this._callHook("attached"))},oe.prototype.dispatch=function(t,e){for(var i=this.parentComponent;i;){if("function"==typeof i.messages[t]){i.messages[t].call(i,{target:this,value:e});break}i=i.parentComponent}},oe.prototype.ref=function(t){function e(r){n(r.childs,function(n){if(n instanceof oe){var r=n.aNode.directives.get("ref");r&&$(r.value,n.scope||s.data,s)===t&&(i=n)}else n instanceof J&&e(n);return!i})}var i,s=this;return e(this),n(this.slotChilds,function(t){return e(t),!i}),i},oe.prototype._initFromEl=function(){this._isInitFromEl=!0,this.aNode=ce(this.el),this.aNode.binds=this.aNode.props,this.aNode.props=new d,this.parent&&this.parent._pushChildANode(this.aNode),ae(this)},le.prototype.goNext=function(){this.current=this.raw[++this.index],this.next=this.raw[this.index+1]},oe.prototype._compile=function(){var t=this.constructor.prototype;if(!t._isComponentsReady){t.components=t.components||{};var e=t.components;for(var i in e){var n=e[i];"object"==typeof n?e[i]=me(n):"self"===n&&(e[i]=this.constructor)}t._isComponentsReady=!0}if(!t.aNode&&(t.aNode=new g,t.template)){var s=y(t.template),r=s.childs[0];if(1!==s.childs.length||r.isText)throw new Error("[SAN FATEL] template must have a root element.");t.aNode=r,"template"===r.tagName&&(r.tagName=null),r.events.each(function(t){t.isOwn=1}),t.template=null}},oe.prototype._initSelfChanger=function(){this.dataChanger||(this.dataChanger=r(this._dataChanger,this),this.data.onChange(this.dataChanger))},oe.prototype.updateView=function(){if(!this.lifeCycle.is("disposed")&&this.dataChanges.length){var t=this.dataChanges;this.dataChanges=[],this.props.each(function(e){n(t,function(t){return V(t.expr,e.expr,this.data)?(this.setProp(e.name,$(e.expr,this.data,this)),!1):void 0},this)},this),n(this.childs,function(e){e.updateView(t)}),n(this.slotChilds,function(e){e.slotUpdateView(t)}),this._callHook("updated")}},oe.prototype._dataChanger=function(t){var e=this.dataChanges.length;for(e||u(this.updateView,this);e--;)switch(V(t.expr,this.dataChanges[e].expr)){case 1:case 2:t.type===Re.SET&&this.dataChanges.splice(e,1)}this.dataChanges.push(t),J.prototype.updateData.call(this,t),n(this.slotChilds,function(e){e.updateData(t)}),this.binds.each(function(e){var i=t.expr;if(e.x&&!se(t,this.owner)&&V(i,E(e.name),this.data)){var n=e.expr;i.paths.length>1&&(n={type:Te.ACCESSOR,paths:e.expr.paths.concat(i.paths.slice(1))}),this.scope.set(n,$(i,this.data,this),{target:{id:this.id,prop:e.name}})}},this)},oe.prototype.updateData=function(t){var e=t.expr;this.binds.each(function(i){var n,s=i.name,r=i.expr;!se(t,this,s)&&(n=V(e,r,this.scope))&&(n>2&&(s={type:Te.ACCESSOR,paths:[{type:Te.STRING,value:s}].concat(e.paths.slice(r.paths.length))},r=e),this.data.set(s,this.evalExpr(r),{target:{id:this.owner.id}}))},this)},oe.prototype.watch=function(t,e){var i=E(t);this.data.onChange(r(function(t){V(t.expr,i,this.data)&&e.call(this,$(i,this.data,this),t)},this))},oe.prototype._dispose=function(){this.slotChilds=null,this.data.unChange(),this.dataChanger=null,this.dataChanges.length=0,this.data=null,J.prototype._dispose.call(this)},i(de,J),de.prototype._initFromEl=function(t){if(t.el){if("if"===t.el.getAttribute("san-stump")){var e=y(t.el.innerHTML);e=e.childs[0],this.aNode=e}else{this.el=null,this._create(),t.el.parentNode.insertBefore(this.el,t.el.nextSibling),t.el.removeAttribute("san-if");var i=he(t.el,this,t.elWalker);this.childs.push(i),this.aNode.childs=i.aNode.childs.slice(0)}t.ifDirective&&this.aNode.directives.push(t.ifDirective),this.parent._pushChildANode(this.aNode)}},de.prototype._create=function(){this.el||(this.el=document.createElement("script"),this.el.type="text/san",this.el.id=this.id)},de.prototype._inited=function(){this.el&&(this._callHook("created"),this.el.parentNode&&this._callHook("attached"))},de.prototype._created=W.prototype._created,de.prototype.genHTML=function(){var t=new l;if(this.evalExpr(this.aNode.directives.get("if").value)){var e=fe(this);this.childs[0]=e,t.push(e.genHTML())}return Se&&!t.length&&t.push(""),t.push(X(this)),t.toString()},de.prototype.updateView=function(t){var e=this.aNode.directives.get("if").value,i=this.childs[0];this.evalExpr(e)?i?i.updateView(t):(i=fe(this),i.attach(this.el.parentNode,this.el),this.childs[0]=i):this._disposeChilds()},de.prototype._pushChildANode=function(){},i(ge,J),ge.prototype._pushChildANode=function(){},ge.prototype._created=W.prototype._created,ge.prototype.genHTML=function(t){var e=new l;return n(this.evalExpr(this.aNode.directives.get("for").list),function(t,i){var n=ye(this,t,i);this.childs.push(n),e.push(n.genHTML())},this),t||(Se&&!e.length&&e.push(""),e.push(X(this))),e.toString()},ge.prototype._initFromEl=function(t){if(t.el){for(;;){var e=t.elWalker.current;if("for"===e.getAttribute("san-stump")){var i=y(e.innerHTML);i=i.childs[0],this.aNode=i;break}e.removeAttribute("san-for");var n=he(e,this,t.elWalker);this.childs.push(n);var s=t.elWalker.next;if(!s||!s.getAttribute("san-for")&&"for"!==s.getAttribute("san-stump"))break;t.elWalker.goNext()}this.parent._pushChildANode(this.aNode)}},ge.prototype._inited=function(){this.el&&(this._callHook("created"),this.el.parentNode&&this._callHook("attached"))},ge.prototype._attach=function(t,e){this.create(),t&&(e?t.insertBefore(this.el,e):t.appendChild(this.el)),this.el.insertAdjacentHTML("beforebegin",this.genHTML(1))},ge.prototype._detach=function(){this._disposeChilds(),p(this.el)},ge.prototype._create=function(){this.el||(this.el=document.createElement("script"),this.el.type="text/san",this.el.id=this.id)},ge.prototype.updateData=function(t){if(this.childsChanges||(this.childsChanges=[],n(this.childs,function(){this.childsChanges.push([])},this)),!this.repaintAll){var i=this.aNode.directives.get("for"),s=V(t.expr,i.list,this.scope);
if(s){if(s>2){var r=t.expr.paths,o=i.list.paths.length;t=e({},t),t.expr={type:Te.ACCESSOR,paths:[{value:i.item,type:Te.STRING}].concat(r.slice(o+1))};var a=+this.evalExpr(r[o]);F.prototype.set.call(this.childs[a].scope,t.expr,t.value,{silence:!0}),this.childs[a].updateData(t),this.childsChanges[a].push(t)}else if(t.type===Re.SET)n(this.childs,function(t){t.disposeSoon()}),this.childs.length=0,this.repaintAll=1;else if(2===s&&t.type===Re.SPLICE){var p=t.index,h=t.deleteCount,c={type:Re.SET,option:t.option,expr:{type:Te.ACCESSOR,paths:t.expr.paths.concat({type:Te.STRING,value:"length"})}},u={type:Re.SET,option:t.option,expr:{type:Te.ACCESSOR,paths:[{type:Te.STRING,value:i.index}]}},l=t.insertions.length;n(this.childs,function(t,e){t.updateData(c),this.childsChanges[e].push(c),e>=p+h&&(t.updateData(u),this.childsChanges[e].push(u),F.prototype.set.call(t.scope,u.expr,e-h+l,{silence:!0}))},this);var d=[p,h],f=[p,h];n(t.insertions,function(t,e){d.push(ye(this,t,p+e)),f.push([])},this),n(this.childs.splice.apply(this.childs,d),function(t){t.disposeSoon()}),this.childsChanges.splice.apply(this.childsChanges,f)}}else n(this.childsChanges,function(e){e.push(t)}),J.prototype.updateData.call(this,t)}},ge.prototype.updateView=function(){if(this.childsChanges)if(this.repaintAll)this.repaintAll=0,this.el.insertAdjacentHTML("beforebegin",this.genHTML(1)),this._noticeAttached();else for(var t=this.childs.length,e=this;t--;){var i=this.childs[t];i.lifeCycle.is("attached")?i.updateView(this.childsChanges[t]):i.attach(e.el.parentNode,e.el),e=i}this.childsChanges=null},Se&&(de.prototype.attached=q.prototype.attached=ge.prototype.attached=function(){if(this.el){var t=this.el.previousSibling;if(t&&3===t.nodeType){var e="string"==typeof t.textContent?"textContent":"data",i=t[e];i&&""!==i||p(t)}}});var Pe={version:"3.0.3-rc.14",Component:oe,defineComponent:me,parseTemplate:y,parseExpr:E,ExprType:Te,LifeCycle:z,nextTick:u,inherits:i};"object"==typeof exports&&"object"==typeof module?exports=module.exports=Pe:"function"==typeof define&&define.amd?define("san",[],Pe):t.san=Pe}(this);