mongoose 6.0.14 → 6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,6 +45,10 @@ e.last=function(t){if(t.length>0)return t[t.length-1]},e.clone=p,
45
45
  * ignore
46
46
  */
47
47
  e.promiseOrCallback=w,
48
+ /*!
49
+ * ignore
50
+ */
51
+ e.cloneArrays=function(t){return Array.isArray(t)?t.map((function(t){return e.cloneArrays(t)})):t},
48
52
  /*!
49
53
  * ignore
50
54
  */
@@ -276,11 +280,11 @@ w.prototype._applySetters=function(t,e,r,n){var i=t;if(r)return i;for(var o=this
276
280
  /*!
277
281
  * ignore
278
282
  */
279
- w.prototype._castNullish=function(t){return t},w.prototype.applySetters=function(t,e,r,n,i){var o=this._applySetters(t,e,r,n,i);return null==o?this._castNullish(o):o=this.cast(o,e,r,n,i)},w.prototype.applyGetters=function(t,e){var r=t,n=this.getters,i=n.length;if(0===i)return r;for(var o=0;o<i;++o)r=n[o].call(e,r,this);return r},w.prototype.select=function(t){return this.selected=!!t,this},w.prototype.doValidate=function(t,e,r,n){var o=!1,s=this.path,a=this.validators.filter((function(t){return null!=t&&"object"===i(t)})),u=a.length;if(!u)return e(null);var h=this;function f(t,r){if(!o)if(void 0===t||t)--u<=0&&l((function(){e(null)}));else{var n=r.ErrorConstructor||g;(o=new n(r))[m]=!0,l((function(){e(o)}))}}a.forEach((function(e){if(!o){var i,a=e.validator,u=p.clone(e);if(u.path=n&&n.path?n.path:s,u.value=t,a instanceof RegExp)f(a.test(t),u);else if("function"==typeof a)if(void 0!==t||a===h.requiredValidator){try{i=u.propsParameter?a.call(r,t,u):a.call(r,t)}catch(t){i=!1,u.reason=t,t.message&&(u.message=t.message)}null!=i&&"function"==typeof i.then?i.then((function(t){f(t,u)}),(function(t){u.reason=t,u.message=t.message,f(i=!1,u)})):f(i,u)}else f(!0,u)}}))},w.prototype.doValidateSync=function(t,e,r){var n=this.path;if(!this.validators.length)return null;var o=this.validators;if(void 0===t){if(!(this.validators.length>0&&"required"===this.validators[0].type))return null;o=[this.validators[0]]}var s=null;return o.forEach((function(o){if(!s&&null!=o&&"object"===i(o)){var u,h=o.validator,f=p.clone(o);if(f.path=r&&r.path?r.path:n,f.value=t,!c(h))if(h instanceof RegExp)a(h.test(t),f);else if("function"==typeof h){try{u=f.propsParameter?h.call(e,t,f):h.call(e,t)}catch(t){u=!1,f.reason=t}null!=u&&"function"==typeof u.then||a(u,f)}}})),s;function a(t,e){if(!s&&void 0!==t&&!t){var r=e.ErrorConstructor||g;(s=new r(e))[m]=!0}}},w._isRef=function(t,e,r,i){var o=i&&t.options&&(t.options.ref||t.options.refPath);if(!o&&r&&null!=r.$__){var s=r.$__fullPath(t.path,!0),a=r.ownerDocument?r.ownerDocument():r;o=null!=s&&a.$populated(s)||r.$populated(t.path)}return!!o&&(null==e||(!(n.isBuffer(e)||"Binary"===e._bsontype||!p.isObject(e))||i))},
283
+ w.prototype._castNullish=function(t){return t},w.prototype.applySetters=function(t,e,r,n,i){var o=this._applySetters(t,e,r,n,i);return null==o?this._castNullish(o):o=this.cast(o,e,r,n,i)},w.prototype.applyGetters=function(t,e){var r=t,n=this.getters,i=n.length;if(0===i)return r;for(var o=0;o<i;++o)r=n[o].call(e,r,this);return r},w.prototype.select=function(t){return this.selected=!!t,this},w.prototype.doValidate=function(t,e,r,n){var o=!1,s=this.path,a=this.validators.filter((function(t){return null!=t&&"object"===i(t)})),u=a.length;if(!u)return e(null);var h=this;function f(t,r){if(!o)if(void 0===t||t)--u<=0&&l((function(){e(null)}));else{var n=r.ErrorConstructor||g;(o=new n(r))[m]=!0,l((function(){e(o)}))}}a.forEach((function(e){if(!o){var i,a=e.validator,u=p.clone(e);if(u.path=n&&n.path?n.path:s,u.value=t,a instanceof RegExp)f(a.test(t),u);else if("function"==typeof a)if(void 0!==t||a===h.requiredValidator){try{i=u.propsParameter?a.call(r,t,u):a.call(r,t)}catch(t){i=!1,u.reason=t,t.message&&(u.message=t.message)}null!=i&&"function"==typeof i.then?i.then((function(t){f(t,u)}),(function(t){u.reason=t,u.message=t.message,f(i=!1,u)})):f(i,u)}else f(!0,u)}}))},w.prototype.doValidateSync=function(t,e,r){var n=this.path;if(!this.validators.length)return null;var o=this.validators;if(void 0===t){if(!(this.validators.length>0&&"required"===this.validators[0].type))return null;o=[this.validators[0]]}var s=null;return o.forEach((function(o){if(!s&&null!=o&&"object"===i(o)){var u,h=o.validator,f=p.clone(o);if(f.path=r&&r.path?r.path:n,f.value=t,!c(h))if(h instanceof RegExp)a(h.test(t),f);else if("function"==typeof h){try{u=f.propsParameter?h.call(e,t,f):h.call(e,t)}catch(t){u=!1,f.reason=t}null!=u&&"function"==typeof u.then||a(u,f)}}})),s;function a(t,e){if(!s&&void 0!==t&&!t){var r=e.ErrorConstructor||g;(s=new r(e))[m]=!0}}},w._isRef=function(t,e,r,i){var o=i&&t.options&&(t.options.ref||t.options.refPath);if(!o&&r&&null!=r.$__){var s=r.$__fullPath(t.path,!0),a=r.ownerDocument();o=null!=s&&a.$populated(s)||r.$populated(t.path)}return!!o&&(null==e||(!(n.isBuffer(e)||"Binary"===e._bsontype||!p.isObject(e))||i))},
280
284
  /*!
281
285
  * ignore
282
286
  */
283
- w.prototype._castRef=function(t,e,r){if(null==t)return t;if(null!=t.$__)return t.$__.wasPopulated=!0,t;if(n.isBuffer(t)||!p.isObject(t)){if(r)return t;throw new v(this.instance,t,this.path,null,this)}var i=e.$__fullPath(this.path,!0),o=(e.ownerDocument?e.ownerDocument():e).$populated(i,!0),s=t;return e.$__.populated&&e.$__.populated[i]&&e.$__.populated[i].options&&e.$__.populated[i].options.options&&e.$__.populated[i].options.options.lean||((s=new o.options[b](t)).$__.wasPopulated=!0),s},w.prototype.$conditionalHandlers={$all:function(t){var e=this;return Array.isArray(t)?t.map((function(t){return e.castForQuery(t)})):[this.castForQuery(t)]},$eq:_,$in:M,$ne:_,$nin:M,$exists:a,$type:u},
287
+ w.prototype._castRef=function(t,e,r){if(null==t)return t;if(null!=t.$__)return t.$__.wasPopulated=!0,t;if(n.isBuffer(t)||!p.isObject(t)){if(r)return t;throw new v(this.instance,t,this.path,null,this)}var i=e.$__fullPath(this.path,!0),o=e.ownerDocument().$populated(i,!0),s=t;return e.$__.populated&&e.$__.populated[i]&&e.$__.populated[i].options&&e.$__.populated[i].options.options&&e.$__.populated[i].options.options.lean||((s=new o.options[b](t)).$__.wasPopulated=!0),s},w.prototype.$conditionalHandlers={$all:function(t){var e=this;return Array.isArray(t)?t.map((function(t){return e.castForQuery(t)})):[this.castForQuery(t)]},$eq:_,$in:M,$ne:_,$nin:M,$exists:a,$type:u},
284
288
  /*!
285
289
  * Wraps `castForQuery` to handle context
286
290
  */
@@ -301,7 +305,7 @@ w.prototype.clone=function(){var t=Object.assign({},this.options),e=new this.con
301
305
  t.exports=e=w,e.CastError=v,e.ValidatorError=g}).call(this,r(3).Buffer)},function(t,e,r){"use strict";function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var i,o="object"===("undefined"==typeof Reflect?"undefined":n(Reflect))?Reflect:null,s=o&&"function"==typeof o.apply?o.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};i=o&&"function"==typeof o.ownKeys?o.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var a=Number.isNaN||function(t){return t!=t};function u(){u.init.call(this)}t.exports=u,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}v(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&v(t,"error",e,r)}(t,i,{once:!0})}))},u.EventEmitter=u,u.prototype._events=void 0,u.prototype._eventsCount=0,u.prototype._maxListeners=void 0;var h=10;function f(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+n(t))}function c(t){return void 0===t._maxListeners?u.defaultMaxListeners:t._maxListeners}function l(t,e,r,n){var i,o,s,a;if(f(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=c(t))>0&&s.length>i&&!s.warned){s.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=s.length,a=u,console&&console.warn&&console.warn(a)}return t}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function p(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=d.bind(n);return i.listener=r,n.wrapFn=i,i}function m(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):b(i,i.length)}function y(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function b(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function v(t,e,r,i){if("function"==typeof t.on)i.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+n(t));t.addEventListener(e,(function n(o){i.once&&t.removeEventListener(e,n),r(o)}))}}Object.defineProperty(u,"defaultMaxListeners",{enumerable:!0,get:function(){return h},set:function(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");h=t}}),u.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},u.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||a(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},u.prototype.getMaxListeners=function(){return c(this)},u.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var n="error"===t,i=this._events;if(void 0!==i)n=n&&void 0===i.error;else if(!n)return!1;if(n){var o;if(e.length>0&&(o=e[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var u=i[t];if(void 0===u)return!1;if("function"==typeof u)s(u,this,e);else{var h=u.length,f=b(u,h);for(r=0;r<h;++r)s(f[r],this,e)}return!0},u.prototype.addListener=function(t,e){return l(this,t,e,!1)},u.prototype.on=u.prototype.addListener,u.prototype.prependListener=function(t,e){return l(this,t,e,!0)},u.prototype.once=function(t,e){return f(e),this.on(t,p(this,t,e)),this},u.prototype.prependOnceListener=function(t,e){return f(e),this.prependListener(t,p(this,t,e)),this},u.prototype.removeListener=function(t,e){var r,n,i,o,s;if(f(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},u.prototype.off=u.prototype.removeListener,u.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},u.prototype.listeners=function(t){return m(this,t,!0)},u.prototype.rawListeners=function(t){return m(this,t,!1)},u.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},u.prototype.listenerCount=y,u.prototype.eventNames=function(){return this._eventsCount>0?i(this._events):[]}},function(t,e){function r(t,e){if(!t)throw new Error(e||"Assertion failed")}t.exports=r,r.equal=function(t,e,r){if(t!=e)throw new Error(r||"Assertion failed: "+t+" != "+e)}},function(t,e,r){"use strict";var n=e,i=r(19),o=r(12),s=r(136);n.assert=o,n.toArray=s.toArray,n.zero2=s.zero2,n.toHex=s.toHex,n.encode=s.encode,n.getNAF=function(t,e,r){var n=new Array(Math.max(t.bitLength(),r)+1);n.fill(0);for(var i=1<<e+1,o=t.clone(),s=0;s<n.length;s++){var a,u=o.andln(i-1);o.isOdd()?(a=u>(i>>1)-1?(i>>1)-u:u,o.isubn(a)):a=0,n[s]=a,o.iushrn(1)}return n},n.getJSF=function(t,e){var r=[[],[]];t=t.clone(),e=e.clone();for(var n,i=0,o=0;t.cmpn(-i)>0||e.cmpn(-o)>0;){var s,a,u=t.andln(3)+i&3,h=e.andln(3)+o&3;3===u&&(u=-1),3===h&&(h=-1),s=0==(1&u)?0:3!==(n=t.andln(7)+i&7)&&5!==n||2!==h?u:-u,r[0].push(s),a=0==(1&h)?0:3!==(n=e.andln(7)+o&7)&&5!==n||2!==u?h:-h,r[1].push(a),2*i===s+1&&(i=1-i),2*o===a+1&&(o=1-o),t.iushrn(1),e.iushrn(1)}return r},n.cachedProperty=function(t,e,r){var n="_"+e;t.prototype[e]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(t){return"string"==typeof t?n.toArray(t,"hex"):t},n.intFromLE=function(t){return new i(t,"hex","le")}},function(t,e,r){"use strict";
302
306
  /*!
303
307
  * Module dependencies.
304
- */function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a,u,h,f=r(11).EventEmitter,c=r(293),l=r(8),d=r(46),p=r(164),m=r(316),y=r(317),b=r(89),v=r(56),g=r(161),w=r(162),_=r(90),M=r(54),S=r(176),O=r(95).compile,A=r(95).defineKey,E=r(354).flatten,x=r(355),k=r(6),j=r(357),$=r(358),R=r(180),P=r(45),B=r(96),T=r(359),I=r(9).inspect,N=r(38).internalToObjectOptions,D=r(360),C=r(85),L=r(361),q=r(4),U=r(363),F=q.clone,z=q.deepEqual,V=q.isMongooseObject,K=r(1).arrayAtomicsBackupSymbol,H=r(1).arrayAtomicsSymbol,W=r(1).documentArrayParent,Z=r(1).documentIsModified,J=r(1).documentModifiedPaths,Y=r(1).documentSchemaSymbol,G=r(1).getSymbol,Q=r(1).populateModelSymbol,X=r(1).scopeSymbol,tt=r(57).schemaMixedSymbol,et=r(364),rt=q.specialProperties;function nt(t,e,r,n){var o=this;if("object"===s(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n),null==this.$__schema){var a=q.isObject(e)&&!e.instanceOfSchema?new b(e):e;this.$__setSchema(a),e=r,r=n,n=arguments[4]||{}}if(this.$__=new c,this.$__.emitter=new f,this.$isNew=!("isNew"in n)||n.isNew,"priorDoc"in n&&(this.$__.priorDoc=n.priorDoc),null!=t&&"object"!==s(t))throw new m(t,"obj","Document");var u=!0;void 0!==n.defaults&&(this.$__.defaults=n.defaults,u=n.defaults);var h=this.$__schema;"boolean"==typeof e||"throw"===e?(this.$__.strictMode=e,e=void 0):(this.$__.strictMode=h.options.strict,void 0!==e&&(this.$__.selected=e));var l,d=h.requiredPaths(!0),p=i(d);try{for(p.s();!(l=p.n()).done;){var y=l.value;this.$__.activePaths.require(y)}}catch(t){p.e(t)}finally{p.f()}this.$__.emitter.setMaxListeners(0);var v=null;q.isPOJO(e)&&(v=T(e));var g=!1===v&&e?ot(e):{};if(null==this._doc&&(this.$__buildDoc(t,e,r,v,g,!1),u&&st(this,e,r,v,g,!0,{isNew:this.$isNew})),t&&(this.$__original_set?this.$__original_set(t,void 0,!0):this.$set(t,void 0,!0),t instanceof nt&&(this.$isNew=t.$isNew)),n.willInit&&u?f.prototype.once.call(this,"init",(function(){st(o,e,r,v,g,!1,n.skipDefaults,o.$isNew)})):u&&st(this,e,r,v,g,!1,n.skipDefaults,this.$isNew),this.$__._id=this._id,!this.$__.strictMode&&t){var w=this,_=Object.keys(this._doc);_.forEach((function(t){t in h.tree||A({prop:t,subprops:null,prototype:w})}))}lt(this)}for(var it in Object.defineProperty(nt.prototype,"isNew",{get:function(){return this.$isNew},set:function(t){this.$isNew=t}}),Object.defineProperty(nt.prototype,"errors",{get:function(){return this.$errors},set:function(t){this.$errors=t}}),
308
+ */function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function i(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var a,u,h,f=r(11).EventEmitter,c=r(293),l=r(8),d=r(46),p=r(164),m=r(316),y=r(317),b=r(89),v=r(56),g=r(161),w=r(162),_=r(90),M=r(54),S=r(176),O=r(95).compile,A=r(95).defineKey,E=r(354).flatten,x=r(355),k=r(6),j=r(357),$=r(358),R=r(180),P=r(45),B=r(96),T=r(359),I=r(9).inspect,N=r(38).internalToObjectOptions,D=r(360),C=r(85),L=r(361),q=r(4),U=r(363),F=q.clone,z=q.deepEqual,V=q.isMongooseObject,K=r(1).arrayAtomicsBackupSymbol,H=r(1).arrayAtomicsSymbol,W=r(1).documentArrayParent,Z=r(1).documentIsModified,J=r(1).documentModifiedPaths,Y=r(1).documentSchemaSymbol,G=r(1).getSymbol,Q=r(1).populateModelSymbol,X=r(1).scopeSymbol,tt=r(57).schemaMixedSymbol,et=r(364),rt=q.specialProperties;function nt(t,e,r,n){var o=this;if("object"===s(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n),null==this.$__schema){var a=q.isObject(e)&&!e.instanceOfSchema?new b(e):e;this.$__setSchema(a),e=r,r=n,n=arguments[4]||{}}if(this.$__=new c,this.$__.emitter=new f,this.$isNew=!("isNew"in n)||n.isNew,"priorDoc"in n&&(this.$__.priorDoc=n.priorDoc),null!=t&&"object"!==s(t))throw new m(t,"obj","Document");var u=!0;void 0!==n.defaults&&(this.$__.defaults=n.defaults,u=n.defaults);var h=this.$__schema;"boolean"==typeof e||"throw"===e?(this.$__.strictMode=e,e=void 0):(this.$__.strictMode=h.options.strict,void 0!==e&&(this.$__.selected=e));var l,d=h.requiredPaths(!0),p=i(d);try{for(p.s();!(l=p.n()).done;){var y=l.value;this.$__.activePaths.require(y)}}catch(t){p.e(t)}finally{p.f()}this.$__.emitter.setMaxListeners(0);var v=null;q.isPOJO(e)&&(v=T(e));var g=!1===v&&e?ot(e):{};if(null==this._doc&&(this.$__buildDoc(t,e,r,v,g,!1),u&&st(this,e,r,v,g,!0,{isNew:this.$isNew})),t&&(this.$__original_set?this.$__original_set(t,void 0,!0):this.$set(t,void 0,!0),t instanceof nt&&(this.$isNew=t.$isNew)),n.willInit&&u?f.prototype.once.call(this,"init",(function(){st(o,e,r,v,g,!1,n.skipDefaults,o.$isNew)})):u&&st(this,e,r,v,g,!1,n.skipDefaults,this.$isNew),this.$__._id=this._id,!this.$__.strictMode&&t){var w=this,_=Object.keys(this._doc);_.forEach((function(t){t in h.tree||t in h.methods||t in h.virtuals||t.startsWith("$")||A({prop:t,subprops:null,prototype:w})}))}lt(this)}for(var it in Object.defineProperty(nt.prototype,"isNew",{get:function(){return this.$isNew},set:function(t){this.$isNew=t}}),Object.defineProperty(nt.prototype,"errors",{get:function(){return this.$errors},set:function(t){this.$errors=t}}),
305
309
  /*!
306
310
  * Document exposes the NodeJS event emitter API, so you can use
307
311
  * `on`, `once`, etc.
@@ -372,22 +376,22 @@ nt.prototype.$__init=function(t,e){if(this.$isNew=!1,this.$init=!0,e=e||{},null!
372
376
  * @param {Object} doc object we are initializing
373
377
  * @api private
374
378
  */
375
- return function t(e,r,n,i,o){o=o||"";var s,a,u,h=Object.keys(r),f=h.length,c=0,l=e.$__.strictMode;for(;c<f;)d(c++);function d(f){if(u=h[f],a=o+u,s=e.$__schema.path(a),!e.$__schema.$isRootDiscriminator||e.$__isSelected(a))if(!s&&q.isPOJO(r[u]))n[u]||(n[u]={}),t(e,r[u],n[u],i,a+".");else if(s){if(n.hasOwnProperty(u)&&void 0!==r[u]&&delete n[u],null===r[u])n[u]=s._castNullish(null);else if(void 0!==r[u]){var c=(r[u].$__||{}).wasPopulated||null;if(s&&!c)try{n[u]=s.cast(r[u],e,!0)}catch(t){e.invalidate(t.path,new w({path:t.path,message:t.message,type:"cast",value:t.value,reason:t}))}else n[u]=r[u]}e.$isModified(a)||e.$__.activePaths.init(a)}else n[u]=r[u],l||(e[u]=r[u])}}(this,t,this._doc,e),D(this,e.populated),this.$emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},nt.prototype.update=function(){var t=q.args(arguments);t.unshift({_id:this._id});var e=this.constructor.update.apply(this.constructor,t);return null!=this.$session()&&("session"in e.options||(e.options.session=this.$session())),e},nt.prototype.updateOne=function(t,e,r){var n=this,i=this.constructor.updateOne({_id:this._id},t,e);return i.pre((function(t){n.constructor._middleware.execPre("updateOne",n,[n],t)})),i.post((function(t){n.constructor._middleware.execPost("updateOne",n,[n],{},t)})),null!=this.$session()&&("session"in i.options||(i.options.session=this.$session())),null!=r?i.exec(r):i},nt.prototype.replaceOne=function(){var t=q.args(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},nt.prototype.$session=function(t){if(0===arguments.length)return null!=this.$__.session&&this.$__.session.hasEnded?(this.$__.session=null,null):this.$__.session;if(null!=t&&t.hasEnded)throw new l("Cannot set a document's session to a session that has ended. Make sure you haven't called `endSession()` on the session you are passing to `$session()`.");if(this.$__.session=t,!this.ownerDocument){var e,r=this.$getAllSubdocs(),n=i(r);try{for(n.s();!(e=n.n()).done;){var o=e.value;o.$session(t)}}catch(t){n.e(t)}finally{n.f()}}return t},nt.prototype.overwrite=function(t){for(var e=0,r=Array.from(new Set(Object.keys(this._doc).concat(Object.keys(t))));e<r.length;e++){var n=r[e];"_id"!==n&&(this.$__schema.options.versionKey&&n===this.$__schema.options.versionKey||this.$__schema.options.discriminatorKey&&n===this.$__schema.options.discriminatorKey||this.$set(n,t[n]))}return this},nt.prototype.$set=function(t,e,r,o){var a=this;q.isPOJO(r)&&(o=r,r=void 0);var u,h,f,c,m=(o=o||{}).merge,y=r&&!0!==r,b=!0===r,g=this.$__schema.options.typeKey,w=0,_="strict"in o?o.strict:this.$__.strictMode;if(y&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var M=[e,t];t=M[0],e=M[1]}else if("string"!=typeof t){if(t instanceof nt&&(t=t.$__isNested?t.toObject():t._doc),null==t){var O=[e,t];t=O[0],e=O[1]}c=e?e+".":"";var A=(u=$(this.$__schema,t)).length,E=k(o,"_skipMinimizeTopLevel",!1);if(0===A&&E)return delete o._skipMinimizeTopLevel,e&&this.$set(e,{}),this;for(var x=0;x<A;++x){var P=c+(f=u[x]);h=this.$__schema.pathType(P);var B=t[f];if(!0!==r||c||null==t[f]||"nested"!==h||null==this._doc[f]?o=Object.assign({},o,{_skipMinimizeTopLevel:!1}):(delete this._doc[f],o=Object.assign({},o,{_skipMinimizeTopLevel:!0})),q.isNonBuiltinObject(B)&&"nested"===h)at(t[f],c+f,this),this.$set(c+f,t[f],b,Object.assign({},o,{_skipMarkModified:!0}));else if(_){if(b&&void 0===t[f]&&void 0!==this.$get(P))continue;if("adhocOrUndefined"===h&&(h=j(this,P,{typeOnly:!0})),"real"===h||"virtual"===h){var T=t[f];this.$__schema.paths[P]&&this.$__schema.paths[P].$isSingleNested&&t[f]instanceof nt&&(T=T.toObject({virtuals:!1,transform:!1})),this.$set(c+f,T,b,o)}else if("nested"===h&&t[f]instanceof nt)this.$set(c+f,t[f].toObject({transform:!1}),b,o);else if("throw"===_)throw"nested"===h?new p(f,t[f]):new v(f)}else void 0!==t[f]&&this.$set(c+f,t[f],b,o)}for(var I=0,N=Object.keys(this.$__schema.tree);I<N.length;I++){var D=N[I];if(this._doc.hasOwnProperty(D)){var L=this._doc[D];delete this._doc[D],this._doc[D]=L}}return this}var U=this.$__schema.pathType(t);"adhocOrUndefined"===U&&(U=j(this,t,{typeOnly:!0})),e=R(e);var F,z=null!=a.$__.priorDoc?a.$__.priorDoc.$__getValue(t):b?void 0:a.$__getValue(t);if("nested"===U&&e){if("object"===s(e)&&null!=e){var V=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.$isNew&&!this.$__.savedState.hasOwnProperty(t)){var K=this.$__getValue(t);this.$__.savedState[t]=K;for(var H=0,W=Object.keys(K||{});H<W.length;H++){var Z=W[H];this.$__.savedState[t+"."+Z]=K[Z]}}if(m)return this.$set(e,t,b);this.$__setValue(t,null),S(this,t);var J=$(this.$__schema,e,t);this.$__setValue(t,{});var Y,G=i(J);try{for(G.s();!(Y=G.n()).done;){var X=Y.value;this.$set(t+"."+X,e[X],b,o)}}catch(t){G.e(t)}finally{G.f()}return null!=z&&q.deepEqual(V?this.$__.savedState[t]:z,e)?this.unmarkModified(t):this.markModified(t),S(this,t,{skipDocArrays:!0}),this}return this.invalidate(t,new l.CastError("Object",e,t)),this}var tt=-1===t.indexOf(".")?[t]:t.split(".");if("string"==typeof this.$__schema.aliases[tt[0]]&&(tt[0]=this.$__schema.aliases[tt[0]]),"adhocOrUndefined"===U&&_){var et;for(w=0;w<tt.length;++w){var rt=tt.slice(0,w+1).join(".");if(w+1<tt.length&&"virtual"===this.$__schema.pathType(rt))return C.set(t,e,this),this;if(null!=(F=this.$__schema.path(rt))&&F instanceof d){et=!0;break}}if(null==F&&(F=j(this,t)),!et&&!F){if("throw"===_)throw new v(t);return this}}else{if("virtual"===U)return(F=this.$__schema.virtualpath(t)).applySetters(e,this),this;F=this.$__path(t)}var it,ot=this._doc,st="";for(w=0;w<tt.length-1;++w)ot=ot[tt[w]],st+=(st.length>0?".":"")+tt[w],ot||(this.$set(st,{}),this.$__isSelected(st)||this.unmarkModified(st),ot=this.$__getValue(st));if(tt.length<=1)it=t;else{for(w=0;w<tt.length;++w){var ut=tt.slice(0,w+1).join(".");if(null===this.$get(ut,null,{getters:!1})){it=ut;break}}it||(it=t)}if(!F)return this.$__set(it,t,o,b,tt,F,e,z),this;if((F.$isSingleNested||F.$isMongooseArray)&&
379
+ return function t(e,r,n,i,o){o=o||"";var s,a,u,h=Object.keys(r),f=h.length,c=0,l=e.$__.strictMode;for(;c<f;)d(c++);function d(f){if(u=h[f],a=o+u,s=e.$__schema.path(a),!e.$__schema.$isRootDiscriminator||e.$__isSelected(a))if(!s&&q.isPOJO(r[u]))n[u]||(n[u]={}),t(e,r[u],n[u],i,a+".");else if(s){if(n.hasOwnProperty(u)&&void 0!==r[u]&&delete n[u],null===r[u])n[u]=s._castNullish(null);else if(void 0!==r[u]){var c=(r[u].$__||{}).wasPopulated||null;if(s&&!c)try{n[u]=s.cast(r[u],e,!0)}catch(t){e.invalidate(t.path,new w({path:t.path,message:t.message,type:"cast",value:t.value,reason:t}))}else n[u]=r[u]}e.$isModified(a)||e.$__.activePaths.init(a)}else n[u]=r[u],l||o||(e[u]=r[u])}}(this,t,this._doc,e),D(this,e.populated),this.$emit("init",this),this.constructor.emit("init",this),this.$__._id=this._id,this},nt.prototype.update=function(){var t=q.args(arguments);t.unshift({_id:this._id});var e=this.constructor.update.apply(this.constructor,t);return null!=this.$session()&&("session"in e.options||(e.options.session=this.$session())),e},nt.prototype.updateOne=function(t,e,r){var n=this,i=this.constructor.updateOne({_id:this._id},t,e);return i.pre((function(t){n.constructor._middleware.execPre("updateOne",n,[n],t)})),i.post((function(t){n.constructor._middleware.execPost("updateOne",n,[n],{},t)})),null!=this.$session()&&("session"in i.options||(i.options.session=this.$session())),null!=r?i.exec(r):i},nt.prototype.replaceOne=function(){var t=q.args(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},nt.prototype.$session=function(t){if(0===arguments.length)return null!=this.$__.session&&this.$__.session.hasEnded?(this.$__.session=null,null):this.$__.session;if(null!=t&&t.hasEnded)throw new l("Cannot set a document's session to a session that has ended. Make sure you haven't called `endSession()` on the session you are passing to `$session()`.");if(this.$__.session=t,!this.$__.isSubDocument){var e,r=this.$getAllSubdocs(),n=i(r);try{for(n.s();!(e=n.n()).done;){var o=e.value;o.$session(t)}}catch(t){n.e(t)}finally{n.f()}}return t},nt.prototype.overwrite=function(t){for(var e=0,r=Array.from(new Set(Object.keys(this._doc).concat(Object.keys(t))));e<r.length;e++){var n=r[e];"_id"!==n&&(this.$__schema.options.versionKey&&n===this.$__schema.options.versionKey||this.$__schema.options.discriminatorKey&&n===this.$__schema.options.discriminatorKey||this.$set(n,t[n]))}return this},nt.prototype.$set=function(t,e,r,o){var a=this;q.isPOJO(r)&&(o=r,r=void 0);var u,h,f,c,m=(o=o||{}).merge,y=r&&!0!==r,b=!0===r,g=this.$__schema.options.typeKey,w=0,_="strict"in o?o.strict:this.$__.strictMode;if(y&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var M=[e,t];t=M[0],e=M[1]}else if("string"!=typeof t){if(t instanceof nt&&(t=t.$__isNested?t.toObject():t._doc),null==t){var O=[e,t];t=O[0],e=O[1]}c=e?e+".":"";var A=(u=$(this.$__schema,t)).length,E=k(o,"_skipMinimizeTopLevel",!1);if(0===A&&E)return delete o._skipMinimizeTopLevel,e&&this.$set(e,{}),this;for(var x=0;x<A;++x){var P=c+(f=u[x]);h=this.$__schema.pathType(P);var B=t[f];if(!0!==r||c||null==t[f]||"nested"!==h||null==this._doc[f]?o=Object.assign({},o,{_skipMinimizeTopLevel:!1}):(delete this._doc[f],o=Object.assign({},o,{_skipMinimizeTopLevel:!0})),q.isNonBuiltinObject(B)&&"nested"===h)at(t[f],c+f,this),this.$set(c+f,t[f],b,Object.assign({},o,{_skipMarkModified:!0}));else if(_){if(b&&void 0===t[f]&&void 0!==this.$get(P))continue;if("adhocOrUndefined"===h&&(h=j(this,P,{typeOnly:!0})),"real"===h||"virtual"===h){var T=t[f];this.$__schema.paths[P]&&this.$__schema.paths[P].$isSingleNested&&t[f]instanceof nt&&(T=T.toObject({virtuals:!1,transform:!1})),this.$set(c+f,T,b,o)}else if("nested"===h&&t[f]instanceof nt)this.$set(c+f,t[f].toObject({transform:!1}),b,o);else if("throw"===_)throw"nested"===h?new p(f,t[f]):new v(f)}else void 0!==t[f]&&this.$set(c+f,t[f],b,o)}for(var I=0,D=Object.keys(this.$__schema.tree);I<D.length;I++){var L=D[I];if(this._doc.hasOwnProperty(L)){var U=this._doc[L];delete this._doc[L],this._doc[L]=U}}return this}var F=this.$__schema.pathType(t);"adhocOrUndefined"===F&&(F=j(this,t,{typeOnly:!0})),e=R(e);var z,V=null!=a.$__.priorDoc?a.$__.priorDoc.$__getValue(t):b?void 0:a.$__getValue(t);if("nested"===F&&e){if("object"===s(e)&&null!=e){if(null!=e.$__&&(e=e.toObject(N)),null==e)return this.invalidate(t,new l.CastError("Object",e,t)),this;var K=null!=this.$__.savedState&&this.$__.savedState.hasOwnProperty(t);if(null!=this.$__.savedState&&!this.$isNew&&!this.$__.savedState.hasOwnProperty(t)){var H=this.$__getValue(t);this.$__.savedState[t]=H;for(var W=0,Z=Object.keys(H||{});W<Z.length;W++){var J=Z[W];this.$__.savedState[t+"."+J]=H[J]}}if(m)return this.$set(e,t,b);this.$__setValue(t,null),S(this,t);var Y=$(this.$__schema,e,t);this.$__setValue(t,{});var G,X=i(Y);try{for(X.s();!(G=X.n()).done;){var tt=G.value;this.$set(t+"."+tt,e[tt],b,o)}}catch(t){X.e(t)}finally{X.f()}return null!=V&&q.deepEqual(K?this.$__.savedState[t]:V,e)?this.unmarkModified(t):this.markModified(t),S(this,t,{skipDocArrays:!0}),this}return this.invalidate(t,new l.CastError("Object",e,t)),this}var et=-1===t.indexOf(".")?[t]:t.split(".");if("string"==typeof this.$__schema.aliases[et[0]]&&(et[0]=this.$__schema.aliases[et[0]]),"adhocOrUndefined"===F&&_){var rt;for(w=0;w<et.length;++w){var it=et.slice(0,w+1).join(".");if(w+1<et.length&&"virtual"===this.$__schema.pathType(it))return C.set(t,e,this),this;if(null!=(z=this.$__schema.path(it))&&z instanceof d){rt=!0;break}}if(null==z&&(z=j(this,t)),!rt&&!z){if("throw"===_)throw new v(t);return this}}else{if("virtual"===F)return(z=this.$__schema.virtualpath(t)).applySetters(e,this),this;z=this.$__path(t)}var ot,st=this._doc,ut="";for(w=0;w<et.length-1;++w)st=st[et[w]],ut+=(ut.length>0?".":"")+et[w],st||(this.$set(ut,{}),this.$__isSelected(ut)||this.unmarkModified(ut),st=this.$__getValue(ut));if(et.length<=1)ot=t;else{for(w=0;w<et.length;++w){var ht=et.slice(0,w+1).join(".");if(null===this.$get(ht,null,{getters:!1})){ot=ht;break}}ot||(ot=t)}if(!z)return this.$__set(ot,t,o,b,et,z,e,V),this;if((z.$isSingleNested||z.$isMongooseArray)&&
376
380
  /*!
377
381
  * ignore
378
382
  */
379
383
  function(t,e){if(!t.$__.validationError)return;for(var r=Object.keys(t.$__.validationError.errors),n=0,i=r;n<i.length;n++){var o=i[n];o.startsWith(e+".")&&delete t.$__.validationError.errors[o]}0===Object.keys(t.$__.validationError.errors).length&&(t.$__.validationError=null)}
380
384
  /*!
381
385
  * ignore
382
- */(this,t),F.$isSingleNested&&null!=e&&m){e instanceof nt&&(e=e.toObject({virtuals:!1,transform:!1}));for(var ht=0,ft=Object.keys(e);ht<ft.length;ht++){var ct=ft[ht];this.$set(t+"."+ct,e[ct],b,o)}return this}var lt=!0;try{var dt,pt=function(){if(null==F.options)return!1;if(!(e instanceof nt))return!1;var t=e.constructor,r=F.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=F.options.refPath;if(null==n)return!1;var i=e.get(n);return i===t.modelName||i===t.baseModelName}(),mt=!1;if(pt&&e instanceof nt&&(this.$populated(t,e._id,n({},Q,e.constructor)),e.$__.wasPopulated=!0,mt=!0),F.options&&Array.isArray(F.options[g])&&F.options[g].length&&F.options[g][0].ref&&
386
+ */(this,t),z.$isSingleNested&&null!=e&&m){e instanceof nt&&(e=e.toObject({virtuals:!1,transform:!1}));for(var ft=0,ct=Object.keys(e);ft<ct.length;ft++){var lt=ct[ft];this.$set(t+"."+lt,e[lt],b,o)}return this}var dt=!0;try{var pt,mt=function(){if(null==z.options)return!1;if(!(e instanceof nt))return!1;var t=e.constructor,r=z.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=z.options.refPath;if(null==n)return!1;var i=e.get(n);return i===t.modelName||i===t.baseModelName}(),yt=!1;if(mt&&e instanceof nt&&(this.$populated(t,e._id,n({},Q,e.constructor)),e.$__.wasPopulated=!0,yt=!0),z.options&&Array.isArray(z.options[g])&&z.options[g].length&&z.options[g][0].ref&&
383
387
  /*!
384
388
  * ignore
385
389
  */
386
- function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=i(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(!(o instanceof nt))return!1;if(null==o.constructor.modelName)return!1;if(o.constructor.modelName!=e&&o.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,F.options[g][0].ref)){dt=n({},Q,e[0].constructor),this.$populated(t,e.map((function(t){return t._id})),dt);var yt,bt=i(e);try{for(bt.s();!(yt=bt.n()).done;){yt.value.$__.wasPopulated=!0}}catch(t){bt.e(t)}finally{bt.f()}mt=!0}if(null==this.$__schema.singleNestedPaths[t]&&(e=F.applySetters(e,this,!1,z)),F.$isMongooseDocumentArray&&Array.isArray(e)&&e.length>0&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var vt=Object.keys(e[0].$__.populated),gt=function(){var r=_t[wt];a.$populated(t+"."+r,e.map((function(t){return t.$populated(r)})),e[0].$__.populated[r].options)},wt=0,_t=vt;wt<_t.length;wt++)gt();mt=!0}if(!mt&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var Mt=0;Mt<e.length;++Mt)e[Mt]instanceof nt&&e.set(Mt,e[Mt]._id,!0);delete this.$__.populated[t]}F.$isSingleNested&&null!=e&&function(t,e,r){var n=e.schema;if(null==n)return;for(var i=0,o=Object.keys(n.paths);i<o.length;i++){var s=o[i],a=n.paths[s];if(null!=a.$immutableSetter){var u=null==r?void 0:r.$__getValue(s);a.$immutableSetter.call(t,u)}}}(e,F,z),this.$markValid(t)}catch(r){r instanceof l.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof l.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new l.CastError(F.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new l.CastError(F.instance,e,t,r)),lt=!1}if(lt){var St=this.ownerDocument?this.ownerDocument():this,Ot=St.$__.savedState,At=this.ownerDocument?this.$__.fullPath+"."+t:t;if(null!=Ot){var Et=At.indexOf("."),xt=-1===Et?At:At.slice(0,Et);Ot.hasOwnProperty(xt)||(Ot[xt]=q.clone(St.$__getValue(xt)))}this.$__set(it,t,o,b,tt,F,e,z),null!=Ot&&Ot.hasOwnProperty(At)&&q.deepEqual(e,Ot[At])&&this.unmarkModified(t)}return F.$isSingleNested&&(this.isDirectModified(t)||null==e)&&S(this,t),this},nt.prototype.set=nt.prototype.$set,nt.prototype.$__shouldModify=function(t,e,r,n,i,o,s,a){return!r._skipMarkModified&&(!!this.$isNew||null==this.$__schema.singleNestedPaths[e]&&(void 0===s&&!this.$__isSelected(e)||(void 0!==s||!(e in this.$__.activePaths.states.default))&&(!(this.$populated(e)&&s instanceof nt&&z(s._id,a))&&(!z(s,a||q.getValue(e,this))||!(n||null==s||!(e in this.$__.activePaths.states.default)||!z(s,o.getDefault(this,n)))))))},nt.prototype.$__set=function(t,e,n,i,o,s,a,f){h=h||r(47);var c=this.$__shouldModify(t,e,n,i,o,s,a,f),l=this;c?(this.markModified(t),u||(u=r(175)),a&&a.isMongooseArray&&(a._registerAtomic("$set",a),a.isMongooseDocumentArray&&a.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=a)})),this.$__.activePaths.forEach((function(t){t.startsWith(e+".")&&l.$__.activePaths.ignore(t)})))):Array.isArray(a)&&a.isMongooseArray&&Array.isArray(f)&&f.isMongooseArray&&(a[H]=f[H],a[K]=f[K]);for(var d=this._doc,p=0,m=o.length,y="";p<m;p++){var b=p+1===m;if(y+=y?"."+o[p]:o[p],rt.has(o[p]))return;b?d instanceof Map?d.set(o[p],a):d[o[p]]=a:(q.isPOJO(d[o[p]])||d[o[p]]&&d[o[p]]instanceof h||d[o[p]]&&d[o[p]].$isSingleNested||d[o[p]]&&Array.isArray(d[o[p]])||(d[o[p]]=d[o[p]]||{}),d=d[o[p]])}},nt.prototype.$__getValue=function(t){return q.getValue(t,this._doc)},nt.prototype.$__setValue=function(t,e){return q.setValue(t,e,this._doc),this},nt.prototype.get=function(t,e,r){var n;r=r||{},e&&(n=this.$__schema.interpretAsType(t,e,this.$__schema.options));var i=this.$__path(t);if(null==i&&(i=this.$__schema.virtualpath(t)),i instanceof d){var o=this.$__schema.virtualpath(t);null!=o&&(i=o)}var s=-1===t.indexOf(".")?[t]:t.split("."),a=this._doc;if(i instanceof _)return i.applyGetters(void 0,this);"string"==typeof this.$__schema.aliases[s[0]]&&(s[0]=this.$__schema.aliases[s[0]]);for(var u=0,h=s.length;u<h;u++)a&&a._doc&&(a=a._doc),a=null==a?void 0:a instanceof Map?a.get(s[u],{getters:!1}):u===h-1?q.getValue(s[u],a):a[s[u]];if(n&&(a=n.cast(a)),null!=i&&!1!==r.getters)a=i.applyGetters(a,this);else if(this.$__schema.nested[t]&&r.virtuals)return dt(this,q.clone(a)||{},{path:t});return a},
390
+ function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=i(t);try{for(n.s();!(r=n.n()).done;){var o=r.value;if(!(o instanceof nt))return!1;if(null==o.constructor.modelName)return!1;if(o.constructor.modelName!=e&&o.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,z.options[g][0].ref)){pt=n({},Q,e[0].constructor),this.$populated(t,e.map((function(t){return t._id})),pt);var bt,vt=i(e);try{for(vt.s();!(bt=vt.n()).done;){bt.value.$__.wasPopulated=!0}}catch(t){vt.e(t)}finally{vt.f()}yt=!0}if(null==this.$__schema.singleNestedPaths[t]&&(e=z.applySetters(e,this,!1,V)),z.$isMongooseDocumentArray&&Array.isArray(e)&&e.length>0&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var gt=Object.keys(e[0].$__.populated),wt=function(){var r=Mt[_t];a.$populated(t+"."+r,e.map((function(t){return t.$populated(r)})),e[0].$__.populated[r].options)},_t=0,Mt=gt;_t<Mt.length;_t++)wt();yt=!0}if(!yt&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var St=0;St<e.length;++St)e[St]instanceof nt&&e.set(St,e[St]._id,!0);delete this.$__.populated[t]}z.$isSingleNested&&null!=e&&function(t,e,r){var n=e.schema;if(null==n)return;for(var i=0,o=Object.keys(n.paths);i<o.length;i++){var s=o[i],a=n.paths[s];if(null!=a.$immutableSetter){var u=null==r?void 0:r.$__getValue(s);a.$immutableSetter.call(t,u)}}}(e,z,V),this.$markValid(t)}catch(r){r instanceof l.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof l.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new l.CastError(z.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new l.CastError(z.instance,e,t,r)),dt=!1}if(dt){var Ot=this.$__.isSubDocument?this.ownerDocument():this,At=Ot.$__.savedState,Et=this.$__.isSubDocument?this.$__.fullPath+"."+t:t;if(null!=At){var xt=Et.indexOf("."),kt=-1===xt?Et:Et.slice(0,xt);At.hasOwnProperty(kt)||(At[kt]=q.clone(Ot.$__getValue(kt)))}this.$__set(ot,t,o,b,et,z,e,V),null!=At&&At.hasOwnProperty(Et)&&q.deepEqual(e,At[Et])&&this.unmarkModified(t)}return z.$isSingleNested&&(this.isDirectModified(t)||null==e)&&S(this,t),this},nt.prototype.set=nt.prototype.$set,nt.prototype.$__shouldModify=function(t,e,r,n,i,o,s,a){return!r._skipMarkModified&&(!!this.$isNew||null==this.$__schema.singleNestedPaths[e]&&(void 0===s&&!this.$__isSelected(e)||(void 0!==s||!(e in this.$__.activePaths.states.default))&&(!(this.$populated(e)&&s instanceof nt&&z(s._id,a))&&(!z(s,a||q.getValue(e,this))||!(n||null==s||!(e in this.$__.activePaths.states.default)||!z(s,o.getDefault(this,n)))))))},nt.prototype.$__set=function(t,e,n,i,o,s,a,f){h=h||r(47);var c=this.$__shouldModify(t,e,n,i,o,s,a,f),l=this;c?(this.markModified(t),u||(u=r(175)),a&&a.isMongooseArray&&(a._registerAtomic("$set",a),a.isMongooseDocumentArray&&a.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=a)})),this.$__.activePaths.forEach((function(t){t.startsWith(e+".")&&l.$__.activePaths.ignore(t)})))):Array.isArray(a)&&a.isMongooseArray&&Array.isArray(f)&&f.isMongooseArray&&(a[H]=f[H],a[K]=f[K]);for(var d=this._doc,p=0,m=o.length,y="";p<m;p++){var b=p+1===m;if(y+=y?"."+o[p]:o[p],rt.has(o[p]))return;b?d instanceof Map?d.set(o[p],a):d[o[p]]=a:(q.isPOJO(d[o[p]])||d[o[p]]&&d[o[p]]instanceof h||d[o[p]]&&d[o[p]].$isSingleNested||d[o[p]]&&Array.isArray(d[o[p]])||(d[o[p]]=d[o[p]]||{}),d=d[o[p]])}},nt.prototype.$__getValue=function(t){return q.getValue(t,this._doc)},nt.prototype.$__setValue=function(t,e){return q.setValue(t,e,this._doc),this},nt.prototype.get=function(t,e,r){var n;r=r||{},e&&(n=this.$__schema.interpretAsType(t,e,this.$__schema.options));var i=this.$__path(t);if(null==i&&(i=this.$__schema.virtualpath(t)),i instanceof d){var o=this.$__schema.virtualpath(t);null!=o&&(i=o)}var s=-1===t.indexOf(".")?[t]:t.split("."),a=this._doc;if(i instanceof _)return i.applyGetters(void 0,this);"string"==typeof this.$__schema.aliases[s[0]]&&(s[0]=this.$__schema.aliases[s[0]]);for(var u=0,h=s.length;u<h;u++)a&&a._doc&&(a=a._doc),a=null==a?void 0:a instanceof Map?a.get(s[u],{getters:!1}):u===h-1?q.getValue(s[u],a):a[s[u]];if(n&&(a=n.cast(a)),null!=i&&!1!==r.getters)a=i.applyGetters(a,this);else if(this.$__schema.nested[t]&&r.virtuals)return dt(this,q.clone(a)||{},{path:t});return a},
387
391
  /*!
388
392
  * ignore
389
393
  */
