!function(a){"object"==typeof module&&"object"==typeof module.exports?module.exports=a():window.Pro=a()}(function(){{var a,b,c,d,e,f,g,h,i,j,k={},l=Array.prototype,m=l.concat,n=l.every,o=l.filter,p=l.forEach,q=l.indexOf,r=l.join,s=l.lastIndexOf,t=l.map,u=l.pop,v=l.push,w=l.reduce,x=l.reduceRight,y=l.reverse,z=l.shift,A=l.slice,B=l.some,C=l.sort,D=l.splice,E=l.toLocaleString,F=l.toString;l.unshift}return k.States={init:1,ready:2,destroyed:3,error:4},k.Utils=k.U={isFunction:function(a){return"function"==typeof a},isString:function(a){return"string"==typeof a},isObject:function(a){return"object"==typeof a},isEmptyObject:function(a){var b;for(b in a)if(a.hasOwnProperty(b))return!1;return!0},isError:function(a){return null!==a&&k.U.isObject(a)&&a.message&&"[object Error]"===Object.prototype.toString.apply(a)},isArray:function(a){return k.U.isObject(a)&&"[object Array]"===Object.prototype.toString.call(a)},isProArray:function(a){return null!==a&&k.U.isObject(a)&&k.U.isArray(a._array)&&void 0!==a.length},isArrayObject:function(a){return k.U.isArray(a)||k.U.isProArray(a)},isProObject:function(a){return a&&k.U.isObject(a)&&void 0!==a.__pro__&&k.U.isObject(a.__pro__.properties)},isProVal:function(a){return k.U.isProObject(a)&&void 0!==a.__pro__.properties.v},ex:function(a,b){var c;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},bind:function(a,b){return function(){return b.apply(a,arguments)}},contains:function(a,b){-1!==a.indexOf(b)},remove:function(a,b){var c=a.indexOf(b);c>-1&&a.splice(c,1)},diff:function(a,b){var c,d,e,f=-1,g=a.length,h=b.length,i={};if(g>=h){for(c=0;h>c;c++)d=a[c],e=b[c],d!==e?(-1===f&&(f=c),i[f]=i[f]||{o:[],n:[]},i[f].o.push(d),i[f].n.push(e)):f=-1;for(-1===f&&(f=c),i[f]=i[f]||{o:[],n:[]};g>c;c++)d=a[c],i[f].o.push(d)}else if(h>g){i=k.U.diff(b,a);for(c in i)el1=i[c],el2=el1.n,el1.n=el1.o,el1.o=el2}return i},defValProp:function(a,b,c,d,e,f){try{Object.defineProperty(a,b,{enumerable:c,configurable:d,writable:e,value:f})}catch(g){a[b]=f}}},k.Configuration={keyprops:!0,keypropList:["p"]},k.N=function(){},k.currentCaller=null,k.Queue=function(a,b){this.name=a||"proq",this.options=b||{},this._queue=[]},k.Queue.runAction=function(a,b,c,d,e){if(d&&d.length>0)if(e)try{c.apply(b,d)}catch(f){e(a,f)}else c.apply(b,d);else if(e)try{c.call(b)}catch(f){e(a,f)}else c.call(b)},k.U.ex(k.Queue.prototype,{constructor:k.Queue,length:function(){return this._queue.length/4},isEmpty:function(){return 0===this.length()},push:function(a,b,c){a&&k.Utils.isFunction(a)&&(c=b,b=a,a=null),this._queue.push(a,b,c,1)},pushOnce:function(a,b,c){a&&k.Utils.isFunction(a)&&(c=b,b=a,a=null);var d,e,f,g=this._queue,h=g.length;for(f=0;h>f;f+=4)if(d=g[f],e=g[f+1],d===a&&e===b)return g[f+2]=c,void(g[f+3]=g[f+3]+1);this.push(a,b,c)},go:function(a){var b,c,d,e,f,g=this._queue,h=this.options,i=(this.runs,g.length),j=h&&h.before,l=h&&h.after,m=h&&h.err,n=i,o=!0,p=1,q=n;for(i&&j&&j(this);o;){for(o=!1,n=q,b=0;n>b;b+=4)c=g[b],d=g[b+1],e=g[b+2],f=g[b+3],f===p?k.Queue.runAction(this,c,d,e,m):f>p&&(o=!0,q=b+4);p+=1}i&&l&&l(this),g.length>i?(this._queue=g.slice(i),a||this.go()):this._queue.length=0}}),k.Queues=function(a,b){a||(a=["proq"]),this.queueNames=a,this.options=b||{},this._queues={};var c,d=this.queueNames.length;for(c=0;d>c;c++)this._queues[this.queueNames[c]]=new k.Queue(this.queueNames[c],this.options.queue)},k.Queues.prototype={},k.Queues.prototype.isEmpty=function(){var a,b,c,d=this._queues,e=this.queueNames,f=e.length;for(a=0;f>a;a++)if(b=e[a],c=d[b],!c.isEmpty())return!1;return!0},k.Queues.prototype.push=function(a,b,c,d){a&&!k.Utils.isString(a)&&(d=c,c=b,b=a,a=this.queueNames[0]),a||(a=this.queueNames[0]);var e=this._queues[a];e&&e.push(b,c,d)},k.Queues.prototype.pushOnce=function(a,b,c,d){a&&!k.Utils.isString(a)&&(d=c,c=b,b=a,a=this.queueNames[0]),a||(a=this.queueNames[0]);var e=this._queues[a];e&&e.pushOnce(b,c,d)},k.Queues.prototype.go=function(a){var b,c,d,e,f=0,g=this._queues,h=this.queueNames,i=this.queueNames.length;if(a)for(b=0;i>b;b++)h[b]===a&&(f=b);for(;i>f;)c=h[f],d=g[c],d.go(!0),-1===(e=this.probePrevIndex(f))?f+=1:f=e},k.Queues.prototype.probePrevIndex=function(a){var b,c,d,e=this._queues,f=this.queueNames;for(b=0;a>=b;b++)if(c=f[b],d=e[c],!d.isEmpty())return b;return-1},k.Flow=function(a,b){a||(a=["proq"]),this.queueNames=a,this.options=b||{},this.flowInstance=null,this.flowInstances=[],this.pauseMode=!1},k.Flow.prototype={constructor:k.Flow,start:function(){var a=this.flowInstance,b=this.options,c=b&&b.start,d=this.queueNames;a&&this.flowInstances.push(a),this.flowInstance=new k.Queues(d,b.flowInstance),c&&c(this.flowInstance)},stop:function(){var a,b=this.flowInstance,c=this.options,d=c&&c.stop;if(b)try{b.go()}finally{this.flowInstance=null,this.flowInstances.length&&(a=this.flowInstances.pop(),this.flowInstance=a),d&&d(b)}},pause:function(){this.pauseMode=!0},resume:function(){this.pauseMode=!1},run:function(a,b){var c=this.options,d=c.err;this.start(),b||(b=a,a=null);try{if(d)try{b.call(a)}catch(e){d(e)}else b.call(a)}finally{this.stop()}},isRunning:function(){return null!==this.flowInstance&&void 0!==this.flowInstance},isPaused:function(){return this.isRunning()&&this.pauseMode},push:function(a,b,c,d){if(!this.flowInstance)throw new Error("Not in running flow!");this.isPaused()||this.flowInstance.push(a,b,c,d)},pushOnce:function(a,b,c,d){if(!this.flowInstance)throw new Error("Not in running flow!");this.isPaused()||this.flowInstance.pushOnce(a,b,c,d)}},k.flow=new k.Flow(["proq"],{err:function(a){k.flow.errStream()?k.flow.errStream().triggerErr(a):console.log(a)},flowInstance:{queue:{err:function(a,b){k.flow.errStream()?k.flow.errStream().triggerErr(b):console.log(b)}}}}),k.Observable=function(a){this.listeners=[],this.errListeners=[],this.sources=[],this.listener=null,this.errListener=null,this.transforms=a?a:[],this.parent=null},k.U.ex(k.Observable,{BadValue:{},transform:function(a,b){var c,d=a.transforms,e=d.length;for(c=0;e>c&&(b=d[c].call(a,b),b!==k.Observable.BadValue);c++);return b}}),k.Observable.prototype={constructor:k.Observable,makeListener:function(){return null},makeErrListener:function(){return null},makeEvent:function(a){return new k.Event(a,this,k.Event.Types.value)},on:function(a,b,c){return k.U.isString(a)||(b=a),k.U.isArray(c)?c.push(b):this.listeners.push(b),this},off:function(a,b,c){return a||b?(k.U.isString(a)||(b=a),k.U.isArray(c)?k.U.remove(c,b):k.U.remove(this.listeners,b),this):void(k.U.isArray(c)?c.length=0:this.listeners=[])},onErr:function(a,b){return this.on(a,b,this.errListeners)},offErr:function(a,b){return this.off(a,b,this.errListeners)},into:function(){var a,b,c=A.call(arguments),d=c.length;for(a=0;d>a;a++)b=c[a],this.sources.push(b),b.on(this.makeListener()),b.onErr(this.makeErrListener());return this},out:function(a){return a.into(this),this},offSource:function(a){return k.U.remove(this.sources,a),a.off(this.listener),a.offErr(this.errListener),this},transform:function(a){return this.transforms.push(a),this},mapping:function(a){return this.transform(a)},filtering:function(a){var b=this;return this.transform(function(c){return a.call(b,c)?c:k.Observable.BadValue})},accumulation:function(a,b){var c=this,d=a;return this.transform(function(a){return d=b.call(c,d,a)})},map:k.N,filter:k.N,accumulate:k.N,reduce:function(a,b){return new k.Val(a).into(this.accumulate(a,b))},update:function(a,b){if(0===this.listeners.length&&0===this.errListeners.length&&null===this.parent)return this;var c=this;return k.flow.isRunning()?c.willUpdate(a,b):k.flow.run(function(){c.willUpdate(a,b)}),this},willUpdate:function(a,b){var c,d,e=k.U.isArray(b)?b:this.listeners,f=e.length,g=this.makeEvent(a);for(c=0;f>c;c++)d=e[c],this.defer(g,d),d.property&&d.property.willUpdate(g);return this.parent&&this.parent.call&&this.defer(g,this.parent),this},defer:function(a,b){return k.U.isFunction(b)?k.flow.pushOnce(b,[a]):k.flow.pushOnce(b,b.call,[a]),this}},k.Event=function(a,b,c){this.source=a,this.target=b,this.type=c,this.args=A.call(arguments,3)},k.Event.Types={value:0,array:1,close:2,error:3},k.Stream=function(a,b){k.Observable.call(this,b),a&&this.into(a)},k.Stream.prototype=k.U.ex(Object.create(k.Observable.prototype),{constructor:k.Stream,makeEvent:function(a){return a},makeListener:function(){if(!this.listener){var a=this;this.listener=function(b){a.trigger(b,!0)}}return this.listener},makeErrListener:function(){if(!this.errListener){var a=this;this.errListener=function(b){a.triggerErr(b)}}return this.errListener},defer:function(a,b){return b.property?void k.Observable.prototype.defer.call(this,a,b):void(k.Utils.isFunction(b)?k.flow.push(b,[a]):k.flow.push(b,b.call,[a]))},trigger:function(a,b){return void 0===b&&(b=!0),this.go(a,b)},triggerErr:function(a){return this.update(a,this.errListeners)},go:function(a,b){{var c=this.transforms;c.length}if(b)try{a=k.Observable.transform(this,a)}catch(d){return this.triggerErr(d),this}return a===k.Observable.BadValue?this:this.update(a)},map:function(a){return new k.Stream(this).mapping(a)},filter:function(a){return new k.Stream(this).filtering(a)},accumulate:function(a,b){return new k.Stream(this).accumulation(a,b)},merge:function(a){return(new k.Stream).into(this,a)}}),k.U.ex(k.Flow.prototype,{errStream:function(){return this.errStreamVar||(this.errStreamVar=new k.Stream),this.errStreamVar}}),k.BufferedStream=function(a,b){k.Stream.call(this,a,b),this.buffer=[]},k.BufferedStream.prototype=k.U.ex(Object.create(k.Stream.prototype),{flush:function(){var a,b=this,c=this.buffer,d=c.length;k.flow.run(function(){for(a=0;d>a;a+=2)b.go(c[a],c[a+1]);b.buffer=[]})}}),k.BufferedStream.prototype.constructor=k.BufferedStream,k.SizeBufferedStream=function(a,b,c){if(1===arguments.length&&"number"==typeof a?(c=a,a=null):2===arguments.length&&"number"==typeof b&&(c=b,b=null),k.BufferedStream.call(this,a,b),!c)throw new Error("SizeBufferedStream must contain size!");this.size=c},k.SizeBufferedStream.prototype=k.U.ex(Object.create(k.BufferedStream.prototype),{trigger:function(a,b){this.buffer.push(a,b),null!==this.size&&this.buffer.length/2===this.size&&this.flush()}}),k.SizeBufferedStream.prototype.constructor=k.SizeBufferedStream,k.U.ex(k.Stream.prototype,{bufferit:function(a){return new k.SizeBufferedStream(this,a)}}),k.DelayedStream=function(a,b,c){"number"==typeof a?(c=a,a=null):k.U.isObject(a)&&"number"==typeof b&&(c=b,b=null),k.BufferedStream.call(this,a,b),this.delayId=null,this.setDelay(c)},k.DelayedStream.prototype=k.U.ex(Object.create(k.BufferedStream.prototype),{trigger:function(a,b){this.buffer.push(a,b)},cancelDelay:function(){null!==this.delayId&&(clearInterval(this.delayId),this.delayId=null)},setDelay:function(a){if(this.delay=a,this.cancelDelay(),this.delay){var b=this;this.delayId=setInterval(function(){b.flush()},this.delay)}}}),k.DelayedStream.prototype.constructor=k.DelayedStream,k.U.ex(k.Stream.prototype,{delay:function(a){return new k.DelayedStream(this,a)}}),k.ThrottlingStream=function(a,b,c){k.DelayedStream.call(this,a,b,c)},k.ThrottlingStream.prototype=k.U.ex(Object.create(k.DelayedStream.prototype),{trigger:function(a,b){this.buffer=[],this.buffer.push(a,b)}}),k.ThrottlingStream.prototype.constructor=k.ThrottlingStream,k.U.ex(k.Stream.prototype,{throttle:function(a){return new k.ThrottlingStream(this,a)}}),k.DebouncingStream=function(a,b,c){k.DelayedStream.call(this,a,b,c)},k.DebouncingStream.prototype=k.U.ex(Object.create(k.DelayedStream.prototype),{trigger:function(a,b){this.buffer=[],this.cancelDelay(),this.setDelay(this.delay),this.buffer.push(a,b)}}),k.DebouncingStream.prototype.constructor=k.DebouncingStream,k.U.ex(k.Stream.prototype,{debounce:function(a){return new k.DebouncingStream(this,a)}}),k.Array=a=function(){this._array=0===arguments.length?[]:1===arguments.length&&k.U.isArray(arguments[0])?arguments[0]:A.call(arguments),this.indexListeners=[],this.lastIndexCaller=null,this.lengthListeners=[],this.lastLengthCaller=null;var a,c,d,e,f=this;a=function(){return f.addCaller("length"),f._array.length},c=function(a){return f._array.length!==a?(e=f._array.length,f._array.length=a,f.update(b.setLength,-1,e,a),a):void 0},Object.defineProperty(this,"length",{configurable:!1,enumerable:!0,get:a,set:c}),Object.defineProperty(this,"__pro__",{enumerable:!1,configurable:!1,writeble:!1,value:{}}),this.__pro__.state=k.States.init;try{for(d=0;df;f++)g=a[f],k.U.isFunction(g)?k.flow.pushOnce(g,[i]):k.flow.pushOnce(g,g.call,[i]),g.property&&g.property.update(i)},updateByDiff:function(a){var b,c,d=this,e=k.U.diff(a,this._array);for(b in e)c=e[b],c&&d.updateSplice(b,c.o,c.n)},concat:function(){var a,b;return 1===arguments.length&&k.U.isProArray(arguments[0])&&(b=arguments[0],arguments[0]=b._array),a=new k.Array(m.apply(this._array,arguments)),b?(this.on(d.leftConcat(a,this,b)),b.on(d.rightConcat(a,this,b))):this.on(d.leftConcat(a,this,A.call(arguments,0))),a},every:function(){return this.addCaller(),n.apply(this._array,arguments)},pevery:function(){var a=new k.Val(n.apply(this._array,arguments));return this.on(d.every(a,this,arguments)),a},some:function(){return this.addCaller(),B.apply(this._array,arguments)},psome:function(){var a=new k.Val(B.apply(this._array,arguments));return this.on(d.some(a,this,arguments)),a},forEach:function(){return this.addCaller(),p.apply(this._array,arguments)},filter:function(){var a=new k.Array(o.apply(this._array,arguments));return this.on(d.filter(a,this,arguments)),a},map:function(){var a=new k.Array(t.apply(this._array,arguments));return this.on(d.map(a,this,arguments)),a},reduce:function(){return this.addCaller(),w.apply(this._array,arguments)},preduce:function(){var a=new k.Val(w.apply(this._array,arguments));return this.on(d.reduce(a,this,arguments)),a},reduceRight:function(){return this.addCaller(),x.apply(this._array,arguments)},preduceRight:function(){var a=new k.Val(x.apply(this._array,arguments));return this.on(d.reduceRight(a,this,arguments)),a},indexOf:function(){return this.addCaller(),q.apply(this._array,arguments)},pindexOf:function(){var a=new k.Val(q.apply(this._array,arguments));return this.on(d.indexOf(a,this,arguments)),a},lastIndexOf:function(){return this.addCaller(),s.apply(this._array,arguments)},plastindexOf:function(){var a=new k.Val(s.apply(this._array,arguments));return this.on(d.lastIndexOf(a,this,arguments)),a},join:function(){return this.addCaller(),r.apply(this._array,arguments)},pjoin:function(a){var b=this.preduce(function(b,c){return b+a+c},""),c=new k.Val(function(){return b.v?b.v.substring(1):""});return c},toLocaleString:function(){return this.addCaller(),E.apply(this._array,arguments)},toString:function(){return this.addCaller(),F.apply(this._array,arguments)},valueOf:function(){return this.toArray()},slice:function(){var a=new k.Array(A.apply(this._array,arguments));return this.on(d.slice(a,this,arguments)),a},reverse:function(){if(0!==this._array.length){var a=y.apply(this._array,arguments),c=this;return c.update(b.reverse,-1,null,null),a}},sort:function(){if(0!==this._array.length){var a=C.apply(this._array,arguments),c=this,d=arguments;return c.update(b.sort,-1,null,d),a}},splice:function(a,b){var c,d=this._array.length,e=D.apply(this._array,arguments),f=this._array.length,g=this,h=A.call(arguments,2);if(a=~a?a:f-a,b=(null==b?f-a:b)||0,h.length>b)for(c=h.length-b;c--;)this.defineIndexProp(d++);else if(b>h.length)for(c=b-h.length;c--;)delete this[--d];return g.updateSplice(a,e,h),new k.Array(e)},pop:function(){if(0!==this._array.length){var a=u.apply(this._array,arguments),c=this,d=this._array.length;return delete this[d],c.update(b.remove,c._array.length,a,null),a}},push:function(){var a,c,d=arguments,e=arguments.length,f=this;for(a=0;e>a;a++)c=this._array.length,v.call(this._array,arguments[a]),this.defineIndexProp(c);return f.update(b.add,f._array.length-1,null,A.call(d,0)),this._array.length},shift:function(){if(0!==this._array.length){var a=z.apply(this._array,arguments),c=this,d=this._array.length;return delete this[d],c.update(b.remove,0,a,null),a}},unshift:function(){for(var a,c=A.call(arguments,0),d=arguments.length,e=this._array,f=this,a=0;d>a;a++)e.splice(a,0,arguments[a]),this.defineIndexProp(e.length-1);return f.update(b.add,0,null,c),e.length},toArray:function(){var a,b,c=[],d=this._array,e=d.length,f=k.U.isProArray;for(a=0;e>a;a++)b=d[a],f(b)&&(b=b.toArray()),c.push(b);return c},toJSON:function(){return JSON.stringify(this._array)}}),k.Array.Listeners=d=k.Array.Listeners||{check:function(a){if(a.type!==k.Event.Types.array)throw Error("Not implemented for non array events")},leftConcat:function(a,e,f){return function(g){d.check(g);var h,i,j=g.args[0],l=g.args[1],n=g.args[2],o=g.args[3],p=f.length;j===b.set?a[l]=o:j===b.add?(h=A.call(o,0),0===l?c.unshift.apply(a,h):c.splice.apply(a,[a._array.length-p,0].concat(h))):j===b.remove?0===l?c.shift.call(a,n):c.splice.apply(a,[a._array.length-p-1,1]):j===b.setLength?(h=n-o,h>0?c.splice.apply(a,[o,h]):(i=[n,0],i.length=2-h,c.splice.apply(a,i))):j===b.reverse||j===b.sort?(h=a._array,i=k.Utils.isProArray(f)?f._array:f,a._array=m.apply(e._array,i),a.updateByDiff(h)):j===b.splice&&c.splice.apply(a,[l,n.length].concat(o))}},rightConcat:function(a,e,f){return function(g){d.check(g);var h,i=g.args[0],j=g.args[1],k=g.args[2],l=g.args[3],n=e._array.length;i===b.set?a[n+j]=l:i===b.add?0===j?c.splice.apply(a,[n,0].concat(l)):c.push.apply(a,l):i===b.remove?0===j?c.splice.call(a,n,1):c.pop.call(a,k):i===b.setLength?a.length=n+l:i===b.reverse||i===b.sort?(h=a._array,a._array=m.apply(e._array,f._array),a.updateByDiff(h)):i===b.splice&&c.splice.apply(a,[j+n,k.length].concat(l))}},every:function(a,c,e){var f=e[0],g=e[1];return function(h){d.check(h);var i,j=h.args[0],k=(h.args[1],h.args[2]),l=h.args[3];j===b.set?(i=f.call(g,l),a.valueOf()!==!0||i?a.valueOf()===!1&&i&&(a.v=n.apply(c._array,e)):a.v=!1):j===b.add?a.valueOf()===!0&&(a.v=n.call(l,f,g)):j===b.remove?a.valueOf()!==!1||f.call(g,k)||(a.v=n.apply(c._array,e)):j===b.setLength?a.valueOf()===!1&&(a.v=n.apply(c._array,e)):j===b.splice&&(a.valueOf()===!0?a.v=n.call(l,f,g):n.call(l,f,g)&&!n.call(k,f,g)&&(a.v=n.apply(c._array,e)))}},some:function(a,c,e){var f=e[0],g=e[1];return function(h){d.check(h);var i,j=h.args[0],k=(h.args[1],h.args[2]),l=h.args[3];j===b.set?(i=f.call(g,l),a.valueOf()===!1&&i?a.v=!0:a.valueOf()!==!0||i||(a.v=B.apply(c._array,e))):j===b.add?a.valueOf()===!1&&(a.v=B.call(l,f,g)):j===b.remove?a.valueOf()===!0&&f.call(g,k)&&(a.v=B.apply(c._array,e)):j===b.setLength?a.valueOf()===!0&&(a.v=B.apply(c._array,e)):j===b.splice&&(a.valueOf()===!1?a.v=B.call(l,f,g):B.call(k,f,g)&&!B.call(l,f,g)&&(a.v=B.apply(c._array,e)))}},filter:function(e,f,g){var h=g[0],i=g[1];return function(j){d.check(j);var k,l,m,n,o,p,q=j.args[0],r=j.args[1],s=j.args[2],t=j.args[3];if(q===b.set)k=h.call(i,t),l=h.call(i,s),(l===!0||k===!0)&&a.reFilter(f,e,g);else if(q===b.add)if(n=[],m=A.call(t,0),p=m.length,0===r){for(o=p-1;o>=0;)h.apply(i,[m[o],o,f._array])&&n.unshift(m[o]),o--;n.length&&c.unshift.apply(e,n)}else{for(o=0;p>o;)h.apply(i,[m[o],f._array.length-(p-o),f._array])&&n.push(m[o]),o++;n.length&&c.push.apply(e,n)}else q===b.remove?h.apply(i,[s,r,f._array])&&(0===r?e.shift():e.pop()):q===b.setLength?a.reFilter(f,e,g):q===b.reverse?e.reverse():q===b.sort?c.sort.apply(e,t):q===b.splice&&a.reFilter(f,e,g)}},map:function(a,e,f){var g=f[0],h=f[1];return function(f){d.check(f);var i,j,k,l,m=f.args[0],n=f.args[1],o=f.args[2],p=f.args[3];if(m===b.set)a[n]=g.call(h,p);else if(m===b.add)if(l=[],i=A.call(p,0),k=i.length,0===n){for(j=k-1;j>=0;)l[j]=g.apply(h,[i[j],j,e._array]),j--;c.unshift.apply(a,l)}else{for(j=0;k>j;)l[j]=g.apply(h,[i[j],e._array.length-(k-j),e._array]),j++;c.push.apply(a,l)}else if(m===b.remove)0===n?a.shift():a.pop();else if(m===b.setLength)a.length=p;else if(m===b.reverse)a.reverse();else if(m===b.sort)c.sort.apply(a,p);else if(m===b.splice){for(l=[],j=0;j=f&&0===k.length?w.apply(l,[g,a.valueOf()]):w.apply(c._array,e),f=c._array.length}},reduceRight:function(a,c,e){var f=e[0];return function(g){d.check(g);var h=g.args[0],i=g.args[1],j=g.args[2],k=g.args[3];a.v=h===b.add&&0===i||h===b.splice&&0===i&&0===j.length?x.apply(k,[f,a.valueOf()]):x.apply(c._array,e)}},indexOf:function(a,c,e){var f=e[0],g=e[1],h=!!g;return function(i){d.check(i);var j,k,l=i.args[0],m=i.args[1],n=i.args[2],o=i.args[3],p=a.valueOf();l===b.set?n===f?a.v=q.apply(c._array,e):o===f&&(p>m||-1===p)&&(!h||m>=g)&&(a.v=m):l===b.add?(j=o.indexOf(f),0===m?-1!==j&&(!h||m>=g)?a.v=j:-1!==p&&(a.v=p+o.length):-1===p&&(!h||m>=g)&&-1!==j&&(a.v=m)):l===b.remove?-1!==p&&(0===m?a.v=n!==f||h?p-1:q.apply(c._array,e):f===n&&(a.v=-1)):l===b.setLength&&p>=o?a.v=-1:l===b.reverse||l===b.sort?a.v=q.apply(c._array,e):l===b.splice&&(j=o.indexOf(f),k=j+m,p>=m?-1!==j&&p>k&&(!h||k>=g)?a.v=k:o.length!==n.length&&-1===n.indexOf(f)?(p+=o.length-n.length,a.v=!h||p>=g?p:q.apply(c._array,e)):a.v=q.apply(c._array,e):-1===p&&-1!==j&&(a.v=k))}},lastIndexOf:function(a,c,e){var f=e[0],g=e[1],h=!!g;return function(i){d.check(i);var j,k=i.args[0],l=i.args[1],m=i.args[2],n=i.args[3],o=a.valueOf();k===b.set?m===f?a.v=s.apply(c._array,e):n===f&&(l>o||-1===o)&&(!h||g>=l)&&(a.v=l):k===b.add?(j=n.indexOf(f),0===l?-1!==j&&-1===o&&(!h||g>=l)?a.v=j:-1!==o&&(a.v=o+n.length):-1!==j&&(!h||g>=l+j)&&(a.v=l+j)):k===b.remove?-1!==o&&(0===l?a.v=o-1:f===m&&(a.v=s.apply(c._array,e))):(k===b.splice||k===b.reverse||k===b.sort||k===b.setLength&&m>n)&&(a.v=s.apply(c._array,e))}},slice:function(a,c,e){var f=e[0],g=e[1],h=!!g;return function(i){d.check(i);var j,k=i.args[0],l=i.args[1],m=(i.args[2],i.args[3]);k===b.set?l>=f&&(!h||g>l)&&(a[l-f]=m):(j=a._array,a._array=A.apply(c._array,e),a.updateByDiff(j))}}},k.Property=function(a,b,c,d){Object.defineProperty(this,"proObject",{enumerable:!1,configurable:!0,writeble:!0,value:a}),this.property=b,this.proObject.__pro__||(this.proObject.__pro__={}),this.proObject.__pro__.properties=this.proObject.__pro__.properties||{},this.proObject.__pro__.properties[b]=this,this.get=c||k.Property.DEFAULT_GETTER(this),this.set=d||k.Property.DEFAULT_SETTER(this),this.oldVal=null,this.val=a[b],this.state=k.States.init,this.g=this.get,this.s=this.set,k.Observable.call(this),this.parent=this.proObject.__pro__,this.init()},k.U.ex(k.Property,{Types:{simple:0,auto:1,object:2,array:3,nil:4,type:function(a){return null===a?k.Property.Types.nil:k.U.isFunction(a)?k.Property.Types.auto:k.U.isArray(a)?k.Property.Types.array:k.U.isObject(a)?k.Property.Types.object:k.Property.Types.simple}},DEFAULT_GETTER:function(a){return function(){return a.addCaller(),a.val}},DEFAULT_SETTER:function(a,b){return function(c){return a.val!==c?(a.oldVal=a.val,a.val=b?b.call(a.proObject,c):k.Observable.transform(a,c),null===a.val||void 0===a.val?void k.Property.reProb(a).update():void a.update()):void 0}},defineProp:function(a,b,c,d){Object.defineProperty(a,b,{get:c,set:d,enumerable:!0,configurable:!0})},reProb:function(a){var b=a.proObject,c=a.property,d=a.listeners;return a.destroy(),b.__pro__.makeProp(c,d)}}),k.Property.prototype=k.U.ex(Object.create(k.Observable.prototype),{constructor:k.Property,type:function(){return k.Property.Types.simple},makeEvent:function(a){return new k.Event(a,this.property,k.Event.Types.value,this.proObject,this.oldVal,this.val)},makeListener:function(){if(!this.listener){var a=this;this.listener={property:a,call:function(b){b&&void 0!==b.type&&b.type===k.Event.Types.value&&3===b.args.length&&b.target&&(b=b.args[0][b.target]),a.oldVal=a.val,a.val=k.Observable.transform(a,b)}}}return this.listener},init:function(){this.state===k.States.init&&(k.Property.defineProp(this.proObject,this.property,this.get,this.set),this.afterInit())},afterInit:function(){this.state=k.States.ready},addCaller:function(){var a=k.currentCaller;a&&a.property!==this&&this.on(a)},destroy:function(){this.state!==k.States.destroyed&&(delete this.proObject.__pro__.properties[this.property],this.listeners=void 0,this.oldVal=void 0,this.parent=void 0,Object.defineProperty(this.proObject,this.property,{value:this.val,enumerable:!0,configurable:!0}),this.get=this.set=this.property=this.proObject=void 0,this.g=this.s=void 0,this.val=void 0,this.state=k.States.destroyed)},toString:function(){return this.val}}),k.NullProperty=function(a,b){var c=this,d=k.Property.DEFAULT_SETTER(this),e=function(a){var b=d.call(c.proObject,a),e=k.Property.Types,f=e.type(b);return f!==e.nil&&k.Property.reProb(c),b};k.Property.call(this,a,b,k.Property.DEFAULT_GETTER(this),e)},k.NullProperty.prototype=k.U.ex(Object.create(k.Property.prototype),{constructor:k.NullProperty,type:function(){return k.Property.Types.nil}}),k.AutoProperty=function(a,b){this.func=a[b];var c=this,d=function(){c.addCaller();var a,b=k.currentCaller,d=k.Property.DEFAULT_GETTER(c),e=k.Property.DEFAULT_SETTER(c,function(a){return c.func.call(c.proObject,a)}),f=arguments;return k.currentCaller=c.makeListener(),a=function(){c.val=c.func.apply(c.proObject,f)},k.flow.run(function(){k.flow.pushOnce(a)}),k.currentCaller=b,k.Property.defineProp(c.proObject,c.property,d,e),c.state=k.States.ready,c.val=k.Observable.transform(c,c.val),c.val};k.Property.call(this,a,b,d,function(){})},k.AutoProperty.prototype=k.U.ex(Object.create(k.Property.prototype),{constructor:k.AutoProperty,type:function(){return k.Property.Types.auto},makeListener:function(){if(!this.listener){var a=this;this.listener={property:a,call:function(){a.oldVal=a.val,a.val=k.Observable.transform(a,a.func.call(a.proObject))}}}return this.listener},afterInit:function(){}}),k.ObjectProperty=function(a,b){var c,d=this;c=function(){d.addCaller(),d.val.__pro__||k.prob(d.val);var a=k.Property.DEFAULT_GETTER(d),b=function(a){if(d.val!=a){if(d.oldVal=d.val,d.val=a,null===d.val||void 0===d.val)return k.Property.reProb(d).update(),d;if(d.oldVal){d.val.__pro__||k.prob(d.val);var b,c,e,f,g,h,i,j,l,m,n,o=d.oldVal.__pro__.properties,p=d.val.__pro__.properties,q=[];for(b in o)if(o.hasOwnProperty(b)){if(e=p[b],!e)continue;for(g=e.listeners,c=o[b],f=c.listeners,j=f.length,h=0;j>h;h++){for(m=!0,i=0;l>i;i++)f[h]==g[i]&&(m=!1);m&&(e.on(f[h]),q.push(h))}for(n=q.length,h=0;n>h;h++)f.splice[(q[h],1)];q=[]}}d.update()}};return k.Property.defineProp(d.proObject,d.property,a,b),d.state=k.States.ready,d.val},k.Property.call(this,a,b,c,function(){})},k.ObjectProperty.prototype=k.U.ex(Object.create(k.Property.prototype),{constructor:k.ObjectProperty,type:function(){return k.Property.Types.object},afterInit:function(){}}),k.ArrayProperty=function(a,b){var c,d=this;c=function(){d.addCaller(),k.Utils.isProArray(d.val)||(d.val=new k.Array(d.val));var a=k.Property.DEFAULT_GETTER(d),b=function(a){if(d.val!=a&&d.val.valueOf()!=a){if(d.oldVal=d.val,d.val=a,null===d.val||void 0===d.val)return k.Property.reProb(d).update(),d;if(k.Utils.isProArray(d.val)||(d.val=new k.Array(d.val)),d.oldVal){var b,c,e,f=[],g=d.oldVal.indexListeners,h=g.length,i=d.val.indexListeners,j=d.oldVal.lengthListeners,l=j.length,m=d.val.lengthListeners;for(b=0;h>b;b++)c=g[b],c.property&&c.property.proObject===d.proObject&&(i.push(c),f.push(b));for(e=f.length,b=0;e>b;b++)g.splice[(f[b],1)];for(f=[],b=0;l>b;b++)c=j[b],c.property&&c.property.proObject===d.proObject&&(m.push(c),f.push(b));for(e=f.length,b=0;e>b;b++)j.splice[(f[b],1)];f=[]}d.update()}};return k.Property.defineProp(d.proObject,d.property,a,b),d.state=k.States.ready,d.val},k.Property.call(this,a,b,c,function(){})},k.ArrayProperty.prototype=k.U.ex(Object.create(k.Property.prototype),{constructor:k.ArrayProperty,type:function(){return k.Property.Types.array},afterInit:function(){}}),k.Core=function(a,b){this.object=a,this.properties={},this.state=k.States.init,this.meta=b||{},k.Observable.call(this)},k.Core.prototype=k.U.ex(Object.create(k.Observable.prototype),{constructor:k.Core,prob:function(){var a=this,b=this.object,c=k.Configuration,d=c.keyprops,e=c.keypropList;try{for(property in b)this.makeProp(property,null,this.meta[property]);d&&-1!==e.indexOf("p")&&k.U.defValProp(b,"p",!1,!1,!1,function(b){return b&&"*"!==b?a.properties[b]:a}),this.state=k.States.ready}catch(f){throw this.state=k.States.error,f}return this},call:function(a){this.update(a)},makeProp:function(a,b,c){var d,e=this.object,f=k.Configuration,g=f.keyprops,h=f.keypropList,i=k.Utils.isFunction,j=k.Utils.isArrayObject,l=k.Utils.isObject;if(!c||!("noprop"===c||c.indexOf&&c.indexOf("noprop")>=0)){if(g&&-1!==h.indexOf(a))throw Error("The property name "+a+" is a key word for pro objects! Objects passed to Pro.prob can not contain properties named as keyword properties.");return!e.hasOwnProperty(a)||null!==e[a]&&void 0!==e[a]?!e.hasOwnProperty(a)||i(e[a])||j(e[a])||l(e[a])?e.hasOwnProperty(a)&&i(e[a])?d=new k.AutoProperty(e,a):e.hasOwnProperty(a)&&j(e[a])?d=new k.ArrayProperty(e,a):e.hasOwnProperty(a)&&l(e[a])&&(d=new k.ObjectProperty(e,a)):d=new k.Property(e,a):d=new k.NullProperty(e,a),b&&(this.properties[a].listeners=this.properties[a].listeners.concat(b)),c&&k.registry&&(k.U.isArray(c)||(c=[c]),k.registry.setup.apply(k.registry,[d].concat(c))),d}},set:function(a,b){var c=this.object;c[a]=b,this.properties[a]||this.makeProp(a)}}),k.Val=function(a){this.v=a,k.prob(this)},k.Val.prototype=k.U.ex(Object.create(k.Observable.prototype),{type:function(){return this.__pro__.properties.v.type()},on:function(a,b){return this.__pro__.properties.v.on(a,b),this},off:function(a,b){return this.__pro__.properties.v.off(a,b),this},onErr:function(a,b){return this.__pro__.properties.v.onErr(a,b),this },offErr:function(a,b){return this.__pro__.properties.v.offErr(a,b),this},transform:function(a){return this.__pro__.properties.v.transform(a),this},into:function(a){return this.__pro__.properties.v.into(a),this},out:function(a){return this.__pro__.properties.v.out(a),this},update:function(a){return this.__pro__.properties.v.update(a),this},willUpdate:function(a){return this.__pro__.properties.v.willUpdate(a),this},valueOf:function(){return this.__pro__.properties.v.val},toString:function(){return this.valueOf().toString()}}),k.prob=function(a,b){var c,d=k.Utils.isArray;return null===a||!k.U.isObject(a)&&!d(a)?new k.Val(a):d(a)?new k.Array(a):(c=new k.Core(a,b),Object.defineProperty(a,"__pro__",{enumerable:!1,configurable:!1,writeble:!1,value:c}),c.prob(),a)},k.Registry=k.R=function(){this.providers={}},k.Registry.prototype=e={constructor:k.Registry,register:function(a,b){if(this.providers[a])throw new Error(a+"is already registered in this registry.");return this.providers[a]=b,b.registered&&b.registered(this),this},make:function(a,b){var c,d=A.call(arguments,2),e=this.getProviderByName(a);return e[0]?(c=e[0].make.apply(e[0],[e[1],e[2]].concat(d)),this.setup(c,b,d)):null},setup:function(a,b,c){return f.run.apply(null,[a,b,this].concat(c))},store:function(a,b){var c=A.call(arguments,2),d=this.getProviderByName(a);return d[0]?d[0].store.apply(d[0],[d[1],b,d[2]].concat(c)):null},get:function(a){var b=this.getProviderByName(a);return b[0]?b[0].get(b[1]):null},getProviderByName:function(a){var b=a.split(":");return[this.providers[b[0]],b[1],b.slice(2)]},toObjectArray:function(a){var b=this;return k.U.isArray(a)?t.call(a,function(a){return b.toObject(a)}):this.toObject(a)},toObject:function(a){if(k.U.isString(a)){var b=this.get(a);return b?b:a}return a}},k.U.ex(k.Registry,{Provider:function(){this.stored={}},StreamProvider:function(){k.Registry.Provider.call(this)},FunctionProvider:function(){k.Registry.Provider.call(this)}}),k.Registry.Provider.prototype={constructor:k.Registry.Provider,make:function(a,b){var c;return this.stored[a]=c=this.provide(b),c},store:function(a,b){return this.stored[a]=b},get:function(a){return this.stored[a]},del:function(a){var b=this.get(a);return delete this.stored[a],b},registered:function(){},types:{basic:function(){throw new Error("Abstract: implement!")}},provide:function(a){var b,c,d,e=a[0];return e&&(b=new RegExp("(\\w*)\\(([\\s\\S]*)\\)"),c=b.exec(e),d=c[2],d&&(d=d.split(",")),e=c[1],e&&this.types[e])?this.types[e].call(this,d):this.types.basic(a)}},k.Registry.StreamProvider.prototype=k.U.ex(Object.create(k.Registry.Provider.prototype),{constructor:k.Registry.StreamProvider,registered:function(a){a.s=a.stream=k.U.bind(this,this.get)},types:{basic:function(){return new k.Stream},delayed:function(a){return new k.DelayedStream(parseInt(a[0],10))},size:function(a){return new k.SizeBufferedStream(parseInt(a[0],10))},debouncing:function(a){return new k.DebouncingStream(parseInt(a[0],10))},throttling:function(a){return new k.ThrottlingStream(parseInt(a[0],10))}}}),k.Registry.FunctionProvider.prototype=k.U.ex(Object.create(k.Registry.Provider.prototype),{constructor:k.Registry.FunctionProvider}),i=new k.Registry.StreamProvider,j=new k.Registry.FunctionProvider,k.registry=(new k.Registry).register("s",i).register("f",j).register("l",j),k.OpStore={all:{simpleOp:function(a,b){return{sym:b,match:function(a){return a.substring(0,b.length)===b},toOptions:function(b,c){var d,e,h,i,j=new RegExp(g[a].sym+"(\\w*)\\(([\\s\\S]*)\\)"),k=j.exec(c),l=k[1],m=k[2],n=[],o=A.call(arguments,2),p=f.predefined[a];if(l&&n.push(l),m)for(m=m.split(","),h=m.length,e=0;h>e;e++)d=m[e].trim(),"$"===d.charAt(0)?d=o[parseInt(d.substring(1),10)-1]:p&&"&"===d.charAt(0)?(e=d.lastIndexOf("&"),i=d.substring(0,e),p[i]&&(d=p[i].call(null,d.substring(e+1)))):p&&p[d]&&(d=p[d]),n.push(d);b[a]=n,b.order=b.order||[],b.order.push(a)},action:function(b,c){if(!c||!c[a])return b;var d=c[a];return k.U.isArray(d)||(d=[d]),b[a].apply(b,d)}}}}},h=k.OpStore.all,k.DSL={separator:"|",ops:{into:h.simpleOp("into","<<"),out:h.simpleOp("out",">>"),on:h.simpleOp("on","@"),mapping:h.simpleOp("mapping","map"),filtering:h.simpleOp("filtering","filter"),accumulation:h.simpleOp("accumulation","acc")},predefined:{mapping:{"-":function(a){return-a},pow:function(a){return a*a},sqrt:function(a){return Math.sqrt(a)},"int":function(a){return parseInt(a,10)},"&.":function(a){return function(b){var c=b[a];return c?k.U.isFunction(c)?c.call(b):c:b}}},filtering:{odd:function(a){return a%2!==0},even:function(a){return a%2===0},"+":function(a){return a>=0},"-":function(a){return 0>=a}},accumulation:{"+":[0,function(a,b){return a+b}],"*":[1,function(a,b){return a*b}],"+str":["",function(a,b){return a+b}]}},optionsFromString:function(a){return f.optionsFromArray.apply(null,[a.split(f.separator)].concat(A.call(arguments,1)))},optionsFromArray:function(a){{var b,c,d,e={},f=a.length;k.R.ops}for(b=0;f>b;b++){c=a[b];for(d in k.DSL.ops)if(d=k.DSL.ops[d],d.match(c)){d.toOptions.apply(d,[e,c].concat(A.call(arguments,1)));break}}return e},run:function(a,b,c){var d,e,h,i,j=k.U.isString,l=A.call(arguments,3);if(b&&j(b)&&(b=f.optionsFromString.apply(null,[b].concat(l))),b&&b instanceof k.Observable&&(b={into:b}),b&&b.order)for(h=b.order.length,e=0;h>e;e++)d=b.order[e],(i=g[d])&&(c&&(b[d]=c.toObjectArray(b[d])),i.action(a,b),delete b[d]);for(i in g)b&&(d=b[i])&&(b[i]=c.toObjectArray(d)),i=g[i],i.action(a,b);return a}},f=k.DSL,g=f.ops,k});