@alipay/faas-web-sdk 1.1.16-alpha.2 → 1.1.16-alpha.3

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.
Files changed (2) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"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},n(t)}var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};var r=function(){return r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var u,c,a,s,p,f,l=(u=function(t,n){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},u(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),y=function(t){function n(e,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=e,o.errorMessage=r,Object.setPrototypeOf(o,n.prototype),o}return l(n,t),Object.defineProperty(n.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),n.INVALID_PARAM_ERR=function(t,e){return new n(60001,"无效入参,参数 ".concat(t," ").concat(e))},n.NOT_FOUND_ERR=function(t){return new n(60001,t)},n.SERVER_ERR=function(t,e,r,o){var i=new n(t,e);return i.requestID=r,i.httpStatus=o,i},n.STORAGE_ERR=function(t,e,r){var o=new n(t,e);return o.requestID=r,o},n.NETWORK_ERR=function(t,e){var r=new n(-1,t.toString());return r.requestID=e,r},n}(Error),h=function(t,n){return void 0===n&&(n=void 0),function(e){if(!((null==e?void 0:e.complete)||(null==e?void 0:e.success)||(null==e?void 0:e.fail)))return t.call(n,e);var r=e.complete,o=e.success,i=e.fail,u=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(e,["complete","success","fail"]);t.call(n,u).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}},d=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var n=t.data||{code:-1,message:"未知异常"},e=n.code,r=n.message;throw y.SERVER_ERR(e,r,t.requestID,t.status)}return t.data.data},t}(),w=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},v=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},_=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},b=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},g=(c=function(t,n){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},c(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}c(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),m=function(){},O=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(m),j=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(O),P=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(m),A=function(t){function n(n,e){var r=t.call(this)||this;return r.name="$"+n,r.value=e,r}return g(n,t),n.prototype.stringify=function(){var t;return(t={})[this.name]=this.value,t},n}(m),x=(a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},a(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),S=function(t){function n(n){return t.call(this,"add",n)||this}return x(n,t),n}(A),C=(s=function(t,n){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},s(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}s(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),E=function(t){function n(n){return t.call(this,"addToSet",n)||this}return C(n,t),n}(A),R=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}();(f=p||(p={})).INVALID_PARAM="INVALID_PARAM",f.INVALID_COMMAND="INVALID_COMMAND";var T,I,N,q,D,k,$=function(t){function n(e){var r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return R(n,t),n.create=function(t,e){var r=new n(e);return r.code=t,r},n.invalidParam=function(t,e){return n.create(p.INVALID_PARAM,'无效入参 "'.concat(t,'", ').concat(e))},n.invalidCommand=function(t){return n.create(p.INVALID_COMMAND,t)},n}(Error),F=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(this.data instanceof m){if(!(this.data instanceof A))throw $.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));switch(n(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw $.invalidParam(this.prefix,"不支持函数");case"symbol":throw $.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw $.invalidParam(this.prefix,"不支持 undefined");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i);r[o]=u.stringify()}return r}},t.prototype.toJSON=function(){return this.stringify()},t}(),L=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),M=function(t){function n(n){var e=n.map((function(t){return new F(t).toJSON()}));return t.call(this,"and",e)||this}return L(n,t),n.prototype.pushCommand=function(t){this.value.push(new F(t).toJSON())},n}(A),B=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),U=function(t){function n(n){return t.call(this,"arrayElemAt",n)||this}return B(n,t),n}(A),H=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),J=function(t){function n(n){return t.call(this,"avg",new F(n).toJSON())||this}return H(n,t),n}(A),V=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),z=function(t){function n(n){return t.call(this,"cmp",n)||this}return V(n,t),n}(A),G=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),W=function(t){function n(n){return t.call(this,"concat",n)||this}return G(n,t),n}(A),K=(T=function(t,n){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},T(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}T(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),Y=function(t){function n(n){var e=Array.isArray(n)?{if:n[0],then:n[1],else:n[2]}:n;return t.call(this,"cond",new F(e).toJSON())||this}return K(n,t),n}(A),Q=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),X=function(t){function n(){return t.call(this,"count",{})||this}return Q(n,t),n}(A),Z=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),tt=function(t){function n(n){return t.call(this,"dateToString",n)||this}return Z(n,t),n}(A),nt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),et=function(t){function n(n){return t.call(this,"eq",n)||this}return nt(n,t),n}(A),rt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ot=function(t){function n(n){return t.call(this,"first",n)||this}return rt(n,t),n}(A),it=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ut=function(t){function n(n){return t.call(this,"ifNull",n)||this}return it(n,t),n}(A),ct=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),at=function(t){function n(n){return t.call(this,"in",n)||this}return ct(n,t),n}(A),st=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),pt=function(t){function n(n){return t.call(this,"indexOfArray",n)||this}return st(n,t),n}(A),ft=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),lt=function(t){function n(n){return t.call(this,"isArray",n)||this}return ft(n,t),n}(A),yt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ht=function(t){function n(n){return t.call(this,"last",n)||this}return yt(n,t),n}(A),dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),wt=function(t){function n(n){return t.call(this,"let",{vars:new F(n.vars).toJSON(),in:new F(n.in).toJSON()})||this}return dt(n,t),n}(A),vt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_t=function(t){function n(n){return t.call(this,"multiply",n)||this}return vt(n,t),n}(A),bt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),gt=function(t){function n(n){return t.call(this,"not",[new F(n).toJSON()])||this}return bt(n,t),n}(A),mt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ot=function(t){function n(n){return t.call(this,"push",n)||this}return mt(n,t),n}(A),jt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Pt=function(t){function n(n){return t.call(this,"size",n)||this}return jt(n,t),n}(A),At=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),xt=function(t){function n(n){return t.call(this,"slice",n)||this}return At(n,t),n}(A),St=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ct=function(t){function n(n){return t.call(this,"split",n)||this}return St(n,t),n}(A),Et=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Rt=function(t){function n(n){return t.call(this,"substr",n)||this}return Et(n,t),n}(A),Tt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),It=function(t){function n(n){return t.call(this,"substrBytes",n)||this}return Tt(n,t),n}(A),Nt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),qt=function(t){function n(n){var e=n.branches.map((function(t){return Array.isArray(t)?{case:new F(t[0]).toJSON(),then:t[1]}:{case:new F(t.case).toJSON(),then:t.then}}));return t.call(this,"switch",{branches:e,default:n.default})||this}return Nt(n,t),n}(A),Dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),kt=function(t){function n(n){return t.call(this,"toLower",n)||this}return Dt(n,t),n}(A),$t=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ft=function(t){function n(n){return t.call(this,"toUpper",n)||this}return $t(n,t),n}(A);!function(t){t.DESC="desc",t.ASC="asc"}(I||(I={})),function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(N||(N={})),function(t){t.update="update",t.findOneAndUpdate="findOneAndUpdate",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(q||(q={})),function(t){t.collection="collection",t.document="document"}(D||(D={})),function(t){t.addFields="$addFields",t.count="$count",t.match="$match",t.group="$group",t.project="$project",t.replaceRoot="$replaceRoot",t.sample="$sample",t.lookup="$lookup",t.sort="$sort",t.limit="$limit",t.skip="$skip",t.unwind="$unwind"}(k||(k={}));var Lt,Mt=function(){function t(t){this.regexp=t.regexp,this.options=t.options||""}return t.prototype.stringify=function(){return{$regexp:this.regexp,$options:this.options}},t}(),Bt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ut=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vn.stringify),e}return Bt(n,t),n.prototype.pushCommand=function(t){this.commands.push(vn.stringify(t))},n.prototype.stringify=function(){return{$and:this.commands}},n}(P),Ht=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Jt=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vn.stringify),e}return Ht(n,t),n.prototype.pushCommand=function(t){this.commands.push(vn.stringify(t))},n.prototype.stringify=function(){return{$or:this.commands}},n}(P),Vt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),zt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Vt(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(P),Gt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Wt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Gt(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(P),Kt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Yt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Kt(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(P),Qt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Xt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Qt(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(P),Zt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),tn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Zt(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(P),nn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),en=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return nn(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(P),rn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),on=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return rn(n,t),n.prototype.stringify=function(){return{$in:this.val}},n}(P),un=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),cn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return un(n,t),n.prototype.stringify=function(){return{$nin:this.val}},n}(P),an=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),sn=function(t){function n(n){var e=t.call(this)||this;return e.exists=n,e}return an(n,t),n.prototype.stringify=function(){return{$exists:this.exists}},n}(P),pn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),fn=function(t){function n(n,e){var r=t.call(this)||this;return r.divisor=n,r.remainder=e,r}return pn(n,t),n.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},n}(P),ln=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),yn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ln(n,t),n.prototype.stringify=function(){return{$all:this.val}},n}(P),hn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),dn=function(t){function n(n){var e=t.call(this)||this;return e.val=vn.stringify(n),e}return hn(n,t),n.prototype.stringify=function(){return{$elemMatch:this.val}},n}(P),wn=function(){function t(t){this.lastCmd=t}return t.prototype.appendCommand=function(t){return t=vn.unchain(t),this.lastCmd instanceof Ut?this.lastCmd.pushCommand(t):this.lastCmd=new Ut([this.lastCmd,t]),this},t.prototype.and=function(t){return this.appendCommand(t)},t.prototype.or=function(t){return t=vn.unchain(t),this.lastCmd instanceof Jt?this.lastCmd.pushCommand(t):this.lastCmd=new Jt([this.lastCmd,t]),this},t.prototype.not=function(t){return this.appendCommand(t)},t.prototype.nor=function(t){return this.appendCommand(t)},t.prototype.eq=function(t){return this.appendCommand(new zt(t))},t.prototype.neq=function(t){return this.appendCommand(new Wt(t))},t.prototype.lt=function(t){return this.appendCommand(new Yt(t))},t.prototype.lte=function(t){return this.appendCommand(new Xt(t))},t.prototype.gt=function(t){return this.appendCommand(new tn(t))},t.prototype.gte=function(t){return this.appendCommand(new en(t))},t.prototype.in=function(t){return this.appendCommand(new on(t))},t.prototype.nin=function(t){return this.appendCommand(new cn(t))},t.prototype.exists=function(t){return this.appendCommand(new sn(t))},t.prototype.mod=function(t,n){return this.appendCommand(new fn(t,n))},t.prototype.all=function(t){return this.appendCommand(new yn(t))},t.prototype.elemMatch=function(t){return this.appendCommand(new dn(vn.unchain(t)))},t.prototype.size=function(t){return this.appendCommand(t)},t}(),vn=function(){function t(){}return t.stringify=function(n){return(n=t.unchain(n))instanceof P?n.stringify():new _n(n).toJSON()},t.unchain=function(t){return t instanceof wn?t.lastCmd:t},t}(),_n=function(){function t(t,n){void 0===n&&(n=""),this.query=t,this.prefix=n}return t.prototype.stringify=function(){var e=this,r={},o=vn.unchain(this.query),i=n(o);if(o instanceof P)return o.stringify();if(o instanceof Mt)return o.stringify();if(Array.isArray(o))return o.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));if("number"===i)return o;if("boolean"===i)return o;if("string"===i)return o;if("bigint"===i)return o;if("function"===i)throw $.invalidParam(this.prefix,"不支持函数");if("symbol"===i)throw $.invalidParam(this.prefix,"不支持 symbol");if("undefined"===i)throw $.invalidParam(this.prefix,"不支持 undefined");if(null===o)return o;for(var u in o){var c=this.prefix?"".concat(this.prefix,".").concat(u):u,a=new t(o[u],c);r[u]=a.stringify()}return r},t.prototype.toJSON=function(){return this.stringify()},t}(),bn=function(){function t(){this.pipeline=[]}return t.prototype.addFields=function(t){return this.pushStage(k.addFields,t),this},t.prototype.count=function(t){return this.pushStage(k.count,t),this},t.prototype.match=function(t){return this.pushStage(k.match,t),this},t.prototype.group=function(t){return this.pushStage(k.group,t),this},t.prototype.project=function(t){return this.pushStage(k.project,t),this},t.prototype.replaceRoot=function(t){return this.pushStage(k.replaceRoot,t),this},t.prototype.sample=function(t){return this.pushStage(k.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(k.lookup,t),this},t.prototype.sort=function(t){return this.pushStage(k.sort,t),this},t.prototype.limit=function(t){return this.pushStage(k.limit,t),this},t.prototype.skip=function(t){return this.pushStage(k.skip,t),this},t.prototype.unwind=function(t){return this.pushStage(k.unwind,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var n,e;switch(t.name){case k.match:return{$match:new _n(t.param).toJSON()};case k.count:case k.sample:case k.lookup:case k.limit:case k.skip:case k.unwind:return(n={})[t.name]=t.param,n;case k.addFields:case k.group:case k.project:case k.replaceRoot:return(e={})[t.name]=new F(t.param).toJSON(),e;case k.sort:return{$sort:Object.keys(t.param).reduce((function(n,e){var r;switch(t.param[e]){case I.DESC:r=-1;break;case I.ASC:case 1:r=1;break;case-1:r=-1;break;default:r=1}return n[e]=r,n}),{})};default:var r=t.name;throw $.invalidParam(r,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,n){this.pipeline.push({name:t,param:n})},t}(),gn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),mn=function(t){function n(n){var e=t.call(this)||this;return e.commands=new F(n).toJSON(),e}return gn(n,t),n.prototype.stringify=function(){return{$expr:this.commands}},n}(P),On=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),jn=function(t){function n(n){return t.call(this,"gt",n)||this}return On(n,t),n}(A),Pn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),An=function(t){function n(n){return t.call(this,"gte",n)||this}return Pn(n,t),n}(A),xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Sn=function(t){function n(n){return t.call(this,"lt",n)||this}return xn(n,t),n}(A),Cn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),En=function(t){function n(n){return t.call(this,"lte",n)||this}return Cn(n,t),n}(A),Rn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Tn=function(t){function n(n){return t.call(this,"max",new F(n).toJSON())||this}return Rn(n,t),n}(A),In=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Nn=function(t){function n(n){return t.call(this,"min",new F(n).toJSON())||this}return In(n,t),n}(A),qn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Dn=function(t){function n(n){return t.call(this,"ne",n)||this}return qn(n,t),n}(A),kn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),$n=function(t){function n(n){var e=n.map((function(t){return new F(t).toJSON()}));return t.call(this,"or",e)||this}return kn(n,t),n.prototype.pushCommand=function(t){this.value.push(new F(t).toJSON())},n}(A),Fn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ln=function(t){function n(n){var e=Array.isArray(n)?n.map((function(t){return new F(t).toJSON()})):new F(n).toJSON();return t.call(this,"sum",e)||this}return Fn(n,t),n}(A),Mn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Bn=function(t){function e(n){var e=t.call(this)||this;return e.value=n,e}return Mn(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$addToSet"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return Array.isArray(this.value)?{$each:this.value}:"object"===n(this.value)&&this.value.hasOwnProperty("each")?{$each:this.value.each}:this.value},e}(j),Un=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Hn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Un(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$max"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),Jn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Vn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Jn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$min"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),zn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Gn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return zn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$mul"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),Wn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Kn=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Wn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.value||1},n}(j),Yn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Qn=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Yn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pull"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return new _n(this.value).toJSON()},n}(j),Xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Zn=function(t){function n(n){var e=t.call(this)||this;return e.values=n,e}return Xn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pullAll"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.values},n}(j),te=(Lt=function(t,n){return Lt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},Lt(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}Lt(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),ne=function(){return ne=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ne.apply(this,arguments)},ee=function(t){function e(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var i=t.call(this)||this;return"object"===n(i.value)&&i.value.hasOwnProperty("each")?i.value=e:(null==r?void 0:r.length)>0?i.value=[].concat.apply([],function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([e],r,!1)):i.value=e,i}return te(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){if(Array.isArray(this.value))return{$each:this.value};if("object"===n(this.value)&&this.value.hasOwnProperty("each")){var t=this.value,e={$each:t.each};return void 0!==t.position&&(e.$position=t.position),void 0!==t.slice&&(e.$slice=t.slice),void 0!==t.sort&&("string"==typeof t.sort?e.$sort=t.sort===I.DESC?-1:1:e.$sort=t.sort),e}return"object"===n(this.value)&&"string"==typeof this.value.$sort?ne(ne({},this.value),{$sort:this.value.$sort===I.DESC?-1:1}):this.value},e}(j),re=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),oe=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return re(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$unset"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return""},n}(O),ie=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ue=function(t){function n(n){var e=t.call(this)||this;return e.name=n,e}return ie(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$rename"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.name},n}(O),ce=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ae=function(t){function n(n){var e=t.call(this)||this;return e.data=n,e}return ce(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.data},n}(O),se=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),pe=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return se(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),fe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),le=function(t){function n(n){var e=t.call(this)||this;return e.command=vn.stringify(n),e}return fe(n,t),n.prototype.stringify=function(){return{$not:this.command.stringify()}},n}(P),ye=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),he=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(vn.stringify),e}return ye(n,t),n.prototype.pushCommand=function(t){this.commands.push(vn.stringify(t))},n.prototype.stringify=function(){return{$nor:this.commands}},n}(P),de=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),we=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return de(n,t),n.prototype.stringify=function(){return{$size:this.val}},n}(P),ve=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},_e=function(){function t(){}return t.prototype.pipeline=function(){return new bn},t.prototype.avg=function(t){return new J(t)},t.prototype.count=function(){return new X},t.prototype.max=function(t){return new Tn(t)},t.prototype.min=function(t){return new Nn(t)},t.prototype.sum=function(t){return new Ln(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new M(t)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new $n(t)},t.prototype.not=function(t){return new gt(t)},t.prototype.cmp=function(t,n){var e=Array.isArray(t)?t:[t,n];return new z(e)},t.prototype.eq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new et(e)},t.prototype.neq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Dn(e)},t.prototype.lt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Sn(e)},t.prototype.lte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new En(e)},t.prototype.gt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new jn(e)},t.prototype.gte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new An(e)},t.prototype.addToSet=function(t){return new E(t)},t.prototype.arrayElemAt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new U(e)},t.prototype.indexOfArray=function(t,n,e,r){var o=Array.isArray(t)?t:[t,n,e,r].filter((function(t){return void 0!==t}));return new pt(o)},t.prototype.isArray=function(t){return new lt(t)},t.prototype.size=function(t){return new Pt(t)},t.prototype.in=function(t,n){var e=Array.isArray(t)?t:[t,n];return new at(e)},t.prototype.slice=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e].filter((function(t){return void 0!==t}));return new xt(r)},t.prototype.ifNull=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ut(e)},t.prototype.cond=function(t){return new Y(t)},t.prototype.switch=function(t){return new qt(t)},t.prototype.concat=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:ve([t],n,!0);return new W(r)},t.prototype.dateToString=function(t){return new tt(t)},t.prototype.toLower=function(t){return new kt(t)},t.prototype.toUpper=function(t){return new Ft(t)},t.prototype.split=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Ct(e)},t.prototype.substr=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new Rt(r)},t.prototype.substrBytes=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new It(r)},t.prototype.first=function(t){return new ot(t)},t.prototype.last=function(t){return new ht(t)},t.prototype.push=function(t){return new Ot(t)},t.prototype.let=function(t){return new wt(t)},t.prototype.add=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Array.isArray(t[0])?t[0]:t;return new S(e)},t.prototype.multiply=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Array.isArray(t[0])?t[0]:t;return new _t(e)},t}(),be=function(){function t(){this.aggregate=new _e,this.Sort=I}return t.prototype.addToSet=function(t){return new Bn(t)},t.prototype.inc=function(t){return new pe(t)},t.prototype.max=function(t){return new Hn(t)},t.prototype.min=function(t){return new Vn(t)},t.prototype.mul=function(t){return new Gn(t)},t.prototype.pop=function(t){return new Kn(t)},t.prototype.pull=function(t){return new Qn(t)},t.prototype.pullAll=function(t){return new Zn(t)},t.prototype.push=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return new(ee.bind.apply(ee,ve([void 0,t],n,!1)))},t.prototype.remove=function(){return new oe},t.prototype.rename=function(t){return new ue(t)},t.prototype.set=function(t){return new ae(t)},t.prototype.expr=function(t){return new mn(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Ut(t.map(vn.unchain));return new wn(e)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Jt(t.map(vn.unchain));return new wn(e)},t.prototype.not=function(t){var n=new le(vn.unchain(t));return new wn(n)},t.prototype.nor=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new he(t.map(vn.unchain));return new wn(e)},t.prototype.eq=function(t){return new wn(new zt(t))},t.prototype.neq=function(t){return new wn(new Wt(t))},t.prototype.lt=function(t){return new wn(new Yt(t))},t.prototype.lte=function(t){return new wn(new Xt(t))},t.prototype.gt=function(t){return new wn(new tn(t))},t.prototype.gte=function(t){return new wn(new en(t))},t.prototype.in=function(t){return new wn(new on(t))},t.prototype.nin=function(t){return new wn(new cn(t))},t.prototype.exists=function(t){return new wn(new sn(t))},t.prototype.mod=function(t,n){return new wn(new fn(t,n))},t.prototype.all=function(t){return new wn(new yn(t))},t.prototype.elemMatch=function(t){return new wn(new dn(vn.unchain(t)))},t.prototype.size=function(t){return new wn(new we(t))},t}(),ge=function(){function t(){}return t.buildCollectionAction=function(t,n){return{target:D.collection,action:t,collectionName:n}},t.buildCollectionListQueryAction=function(t){return{target:D.collection,action:N.queryList,options:t}},t.buildDocumentAction=function(t,n,e){return{target:D.document,action:t,collectionName:n,options:e}},t}(),me=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Oe=function(t){function n(n){var e=t.call(this)||this;return e.collectionName=n,e}return me(n,t),n.prototype.end=function(){var t={$aggregate:this.done()};return ge.buildDocumentAction(q.aggregate,this.collectionName,t)},n}(bn),je=function(){function t(){this.res={}}return t.prototype.set=function(t,n){this.res.$set=this.res.$set||{},this.res.$set[t]=n},t.prototype.applyOperator=function(t,n,e){this.res[t]=this.res[t]||{},this.res[t][n]=e},t.prototype.emit=function(){return this.res},t}(),Pe=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(e){for(var r in e=e||new je,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],u=n(i);if(i instanceof m){if(!(i instanceof O))throw $.invalidCommand("Command 不是更新操作");e.applyOperator(i.operator,o,i.stringify())}else if("number"===u)e.set(o,i);else if("boolean"===u)e.set(o,i);else if("string"===u)e.set(o,i);else if("bigint"===u)e.set(o,i);else{if("function"===u)throw $.invalidParam(o,"不支持函数");if("symbol"===u)throw $.invalidParam(o,"不支持 symbol");if("undefined"===u)throw $.invalidParam(o,"不支持 undefined");if(null===i)e.set(o,i);else if(Array.isArray(i))e.set(o,i);else{new t(i,o).stringify(e)}}}return e},t.prototype.toJSON=function(){return this.stringify().emit()},t}(),Ae=function(){return Ae=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Ae.apply(this,arguments)},xe=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var e in t)t[e]?"object"!==n(t[e])&&(t[e]=1):t[e]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,n){return this.criteria.sort.push({field:t,sort:n}),this},t.prototype.update=function(t){return this.build(q.update,Ae(Ae({},this.baseOptions()),{$update:new Pe(t.data).toJSON()}))},t.prototype.updateAndReturn=function(t){var n=this.findOptions();return this.build(q.findOneAndUpdate,{$match:n.$match,$update:new Pe(t.data).toJSON(),$options:{$sort:n.$sort,$returnDocument:"after",$upsert:!1}})},t.prototype.set=function(t){return this.build(q.replace,Ae(Ae({},this.baseOptions()),{$replace:t.data}))},t.prototype.remove=function(){return this.build(q.delete,this.baseOptions())},t.prototype.get=function(){return this.build(q.queryList,Ae({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(q.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var n=new _n(this.criteria.match);t.$match=n.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var n=0,e=this.criteria.sort;n<e.length;n++){var r=e[n];t.$sort[r.field]=r.sort===I.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,n){return ge.buildDocumentAction(t,this.collectionName,n)},t}(),Se=function(){function t(t,n){this.collectionName=t,this.id=n}return t.prototype.update=function(t){return new xe(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new xe(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new xe(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new xe(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=q.query,t},t}(),Ce=function(){function t(t){this.collectionName=t}return t.prototype.add=function(t){if(!(null==t?void 0:t.data))throw $.invalidParam("data","不能为空");return Array.isArray(t.data)?this.batchAdd(t):ge.buildDocumentAction(q.create,this.collectionName,t.data)},t.prototype.batchAdd=function(t){if(t.data.length<=0)throw $.invalidParam("data","不能为空数组");if(t.data.length>200)throw $.invalidParam("data","最大长度 200");var n={$create:t.data};return"boolean"==typeof t.ordered&&(n.$ordered=t.ordered),ge.buildDocumentAction(q.batchCreate,this.collectionName,n)},t.prototype.doc=function(t){return new Se(this.collectionName,t)},t.prototype.limit=function(t){return new xe(this.collectionName).limit(t)},t.prototype.skip=function(t){return new xe(this.collectionName).skip(t)},t.prototype.where=function(t){return new xe(this.collectionName).where(t)},t.prototype.projection=function(t){return new xe(this.collectionName).projection(t)},t.prototype.orderBy=function(t,n){return new xe(this.collectionName).orderBy(t,n)},t.prototype.aggregate=function(){return new Oe(this.collectionName)},t.prototype.get=function(){return new xe(this.collectionName).get()},t.prototype.count=function(){return new xe(this.collectionName).count()},t}(),Ee=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Re=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function Te(){return function(t,n,e){var r=e.value;e.value=function(t){return Ee(this,void 0,void 0,(function(){return Re(this,(function(n){return[2,h(r,this)(t)]}))}))}}}var Ie,Ne=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},qe=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},De=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},ke=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new Oe(t)}return t.prototype.addFields=function(t){return this.builder.addFields(t),this},t.prototype.count=function(t){return this.builder.count(t),this},t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.project=function(t){return this.builder.project(t),this},t.prototype.replaceRoot=function(t){return this.builder.replaceRoot(t),this},t.prototype.sort=function(t){return this.builder.sort(t),this},t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.unwind=function(t){return this.builder.unwind(t),this},t.prototype.end=function(){return qe(this,void 0,void 0,(function(){var t,n,e;return De(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,"POST",n="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:n,data:t})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);u>3&&c&&Object.defineProperty(e,r,c)}([Te(),Ne("design:type",Function),Ne("design:paramtypes",[]),Ne("design:returntype",Promise)],t.prototype,"end",null),t}(),$e=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Fe=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Le=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Me=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Be=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new xe(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,n){return this.builder.orderBy(t,n),this},t.prototype.updateAndReturn=function(t){return Le(this,void 0,void 0,(function(){var n,e,r,o;return Me(this,(function(i){switch(i.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?findOneAndUpdate"),e=this.builder.updateAndReturn(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=i.sent(),[2,{updated:(o=d.handleResponse(r))?1:0,doc:o}]}}))}))},t.prototype.update=function(t){return Le(this,void 0,void 0,(function(){var n,e,r;return Me(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?update"),e=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.set=function(t){return Le(this,void 0,void 0,(function(){var n,e,r;return Me(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?replace"),e=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.remove=function(){return Le(this,void 0,void 0,(function(){var t,n,e;return Me(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?delete"),n=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.get=function(){return Le(this,void 0,void 0,(function(){var t,n,e;return Me(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?query"),n=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.count=function(){return Le(this,void 0,void 0,(function(){var t,n,e;return Me(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?count"),n=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,{total:d.handleResponse(e).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[Object]),Fe("design:returntype",Promise)],t.prototype,"updateAndReturn",null),$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[Object]),Fe("design:returntype",Promise)],t.prototype,"update",null),$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[Object]),Fe("design:returntype",Promise)],t.prototype,"set",null),$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[]),Fe("design:returntype",Promise)],t.prototype,"remove",null),$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[]),Fe("design:returntype",Promise)],t.prototype,"get",null),$e([Te(),Fe("design:type",Function),Fe("design:paramtypes",[]),Fe("design:returntype",Promise)],t.prototype,"count",null),t}(),Ue=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},He=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Je=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ve=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},ze=function(){function t(t,n,e){this.collectionName=t,this.id=n,this.options=e}return t.prototype.projection=function(t){return this.query.projection(t),this},t.prototype.field=function(t){return this.query.field(t),this},t.prototype.update=function(t){return Je(this,void 0,void 0,(function(){return Ve(this,(function(n){switch(n.label){case 0:return[4,this.query.update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Je(this,void 0,void 0,(function(){return Ve(this,(function(n){switch(n.label){case 0:return[4,this.query.updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Je(this,void 0,void 0,(function(){return Ve(this,(function(n){switch(n.label){case 0:return[4,this.query.set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Je(this,void 0,void 0,(function(){return Ve(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Je(this,void 0,void 0,(function(){var t,n;return Ve(this,(function(e){switch(e.label){case 0:return[4,this.query.get()];case 1:if(t=e.sent(),!(n=t[0])){if(this.options.throwOnNotFound)throw y.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,n]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return this._query||(this._query=new Be(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)),this._query},enumerable:!1,configurable:!0}),Ue([Te(),He("design:type",Function),He("design:paramtypes",[Object]),He("design:returntype",Promise)],t.prototype,"update",null),Ue([Te(),He("design:type",Function),He("design:paramtypes",[Object]),He("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Ue([Te(),He("design:type",Function),He("design:paramtypes",[Object]),He("design:returntype",Promise)],t.prototype,"set",null),Ue([Te(),He("design:type",Function),He("design:paramtypes",[]),He("design:returntype",Promise)],t.prototype,"remove",null),Ue([Te(),He("design:type",Function),He("design:paramtypes",[]),He("design:returntype",Promise)],t.prototype,"get",null),t}(),Ge=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},We=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Ke=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ye=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Qe=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new Ce(t)}return t.prototype.add=function(t){return Ke(this,void 0,void 0,(function(){var n,e,r;return Ye(this,(function(o){switch(o.label){case 0:return n=this.builder.add(t).options,"POST",e=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new ze(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new Be(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new Be(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new Be(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new Be(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new Be(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,n){return new Be(this.collectionName,this.options).orderBy(t,n)},t.prototype.aggregate=function(){return new ke(this.collectionName,this.options)},t.prototype.update=function(t){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(n){switch(n.label){case 0:return[4,new Be(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(n){switch(n.label){case 0:return[4,new Be(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(n){switch(n.label){case 0:return[4,new Be(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(t){switch(t.label){case 0:return[4,new Be(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(t){switch(t.label){case 0:return[4,new Be(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Ke(this,void 0,void 0,(function(){return Ye(this,(function(t){switch(t.label){case 0:return[4,new Be(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},Ge([Te(),We("design:type",Function),We("design:paramtypes",[Object]),We("design:returntype",Promise)],t.prototype,"add",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[Object]),We("design:returntype",Promise)],t.prototype,"update",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[Object]),We("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[Object]),We("design:returntype",Promise)],t.prototype,"set",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[]),We("design:returntype",Promise)],t.prototype,"remove",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[]),We("design:returntype",Promise)],t.prototype,"get",null),Ge([Te(),We("design:type",Function),We("design:paramtypes",[]),We("design:returntype",Promise)],t.prototype,"count",null),t}(),Xe=function(){return Xe=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Xe.apply(this,arguments)},Ze=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},tr=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},nr=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return Ze(this,void 0,void 0,(function(){return tr(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:n,path:e,data:r,headers:Xe({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),er=function(){function t(t){this.command=new be,this.options=Xe(Xe({},t),{httpclient:new nr(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw y.INVALID_PARAM_ERR("collectionName","不能为空");return new Qe(t,this.options)},t}(),rr=function(){return rr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},rr.apply(this,arguments)},or=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},ir=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},ur=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var n=t.trim().replace(/^cloud:\/\//,""),e=n.indexOf("/");if(e<=0)throw y.INVALID_PARAM_ERR("fileID","不合法");var r=n.substring(0,e),o=n.substring(e+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.uploadFile=function(t){return or(this,void 0,void 0,(function(){var n,e,r,o,i,u;return ir(this,(function(c){switch(c.label){case 0:if(n=this.checkCloudPath(t.cloudPath))throw y.INVALID_PARAM_ERR("cloudPath",n);return e=this.getUploadPath(t.cloudPath.trim()),[4,this.request({method:"GET",path:e})];case 1:return r=c.sent(),o=d.handleResponse(r),i=this.formatFileID(o.file_id),[4,this.options.fileUploader.upload({fileID:i,uploadURL:o.upload_url,fileContent:t.fileContent})];case 2:if(200!==(u=c.sent()).statusCode)throw y.STORAGE_ERR(-1,"上传文件 ".concat(o.upload_url," 失败"),r.requestID);return[2,{fileID:i,statusCode:u.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return or(this,void 0,void 0,(function(){var n,e,r,o,i,u;return ir(this,(function(c){switch(c.label){case 0:if(n=this.checkFileID(t.fileID))throw y.INVALID_PARAM_ERR("fileID",n);return e=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(e),[4,this.request({method:"GET",path:r})];case 1:return o=c.sent(),i=d.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(u=c.sent()).statusCode)throw y.STORAGE_ERR(-1,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,u]}}))}))},t.prototype.deleteFile=function(t){return or(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return ir(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw y.INVALID_PARAM_ERR("fileList","不能为空数组");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw y.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push(c)}return a=this.getBatchDeletePath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return or(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return ir(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw y.INVALID_PARAM_ERR("fileList","不能为空数组");if(n.length>50)throw y.INVALID_PARAM_ERR("fileList","最大长度 50");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw y.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push({file_id:c,expire:600})}return a=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return or(this,void 0,void 0,(function(){return ir(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:n,path:e,data:r,headers:rr({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),cr=function(){function t(){}return t.createCallFunction=function(t){return function(t){var n=t.httpclient;return h((function(t){return _(void 0,void 0,void 0,(function(){var e,r,o,i,u;return b(this,(function(c){switch(c.label){case 0:if(!t.name)throw y.INVALID_PARAM_ERR("name","缺失");return e={"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"},[4,n.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:e})];case 1:if(200!==(r=c.sent()).status)throw o=-1,i="",(u=r.data)&&(o=u.errCode,i=u.errMsg,u.errDetail&&(i+=",详情:".concat(u.errDetail))),y.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data}]}}))}))}))}(t)},t.createCallContainer=function(t){return function(t){return h((function(n){return w(void 0,void 0,void 0,(function(){return v(this,(function(e){throw new Error("not implemented in "+t.type+" with "+n)}))}))}))}(t)},t.createDatabase=function(t){return new er(t)},t.createStorage=function(t){return new ur(t)},t}();!function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(Ie||(Ie={}));var ar="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function sr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pr={exports:{}};var fr,lr={exports:{}};function yr(){return fr||(fr=1,function(t,n){var e;t.exports=(e=e||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==ar&&ar.crypto&&(e=ar.crypto),!e)try{e=require("crypto")}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=u.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||p).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var u=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=u<<24-(r+i)%4*8}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),s=i.enc={},p=s.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},f=s.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},y=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,u=this.blockSize,c=i/(4*u),s=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*u,p=t.min(4*s,i);if(s){for(var f=0;f<s;f+=u)this._doProcessBlock(o,f);e=o.splice(0,s),r.sigBytes-=p}return new a.init(e,p)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=y.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new h.HMAC.init(t,e).finalize(n)}}});var h=i.algo={};return i}(Math),e)}(lr)),lr.exports}!function(t,n){t.exports=yr().enc.Hex}(pr);var hr=sr(pr.exports),dr={exports:{}},wr={exports:{}};!function(t,n){var e;t.exports=(e=yr(),function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,u=n.algo,c=[],a=[];!function(){function n(n){for(var e=t.sqrt(n),r=2;r<=e;r++)if(!(n%r))return!1;return!0}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)n(r)&&(o<8&&(c[o]=e(t.pow(r,.5))),a[o]=e(t.pow(r,1/3)),o++),r++}();var s=[],p=u.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(t,n){for(var e=this._hash.words,r=e[0],o=e[1],i=e[2],u=e[3],c=e[4],p=e[5],f=e[6],l=e[7],y=0;y<64;y++){if(y<16)s[y]=0|t[n+y];else{var h=s[y-15],d=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,w=s[y-2],v=(w<<15|w>>>17)^(w<<13|w>>>19)^w>>>10;s[y]=d+s[y-7]+v+s[y-16]}var _=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),g=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&p^~c&f)+a[y]+s[y];l=f,f=p,p=c,c=u+g|0,u=i,i=o,o=r,r=g+(b+_)|0}e[0]=e[0]+r|0,e[1]=e[1]+o|0,e[2]=e[2]+i|0,e[3]=e[3]+u|0,e[4]=e[4]+c|0,e[5]=e[5]+p|0,e[6]=e[6]+f|0,e[7]=e[7]+l|0},_doFinalize:function(){var n=this._data,e=n.words,r=8*this._nDataBytes,o=8*n.sigBytes;return e[o>>>5]|=128<<24-o%32,e[14+(o+64>>>9<<4)]=t.floor(r/4294967296),e[15+(o+64>>>9<<4)]=r,n.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=i._createHelper(p),n.HmacSHA256=i._createHmacHelper(p)}(Math),e.SHA256)}(wr);var vr,_r=wr.exports,br=sr(_r),gr={exports:{}};!function(t,n){var e;t.exports=(e=yr(),vr||(vr=1,function(t,n){var e,r,o;t.exports=(r=(e=yr()).lib.Base,o=e.enc.Utf8,void(e.algo.HMAC=r.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=o.parse(n));var e=t.blockSize,r=4*e;n.sigBytes>r&&(n=t.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),u=this._iKey=n.clone(),c=i.words,a=u.words,s=0;s<e;s++)c[s]^=1549556828,a[s]^=909522486;i.sigBytes=u.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var n=this._hasher,e=n.finalize(t);return n.reset(),n.finalize(this._oKey.clone().concat(e))}})))}(gr)),e.HmacSHA256)}(dr);var mr=sr(dr.exports),Or=function(){function t(){}return t.sign=function(n){for(var e=n.signedHeaders.join(";"),r="",o=0,i=n.signedHeaders;o<i.length;o++){var u=i[o],c=n.headers[u];r+="".concat(u,":").concat(c,"\n")}var a=t.createHash(n.body||""),s=n.method.toUpperCase()+"\n"+n.path+"\n"+n.query+"\n"+r+"\n"+e+"\n"+a+"\n",p="HMAC-SHA256",f=t.createHash(s),l="".concat(p,"\n").concat(n.timestamp,"\n").concat(f,"\n"),y=t.createSha256(l,n.secretKey);return"".concat(p," Credential=").concat(n.secretId,", SignedHeaders=").concat(e,", Signature=").concat(y)},t.createSha256=function(t,n){return void 0===n&&(n=""),mr(t,n).toString(hr)},t.createHash=function(t){return br(t).toString(hr)},t}(),jr=function(){function t(){}return t.detectRuntime=function(){return window||void 0===("undefined"==typeof my?"undefined":n(my))?window||void 0===("undefined"==typeof wx?"undefined":n(wx))?Ie.WEB:Ie.WEICHAT_MINI:Ie.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))},t.parseUrl=function(t,n){if(n===Ie.WEB)return new URL(t);var e=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=e[1],o=e[2],i=e[3],u=e[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:u||""}},t}();var Pr=function(){function t(t,n){this.req=t,this.config=n}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),Ar=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e,o,u;return i(this,(function(i){switch(i.label){case 0:return[4,fetch(t,r({mode:"cors"},n))];case 1:return e=i.sent(),o={},e.headers.forEach((function(t,n){o[n]=t})),u={status:e.status},[4,e.json()];case 2:return[2,(u.data=i.sent(),u.headers=o,u)]}}))}))},t}(),xr=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,headers:null==n?void 0:n.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw e=r.sent(),console.error(e),new Error("error: ".concat(e.error,", message: ").concat(e.errorMessage));case 3:return[2]}}))}))},t}(),Sr=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){wx.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,header:null==n?void 0:n.headers,dataType:"json",success:function(t){e({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),Cr=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case Ie.ALIPAY_MINI:this.singleton=new xr;break;case Ie.WEB:this.singleton=new Ar;break;case Ie.WEICHAT_MINI:this.singleton=new Sr;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function Er(t,n){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return[4,n()];case 1:return o.sent(),e=t.config.fetch||Cr.default(t.config.runtime),r=t,[4,e.request(t.req.url,t.req.requestOptions)];case 2:return r.res=o.sent(),t.result={status:t.res.status,requestID:t.requestId,headers:t.res.headers,data:t.res.data},[2]}}))}))}function Rr(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:throw e=r.sent(),y.NETWORK_ERR(e,t.requestId);case 3:return[2]}}))}))}function Tr(t){return function(n,e){return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),u=jr.parseUrl(n.req.url,n.config.runtime),c={authorization:"","x-from-app-id":n.config.appId,"x-from-env-id":n.config.envId,"x-to-env-id":n.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":n.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var e,r=null===(e=n.req.requestOptions.headers)||void 0===e?void 0:e[t];r&&(c[t]=r)})),a=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:u.pathname,query:u.search.substring(1),secretId:n.config.secretId,secretKey:n.config.secretKey,method:n.req.requestOptions.method,headers:c,body:n.req.requestOptions.body,timestamp:o,signedHeaders:a},c.authorization=Or.sign(s),n.req.requestOptions.headers=r(r({},c),n.req.requestOptions.headers),[4,e()];case 1:return i.sent(),[2]}}))}))}}var Ir=function(){function t(t,n){var e;this.config=t,this.handler=(e=n,function(t,n){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var u=e[i];if(i===e.length&&(u=n),!u)return Promise.resolve();try{return Promise.resolve(u(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,u=t.headers;return o(this,void 0,void 0,(function(){var t,o,c,a;return i(this,(function(i){switch(i.label){case 0:return t=this.config.endpoint+e,o=r?JSON.stringify(r):r,c=jr.generateUUID(),u=Object.assign({"x-alipay-callid":c,"x-request-id":c,"x-alipay-source":"web,web-sdk","content-type":"application/json"},u),a=new Pr({url:t,requestOptions:{method:n,body:o,headers:u}},this.config),[4,this.handler(a)];case 1:return i.sent(),[2,a.result]}}))}))},t.createFunctionHttpclient=function(n){return new t(n,[Rr,Tr(["x-to-function-name"]),Er])},t.createDatabaseHttpclient=function(n){return new t(n,[Rr,Tr(["x-data-api-type","x-expire-timestamp"]),Er])},t.createStorageHttpclient=function(n){return new t(n,[Rr,Tr(["x-data-api-type","x-expire-timestamp"]),Er])},t}(),Nr=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n=t.uploadURL,e=t.fileContent,[4,fetch(n,{method:"PUT",mode:"cors",body:e})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),qr=function(t){function n(e){var r=Ir.createStorageHttpclient(e),o=n.getFileUploader(e);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:e.envId})||this}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===Ie.WEB)return Nr.create();throw y.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},n}(ur),Dr=function(){function t(t){var n=t.resourceEnv||t.envId,e=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(n,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:e,envId:n,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||jr.detectRuntime(),functionName:""}}return t.prototype.init=function(){},t.prototype.callFunction=function(t){var n;return o(this,void 0,void 0,(function(){var e,o;return i(this,(function(i){switch(i.label){case 0:return e=r(r({},this.config),{envId:(null===(n=t.config)||void 0===n?void 0:n.env)||this.config.envId,functionName:t.name}),o=Ir.createFunctionHttpclient(e),[4,cr.createCallFunction({type:"web",httpclient:o})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new qr(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,n.sent()]}}))}))},t.RUNTIME=Ie,t}();t.Cloud=Dr}));
1
+ !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).cloud={})}(this,(function(t){"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},n(t)}var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},e(t,n)};var r=function(){return r=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},r.apply(this,arguments)};function o(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){var n;t.done?o(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(u,c)}a((r=r.apply(t,n||[])).next())}))}function i(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}}"function"==typeof SuppressedError&&SuppressedError;var u,c,a,s,p,f,l=(u=function(t,n){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},u(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}u(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),y=function(t){function n(e,r){var o=t.call(this,r)||this;return o.name="FaasError",o.error=e,o.errorMessage=r,Object.setPrototypeOf(o,n.prototype),o}return l(n,t),Object.defineProperty(n.prototype,"errCode",{get:function(){return this.error},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"errMsg",{get:function(){return this.message},enumerable:!1,configurable:!0}),n.INVALID_PARAM_ERR=function(t,e){return new n(60001,"无效入参,参数 ".concat(t," ").concat(e))},n.NOT_FOUND_ERR=function(t){return new n(60001,t)},n.SERVER_ERR=function(t,e,r,o){var i=new n(t,e);return i.requestID=r,i.httpStatus=o,i},n.STORAGE_ERR=function(t,e,r){var o=new n(t,e);return o.requestID=r,o},n.NETWORK_ERR=function(t,e){var r=new n(-1,t.toString());return r.requestID=e,r},n}(Error),h=function(t,n){return void 0===n&&(n=void 0),function(e){if(!((null==e?void 0:e.complete)||(null==e?void 0:e.success)||(null==e?void 0:e.fail)))return t.call(n,e);var r=e.complete,o=e.success,i=e.fail,u=function(t,n){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&n.indexOf(r)<0&&(e[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)n.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(e[r[o]]=t[r[o]])}return e}(e,["complete","success","fail"]);t.call(n,u).then((function(t){return null==o||o(t),t}),(function(t){return null==i||i(t),t})).then((function(t){null==r||r(t)}))}},d=function(){function t(){}return t.handleResponse=function(t){if(200!==t.status){var n=t.data||{code:-1,message:"未知异常"},e=n.code,r=n.message;throw y.SERVER_ERR(e,r,t.requestID,t.status)}return t.data.data},t}(),w=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},v=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},_=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},b=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},g=(c=function(t,n){return c=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},c(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}c(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),m=function(){},O=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(m),j=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(O),P=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return g(n,t),n}(m),A=function(t){function n(n,e){var r=t.call(this)||this;return r.name="$"+n,r.value=e,r}return g(n,t),n.prototype.stringify=function(){var t;return(t={})[this.name]=this.value,t},n}(m),x=(a=function(t,n){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},a(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}a(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),S=function(t){function n(n){return t.call(this,"add",n)||this}return x(n,t),n}(A),C=(s=function(t,n){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},s(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}s(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),E=function(t){function n(n){return t.call(this,"addToSet",n)||this}return C(n,t),n}(A),R=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}();(f=p||(p={})).INVALID_PARAM="INVALID_PARAM",f.INVALID_COMMAND="INVALID_COMMAND";var T,I,N,q,D,k,$=function(t){function n(e){var r=t.call(this,e)||this;return Object.setPrototypeOf(r,n.prototype),r}return R(n,t),n.create=function(t,e){var r=new n(e);return r.code=t,r},n.invalidParam=function(t,e){return n.create(p.INVALID_PARAM,'无效入参 "'.concat(t,'", ').concat(e))},n.invalidCommand=function(t){return n.create(p.INVALID_COMMAND,t)},n}(Error),F=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(){var e=this;if(this.data instanceof m){if(!(this.data instanceof A))throw $.invalidCommand("Command 不是聚合操作");return this.data.stringify()}if(null===this.data)return this.data;if(Array.isArray(this.data))return this.data.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));switch(n(this.data)){case"number":case"boolean":case"string":case"bigint":return this.data;case"function":throw $.invalidParam(this.prefix,"不支持函数");case"symbol":throw $.invalidParam(this.prefix,"不支持 symbol");case"undefined":throw $.invalidParam(this.prefix,"不支持 undefined");default:var r={};for(var o in this.data){var i=this.prefix?"".concat(this.prefix,".").concat(o):o,u=new t(this.data[o],i);r[o]=u.stringify()}return r}},t.prototype.toJSON=function(){return this.stringify()},t}(),L=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),M=function(t){function n(n){var e=n.map((function(t){return new F(t).toJSON()}));return t.call(this,"and",e)||this}return L(n,t),n.prototype.pushCommand=function(t){this.value.push(new F(t).toJSON())},n}(A),B=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),U=function(t){function n(n){return t.call(this,"arrayElemAt",n)||this}return B(n,t),n}(A),H=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),J=function(t){function n(n){return t.call(this,"avg",new F(n).toJSON())||this}return H(n,t),n}(A),V=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),z=function(t){function n(n){return t.call(this,"cmp",n)||this}return V(n,t),n}(A),G=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),W=function(t){function n(n){return t.call(this,"concat",n)||this}return G(n,t),n}(A),K=(T=function(t,n){return T=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},T(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}T(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),Y=function(t){function n(n){var e=Array.isArray(n)?{if:n[0],then:n[1],else:n[2]}:n;return t.call(this,"cond",new F(e).toJSON())||this}return K(n,t),n}(A),Q=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),X=function(t){function n(){return t.call(this,"count",{})||this}return Q(n,t),n}(A),Z=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),tt=function(t){function n(n){return t.call(this,"dateToString",n)||this}return Z(n,t),n}(A),nt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),et=function(t){function n(n){return t.call(this,"eq",n)||this}return nt(n,t),n}(A),rt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ot=function(t){function n(n){return t.call(this,"first",n)||this}return rt(n,t),n}(A),it=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ut=function(t){function n(n){return t.call(this,"ifNull",n)||this}return it(n,t),n}(A),ct=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),at=function(t){function n(n){return t.call(this,"in",n)||this}return ct(n,t),n}(A),st=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),pt=function(t){function n(n){return t.call(this,"indexOfArray",n)||this}return st(n,t),n}(A),ft=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),lt=function(t){function n(n){return t.call(this,"isArray",n)||this}return ft(n,t),n}(A),yt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ht=function(t){function n(n){return t.call(this,"last",n)||this}return yt(n,t),n}(A),dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),wt=function(t){function n(n){return t.call(this,"let",{vars:new F(n.vars).toJSON(),in:new F(n.in).toJSON()})||this}return dt(n,t),n}(A),vt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_t=function(t){function n(n){return t.call(this,"mergeObjects",new F(n).toJSON())||this}return vt(n,t),n}(A),bt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),gt=function(t){function n(n){return t.call(this,"multiply",n)||this}return bt(n,t),n}(A),mt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ot=function(t){function n(n){return t.call(this,"not",[new F(n).toJSON()])||this}return mt(n,t),n}(A),jt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Pt=function(t){function n(n){return t.call(this,"push",n)||this}return jt(n,t),n}(A),At=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),xt=function(t){function n(n){return t.call(this,"size",n)||this}return At(n,t),n}(A),St=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ct=function(t){function n(n){return t.call(this,"slice",n)||this}return St(n,t),n}(A),Et=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Rt=function(t){function n(n){return t.call(this,"split",n)||this}return Et(n,t),n}(A),Tt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),It=function(t){function n(n){return t.call(this,"substr",n)||this}return Tt(n,t),n}(A),Nt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),qt=function(t){function n(n){return t.call(this,"substrBytes",n)||this}return Nt(n,t),n}(A),Dt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),kt=function(t){function n(n){var e=n.branches.map((function(t){return Array.isArray(t)?{case:new F(t[0]).toJSON(),then:t[1]}:{case:new F(t.case).toJSON(),then:t.then}}));return t.call(this,"switch",{branches:e,default:n.default})||this}return Dt(n,t),n}(A),$t=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ft=function(t){function n(n){return t.call(this,"toLower",n)||this}return $t(n,t),n}(A),Lt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Mt=function(t){function n(n){return t.call(this,"toUpper",n)||this}return Lt(n,t),n}(A);!function(t){t.DESC="desc",t.ASC="asc"}(I||(I={})),function(t){t.update="update",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create"}(N||(N={})),function(t){t.update="update",t.findOneAndUpdate="findOneAndUpdate",t.replace="replace",t.delete="delete",t.query="query",t.queryList="queryList",t.create="create",t.batchCreate="batchCreate",t.count="count",t.aggregate="aggregate"}(q||(q={})),function(t){t.collection="collection",t.document="document"}(D||(D={})),function(t){t.addFields="$addFields",t.count="$count",t.match="$match",t.group="$group",t.project="$project",t.replaceRoot="$replaceRoot",t.sample="$sample",t.lookup="$lookup",t.sort="$sort",t.limit="$limit",t.skip="$skip",t.unwind="$unwind"}(k||(k={}));var Bt,Ut=function(){function t(t){this.regexp=t.regexp,this.options=t.options||""}return t.prototype.stringify=function(){return{$regex:this.regexp,$options:this.options}},t}(),Ht=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Jt=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(bn.stringify),e}return Ht(n,t),n.prototype.pushCommand=function(t){this.commands.push(bn.stringify(t))},n.prototype.stringify=function(){return{$and:this.commands}},n}(P),Vt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),zt=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(bn.stringify),e}return Vt(n,t),n.prototype.pushCommand=function(t){this.commands.push(bn.stringify(t))},n.prototype.stringify=function(){return{$or:this.commands}},n}(P),Gt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Wt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Gt(n,t),n.prototype.stringify=function(){return{$eq:this.val}},n}(P),Kt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Yt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Kt(n,t),n.prototype.stringify=function(){return{$ne:this.val}},n}(P),Qt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Xt=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Qt(n,t),n.prototype.stringify=function(){return{$lt:this.val}},n}(P),Zt=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),tn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return Zt(n,t),n.prototype.stringify=function(){return{$lte:this.val}},n}(P),nn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),en=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return nn(n,t),n.prototype.stringify=function(){return{$gt:this.val}},n}(P),rn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),on=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return rn(n,t),n.prototype.stringify=function(){return{$gte:this.val}},n}(P),un=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),cn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return un(n,t),n.prototype.stringify=function(){return{$in:this.val}},n}(P),an=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),sn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return an(n,t),n.prototype.stringify=function(){return{$nin:this.val}},n}(P),pn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),fn=function(t){function n(n){var e=t.call(this)||this;return e.exists=n,e}return pn(n,t),n.prototype.stringify=function(){return{$exists:this.exists}},n}(P),ln=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),yn=function(t){function n(n,e){var r=t.call(this)||this;return r.divisor=n,r.remainder=e,r}return ln(n,t),n.prototype.stringify=function(){return{$mod:[this.divisor,this.remainder]}},n}(P),hn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),dn=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return hn(n,t),n.prototype.stringify=function(){return{$all:this.val}},n}(P),wn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),vn=function(t){function n(n){var e=t.call(this)||this;return e.val=bn.stringify(n),e}return wn(n,t),n.prototype.stringify=function(){return{$elemMatch:this.val}},n}(P),_n=function(){function t(t){this.lastCmd=t}return t.prototype.appendCommand=function(t){return t=bn.unchain(t),this.lastCmd instanceof Jt?this.lastCmd.pushCommand(t):this.lastCmd=new Jt([this.lastCmd,t]),this},t.prototype.and=function(t){return this.appendCommand(t)},t.prototype.or=function(t){return t=bn.unchain(t),this.lastCmd instanceof zt?this.lastCmd.pushCommand(t):this.lastCmd=new zt([this.lastCmd,t]),this},t.prototype.not=function(t){return this.appendCommand(t)},t.prototype.nor=function(t){return this.appendCommand(t)},t.prototype.eq=function(t){return this.appendCommand(new Wt(t))},t.prototype.neq=function(t){return this.appendCommand(new Yt(t))},t.prototype.lt=function(t){return this.appendCommand(new Xt(t))},t.prototype.lte=function(t){return this.appendCommand(new tn(t))},t.prototype.gt=function(t){return this.appendCommand(new en(t))},t.prototype.gte=function(t){return this.appendCommand(new on(t))},t.prototype.in=function(t){return this.appendCommand(new cn(t))},t.prototype.nin=function(t){return this.appendCommand(new sn(t))},t.prototype.exists=function(t){return this.appendCommand(new fn(t))},t.prototype.mod=function(t,n){return this.appendCommand(new yn(t,n))},t.prototype.all=function(t){return this.appendCommand(new dn(t))},t.prototype.elemMatch=function(t){return this.appendCommand(new vn(bn.unchain(t)))},t.prototype.size=function(t){return this.appendCommand(t)},t}(),bn=function(){function t(){}return t.stringify=function(n){return(n=t.unchain(n))instanceof P?n.stringify():new gn(n).toJSON()},t.unchain=function(t){return t instanceof _n?t.lastCmd:t},t}(),gn=function(){function t(t,n){void 0===n&&(n=""),this.query=t,this.prefix=n}return t.prototype.stringify=function(){var e=this,r={},o=bn.unchain(this.query),i=n(o);if(o instanceof P)return o.stringify();if(o instanceof Ut)return o.stringify();if(Array.isArray(o))return o.map((function(n,r){return new t(n,"".concat(e.prefix,".$.").concat(r)).stringify()}));if("number"===i)return o;if("boolean"===i)return o;if("string"===i)return o;if("bigint"===i)return o;if("function"===i)throw $.invalidParam(this.prefix,"不支持函数");if("symbol"===i)throw $.invalidParam(this.prefix,"不支持 symbol");if("undefined"===i)throw $.invalidParam(this.prefix,"不支持 undefined");if(null===o)return o;for(var u in o){var c=this.prefix?"".concat(this.prefix,".").concat(u):u,a=new t(o[u],c);r[u]=a.stringify()}return r},t.prototype.toJSON=function(){return this.stringify()},t}(),mn=function(){function t(){this.pipeline=[]}return t.prototype.addFields=function(t){return this.pushStage(k.addFields,t),this},t.prototype.count=function(t){return this.pushStage(k.count,t),this},t.prototype.match=function(t){return this.pushStage(k.match,t),this},t.prototype.group=function(t){return this.pushStage(k.group,t),this},t.prototype.project=function(t){return this.pushStage(k.project,t),this},t.prototype.replaceRoot=function(t){return this.pushStage(k.replaceRoot,t),this},t.prototype.sample=function(t){return this.pushStage(k.sample,t),this},t.prototype.lookup=function(t){return this.pushStage(k.lookup,t),this},t.prototype.sort=function(t){return this.pushStage(k.sort,t),this},t.prototype.limit=function(t){return this.pushStage(k.limit,t),this},t.prototype.skip=function(t){return this.pushStage(k.skip,t),this},t.prototype.unwind=function(t){return this.pushStage(k.unwind,t),this},t.prototype.done=function(){return this.pipeline.map((function(t){var n,e;switch(t.name){case k.match:return{$match:new gn(t.param).toJSON()};case k.count:case k.sample:case k.lookup:case k.limit:case k.skip:case k.unwind:return(n={})[t.name]=t.param,n;case k.addFields:case k.group:case k.project:case k.replaceRoot:return(e={})[t.name]=new F(t.param).toJSON(),e;case k.sort:return{$sort:Object.keys(t.param).reduce((function(n,e){var r;switch(t.param[e]){case I.DESC:r=-1;break;case I.ASC:case 1:r=1;break;case-1:r=-1;break;default:r=1}return n[e]=r,n}),{})};default:var r=t.name;throw $.invalidParam(r,"不支持的 aggregate 操作")}}))},t.prototype.pushStage=function(t,n){this.pipeline.push({name:t,param:n})},t}(),On=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),jn=function(t){function n(n){var e=t.call(this)||this;return e.commands=new F(n).toJSON(),e}return On(n,t),n.prototype.stringify=function(){return{$expr:this.commands}},n}(P),Pn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),An=function(t){function n(n){return t.call(this,"gt",n)||this}return Pn(n,t),n}(A),xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Sn=function(t){function n(n){return t.call(this,"gte",n)||this}return xn(n,t),n}(A),Cn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),En=function(t){function n(n){return t.call(this,"lt",n)||this}return Cn(n,t),n}(A),Rn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Tn=function(t){function n(n){return t.call(this,"lte",n)||this}return Rn(n,t),n}(A),In=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Nn=function(t){function n(n){return t.call(this,"max",new F(n).toJSON())||this}return In(n,t),n}(A),qn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Dn=function(t){function n(n){return t.call(this,"min",new F(n).toJSON())||this}return qn(n,t),n}(A),kn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),$n=function(t){function n(n){return t.call(this,"ne",n)||this}return kn(n,t),n}(A),Fn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Ln=function(t){function n(n){var e=n.map((function(t){return new F(t).toJSON()}));return t.call(this,"or",e)||this}return Fn(n,t),n.prototype.pushCommand=function(t){this.value.push(new F(t).toJSON())},n}(A),Mn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Bn=function(t){function n(n){var e=Array.isArray(n)?n.map((function(t){return new F(t).toJSON()})):new F(n).toJSON();return t.call(this,"sum",e)||this}return Mn(n,t),n}(A),Un=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Hn=function(t){function e(n){var e=t.call(this)||this;return e.value=n,e}return Un(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$addToSet"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){return Array.isArray(this.value)?{$each:this.value}:"object"===n(this.value)&&this.value.hasOwnProperty("each")?{$each:this.value.each}:this.value},e}(j),Jn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Vn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Jn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$max"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),zn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Gn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return zn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$min"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),Wn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Kn=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return Wn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$mul"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),Yn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Qn=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Yn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pop"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.value||1},n}(j),Xn=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Zn=function(t){function n(n){var e=t.call(this)||this;return e.value=n,e}return Xn(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pull"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return new gn(this.value).toJSON()},n}(j),te=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ne=function(t){function n(n){var e=t.call(this)||this;return e.values=n,e}return te(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$pullAll"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.values},n}(j),ee=(Bt=function(t,n){return Bt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},Bt(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}Bt(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}),re=function(){return re=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},re.apply(this,arguments)},oe=function(t){function e(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var i=t.call(this)||this;return"object"===n(i.value)&&i.value.hasOwnProperty("each")?i.value=e:(null==r?void 0:r.length)>0?i.value=[].concat.apply([],function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}([e],r,!1)):i.value=e,i}return ee(e,t),Object.defineProperty(e.prototype,"operator",{get:function(){return"$push"},enumerable:!1,configurable:!0}),e.prototype.stringify=function(){if(Array.isArray(this.value))return{$each:this.value};if("object"===n(this.value)&&this.value.hasOwnProperty("each")){var t=this.value,e={$each:t.each};return void 0!==t.position&&(e.$position=t.position),void 0!==t.slice&&(e.$slice=t.slice),void 0!==t.sort&&("string"==typeof t.sort?e.$sort=t.sort===I.DESC?-1:1:e.$sort=t.sort),e}return"object"===n(this.value)&&"string"==typeof this.value.$sort?re(re({},this.value),{$sort:this.value.$sort===I.DESC?-1:1}):this.value},e}(j),ie=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ue=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return ie(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$unset"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return""},n}(O),ce=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),ae=function(t){function n(n){var e=t.call(this)||this;return e.name=n,e}return ce(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$rename"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.name},n}(O),se=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),pe=function(t){function n(n){var e=t.call(this)||this;return e.data=n,e}return se(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$set"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.data},n}(O),fe=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),le=function(t){function n(n){var e=t.call(this)||this;return e.num=n,e}return fe(n,t),Object.defineProperty(n.prototype,"operator",{get:function(){return"$inc"},enumerable:!1,configurable:!0}),n.prototype.stringify=function(){return this.num},n}(O),ye=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),he=function(t){function n(n){var e=t.call(this)||this;return e.command=bn.stringify(n),e}return ye(n,t),n.prototype.stringify=function(){return{$not:this.command.stringify()}},n}(P),de=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),we=function(t){function n(n){var e=t.call(this)||this;return e.commands=n.map(bn.stringify),e}return de(n,t),n.prototype.pushCommand=function(t){this.commands.push(bn.stringify(t))},n.prototype.stringify=function(){return{$nor:this.commands}},n}(P),ve=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),_e=function(t){function n(n){var e=t.call(this)||this;return e.val=n,e}return ve(n,t),n.prototype.stringify=function(){return{$size:this.val}},n}(P),be=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))},ge=function(){function t(){}return t.prototype.pipeline=function(){return new mn},t.prototype.avg=function(t){return new J(t)},t.prototype.count=function(){return new X},t.prototype.max=function(t){return new Nn(t)},t.prototype.min=function(t){return new Dn(t)},t.prototype.sum=function(t){return new Bn(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new M(t)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return t=Array.isArray(t[0])?t[0]:t,new Ln(t)},t.prototype.not=function(t){return new Ot(t)},t.prototype.cmp=function(t,n){var e=Array.isArray(t)?t:[t,n];return new z(e)},t.prototype.eq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new et(e)},t.prototype.neq=function(t,n){var e=Array.isArray(t)?t:[t,n];return new $n(e)},t.prototype.lt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new En(e)},t.prototype.lte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Tn(e)},t.prototype.gt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new An(e)},t.prototype.gte=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Sn(e)},t.prototype.addToSet=function(t){return new E(t)},t.prototype.arrayElemAt=function(t,n){var e=Array.isArray(t)?t:[t,n];return new U(e)},t.prototype.indexOfArray=function(t,n,e,r){var o=Array.isArray(t)?t:[t,n,e,r].filter((function(t){return void 0!==t}));return new pt(o)},t.prototype.isArray=function(t){return new lt(t)},t.prototype.size=function(t){return new xt(t)},t.prototype.in=function(t,n){var e=Array.isArray(t)?t:[t,n];return new at(e)},t.prototype.slice=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e].filter((function(t){return void 0!==t}));return new Ct(r)},t.prototype.ifNull=function(t,n){var e=Array.isArray(t)?t:[t,n];return new ut(e)},t.prototype.cond=function(t){return new Y(t)},t.prototype.switch=function(t){return new kt(t)},t.prototype.concat=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];var r=Array.isArray(t)?t:be([t],n,!0);return new W(r)},t.prototype.dateToString=function(t){return new tt(t)},t.prototype.toLower=function(t){return new Ft(t)},t.prototype.toUpper=function(t){return new Mt(t)},t.prototype.split=function(t,n){var e=Array.isArray(t)?t:[t,n];return new Rt(e)},t.prototype.substr=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new It(r)},t.prototype.substrBytes=function(t,n,e){var r=Array.isArray(t)?t:[t,n,e];return new qt(r)},t.prototype.first=function(t){return new ot(t)},t.prototype.last=function(t){return new ht(t)},t.prototype.push=function(t){return new Pt(t)},t.prototype.let=function(t){return new wt(t)},t.prototype.add=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Array.isArray(t[0])?t[0]:t;return new S(e)},t.prototype.multiply=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var e=Array.isArray(t[0])?t[0]:t;return new gt(e)},t.prototype.mergeObjects=function(t){return new _t(t)},t}(),me=function(){function t(){this.aggregate=new ge,this.Sort=I}return t.prototype.addToSet=function(t){return new Hn(t)},t.prototype.inc=function(t){return new le(t)},t.prototype.max=function(t){return new Vn(t)},t.prototype.min=function(t){return new Gn(t)},t.prototype.mul=function(t){return new Kn(t)},t.prototype.pop=function(t){return new Qn(t)},t.prototype.pull=function(t){return new Zn(t)},t.prototype.pullAll=function(t){return new ne(t)},t.prototype.push=function(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];return new(oe.bind.apply(oe,be([void 0,t],n,!1)))},t.prototype.remove=function(){return new ue},t.prototype.rename=function(t){return new ae(t)},t.prototype.set=function(t){return new pe(t)},t.prototype.expr=function(t){return new jn(t)},t.prototype.and=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new Jt(t.map(bn.unchain));return new _n(e)},t.prototype.or=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new zt(t.map(bn.unchain));return new _n(e)},t.prototype.not=function(t){var n=new he(bn.unchain(t));return new _n(n)},t.prototype.nor=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t=Array.isArray(t[0])?t[0]:t;var e=new we(t.map(bn.unchain));return new _n(e)},t.prototype.eq=function(t){return new _n(new Wt(t))},t.prototype.neq=function(t){return new _n(new Yt(t))},t.prototype.lt=function(t){return new _n(new Xt(t))},t.prototype.lte=function(t){return new _n(new tn(t))},t.prototype.gt=function(t){return new _n(new en(t))},t.prototype.gte=function(t){return new _n(new on(t))},t.prototype.in=function(t){return new _n(new cn(t))},t.prototype.nin=function(t){return new _n(new sn(t))},t.prototype.exists=function(t){return new _n(new fn(t))},t.prototype.mod=function(t,n){return new _n(new yn(t,n))},t.prototype.all=function(t){return new _n(new dn(t))},t.prototype.elemMatch=function(t){return new _n(new vn(bn.unchain(t)))},t.prototype.size=function(t){return new _n(new _e(t))},t}(),Oe=function(){function t(){}return t.buildCollectionAction=function(t,n){return{target:D.collection,action:t,collectionName:n}},t.buildCollectionListQueryAction=function(t){return{target:D.collection,action:N.queryList,options:t}},t.buildDocumentAction=function(t,n,e){return{target:D.document,action:t,collectionName:n,options:e}},t}(),je=function(){var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Pe=function(t){function n(n){var e=t.call(this)||this;return e.collectionName=n,e}return je(n,t),n.prototype.end=function(){var t={$aggregate:this.done()};return Oe.buildDocumentAction(q.aggregate,this.collectionName,t)},n}(mn),Ae=function(){function t(){this.res={}}return t.prototype.set=function(t,n){this.res.$set=this.res.$set||{},this.res.$set[t]=n},t.prototype.applyOperator=function(t,n,e){this.res[t]=this.res[t]||{},this.res[t][n]=e},t.prototype.emit=function(){return this.res},t}(),xe=function(){function t(t,n){void 0===n&&(n=""),this.data=t,this.prefix=n}return t.prototype.stringify=function(e){for(var r in e=e||new Ae,this.data){var o=this.prefix?"".concat(this.prefix,".").concat(r):r,i=this.data[r],u=n(i);if(i instanceof m){if(!(i instanceof O))throw $.invalidCommand("Command 不是更新操作");e.applyOperator(i.operator,o,i.stringify())}else if("number"===u)e.set(o,i);else if("boolean"===u)e.set(o,i);else if("string"===u)e.set(o,i);else if("bigint"===u)e.set(o,i);else{if("function"===u)throw $.invalidParam(o,"不支持函数");if("symbol"===u)throw $.invalidParam(o,"不支持 symbol");if("undefined"===u)throw $.invalidParam(o,"不支持 undefined");if(null===i)e.set(o,i);else if(Array.isArray(i))e.set(o,i);else{new t(i,o).stringify(e)}}}return e},t.prototype.toJSON=function(){return this.stringify().emit()},t}(),Se=function(){return Se=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},Se.apply(this,arguments)},Ce=function(){function t(t){this.collectionName=t,this.criteria={sort:[]}}return t.prototype.limit=function(t){return this.criteria.limit=t,this},t.prototype.skip=function(t){return this.criteria.skip=t,this},t.prototype.where=function(t){return this.criteria.match=t,this},t.prototype.projection=function(t){for(var e in t)t[e]?"object"!==n(t[e])&&(t[e]=1):t[e]=0;return this.criteria.projection=t,this},t.prototype.orderBy=function(t,n){return this.criteria.sort.push({field:t,sort:n}),this},t.prototype.update=function(t){return this.build(q.update,Se(Se({},this.baseOptions()),{$update:new xe(t.data).toJSON()}))},t.prototype.updateAndReturn=function(t){var n=this.findOptions();return this.build(q.findOneAndUpdate,{$match:n.$match,$update:new xe(t.data).toJSON(),$options:{$sort:n.$sort,$returnDocument:"after",$upsert:!1}})},t.prototype.set=function(t){return this.build(q.replace,Se(Se({},this.baseOptions()),{$replace:t.data,$upsert:!0}))},t.prototype.remove=function(){return this.build(q.delete,this.baseOptions())},t.prototype.get=function(){return this.build(q.queryList,Se({$limit:100},this.findOptions()))},t.prototype.count=function(){return this.build(q.count,this.baseOptions())},t.prototype.baseOptions=function(){var t={};if(void 0!==this.criteria.match){var n=new gn(this.criteria.match);t.$match=n.toJSON()}return void 0!==this.criteria.limit&&(t.$limit=this.criteria.limit),t},t.prototype.findOptions=function(){var t=this.baseOptions();if(void 0!==this.criteria.projection&&(t.$project=this.criteria.projection),void 0!==this.criteria.sort){t.$sort={};for(var n=0,e=this.criteria.sort;n<e.length;n++){var r=e[n];t.$sort[r.field]=r.sort===I.DESC?-1:1}}return void 0!==this.criteria.skip&&(t.$skip=this.criteria.skip),t},t.prototype.build=function(t,n){return Oe.buildDocumentAction(t,this.collectionName,n)},t}(),Ee=function(){function t(t,n){this.collectionName=t,this.id=n}return t.prototype.update=function(t){return new Ce(this.collectionName).where({_id:String(this.id)}).limit(1).update(t)},t.prototype.set=function(t){return new Ce(this.collectionName).where({_id:String(this.id)}).limit(1).set(t)},t.prototype.remove=function(){return new Ce(this.collectionName).where({_id:String(this.id)}).limit(1).remove()},t.prototype.get=function(){var t=new Ce(this.collectionName).where({_id:String(this.id)}).limit(1).get();return t.action=q.query,t},t}(),Re=function(){function t(t){this.collectionName=t}return t.prototype.add=function(t){if(!(null==t?void 0:t.data))throw $.invalidParam("data","不能为空");return Array.isArray(t.data)?this.batchAdd(t):Oe.buildDocumentAction(q.create,this.collectionName,t.data)},t.prototype.batchAdd=function(t){if(t.data.length<=0)throw $.invalidParam("data","不能为空数组");if(t.data.length>200)throw $.invalidParam("data","最大长度 200");var n={$create:t.data};return"boolean"==typeof t.ordered&&(n.$ordered=t.ordered),Oe.buildDocumentAction(q.batchCreate,this.collectionName,n)},t.prototype.doc=function(t){return new Ee(this.collectionName,t)},t.prototype.limit=function(t){return new Ce(this.collectionName).limit(t)},t.prototype.skip=function(t){return new Ce(this.collectionName).skip(t)},t.prototype.where=function(t){return new Ce(this.collectionName).where(t)},t.prototype.projection=function(t){return new Ce(this.collectionName).projection(t)},t.prototype.orderBy=function(t,n){return new Ce(this.collectionName).orderBy(t,n)},t.prototype.aggregate=function(){return new Pe(this.collectionName)},t.prototype.get=function(){return new Ce(this.collectionName).get()},t.prototype.count=function(){return new Ce(this.collectionName).count()},t}(),Te=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ie=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}};function Ne(){return function(t,n,e){var r=e.value;e.value=function(t){return Te(this,void 0,void 0,(function(){return Ie(this,(function(n){return[2,h(r,this)(t)]}))}))}}}var qe,De=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ke=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},$e=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Fe=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new Pe(t)}return t.prototype.addFields=function(t){return this.builder.addFields(t),this},t.prototype.count=function(t){return this.builder.count(t),this},t.prototype.match=function(t){return this.builder.match(t),this},t.prototype.group=function(t){return this.builder.group(t),this},t.prototype.sample=function(t){return this.builder.sample(t),this},t.prototype.lookup=function(t){return this.builder.lookup(t),this},t.prototype.project=function(t){return this.builder.project(t),this},t.prototype.replaceRoot=function(t){return this.builder.replaceRoot(t),this},t.prototype.sort=function(t){return this.builder.sort(t),this},t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.unwind=function(t){return this.builder.unwind(t),this},t.prototype.end=function(){return ke(this,void 0,void 0,(function(){var t,n,e;return $e(this,(function(r){switch(r.label){case 0:return t=this.builder.end().options,"POST",n="".concat(this.getCollectionPath(),"?aggregate"),[4,this.options.httpclient.request({method:"POST",path:n,data:t})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);u>3&&c&&Object.defineProperty(e,r,c)}([Ne(),De("design:type",Function),De("design:paramtypes",[]),De("design:returntype",Promise)],t.prototype,"end",null),t}(),Le=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Me=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Be=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ue=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},He=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new Ce(t)}return t.prototype.limit=function(t){return this.builder.limit(t),this},t.prototype.skip=function(t){return this.builder.skip(t),this},t.prototype.where=function(t){return this.builder.where(t),this},t.prototype.projection=function(t){return this.builder.projection(t),this},t.prototype.field=function(t){return this.builder.projection(t),this},t.prototype.orderBy=function(t,n){return this.builder.orderBy(t,n),this},t.prototype.updateAndReturn=function(t){return Be(this,void 0,void 0,(function(){var n,e,r,o;return Ue(this,(function(i){switch(i.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?findOneAndUpdate"),e=this.builder.updateAndReturn(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=i.sent(),[2,{updated:(o=d.handleResponse(r))?1:0,doc:o}]}}))}))},t.prototype.update=function(t){return Be(this,void 0,void 0,(function(){var n,e,r;return Ue(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?update"),e=this.builder.update(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.set=function(t){return Be(this,void 0,void 0,(function(){var n,e,r;return Ue(this,(function(o){switch(o.label){case 0:return"POST",n="".concat(this.getCollectionPath(),"?replace"),e=this.builder.set(t).options,[4,this.options.httpclient.request({method:"POST",path:n,data:e})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.remove=function(){return Be(this,void 0,void 0,(function(){var t,n,e;return Ue(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?delete"),n=this.builder.remove().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.get=function(){return Be(this,void 0,void 0,(function(){var t,n,e;return Ue(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?query"),n=this.builder.get().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,d.handleResponse(e)]}}))}))},t.prototype.count=function(){return Be(this,void 0,void 0,(function(){var t,n,e;return Ue(this,(function(r){switch(r.label){case 0:return"POST",t="".concat(this.getCollectionPath(),"?count"),n=this.builder.count().options,[4,this.options.httpclient.request({method:"POST",path:t,data:n})];case 1:return e=r.sent(),[2,{total:d.handleResponse(e).count}]}}))}))},t.prototype.getCollectionPath=function(){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName)},Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[Object]),Me("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[Object]),Me("design:returntype",Promise)],t.prototype,"update",null),Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[Object]),Me("design:returntype",Promise)],t.prototype,"set",null),Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[]),Me("design:returntype",Promise)],t.prototype,"remove",null),Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[]),Me("design:returntype",Promise)],t.prototype,"get",null),Le([Ne(),Me("design:type",Function),Me("design:paramtypes",[]),Me("design:returntype",Promise)],t.prototype,"count",null),t}(),Je=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Ve=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},ze=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Ge=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},We=function(){function t(t,n,e){this.collectionName=t,this.id=n,this.options=e}return t.prototype.projection=function(t){return this.query.projection(t),this},t.prototype.field=function(t){return this.query.field(t),this},t.prototype.update=function(t){return ze(this,void 0,void 0,(function(){return Ge(this,(function(n){switch(n.label){case 0:return[4,this.query.update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return ze(this,void 0,void 0,(function(){return Ge(this,(function(n){switch(n.label){case 0:return[4,this.query.updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return ze(this,void 0,void 0,(function(){return Ge(this,(function(n){switch(n.label){case 0:return[4,this.query.set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return ze(this,void 0,void 0,(function(){return Ge(this,(function(t){switch(t.label){case 0:return[4,this.query.remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return ze(this,void 0,void 0,(function(){var t,n;return Ge(this,(function(e){switch(e.label){case 0:return[4,this.query.get()];case 1:if(t=e.sent(),!(n=t[0])){if(this.options.throwOnNotFound)throw y.NOT_FOUND_ERR("不存在_id 为 ".concat(this.id," 的文档"));return[2,null]}return[2,n]}}))}))},Object.defineProperty(t.prototype,"query",{get:function(){return this._query||(this._query=new He(this.collectionName,this.options).where({_id:String(this.id)}).limit(1)),this._query},enumerable:!1,configurable:!0}),Je([Ne(),Ve("design:type",Function),Ve("design:paramtypes",[Object]),Ve("design:returntype",Promise)],t.prototype,"update",null),Je([Ne(),Ve("design:type",Function),Ve("design:paramtypes",[Object]),Ve("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Je([Ne(),Ve("design:type",Function),Ve("design:paramtypes",[Object]),Ve("design:returntype",Promise)],t.prototype,"set",null),Je([Ne(),Ve("design:type",Function),Ve("design:paramtypes",[]),Ve("design:returntype",Promise)],t.prototype,"remove",null),Je([Ne(),Ve("design:type",Function),Ve("design:paramtypes",[]),Ve("design:returntype",Promise)],t.prototype,"get",null),t}(),Ke=function(t,e,r,o){var i,u=arguments.length,c=u<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,r):o;if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,r,o);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(c=(u<3?i(c):u>3?i(e,r,c):i(e,r))||c);return u>3&&c&&Object.defineProperty(e,r,c),c},Ye=function(t,e){if("object"===("undefined"==typeof Reflect?"undefined":n(Reflect))&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},Qe=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},Xe=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},Ze=function(){function t(t,n){this.collectionName=t,this.options=n,this.builder=new Re(t)}return t.prototype.add=function(t){return Qe(this,void 0,void 0,(function(){var n,e,r;return Xe(this,(function(o){switch(o.label){case 0:return n=this.builder.add(t).options,"POST",e=this.getDocumentPath(t.data._id),[4,this.options.httpclient.request({method:"POST",path:e,data:n})];case 1:return r=o.sent(),[2,d.handleResponse(r)]}}))}))},t.prototype.doc=function(t){return new We(this.collectionName,t,this.options)},t.prototype.limit=function(t){return new He(this.collectionName,this.options).limit(t)},t.prototype.skip=function(t){return new He(this.collectionName,this.options).skip(t)},t.prototype.where=function(t){return new He(this.collectionName,this.options).where(t)},t.prototype.projection=function(t){return new He(this.collectionName,this.options).projection(t)},t.prototype.field=function(t){return new He(this.collectionName,this.options).field(t)},t.prototype.orderBy=function(t,n){return new He(this.collectionName,this.options).orderBy(t,n)},t.prototype.aggregate=function(){return new Fe(this.collectionName,this.options)},t.prototype.update=function(t){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(n){switch(n.label){case 0:return[4,new He(this.collectionName,this.options).update(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.updateAndReturn=function(t){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(n){switch(n.label){case 0:return[4,new He(this.collectionName,this.options).updateAndReturn(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.set=function(t){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(n){switch(n.label){case 0:return[4,new He(this.collectionName,this.options).set(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.remove=function(){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(t){switch(t.label){case 0:return[4,new He(this.collectionName,this.options).remove()];case 1:return[2,t.sent()]}}))}))},t.prototype.get=function(){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(t){switch(t.label){case 0:return[4,new He(this.collectionName,this.options).get()];case 1:return[2,t.sent()]}}))}))},t.prototype.count=function(){return Qe(this,void 0,void 0,(function(){return Xe(this,(function(t){switch(t.label){case 0:return[4,new He(this.collectionName,this.options).count()];case 1:return[2,t.sent()]}}))}))},t.prototype.getDocumentPath=function(t){return"/".concat(this.options.databaseName||"faas","/").concat(this.collectionName,"?_id=").concat(t||"")},Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[Object]),Ye("design:returntype",Promise)],t.prototype,"add",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[Object]),Ye("design:returntype",Promise)],t.prototype,"update",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[Object]),Ye("design:returntype",Promise)],t.prototype,"updateAndReturn",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[Object]),Ye("design:returntype",Promise)],t.prototype,"set",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[]),Ye("design:returntype",Promise)],t.prototype,"remove",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[]),Ye("design:returntype",Promise)],t.prototype,"get",null),Ke([Ne(),Ye("design:type",Function),Ye("design:paramtypes",[]),Ye("design:returntype",Promise)],t.prototype,"count",null),t}(),tr=function(){return tr=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},tr.apply(this,arguments)},nr=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},er=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},rr=function(){function t(t){this.httpclient=t}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return nr(this,void 0,void 0,(function(){return er(this,(function(t){switch(t.label){case 0:return[4,this.httpclient.request({method:n,path:e,data:r,headers:tr({"x-alipay-cloud-mode":"mongo","x-data-api-type":"mongo","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),or=function(){function t(t){this.command=new me,this.options=tr(tr({},t),{httpclient:new rr(t.httpclient)})}return t.prototype.collection=function(t){if(!t)throw y.INVALID_PARAM_ERR("collectionName","不能为空");return new Ze(t,this.options)},t}(),ir=function(){return ir=Object.assign||function(t){for(var n,e=1,r=arguments.length;e<r;e++)for(var o in n=arguments[e])Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o]);return t},ir.apply(this,arguments)},ur=function(t,n,e,r){return new(e||(e=Promise))((function(o,i){function u(t){try{a(r.next(t))}catch(t){i(t)}}function c(t){try{a(r.throw(t))}catch(t){i(t)}}function a(t){t.done?o(t.value):function(t){return t instanceof e?t:new e((function(n){n(t)}))}(t.value).then(u,c)}a((r=r.apply(t,n||[])).next())}))},cr=function(t,n){var e,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(a){return function(c){if(e)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(u=0)),u;)try{if(e=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=u.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=n.call(t,u)}catch(t){c=[6,t],r=0}finally{e=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,a])}}},ar=function(){function t(t){this.options=t}return t.prototype.getUploadPath=function(t){return"/".concat(t,"?upload_url")},t.prototype.getDownloadPath=function(t){return"/".concat(t,"?download_url&expire=3600")},t.prototype.getBatchDeletePath=function(){return"/?delete"},t.prototype.getBatchDownloadPath=function(){return"/?download_url"},t.prototype.checkCloudPath=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?t.startsWith("/")?"不能以 / 开头":t.includes("//")?"不能包含连续的 /":t.length>850?"长度不能超过 850 字节":void 0:"不能为空字符串"},t.prototype.checkFileID=function(t){return"string"!=typeof t?"必须为字符串":(t=t.trim())?void 0:"不能为空字符串"},t.prototype.formatFileID=function(t){return"cloud://".concat(this.options.toEnvId,"/").concat(t.replace(/^\/+/,""))},t.prototype.getCloudPathFromFileID=function(t){var n=t.trim().replace(/^cloud:\/\//,""),e=n.indexOf("/");if(e<=0)throw y.INVALID_PARAM_ERR("fileID","不合法");var r=n.substring(0,e),o=n.substring(e+1);return r!==this.options.toEnvId&&console.warn("file ".concat(t," does not belong to env ").concat(this.options.toEnvId)),o},t.prototype.uploadFile=function(t){return ur(this,void 0,void 0,(function(){var n,e,r,o,i,u;return cr(this,(function(c){switch(c.label){case 0:if(n=this.checkCloudPath(t.cloudPath))throw y.INVALID_PARAM_ERR("cloudPath",n);return e=this.getUploadPath(t.cloudPath.trim()),[4,this.request({method:"GET",path:e})];case 1:return r=c.sent(),o=d.handleResponse(r),i=this.formatFileID(o.file_id),[4,this.options.fileUploader.upload({fileID:i,uploadURL:o.upload_url,fileContent:t.fileContent})];case 2:if(200!==(u=c.sent()).statusCode)throw y.STORAGE_ERR(-1,"上传文件 ".concat(o.upload_url," 失败"),r.requestID);return[2,{fileID:i,statusCode:u.statusCode}]}}))}))},t.prototype.downloadFile=function(t){return ur(this,void 0,void 0,(function(){var n,e,r,o,i,u;return cr(this,(function(c){switch(c.label){case 0:if(n=this.checkFileID(t.fileID))throw y.INVALID_PARAM_ERR("fileID",n);return e=this.getCloudPathFromFileID(t.fileID),r=this.getDownloadPath(e),[4,this.request({method:"GET",path:r})];case 1:return o=c.sent(),i=d.handleResponse(o),[4,this.options.fileUploader.download({fileID:t.fileID,downloadURL:i.download_url})];case 2:if(200!==(u=c.sent()).statusCode)throw y.STORAGE_ERR(-1,"下载文件 ".concat(i.download_url," 失败"),o.requestID);return[2,u]}}))}))},t.prototype.deleteFile=function(t){return ur(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return cr(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw y.INVALID_PARAM_ERR("fileList","不能为空数组");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw y.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push(c)}return a=this.getBatchDeletePath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.getTempFileURL=function(t){return ur(this,void 0,void 0,(function(){var n,e,r,o,i,u,c,a,s,p=this;return cr(this,(function(f){switch(f.label){case 0:if(n=Array.isArray(t)?t:t.fileList,!Array.isArray(n)||0===n.length)throw y.INVALID_PARAM_ERR("fileList","不能为空数组");if(n.length>50)throw y.INVALID_PARAM_ERR("fileList","最大长度 50");for(e=[],r=0,o=n;r<o.length;r++){if(i=o[r],u=this.checkFileID(i))throw y.INVALID_PARAM_ERR("fileID",u);c=this.getCloudPathFromFileID(i),e.push({file_id:c,expire:600})}return a=this.getBatchDownloadPath(),[4,this.request({method:"POST",path:a,data:{file_list:e}})];case 1:return s=f.sent(),[2,{fileList:d.handleResponse(s).file_list.map((function(t){return{fileID:p.formatFileID(t.file_id),tempFileURL:t.download_url,status:t.status?0:-1,errMsg:t.status?"ok":t.result_message}}))}]}}))}))},t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,o=t.headers;return ur(this,void 0,void 0,(function(){return cr(this,(function(t){switch(t.label){case 0:return[4,this.options.httpclient.request({method:n,path:e,data:r,headers:ir({"x-alipay-cloud-mode":"oss","x-data-api-type":"oss","x-expire-timestamp":"".concat(Date.now()+6e4)},o)})];case 1:return[2,t.sent()]}}))}))},t}(),sr=function(){function t(){}return t.createCallFunction=function(t){return function(t){var n=t.httpclient;return h((function(t){return _(void 0,void 0,void 0,(function(){var e,r,o,i,u;return b(this,(function(c){switch(c.label){case 0:if(!t.name)throw y.INVALID_PARAM_ERR("name","缺失");return e={"x-to-function-name":t.name,"x-alipay-cloud-mode":"function"},[4,n.request({method:"POST",path:"/functions/invokeFunction",data:t.data,headers:e})];case 1:if(200!==(r=c.sent()).status)throw o=-1,i="",(u=r.data)&&(o=u.errCode,i=u.errMsg,u.errDetail&&(i+=",详情:".concat(u.errDetail))),y.SERVER_ERR(o,i,r.requestID,r.status);return[2,{requestID:r.requestID,result:r.data}]}}))}))}))}(t)},t.createCallContainer=function(t){return function(t){return h((function(n){return w(void 0,void 0,void 0,(function(){return v(this,(function(e){throw new Error("not implemented in "+t.type+" with "+n)}))}))}))}(t)},t.createDatabase=function(t){return new or(t)},t.createStorage=function(t){return new ar(t)},t}();!function(t){t.WEB="WEB",t.ALIPAY_MINI="ALIPAY_MINI",t.WEICHAT_MINI="WEICHAT_MINI"}(qe||(qe={}));var pr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function fr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var lr={exports:{}};var yr,hr={exports:{}};function dr(){return yr||(yr=1,function(t,n){var e;t.exports=(e=e||function(t,n){var e;if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),"undefined"!=typeof self&&self.crypto&&(e=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(e=globalThis.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==pr&&pr.crypto&&(e=pr.crypto),!e)try{e=require("crypto")}catch(t){}var r=function(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||function(){function t(){}return function(n){var e;return t.prototype=n,e=new t,t.prototype=null,e}}(),i={},u=i.lib={},c=u.Base={extend:function(t){var n=o(this);return t&&n.mixIn(t),n.hasOwnProperty("init")&&this.init!==n.init||(n.init=function(){n.$super.init.apply(this,arguments)}),n.init.prototype=n,n.$super=this,n},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var n in t)t.hasOwnProperty(n)&&(this[n]=t[n]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},a=u.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=e!=n?e:4*t.length},toString:function(t){return(t||p).stringify(this)},concat:function(t){var n=this.words,e=t.words,r=this.sigBytes,o=t.sigBytes;if(this.clamp(),r%4)for(var i=0;i<o;i++){var u=e[i>>>2]>>>24-i%4*8&255;n[r+i>>>2]|=u<<24-(r+i)%4*8}else for(var c=0;c<o;c+=4)n[r+c>>>2]=e[c>>>2];return this.sigBytes+=o,this},clamp:function(){var n=this.words,e=this.sigBytes;n[e>>>2]&=4294967295<<32-e%4*8,n.length=t.ceil(e/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var n=[],e=0;e<t;e+=4)n.push(r());return new a.init(n,t)}}),s=i.enc={},p=s.Hex={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push((i>>>4).toString(16)),r.push((15&i).toString(16))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r+=2)e[r>>>3]|=parseInt(t.substr(r,2),16)<<24-r%8*4;return new a.init(e,n/2)}},f=s.Latin1={stringify:function(t){for(var n=t.words,e=t.sigBytes,r=[],o=0;o<e;o++){var i=n[o>>>2]>>>24-o%4*8&255;r.push(String.fromCharCode(i))}return r.join("")},parse:function(t){for(var n=t.length,e=[],r=0;r<n;r++)e[r>>>2]|=(255&t.charCodeAt(r))<<24-r%4*8;return new a.init(e,n)}},l=s.Utf8={stringify:function(t){try{return decodeURIComponent(escape(f.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return f.parse(unescape(encodeURIComponent(t)))}},y=u.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=l.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(n){var e,r=this._data,o=r.words,i=r.sigBytes,u=this.blockSize,c=i/(4*u),s=(c=n?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*u,p=t.min(4*s,i);if(s){for(var f=0;f<s;f+=u)this._doProcessBlock(o,f);e=o.splice(0,s),r.sigBytes-=p}return new a.init(e,p)},clone:function(){var t=c.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=y.extend({cfg:c.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset()},reset:function(){y.reset.call(this),this._doReset()},update:function(t){return this._append(t),this._process(),this},finalize:function(t){return t&&this._append(t),this._doFinalize()},blockSize:16,_createHelper:function(t){return function(n,e){return new t.init(e).finalize(n)}},_createHmacHelper:function(t){return function(n,e){return new h.HMAC.init(t,e).finalize(n)}}});var h=i.algo={};return i}(Math),e)}(hr)),hr.exports}!function(t,n){t.exports=dr().enc.Hex}(lr);var wr=fr(lr.exports),vr={exports:{}},_r={exports:{}};!function(t,n){var e;t.exports=(e=dr(),function(t){var n=e,r=n.lib,o=r.WordArray,i=r.Hasher,u=n.algo,c=[],a=[];!function(){function n(n){for(var e=t.sqrt(n),r=2;r<=e;r++)if(!(n%r))return!1;return!0}function e(t){return 4294967296*(t-(0|t))|0}for(var r=2,o=0;o<64;)n(r)&&(o<8&&(c[o]=e(t.pow(r,.5))),a[o]=e(t.pow(r,1/3)),o++),r++}();var s=[],p=u.SHA256=i.extend({_doReset:function(){this._hash=new o.init(c.slice(0))},_doProcessBlock:function(t,n){for(var e=this._hash.words,r=e[0],o=e[1],i=e[2],u=e[3],c=e[4],p=e[5],f=e[6],l=e[7],y=0;y<64;y++){if(y<16)s[y]=0|t[n+y];else{var h=s[y-15],d=(h<<25|h>>>7)^(h<<14|h>>>18)^h>>>3,w=s[y-2],v=(w<<15|w>>>17)^(w<<13|w>>>19)^w>>>10;s[y]=d+s[y-7]+v+s[y-16]}var _=r&o^r&i^o&i,b=(r<<30|r>>>2)^(r<<19|r>>>13)^(r<<10|r>>>22),g=l+((c<<26|c>>>6)^(c<<21|c>>>11)^(c<<7|c>>>25))+(c&p^~c&f)+a[y]+s[y];l=f,f=p,p=c,c=u+g|0,u=i,i=o,o=r,r=g+(b+_)|0}e[0]=e[0]+r|0,e[1]=e[1]+o|0,e[2]=e[2]+i|0,e[3]=e[3]+u|0,e[4]=e[4]+c|0,e[5]=e[5]+p|0,e[6]=e[6]+f|0,e[7]=e[7]+l|0},_doFinalize:function(){var n=this._data,e=n.words,r=8*this._nDataBytes,o=8*n.sigBytes;return e[o>>>5]|=128<<24-o%32,e[14+(o+64>>>9<<4)]=t.floor(r/4294967296),e[15+(o+64>>>9<<4)]=r,n.sigBytes=4*e.length,this._process(),this._hash},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});n.SHA256=i._createHelper(p),n.HmacSHA256=i._createHmacHelper(p)}(Math),e.SHA256)}(_r);var br,gr=_r.exports,mr=fr(gr),Or={exports:{}};!function(t,n){var e;t.exports=(e=dr(),br||(br=1,function(t,n){var e,r,o;t.exports=(r=(e=dr()).lib.Base,o=e.enc.Utf8,void(e.algo.HMAC=r.extend({init:function(t,n){t=this._hasher=new t.init,"string"==typeof n&&(n=o.parse(n));var e=t.blockSize,r=4*e;n.sigBytes>r&&(n=t.finalize(n)),n.clamp();for(var i=this._oKey=n.clone(),u=this._iKey=n.clone(),c=i.words,a=u.words,s=0;s<e;s++)c[s]^=1549556828,a[s]^=909522486;i.sigBytes=u.sigBytes=r,this.reset()},reset:function(){var t=this._hasher;t.reset(),t.update(this._iKey)},update:function(t){return this._hasher.update(t),this},finalize:function(t){var n=this._hasher,e=n.finalize(t);return n.reset(),n.finalize(this._oKey.clone().concat(e))}})))}(Or)),e.HmacSHA256)}(vr);var jr=fr(vr.exports),Pr=function(){function t(){}return t.sign=function(n){for(var e=n.signedHeaders.join(";"),r="",o=0,i=n.signedHeaders;o<i.length;o++){var u=i[o],c=n.headers[u];r+="".concat(u,":").concat(c,"\n")}var a=t.createHash(n.body||""),s=n.method.toUpperCase()+"\n"+n.path+"\n"+n.query+"\n"+r+"\n"+e+"\n"+a+"\n",p="HMAC-SHA256",f=t.createHash(s),l="".concat(p,"\n").concat(n.timestamp,"\n").concat(f,"\n"),y=t.createSha256(l,n.secretKey);return"".concat(p," Credential=").concat(n.secretId,", SignedHeaders=").concat(e,", Signature=").concat(y)},t.createSha256=function(t,n){return void 0===n&&(n=""),jr(t,n).toString(wr)},t.createHash=function(t){return mr(t).toString(wr)},t}(),Ar=function(){function t(){}return t.detectRuntime=function(){return window||void 0===("undefined"==typeof my?"undefined":n(my))?window||void 0===("undefined"==typeof wx?"undefined":n(wx))?qe.WEB:qe.WEICHAT_MINI:qe.ALIPAY_MINI},t.generateUUID=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var n=16*Math.random()|0;return("x"==t?n:3&n|8).toString(16)}))},t.parseUrl=function(t,n){if(n===qe.WEB)return new URL(t);var e=t.match(/^(https?):\/\/([^/]+)(\/[^?]+)?(\?[^#]+)?/)||[],r=e[1],o=e[2],i=e[3],u=e[4];return{protocol:r||"",host:o||"",pathname:"".concat(i||""),search:u||""}},t}();var xr=function(){function t(t,n){this.req=t,this.config=n}return Object.defineProperty(t.prototype,"requestId",{get:function(){return this.req.requestOptions.headers["x-trace-id"]},enumerable:!1,configurable:!0}),t}(),Sr=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e,o,u;return i(this,(function(i){switch(i.label){case 0:return[4,fetch(t,r({mode:"cors"},n))];case 1:return e=i.sent(),o={},e.headers.forEach((function(t,n){o[n]=t})),u={status:e.status},[4,e.json()];case 2:return[2,(u.data=i.sent(),u.headers=o,u)]}}))}))},t}(),Cr=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,my.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,headers:null==n?void 0:n.headers,dataType:"json"})];case 1:return[2,r.sent()];case 2:throw e=r.sent(),console.error(e),new Error("error: ".concat(e.error,", message: ").concat(e.errorMessage));case 3:return[2]}}))}))},t}(),Er=function(){function t(){}return t.prototype.request=function(t,n){return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,new Promise((function(e,r){wx.request({url:t,method:(null==n?void 0:n.method)||"GET",data:null==n?void 0:n.body,header:null==n?void 0:n.headers,dataType:"json",success:function(t){e({status:t.statusCode,data:t.data,headers:t.header})},reject:function(t){r(new Error("error: ".concat(t.errno,", message: ").concat(t.errMsg)))}})}))]}))}))},t}(),Rr=function(){function t(){}return t.default=function(t){if(!this.singleton)switch(t){case qe.ALIPAY_MINI:this.singleton=new Cr;break;case qe.WEB:this.singleton=new Sr;break;case qe.WEICHAT_MINI:this.singleton=new Er;break;default:throw new Error("未知运行环境".concat(t))}return this.singleton},t}();function Tr(t,n){return o(this,void 0,void 0,(function(){var e,r;return i(this,(function(o){switch(o.label){case 0:return[4,n()];case 1:return o.sent(),e=t.config.fetch||Rr.default(t.config.runtime),r=t,[4,e.request(t.req.url,t.req.requestOptions)];case 2:return r.res=o.sent(),t.result={status:t.res.status,requestID:t.requestId,headers:t.res.headers,data:t.res.data},[2]}}))}))}function Ir(t,n){return o(this,void 0,void 0,(function(){var e;return i(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,n()];case 1:return r.sent(),[3,3];case 2:throw e=r.sent(),y.NETWORK_ERR(e,t.requestId);case 3:return[2]}}))}))}function Nr(t){return function(n,e){return o(this,void 0,void 0,(function(){var o,u,c,a,s;return i(this,(function(i){switch(i.label){case 0:return o=Date.now(),u=Ar.parseUrl(n.req.url,n.config.runtime),c={authorization:"","x-from-app-id":n.config.appId,"x-from-env-id":n.config.envId,"x-to-env-id":n.config.envId,"x-from-instance-id":"".concat(o),"x-from-function-name":n.config.functionName,"x-client-timestamp":"".concat(o)},t.length>0&&t.forEach((function(t){var e,r=null===(e=n.req.requestOptions.headers)||void 0===e?void 0:e[t];r&&(c[t]=r)})),a=function(t,n,e){if(e||2===arguments.length)for(var r,o=0,i=n.length;o<i;o++)!r&&o in n||(r||(r=Array.prototype.slice.call(n,0,o)),r[o]=n[o]);return t.concat(r||Array.prototype.slice.call(n))}(["x-from-app-id","x-from-env-id","x-from-instance-id","x-from-function-name","x-client-timestamp","x-to-env-id"],t,!0).sort(),s={path:u.pathname,query:u.search.substring(1),secretId:n.config.secretId,secretKey:n.config.secretKey,method:n.req.requestOptions.method,headers:c,body:n.req.requestOptions.body,timestamp:o,signedHeaders:a},c.authorization=Pr.sign(s),n.req.requestOptions.headers=r(r({},c),n.req.requestOptions.headers),[4,e()];case 1:return i.sent(),[2]}}))}))}}var qr=function(){function t(t,n){var e;this.config=t,this.handler=(e=n,function(t,n){var r=-1;return function o(i){if(i<=r)return Promise.reject(new Error("next() called multiple times"));r=i;var u=e[i];if(i===e.length&&(u=n),!u)return Promise.resolve();try{return Promise.resolve(u(t,o.bind(null,i+1)))}catch(t){return Promise.reject(t)}}(0)})}return t.prototype.request=function(t){var n=t.method,e=t.path,r=t.data,u=t.headers;return o(this,void 0,void 0,(function(){var t,o,c,a;return i(this,(function(i){switch(i.label){case 0:return t=this.config.endpoint+e,o=r?JSON.stringify(r):r,c=Ar.generateUUID(),u=Object.assign({"x-alipay-callid":c,"x-request-id":c,"x-alipay-source":"web,web-sdk","content-type":"application/json"},u),a=new xr({url:t,requestOptions:{method:n,body:o,headers:u}},this.config),[4,this.handler(a)];case 1:return i.sent(),[2,a.result]}}))}))},t.createFunctionHttpclient=function(n){return new t(n,[Ir,Nr(["x-to-function-name"]),Tr])},t.createDatabaseHttpclient=function(n){return new t(n,[Ir,Nr(["x-data-api-type","x-expire-timestamp"]),Tr])},t.createStorageHttpclient=function(n){return new t(n,[Ir,Nr(["x-data-api-type","x-expire-timestamp"]),Tr])},t}(),Dr=function(){function t(){}return t.prototype.upload=function(t){return o(this,void 0,void 0,(function(){var n,e;return i(this,(function(r){switch(r.label){case 0:return n=t.uploadURL,e=t.fileContent,[4,fetch(n,{method:"PUT",mode:"cors",body:e})];case 1:return[2,{statusCode:r.sent().status}]}}))}))},t.prototype.download=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,{fileContent:t.downloadURL,statusCode:200}]}))}))},t.create=function(){return t.instance||(t.instance=new t),t.instance},t}(),kr=function(t){function n(e){var r=qr.createStorageHttpclient(e),o=n.getFileUploader(e);return t.call(this,{httpclient:r,fileUploader:o,type:"web",toEnvId:e.envId})||this}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n.getFileUploader=function(t){if(t.fileUploader)return t.fileUploader;if(t.runtime===qe.WEB)return Dr.create();throw y.INVALID_PARAM_ERR("fileUploader","未指定文件上传/下载实现")},n}(ar),$r=function(){function t(t){var n=t.resourceEnv||t.envId,e=t.resourceAppid||t.appId;this.config={endpoint:t.endpoint||"https://".concat(n,".api-hz.cloudbasefunction.cn"),secretId:t.secretId,secretKey:t.secretKey,appId:e,envId:n,fetch:t.fetch,fileUploader:t.fileUploader,runtime:t.runtime||Ar.detectRuntime(),functionName:""}}return t.prototype.init=function(){},t.prototype.callFunction=function(t){var n;return o(this,void 0,void 0,(function(){var e,o;return i(this,(function(i){switch(i.label){case 0:return e=r(r({},this.config),{envId:(null===(n=t.config)||void 0===n?void 0:n.env)||this.config.envId,functionName:t.name}),o=qr.createFunctionHttpclient(e),[4,sr.createCallFunction({type:"web",httpclient:o})(t)];case 1:return[2,i.sent()]}}))}))},t.prototype.getStorage=function(){return this.storage||(this.storage=new kr(this.config)),this.storage},t.prototype.uploadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().uploadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.downloadFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().downloadFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.deleteFile=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().deleteFile(t)];case 1:return[2,n.sent()]}}))}))},t.prototype.getTempFileURL=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.getStorage().getTempFileURL(t)];case 1:return[2,n.sent()]}}))}))},t.RUNTIME=qe,t}();t.Cloud=$r}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alipay/faas-web-sdk",
3
- "version": "1.1.16-alpha.2",
3
+ "version": "1.1.16-alpha.3",
4
4
  "description": "云函数服务 web SDK",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -18,7 +18,7 @@
18
18
  "access": "public"
19
19
  },
20
20
  "dependencies": {
21
- "@alipay/faas-common-sdk": "^1.1.16-alpha.2",
21
+ "@alipay/faas-common-sdk": "^1.1.16-alpha.3",
22
22
  "crypto-js": "^4.1.1"
23
23
  },
24
24
  "devDependencies": {