390
- nt.prototype[G]=nt.prototype.get,nt.prototype.$get=nt.prototype.get,nt.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e.hasOwnProperty(t)?e[t]:null;return r||this.$__schema.path(t)},nt.prototype.markModified=function(t,e){this.$__.activePaths.modify(t),null==e||this.ownerDocument||(this.$__.pathsToScopes=this.$__pathsToScopes||{},this.$__.pathsToScopes[t]=e)},nt.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),null!=this.$__.pathsToScopes&&delete this.$__.pathsToScopes[t]},nt.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},nt.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.states.modify)},nt.prototype.$isEmpty=function(t){var e={minimize:!0,virtuals:!1,getters:!1,transform:!1};if(arguments.length>0){var r=this.$get(t);return null==r||"object"===s(r)&&(q.isPOJO(r)?ut(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},nt.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.states.modify),r=this;return e.reduce((function(e,n){var o=n.split(".");if(e=e.concat(o.reduce((function(t,e,r){return t.concat(o.slice(0,r).concat(e).join("."))}),[]).filter((function(t){return-1===e.indexOf(t)}))),!t.includeChildren)return e;var a=r.$get(n);if(null!=a&&"object"===s(a))if(a._doc&&(a=a._doc),Array.isArray(a)){for(var u=a.length,h=0;h<u;++h)if(-1===e.indexOf(n+"."+h)&&(e.push(n+"."+h),null!=a[h]&&a[h].$__)){var f,c=i(a[h].modifiedPaths());try{for(c.s();!(f=c.n()).done;){var l=f.value;e.push(n+"."+h+"."+l)}}catch(t){c.e(t)}finally{c.f()}}}else Object.keys(a).filter((function(t){return-1===e.indexOf(n+"."+t)})).forEach((function(t){e.push(n+"."+t)}));return e}),[])},nt.prototype[J]=nt.prototype.modifiedPaths,nt.prototype.isModified=function(t,e){if(t){Array.isArray(t)||(t=t.split(" "));var r=e||this[J](),n=Object.keys(this.$__.activePaths.states.modify);return t.some((function(t){return!!~r.indexOf(t)}))||t.some((function(t){return n.some((function(e){return e===t||t.startsWith(e+".")}))}))}return this.$__.activePaths.some("modify")},nt.prototype.$isModified=nt.prototype.isModified,nt.prototype[Z]=nt.prototype.isModified,nt.prototype.$isDefault=function(t){var e=this;if(null==t)return this.$__.activePaths.some("default");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.default.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.default.hasOwnProperty(t)}))},nt.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},nt.prototype.isDirectModified=function(t){var e=this;if(null==t)return this.$__.activePaths.some("modify");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.modify.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.modify.hasOwnProperty(t)}))},nt.prototype.isInit=function(t){var e=this;if(null==t)return this.$__.activePaths.some("init");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.init.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.init.hasOwnProperty(t)}))},nt.prototype.isSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.$__isSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var s=o[i];if("_id"!==s&&B(this.$__.selected[s])){n=!!this.$__.selected[s];break}}if(null===n)return!0;if(t in this.$__.selected)return n;for(var a=t+".",u=0,h=r;u<h.length;u++){var f=h[u];if("_id"!==f){if(f.startsWith(a))return n||f!==a;if(a.startsWith(f+"."))return n}}return!n},nt.prototype.$__isSelected=nt.prototype.isSelected,nt.prototype.isDirectSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.isDirectSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var s=o[i];if("_id"!==s&&B(this.$__.selected[s])){n=!!this.$__.selected[s];break}}return null===n||(this.$__.selected.hasOwnProperty(t)?n:!n)},nt.prototype.validate=function(t,e,r){var n,i=this;if(this.$op="validate",null!=this.ownerDocument||(this.$__.validating?n=new y(this,{parentStack:e&&e.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new y(this,{parentStack:e&&e.parentStack})),1===arguments.length?"object"!==s(arguments[0])||Array.isArray(arguments[0])?"function"==typeof arguments[0]&&(r=arguments[0],e=null,t=null):(e=arguments[0],r=null,t=null):"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=t,t=null),e&&"string"==typeof e.pathsToSkip){var o=-1===e.pathsToSkip.indexOf(" ");e.pathsToSkip=o?[e.pathsToSkip]:e.pathsToSkip.split(" ")}return M(r,(function(r){if(null!=n)return r(n);i.$__validate(t,e,(function(t){i.$op=null,r(t)}))}),this.constructor.events)},nt.prototype.$validate=nt.prototype.validate,nt.prototype.$__validate=function(t,e,r){var n=this;"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=null);var o,a=e&&"object"===s(e)&&"validateModifiedOnly"in e,u=k(e,"pathsToSkip",null);o=a?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var h=this,f=function(){var t=n.$__.validationError;if(n.$__.validationError=void 0,o&&null!=t){for(var e=0,r=Object.keys(t.errors);e<r.length;e++){var i=r[e];n.$isModified(i)||delete t.errors[i]}0===Object.keys(t.errors).length&&(t=void 0)}if(n.$__.cachedRequired={},n.$emit("validate",h),n.constructor.emit("validate",h),t){for(var s in t.errors)!n[W]&&t.errors[s]instanceof l.CastError&&n.invalidate(s,t.errors[s]);return t}},c=ht(this),d=o?c[0].filter((function(t){return n.$isModified(t)})):c[0],p=c[1];if("string"==typeof t&&(t=t.split(" ")),Array.isArray(t)?d=ft(d,t):u&&(d=ct(d,u)),0===d.length)return P((function(){var t=f();if(t)return h.$__schema.s.hooks.execPost("validate:error",h,[h],{error:t},(function(t){r(t)}));r(null,h)}));var m,y={},b=0,v=i(d);try{for(v.s();!(m=v.n()).done;){w(m.value)}}catch(t){v.e(t)}finally{v.f()}function w(t){null==t||y[t]||(y[t]=!0,b++,P((function(){var e=h.$__schema.path(t);if(!e)return--b||_();if(h.$isValid(t)){if(null!=e[tt]&&t!==e.path)return--b||_();var r,n=h.$__getValue(t);(r=h.$populated(t))?n=r:null!=n&&null!=n.$__&&n.$__.wasPopulated&&(n=n._id);var i=null!=h.$__.pathsToScopes&&t in h.$__.pathsToScopes?h.$__.pathsToScopes[t]:h,s={skipSchemaValidators:p[t],path:t,validateModifiedOnly:o};e.doValidate(n,(function(r){if(r){if((e.$isSingleNested||e.$isArraySubdocument||e.$isMongooseDocumentArray)&&r instanceof g)return--b||_();h.invalidate(t,r,void 0,!0)}--b||_()}),i,s)}else--b||_()})))}function _(){var t=f();if(t)return h.$__schema.s.hooks.execPost("validate:error",h,[h],{error:t},(function(t){r(t)}));r(null,h)}},nt.prototype.validateSync=function(t,e){var r=this,n=this;1!==arguments.length||"object"!==s(arguments[0])||Array.isArray(arguments[0])||(e=arguments[0],t=null);var i,o=e&&"object"===s(e)&&"validateModifiedOnly"in e;i=o?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var a=e&&e.pathsToSkip;if("string"==typeof t){var u=-1===t.indexOf(" ");t=u?[t]:t.split(" ")}else"string"==typeof a&&-1!==a.indexOf(" ")&&(a=a.split(" "));var h=ht(this),f=i?h[0].filter((function(t){return r.$isModified(t)})):h[0],c=h[1];Array.isArray(t)?f=ft(f,t):Array.isArray(a)&&(f=ct(f,a));var d={};f.forEach((function(t){if(!d[t]){d[t]=!0;var e=n.$__schema.path(t);if(e&&n.$isValid(t)){var r=n.$__getValue(t),o=e.doValidateSync(r,n,{skipSchemaValidators:c[t],path:t,validateModifiedOnly:i});if(o){if((e.$isSingleNested||e.$isArraySubdocument||e.$isMongooseDocumentArray)&&o instanceof g)return;n.invalidate(t,o,void 0,!0)}}}}));var p=n.$__.validationError;if(n.$__.validationError=void 0,n.$emit("validate",n),n.constructor.emit("validate",n),p)for(var m in p.errors)p.errors[m]instanceof l.CastError&&n.invalidate(m,p.errors[m]);return p},nt.prototype.invalidate=function(t,e,r,n){if(this.$__.validationError||(this.$__.validationError=new g(this)),!this.$__.validationError.errors[t])return e&&"string"!=typeof e||(e=new w({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e||this.$__.validationError.addError(t,e),this.$__.validationError},nt.prototype.$markValid=function(t){this.$__.validationError&&this.$__.validationError.errors[t]&&(delete this.$__.validationError.errors[t],0===Object.keys(this.$__.validationError.errors).length&&(this.$__.validationError=null))},nt.prototype.$isValid=function(t){var e=this;return null==this.$__.validationError||0===Object.keys(this.$__.validationError.errors).length||null!=t&&(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t)?t.some((function(t){return null==e.$__.validationError.errors[t]})):null==this.$__.validationError.errors[t])},nt.prototype.$__reset=function(){var t=this;return a||(a=r(27)),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length})).forEach((function(e){for(var r=e.length;r--;){var n=e[r];n&&n.$__reset()}t.$__.activePaths.init(e.$path()),e[K]=e[H],e[H]={}})),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t.$isSingleNested})).forEach((function(e){e.$__reset(),e.$parent()===t?t.$__.activePaths.init(e.$basePath):null!=e.$parent()&&e.$parent().ownerDocument&&e.$parent().$__reset()})),this.$__dirty().forEach((function(t){var e=t.value;e&&e[H]&&(e[K]=e[H],e[H]={})})),this.$__.backup={},this.$__.backup.activePaths={modify:Object.assign({},this.$__.activePaths.states.modify),default:Object.assign({},this.$__.activePaths.states.default)},this.$__.backup.validationError=this.$__.validationError,this.$__.backup.errors=this.$errors,this.$__.activePaths.clear("modify"),this.$__.activePaths.clear("default"),this.$__.validationError=void 0,this.$errors=void 0,t=this,this.$__schema.requiredPaths().forEach((function(e){t.$__.activePaths.require(e)})),this},
394
+ nt.prototype[G]=nt.prototype.get,nt.prototype.$get=nt.prototype.get,nt.prototype.$__path=function(t){var e=this.$__.adhocPaths,r=e&&e.hasOwnProperty(t)?e[t]:null;return r||this.$__schema.path(t)},nt.prototype.markModified=function(t,e){this.$__.activePaths.modify(t),null==e||this.$__.isSubDocument||(this.$__.pathsToScopes=this.$__pathsToScopes||{},this.$__.pathsToScopes[t]=e)},nt.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),null!=this.$__.pathsToScopes&&delete this.$__.pathsToScopes[t]},nt.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},nt.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.states.modify)},nt.prototype.$isEmpty=function(t){var e={minimize:!0,virtuals:!1,getters:!1,transform:!1};if(arguments.length>0){var r=this.$get(t);return null==r||"object"===s(r)&&(q.isPOJO(r)?ut(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},nt.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.states.modify),r=this;return e.reduce((function(e,n){var o=n.split(".");if(e=e.concat(o.reduce((function(t,e,r){return t.concat(o.slice(0,r).concat(e).join("."))}),[]).filter((function(t){return-1===e.indexOf(t)}))),!t.includeChildren)return e;var a=r.$get(n);if(null!=a&&"object"===s(a))if(a._doc&&(a=a._doc),Array.isArray(a)){for(var u=a.length,h=0;h<u;++h)if(-1===e.indexOf(n+"."+h)&&(e.push(n+"."+h),null!=a[h]&&a[h].$__)){var f,c=i(a[h].modifiedPaths());try{for(c.s();!(f=c.n()).done;){var l=f.value;e.push(n+"."+h+"."+l)}}catch(t){c.e(t)}finally{c.f()}}}else Object.keys(a).filter((function(t){return-1===e.indexOf(n+"."+t)})).forEach((function(t){e.push(n+"."+t)}));return e}),[])},nt.prototype[J]=nt.prototype.modifiedPaths,nt.prototype.isModified=function(t,e){if(t){Array.isArray(t)||(t=t.split(" "));var r=e||this[J](),n=Object.keys(this.$__.activePaths.states.modify);return t.some((function(t){return!!~r.indexOf(t)}))||t.some((function(t){return n.some((function(e){return e===t||t.startsWith(e+".")}))}))}return this.$__.activePaths.some("modify")},nt.prototype.$isModified=nt.prototype.isModified,nt.prototype[Z]=nt.prototype.isModified,nt.prototype.$isDefault=function(t){var e=this;if(null==t)return this.$__.activePaths.some("default");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.default.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.default.hasOwnProperty(t)}))},nt.prototype.$isDeleted=function(t){return 0===arguments.length?!!this.$__.isDeleted:(this.$__.isDeleted=!!t,this)},nt.prototype.isDirectModified=function(t){var e=this;if(null==t)return this.$__.activePaths.some("modify");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.modify.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.modify.hasOwnProperty(t)}))},nt.prototype.isInit=function(t){var e=this;if(null==t)return this.$__.activePaths.some("init");if("string"==typeof t&&-1===t.indexOf(" "))return this.$__.activePaths.states.init.hasOwnProperty(t);var r=t;return Array.isArray(r)||(r=r.split(" ")),r.some((function(t){return e.$__.activePaths.states.init.hasOwnProperty(t)}))},nt.prototype.isSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.$__isSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var s=o[i];if("_id"!==s&&B(this.$__.selected[s])){n=!!this.$__.selected[s];break}}if(null===n)return!0;if(t in this.$__.selected)return n;for(var a=t+".",u=0,h=r;u<h.length;u++){var f=h[u];if("_id"!==f){if(f.startsWith(a))return n||f!==a;if(a.startsWith(f+"."))return n}}return!n},nt.prototype.$__isSelected=nt.prototype.isSelected,nt.prototype.isDirectSelected=function(t){var e=this;if(null==this.$__.selected)return!0;if("_id"===t)return 0!==this.$__.selected._id;if(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t))return t.some((function(t){return e.isDirectSelected(t)}));var r=Object.keys(this.$__.selected),n=null;if(1===r.length&&"_id"===r[0])return 0===this.$__.selected._id;for(var i=0,o=r;i<o.length;i++){var s=o[i];if("_id"!==s&&B(this.$__.selected[s])){n=!!this.$__.selected[s];break}}return null===n||(this.$__.selected.hasOwnProperty(t)?n:!n)},nt.prototype.validate=function(t,e,r){var n,i=this;if(this.$op="validate",null!=this.$__.isSubDocument||(this.$__.validating?n=new y(this,{parentStack:e&&e.parentStack,conflictStack:this.$__.validating.stack}):this.$__.validating=new y(this,{parentStack:e&&e.parentStack})),1===arguments.length?"object"!==s(arguments[0])||Array.isArray(arguments[0])?"function"==typeof arguments[0]&&(r=arguments[0],e=null,t=null):(e=arguments[0],r=null,t=null):"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=t,t=null),e&&"string"==typeof e.pathsToSkip){var o=-1===e.pathsToSkip.indexOf(" ");e.pathsToSkip=o?[e.pathsToSkip]:e.pathsToSkip.split(" ")}return M(r,(function(r){if(null!=n)return r(n);i.$__validate(t,e,(function(t){i.$op=null,r(t)}))}),this.constructor.events)},nt.prototype.$validate=nt.prototype.validate,nt.prototype.$__validate=function(t,e,r){var n=this;"function"==typeof t?(r=t,e=null,t=null):"function"==typeof e&&(r=e,e=null);var o,a=e&&"object"===s(e)&&"validateModifiedOnly"in e,u=k(e,"pathsToSkip",null);o=a?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var h=this,f=function(){var t=n.$__.validationError;if(n.$__.validationError=void 0,o&&null!=t){for(var e=0,r=Object.keys(t.errors);e<r.length;e++){var i=r[e];n.$isModified(i)||delete t.errors[i]}0===Object.keys(t.errors).length&&(t=void 0)}if(n.$__.cachedRequired={},n.$emit("validate",h),n.constructor.emit("validate",h),t){for(var s in t.errors)!n[W]&&t.errors[s]instanceof l.CastError&&n.invalidate(s,t.errors[s]);return t}},c=ht(this),d=o?c[0].filter((function(t){return n.$isModified(t)})):c[0],p=c[1];if("string"==typeof t&&(t=t.split(" ")),Array.isArray(t)?d=ft(d,t):u&&(d=ct(d,u)),0===d.length)return P((function(){var t=f();if(t)return h.$__schema.s.hooks.execPost("validate:error",h,[h],{error:t},(function(t){r(t)}));r(null,h)}));var m,y={},b=0,v=i(d);try{for(v.s();!(m=v.n()).done;){w(m.value)}}catch(t){v.e(t)}finally{v.f()}function w(t){null==t||y[t]||(y[t]=!0,b++,P((function(){var e=h.$__schema.path(t);if(!e)return--b||_();if(h.$isValid(t)){if(null!=e[tt]&&t!==e.path)return--b||_();var r,n=h.$__getValue(t);(r=h.$populated(t))?n=r:null!=n&&null!=n.$__&&n.$__.wasPopulated&&(n=n._id);var i=null!=h.$__.pathsToScopes&&t in h.$__.pathsToScopes?h.$__.pathsToScopes[t]:h,s={skipSchemaValidators:p[t],path:t,validateModifiedOnly:o};e.doValidate(n,(function(r){if(r){if((e.$isSingleNested||e.$isArraySubdocument||e.$isMongooseDocumentArray)&&r instanceof g)return--b||_();h.invalidate(t,r,void 0,!0)}--b||_()}),i,s)}else--b||_()})))}function _(){var t=f();if(t)return h.$__schema.s.hooks.execPost("validate:error",h,[h],{error:t},(function(t){r(t)}));r(null,h)}},nt.prototype.validateSync=function(t,e){var r=this,n=this;1!==arguments.length||"object"!==s(arguments[0])||Array.isArray(arguments[0])||(e=arguments[0],t=null);var i,o=e&&"object"===s(e)&&"validateModifiedOnly"in e;i=o?!!e.validateModifiedOnly:this.$__schema.options.validateModifiedOnly;var a=e&&e.pathsToSkip;if("string"==typeof t){var u=-1===t.indexOf(" ");t=u?[t]:t.split(" ")}else"string"==typeof a&&-1!==a.indexOf(" ")&&(a=a.split(" "));var h=ht(this),f=i?h[0].filter((function(t){return r.$isModified(t)})):h[0],c=h[1];Array.isArray(t)?f=ft(f,t):Array.isArray(a)&&(f=ct(f,a));var d={};f.forEach((function(t){if(!d[t]){d[t]=!0;var e=n.$__schema.path(t);if(e&&n.$isValid(t)){var r=n.$__getValue(t),o=e.doValidateSync(r,n,{skipSchemaValidators:c[t],path:t,validateModifiedOnly:i});if(o){if((e.$isSingleNested||e.$isArraySubdocument||e.$isMongooseDocumentArray)&&o instanceof g)return;n.invalidate(t,o,void 0,!0)}}}}));var p=n.$__.validationError;if(n.$__.validationError=void 0,n.$emit("validate",n),n.constructor.emit("validate",n),p)for(var m in p.errors)p.errors[m]instanceof l.CastError&&n.invalidate(m,p.errors[m]);return p},nt.prototype.invalidate=function(t,e,r,n){if(this.$__.validationError||(this.$__.validationError=new g(this)),!this.$__.validationError.errors[t])return e&&"string"!=typeof e||(e=new w({path:t,message:e,type:n||"user defined",value:r})),this.$__.validationError===e||this.$__.validationError.addError(t,e),this.$__.validationError},nt.prototype.$markValid=function(t){this.$__.validationError&&this.$__.validationError.errors[t]&&(delete this.$__.validationError.errors[t],0===Object.keys(this.$__.validationError.errors).length&&(this.$__.validationError=null))},nt.prototype.$isValid=function(t){var e=this;return null==this.$__.validationError||0===Object.keys(this.$__.validationError.errors).length||null!=t&&(-1!==t.indexOf(" ")&&(t=t.split(" ")),Array.isArray(t)?t.some((function(t){return null==e.$__.validationError.errors[t]})):null==this.$__.validationError.errors[t])},nt.prototype.$__reset=function(){var t=this;return a||(a=r(27)),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t instanceof Array&&t.isMongooseDocumentArray&&t.length})).forEach((function(e){for(var r=e.length;r--;){var n=e[r];n&&n.$__reset()}t.$__.activePaths.init(e.$path()),e[K]=e[H],e[H]={}})),this.$__.activePaths.map("init","modify",(function(e){return t.$__getValue(e)})).filter((function(t){return t&&t.$isSingleNested})).forEach((function(e){e.$__reset(),e.$parent()===t?t.$__.activePaths.init(e.$basePath):null!=e.$parent()&&e.$parent().$__.isSubDocument&&e.$parent().$__reset()})),this.$__dirty().forEach((function(t){var e=t.value;e&&e[H]&&(e[K]=e[H],e[H]={})})),this.$__.backup={},this.$__.backup.activePaths={modify:Object.assign({},this.$__.activePaths.states.modify),default:Object.assign({},this.$__.activePaths.states.default)},this.$__.backup.validationError=this.$__.validationError,this.$__.backup.errors=this.$errors,this.$__.activePaths.clear("modify"),this.$__.activePaths.clear("default"),this.$__.validationError=void 0,this.$errors=void 0,t=this,this.$__schema.requiredPaths().forEach((function(e){t.$__.activePaths.require(e)})),this},
391
395
  /*!
392
396
  * ignore
393
397
  */
@@ -405,7 +409,7 @@ nt.prototype.$__undoReset=function(){if(null!=this.$__.backup&&null!=this.$__.ba
405
409
  * @param {Object} object to minimize
406
410
  * @return {Object}
407
411
  */
408
- function t(e){var r,n,i,o=Object.keys(e),s=o.length;for(;s--;)n=o[s],i=e[n],q.isPOJO(i)&&(e[n]=t(i)),void 0!==e[n]?r=!0:delete e[n];return r?e:void 0}(c)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&dt(this,c,h,t),!1===t.versionKey&&this.$__schema.options.versionKey&&delete c[this.$__schema.options.versionKey];var l=t.transform;if(l&&function(t,e){var r=t.$__schema,n=Object.keys(r.paths||{});if(!t._doc)return e;for(var i=0,o=n;i<o.length;i++){var s=o[i],a=r.paths[s];if("function"==typeof a.options.transform){var u=t.$get(s),h=a.options.transform.call(t,u);pt(s,h),q.setValue(s,h,e)}else if(null!=a.$embeddedSchemaType&&"function"==typeof a.$embeddedSchemaType.options.transform){for(var f=[].concat(t.$get(s)),c=a.$embeddedSchemaType.options.transform,l=0;l<f.length;++l){var d=c.call(t,f[l]);f[l]=d,pt(s,d)}e[s]=f}}}(this,c),t.useProjection&&function(t,e){var r=t.$__schema,n=Object.keys(r.paths||{});if(!t._doc)return e;var i=t.$__.selected;void 0===i&&(i={},L.applyPaths(i,r));if(null==i||0===Object.keys(i).length)return e;for(var o=0,s=n;o<s.length;o++){var a=s[o];null==i[a]||i[a]||delete e[a]}}(this,c),!0===l||a.toObject&&l){var d=t.json?a.toJSON:a.toObject;d&&(l="function"==typeof t.transform?t.transform:d.transform)}else t.transform=f;if("function"==typeof l){var p=l(this,c,t);void 0!==p&&(c=p)}return c},nt.prototype.toObject=function(t){return this.$toObject(t)},nt.prototype.toJSON=function(t){return this.$toObject(t,!0)},nt.prototype.parent=function(){return this.$__.parent},nt.prototype.$parent=nt.prototype.parent,nt.prototype.inspect=function(t){var e;q.isPOJO(t)&&((e=t).minimize=!1);var r=this.toObject(e);return null==r?"MongooseDocument { "+r+" }":r},I.custom&&(
412
+ function t(e){var r,n,i,o=Object.keys(e),s=o.length;for(;s--;)n=o[s],i=e[n],q.isPOJO(i)&&(e[n]=t(i)),void 0!==e[n]?r=!0:delete e[n];return r?e:void 0}(c)||{})),(t.virtuals||t.getters&&!1!==t.virtuals)&&dt(this,c,h,t),!1===t.versionKey&&this.$__schema.options.versionKey&&delete c[this.$__schema.options.versionKey];var l=t.transform;if(l&&function(t,e){var r=t.$__schema,n=Object.keys(r.paths||{});if(!t._doc)return e;for(var i=0,o=n;i<o.length;i++){var s=o[i],a=r.paths[s];if("function"==typeof a.options.transform){var u=t.$get(s),h=a.options.transform.call(t,u);pt(s,h),q.setValue(s,h,e)}else if(null!=a.$embeddedSchemaType&&"function"==typeof a.$embeddedSchemaType.options.transform){for(var f=[].concat(t.$get(s)),c=a.$embeddedSchemaType.options.transform,l=0;l<f.length;++l){var d=c.call(t,f[l]);f[l]=d,pt(s,d)}e[s]=f}}}(this,c),t.useProjection&&function(t,e){var r=t.$__schema,n=Object.keys(r.paths||{});if(!t._doc)return e;var i=t.$__.selected;void 0===i&&(i={},L.applyPaths(i,r));if(null==i||0===Object.keys(i).length)return e;for(var o=0,s=n;o<s.length;o++){var a=s[o];null==i[a]||i[a]||delete e[a]}}(this,c),!0===l||a.toObject&&l){var d=t.json?a.toJSON:a.toObject;d&&(l="function"==typeof t.transform?t.transform:d.transform)}else t.transform=f;if("function"==typeof l){var p=l(this,c,t);void 0!==p&&(c=p)}return c},nt.prototype.toObject=function(t){return this.$toObject(t)},nt.prototype.toJSON=function(t){return this.$toObject(t,!0)},nt.prototype.ownerDocument=function(){return this},nt.prototype.parent=function(){return this.$__.isSubDocument||this.$__.wasPopulated?this.$__.parent:this},nt.prototype.$parent=nt.prototype.parent,nt.prototype.inspect=function(t){var e;q.isPOJO(t)&&((e=t).minimize=!1);var r=this.toObject(e);return null==r?"MongooseDocument { "+r+" }":r},I.custom&&(
409
413
  /*!
410
414
  * Avoid Node deprecation warning DEP0079
411
415
  */
@@ -737,7 +741,7 @@ function _(t,e){var r,i,s,a=null==t?null:f(t[y],"caster.options.ref",null);0===t
737
741
  /*!
738
742
  * ignore
739
743
  */
740
- function(t,e){if(!e)return!1;var r,i=n(t);try{for(i.s();!(r=i.n()).done;){var s=r.value;if(null==s)return!1;var a=s.constructor;if(!(s instanceof o)||a.modelName!==e&&a.baseModelName!==e)return!1}}catch(t){i.e(t)}finally{i.f()}return!0}(e,a)&&t[p].$populated(t[m],[],(r={},i=b,s=e[0].constructor,i in r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,r))}for(var M=function(){var t=O[S];if(null==Array.prototype[t])return"continue";w[t]=function(){var e=this.isMongooseArrayProxy?this.__array:this,r=[].concat(e);return r[t].apply(r,arguments)}},S=0,O=["filter","flat","flatMap","map","slice"];S<O.length;S++)M();t.exports=w}).call(this,r(3).Buffer)},function(t,e,r){"use strict";var n=r(14),i=r(45),o=r(38).internalToObjectOptions,s=r(54),a=r(9),u=r(4);function h(t,e,r,i,o){if(null!=r){var s={isNew:r.isNew,defaults:!("defaults"in r.$__)||r.$__.defaults};o=Object.assign({},s,o)}null!=o&&null!=o.path&&(this.$basePath=o.path),n.call(this,t,e,i,o),delete this.$__.priorDoc}t.exports=h,h.prototype=Object.create(n.prototype),Object.defineProperty(h.prototype,"$isSingleNested",{configurable:!1,writable:!1,value:!0}),
744
+ function(t,e){if(!e)return!1;var r,i=n(t);try{for(i.s();!(r=i.n()).done;){var s=r.value;if(null==s)return!1;var a=s.constructor;if(!(s instanceof o)||a.modelName!==e&&a.baseModelName!==e)return!1}}catch(t){i.e(t)}finally{i.f()}return!0}(e,a)&&t[p].$populated(t[m],[],(r={},i=b,s=e[0].constructor,i in r?Object.defineProperty(r,i,{value:s,enumerable:!0,configurable:!0,writable:!0}):r[i]=s,r))}for(var M=function(){var t=O[S];if(null==Array.prototype[t])return"continue";w[t]=function(){var e=this.isMongooseArrayProxy?this.__array:this,r=[].concat(e);return r[t].apply(r,arguments)}},S=0,O=["filter","flat","flatMap","map","slice"];S<O.length;S++)M();t.exports=w}).call(this,r(3).Buffer)},function(t,e,r){"use strict";var n=r(14),i=r(45),o=r(38).internalToObjectOptions,s=r(54),a=r(9),u=r(4);function h(t,e,r,i,o){if(null!=r){var s={isNew:r.isNew,defaults:!("defaults"in r.$__)||r.$__.defaults};o=Object.assign({},s,o)}null!=o&&null!=o.path&&(this.$basePath=o.path),n.call(this,t,e,i,o),this.$__.isSubDocument=!0,delete this.$__.priorDoc}t.exports=h,h.prototype=Object.create(n.prototype),Object.defineProperty(h.prototype,"$isSingleNested",{configurable:!1,writable:!1,value:!0}),
741
745
  /*!
742
746
  * ignore
743
747
  */
@@ -1041,7 +1045,7 @@ t.exports=n},function(t,e,r){"use strict";
1041
1045
  t.exports.setBrowser=function(t){o=t}},function(t,e,r){"use strict";
1042
1046
  /*!
1043
1047
  * Dependencies
1044
- */var n=r(294).ctor("require","modify","init","default","ignore");function i(){this.activePaths=new n,this.ownerDocument=void 0,this.fullPath=void 0}t.exports=i,i.prototype.strictMode=void 0,i.prototype.selected=void 0,i.prototype.shardval=void 0,i.prototype.saveError=void 0,i.prototype.validationError=void 0,i.prototype.adhocPaths=void 0,i.prototype.removing=void 0,i.prototype.inserting=void 0,i.prototype.saving=void 0,i.prototype.version=void 0,i.prototype._id=void 0,i.prototype.populate=void 0,i.prototype.populated=void 0,i.prototype.wasPopulated=!1,i.prototype.scope=void 0,i.prototype.session=null,i.prototype.pathsToScopes=null,i.prototype.cachedRequired=null},function(t,e,r){"use strict";
1048
+ */var n=r(294).ctor("require","modify","init","default","ignore");function i(){this.activePaths=new n,this.ownerDocument=void 0,this.isSubDocument=void 0,this.fullPath=void 0}t.exports=i,i.prototype.strictMode=void 0,i.prototype.selected=void 0,i.prototype.shardval=void 0,i.prototype.saveError=void 0,i.prototype.validationError=void 0,i.prototype.adhocPaths=void 0,i.prototype.removing=void 0,i.prototype.inserting=void 0,i.prototype.saving=void 0,i.prototype.version=void 0,i.prototype._id=void 0,i.prototype.populate=void 0,i.prototype.populated=void 0,i.prototype.wasPopulated=!1,i.prototype.scope=void 0,i.prototype.session=null,i.prototype.pathsToScopes=null,i.prototype.cachedRequired=null},function(t,e,r){"use strict";
1045
1049
  /*!
1046
1050
  * Module dependencies.
1047
1051
  */var n=r(4),i=t.exports=function(){};
@@ -1255,7 +1259,7 @@ function(t,r){for(var n=t._indexes,i=n.length,o=0;o<i;++o){for(var s=n[o][0],a=n
1255
1259
  /*!
1256
1260
  * Returns this documents _id cast to a string.
1257
1261
  */
1258
- function n(){return null!=this._id?String(this._id):null}t.exports=function(t){return!t.paths.id&&t.paths._id&&t.options.id?(t.virtual("id").get(n),t):t}},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i=r(323),o=r(325),s=r(6),a=r(166),u=r(57);t.exports=function(t,e){var r=t.childSchemas.find((function(t){return!!t.schema.options.timestamps}));if(e||r){var h,f=a(e,"createdAt"),c=a(e,"updatedAt"),l=null!=e&&e.hasOwnProperty("currentTime")?e.currentTime:null,d={};if(t.$timestamps={createdAt:f,updatedAt:c},c&&!t.paths[c]&&(d[c]=Date),f&&!t.paths[f])d[f]=(n(h={},t.options.typeKey||"type",Date),n(h,"immutable",!0),h);t.add(d),t.pre("save",(function(t){var e=s(this,"$__.saveOptions.timestamps");if(!1===e)return t();var r=null!=e&&!1===e.updatedAt,n=null!=e&&!1===e.createdAt,i=null!=l?l():(this.ownerDocument?this.ownerDocument():this).constructor.base.now(),o=this._id&&this._id.auto;if(!n&&f&&!this.$__getValue(f)&&this.$__isSelected(f)&&this.$set(f,o?this._id.getTimestamp():i),!r&&c&&(this.isNew||this.$isModified())){var a=i;this.isNew&&(null!=f?a=this.$__getValue(f):o&&(a=this._id.getTimestamp())),this.$set(c,a)}t()})),t.methods.initializeTimestamps=function(){var t=null!=l?l():this.constructor.base.now();return f&&!this.get(f)&&this.$set(f,t),c&&!this.get(c)&&this.$set(c,t),this},m[u.builtInMiddleware]=!0;var p={query:!0,model:!1};t.pre("findOneAndReplace",p,m),t.pre("findOneAndUpdate",p,m),t.pre("replaceOne",p,m),t.pre("update",p,m),t.pre("updateOne",p,m),t.pre("updateMany",p,m)}function m(t){var e=null!=l?l():this.model.base.now();"findOneAndReplace"===this.op&&null==this.getUpdate()&&this.setUpdate({}),o(e,f,c,this.getUpdate(),this.options,this.schema),i(e,this.getUpdate(),this.model.schema),t()}}},function(t,e,r){"use strict";function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var o=r(324),s=r(166);
1262
+ function n(){return null!=this._id?String(this._id):null}t.exports=function(t){return!t.paths.id&&t.paths._id&&t.options.id?(t.virtual("id").get(n),t):t}},function(t,e,r){"use strict";function n(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var i=r(323),o=r(325),s=r(6),a=r(166),u=r(57);t.exports=function(t,e){var r=t.childSchemas.find((function(t){return!!t.schema.options.timestamps}));if(e||r){var h,f=a(e,"createdAt"),c=a(e,"updatedAt"),l=null!=e&&e.hasOwnProperty("currentTime")?e.currentTime:null,d={};if(t.$timestamps={createdAt:f,updatedAt:c},c&&!t.paths[c]&&(d[c]=Date),f&&!t.paths[f])d[f]=(n(h={},t.options.typeKey||"type",Date),n(h,"immutable",!0),h);t.add(d),t.pre("save",(function(t){var e=s(this,"$__.saveOptions.timestamps");if(!1===e)return t();var r=null!=e&&!1===e.updatedAt,n=null!=e&&!1===e.createdAt,i=null!=l?l():this.ownerDocument().constructor.base.now(),o=this._id&&this._id.auto;if(!n&&f&&!this.$__getValue(f)&&this.$__isSelected(f)&&this.$set(f,o?this._id.getTimestamp():i),!r&&c&&(this.isNew||this.$isModified())){var a=i;this.isNew&&(null!=f?a=this.$__getValue(f):o&&(a=this._id.getTimestamp())),this.$set(c,a)}t()})),t.methods.initializeTimestamps=function(){var t=null!=l?l():this.constructor.base.now();return f&&!this.get(f)&&this.$set(f,t),c&&!this.get(c)&&this.$set(c,t),this},m[u.builtInMiddleware]=!0;var p={query:!0,model:!1};t.pre("findOneAndReplace",p,m),t.pre("findOneAndUpdate",p,m),t.pre("replaceOne",p,m),t.pre("update",p,m),t.pre("updateOne",p,m),t.pre("updateMany",p,m)}function m(t){var e=null!=l?l():this.model.base.now();"findOneAndReplace"===this.op&&null==this.getUpdate()&&this.setUpdate({}),o(e,f,c,this.getUpdate(),this.options,this.schema),i(e,this.getUpdate(),this.model.schema),t()}}},function(t,e,r){"use strict";function n(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(!t)return;if("string"==typeof t)return i(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(t,e)}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,s=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw s}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var o=r(324),s=r(166);
1259
1263
  /*!
1260
1264
  * ignore
1261
1265
  */