!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).obop=r()}}((function(){return function r(n,t,e){function o(f,u){if(!t[f]){if(!n[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(i)return i(f,!0);var c=new Error("Cannot find module '"+f+"'");throw c.code="MODULE_NOT_FOUND",c}var s=t[f]={exports:{}};n[f][0].call(s.exports,(function(r){return o(n[f][1][r]||r)}),s,s.exports,r,n,t,e)}return t[f].exports}for(var i="function"==typeof require&&require,f=0;fr}},$gte:function(r){return function(n){return n>=r}},$in:function(r){if(!(r instanceof Array))return new Error("invalid query");var n=r.length;return function(t){for(var e=0;e=0;a--)f=c(r[a][0],r[a][1],f);return f;function c(r,t,e){var o,i,f,u,a=r.indexOf(".");return a>-1?(o=r.substr(0,a),i=[r.substr(a+1),t],f=n.order([i]),function(r,n){var t=r[o],i=n[o],u=t&&"object"==typeof t,a=i&&"object"==typeof i;if(u||a){u||(t={}),a||(i={});var c=f(t,i);if(c)return c}return e?e(r,n):0}):function(n,o){var i=n[r],f=o[r];return i>f?t:i-1){var v=c.substr(0,l),p=c.substr(l+1);a[v]=a[v]||{},a[v][p]=s}else u[c]=s}if(Object.keys(u).length){var h=i(u);o.push(h)}Object.keys(a).length&&Object.keys(a).forEach((function(r){var n={};n[e]=a[r];var i=t.update(n);o.push((function(n){var t=n[r];return"object"!=typeof t&&(t=n[r]={}),n[r]=i(t),n}))}))}else n=new Error("Unknown update operator: "+e)}})),n||(o.length<2?o.shift()||null:function(r){var n=r.length;return function(t){for(var e=0;e-1){var v=c.substr(0,l),p=c.substr(l+1);e=!0,s?(u[v]=u[v]||{},u[v][p]=s):(a[v]=a[v]||{},a[v][p]=s)}else s?i[c]=!0:f[c]=!0}e&&(Object.keys(u).forEach((function(r){var t=u[r];i[r]=n.view(t)})),Object.keys(a).forEach((function(r){var t=a[r];f[r]=n.view(t)})));var h=Object.keys(i).length,y=Object.keys(f).length;return 1!==h||y||e?h&&!y?e?w:function(r){var n={};return Object.keys(r).forEach((function(t){i[t]&&(n[t]=r[t])})),n}:!h&&y?e?d:function(r){var n={};return Object.keys(r).forEach((function(t){f[t]||(n[t]=r[t])})),n}:function(r){h&&(r=w(r));y&&(r=d(r));return r}:function(r){var n={};r.hasOwnProperty(o)&&(n[o]=r[o]);return n};function d(r){var n={};return Object.keys(r).forEach((function(t){var e=f[t],o=r[t];"function"==typeof e?n[t]="object"==typeof o?e(o):o:e||(n[t]=o)})),n}function w(r){var n={};return Object.keys(r).forEach((function(t){var e=i[t],o=r[t];"function"==typeof e?"object"==typeof o&&(n[t]=e(o)):e&&(n[t]=o)})),n}}t.view=function(r,n){var t,o=arguments.length;if(1===o){if((t=e.call(this,r))instanceof Error)throw t;return t}if(2===o){if(r instanceof Array){if((t=e.call(this,n))instanceof Error)throw t;return r.map(t)}throw new Error("Invalid argument type: "+r)}throw new Error("Invalid arguments length: "+o)}},{}],8:[function(r,n,t){function e(r){var n=this;if("function"==typeof r)return r;if("object"!=typeof(r=r||{}))return new Error("Invalid where operator type: "+r);var t=[],e={},o={},i={};for(var f in r){if(/(^|\.)__proto__(\.|$)/.test(f))return new Error("Invalid target: "+f);var u=r[f],a=f.indexOf("."),c=n.$where[f];if(c){var s=c(u,n,f);s&&t.push(s)}else if(a>-1){var l=f.substr(0,a),v=f.substr(a+1);o[l]=o[l]||{},o[l][v]=u}else{if(u instanceof Array)return new Error("Unknown where operator: "+f);"object"==typeof u?i[f]=u:e[f]=u}}var p,h=Object.keys(e);if(1===h.length){var y=h[0],d=r[y];t.push((function(r){return"object"==typeof r&&r[y]==d}))}else if(h.length>1){t.push((function(r){if("object"!=typeof r)return!1;for(var n in e)if(r[n]!=e[n])return!1;return!0}))}return w(o),w(i),p?new Error(p):t.length<2?t.shift()||null:function(r){var n=r.length;return function(r){for(var n=r.length,t=0;t