forked from imba/imba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimba.js
250 lines (250 loc) · 58.3 KB
/
imba.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.imba=e():t.Imba=e()}(this,function(){return function(t){var e={}
function n(r){if(e[r])return e[r].exports
var i=e[r]={i:r,l:!1,exports:{}}
return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t}
return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){var n={VERSION:"1.4.0",setTimeout:function(t,e){return setTimeout(function(){return e(),n.commit()},t)},setInterval:function(t,e){return setInterval(e,t)},clearInterval:function(t){return clearInterval(t)},clearTimeout:function(t){return clearTimeout(t)},subclass:function(t,e){for(var n in e){var r
r=e[n],e.hasOwnProperty(n)&&(t[n]=r)}return t.prototype=Object.create(e.prototype),t.__super__=t.prototype.__super__=e.prototype,t.prototype.initialize=t.prototype.constructor=t,t},iterable:function(t){return t?t.toArray?t.toArray():t:[]},await:function(t){return t instanceof Array?(console.warn("await (Array) is deprecated - use await Promise.all(Array)"),Promise.all(t)):t&&t.then?t:Promise.resolve(t)}},r=/-./g,i={}
n.toCamelCase=function(t){return t.indexOf("-")>=0?t.replace(r,function(t){return t.charAt(1).toUpperCase()}):t},n.toSetter=function(t){return i[t]||(i[t]=n.toCamelCase("set-"+t))},n.indexOf=function(t,e){return e&&e.indexOf?e.indexOf(t):[].indexOf.call(t,e)},n.len=function(t){return t&&(t.len instanceof Function?t.len.call(t):t.length)||0},n.prop=function(t,e,n){if(t.defineProperty)return t.defineProperty(e,n)},n.attr=function(t,e,r){if(void 0===r&&(r={}),t.defineAttribute)return t.defineAttribute(e,r)
var i=n.toCamelCase(e),o=n.toCamelCase("set-"+e),s=t.prototype
r.dom?(s[i]=function(){return this.dom()[e]},s[o]=function(t){return t!=this[e]()&&(this.dom()[e]=t),this}):(s[i]=function(){return this.getAttribute(e)},s[o]=function(t){return this.setAttribute(e,t),this})},n.propDidSet=function(t,e,n,r){var i=e.watch
i instanceof Function?i.call(t,n,r,e):("string"==typeof i||i instanceof String)&&t[i]&&t[i](n,r,e)}
var o=function(t,e,n){for(var r,i;(r=n)&&(n=n.next);)(i=n.listener)&&(n.path&&i[n.path]?e?i[n.path].apply(i,e):i[n.path]():e?i.apply(n,e):i.call(n)),n.times&&--n.times<=0&&(r.next=n.next,n.listener=null)}
n.listen=function(t,e,n,r){var i,o,s
return(s=(o=(i=t.__listeners__||(t.__listeners__={}))[e]||(i[e]={})).tail||(o.tail=o.next={})).listener=n,s.path=r,o.tail=s.next={},s},n.once=function(t,e,r){var i=n.listen(t,e,r)
return i.times=1,i},n.unlisten=function(t,e,n,r){var i,o,s=t.__listeners__
if(s&&(i=s[e]))for(;(o=i)&&(i=i.next);)if(i==n||i.listener==n){o.next=i.next,i.listener=null
break}},n.emit=function(t,e,n){var r;(r=t.__listeners__)&&(r[e]&&o(0,n,r[e]),r.all&&o(0,[e,n],r.all))},n.observeProperty=function(t,e,r,i,o){return o&&"object"==typeof o&&n.unlisten(o,"all",t,r),i&&"object"==typeof i&&n.listen(i,"all",t,r),this},t.exports=n},function(t,e,n){var r=n(0)
r.Pointer=function(){return this._button=-1,this._event={x:0,y:0,type:"uninitialized"},this},r.Pointer.prototype.button=function(){return this._button},r.Pointer.prototype.touch=function(){return this._touch},r.Pointer.prototype.update=function(t){return this._event=t,this._dirty=!0,this},r.Pointer.prototype.process=function(){var t=this._event
if(this._dirty)if(this._prevEvent=t,this._dirty=!1,"mousedown"==t.type){if(this._button=t.button,this._touch&&0!=this._button)return
this._touch&&this._touch.cancel(),this._touch=new r.Touch(t,this),this._touch.mousedown(t,t)}else"mousemove"==t.type?this._touch&&this._touch.mousemove(t,t):"mouseup"==t.type&&(this._button=-1,this._touch&&this._touch.button()==t.button&&(this._touch.mouseup(t,t),this._touch=null))
else this._touch&&this._touch.idle()
return this},r.Pointer.prototype.x=function(){return this._event.x},r.Pointer.prototype.y=function(){return this._event.y}},function(t,e,n){var r=n(0),i=!1,o="undefined"!=typeof window?window:"undefined"!=typeof global?global:null
o&&o.Imba?(console.warn("Imba v"+o.Imba.VERSION+" is already loaded."),r=o.Imba):o&&(o.Imba=r,i=!0,o.define&&o.define.amd&&o.define("imba",[],function(){return r})),t.exports=r,n(3),n(4),i&&r.EventManager.activate()},function(t,e,n){var r,i,o=n(0)
function s(){var t=this
t._queue=[],t._stage=-1,t._scheduled=!1,t._ticker=function(e){return t._scheduled=!1,t.tick(e)}}i=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitRequestAnimationFrame,(r=window.requestAnimationFrame)||(r=window.webkitRequestAnimationFrame),r||(r=window.mozRequestAnimationFrame),r||(r=function(t){return setTimeout(t,1e3/60)}),s.prototype.stage=function(t){return this._stage},s.prototype.setStage=function(t){return this._stage=t,this},s.prototype.queue=function(t){return this._queue},s.prototype.setQueue=function(t){return this._queue=t,this},s.prototype.add=function(t,e){if((e||-1==this._queue.indexOf(t))&&this._queue.push(t),!this._scheduled)return this.schedule()},s.prototype.tick=function(t){var e,n=this._queue
if(this._ts||(this._ts=t),this._dt=t-this._ts,this._ts=t,this._queue=[],this._stage=1,this.before(),n.length)for(var r,i=0,o=(e=n)?e.toArray?e.toArray():e:[],s=o.length;i<s;i++)(r=o[i])instanceof Function?r(this._dt,this):r.tick&&r.tick(this._dt,this)
return this._stage=2,this.after(),this._stage=this._scheduled?0:-1,this},s.prototype.schedule=function(){return this._scheduled||(this._scheduled=!0,-1==this._stage&&(this._stage=0),r(this._ticker)),this},s.prototype.before=function(){return this},s.prototype.after=function(){return o.TagManager&&o.TagManager.refresh(),this},o.TICKER=new s,o.SCHEDULERS=[],o.ticker=function(){return o.TICKER},o.requestAnimationFrame=function(t){return r(t)},o.cancelAnimationFrame=function(t){return i(t)}
var u=0
o.commit=function(t){u++,o.emit(o,"commit",void 0!=t?[t]:void 0),0==--u&&o.TagManager&&o.TagManager.refresh()},o.Scheduler=function(t){var e=this
e._id=a++,e._target=t,e._marked=!1,e._active=!1,e._marker=function(){return e.mark()},e._ticker=function(t){return e.tick(t)},e._dt=0,e._frame={},e._scheduled=!1,e._timestamp=0,e._ticks=0,e._flushes=0,e.onevent=e.onevent.bind(e)}
var a=0
o.Scheduler.event=function(t){return o.emit(o,"event",t)},o.Scheduler.prototype.__raf={watch:"rafDidSet",name:"raf"},o.Scheduler.prototype.raf=function(t){return this._raf},o.Scheduler.prototype.setRaf=function(t){var e=this.raf()
return t!=e&&(this._raf=t),t!=e&&this.rafDidSet&&this.rafDidSet(t,e,this.__raf),this},o.Scheduler.prototype.__interval={watch:"intervalDidSet",name:"interval"},o.Scheduler.prototype.interval=function(t){return this._interval},o.Scheduler.prototype.setInterval=function(t){var e=this.interval()
return t!=e&&(this._interval=t),t!=e&&this.intervalDidSet&&this.intervalDidSet(t,e,this.__interval),this},o.Scheduler.prototype.__events={watch:"eventsDidSet",name:"events"},o.Scheduler.prototype.events=function(t){return this._events},o.Scheduler.prototype.setEvents=function(t){var e=this.events()
return t!=e&&(this._events=t),t!=e&&this.eventsDidSet&&this.eventsDidSet(t,e,this.__events),this},o.Scheduler.prototype.marked=function(t){return this._marked},o.Scheduler.prototype.setMarked=function(t){return this._marked=t,this},o.Scheduler.prototype.rafDidSet=function(t){return t&&this._active&&this.requestTick(),this},o.Scheduler.prototype.intervalDidSet=function(t){return clearInterval(this._intervalId),this._intervalId=null,t&&this._active&&(this._intervalId=setInterval(this.oninterval.bind(this),t)),this},o.Scheduler.prototype.eventsDidSet=function(t,e){return this._active&&t&&!e?o.listen(o,"commit",this,"onevent"):!t&&e?o.unlisten(o,"commit",this,"onevent"):void 0},o.Scheduler.prototype.active=function(){return this._active},o.Scheduler.prototype.dt=function(){return this._dt},o.Scheduler.prototype.configure=function(t){return void 0===t&&(t={}),void 0!=t.raf&&this.setRaf(t.raf),void 0!=t.interval&&this.setInterval(t.interval),void 0!=t.events&&this.setEvents(t.events),this},o.Scheduler.prototype.mark=function(){return this._marked=!0,this._scheduled||this.requestTick(),this},o.Scheduler.prototype.flush=function(){return this._flushes++,this._target.tick(this),this._marked=!1,this},o.Scheduler.prototype.tick=function(t,e){return this._ticks++,this._dt=t,e&&(this._scheduled=!1),this.flush(),this._raf&&this._active&&this.requestTick(),this},o.Scheduler.prototype.requestTick=function(){return this._scheduled||(this._scheduled=!0,o.TICKER.add(this)),this},o.Scheduler.prototype.activate=function(t){return void 0===t&&(t=!0),this._active||(this._active=!0,this._commit=this._target.commit,this._target.commit=function(){return this},this._target&&this._target.flag&&this._target.flag("scheduled_"),o.SCHEDULERS.push(this),this._events&&o.listen(o,"commit",this,"onevent"),this._interval&&!this._intervalId&&(this._intervalId=setInterval(this.oninterval.bind(this),this._interval)),t?this.tick(0):this._raf&&this.requestTick()),this},o.Scheduler.prototype.deactivate=function(){if(this._active){this._active=!1,this._target.commit=this._commit
var t=o.SCHEDULERS.indexOf(this)
t>=0&&o.SCHEDULERS.splice(t,1),this._events&&o.unlisten(o,"commit",this,"onevent"),this._intervalId&&(clearInterval(this._intervalId),this._intervalId=null),this._target&&this._target.unflag&&this._target.unflag("scheduled_")}return this},o.Scheduler.prototype.track=function(){return this._marker},o.Scheduler.prototype.oninterval=function(){return this.tick(),o.TagManager.refresh(),this},o.Scheduler.prototype.onevent=function(t){return!this._events||this._marked?this:(this._events instanceof Function?this._events(t,this)&&this.mark():this._events instanceof Array?this._events.indexOf(t&&t.type||t)>=0&&this.mark():this.mark(),this)}},function(t,e,n){var r=n(0)
n(5),n(6),r.TagManager=new r.TagManagerClass,n(7),n(8),n(1),n(9),n(10),n(11)},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i=n(0)
i.TagManagerClass=function(){this._inserts=0,this._removes=0,this._mounted=[],this._mountables=0,this._unmountables=0,this._unmounting=0},i.TagManagerClass.prototype.mounted=function(){return this._mounted},i.TagManagerClass.prototype.insert=function(t,e){this._inserts++,t&&t.mount&&this.regMountable(t)},i.TagManagerClass.prototype.remove=function(t,e){return this._removes++},i.TagManagerClass.prototype.changes=function(){return this._inserts+this._removes},i.TagManagerClass.prototype.mount=function(t){},i.TagManagerClass.prototype.refresh=function(t){if(void 0===t&&(t=!1),t||0!=this.changes())return(this._inserts&&this._mountables>this._mounted.length||t)&&this.tryMount(),(this._removes||t)&&this._mounted.length&&this.tryUnmount(),this._inserts=0,this._removes=0,this},i.TagManagerClass.prototype.unmount=function(t){return this},i.TagManagerClass.prototype.regMountable=function(t){if(!(t.FLAGS&i.TAG_MOUNTABLE))return t.FLAGS|=i.TAG_MOUNTABLE,this._mountables++},i.TagManagerClass.prototype.tryMount=function(){for(var t,e=0,n=r(document.body.querySelectorAll(".__mount")),i=n.length;e<i;e++)(t=n[e])&&t._tag&&-1==this._mounted.indexOf(t._tag)&&this.mountNode(t._tag)
return this},i.TagManagerClass.prototype.mountNode=function(t){-1==this._mounted.indexOf(t)&&(this.regMountable(t),this._mounted.push(t),t.FLAGS|=i.TAG_MOUNTED,t.mount&&t.mount())},i.TagManagerClass.prototype.tryUnmount=function(){this._unmounting++
for(var t,e=[],n=(document.body,0),o=r(this._mounted),s=o.length;n<s;n++)(t=o[n])&&(document.documentElement.contains(t._dom)||(e.push(t),this._mounted[n]=null))
if(this._unmounting--,e.length){this._mounted=this._mounted.filter(function(t){return t&&-1==e.indexOf(t)})
for(var u,a=0,h=e.length;a<h;a++)(u=e[a]).FLAGS=u.FLAGS&~i.TAG_MOUNTED,u.unmount&&u._dom?u.unmount():u._scheduler&&u.unschedule()}return this}},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i=n(0)
n(1)
var o=["keydown","keyup","keypress","textInput","input","change","submit","focusin","focusout","focus","blur","contextmenu","selectstart","dblclick","selectionchange","mousewheel","wheel","scroll","beforecopy","copy","beforepaste","paste","beforecut","cut","dragstart","drag","dragend","dragenter","dragover","dragleave","dragexit","drop","mouseup","mousedown","mouseenter","mouseleave","mouseout","mouseover","mousemove"]
i.EventManager=function(t,e){var n=this
e&&e.constructor===Object||(e={})
var i=void 0!==e.events?e.events:[]
n._shimFocusEvents=window.netscape&&void 0===t.onfocusin,n.setRoot(t),n.setListeners([]),n.setDelegators({}),n.setDelegator(function(t){return n.delegate(t),!0})
for(var o=0,s=r(i),u=s.length;o<u;o++)n.register(s[o])
return n},i.EventManager.prototype.root=function(t){return this._root},i.EventManager.prototype.setRoot=function(t){return this._root=t,this},i.EventManager.prototype.count=function(t){return this._count},i.EventManager.prototype.setCount=function(t){return this._count=t,this},i.EventManager.prototype.__enabled={default:!1,watch:"enabledDidSet",name:"enabled"},i.EventManager.prototype.enabled=function(t){return this._enabled},i.EventManager.prototype.setEnabled=function(t){var e=this.enabled()
return t!=e&&(this._enabled=t),t!=e&&this.enabledDidSet&&this.enabledDidSet(t,e,this.__enabled),this},i.EventManager.prototype._enabled=!1,i.EventManager.prototype.listeners=function(t){return this._listeners},i.EventManager.prototype.setListeners=function(t){return this._listeners=t,this},i.EventManager.prototype.delegators=function(t){return this._delegators},i.EventManager.prototype.setDelegators=function(t){return this._delegators=t,this},i.EventManager.prototype.delegator=function(t){return this._delegator},i.EventManager.prototype.setDelegator=function(t){return this._delegator=t,this}
var s=[]
i.EventManager.prototype.enabledDidSet=function(t){return t?this.onenable():this.ondisable(),this},i.EventManager.bind=function(t){return i.Events?i.Events.autoregister(t):-1==s.indexOf(t)&&o.indexOf(t)>=0?s.push(t):void 0},i.EventManager.activate=function(){return i.Events?i.Events:(i.Events=new i.EventManager(i.document(),{events:[]}),i.POINTER||(i.POINTER=new i.Pointer),window&&void 0!==window.ontouchstart&&(i.Events.listen("touchstart",function(t){return i.Touch.ontouchstart(t)}),i.Events.listen("touchmove",function(t){return i.Touch.ontouchmove(t)}),i.Events.listen("touchend",function(t){return i.Touch.ontouchend(t)}),i.Events.listen("touchcancel",function(t){return i.Touch.ontouchcancel(t)})),i.Events.register("click",function(t){if(t.timeStamp-i.Touch.LastTimestamp>i.Touch.TapTimeout){t._imbaSimulatedTap=!0
var e=new i.Event(t)
if(e.setType("tap"),e.process(),e._responder&&e.defaultPrevented)return t.preventDefault()}return i.Events.delegate(t)}),i.Events.listen("mousedown",function(t){if(t.timeStamp-i.Touch.LastTimestamp>i.Touch.TapTimeout&&i.POINTER)return i.POINTER.update(t).process()}),i.Events.listen("mouseup",function(t){if(t.timeStamp-i.Touch.LastTimestamp>i.Touch.TapTimeout&&i.POINTER)return i.POINTER.update(t).process()}),i.Events.register(["mousedown","mouseup"]),i.Events.register(s),i.Events.setEnabled(!0),i.Events)},i.EventManager.prototype.register=function(t,e){if(void 0===e&&(e=!0),t instanceof Array){for(var n=0,i=r(t),o=i.length;n<o;n++)this.register(i[n],e)
return this}if(this.delegators()[t])return this
var s=this.delegators()[t]=e instanceof Function?e:this.delegator()
return this.enabled()?this.root().addEventListener(t,s,!0):void 0},i.EventManager.prototype.autoregister=function(t){return-1==o.indexOf(t)?this:this.register(t)},i.EventManager.prototype.listen=function(t,e,n){return void 0===n&&(n=!0),this.listeners().push([t,e,n]),this.enabled()&&this.root().addEventListener(t,e,n),this},i.EventManager.prototype.delegate=function(t){return i.Event.wrap(t).process(),this._shimFocusEvents&&("focus"==t.type?i.Event.wrap(t).setType("focusin").process():"blur"==t.type&&i.Event.wrap(t).setType("focusout").process()),this},i.EventManager.prototype.create=function(t,e,n){n&&n.constructor===Object||(n={})
var r=void 0!==n.data?n.data:null,o=void 0!==n.source?n.source:null,s=i.Event.wrap({type:t,target:e})
return r&&s.setData(r),o&&s.setSource(o),s},i.EventManager.prototype.trigger=function(){return this.create.apply(this,arguments).process()},i.EventManager.prototype.onenable=function(){for(var t,e,n=this.delegators(),o=0,s=Object.keys(n),u=s.length;o<u;o++)t=n[e=s[o]],this.root().addEventListener(e,t,!0)
for(var a,h=0,c=r(this.listeners()),p=c.length;h<p;h++)a=c[h],this.root().addEventListener(a[0],a[1],a[2])
return window.addEventListener("hashchange",i.commit),window.addEventListener("popstate",i.commit),this},i.EventManager.prototype.ondisable=function(){for(var t,e,n=this.delegators(),o=0,s=Object.keys(n),u=s.length;o<u;o++)t=n[e=s[o]],this.root().removeEventListener(e,t,!0)
for(var a,h=0,c=r(this.listeners()),p=c.length;h<p;h++)a=c[h],this.root().removeEventListener(a[0],a[1],a[2])
return window.removeEventListener("hashchange",i.commit),window.removeEventListener("popstate",i.commit),this}},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i=n(0)
i.CSSKeyMap={},i.TAG_BUILT=1,i.TAG_SETUP=2,i.TAG_MOUNTING=4,i.TAG_MOUNTED=8,i.TAG_SCHEDULED=16,i.TAG_AWAKENED=32,i.TAG_MOUNTABLE=64,i.document=function(){return window.document},i.root=function(){return i.getTagForDom(i.document().body)},i.static=function(t,e,n){return t._type=e,t.static=n,t},i.mount=function(t,e){return e||(e=i.document().body),e.appendChild(t.dom()),i.TagManager.insert(t,e),t.scheduler().configure({events:!0}).activate(!1),i.TagManager.refresh(),t},i.createTextNode=function(t){return t&&3==t.nodeType?t:i.document().createTextNode(t)},i.Tag=function(t,e){this.setDom(t),this.$=o.build(this),this.$up=this._owner_=e,this._tree_=null,this.FLAGS=0,this.build()},i.Tag.buildNode=function(){var t=i.document().createElement(this._nodeType||"div")
if(this._classes){var e=this._classes.join(" ")
e&&(t.className=e)}return t},i.Tag.createNode=function(){return(this._protoDom||(this._protoDom=this.buildNode())).cloneNode(!1)},i.Tag.build=function(t){return new this(this.createNode(),t)},i.Tag.dom=function(){return this._protoDom||(this._protoDom=this.buildNode())},i.Tag.end=function(){return this.commit(0)},i.Tag.inherit=function(t){return t._protoDom=null,this._nodeType?(t._nodeType=this._nodeType,t._classes=this._classes.slice(),t._flagName?t._classes.push(t._flagName):void 0):(t._nodeType=t._name,t._flagName=null,t._classes=[])},i.Tag.prototype.optimizeTagStructure=function(){var t=this.constructor,e=Object.keys(this)
e.indexOf("mount")>=0&&(t._classes&&-1==t._classes.indexOf("__mount")&&t._classes.push("__mount"),t._protoDom&&t._protoDom.classList.add("__mount"))
for(var n,o=0,s=r(e),u=s.length;o<u;o++)n=s[o],/^on/.test(n)&&i.EventManager.bind(n.slice(2))
return this},i.attr(i.Tag,"name"),i.attr(i.Tag,"role"),i.attr(i.Tag,"tabindex"),i.Tag.prototype.title=function(t){return this.getAttribute("title")},i.Tag.prototype.setTitle=function(t){return this.setAttribute("title",t),this},i.Tag.prototype.dom=function(){return this._dom},i.Tag.prototype.setDom=function(t){return t._tag=this,this._dom=this._slot_=t,this},i.Tag.prototype.ref=function(){return this._ref},i.Tag.prototype.root=function(){return this._owner_?this._owner_.root():this},i.Tag.prototype.ref_=function(t){return this.flag(this._ref=t),this},i.Tag.prototype.setData=function(t){return this._data=t,this},i.Tag.prototype.data=function(){return this._data},i.Tag.prototype.bindData=function(t,e,n){return this.setData(n?t[e].apply(t,n):t[e])},i.Tag.prototype.setHtml=function(t){return this.html()!=t&&(this._dom.innerHTML=t),this},i.Tag.prototype.html=function(){return this._dom.innerHTML},i.Tag.prototype.on$=function(t,e,n){var r=this._on_||(this._on_=[]),o=r[t]
return t<0&&(t=void 0==o?r[t]=r.length:o,o=r[t]),r[t]=e,o?e.state=o.state:(e.state={context:n},i.EventManager.bind(e[0])),this},i.Tag.prototype.setId=function(t){return null!=t&&(this.dom().id=t),this},i.Tag.prototype.id=function(){return this.dom().id},i.Tag.prototype.setAttribute=function(t,e){return this.dom().getAttribute(t)==e||(null!=e&&!1!==e?this.dom().setAttribute(t,e):this.dom().removeAttribute(t)),this},i.Tag.prototype.setNestedAttr=function(t,e,n,r){return this[t+"SetAttribute"]?this[t+"SetAttribute"](e,n,r):this.setAttributeNS(t,e,n),this},i.Tag.prototype.setAttributeNS=function(t,e,n){return this.getAttributeNS(t,e)!=n&&(null!=n&&!1!==n?this.dom().setAttributeNS(t,e,n):this.dom().removeAttributeNS(t,e)),this},i.Tag.prototype.removeAttribute=function(t){return this.dom().removeAttribute(t)},i.Tag.prototype.getAttribute=function(t){return this.dom().getAttribute(t)},i.Tag.prototype.getAttributeNS=function(t,e){return this.dom().getAttributeNS(t,e)},i.Tag.prototype.set=function(t,e,n){var r=i.toSetter(t)
return this[r]instanceof Function?this[r](e,n):this._dom.setAttribute(t,e),this},i.Tag.prototype.get=function(t){return this._dom.getAttribute(t)},i.Tag.prototype.setContent=function(t,e){return this.setChildren(t,e),this},i.Tag.prototype.setChildren=function(t,e){return this._tree_=t,this},i.Tag.prototype.setTemplate=function(t){return this._template||this.render==i.Tag.prototype.render&&(this.render=this.renderTemplate),this.template=this._template=t,this},i.Tag.prototype.template=function(){return null},i.Tag.prototype.renderTemplate=function(){var t=this.template()
return t!=this&&this.setChildren(t),this},i.Tag.prototype.removeChild=function(t){var e=this.dom(),n=t._slot_||t
return n&&n.parentNode==e&&(i.TagManager.remove(n._tag||n,this),e.removeChild(n)),this},i.Tag.prototype.removeAllChildren=function(){if(this._dom.firstChild)for(var t;t=this._dom.firstChild;)i.TagManager.remove(t._tag||t,this),this._dom.removeChild(t)
return this._tree_=this._text_=null,this},i.Tag.prototype.appendChild=function(t){return"string"==typeof t||t instanceof String?this.dom().appendChild(i.document().createTextNode(t)):t&&(this.dom().appendChild(t._slot_||t),i.TagManager.insert(t._tag||t,this)),this},i.Tag.prototype.insertBefore=function(t,e){return("string"==typeof t||t instanceof String)&&(t=i.document().createTextNode(t)),t&&e&&(this.dom().insertBefore(t._slot_||t,e._slot_||e),i.TagManager.insert(t._tag||t,this)),this},i.Tag.prototype.detachFromParent=function(){return this._slot_==this._dom&&(this._slot_=this._dom._placeholder_||(this._dom._placeholder_=i.document().createComment("node")),this._slot_._tag||(this._slot_._tag=this),this._dom.parentNode&&(i.TagManager.remove(this,this._dom.parentNode),this._dom.parentNode.replaceChild(this._slot_,this._dom))),this},i.Tag.prototype.attachToParent=function(){if(this._slot_!=this._dom){var t=this._slot_
this._slot_=this._dom,t&&t.parentNode&&(i.TagManager.insert(this),t.parentNode.replaceChild(this._dom,t))}return this},i.Tag.prototype.orphanize=function(){var t
return(t=this.parent())&&t.removeChild(this),this},i.Tag.prototype.text=function(t){return this._dom.textContent},i.Tag.prototype.setText=function(t){return this._tree_=t,this._dom.textContent=null==t||!1===this.text()?"":t,this},i.Tag.prototype.dataset=function(t,e){if(t instanceof Object){for(var n,o,s=0,u=Object.keys(t),a=u.length;s<a;s++)n=t[o=u[s]],this.dataset(o,n)
return this}if(2==arguments.length)return this.setAttribute("data-"+t,e),this
if(t)return this.getAttribute("data-"+t)
var h=this.dom().dataset
if(!h){h={}
for(var c,p=0,l=r(this.dom().attributes),d=l.length;p<d;p++)"data-"==(c=l[p]).name.substr(0,5)&&(h[i.toCamelCase(c.name.slice(5))]=c.value)}return h},i.Tag.prototype.render=function(){return this},i.Tag.prototype.build=function(){return this},i.Tag.prototype.setup=function(){return this},i.Tag.prototype.commit=function(){return!1!==this.beforeRender()&&this.render(),this},i.Tag.prototype.beforeRender=function(){return this},i.Tag.prototype.tick=function(){return!1!==this.beforeRender()&&this.render(),this},i.Tag.prototype.end=function(){return this.setup(),this.commit(0),this.end=i.Tag.end,this},i.Tag.prototype.$open=function(t){return t!=this._context_&&(this._tree_=null,this._context_=t),this},i.Tag.prototype.synced=function(){return this},i.Tag.prototype.awaken=function(){return this},i.Tag.prototype.flags=function(){return this._dom.classList},i.Tag.prototype.flag=function(t,e){return 2==arguments.length?this._dom.classList.contains(t)!=!!e&&this._dom.classList.toggle(t):this._dom.classList.contains(t)||this._dom.classList.add(t),this},i.Tag.prototype.unflag=function(t){return this._dom.classList.remove(t),this},i.Tag.prototype.toggleFlag=function(t){return this._dom.classList.toggle(t),this},i.Tag.prototype.hasFlag=function(t){return this._dom.classList.contains(t)},i.Tag.prototype.flagIf=function(t,e){var n=this._flags_||(this._flags_={}),r=n[t]
return e&&!r?(this._dom.classList.add(t),n[t]=!0):r&&!e&&(this._dom.classList.remove(t),n[t]=!1),this},i.Tag.prototype.setFlag=function(t,e){var n=this._namedFlags_||(this._namedFlags_={}),r=n[t]
return r!=e&&(r&&this.unflag(r),e&&this.flag(e),n[t]=e),this},i.Tag.prototype.scheduler=function(){return null==this._scheduler?this._scheduler=new i.Scheduler(this):this._scheduler},i.Tag.prototype.schedule=function(t){return void 0===t&&(t={events:!0}),this.scheduler().configure(t).activate(),this},i.Tag.prototype.unschedule=function(){return this._scheduler&&this.scheduler().deactivate(),this},i.Tag.prototype.parent=function(){return i.getTagForDom(this.dom().parentNode)},i.Tag.prototype.children=function(t){for(var e,n=[],o=0,s=r(this._dom.children),u=s.length;o<u;o++)e=s[o],n.push(e._tag||i.getTagForDom(e))
return n},i.Tag.prototype.querySelector=function(t){return i.getTagForDom(this._dom.querySelector(t))},i.Tag.prototype.querySelectorAll=function(t){for(var e=[],n=0,o=r(this._dom.querySelectorAll(t)),s=o.length;n<s;n++)e.push(i.getTagForDom(o[n]))
return e},i.Tag.prototype.matches=function(t){var e
return t instanceof Function?t(this):(t.query instanceof Function&&(t=t.query()),(e=this._dom.matches||this._dom.matchesSelector||this._dom.webkitMatchesSelector||this._dom.msMatchesSelector||this._dom.mozMatchesSelector)?e.call(this._dom,t):void 0)},i.Tag.prototype.closest=function(t){return i.getTagForDom(this._dom.closest(t))},i.Tag.prototype.contains=function(t){return this.dom().contains(t._dom||t)},i.Tag.prototype.log=function(){for(var t=arguments,e=t.length,n=new Array(e>0?e:0);e>0;)n[e-1]=t[--e]
return n.unshift(console),Function.prototype.call.apply(console.log,n),this},i.Tag.prototype.css=function(t,e,n){if(t instanceof Object){for(var r,o,s=0,u=Object.keys(t),a=u.length;s<a;s++)r=t[o=u[s]],this.css(o,r)
return this}var h=i.CSSKeyMap[t]||t
if(null==e)this.dom().style.removeProperty(h)
else{if(void 0==e&&1==arguments.length)return this.dom().style[h]
h.match(/^--/)?this.dom().style.setProperty(h,e):("number"==typeof e||e instanceof Number)&&(h.match(/width|height|left|right|top|bottom/)||n&&n.px)?this.dom().style[h]=e+"px":this.dom().style[h]=e}return this},i.Tag.prototype.setStyle=function(t){return this.setAttribute("style",t)},i.Tag.prototype.style=function(){return this.getAttribute("style")},i.Tag.prototype.trigger=function(t,e){return void 0===e&&(e={}),i.Events.trigger(t,this,{data:e})},i.Tag.prototype.focus=function(){return this.dom().focus(),this},i.Tag.prototype.blur=function(){return this.dom().blur(),this},i.Tag.prototype.toString=function(){return this.dom().outerHTML},i.Tag.prototype.initialize=i.Tag,i.SVGTag=function(){return i.Tag.apply(this,arguments)},i.subclass(i.SVGTag,i.Tag),i.SVGTag.namespaceURI=function(){return"http://www.w3.org/2000/svg"},i.SVGTag.buildNode=function(){var t=i.document().createElementNS(this.namespaceURI(),this._nodeType)
if(this._classes){var e=this._classes.join(" ")
e&&(t.className.baseVal=e)}return t},i.SVGTag.inherit=function(t){if(t._protoDom=null,this==i.SVGTag)return t._nodeType=t._name,t._classes=[]
t._nodeType=this._nodeType
var e="_"+t._name.replace(/_/g,"-")
return t._classes=(this._classes||[]).concat(e)},i.HTML_TAGS="a abbr address area article aside audio b base bdi bdo big blockquote body br button canvas caption cite code col colgroup data datalist dd del details dfn div dl dt em embed fieldset figcaption figure footer form h1 h2 h3 h4 h5 h6 head header hr html i iframe img input ins kbd keygen label legend li link main map mark menu menuitem meta meter nav noscript object ol optgroup option output p param pre progress q rp rt ruby s samp script section select small source span strong style sub summary sup table tbody td textarea tfoot th thead time title tr track u ul var video wbr".split(" "),i.HTML_TAGS_UNSAFE="article aside header section".split(" "),i.HTML_ATTRS={a:"href target hreflang media download rel type ping referrerpolicy",audio:"autoplay controls crossorigin loop muted preload src",area:"alt coords download href hreflang ping referrerpolicy rel shape target",base:"href target",video:"autoplay buffered controls crossorigin height loop muted preload poster src width playsinline",fieldset:"disabled form name",form:"method action enctype autocomplete target",button:"autofocus type form formaction formenctype formmethod formnovalidate formtarget value name",embed:"height src type width",input:"accept disabled form list max maxlength min minlength pattern required size step type",label:"accesskey for form",img:"alt src srcset crossorigin decoding height importance intrinsicsize ismap referrerpolicy sizes width usemap",link:"rel type href media",iframe:"allow allowfullscreen allowpaymentrequest height importance name referrerpolicy sandbox src srcdoc width",meta:"property content charset desc",map:"name",optgroup:"label",option:"label",output:"for form",object:"type data width height",param:"name type value valuetype",progress:"max",script:"src type async defer crossorigin integrity nonce language nomodule",select:"size form multiple",source:"sizes src srcset type media",textarea:"rows cols minlength maxlength form wrap",track:"default kind label src srclang",td:"colspan rowspan headers",th:"colspan rowspan"},i.HTML_PROPS={input:"autofocus autocomplete autocapitalize autocorrect value placeholder required disabled multiple checked readOnly spellcheck",textarea:"autofocus autocomplete autocapitalize autocorrect value placeholder required disabled multiple checked readOnly spellcheck",form:"novalidate",fieldset:"disabled",button:"disabled",select:"autofocus disabled required readOnly multiple",option:"disabled selected value",optgroup:"disabled",progress:"value",fieldset:"disabled",canvas:"width height"}
function o(t){this._tag=t}function s(t,e,n){this.cache$=t,this.key$=e,this.par$=n,this.i$=0}i.Tags=function(){},i.Tags.prototype.__clone=function(t){var e=Object.create(this)
return e._parent=this,e},i.Tags.prototype.ns=function(t){return this["_"+t.toUpperCase()]||this.defineNamespace(t)},i.Tags.prototype.defineNamespace=function(t){var e=Object.create(this)
return e._parent=this,e._ns=t,this["_"+t.toUpperCase()]=e,e},i.Tags.prototype.baseType=function(t,e){return i.indexOf(t,i.HTML_TAGS)>=0?"element":"div"},i.Tags.prototype.defineTag=function(t,e,n){var r
void 0==n&&"function"==typeof e&&(n=e,e=""),void 0==e&&(e=""),n&&n._nodeType&&(e=n,n=null),this[t]&&console.log("tag already exists?",t)
var o=t,s=o.indexOf(":")
s>=0&&(r=t.substr(0,s),o=t.substr(s+1),"svg"!=r||e||(e="svg:element")),e||(e=this.baseType(t))
var u="string"==typeof e||e instanceof String?this.findTagType(e):e,a=function(t,e){return this.initialize(t,e),this}
return a._name=o,a._flagName=null,"#"==o[0]?(i.SINGLETONS[o.slice(1)]=a,this[o]=a):o[0]==o[0].toUpperCase()?a._flagName=o:(a._flagName="_"+t.replace(/[_\:]/g,"-"),this[t]=a),function(t,e){for(var n,r,i=0,o=Object.keys(e),s=o.length;i<s;i++)n=e[r=o[i]],null==t[r]?t[r]=n:t[r]
t.prototype=Object.create(e.prototype),t.__super__=t.prototype.__super__=e.prototype,t.prototype.constructor=t,e.inherit&&e.inherit(t)}(a,u),n&&(n.call(a,a,a.TAGS||this),a.defined&&a.defined(),this.optimizeTag(a)),a},i.Tags.prototype.defineSingleton=function(t,e,n){return this.defineTag(t,e,n)},i.Tags.prototype.extendTag=function(t,e,n){void 0==n&&"function"==typeof e&&(n=e,e=""),void 0==e&&(e="")
var r="string"==typeof t||t instanceof String?this.findTagType(t):t
return n&&n&&n.call(r,r,r.prototype),r.extended&&r.extended(),this.optimizeTag(r),r},i.Tags.prototype.optimizeTag=function(t){var e
return(e=t.prototype)&&e.optimizeTagStructure&&e.optimizeTagStructure()},i.Tags.prototype.findTagType=function(t){var e,n,o=this[t]
if(!o)if("svg:"==t.substr(0,4))o=this.defineTag(t,"svg:element")
else if(i.HTML_TAGS.indexOf(t)>=0){if(o=this.defineTag(t,"element"),e=i.HTML_ATTRS[t])for(var s=0,u=r(e.split(" ")),a=u.length;s<a;s++)i.attr(o,u[s])
if(n=i.HTML_PROPS[t])for(var h=0,c=r(n.split(" ")),p=c.length;h<p;h++)i.attr(o,c[h],{dom:!0})}return o},i.createElement=function(t,e,n,r){var o,u=t
u=t instanceof Function?t:i.TAGS.findTagType(t),o=e instanceof s?e.par$:r instanceof i.Tag?r:e&&void 0!=r?e[r]:e&&e._tag||e
var a=u.build(o)
return e instanceof s&&(e.i$++,a.$key=n),e&&void 0!=n&&(e[n]=a),a},i.createTagCache=function(t){var e=[]
return e._tag=t,e},i.createTagMap=function(t,e,n){var r=new s(t,e,void 0!=n?n:t._tag)
return t[e]=r,r},i.createTagList=function(t,e,n){var r=[]
return r._type=4,r._tag=void 0!=n?n:t._tag,t[e]=r,r},i.createTagLoopResult=function(t,e,n){var r=[]
return r._type=5,r.cache={i$:0},r},o.build=function(t){var e=[]
return e._tag=t,e},s.prototype.$iter=function(){var t=[]
return t._type=5,t.cache=this,t},s.prototype.$prune=function(t){for(var e,n=this.cache$,i=this.key$,o=new s(n,i,this.par$),u=0,a=r(t),h=a.length;u<h;u++)o[(e=a[u]).key$]=e
return o.i$=t.length,n[i]=o},i.TagMap=s,i.TagCache=o,i.SINGLETONS={},i.TAGS=new i.Tags,i.TAGS.element=i.TAGS.htmlelement=i.Tag,i.TAGS["svg:element"]=i.SVGTag,i.defineTag=function(t,e,n){return void 0==n&&"function"==typeof e&&(n=e,e=""),void 0==e&&(e=""),i.TAGS.defineTag(t,e,n)},i.defineSingletonTag=function(t,e,n){return void 0==n&&"function"==typeof e&&(n=e,e="div"),void 0==e&&(e="div"),i.TAGS.defineTag(this.name(),e,n)},i.extendTag=function(t,e){return i.TAGS.extendTag(t,e)},i.getTagSingleton=function(t){var e,n,r
return(e=i.SINGLETONS[t])?e&&e.Instance?e.Instance:(n=i.document().getElementById(t))?((r=e.Instance=new e(n)).awaken(n),r):((n=e.createNode()).id=t,(r=e.Instance=new e(n)).end().awaken(n),r):(n=i.document().getElementById(t))?i.getTagForDom(n):void 0}
var u="undefined"!=typeof SVGElement
if(i.getTagForDom=function(t){if(!t)return null
if(t._dom)return t
if(t._tag)return t._tag
if(!t.nodeName)return null
var e=t.nodeName.toLowerCase(),n=i.TAGS
return t.id&&i.SINGLETONS[t.id]?i.getTagSingleton(t.id):new(u&&t instanceof SVGElement?n.findTagType("svg:"+e):i.HTML_TAGS.indexOf(e)>=0?n.findTagType(e):i.Tag)(t,null).awaken(t)},document){for(var a,h=window.getComputedStyle(document.documentElement,""),c=0,p=r(h),l=p.length;c<l;c++){var d=(a=p[c]).replace(/^-(webkit|ms|moz|o|blink)-/,""),f=d.replace(/-(\w)/g,function(t,e){return e.toUpperCase()})
a!=d&&h.hasOwnProperty(d)||(i.CSSKeyMap[d]=i.CSSKeyMap[f]=a)}document.documentElement.classList||i.extendTag("element",function(t){t.prototype.hasFlag=function(t){return new RegExp("(^|\\s)"+t+"(\\s|$)").test(this._dom.className)},t.prototype.addFlag=function(t){return this.hasFlag(t)?this:(this._dom.className+=(this._dom.className?" ":"")+t,this)},t.prototype.unflag=function(t){if(!this.hasFlag(t))return this
var e=new RegExp("(^|\\s)*"+t+"(\\s|$)*","g")
return this._dom.className=this._dom.className.replace(e,""),this},t.prototype.toggleFlag=function(t){return this.hasFlag(t)?this.unflag(t):this.flag(t)},t.prototype.flag=function(t,e){return 2==arguments.length&&!1==!!e?this.unflag(t):this.addFlag(t)}})}i.Tag},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i=n(0)
function o(t,e,n){this._node=t,this._path=e,this._args=n,this._args&&(this._setter=i.toSetter(this._path))}i.defineTag("fragment","element",function(t){t.createNode=function(){return i.document().createDocumentFragment()}}),i.extendTag("html",function(t){t.prototype.parent=function(){return null}}),i.extendTag("canvas",function(t){t.prototype.context=function(t){return void 0===t&&(t="2d"),this.dom().getContext(t)}}),o.bind=function(t,e,n,r){return(t._data||(t._data=new this(t,n,r))).bind(e,n,r),t},o.prototype.bind=function(t,e,n){return t!=this._data&&(this._data=t),this},o.prototype.getFormValue=function(){return this._setter?this._data[this._path]():this._data[this._path]},o.prototype.setFormValue=function(t){return this._setter?this._data[this._setter](t):this._data[this._path]=t}
var s=function(t){return t&&t.splice&&t.sort}
i.extendTag("input",function(t){t.prototype.lazy=function(t){return this._lazy},t.prototype.setLazy=function(t){return this._lazy=t,this},t.prototype.number=function(t){return this._number},t.prototype.setNumber=function(t){return this._number=t,this},t.prototype.bindData=function(t,e,n){return o.bind(this,t,e,n),this},t.prototype.checked=function(){return this._dom.checked},t.prototype.setChecked=function(t){return!!t!=this._dom.checked&&(this._dom.checked=!!t),this},t.prototype.setValue=function(t,e){return void 0!=this._localValue&&void 0!=e||(this.dom().value=this._value=t,this._localValue=void 0),this},t.prototype.setType=function(t){return this.dom().type=this._type=t,this},t.prototype.value=function(){var t=this._dom.value
return this._number&&t?parseFloat(t):t},t.prototype.oninput=function(t){var e=this._dom.value
this._localValue=e,this._data&&!this.lazy()&&"radio"!=this.type()&&"checkbox"!=this.type()&&this._data.setFormValue(this.value(),this)},t.prototype.onchange=function(t){if(this._modelValue=this._localValue=void 0,this.data()){if("radio"!=this.type()&&"checkbox"!=this.type())return this._data.setFormValue(this.value())
var e=this.checked(),n=this._data.getFormValue(this),r=void 0!=this._value?this._value:this.value()
if("radio"==this.type())return this._data.setFormValue(r,this)
if("on"==this.dom().value||void 0==this.dom().value)return this._data.setFormValue(!!e,this)
if(!s(n))return this._data.setFormValue(r,this)
var i=n.indexOf(r)
return e&&-1==i?n.push(r):!e&&i>=0?n.splice(i,1):void 0}},t.prototype.onblur=function(t){return this._localValue=void 0},t.prototype.end=function(){if(void 0!==this._localValue||!this._data)return this
var t=this._data.getFormValue(this)
if(t==this._modelValue)return this
if(s(t)||(this._modelValue=t),"radio"==this.type()||"checkbox"==this.type()){var e=this._value,n=s(t)?t.indexOf(e)>=0:"on"==this.dom().value||void 0==this.dom().value?!!t:t==this._value
this.setChecked(n)}else this._dom.value=t
return this}}),i.extendTag("textarea",function(t){t.prototype.lazy=function(t){return this._lazy},t.prototype.setLazy=function(t){return this._lazy=t,this},t.prototype.bindData=function(t,e,n){return o.bind(this,t,e,n),this},t.prototype.setValue=function(t,e){return void 0!=this._localValue&&void 0!=e||(this.dom().value=t,this._localValue=void 0),this},t.prototype.oninput=function(t){var e=this._dom.value
if(this._localValue=e,this._data&&!this.lazy())return this._data.setFormValue(this.value(),this)},t.prototype.onchange=function(t){if(this._localValue=void 0,this._data)return this._data.setFormValue(this.value(),this)},t.prototype.onblur=function(t){return this._localValue=void 0},t.prototype.render=function(){if(void 0==this._localValue&&this._data){if(this._data){var t=this._data.getFormValue(this)
this._dom.value=void 0!=t?t:""}return this}}}),i.extendTag("option",function(t){t.prototype.setValue=function(t){return t!=this._value&&(this.dom().value=this._value=t),this},t.prototype.value=function(){return this._value||this.dom().value}}),i.extendTag("select",function(t){t.prototype.bindData=function(t,e,n){return o.bind(this,t,e,n),this},t.prototype.setValue=function(t,e){this._value
return this._value=t,e||this.syncValue(t),this},t.prototype.syncValue=function(t){var e=this._syncValue
if(this.multiple()&&t instanceof Array){if(e instanceof Array&&function(t,e){var n=t.length,r=0
if(n!=e.length)return!1
for(;r++<n;)if(t[r]!=e[r])return!1
return!0}(e,t))return this
t=t.slice()}if(this._syncValue=t,"object"==typeof t)for(var n,i=this.multiple()&&t instanceof Array,o=0,s=r(this.dom().options),u=s.length;o<u;o++){var a=(n=s[o])._tag?n._tag.value():n.value
if(i)n.selected=t.indexOf(a)>=0
else if(t==a){this.dom().selectedIndex=o
break}}else this.dom().value=t
return this},t.prototype.value=function(){if(this.multiple()){for(var t,e=[],n=0,i=r(this.dom().selectedOptions),o=i.length;n<o;n++)t=i[n],e.push(t._tag?t._tag.value():t.value)
return e}var s=this.dom().selectedOptions[0]
return s?s._tag?s._tag.value():s.value:null},t.prototype.onchange=function(t){if(this._data)return this._data.setFormValue(this.value(),this)},t.prototype.end=function(){return this._data&&this.setValue(this._data.getFormValue(this),1),this._value!=this._syncValue&&this.syncValue(this._value),this}})},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i=n(0)
i.Touch=function(t,e){return this.setEvent(t),this.setData({}),this.setActive(!0),this._button=t&&t.button||0,this._suppress=!1,this._captured=!1,this.setBubble(!1),e=e,this.setUpdates(0),this},i.Touch.LastTimestamp=0,i.Touch.TapTimeout=50
var o=[],s=0,u={}
i.Touch.count=function(){return s},i.Touch.lookup=function(t){return t&&(t.__touch__||u[t.identifier])},i.Touch.release=function(t,e){u[t.identifier],delete u[t.identifier],t.__touch__,delete t.__touch__},i.Touch.ontouchstart=function(t){for(var e,n=0,i=r(t.changedTouches),a=i.length;n<a;n++)if(e=i[n],!this.lookup(e)){var h=u[e.identifier]=new this(t)
e.__touch__=h,o.push(h),s++,h.touchstart(t,e)}return this},i.Touch.ontouchmove=function(t){for(var e,n,i=0,o=r(t.changedTouches),s=o.length;i<s;i++)n=o[i],(e=this.lookup(n))&&e.touchmove(t,n)
return this},i.Touch.ontouchend=function(t){for(var e,n,i=0,o=r(t.changedTouches),u=o.length;i<u;i++)n=o[i],(e=this.lookup(n))&&(e.touchend(t,n),this.release(n,e),s--)
return this},i.Touch.ontouchcancel=function(t){for(var e,n,i=0,o=r(t.changedTouches),u=o.length;i<u;i++)n=o[i],(e=this.lookup(n))&&(e.touchcancel(t,n),this.release(n,e),s--)
return this},i.Touch.onmousedown=function(t){return this},i.Touch.onmousemove=function(t){return this},i.Touch.onmouseup=function(t){return this},i.Touch.prototype.phase=function(t){return this._phase},i.Touch.prototype.setPhase=function(t){return this._phase=t,this},i.Touch.prototype.active=function(t){return this._active},i.Touch.prototype.setActive=function(t){return this._active=t,this},i.Touch.prototype.event=function(t){return this._event},i.Touch.prototype.setEvent=function(t){return this._event=t,this},i.Touch.prototype.pointer=function(t){return this._pointer},i.Touch.prototype.setPointer=function(t){return this._pointer=t,this},i.Touch.prototype.target=function(t){return this._target},i.Touch.prototype.setTarget=function(t){return this._target=t,this},i.Touch.prototype.handler=function(t){return this._handler},i.Touch.prototype.setHandler=function(t){return this._handler=t,this},i.Touch.prototype.updates=function(t){return this._updates},i.Touch.prototype.setUpdates=function(t){return this._updates=t,this},i.Touch.prototype.suppress=function(t){return this._suppress},i.Touch.prototype.setSuppress=function(t){return this._suppress=t,this},i.Touch.prototype.data=function(t){return this._data},i.Touch.prototype.setData=function(t){return this._data=t,this},i.Touch.prototype.__bubble={chainable:!0,name:"bubble"},i.Touch.prototype.bubble=function(t){return void 0!==t?(this.setBubble(t),this):this._bubble},i.Touch.prototype.setBubble=function(t){return this._bubble=t,this},i.Touch.prototype.timestamp=function(t){return this._timestamp},i.Touch.prototype.setTimestamp=function(t){return this._timestamp=t,this},i.Touch.prototype.gestures=function(t){return this._gestures},i.Touch.prototype.setGestures=function(t){return this._gestures=t,this},i.Touch.prototype.capture=function(){return this._captured=!0,this._event&&this._event.stopPropagation(),this._selblocker||(this._selblocker=function(t){return t.preventDefault()},i.document().addEventListener("selectstart",this._selblocker,!0)),this},i.Touch.prototype.isCaptured=function(){return!!this._captured},i.Touch.prototype.extend=function(t){return this._gestures||(this._gestures=[]),this._gestures.push(t),this},i.Touch.prototype.redirect=function(t){return this._redirect=t,this},i.Touch.prototype.suppress=function(){return this._active=!1,this},i.Touch.prototype.setSuppress=function(t){return console.warn("Imba.Touch#suppress= is deprecated"),this._supress=t,this},i.Touch.prototype.touchstart=function(t,e){return this._event=t,this._touch=e,this._button=0,this._x=e.clientX,this._y=e.clientY,this.began(),this.update(),t&&this.isCaptured()&&t.preventDefault(),this},i.Touch.prototype.touchmove=function(t,e){return this._event=t,this._x=e.clientX,this._y=e.clientY,this.update(),t&&this.isCaptured()&&t.preventDefault(),this},i.Touch.prototype.touchend=function(t,e){if(this._event=t,this._x=e.clientX,this._y=e.clientY,this.ended(),i.Touch.LastTimestamp=t.timeStamp,this._maxdr<20){var n=new i.Event(t)
n.setType("tap"),n.process()}return t&&this.isCaptured()&&t.preventDefault(),this},i.Touch.prototype.touchcancel=function(t,e){return this.cancel()},i.Touch.prototype.mousedown=function(t,e){var n=this
return n._event=t,n._button=t.button,n._x=e.clientX,n._y=e.clientY,n.began(),n.update(),n._mousemove=function(t){return n.mousemove(t,t)},i.document().addEventListener("mousemove",n._mousemove,!0),n},i.Touch.prototype.mousemove=function(t,e){return this._x=e.clientX,this._y=e.clientY,this._event=t,this.isCaptured()&&t.preventDefault(),this.update(),this.move(),this},i.Touch.prototype.mouseup=function(t,e){return this._x=e.clientX,this._y=e.clientY,this.ended(),this},i.Touch.prototype.idle=function(){return this.update()},i.Touch.prototype.began=function(){this._timestamp=Date.now(),this._maxdr=this._dr=0,this._x0=this._x,this._y0=this._y
var t=this.event().target,e=null
for(this._sourceTarget=t&&i.getTagForDom(t);t&&(!(e=i.getTagForDom(t))||!e.ontouchstart||(this._bubble=!1,this.setTarget(e),this.target().ontouchstart(this),this._bubble));)t=t.parentNode
return this._updates++,this},i.Touch.prototype.update=function(){var t
if(!this._active||this._cancelled)return this
var e=Math.sqrt(this.dx()*this.dx()+this.dy()*this.dy())
if(e>this._dr&&(this._maxdr=e),this._dr=e,this._redirect&&(this._target&&this._target.ontouchcancel&&this._target.ontouchcancel(this),this.setTarget(this._redirect),this._redirect=null,this.target().ontouchstart&&this.target().ontouchstart(this),this._redirect))return this.update()
if(this._updates++,this._gestures)for(var n=0,i=r(this._gestures),o=i.length;n<o;n++)i[n].ontouchupdate(this)
return(t=this.target())&&t.ontouchupdate&&t.ontouchupdate(this),this._redirect&&this.update(),this},i.Touch.prototype.move=function(){var t
if(!this._active||this._cancelled)return this
if(this._gestures)for(var e,n=0,i=r(this._gestures),o=i.length;n<o;n++)(e=i[n]).ontouchmove&&e.ontouchmove(this,this._event)
return(t=this.target())&&t.ontouchmove&&t.ontouchmove(this,this._event),this},i.Touch.prototype.ended=function(){var t
if(!this._active||this._cancelled)return this
if(this._updates++,this._gestures)for(var e=0,n=r(this._gestures),i=n.length;e<i;e++)n[e].ontouchend(this)
return(t=this.target())&&t.ontouchend&&t.ontouchend(this),this.cleanup_(),this},i.Touch.prototype.cancel=function(){return this._cancelled||(this._cancelled=!0,this.cancelled(),this.cleanup_()),this},i.Touch.prototype.cancelled=function(){var t
if(!this._active)return this
if(this._cancelled=!0,this._updates++,this._gestures)for(var e,n=0,i=r(this._gestures),o=i.length;n<o;n++)(e=i[n]).ontouchcancel&&e.ontouchcancel(this)
return(t=this.target())&&t.ontouchcancel&&t.ontouchcancel(this),this},i.Touch.prototype.cleanup_=function(){return this._mousemove&&(i.document().removeEventListener("mousemove",this._mousemove,!0),this._mousemove=null),this._selblocker&&(i.document().removeEventListener("selectstart",this._selblocker,!0),this._selblocker=null),this},i.Touch.prototype.dr=function(){return this._dr},i.Touch.prototype.dx=function(){return this._x-this._x0},i.Touch.prototype.dy=function(){return this._y-this._y0},i.Touch.prototype.x0=function(){return this._x0},i.Touch.prototype.y0=function(){return this._y0},i.Touch.prototype.x=function(){return this._x},i.Touch.prototype.y=function(){return this._y},i.Touch.prototype.tx=function(){return this._targetBox||(this._targetBox=this._target.dom().getBoundingClientRect()),this._x-this._targetBox.left},i.Touch.prototype.ty=function(){return this._targetBox||(this._targetBox=this._target.dom().getBoundingClientRect()),this._y-this._targetBox.top},i.Touch.prototype.button=function(){return this._button},i.Touch.prototype.sourceTarget=function(){return this._sourceTarget},i.Touch.prototype.elapsed=function(){return Date.now()-this._timestamp},i.TouchGesture=function(){},i.TouchGesture.prototype.__active={default:!1,name:"active"},i.TouchGesture.prototype.active=function(t){return this._active},i.TouchGesture.prototype.setActive=function(t){return this._active=t,this},i.TouchGesture.prototype._active=!1,i.TouchGesture.prototype.ontouchstart=function(t){return this},i.TouchGesture.prototype.ontouchupdate=function(t){return this},i.TouchGesture.prototype.ontouchend=function(t){return this}},function(t,e,n){var r=n(0),i={esc:27,tab:9,enter:13,space:32,up:38,down:40},o=r.Tag.prototype
o.stopModifier=function(t){return t.stop()||!0},o.preventModifier=function(t){return t.prevent()||!0},o.silenceModifier=function(t){return t.silence()||!0},o.bubbleModifier=function(t){return t.bubble(!0)||!0},o.ctrlModifier=function(t){return 1==t.event().ctrlKey},o.altModifier=function(t){return 1==t.event().altKey},o.shiftModifier=function(t){return 1==t.event().shiftKey},o.metaModifier=function(t){return 1==t.event().metaKey},o.keyModifier=function(t,e){return!e.keyCode()||e.keyCode()==t},o.delModifier=function(t){return!t.keyCode()||(8==t.keyCode()||46==t.keyCode())},o.selfModifier=function(t){return t.event().target==this._dom},o.leftModifier=function(t){return void 0!=t.button()?0===t.button():o.keyModifier(37,t)},o.rightModifier=function(t){return void 0!=t.button()?2===t.button():o.keyModifier(39,t)},o.middleModifier=function(t){return void 0==t.button()||1===t.button()},o.getHandler=function(t,e){if(this[t])return this},r.Event=function(t){this.setEvent(t),this._bubble=!0},r.Event.prototype.event=function(t){return this._event},r.Event.prototype.setEvent=function(t){return this._event=t,this},r.Event.prototype.prefix=function(t){return this._prefix},r.Event.prototype.setPrefix=function(t){return this._prefix=t,this},r.Event.prototype.source=function(t){return this._source},r.Event.prototype.setSource=function(t){return this._source=t,this},r.Event.prototype.data=function(t){return this._data},r.Event.prototype.setData=function(t){return this._data=t,this},r.Event.prototype.responder=function(t){return this._responder},r.Event.prototype.setResponder=function(t){return this._responder=t,this},r.Event.wrap=function(t){return new this(t)},r.Event.prototype.setType=function(t){return this._type=t,this},r.Event.prototype.type=function(){return this._type||this.event().type},r.Event.prototype.native=function(){return this._event},r.Event.prototype.name=function(){return this._name||(this._name=this.type().toLowerCase().replace(/\:/g,""))},r.Event.prototype.bubble=function(t){return void 0!=t?(this.setBubble(t),this):this._bubble},r.Event.prototype.setBubble=function(t){return this._bubble=t,this},r.Event.prototype.stop=function(){return this.setBubble(!1),this},r.Event.prototype.stopPropagation=function(){return this.stop()},r.Event.prototype.halt=function(){return this.stop()},r.Event.prototype.prevent=function(){return this.event().preventDefault?this.event().preventDefault():this.event().defaultPrevented=!0,this.defaultPrevented=!0,this},r.Event.prototype.preventDefault=function(){return console.warn("Event#preventDefault is deprecated - use Event#prevent"),this.prevent()},r.Event.prototype.isPrevented=function(){return this.event()&&this.event().defaultPrevented},r.Event.prototype.cancel=function(){return console.warn("Event#cancel is deprecated - use Event#prevent"),this.prevent()},r.Event.prototype.silence=function(){return this._silenced=!0,this},r.Event.prototype.isSilenced=function(){return!!this._silenced},r.Event.prototype.target=function(){return r.getTagForDom(this.event()._target||this.event().target)},r.Event.prototype.responder=function(){return this._responder},r.Event.prototype.redirect=function(t){return this._redirect=t,this},r.Event.prototype.processHandlers=function(t,e){var n=1,o=e.length,s=this._bubble,u=e.state||(e.state={})
for(s&&(this._bubble=1);n<o;){var a=!1,h=e[n++],c=null,p=t
if(h instanceof Array&&(c=h.slice(1),h=h[0]),"string"==typeof h){i[h]&&(c=[i[h]],h="key")
var l=h+"Modifier"
t[l]&&(a=!0,c=(c||[]).concat([this,u]),h=t[l])}if("string"==typeof h){var d=null,f=u.context
f&&(f.getHandler instanceof Function&&(f=f.getHandler(h,this)),f[h]instanceof Function&&(h=d=f[h],p=f)),d||console.warn("event "+this.type()+": could not find '"+h+"' in context",f)}if(h instanceof Function){var _=h.apply(p,c||[this])
if(a||this._responder||(this._responder=t),0==_)break
_&&!this._silenced&&_.then instanceof Function&&_.then(r.commit)}}return 1===this._bubble&&(this._bubble=s),null},r.Event.prototype.process=function(){for(var t,e,n,r=this.name(),i="on"+(this._prefix||"")+r,o=this.event()._target||this.event().target,s=o._responder||o;s;){this._redirect=null
var u=s._dom?s:s._tag
if(u){if(e=u._on_){for(var a,h=0,c=(n=e)?n.toArray?n.toArray():n:[],p=c.length;h<p;h++)if(a=c[h]){a[0]
r==a[0]&&this.bubble()&&this.processHandlers(u,a)}if(!this.bubble())break}this.bubble()&&u[i]instanceof Function&&(this._responder||(this._responder=u),this._silenced=!1,t=u[i](this,this.data())),u.onevent&&u.onevent(this)}if(!this.bubble()||!(s=this._redirect||(u?u.parent():s.parentNode)))break}return this.processed(),t&&t.then instanceof Function&&t.then(this.processed.bind(this)),this},r.Event.prototype.processed=function(){return!this._silenced&&this._responder&&(r.emit(r,"event",[this]),r.commit(this.event())),this},r.Event.prototype.x=function(){return this.native().x},r.Event.prototype.y=function(){return this.native().y},r.Event.prototype.button=function(){return this.native().button},r.Event.prototype.keyCode=function(){return this.native().keyCode},r.Event.prototype.ctrl=function(){return this.native().ctrlKey},r.Event.prototype.alt=function(){return this.native().altKey},r.Event.prototype.shift=function(){return this.native().shiftKey},r.Event.prototype.meta=function(){return this.native().metaKey},r.Event.prototype.key=function(){return this.native().key},r.Event.prototype.which=function(){return this.event().which}},function(t,e,n){function r(t){return t?t.toArray?t.toArray():t:[]}var i={},o=n(0),s=function(t,e,n){if(e instanceof Array)for(var i=0,o=r(e),u=o.length;i<u;i++)s(t,o[i],n)
else if(e&&e._slot_)t.removeChild(e)
else if(null!=e){var a=n?n.nextSibling:t._dom.firstChild
if(!(a instanceof Text&&a.textContent==e))throw"cannot remove string"
t.removeChild(a)}return n},u=function(t,e){if(e instanceof Array)for(var n=0,r=e.taglen,i=null!=r?e.domlen=r:e.length;n<i;)u(t,e[n++])
else e&&e._dom?t.appendChild(e):null!=e&&!1!==e&&t.appendChild(o.createTextNode(e))},a=function(t,e,n){if(e instanceof Array)for(var r=0,i=e.taglen,s=null!=i?e.domlen=i:e.length;r<s;)a(t,e[r++],n)
else e&&e._dom?t.insertBefore(e,n):null!=e&&!1!==e&&t.insertBefore(o.createTextNode(e),n)
return n}
i.insertNestedAfter=function(t,e,n){var r=n?n.nextSibling:t._dom.firstChild
return r?(a(t,e,r),r.previousSibling):(u(t,e),t._dom.lastChild)}
var h=function(t,e,n,s){for(var u,a,h=e[e.length-1],c=[],p=[],l=[],d=0,f=0,_=0,v=r(n),g=v.length;_<g;_++)if((a=v[_])&&3==a.nodeType?((u=e.indexOf(a.textContent))>=0&&(e[u]=a),!0):u=e.indexOf(a),c.push(u),-1!=u){for(var m=c.length-2;m>=0;)if(-1==c[m])m--
else{if(u>c[m])break
m=p[m]}p.push(m)
var y=-1==m?0:l[m]+1
y>d&&(d=y,f=_),l.push(y)}else t.removeChild(a),p.push(-1),l.push(-1)
for(var T=[],b=c.length-1;b>=0;)b==f&&-1!=c[b]&&(T[c[b]]=!0,f=p[f]),b-=1
for(var E,S=0,x=r(e),A=x.length;S<A;S++){if(E=x[S],!T[S]){E&&E._dom||(E=e[S]=o.createTextNode(E))
var w=e[S-1]
i.insertNestedAfter(t,E,w&&w._slot_||w||s)}s=E._slot_||s&&s.nextSibling||t._dom.firstChild}return h&&h._slot_||s},c=function(t,e,n,r){for(var i=e.length,o=n.length,s=e.cache.i$,u=0,a=i-o;u<o&&u<i&&e[u]===n[u];)u++
if(s>1e3&&s-i>500&&e.cache.$prune(e),!(a>0&&u==o)){if(a>0){for(var c=i;c>u&&e[c-1]===n[c-1-a];)c--
if(a==c-u){for(var p=n[u]._slot_;u<c;)t.insertBefore(e[u++],p)
return}}else{if(a<0&&u==i){for(;u<o;)t.removeChild(n[u++])
return}if(a<0){for(var l=o;l>u&&e[l-1+a]===n[l-1];)l--
if(a==u-l){for(;u<l;)t.removeChild(n[u++])
return}}else if(u==i)return}return h(t,e,n,r)}for(;u<i;)t.appendChild(e[u++])},p=function(t,e,n,r){var i=e.taglen,o=e.domlen||0,s=i?e[i-1]:null
if(o>i)for(;o>i;){var u=e[--o]
t.removeChild(u._slot_)}else if(i>o)for(var a=o?e[o-1]._slot_:r,h=a?a.nextSibling:t._dom.firstChild;o<i;){var c=e[o++]
h?t.insertBefore(c._slot_,h):t.appendChild(c._slot_)}return e.domlen=i,s?s._slot_:r},l=function(t,e,n,o){var u,a=null==e||!1===e,c=null==n||!1===n
if(e===n)return a?o:e._slot_?e._slot_:e instanceof Array&&null!=e.taglen?p(t,e,0,o):o?o.nextSibling:t._dom.firstChild
if(e instanceof Array){if(n instanceof Array){var d=e.static
if(!d&&!n.static)return function(t,e,n,r){var i=e.length,o=i,s=e[i-1]
if(i==n.length&&e[0]===n[0])for(;o--&&e[o]===n[o];);return-1==o?s&&s._slot_||s||r:h(t,e,n,r)}(t,e,n,o)
if(d==n.static){for(var f=0,_=r(e),v=_.length;f<v;f++)o=l(t,_[f],n[f],o)
return o}s(t,n,o)}else c||(n._slot_?t.removeChild(n):t.removeChild(o?o.nextSibling:t._dom.firstChild))
return i.insertNestedAfter(t,e,o)}if(!a&&e._slot_)return c||s(t,n,o),i.insertNestedAfter(t,e,o)
if(a)return c||s(t,n,o),o
if(n instanceof Array)s(t,n,o)
else if(n&&n._slot_)t.removeChild(n)
else if(!c&&(u=o?o.nextSibling:t._dom.firstChild)instanceof Text&&u.textContent!=e)return u.textContent=e,u
return i.insertNestedAfter(t,e,o)}
o.extendTag("element",function(t){t.prototype.setChildren=function(t,e){var n=this._tree_
if(t===n&&(!t||void 0==t.taglen))return this
if(n||3==e)if(1==e)for(var i=null,o=0,s=r(t),a=s.length;o<a;o++)i=l(this,s[o],n[o],i)
else{if(2==e)return this
if(3==e){if("object"!=typeof t)return this.setText(t)
if(t&&t._dom)this.removeAllChildren(),this.appendChild(t)
else{if(!(t instanceof Array))return this.setText(t)
5==t._type&&n&&5==n._type?c(this,t,n,null):n instanceof Array?l(this,t,n,null):(this.removeAllChildren(),u(this,t))}}else 4==e?p(this,t,0,null):5==e?c(this,t,n,null):t instanceof Array&&n instanceof Array?l(this,t,n,null):(this.removeAllChildren(),u(this,t))}else this.removeAllChildren(),u(this,t)
return this._tree_=t,this},t.prototype.content=function(){return this._content||this.children().toArray()},t.prototype.setText=function(t){if(t!=this._tree_){var e=null===t||!1===t?"":t;(this._text_||this._dom).textContent=e,this._text_||(this._text_=this._dom.firstChild),this._tree_=t}return this}})
var d=o.Tag.prototype
d.setContent=d.setChildren,"undefined"!=typeof navigator&&0==(navigator.vendor||"").indexOf("Apple")&&(d.setText=function(t){return t!=this._tree_&&(this._dom.textContent=null===t||!1===t?"":t,this._tree_=t),this})}])})