/*! Sqimitive.js - a JavaScript primitive https://squizzle.me/js/sqimitive | Public domain/Unlicense */ !function(t){var i,n,e="nodash?main:_",s="Sqimitive";"undefined"==typeof exports||exports.nodeType?"function"==typeof define&&define.amd?define(e.replace(/\?/g,"/").match(/\S+(?=:)/g)||[],t):(i="object"==typeof self?self:"object"==typeof global?global:this||{},n=function(t,e){for(e=e.split(".");t&&e.length;)t=t[e.shift()];return t},e=(e.match(/:\S+/g)||[]).map(function(t){var e=n(i,t=t.substr(1));if(e)return e;throw s+": missing dependency: "+t}),s=s.split(/\.([^.]+)$/),(i=1s&&((h=t[s])._batch||(h._batchID=n,h._batched=this._batched),e=h.batch.bind(h,t.slice(1+s),e,i||this))}if(this._batch)return e.call(i||this,n);var r,o=this._batch=[],h=!this._batches;h?this._batches=[o]:this._batches.push(o),this._batched.push([this,o]);try{try{var c=e.call(i||this,n)}finally{p.forEach(this._batched,function(t){t[0]._batch=t[0]._batchID=null,t[0]._batched=[]})}for(o.eventIndex=-1;r=o[++o.eventIndex];)this.fire(r[0],r.slice(1),!1);if(o.eventIndex=null,h)for(;o=this._batches.shift();)for(;o.length;)this.fire(o[0][0],o[0].slice(1),!0),o.shift();return c}finally{h&&(this._batches=null)}}}),n.Base=u.extend({_opt:{},_parent:null,_parentKey:null,_children:{},_owning:!0,_childClass:null,_childEvents:[],_respToOpt:{},_initToOpt:{el:!1},el:!1,elEvents:{},length:0,constructor:function(t){t||a.unshift.call(arguments,{}),n.Base.__super__.constructor.apply(this,arguments),this.init.apply(this,arguments),this.postInit.apply(this,arguments)},init:function(t){var e=this._childClass;if(p.isArray(e)){for(var i=e[1].split("."),e=e[0];e&&i[0];)e=e[i.shift()];if(!e)throw new ReferenceError("init: _childClass by path not found");this.constructor.prototype._childClass=e}this.assignResp(t,{schema:"_initToOpt"})},postInit:u.stub,render:function(){return this.invoke("attach"),this},attach:function(t){return this},getSet:function(t,e,i,n,s){for(var r=u.toArray(arguments),o=0;o<=2;o++){"function"==typeof r[o]?r.splice(o,0,r[o-1]):null==r[o]&&(r[o]=r[o-1]);var h=r["a"+o]=p.isArray(r[o])?r[o]:[r[o]];o<2&&h.forEach(function(t,e){h[e]=t.substr("-"==t[0])})}var c=p.map(r.a0,this.get,this),a={};return r.a2.forEach(function(t,e){"-"==t[0]&&(a[e]=this.get(t.substr(1)))},this),r[3]&&(c=r[3].apply(r[4]||this,c),p.isArray(r[1])||(c=[c])),this.assignResp(p.object(r.a1,c),{schema:{}}),p.isArray(r[2])?p.assign(p.map(r[2],this.get,this),a):0 in a?a[0]:this.get(r[2])},get:function(t){return arguments.length?this._opt[t]:p.assign({},this._opt)},set:function(t,e,i){return this.ifSet(t,e,i),this},ifSet:function(e,i,n){n=n||{};var t,s=this._opt[e],r="normalize_"+e;if(r in this?this[r]&&(t=this[r](i,n)):t=this.fire(r,[i,n]),void 0!==t&&(i=t),n.forceFire||!this.isEqual(i,s))return this._opt[e]=i,this.batch(null,function(t){n=this._batchOptions(t,n),this._batch.push(["change_"+e,i,s,n]),this._batch.push(["change",e,i,s,n])}),!0},isEqual:function(t,e){return t===e},nest:function(t,e,i){t=+!(t instanceof Object);return arguments[t].constructor===Object&&this._childClass!==Object&&(arguments[t]=new this._childClass(arguments[t])),t||a.unshift.call(arguments,this._defaultKey(arguments[0])),i=p.assign({},arguments[2]||{},{key:arguments[0],child:arguments[1]}),this.nestEx(i).child},nestEx:function(t){var e=t.child;if(!(e instanceof this._childClass))throw new TypeError("nestEx: Nesting Sqimitive of wrong class");if("object"==typeof t.key||void 0===t.key)throw new TypeError("nestEx: Bad key given");var i=t.key+="",n=t.previous=this._children[i];return(t.changed=n!==e)&&(this._owning?(n&&n.unnest(),e.unnest(),(this._children[i]=e)._parent=this,e._parentKey=i,this.length++):(this._children[i]=e,n?this.unnested(n,i):this.length++),this._forward(".",this._childEvents,e),this._owning&&e.owned()),this._nested(t),t},_nested:u.stub,_unnested:u.stub,_defaultKey:function(t){return t._cid},owned:u.stub,unlist:function(t){var e;return(e=null!=(t=t instanceof Object?this.findKey(t):t)?this._children[t+=""]:e)&&(this._owning?e.remove():(delete this._children[t],--this.length,this.unnested(e,t))),e},unnest:function(){var t,e=this._parent;return e&&(t=this._parentKey,delete e._children[t],this._parent=this._parentKey=null,--e.length,e.unnested(this,t)),this},unnested:function(t,e){t.off(this),this._unnested(t,e),this.length<0&&console&&console.error&&console.error("Broken nesting: sqimitive.length below zero")},nested:function(t){return arguments.length?null!=t?t instanceof Object?null!=this.findKey(t)?t:void 0:this._children[t+""]:void 0:p.assign({},this._children)},slice:function(t,e){return p.values(this._children).slice(t,e)},findKey:function(t,e){var i,n=t instanceof Object;if(n&&this._owning)return t._parent===this?t._parentKey:void 0;for(i in this._children)if(n?this._children[i]===t:t.call(e||this,this._children[i],i,this._children))return i},sort:function(t,e){return this.slice().sort(t.bind(e||this))},_:function(){return p.chain(this.slice())},remove:function(){return this.unnest()},assignChildren:function(t,e){(e=e||{}).assignChildren=!0;for(var i,n,s=e.eqFunc,r=e.keyFunc||this._defaultKey,o=e.unFunc||this.unlist,h=(null==s?(i=e.keepMissing?{}:this.nested(),e.keepMissing||this.forEach(o,this)):"function"!=typeof s&&(n=s,s=function(t,e){return e&&t.get(n)==e[n]}),p.isArray(t)||(t=p.values(t)),s?this.nested():{}),c=[],a=0;at.oldIndex,t.oldIndex==e?p.assign(this._ordered[e],i):(t.changed||this._ordered.splice(t.oldIndex,1),this._ordered.splice(e,0,i),this._repos(t.child,e)))},_unnested:function(t,e){this._removeFromOrdered(e,t)},"=slice":function(t,e,i){return p.pluck(this._ordered.slice(e,i),"child")}},_removeFromOrdered:function(t,e){e=this._indexOf(e);if(-1==e)throw new TypeError("Broken nesting: sqimitive missing from _ordered");this._ordered.splice(e,1)},_indexOf:function(e){return p.findIndex(this._ordered,function(t){return t.child===e})},_indexFor:function(t,e){return this.constructor.indexFor(this._ordered,t,this._sorter,this,e)},_sorter:function(t,e,i){return t=null==t.pos?t.key:t.pos,1==arguments.length?t:i>>1;0<(c=i.call(n,t[a+(a==s)],e,r))?o=a:h=1+a}return h}}},p.forEach("pick omit keys".split(" "),function(t,e){var i=1