UNPKG

mongoose

Version:
2 lines 869 kB
/*! For license information please see browser.umd.js.LICENSE.txt */ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.mongoose=e():t.mongoose=e()}("undefined"!=typeof self?self:this,(()=>(()=>{var t={4986:(t,e,r)=>{"use strict";t.exports=r(254)},254:(t,e,r)=>{"use strict";var n=r(5832).Buffer;function i(t){return i="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},i(t)}function o(t,e,r){return e=s(e),function(t,e){if(e&&("object"==i(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,a()?Reflect.construct(e,r||[],s(t).constructor):e.apply(t,r))}function a(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(a=function(){return!!t})()}function s(t){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},s(t)}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}r(8582).set(r(5221));var u=r(3300);u.setBrowser(!0),e.Error=r(9507),e.Schema=r(9703),e.Types=r(1148),e.VirtualType=r(5165),e.SchemaType=r(2319),e.utils=r(335),e.Document=u(),e.model=function(t,r){var n=function(t){function e(t,n){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),o(this,e,[t,r,n])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}(e,t),n=e,Object.defineProperty(n,"prototype",{writable:!1}),n;var n}(e.Document);return n.modelName=t,n},"undefined"!=typeof window&&(window.mongoose=t.exports,window.Buffer=n)},6024:(t,e,r)=>{"use strict";var n=r(3293),i=r(3550).EventEmitter,o=r(9507),a=r(9703),s=r(6704),c=o.ValidationError,u=r(8892),f=r(4797);function l(t,e,r,i,c){if(!(this instanceof l))return new l(t,e,r,i,c);if(f(e)&&!e.instanceOfSchema&&(e=new a(e)),e=this.schema||e,!this.schema&&e.options._id&&void 0===(t=t||{})._id&&(t._id=new s),!e)throw new o.MissingSchemaError;for(var h in this.$__setSchema(e),n.call(this,t,r,i,c),u(this,e,{decorateDoc:!0}),e.methods)this[h]=e.methods[h];for(var p in e.statics)this[p]=e.statics[p]}l.prototype=Object.create(n.prototype),l.prototype.constructor=l,l.events=new i,l.$emitter=new i,["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"].forEach((function(t){l[t]=function(){return l.$emitter[t].apply(l.$emitter,arguments)}})),l.ValidationError=c,t.exports=l},8447:(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){if("string"==typeof t)return i(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(t,e):void 0}}(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 a,s=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){c=!0,a=t},f:function(){try{s||null==r.return||r.return()}finally{if(c)throw a}}}}function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function o(t){return o="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},o(t)}var a=r(6148),s=r(6166),c=r(2176),u=r(8385),f=r(2503),l=r(5132),h=r(1654),p=r(499),d=r(7352),y=r(4797),b=r(6504),m=r(335),v=["Polygon","MultiPolygon"];function g(t,e,r){if(Array.isArray(t))t.forEach((function(n,i){if(Array.isArray(n)||y(n))return g(n,e,r);t[i]=e.castForQuery(null,n,r)}));else for(var n=Object.keys(t),i=n.length;i--;){var o=n[i],a=t[o];Array.isArray(a)||y(a)?(g(a,e,r),t[o]=a):t[o]=e.castForQuery({val:a,context:r})}}function _(t,e,r,n){if("strictQuery"in t)return t.strictQuery;if("strictQuery"in e)return e.strictQuery;var i=n&&n.mongooseCollection&&n.mongooseCollection.conn&&n.mongooseCollection.conn.base&&n.mongooseCollection.conn.base.options;return i&&"strictQuery"in i?i.strictQuery:r.strictQuery}t.exports=function t(e,r,i,w){if(Array.isArray(r))throw new Error("Query filter must be an object, got an array ",d.inspect(r));if(null==r)return r;null!=e&&null!=e.discriminators&&null!=r[e.options.discriminatorKey]&&(e=h(e,r[e.options.discriminatorKey])||e);var S,O,j,$,A,E,x=Object.keys(r),P=x.length;for(i=i||{};P--;)if(E=r[$=x[P]],"$or"===$||"$nor"===$||"$and"===$){if(!Array.isArray(E))throw new a("Array",E,$);for(var k=0;k<E.length;++k){if(null==E[k]||"object"!==o(E[k]))throw new a("Object",E[k],$+"."+k);var M=E[k][e.options.discriminatorKey];if(null==M)E[k]=t(e,E[k],i,w);else{var I=h(w.schema,M);E[k]=t(I||e,E[k],i,w)}}}else{if("$where"===$){if("string"!==(A=o(E))&&"function"!==A)throw new Error("Must have a string or function for $where");"function"===A&&(r[$]=E.toString());continue}if("$expr"===$){E=u(E,e);continue}if("$elemMatch"===$)E=t(e,E,i,w);else if("$text"===$)E=f(E,$);else{if(!e)continue;if(!(O=e.path($)))for(var T=$.split("."),B=T.length;B--;){var R=T.slice(0,B).join("."),N=T.slice(B).join("."),D=e.path(R),L=D&&D.schema&&D.schema.options&&D.schema.options.discriminatorKey;if(null!=D&&null!=(D.schema&&D.schema.discriminators)&&null!=L&&N!==L){var C=l(r,R+"."+L),U=D.schema.discriminators;"string"==typeof C&&null!=U[C]?O=U[C].path(N):null!=C&&1===Object.keys(C).length&&Array.isArray(C.$in)&&1===C.$in.length&&"string"==typeof C.$in[0]&&null!=U[C.$in[0]]&&(O=U[C.$in[0]].path(N))}}if(O){if(null==E)continue;if(m.isPOJO(E))if(Object.keys(E).some(p))for(var q=Object.keys(E),F=void 0,V=q.length;V--;)if(j=E[F=q[V]],"$elemMatch"===F)j&&null!=O&&null!=O.schema?t(O.schema,j,i,w):j&&null!=O&&O.$isMongooseArray&&(m.isPOJO(j)&&null!=j.$not?t(e,j,i,w):E[F]=O.castForQuery(F,j,w));else if("$not"===F){if(j&&O){if((S=Object.keys(j)).length&&p(S[0]))for(var z in j)j[z]=O.castForQuery(z,j[z],w);else E[F]=O.castForQuery(F,j,w);continue}}else E[F]=O.castForQuery(F,j,w);else r[$]=O.castForQuery(null,E,w);else if(Array.isArray(E)&&-1===["Buffer","Array"].indexOf(O.instance)){var K,H=[],W=n(E);try{for(W.s();!(K=W.n()).done;){var J=K.value;H.push(O.castForQuery(null,J,w))}}catch(t){W.e(t)}finally{W.f()}r[$]={$in:H}}else r[$]=O.castForQuery(null,E,w)}else{for(var G=$.split("."),Y=G.length,Q=void 0,X=void 0,Z=void 0;Y--&&(Q=G.slice(0,Y).join("."),!(O=e.path(Q))););if(O){if(O.caster&&O.caster.schema){(Z={})[X=G.slice(Y).join(".")]=E;var tt=t(O.caster.schema,Z,i,w)[X];void 0===tt?delete r[$]:r[$]=tt}else r[$]=E;continue}if(y(E)){var et="";if(E.$near?et="$near":E.$nearSphere?et="$nearSphere":E.$within?et="$within":E.$geoIntersects?et="$geoIntersects":E.$geoWithin&&(et="$geoWithin"),et){var rt=new c.Number("__QueryCasting__"),nt=E[et];if(null!=E.$maxDistance&&(E.$maxDistance=rt.castForQuery(null,E.$maxDistance,w)),null!=E.$minDistance&&(E.$minDistance=rt.castForQuery(null,E.$minDistance,w)),"$within"===et){var it=nt.$center||nt.$centerSphere||nt.$box||nt.$polygon;if(!it)throw new Error("Bad $within parameter: "+JSON.stringify(E));nt=it}else if("$near"===et&&"string"==typeof nt.type&&Array.isArray(nt.coordinates))nt=nt.coordinates;else if(("$near"===et||"$nearSphere"===et||"$geoIntersects"===et)&&nt.$geometry&&"string"==typeof nt.$geometry.type&&Array.isArray(nt.$geometry.coordinates))null!=nt.$maxDistance&&(nt.$maxDistance=rt.castForQuery(null,nt.$maxDistance,w)),null!=nt.$minDistance&&(nt.$minDistance=rt.castForQuery(null,nt.$minDistance,w)),b(nt.$geometry)&&(nt.$geometry=nt.$geometry.toObject({transform:!1,virtuals:!1})),nt=nt.$geometry.coordinates;else if("$geoWithin"===et)if(nt.$geometry){b(nt.$geometry)&&(nt.$geometry=nt.$geometry.toObject({virtuals:!1}));var ot=nt.$geometry.type;if(-1===v.indexOf(ot))throw new Error('Invalid geoJSON type for $geoWithin "'+ot+'", must be "Polygon" or "MultiPolygon"');nt=nt.$geometry.coordinates}else nt=nt.$box||nt.$polygon||nt.$center||nt.$centerSphere,b(nt)&&(nt=nt.toObject({virtuals:!1}));g(nt,rt,w);continue}}if(e.nested[$])continue;var at="strict"in i?i.strict:e.options.strict,st=_(i,e._userProvidedOptions,e.options,w);if(i.upsert&&at){if("throw"===at)throw new s($);throw new s($,'Path "'+$+'" is not in schema, strict mode is `true`, and upsert is `true`.')}if("throw"===st)throw new s($,'Path "'+$+"\" is not in schema and strictQuery is 'throw'.");st&&delete r[$]}}}return r}},6237:(t,e,r)=>{"use strict";var n=r(2402),i=r(3633).Long;t.exports=function(t){return null==t?t:""===t?null:"bigint"==typeof t?t:t instanceof i?t.toBigInt():"string"==typeof t||"number"==typeof t?BigInt(t):void n.ok(!1)}},7092:(t,e,r)=>{"use strict";var n=r(6148);t.exports=function(e,r){if(t.exports.convertToTrue.has(e))return!0;if(t.exports.convertToFalse.has(e))return!1;if(null==e)return e;throw new n("boolean",e,r)},t.exports.convertToTrue=new Set([!0,"true",1,"1","yes"]),t.exports.convertToFalse=new Set([!1,"false",0,"0","no"])},9973:(t,e,r)=>{"use strict";var n=r(2402);t.exports=function(t){return null==t||""===t?null:t instanceof Date?(n.ok(!isNaN(t.valueOf())),t):(n.ok("boolean"!=typeof t),e=t instanceof Number||"number"==typeof t?new Date(t):"string"==typeof t&&!isNaN(Number(t))&&(Number(t)>=275761||Number(t)<-271820)?new Date(Number(t)):"function"==typeof t.valueOf?new Date(t.valueOf()):new Date(t),isNaN(e.valueOf())?void n.ok(!1):e);var e}},3854:(t,e,r)=>{"use strict";var n=r(5832).Buffer;function i(t){return i="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},i(t)}var o=r(9394),a=r(2402);t.exports=function(t){return null==t?t:"object"===i(t)&&"string"==typeof t.$numberDecimal?o.fromString(t.$numberDecimal):t instanceof o?t:"string"==typeof t?o.fromString(t):"function"==typeof n&&n.isBuffer(t)||"function"==typeof Uint8Array&&t instanceof Uint8Array?new o(t):"number"==typeof t?o.fromString(String(t)):"function"==typeof t.valueOf&&"string"==typeof t.valueOf()?o.fromString(t.valueOf()):void a.ok(!1)}},247:(t,e,r)=>{"use strict";var n=r(2402);t.exports=function(t){return null==t?t:""===t?null:("string"!=typeof t&&"boolean"!=typeof t||(t=Number(t)),n.ok(!isNaN(t)),t instanceof Number?t.valueOf():"number"==typeof t?t:Array.isArray(t)||"function"!=typeof t.valueOf?t.toString&&!Array.isArray(t)&&t.toString()==Number(t)?Number(t):void n.ok(!1):Number(t.valueOf()))}},8092:(t,e,r)=>{"use strict";var n=r(2128),i=r(6704);t.exports=function(t){if(null==t)return t;if(n(t,"ObjectId"))return t;if(t._id){if(n(t._id,"ObjectId"))return t._id;if(t._id.toString instanceof Function)return new i(t._id.toString())}return t.toString instanceof Function?new i(t.toString()):new i(t)}},8471:(t,e,r)=>{"use strict";var n=r(6148);t.exports=function(t,e){if(null==t)return t;if(t._id&&"string"==typeof t._id)return t._id;if(t.toString&&t.toString!==Object.prototype.toString&&!Array.isArray(t))return t.toString();throw new n("string",t,e)}},991:(t,e)=>{"use strict";var r=Object.freeze(["countDocuments","distinct","estimatedDocumentCount","find","findOne","findOneAndReplace","findOneAndUpdate","replaceOne","updateMany","updateOne","deleteMany","deleteOne","findOneAndDelete"]).concat(["validate"]);e.U=r},3293:(t,e,r)=>{"use strict";var n=r(5832).Buffer;function i(t){return function(t){if(Array.isArray(t))return p(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||h(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(){o=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:x(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var p="suspendedStart",y="suspendedYield",b="executing",m="completed",v={};function g(){}function _(){}function w(){}var S={};f(S,s,(function(){return this}));var O=Object.getPrototypeOf,j=O&&O(O(T([])));j&&j!==r&&n.call(j,s)&&(S=j);var $=w.prototype=g.prototype=Object.create(S);function A(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function E(t,e){function r(i,o,a,s){var c=h(t[i],t,o);if("throw"!==c.type){var u=c.arg,f=u.value;return f&&"object"==d(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){u.value=t,a(u)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function x(e,r,n){var i=p;return function(o,a){if(i===b)throw Error("Generator is already running");if(i===m){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var c=P(s,n);if(c){if(c===v)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===p)throw i=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=b;var u=h(e,r,n);if("normal"===u.type){if(i=n.done?m:y,u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i=m,n.method="throw",n.arg=u.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=h(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function k(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function M(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(k,this),this.reset(!0)}function T(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(d(e)+" is not iterable")}return _.prototype=w,i($,"constructor",{value:w,configurable:!0}),i(w,"constructor",{value:_,configurable:!0}),_.displayName=f(w,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===_||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,f(t,u,"GeneratorFunction")),t.prototype=Object.create($),t},e.awrap=function(t){return{__await:t}},A(E.prototype),f(E.prototype,c,(function(){return this})),e.AsyncIterator=E,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new E(l(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},A($),f($,u,"Generator"),f($,s,(function(){return this})),f($,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=T,I.prototype={constructor:I,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(M),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),v},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),M(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:T(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}function a(t,e,r,n,i,o,a){try{var s=t[o](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,i)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){a(o,n,i,s,c,"next",t)}function c(t){a(o,n,i,s,c,"throw",t)}s(void 0)}))}}function c(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function u(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?c(Object(r),!0).forEach((function(e){f(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function f(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=d(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==d(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=h(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 o,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function h(t,e){if(t){if("string"==typeof t)return p(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function d(t){return d="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},d(t)}var y,b,m,v=r(6432),g=r(3550).EventEmitter,_=r(641),w=r(9820),S=r(9507),O=r(1895),j=r(7283),$=r(2260),A=r(1857),E=r(3810),x=r(9703),P=r(6166),k=r(5368),M=r(8393),I=r(8279),T=r(6690),B=r(8208),R=r(1829),N=r(9725).w,D=r(9725).X,L=r(5575),C=r(9563).B,U=r(8239),q=r(4051),F=r(8825),V=r(8145),z=r(3933),K=r(2128),H=r(6239),W=r(1384),J=r(2243),G=r(7352).inspect,Y=r(3920)._,Q=r(1096),X=r(6470),Z=r(5678),tt=r(4094),et=r(2205),rt=r(335),nt=r(3165),it=rt.deepEqual,ot=rt.isMongooseObject,at=r(5625).arrayAtomicsBackupSymbol,st=r(5625).arrayAtomicsSymbol,ct=r(5625).documentArrayParent,ut=r(5625).documentIsModified,ft=r(5625).documentModifiedPaths,lt=r(5625).documentSchemaSymbol,ht=r(5625).getSymbol,pt=r(5625).populateModelSymbol,dt=r(5625).scopeSymbol,yt=r(3089).schemaMixedSymbol,bt=r(2609),mt=r(5625).sessionNewDocuments,vt=rt.specialProperties,gt=1,_t=2,wt=gt|_t;function St(t,e,r,n){if("object"===d(r)&&null!=r&&(r=(n=r).skipId),n=Object.assign({},n),null==this.$__schema){var i=rt.isObject(e)&&!e.instanceOfSchema?new x(e):e;this.$__setSchema(i),e=r,r=n,n=arguments[4]||{}}if(this.$__=new _,null!=n.isNew&&!0!==n.isNew&&(this.$isNew=n.isNew),null!=n.priorDoc&&(this.$__.priorDoc=n.priorDoc),r&&(this.$__.skipId=r),null!=t&&"object"!==d(t))throw new A(t,"obj","Document");var o=!0;void 0!==n.defaults&&(this.$__.defaults=n.defaults,o=n.defaults);var a=this.$__schema;"boolean"==typeof e||"throw"===e?(!0!==e&&(this.$__.strictMode=e),e=void 0):!0!==a.options.strict&&(this.$__.strictMode=a.options.strict);var s,c=l(a.requiredPaths(!0));try{for(c.s();!(s=c.n()).done;){var u=s.value;this.$__.activePaths.require(u)}}catch(t){c.e(t)}finally{c.f()}var f=null;rt.isPOJO(e)&&Object.keys(e).length>0&&(f=W(e),this.$__.selected=e,this.$__.exclude=f);var h=!1===f&&e?I(e):null;if(null==this._doc&&(this.$__buildDoc(t,e,r,f,h,!1),o&&T(this,e,f,h,!0,null,{skipParentChangeTracking:!0})),t&&(this.$__original_set?this.$__original_set(t,void 0,!0,n):this.$set(t,void 0,!0,n),t instanceof St&&(this.$isNew=t.$isNew)),n.willInit&&o?n.skipDefaults&&(this.$__.skipDefaults=n.skipDefaults):o&&T(this,e,f,h,!1,n.skipDefaults),!this.$__.strictMode&&t){var p=this;Object.keys(this._doc).forEach((function(t){t in a.tree||t in a.methods||t in a.virtuals||t.startsWith("$")||D({prop:t,subprops:null,prototype:p})}))}!function(t){var e=t.$__schema&&t.$__schema.callQueue;if(e.length){var r,n=l(e);try{for(n.s();!(r=n.n()).done;){var i=r.value;"pre"!==i[0]&&"post"!==i[0]&&"on"!==i[0]&&t[i[0]].apply(t,i[1])}}catch(t){n.e(t)}finally{n.f()}}}(this)}for(var Ot in St.prototype.$isMongooseDocumentPrototype=!0,Object.defineProperty(St.prototype,"isNew",{get:function(){return this.$isNew},set:function(t){this.$isNew=t}}),Object.defineProperty(St.prototype,"errors",{get:function(){return this.$errors},set:function(t){this.$errors=t}}),St.prototype.$isNew=!0,rt.each(["on","once","emit","listeners","removeListener","setMaxListeners","removeAllListeners","addListener"],(function(t){St.prototype[t]=function(){if(!this.$__.emitter){if("emit"===t)return;this.$__.emitter=new g,this.$__.emitter.setMaxListeners(0)}return this.$__.emitter[t].apply(this.$__.emitter,arguments)},St.prototype["$".concat(t)]=St.prototype[t]})),St.prototype.constructor=St,g.prototype)St[Ot]=g.prototype[Ot];function jt(t,e,r){if(null!=t)for(var n=Object.keys(r.$__schema.paths),i=n.length,o=-1===e.indexOf(".")?[e]:e.split("."),a=0;a<i;++a){var s="",c=n[a];if(c.startsWith(e+".")){var u=r.$__schema.paths[c],f=u.splitPath().slice(o.length),l=f.length;if(void 0!==u.defaultValue)for(var h=t,p=0;p<l&&null!=h;++p){var d=f[p];if(p===l-1){if(void 0!==h[d])break;try{var y=u.getDefault(r,!1);void 0!==y&&(h[d]=y)}catch(t){r.invalidate(e+"."+s,t);break}break}s+=(s.length?".":"")+d,h[d]=h[d]||{},h=h[d]}}}}function $t(t,e,r,n,i){i=i||"",null!=e.$__&&(e=e._doc);for(var o,a,s,c=Object.keys(e),u=c.length,f=0,l=t.$__.strictMode,h=t.$__schema;f<u;)p(f++);function p(u){if("__proto__"!==(s=c[u])&&"constructor"!==s&&(a=i?i+s:s,o=h.path(a),!h.$isRootDiscriminator||t.$__isSelected(a))){var f=e[s];if(!o&&rt.isPOJO(f))r[s]||(r[s]={},l||s in h.tree||s in h.methods||s in h.virtuals||(t[s]=r[s])),$t(t,f,r[s],n,a+".");else if(o){if(r.hasOwnProperty(s)&&void 0!==f&&!n.hydratedPopulatedDocs&&delete r[s],null===f)r[s]=o._castNullish(null);else if(void 0!==f){var p=null==f.$__?null:f.$__.wasPopulated;if(!o||p||n.hydratedPopulatedDocs)r[s]=f;else try{n&&n.setters?r[s]=o.applySetters(f,t,!1):r[s]=o.cast(f,t,!0)}catch(e){t.invalidate(e.path,new M({path:e.path,message:e.message,type:"cast",value:e.value,reason:e}))}}t.$isModified(a)||t.$__.activePaths.init(a)}else r[s]=f,l||i||(t[s]=f)}}}function At(t){if(null==t)return!0;if("object"!==d(t)||Array.isArray(t))return!1;for(var e=0,r=Object.keys(t);e<r.length;e++)if(!At(t[r[e]]))return!1;return!0}function Et(t,e,r){var n={};!function(t){var e=Object.keys(t.$__.activePaths.getStatePaths("require")),r=0,n=e.length;for(r=0;r<n;++r){var i=e[r],o=t.$__schema.path(i);if(null!=o&&"function"==typeof o.originalRequiredValue){t.$__.cachedRequired=t.$__.cachedRequired||{};try{t.$__.cachedRequired[i]=o.originalRequiredValue.call(t,t)}catch(e){t.invalidate(i,e)}}}}(t);var i=new Set(Object.keys(t.$__.activePaths.getStatePaths("require")).filter((function(e){return!(!t.$__isSelected(e)&&!t.$isModified(e))&&(null==t.$__.cachedRequired||!(e in t.$__.cachedRequired)||t.$__.cachedRequired[e])})));function o(t){i.add(t)}Object.keys(t.$__.activePaths.getStatePaths("init")).forEach(o),Object.keys(t.$__.activePaths.getStatePaths("modify")).forEach(o),Object.keys(t.$__.activePaths.getStatePaths("default")).forEach(o);var a,s=t.$getAllSubdocs(),c=t.modifiedPaths(),u=l(s);try{for(u.s();!(a=u.n()).done;){var f=a.value;if(f.$basePath){var h,p=f.$isSingleNested?f.$__pathRelativeToParent():f.$__fullPathWithIndexes(),d=l(f.modifiedPaths());try{for(d.s();!(h=d.n()).done;){var y=h.value;i.delete(p+"."+y)}}catch(t){d.e(t)}finally{d.f()}!t.$isModified(p,null,c)||t.isDirectModified(p)||t.$isDefault(p)||(i.add(p),null==t.$__.pathsToScopes&&(t.$__.pathsToScopes={}),t.$__.pathsToScopes[p]=f.$isDocumentArrayElement?f.__parentArray:f.$parent(),n[p]={skipSchemaValidators:!0},f.$isDocumentArrayElement&&null!=f.__index&&(n[p].index=f.__index))}}}catch(t){u.e(t)}finally{u.f()}var b,m=l(i);try{for(m.s();!(b=m.n()).done;){var v=b.value,g=t.$__schema.path(v);if(g){if(g.$isMongooseDocumentArray){var _,w=l(i);try{for(w.s();!(_=w.n()).done;){var S=_.value;(null==S||S.startsWith(g.path+"."))&&i.delete(S)}}catch(t){w.e(t)}finally{w.f()}}(g.caster||0!==g.validators.length||g.$parentSchemaDocArray)&&(!g.$isMongooseArray||g.$isMongooseDocumentArray||g.$embeddedSchemaType.$isMongooseArray||0!==g.validators.length||0!==g.$embeddedSchemaType.validators.length)||i.delete(v)}}}catch(t){m.e(t)}finally{m.f()}var O,j=l(i);try{for(j.s();!(O=j.n()).done;){var $=O.value;t.$__schema.singleNestedPaths.hasOwnProperty($)&&i.delete($)}}catch(t){j.e(t)}finally{j.f()}Array.isArray(e)?i=function(t,e){var r,n=new Set(e),i=new Map([]),o=l(e);try{for(o.s();!(r=o.n()).done;){var a=r.value;if(-1!==a.indexOf("."))for(var s=a.split("."),c=s[0],u=1;u<s.length;++u)i.set(c,a),c=c+"."+s[u]}}catch(t){o.e(t)}finally{o.f()}var f,h=new Set,p=l(t);try{for(p.s();!(f=p.n()).done;){var d=f.value;n.has(d)?h.add(d):i.has(d)&&h.add(i.get(d))}}catch(t){p.e(t)}finally{p.f()}return h}(i,e):Array.isArray(r)&&(i=function(t,e){return e=new Set(e),t=Array.from(t).filter((function(t){return!e.has(t)})),new Set(t)}(i,r)),function(t,e){var r,n=l(e);try{for(n.s();!(r=n.n()).done;){var i=r.value,o=t.$__schema.path(i);o&&o.$isMongooseArray&&(Array.isArray(o)||!o.$isMongooseDocumentArray||o&&o.schemaOptions&&o.schemaOptions.required)&&(!o.$isMongooseArray||o.$isMongooseDocumentArray||o.$embeddedSchemaType.$isMongooseArray||0!==o.$embeddedSchemaType.validators.length)&&xt(t.$__getValue(i),e,i)}}catch(t){n.e(t)}finally{n.f()}}(t,i);var A,E={skipArrays:!0},x=l(i);try{for(x.s();!(A=x.n()).done;){var P=A.value;if(t.$__schema.nested[P]){var k=t.$__getValue(P);ot(k)&&(k=k.toObject({transform:!1}));var M=C(k,P,E,t.$__schema);Object.keys(M).forEach(o)}}}catch(t){x.e(t)}finally{x.f()}var I,T=l(i);try{for(T.s();!(I=T.n()).done;){var B=I.value,R=t.$__schema.path(B);if(R&&(R.$parentSchemaDocArray&&"string"==typeof R.$parentSchemaDocArray.path&&i.add(R.$parentSchemaDocArray.path),R.$isSchemaMap)){var N=t.$__getValue(B);if(null!=N){var D,L=l(N.keys());try{for(L.s();!(D=L.n()).done;){var U=D.value;i.add(B+"."+U)}}catch(t){L.e(t)}finally{L.f()}}}}}catch(t){T.e(t)}finally{T.f()}return[i=Array.from(i),n]}function xt(t,e,r){if(null!=t)for(var n=t.length,i=0;i<n;++i)Array.isArray(t[i])?xt(t[i],e,r+"."+i):e.add(r+"."+i)}function Pt(t,e,r,n){var i,o,a,s=t.$__schema,c=s.virtuals,u=Object.keys(c),f=u.length,l=f,h=t._doc,p="boolean"!=typeof(n&&n.aliases)||n.aliases;r=r||{};var d=null;if(Array.isArray(r.virtuals))d=new Set(r.virtuals);else if(r.virtuals&&r.virtuals.pathsToSkip){d=new Set(u);for(var y=0;y<r.virtuals.pathsToSkip.length;y++)d.has(r.virtuals.pathsToSkip[y])&&d.delete(r.virtuals.pathsToSkip[y])}if(!h)return e;for(f=0;f<l;++f)if(i=u[f],(null==d||d.has(i))&&(p||!s.aliases.hasOwnProperty(i))){if(o=i,null!=r.path){if(!i.startsWith(r.path+"."))continue;o=i.substring(r.path.length+1)}if(-1!==o.indexOf(".")||o!==i){var b=o.split(".");if(void 0!==(a=R(t.get(i),r))){var m=b.length;h=e;for(var v=0;v<m-1;++v)h[b[v]]=h[b[v]]||{},h=h[b[v]];h[b[m-1]]=a}}else{if(void 0===(a=c[i].applyGetters(void 0,t)))continue;a=R(a,r),e[o]=a}}return e}function kt(t,e){if(nt(e))throw new Error("`transform` function must be synchronous, but the transform on path `"+t+"` returned a promise.")}function Mt(t,e,r){var n=t.$populated(e,!0);if(!n&&t.$__.selected){var i=e.split(".")[0];if(t.$__.selected[i+".$"])return i}if(n&&rt.isMongooseArray(r)&&(n.options.match||n.options.options&&rt.object.hasOwnProperty(n.options.options,"limit")||n.options.options&&n.options.options.skip||n.options.select&&(0===n.options.select._id||/\s?-_id\s?/.test(n.options.select)))){var o=r[st];if(0===Object.keys(o).length||o.$set||o.$pop)return e}}function It(t,e,r,n,i,o){if(o||(o="$set"),r[o]||(r[o]={}),r[o][n.path]=i,!1!==t.$__schema.options.versionKey&&!function(t,e){var r=t.$__schema.options.skipVersioning;return!!r&&r[e=e.replace(/\.\d+\./,".")]}(t,n.path)&&wt!==(wt&t.$__.version)&&!t.$__schema.options.optimisticConcurrency){switch(o){case"$set":case"$unset":case"$pop":case"$pull":case"$pullAll":case"$push":case"$addToSet":case"$inc":break;default:return}"$push"===o||"$addToSet"===o||"$pullAll"===o||"$pull"===o?/\.\d+\.|\.\d+$/.test(n.path)?t.$__.version=wt:t.$__.version=_t:/^\$p/.test(o)||Array.isArray(i)?t.$__.version=wt:/\.\d+\.|\.\d+$/.test(n.path)&&(t.$__.version=gt)}}function Tt(t,e,r,n,i){if(!r.$set||!r.$set[n.path])if("function"!=typeof i.$__getAtomics){var o,a,s=i[st],c=Object.keys(s),u=c.length;if(0===u)return rt.isMongooseObject(i)?i=i.toObject({depopulate:1,_isNested:!0}):i.valueOf&&(i=i.valueOf()),It(t,0,r,n,i);for(;u--;)o=s[a=c[u]],rt.isMongooseObject(o)?o=o.toObject({depopulate:!0,transform:!1,_isNested:!0}):Array.isArray(o)?o=o.map(f):o.valueOf&&(o=o.valueOf()),"$addToSet"===a&&(o={$each:o}),It(t,0,r,n,o,a)}else i.$__getAtomics().forEach((function(e){var i=e[0],o=e[1];It(t,0,r,n,o,i)}));function f(t){return rt.isMongooseObject(t)?t.toObject({depopulate:1,_isNested:!0}):t}}St.prototype.$__schema,St.prototype.schema,Object.defineProperty(St.prototype,"$locals",{configurable:!1,enumerable:!1,get:function(){return null==this.$__.locals&&(this.$__.locals={}),this.$__.locals},set:function(t){this.$__.locals=t}}),St.prototype.isNew,Object.defineProperty(St.prototype,"$where",{configurable:!1,enumerable:!1,writable:!0}),St.prototype.id,St.prototype.$errors,Object.defineProperty(St.prototype,"$op",{get:function(){return this.$__.op||null},set:function(t){this.$__.op=t}}),St.prototype.$__buildDoc=function(t,e,r,n,i){for(var o={},a=Object.keys(this.$__schema.paths).filter((function(t){return!t.includes("$*")})),s=a.length,c=0;c<s;++c){var u=a[c];if("_id"===u){if(r)continue;if(t&&"_id"in t)continue}for(var f=this.$__schema.paths[u].splitPath(),l=f.length,h=l-1,p="",d=o,y=!1,b=0;b<l;++b){var m=f[b];if(p.length?p+="."+m:p=m,!0===n){if(p in e)break}else if(!1===n&&e&&!y)if(p in e)y=!0;else if(!i[p])break;b<h&&(d=d[m]||(d[m]={}))}}this._doc=o},St.prototype.toBSON=function(){return this.toObject(Y)},St.prototype.init=function(t,e,r){return"function"==typeof e&&(r=e,e=null),this.$__init(t,e),r&&r(null,this),this},St.prototype.$init=function(){return this.constructor.prototype.init.apply(this,arguments)},St.prototype.$__init=function(t,e){if(this.$isNew=!1,e=e||{},null!=t._id&&e.populated&&e.populated.length){var r,n=String(t._id),i=l(e.populated);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(o.isVirtual?this.$populated(o.path,rt.getValue(o.path,t),o):this.$populated(o.path,o._docs[n],o),null!=o._childDocs){var a,s=l(o._childDocs);try{for(s.s();!(a=s.n()).done;){var c=a.value;null!=c&&null!=c.$__&&(c.$__.parent=this)}}catch(t){s.e(t)}finally{s.f()}o._childDocs=[]}}}catch(t){i.e(t)}finally{i.f()}}$t(this,t,this._doc,e),Q(this,e.populated),this.$emit("init",this),this.constructor.emit("init",this);var u=!1===this.$__.exclude&&this.$__.selected?I(this.$__.selected):null;return T(this,this.$__.selected,this.$__.exclude,u,!1,this.$__.skipDefaults),this},St.prototype.updateOne=function(t,e,r){var n=this.constructor.updateOne({_id:this._id},t,e),i=this;return n.pre((function(t){i.constructor._middleware.execPre("updateOne",i,[i],t)})),n.post((function(t){i.constructor._middleware.execPost("updateOne",i,[i],{},t)})),null!=this.$session()&&("session"in n.options||(n.options.session=this.$session())),null!=r?n.exec(r):n},St.prototype.replaceOne=function(){var t=Array.prototype.slice.call(arguments);return t.unshift({_id:this._id}),this.constructor.replaceOne.apply(this.constructor,t)},St.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 S("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(null!=t||null!=this.$__.session){if(this.$__.session=t,!this.$isSubdocument){var e,r=l(this.$getAllSubdocs());try{for(r.s();!(e=r.n()).done;)e.value.$session(t)}catch(t){r.e(t)}finally{r.f()}}return t}},St.prototype.$timestamps=function(t){return 0===arguments.length?null!=this.$__.timestamps?this.$__.timestamps:this.$__schema?this.$__schema.options.timestamps:void 0:(t!==this.$timestamps()&&(this.$__.timestamps=t),this)},St.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},St.prototype.$set=function(t,e,r,n){var i=this;rt.isPOJO(r)&&(n=r,r=void 0);var o,a,s,c,h=n&&n.merge,p=r&&!0!==r,y=!0===r,b=0,m=n&&"strict"in n,v=m?n.strict:this.$__.strictMode;if(p&&((this.$__.adhocPaths||(this.$__.adhocPaths={}))[t]=this.$__schema.interpretAsType(t,r,this.$__schema.options)),null==t){var g=[e,t];t=g[0],e=g[1]}else if("string"!=typeof t){if(t instanceof St&&(t=t.$__isNested?t.toObject():t.$__schema===this.$__schema?Pt(t,u({},t._doc)):t._doc),null==t){var _=[e,t];t=_[0],e=_[1]}c=e?e+".":"";var w=(o=q(this.$__schema,t)).length,j=n&&n._skipMinimizeTopLevel||!1;if(0===w&&j)return delete n._skipMinimizeTopLevel,e&&this.$set(e,{}),this;n=Object.assign({},n,{_skipMinimizeTopLevel:!1});for(var A=0;A<w;++A){s=o[A];var E=c?c+s:s;a=this.$__schema.pathType(E);var x=t[s];if(!0!==r||c||null==x||"nested"!==a||null==this._doc[s]||delete this._doc[s],rt.isNonBuiltinObject(x)&&"nested"===a)this.$set(E,x,y,Object.assign({},n,{_skipMarkModified:!0})),jt(this.$get(E),E,this);else if(v){if(y&&void 0===x&&void 0!==this.$get(E))continue;if("adhocOrUndefined"===a&&(a=U(this,E,{typeOnly:!0})),"real"===a||"virtual"===a)this.$set(E,x,y,n);else if("nested"===a&&x instanceof St)this.$set(E,x.toObject({transform:!1}),y,n);else{if("throw"===v)throw"nested"===a?new $(s,x):new P(s);"nested"===a&&null==x&&this.$set(E,x,y,n)}}else void 0!==x&&this.$set(E,x,y,n)}for(var k={},M=Object.keys(this.$__schema.tree),I=0,T=M.length;I<T;++I)(s=M[I])&&this._doc.hasOwnProperty(s)&&(k[s]=void 0);return this._doc=Object.assign(k,this._doc),this}var R=this.$__schema.pathType(t),N=null;if("adhocOrUndefined"===R&&(N=-1===t.indexOf(".")?[t]:t.split("."),R=U(this,N,{typeOnly:!0})),"adhocOrUndefined"===R&&!m){null==N&&(N=-1===t.indexOf(".")?[t]:t.split("."));var D=F(this.$__schema,N);void 0!==D&&(v=D)}e=V(e,!0);var L,C=null!=i.$__.priorDoc?i.$__.priorDoc.$__getValue(t):y?void 0:i.$__getValue(t);if("nested"===R&&e){if("object"===d(e)&&null!=e){if(null!=e.$__&&(e=e.toObject(Y)),null==e)return this.invalidate(t,new S.CastError("Object",e,t)),this;var z=this.$isModified(t),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,J=Object.keys(H||{});W<J.length;W++){var G=J[W];this.$__.savedState[t+"."+G]=H[G]}}if(h)return this.$set(e,t,y);this.$__setValue(t,null),B(this,t);var Q=q(this.$__schema,e,t);this.$__setValue(t,{});var X,tt=l(Q);try{for(tt.s();!(X=tt.n()).done;){var et=X.value;this.$set(t+"."+et,e[et],y,u(u({},n),{},{_skipMarkModified:!0}))}}catch(t){tt.e(t)}finally{tt.f()}return null==C||z&&!K||!rt.deepEqual(K?this.$__.savedState[t]:C,e)?this.markModified(t):this.unmarkModified(t),this}return this.invalidate(t,new S.CastError("Object",e,t)),this}if(null==N&&(N=-1===t.indexOf(".")?[t]:t.split(".")),"string"==typeof this.$__schema.aliases[N[0]]&&(N[0]=this.$__schema.aliases[N[0]]),"adhocOrUndefined"===R&&v){var nt;for(b=0;b<N.length;++b){var it=N.slice(0,b+1).join(".");if(b+1<N.length&&"virtual"===this.$__schema.pathType(it))return Z.set(t,e,this),this;if(null!=(L=this.$__schema.path(it))){if(L instanceof O){nt=!0;break}if(L.$isSchemaMap&&L.$__schemaType instanceof O&&b<N.length-1){nt=!0,L=L.$__schemaType;break}}}if(null==L&&(L=U(this,t)),!nt&&!L){if("throw"===v)throw new P(t);return this}}else{if("virtual"===R)return(L=this.$__schema.virtualpath(t)).applySetters(e,this),this;L=this.$__path(t)}var ot,at=this._doc,st="";for(b=0;b<N.length-1;++b)at=at[N[b]],st+=(0!==st.length?".":"")+N[b],at||(this.$set(st,{}),this.$__isSelected(st)||this.unmarkModified(st),at=this.$__getValue(st));if(N.length<=1)ot=t;else{var ct=N.length;for(b=0;b<ct;++b){var ut=N.slice(0,b+1).join(".");if(null===this.$get(ut,null,{getters:!1})){ot=ut;break}}ot||(ot=t)}if(!L)return this.$__set(ot,t,n,y,N,L,e,C),"nested"===R&&null==e&&B(this,t),this;if((L.$isSingleNested||L.$isMongooseArray)&&function(t,e){if(t.$__.validationError){for(var r=0,n=Object.keys(t.$__.validationError.errors);r<n.length;r++){var i=n[r];i.startsWith(e+".")&&delete t.$__.validationError.errors[i]}0===Object.keys(t.$__.validationError.errors).length&&(t.$__.validationError=null)}}(this,t),null!=e&&h&&L.$isSingleNested){e instanceof St&&(e=e.toObject({virtuals:!1,transform:!1}));for(var ft=0,lt=Object.keys(e);ft<lt.length;ft++){var ht=lt[ft];this.$set(t+"."+ht,e[ht],y,n)}return this}var dt=!0;try{var yt,vt=function(){if(null==L.options)return!1;if(!(e instanceof St))return!1;var t=e.constructor,r=L.options.ref;if(null!=r&&(r===t.modelName||r===t.baseModelName))return!0;var n=L.options.refPath;if(null==n)return!1;var i=e.get(n);return i===t.modelName||i===t.baseModelName}(),gt=!1;if(vt&&e instanceof St&&(!e.$__.wasPopulated||rt.deepEqual(e.$__.wasPopulated.value,e._id))){var _t=L&&L.$isSingleNested?L.cast(e,this):e._id;this.$populated(t,_t,f({},pt,e.constructor)),e.$__.wasPopulated={value:_t},gt=!0}var wt=this.$__schema.options.typeKey;if(L.options&&Array.isArray(L.options[wt])&&L.options[wt].length&&L.options[wt][0]&&L.options[wt][0].ref&&function(t,e){if(!Array.isArray(t))return!1;if(0===t.length)return!1;var r,n=l(t);try{for(n.s();!(r=n.n()).done;){var i=r.value;if(!(i instanceof St))return!1;if(null==i.constructor.modelName)return!1;if(i.constructor.modelName!=e&&i.constructor.baseModelName!=e)return!1}}catch(t){n.e(t)}finally{n.f()}return!0}(e,L.options[wt][0].ref)){yt=f({},pt,e[0].constructor),this.$populated(t,e.map((function(t){return t._id})),yt);var Ot,$t=l(e);try{for($t.s();!(Ot=$t.n()).done;){var At=Ot.value;At.$__.wasPopulated={value:At._id}}}catch(t){$t.e(t)}finally{$t.f()}gt=!0}if(!vt||!L.$isSingleNested||!e.$__){var Et=this;null!=this.$__schema.singleNestedPaths[t]&&N.length>1&&(Et=bt(this,N,this.schema)),e=null!=n&&n.overwriteImmutable?L.applySetters(e,Et,!1,C,{overwriteImmutable:!0}):L.applySetters(e,Et,!1,C)}if(Array.isArray(e)&&!Array.isArray(L)&&L.$isMongooseDocumentArray&&0!==e.length&&null!=e[0]&&null!=e[0].$__&&null!=e[0].$__.populated){for(var xt=Object.keys(e[0].$__.populated),kt=function(){var r=It[Mt];i.$populated(t+"."+r,e.map((function(t){return t.$populated(r)})),e[0].$__.populated[r].options)},Mt=0,It=xt;Mt<It.length;Mt++)kt();gt=!0}if(!gt&&this.$__.populated){if(Array.isArray(e)&&this.$__.populated[t])for(var Tt=0;Tt<e.length;++Tt)e[Tt]instanceof St&&e.set(Tt,e[Tt]._id,!0);delete this.$__.populated[t]}null!=e&&L.$isSingleNested&&function(t,e,r){var n=e.schema;if(null!=n)for(var i=0,o=Object.keys(n.paths);i<o.length;i++){var a=o[i],s=n.paths[a];if(null!=s.$immutableSetter){var c=null==r?void 0:r.$__getValue(a);s.$immutableSetter.call(t,c)}}}(e,L,C),this.$markValid(t)}catch(r){r instanceof S.StrictModeError&&r.isImmutableError?this.invalidate(t,r):r instanceof S.CastError?(this.invalidate(r.path,r),r.$originalErrorPath&&this.invalidate(t,new S.CastError(L.instance,e,t,r.$originalErrorPath))):this.invalidate(t,new S.CastError(L.instance,e,t,r)),dt=!1}if(dt){var Bt,Rt=null,Nt=null;if(!y){var Dt=this.$isSubdocument?this.ownerDocument():this;Rt=Dt.$__.savedState,Nt=this.$isSubdocument?this.$__.fullPath+"."+t:t,Dt.$__saveInitialState(Nt)}this.$__set(ot,t,n,y,N,L,e,C);var Lt=!(null===(Bt=this.$__.session)||void 0===Bt||!Bt.transaction),Ct=this.$__.session&&this.$__.session[mt]&&this.$__.session[mt].has(this)&&this.$__.session[mt].get(this).modifiedPaths&&!this.$__.session[mt].get(this).modifiedPaths.has(Nt);null!=Rt&&Rt.hasOwnProperty(Nt)&&(!Lt||Ct)&&rt.deepEqual(e,Rt[Nt])&&this.unmarkModified(t)}return L.$isSingleNested&&(this.isDirectModified(t)||null==e)&&B(this,t),this},St.prototype.set=St.prototype.$set,St.prototype.$__shouldModify=function(t,e,r,n,i,o,a,s){return!(r&&r._skipMarkModified||!this.$isNew&&!(e in this.$__.activePaths.getStatePaths("modify"))&&(void 0!==a||this.$__isSelected(e))&&(void 0===a&&e in this.$__.activePaths.getStatePaths("default")||this.$populated(e)&&a instanceof St&&it(a._id,s)||it(a,void 0!==s?s:rt.getValue(e,this))&&(n||null==a||!(e in this.$__.activePaths.getStatePaths("default"))||!it(a,o.getDefault(this,n)))))},St.prototype.$__set=function(t,e,n,i,o,a,s,c){m=m||r(8578);var u=this.$__shouldModify(t,e,n,i,o,a,s,c);u?(this.$__.primitiveAtomics&&this.$__.primitiveAtomics[e]&&(delete this.$__.primitiveAtomics[e],0===Object.keys(this.$__.primitiveAtomics).length&&delete this.$__.primitiveAtomics),this.markModified(t),b||(b=r(2918)),s&&rt.isMongooseArray(s)&&(s._registerAtomic("$set",s),rt.isMongooseDocumentArray(s)&&s.forEach((function(t){t&&t.__parentArray&&(t.__parentArray=s)})))):Array.isArray(s)&&Array.isArray(c)&&rt.isMongooseArray(s)&&rt.isMongooseArray(c)&&(s[st]=c[st],s[at]=c[at],rt.isMongooseDocumentArray(s)&&s.forEach((function(t){null!=t&&(t.$isNew=!1)})));for(var f=this._doc,l=0,h=o.length,p="";l<h;l++){var d=l+1===h;if(p+=p?"."+o[l]:o[l],vt.has(o[l]))return;if(d)f instanceof Map?f.set(o[l],s):f.$isSingleNested?(o[l]in f||(f[o[l]]=s),f._doc[o[l]]=s,u&&f.markModified(o[l])):f[o[l]]=s;else{var y=f instanceof Map,v=y?f.get(o[l]):f[o[l]];rt.isPOJO(v)||v&&v instanceof m||v&&!Array.isArray(v)&&v.$isSingleNested||v&&Array.isArray(v)?f=v:null==v?(v={},y?f.set(o[l],v):f[o[l]]=v,f=v):f=v}}},St.prototype.$__getValue=function(t){return rt.getValue(t,this._doc)},St.prototype.$inc=function(t,e){var r=this;if(null==e&&(e=1),Array.isArray(t))return t.forEach((function(t){return r.$inc(t,e)})),this;var n=this.$__path(t);if(null==n){if("throw"===this.$__.strictMode)throw new P(t);if(!0===this.$__.strictMode)return this}else if("Number"!==n.instance)return this.invalidate(t,new S.CastError(n.instance,e,t)),this;var i=this.$__getValue(t)||0,o=!1,a=null,s=e;try{e=n.cast(e),s=(a=n.applySetters(i+e,this))-i,o=!0}catch(r){this.invalidate(t,new S.CastError("number",e,t,r))}return o&&(this.$__.primitiveAtomics=this.$__.primitiveAtomics||{},null==this.$__.primitiveAtomics[t]?this.$__.primitiveAtomics[t]={$inc:s}:this.$__.primitiveAtomics[t].$inc+=s,this.markModified(t),this.$__setValue(t,a)),this},St.prototype.$__setValue=function(t,e){return rt.setValue(t,e,this._doc),this},St.prototype.get=function(t,e,r){var n;null==r&&(r={}),e&&(n=this.$__schema.interpretAsType(t,e,this.$__schema.options));var i=r.noDottedPath,o=i?this.$__schema.paths[t]:this.$__path(t);if(null==o&&null!=(o=this.$__schema.virtualpath(t)))return o.applyGetters(void 0,this);if(i){var a=this._doc[t];return n&&(a=n.cast(a)),null!=o&&!1!==r.getters?o.applyGetters(a,this):a}if(null!=o&&"Mixed"===o.instance){var s=this.$__schema.virtualpath(t);null!=s&&(o=s)}var c=-1!==t.indexOf("."),u=this._doc,f=c?t.split("."):[t];"string"==typeof this.$__schema.aliases[f[0]]&&(f[0]=this.$__schema.aliases[f[0]]);for(var l=0,h=f.length;l<h;l++)u&&u._doc&&(u=u._doc),u=null==u?void 0:u instanceof Map?u.get(f[l],{getters:!1}):l===h-1?rt.getValue(f[l],u):u[f[l]];if(n&&(u=n.cast(u)),null!=o&&!1!==r.getters)u=o.applyGetters(u,this);else if(this.$__schema.nested[t]&&r.virtuals)return Pt(this,R(u)||{},{path:t});return u},St.prototype[ht]=St.prototype.get,St.prototype.$get=St.prototype.get,St.prototype.$__path=function(t){var e=this.$__.adhocPaths;return(e&&e.hasOwnProperty(t)?e[t]:null)||this.$__schema.path(t)},St.prototype.markModified=function(t,e){this.$__saveInitialState(t),this.$__.activePaths.modify(t),null==e||this.$isSubdocument||(this.$__.pathsToScopes=this.$__pathsToScopes||{},this.$__.pathsToScopes[t]=e)},St.prototype.$__saveInitialState=function(t){var e=this.$__.savedState,r=t;if(null!=e){var n=r.indexOf("."),i=-1===n?r:r.slice(0,n);e.hasOwnProperty(i)||(e[i]=R(this.$__getValue(i)))}},St.prototype.unmarkModified=function(t){this.$__.activePaths.init(t),null!=this.$__.pathsToScopes&&delete this.$__.pathsToScopes[t]},St.prototype.$ignore=function(t){this.$__.activePaths.ignore(t)},St.prototype.directModifiedPaths=function(){return Object.keys(this.$__.activePaths.getStatePaths("modify"))},St.prototype.$isEmpty=function(t){var e={minimize:!0,virtuals:!1,getters:!1,transform:!1};if(0!==arguments.length){var r=this.$get(t);return null==r||"object"===d(r)&&(rt.isPOJO(r)?At(r):0===Object.keys(r.toObject(e)).length)}return 0===Object.keys(this.toObject(e)).length},St.prototype.modifiedPaths=function(t){t=t||{};var e=Object.keys(this.$__.activePaths.getStatePaths("modify")),r=new Set,n=0,i=0,o=e.length;for(n=0;n<o;++n){var a=e[n],s=tt(a),c=s.length;for(i=0;i<c;++i)r.add(s[i]);if(t.includeChildren){var u=0,f=this.$get(a);if("object"===d(f)&&null!==f){f._doc&&(f=f._doc);var l=f.length;if(Array.isArray(f))for(u=0;u<l;++u){var h=a+"."+u;if(!r.has(h)&&(r.add(h),null!=f[u]&&f[u].$__)){var p=f[u].modifiedPaths(),y=0,b=p.length;for(y=0;y<b;++y)r.add(h+"."+p[y])}}else{var m=Object.keys(f),v=0,g=m.length;for(v=0;v<g;++v)r.add(a+"."+m[v])}}}}return Array.from(r)},St.prototype[ft]=St.prototype.modifiedPaths,St.prototype.isModified=function(t,e,r){var n=this;if(t){var i=e&&e.ignoreAtomics,o=this.$__.activePaths.states.modify;if(null==o)return!1;"string"==typeof t&&(t=-1===t.indexOf(" ")?[t]:t.split(" "));var a,s=l(t);try{for(s.s();!(a=s.n()).done;)if(null!=o[a.value])return!0}catch(t){s.e(t)}finally{s.f()}var c=r||this[ft](),u=t.some((function(t){return!!~c.indexOf(t)})),f=Object.keys(o);return i&&(f=f.filter((function(t){var e=n.$__getValue(t);return null==e||null==e[st]||void 0!==e[st].$set}))),u||t.some((function(t){return f.some