couchdb-web-node-plugin 2.0.839 → 2.0.840

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.
package/index.js CHANGED
@@ -1 +1,894 @@
1
- (()=>{var __webpack_modules__=[(e,t,r)=>{"use strict";r.d(t,{applyModelsInheritance:()=>w,determineGenericIndexablePropertyNames:()=>A,determineModelRolesMapping:()=>D,ensureValidationDocumentPresence:()=>O,getConnectorOptions:()=>y,getEffectiveURL:()=>P,getPouchDBPlugin:()=>b,initializeConnection:()=>g,log:()=>v,mayStripRepresentation:()=>E,removeDeprecatedIndexes:()=>h,waitWithTimeout:()=>x});var n=r(1),o=r.n(n),a=r(2),i=r.n(a),_=r(3),c=r.n(_),u=r(4);const s=require("rxjs"),l=require("rxjs/fetch"),p="2.0.839";function d(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return f(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?f(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function f(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var m=Symbol("toggleLatestRevisionDetermining"),v=new u.Logger({name:"web-node.couchdb"}),b=function(e){var t=e.model.property.name.special,r=t.id,n=t.revision,o=t.attachment,a=t.deleted;return{installCouchDBWebNodePlugin:function(t){var _=this;if(this.bulkDocs){var s=this.bulkDocs.bind(this);this.bulkDocs=i()(c().mark((function o(a){var i,l,p,f,b,h,y,E,O,g,P,x,D,M,A,I,C,w,T,L,S,R,U,k=arguments;return c().wrap((function(o){for(;;)switch(o.prev=o.next){case 0:v.debug("BulkDocs called from:",t),(0,u.isObject)(a)&&1===Object.keys(a).length&&"docs"in a&&Array.isArray(a.docs)&&(a=a.docs);for(i=k.length,l=new Array(i>1?i-1:0),p=1;p<i;p++)l[p-1]=k[p];f=l.length>0&&l[l.length-1]===m,b=f?!e.skipLatestRevisionDetermining:e.skipLatestRevisionDetermining,f&&l.pop(),h=!Array.isArray(a)&&(0,u.isObject)(a)&&r in a?[a]:a,y=e.maximumNumberOfEntitiesInBulkOperation,E=[],O=0;case 1:if(!(O<h.length)){o.next=4;break}return g=h.slice(O,O+y),o.next=2,s.call.apply(s,[_,g].concat(l));case 2:P=o.sent,E=E.concat(P);case 3:O+=y,o.next=1;break;case 4:x=[],D=[],M=0,A=d(E);case 5:if((I=A()).done){o.next=12;break}if(C=I.value,"object"!=typeof h[M]){o.next=10;break}if(!(n in h[M])||"conflict"!==C.name||!["0-latest","0-upsert"].includes(h[M][n])){o.next=6;break}D.push(h[M]),x.push(M),o.next=10;break;case 6:if(!(r in h[M]&&e.ignoreNoChangeError&&"name"in C&&"forbidden"===C.name&&"message"in C&&C.message.startsWith("NoChange:"))){o.next=10;break}if(E[M]={id:h[M][r],ok:!0},b){o.next=10;break}if(!(n in h[M])||["0-latest","0-upsert"].includes(h[M][n])){o.next=7;break}R=h[M][n],o.next=9;break;case 7:return o.next=8,_.get(E[M].id);case 8:U=n,R=o.sent[U];case 9:E[M].rev=R;case 10:M+=1;case 11:o.next=5;break;case 12:if(!D.length){o.next=14;break}return h=D,f&&l.push(m),o.next=13,_.bulkDocs.apply(_,[h].concat(l));case 13:for(w=o.sent,T=d(w);!(L=T()).done;)S=L.value,E[x.shift()]=S;case 14:return o.abrupt("return",E);case 15:case"end":return o.stop()}}),o)})))}this.post=this.put=i()(c().mark((function e(t,r){var n;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,_.bulkDocs([t],r);case 1:if(null==(n=e.sent[0])||!n.name){e.next=2;break}throw n;case 2:return e.abrupt("return",n);case 3:case"end":return e.stop()}}),e)}))),this.remove=i()(c().mark((function e(t,o){var i;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",_.put(((i={})[r]=t,i[n]=o,i[a]=!0,i)));case 1:case"end":return e.stop()}}),e)}))),this.putAttachment&&(this.putAttachment=i()(c().mark((function e(t,a,i,u,s){var l,p,d,f,m,v;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"string"==typeof i?(m=u,v=i):(m=i,v="0-latest"),e.abrupt("return",_.put(((f={})[r]=t,f[n]=v,f[o]=((d={})[a]={content_type:null!==(l=null!==(p=m.type)&&void 0!==p?p:s)&&void 0!==l?l:"application/octet-stream",data:m},d),f)));case 1:case"end":return e.stop()}}),e)})))),this.removeAttachment&&(this.removeAttachment=i()(c().mark((function e(t,a,i){var u,s;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",_.put(((s={})[r]=t,s[n]=i,s[o]=((u={})[a]={content_type:"application/octet-stream",data:null},u),s)));case 1:case"end":return e.stop()}}),e)}))))}}},h=function(){var e=i()(c().mark((function e(t,r,n){var o,a,i,_,u,s,l,p,f,m,v,b,h;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=1,t.getIndexes();case 1:o=e.sent.indexes.filter((function(e){return e.name.endsWith("-GenericIndex")})),a=d(o);case 2:if((i=a()).done){e.next=7;break}_=i.value,u=!1,s=0,l=Object.entries(r);case 3:if(!(s<l.length)){e.next=5;break}if(p=l[s],f=p[0],m=p[1],!_.name.startsWith(f+"-")){e.next=4;break}for(v=0,b=A(n,m);v<b.length;v++)h=b[v],[f+"-"+h+"-GenericIndex",f+"-GenericIndex"].includes(_.name)&&(u=!0);return e.abrupt("continue",5);case 4:s++,e.next=3;break;case 5:if(u){e.next=6;break}return e.next=6,t.deleteIndex(_);case 6:e.next=2;break;case 7:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),y=function(e,t){var r=new Map([[408,"Request Timeout"],[425,"Too Early"],[429,"Too Many Requests"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"]]);return o()({},e,{fetch:function(n,o){var a=e.fetchInterceptor,i=a.numberOfRetries,_=a.retryIntervalInSeconds,c=a.exponentialBackoff,p=a.maximumRetryIntervallInSeconds,d=(0,l.fromFetch)(n,function(r){var n;return void 0===r&&(r={}),r=(0,u.extend)(!0,(0,u.copy)(e.fetch),r),Array.isArray(t)&&t.length>0&&(r.signal=null==(n=t.pop())?void 0:n.controller.signal),r}(o)).pipe((0,s.map)((function(e){if(r.has(e.status))throw e;return e})),(0,s.retry)({count:i,delay:function(e,t){if("number"!=typeof e.status)throw e;var r=e;if(r.headers.has("retry-after")){var n=r.headers.get("retry-after");if("string"==typeof n){var o=parseInt(n);if(String(o)===n)return v.info("Retry in "+n+" seconds","according to given retry value."),(0,s.timer)(1e3*o);var a=new Date(n);if(!isNaN(a.getTime())){var i=new Date;if(i<a){if(p<(a.getTime()-i.getTime())/1e3)return v.info("Retry at",a.toUTCString(),"according to given retry","value."),(0,s.timer)(a);v.warn("The recommended retry attempt is",a.toUTCString(),"further in the future than the","configured maximum wait time of",p,"seconds.")}else v.warn("Given retry time recommendation","from server is in the past and","has to be ignored therefore.")}}}var u=c?Math.pow(2,t-1)*_:_;return(0,s.timer)(1e3*Math.min(u,p))}}));return(0,s.lastValueFrom)(d)}})},E=function(e,t,r){var n=(0,u.represent)(e);return n.length<=t?n.length>r?n.substring(0,r-3)+"...":n:"DOCUMENT IS TOO BIG TO REPRESENT"},O=function(){var e=i()(c().mark((function e(t,r,n,a,i,_,s,l){var d,f,m,b,h;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===i&&(i=!0),void 0===_&&(_="_id"),void 0===s&&(s="_rev"),void 0===l&&(l="_design/"),f=o()(((d={})[_]=""+l+r,d.language="javascript",d.version=p,d),n),e.prev=1,e.next=2,t.get(""+l+r);case 2:return m=e.sent,f[s]=m[s],e.next=3,t.put(f);case 3:i&&v.info(a+" updated."),e.next=8;break;case 4:return e.prev=4,b=e.catch(1),i&&("not_found"===b.error||"not_found"===b.name||"missing"===b.message||"missing"===b.reason?v.info(a+" not available. Create new one."):v.info(a+" couldn't be updated:",'"'+(0,u.represent)(b)+'" create new one.')),e.prev=5,e.next=6,t.put(f);case 6:i&&v.info(a+" installed/updated."),e.next=8;break;case 7:throw e.prev=7,h=e.catch(5),new Error(a+" couldn't be installed/updated: \""+(0,u.represent)(h)+'".',{cause:h});case 8:case"end":return e.stop()}}),e,null,[[1,4],[5,7]])})));return function(t,r,n,o,a,i,_,c){return e.apply(this,arguments)}}(),g=function(){var e=i()(c().mark((function e(t,r,n){var o,a,i,_;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=!0),o=t.couchdb,a=r.couchdb,i=P(a),t.couchdb.server.expressPouchDBInstance?(o.connection=new o.connector(a.databaseName,o.server.runner.configuration),o.connection.installValidationMethods()):o.connection=new o.connector(i,y(a.connector)),o.connection.installCouchDBWebNodePlugin("backend"),o.connection.setMaxListeners(1/0),!n){e.next=4;break}return e.prev=1,e.next=2,o.connection.allDocs({limit:1});case 2:e.next=4;break;case 3:throw e.prev=3,_=e.catch(1),new Error("Database has not been installed yet: "+(0,u.represent)(_),{cause:_});case 4:return e.abrupt("return",t);case 5:case"end":return e.stop()}}),e,null,[[1,3]])})));return function(t,r,n){return e.apply(this,arguments)}}(),P=function(e,t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var n=/^https?:\/\//.test(e.url)?e.url:"http://{1}"+e.runner.host+":"+String(e.runner.port);return(0,u.format)(n,r?e.admin.name+":"+e.admin.password+"@":"")+(t?"/"+e.databaseName:"")},x=function(e,t,r){var n=!0;return Promise.race([e.then((function(){n=!1})),(0,u.timeout)(1e3*t).then((function(){n&&v.warn("Timeout of",String(t)+".","seconds reached while waiting for "+r+".")}))])},D=function(e){for(var t=e.property.name.special,r=t.role,n=t.attachment,a={},i=w(e),_=0,c=Object.entries(i);_<c.length;_++){var s=c[_],l=s[0],p=s[1];if(p[r]){a[l]=o()({properties:{}},T(p[r]));for(var d=0,f=Object.entries(p);d<f.length;d++){var m=f[d],v=m[0],b=m[1];if((0,u.isObject)(b))if(v===n){a[l].attachments={};for(var h=0,y=Object.entries(b);h<y.length;h++){var E=y[h],O=E[0],g=E[1];g.roles&&(a[l].attachments[O]=T(g.roles))}}else b.roles&&(a[l].properties[v]=T(b.roles))}}}return a},M=function(e){return(0,u.isObject)(e)},A=function(e,t){var r=e.property.name.special;return Object.keys(t).filter((function(n){var o=t[n];return M(o)&&Object.prototype.hasOwnProperty.call(o,"index")&&o.index||M(o)&&!(Object.prototype.hasOwnProperty.call(o,"index")&&!o.index||e.property.name.reserved.concat(r.additional,r.role,r.attachment,r.conflict,r.constraint.execution,r.constraint.expression,r.deleted,r.deletedConflict,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType,r.id,r.revision,r.revisions,r.revisionsInformation,r.type,r.updateStrategy).includes(n)||o.type&&("string"==typeof o.type&&o.type.endsWith("[]")||Array.isArray(o.type)&&o.type.length&&Array.isArray(o.type[0])||Object.prototype.hasOwnProperty.call(e.entities,o.type)))})).concat([r.id,r.revision]).sort()},I=function(e,t,r){void 0===r&&(r="in-place");var n=t.entities,o=t.property.name.special.extend;if(Object.prototype.hasOwnProperty.call(n,"_base")&&(Object.prototype.hasOwnProperty.call(e,o)&&e[o]&&![].concat(e[o]).includes("_base")?e[o]=["_base"].concat(e[o]):e[o]="_base"),Object.prototype.hasOwnProperty.call(e,o)){for(var a,i=[].concat(e[o]),_=d(i);!(a=_()).done;){var c=a.value;"_base"!==c&&I(n[c],t,c),(0,u.extend)(!0,e,n[c],(0,u.copy)(e)),e[o]=i}delete e[o]}return C(e,t),e},C=function(e,t){for(var r=t.property.name.special,n=0,o=Object.entries(e);n<o.length;n++){var a=o[n],i=a[0],_=a[1];if(i===r.attachment)for(var c=_,s=0,l=Object.entries(c);s<l.length;s++){var p=l[s],f=p[0],m=p[1];c[f]=(0,u.extend)(!0,(0,u.copy)(t.property.defaultDefinition),m)}else if(![r.role,r.constraint.execution,r.constraint.expression,r.extend,r.maximumAggregatedSize,r.minimumAggregatedSize,r.oldType].includes(i)){var v=(0,u.extend)(!0,(0,u.copy)(t.property.defaultDefinition),_);e[i]=v;for(var b,h=d([].concat(v.type));!(b=h()).done;){var y=b.value;Array.isArray(y)||"object"!=typeof y||(v.type=I(y,t))}}}return e},w=function(e){for(var t=e.entities,r=e.property.name.typePattern,n=0,o=Object.keys(t);n<o.length;n++){var a=o[n];if(!new RegExp(r.public).test(a)&&!new RegExp(r.private).test(a))throw new Error('Model names have to match "'+r.public+'" or "'+r.private+'" for xprivate one (given name: "'+a+'").');"_base"!==a&&I(t[a],e,a)}return t},T=function(e){if(Array.isArray(e))return{read:e,write:e};if("object"==typeof e){for(var t={read:[],write:[]},r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];if(Object.prototype.hasOwnProperty.call(e,o)){var a=e[o];Array.isArray(a)?t[o]=a:"string"==typeof a&&(t[o]=[a])}}return t}return{read:[e],write:[e]}}},e=>{"use strict";e.exports=require("@babel/runtime/helpers/extends")},e=>{"use strict";e.exports=require("@babel/runtime/helpers/asyncToGenerator")},e=>{"use strict";e.exports=require("@babel/runtime/regenerator")},e=>{"use strict";e.exports=require("clientnode")},module=>{(function(){var __webpack_modules__=[function(e,t,r){var n=r(1);function o(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var t,r,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",_=a.toStringTag||"@@toStringTag";function c(e,o,a,i){var _=o&&o.prototype instanceof s?o:s,c=Object.create(_.prototype);return n(c,"_invoke",function(e,n,o){var a,i,_,c=0,s=o||[],l=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return a=e,i=0,_=t,p.n=r,u}};function d(e,n){for(i=e,_=n,r=0;!l&&c&&!o&&r<s.length;r++){var o,a=s[r],d=p.p,f=a[2];e>3?(o=f===n)&&(_=a[(i=a[4])?5:(i=3,3)],a[4]=a[5]=t):a[0]<=d&&((o=e<2&&d<a[1])?(i=0,p.v=n,p.n=a[1]):d<f&&(o=e<3||a[0]>n||n>f)&&(a[4]=e,a[5]=n,p.n=f,i=0))}if(o||e>1)return u;throw l=!0,n}return function(o,s,f){if(c>1)throw TypeError("Generator is already running");for(l&&1===s&&d(s,f),i=s,_=f;(r=i<2?t:_)||!l;){a||(i?i<3?(i>1&&(p.n=-1),d(i,_)):p.n=_:p.v=_);try{if(c=2,a){if(i||(o="next"),r=a[o]){if(!(r=r.call(a,_)))throw TypeError("iterator result is not an object");if(!r.done)return r;_=r.value,i<2&&(i=0)}else 1===i&&(r=a.return)&&r.call(a),i<2&&(_=TypeError("The iterator does not provide a '"+o+"' method"),i=1);a=t}else if((r=(l=p.n<0)?_:e.call(n,p))!==u)break}catch(e){a=t,i=1,_=e}finally{c=1}}return{value:r,done:l}}}(e,a,i),!0),c}var u={};function s(){}function l(){}function p(){}r=Object.getPrototypeOf;var d=[][i]?r(r([][i]())):(n(r={},i,(function(){return this})),r),f=p.prototype=s.prototype=Object.create(d);function m(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,p):(e.__proto__=p,n(e,_,"GeneratorFunction")),e.prototype=Object.create(f),e}return l.prototype=p,n(f,"constructor",p),n(p,"constructor",l),l.displayName="GeneratorFunction",n(p,_,"GeneratorFunction"),n(f),n(f,_,"Generator"),n(f,i,(function(){return this})),n(f,"toString",(function(){return"[object Generator]"})),(e.exports=o=function(){return{w:c,m}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=o,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(r,n,o,a){var i=Object.defineProperty;try{i({},"",{})}catch(r){i=0}e.exports=t=function(e,r,n,o){function a(r,n){t(e,r,(function(e){return this._invoke(r,n,e)}))}r?i?i(e,r,{value:n,enumerable:!o,configurable:!o,writable:!o}):e[r]=n:(a("next",0),a("throw",1),a("return",2))},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n,o,a)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){e.exports=function(e,t){this.v=e,this.k=t},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(0),o=r(4);e.exports=function(e,t,r,a,i){return new o(n().w(e,t,r,a),i||Promise)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(2),o=r(1);e.exports=function e(t,r){function a(e,o,i,_){try{var c=t[e](o),u=c.value;return u instanceof n?r.resolve(u.v).then((function(e){a("next",e,i,_)}),(function(e){a("throw",e,i,_)})):r.resolve(u).then((function(e){c.value=e,i(c)}),(function(e){return a("throw",e,i,_)}))}catch(e){_(e)}}var i;this.next||(o(e.prototype),o(e.prototype,"function"==typeof Symbol&&Symbol.asyncIterator||"@asyncIterator",(function(){return this}))),o(this,"_invoke",(function(e,t,n){function o(){return new r((function(t,r){a(e,n,t,r)}))}return i=i?i.then(o,o):o()}),!0)},e.exports.__esModule=!0,e.exports.default=e.exports},function(module,__unused_webpack_exports,__nested_webpack_require_3485__){"use strict";var __webpack_dirname__="/",r;if(module=__nested_webpack_require_3485__.nmd(module),null!==module&&"undefined"!==eval("typeof require")&&null!==eval("require")&&"main"in eval("require")&&"undefined"!==eval("typeof require.main")&&null!==eval("require.main")){var ORIGINAL_MAIN_MODULE=module;module!==eval("require.main")&&"paths"in module&&"paths"in eval("require.main")&&null!=__webpack_dirname__&&(module.paths=eval("require.main.paths").concat(module.paths.filter((function(path){return eval("require.main.paths").includes(path)}))))}if(null==window)var window=void 0===__nested_webpack_require_3485__.g||null===__nested_webpack_require_3485__.g?{}:__nested_webpack_require_3485__.g;r=function r(__WEBPACK_EXTERNAL_MODULE__4__,__WEBPACK_EXTERNAL_MODULE__11__,__WEBPACK_EXTERNAL_MODULE__12__,__WEBPACK_EXTERNAL_MODULE__13__){return function(){var __webpack_modules__=[function(e,t,r){r.d(t,{ABBREVIATIONS:function(){return s},ANIMATION_END_EVENT_NAMES:function(){return l},CLASS_TO_TYPE_MAPPING:function(){return p},CLOSE_EVENT_NAMES:function(){return i},CONSOLE_METHODS:function(){return _},DEFAULT_ENCODING:function(){return a},IGNORE_NULL_AND_UNDEFINED_SYMBOL:function(){return u},KEYBOARD_CODES:function(){return f},KEY_CODES:function(){return d},LOCALES:function(){return m},Lock:function(){return n.Lock},PLAIN_OBJECT_PROTOTYPES:function(){return v},SPECIAL_REGEX_SEQUENCES:function(){return b},Semaphore:function(){return o.Semaphore},TRANSITION_END_EVENT_NAMES:function(){return h},VALUE_COPY_SYMBOL:function(){return c}});var n=r(9),o=r(10),a="utf8",i=["close","exit","SIGINT","SIGTERM","SIGQUIT","uncaughtException"],_=["debug","error","info","log","warn"],c=Symbol.for("clientnodeValue"),u=Symbol.for("clientnodeIgnoreNullAndUndefined"),s=["html","id","url","us","de","api","href"],l="animationend webkitAnimationEnd oAnimationEnd MSAnimationEnd",p={"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Error]":"error","[object Function]":"function","[object Map]":"map","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object Set]":"set","[object String]":"string"},d={BACKSPACE:8,SPACE:32,TAB:9,DELETE:46,ENTER:13,COMMA:188,PERIOD:190,END:35,ESCAPE:27,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,HOME:36,NUMPAD_ADD:107,NUMPAD_SUBTRACT:109,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,PAGE_UP:33,PAGE_DOWN:34,UP:38,DOWN:40,LEFT:37,RIGHT:39},f={BACKSPACE:"Backspace",SPACE:"Space",TAB:"Tab",DELETE:"Delete",ENTER:"Enter",COMMA:"Comma",PERIOD:"Period",END:"End",ESCAPE:"Escape",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F111",F12:"F12",HOME:"Home",NUMPAD_ADD:"NumpadAdd",NUMPAD_SUBTRACT:"NumpadSubtract",NUMPAD_DECIMAL:"NumpadDecimal",NUMPAD_DIVIDE:"NumpadDivide",NUMPAD_ENTER:"NumpadEnter",NUMPAD_MULTIPLY:"NumpadMultiply",PAGE_UP:"PageUp",PAGE_DOWN:"PageUp",UP:"ArrowUp",DOWN:"ArrowDown",LEFT:"ArrowLeft",RIGHT:"ArrowUp"},m=[],v=[Object.prototype],b=["-","[","]","(",")","^","$","*","+",".","{","}"],h="transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"},function(e,t,r){r.d(t,{MAXIMAL_NUMBER_OF_ITERATIONS:function(){return l},NOOP:function(){return p},determineGlobalContext:function(){return c},globalContext:function(){return u},mockConsole:function(){return d},setGlobalContext:function(){return s}});var n,o,a=r(0),i=r(5);function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}e=r.hmd(e);var c=function(){return"undefined"==typeof globalThis?void 0===window?void 0===r.g?e:Object.prototype.hasOwnProperty.call(r.g,"window")?r.g.window:r.g:window:globalThis},u=c(),s=function(e){u=e};u.fetch=u.fetch?u.fetch.bind(u):null!==(n=null==(o=(0,i.optionalRequire)("node-fetch"))?void 0:o.default)&&void 0!==n?n:function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return i.currentImport?(0,i.currentImport)("node-fetch").then((function(e){var r;return(r=e).default.apply(r,t)})):null};var l={value:100},p=function(){},d=function(){Object.prototype.hasOwnProperty.call(u,"console")||(u.console={}),u.console||(u.console={});for(var e,t=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return _(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(a.CONSOLE_METHODS);!(e=t()).done;){var r=e.value;r in u.console||(u.console[r]=p)}}},function(__unused_webpack_module,__nested_webpack_exports__,__nested_webpack_require_5862__){__nested_webpack_require_5862__.r(__nested_webpack_exports__),__nested_webpack_require_5862__.d(__nested_webpack_exports__,{addDynamicGetterAndSetter:function(){return _addDynamicGetterAndSetter2},convertCircularObjectToJSON:function(){return _convertCircularObjectToJSON},convertMapToPlainObject:function(){return _convertMapToPlainObject2},convertPlainObjectToMap:function(){return _convertPlainObjectToMap2},convertSubstringInPlainObject:function(){return _convertSubstringInPlainObject2},copy:function(){return _copy2},determineType:function(){return _determineType},equals:function(){return _equals},evaluateDynamicData:function(){return _evaluateDynamicData},extend:function(){return _extend2},getProxyHandler:function(){return _getProxyHandler},mask:function(){return _mask2},modifyObject:function(){return _modifyObject2},removeKeyPrefixes:function(){return _removeKeyPrefixes2},removeKeysInEvaluation:function(){return _removeKeysInEvaluation2},represent:function(){return _represent2},sort:function(){return _sort},unwrapProxy:function(){return _unwrapProxy2}});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__nested_webpack_require_5862__(4),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__nested_webpack_require_5862__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_constants__WEBPACK_IMPORTED_MODULE_1__=__nested_webpack_require_5862__(0),_indicators__WEBPACK_IMPORTED_MODULE_2__=__nested_webpack_require_5862__(3),_number__WEBPACK_IMPORTED_MODULE_3__=__nested_webpack_require_5862__(8),_string__WEBPACK_IMPORTED_MODULE_4__=__nested_webpack_require_5862__(7);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var _addDynamicGetterAndSetter2=function(e,t,r,n,o,a){if(void 0===t&&(t=null),void 0===r&&(r=null),void 0===n&&(n={}),void 0===o&&(o=!0),void 0===a&&(a=[Object]),o&&"object"==typeof e)if(Array.isArray(e))for(var i,_=0,c=_createForOfIteratorHelperLoose(e);!(i=c()).done;){var u=i.value;e[_]=_addDynamicGetterAndSetter2(u,t,r,n,o),_+=1}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var s,l=_createForOfIteratorHelperLoose(e);!(s=l()).done;){var p=s.value,d=p[0],f=p[1];e.set(d,_addDynamicGetterAndSetter2(f,t,r,n,o))}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e)){for(var m,v=[],b=_createForOfIteratorHelperLoose(e);!(m=b()).done;){var h=m.value;e.delete(h),v.push(_addDynamicGetterAndSetter2(h,t,r,n,o))}for(var y=0,E=v;y<E.length;y++){var O=E[y];e.add(O)}}else if(null!==e)for(var g=0,P=Object.entries(e);g<P.length;g++){var x=P[g],D=x[0],M=x[1];e[D]=_addDynamicGetterAndSetter2(M,t,r,n,o)}if(t||r)for(var A,I,C=function(){var o=I.value;if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e)&&e instanceof o){var a=_getProxyHandler(e,n),i=_getProxyHandler(e,n);t&&(i.get=function(r,n){return"__target__"===n?e:"__revoke__"===n?function(){return u(),e}:"function"==typeof e[n]?e[n]:t(a.get(c,n),n,e)}),r&&(i.set=function(t,n,o){return a.set(c,n,r(n,o,e))});var _=Proxy.revocable({},i),c=_.proxy,u=_.revoke;return{v:c}}},w=_createForOfIteratorHelperLoose(a);!(I=w()).done;)if(A=C())return A.v;return e},_convertCircularObjectToJSON=function(e,t,r){void 0===t&&(t=function(e){return null!=e?e:"__circularReference__"}),void 0===r&&(r=0);var n=new Map;return function(e){var o=function(e,r){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(r)){var a,i;if(n.has(r))return t(null!==(a=n.get(r))&&void 0!==a?a:null,e,r,n);if(n.set(r,null),Array.isArray(r)){i=[];for(var _,c=_createForOfIteratorHelperLoose(r);!(_=c()).done;){var u=_.value;i.push(o(null,u))}}else{i={};for(var s=0,l=Object.entries(r);s<l.length;s++){var p=l[s],d=p[0],f=p[1];i[d]=o(d,f)}}return n.set(r,i),i}return r};return JSON.stringify(e,o,r)}(e)},_convertMapToPlainObject2=function(e,t){if(void 0===t&&(t=!0),"object"==typeof e){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e)){for(var r,n={},o=_createForOfIteratorHelperLoose(e);!(r=o()).done;){var a=r.value,i=a[0],_=a[1];t&&(_=_convertMapToPlainObject2(_,t)),["number","string"].includes(typeof i)&&(n[String(i)]=_)}return n}if(t)if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(e))for(var c=0,u=Object.entries(e);c<u.length;c++){var s=u[c],l=s[0],p=s[1];e[l]=_convertMapToPlainObject2(p,t)}else if(Array.isArray(e))for(var d=0,f=0,m=e;f<m.length;f++){var v=m[f];e[d]=_convertMapToPlainObject2(v,t),d+=1}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e)){for(var b,h=[],y=_createForOfIteratorHelperLoose(e);!(b=y()).done;){var E=b.value;e.delete(E),h.push(_convertMapToPlainObject2(E,t))}for(var O=0,g=h;O<g.length;O++){var P=g[O];e.add(P)}}}return e},_convertPlainObjectToMap2=function(e,t){if(void 0===t&&(t=!0),"object"==typeof e){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(e)){for(var r=new Map,n=0,o=Object.entries(e);n<o.length;n++){var a=o[n],i=a[0],_=a[1];t&&(e[i]=_convertPlainObjectToMap2(_,t)),r.set(i,e[i])}return r}if(t)if(Array.isArray(e))for(var c=0,u=0,s=e;u<s.length;u++){var l=s[u];e[c]=_convertPlainObjectToMap2(l,t),c+=1}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var p,d=_createForOfIteratorHelperLoose(e);!(p=d()).done;){var f=p.value,m=f[0],v=f[1];e.set(m,_convertPlainObjectToMap2(v,t))}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e)){for(var b,h=[],y=_createForOfIteratorHelperLoose(e);!(b=y()).done;){var E=b.value;e.delete(E),h.push(_convertPlainObjectToMap2(E,t))}for(var O=0,g=h;O<g.length;O++){var P=g[O];e.add(P)}}}return e},_convertSubstringInPlainObject2=function(e,t,r){for(var n=0,o=Object.entries(e);n<o.length;n++){var a=o[n],i=a[0],_=a[1];(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(_)?e[i]=_convertSubstringInPlainObject2(_,t,r):"string"==typeof _&&(e[i]=_.replace(t,r))}return e},_copy2=function(e,t,r,n,o,a,i,_){if(void 0===t&&(t=!1),void 0===r&&(r=-1),void 0===n&&(n=_constants__WEBPACK_IMPORTED_MODULE_1__.VALUE_COPY_SYMBOL),void 0===o&&(o=null),void 0===a&&(a=!1),void 0===i&&(i=[]),void 0===_&&(_=0),(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e)){if(!o){if(Array.isArray(e))return _copy2(e,t,r,n,[],a,i,_);if(e instanceof Map)return _copy2(e,t,r,n,new Map,a,i,_);if(e instanceof Set)return _copy2(e,t,r,n,new Set,a,i,_);if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){var c=/[^/]*$/.exec(e.toString());return(o=new RegExp(e.source,c?c[0]:void 0)).lastIndex=e.lastIndex,o}return"undefined"!=typeof Blob&&e instanceof Blob?t?e.slice(0,e.size,e.type):e:_copy2(e,t,r,n,{},a,i,_)}if(e===o)throw new Error("Can't copy because source and destination are identical.");if(!a&&![void 0,null].includes(e)){var u=i.indexOf(e);if(-1!==u)return i[u];i.push(e)}var s=function(e){if(-1!==r&&r<_+1)return n===_constants__WEBPACK_IMPORTED_MODULE_1__.VALUE_COPY_SYMBOL?e:n;var o=_copy2(e,t,r,n,null,a,i,_+1);return a||[void 0,null].includes(e)||"object"!=typeof e||i.push(e),o};if(Array.isArray(e))for(var l,p=_createForOfIteratorHelperLoose(e);!(l=p()).done;){var d=l.value;o.push(s(d))}else if(e instanceof Map)for(var f,m=_createForOfIteratorHelperLoose(e);!(f=m()).done;){var v=f.value,b=v[0],h=v[1];o.set(b,s(h))}else if(e instanceof Set)for(var y,E=_createForOfIteratorHelperLoose(e);!(y=E()).done;){var O=y.value;o.add(s(O))}else for(var g=0,P=Object.entries(e);g<P.length;g++){var x=P[g],D=x[0],M=x[1];try{o[D]=s(M)}catch(e){throw new Error('Failed to copy property value object "'+D+'": '+_represent2(e),{cause:e})}}}return o||e},_determineType=function(e){if([null,void 0].includes(e))return String(e);var t=typeof e;if(["function","object"].includes(t)&&"toString"in e){var r=Object.prototype.toString.call(e);if(Object.prototype.hasOwnProperty.call(_constants__WEBPACK_IMPORTED_MODULE_1__.CLASS_TO_TYPE_MAPPING,r))return _constants__WEBPACK_IMPORTED_MODULE_1__.CLASS_TO_TYPE_MAPPING[r]}return t},_equals=function equals(firstValue,secondValue,givenOptions){void 0===givenOptions&&(givenOptions={});var options=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({compareBlobs:!1,deep:-1,exceptionPrefixes:[],ignoreFunctions:!0,properties:null,returnReasonIfNotEqual:!1},givenOptions);if(options.ignoreFunctions&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isFunction)(firstValue)&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isFunction)(secondValue)||firstValue===secondValue||(0,_number__WEBPACK_IMPORTED_MODULE_3__.isNotANumber)(firstValue)&&(0,_number__WEBPACK_IMPORTED_MODULE_3__.isNotANumber)(secondValue)||firstValue instanceof RegExp&&secondValue instanceof RegExp&&firstValue.toString()===secondValue.toString()&&firstValue.flags.split("").sort().join("")===secondValue.flags.split("").sort().join("")||firstValue instanceof Date&&secondValue instanceof Date&&(isNaN(firstValue.getTime())&&isNaN(secondValue.getTime())||!isNaN(firstValue.getTime())&&!isNaN(secondValue.getTime())&&firstValue.getTime()===secondValue.getTime())||options.compareBlobs&&"undefined"!==eval("typeof Buffer")&&Object.prototype.hasOwnProperty.call(eval("Buffer"),"isBuffer")&&firstValue instanceof eval("Buffer")&&secondValue instanceof eval("Buffer")&&firstValue.toString("base64")===secondValue.toString("base64"))return!0;if(options.compareBlobs&&"undefined"!=typeof Blob&&firstValue instanceof Blob&&secondValue instanceof Blob)return new Promise((function(e){for(var t=[],r=0,n=[firstValue,secondValue];r<n.length;r++){var o=n[r],a=new FileReader;a.onload=function(r){null===r.target?t.push(null):t.push(r.target.result),2===t.length&&(t[0]===t[1]?e(!0):e(!!options.returnReasonIfNotEqual&&">>> Blob("+_represent2(t[0])+") !== Blob("+_represent2(t[1])+")"))},a.readAsDataURL(o)}}));if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(firstValue)&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(secondValue)&&!(firstValue instanceof RegExp||secondValue instanceof RegExp)||Array.isArray(firstValue)&&Array.isArray(secondValue)&&firstValue.length===secondValue.length||_determineType(firstValue)===_determineType(secondValue)&&["map","set"].includes(_determineType(firstValue))&&firstValue.size===secondValue.size){for(var promises=[],_i11=0,_arr4=[[firstValue,secondValue],[secondValue,firstValue]];_i11<_arr4.length;_i11++){var _arr4$_i=_arr4[_i11],first=_arr4$_i[0],second=_arr4$_i[1],firstIsArray=Array.isArray(first);if(firstIsArray&&(!Array.isArray(second)||first.length!==second.length))return!!options.returnReasonIfNotEqual&&".length";var firstIsMap=(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(first);if(firstIsMap&&(!(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(second)||first.size!==second.size))return!!options.returnReasonIfNotEqual&&".size";var firstIsSet=(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(first);if(firstIsSet&&(!(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(second)||first.size!==second.size))return!!options.returnReasonIfNotEqual&&".size";if(firstIsArray){for(var index=0,_loop2=function(){var e=_arr5[_i12];if(0!==options.deep){var t=_equals(e,second[index],_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},options,{deep:options.deep-1}));if(!t)return{v:!1};var r=index,n=function(e){var t;return"string"==typeof e?"["+String(r)+"]"+(null!==(t={"[":"",">":" "}[e[0]])&&void 0!==t?t:".")+e:e};if(Object.prototype.hasOwnProperty.call(t,"then")&&promises.push(t.then(n)),"string"==typeof t)return{v:n(t)}}index+=1},_ret2,_i12=0,_arr5=first;_i12<_arr5.length;_i12++)if(_ret2=_loop2(),_ret2)return _ret2.v}else if(firstIsMap){for(var _loop3=function(){var e=_step11.value,t=e[0],r=e[1];if(0!==options.deep){var n=_equals(r,second.get(t),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},options,{deep:options.deep-1}));if(!n)return{v:!1};var o=function(e){var r;return"string"==typeof e?"get("+_represent2(t)+")"+(null!==(r={"[":"",">":" "}[e[0]])&&void 0!==r?r:".")+e:e};if(Object.prototype.hasOwnProperty.call(n,"then")&&promises.push(n.then(o)),"string"==typeof n)return{v:o(n)}}},_ret3,_iterator11=_createForOfIteratorHelperLoose(first),_step11;!(_step11=_iterator11()).done;)if(_ret3=_loop3(),_ret3)return _ret3.v}else if(firstIsSet){for(var _loop4=function(){var e=_step12.value;if(0!==options.deep){for(var t,r=!1,n=[],o=_createForOfIteratorHelperLoose(second);!(t=o()).done;){var a=t.value,i=_equals(e,a,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},options,{deep:options.deep-1}));if("boolean"==typeof i){if(i){r=!0;break}}else n.push(i)}var _=function(t){return!!t||!!options.returnReasonIfNotEqual&&">>> {-> "+_represent2(e)+" not found}"};return r?0:(n.length&&promises.push(new Promise((function(e){Promise.all(n).then((function(t){e(_(t.some((function(e){return e}))))}),(function(){}))}))),{v:_(!1)})}},_ret4,_iterator12=_createForOfIteratorHelperLoose(first),_step12;!(_step12=_iterator12()).done;)if(_ret4=_loop4(),0!==_ret4&&_ret4)return _ret4.v}else for(var _loop5=function(){var e=_Object$entries7[_i13],t=e[0],r=e[1];if(options.properties&&!options.properties.includes(t))return 0;for(var n,o=!1,a=_createForOfIteratorHelperLoose(options.exceptionPrefixes);!(n=a()).done;){var i=n.value;if(t.startsWith(i)){o=!0;break}}if(o)return 0;if(0!==options.deep){var _=_equals(r,second[t],_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},options,{deep:options.deep-1}));if(!_)return{v:!1};var c=function(e){var r;return"string"==typeof e?t+(null!==(r={"[":"",">":" "}[e[0]])&&void 0!==r?r:".")+e:e};if(Object.prototype.hasOwnProperty.call(_,"then")&&promises.push(_.then(c)),"string"==typeof _)return{v:c(_)}}},_ret5,_i13=0,_Object$entries7=Object.entries(first);_i13<_Object$entries7.length&&(_ret5=_loop5(),0!==_ret5);_i13++)if(_ret5)return _ret5.v}return!promises.length||new Promise((function(e){Promise.all(promises).then((function(t){for(var r,n=_createForOfIteratorHelperLoose(t);!(r=n()).done;){var o=r.value;if(!o||"string"==typeof o){e(o);break}}e(!0)}),(function(){}))}))}return!!options.returnReasonIfNotEqual&&">>> "+_represent2(firstValue)+" !== "+_represent2(secondValue)},_evaluateDynamicData=function(e,t,r,n,o){if(void 0===t&&(t={}),void 0===r&&(r="self"),void 0===n&&(n="__evaluate__"),void 0===o&&(o="__execute__"),"object"!=typeof e||null===e)return e;r in t||(t[r]=e);var a=function(e,r){void 0===r&&(r=n);var a=(0,_string__WEBPACK_IMPORTED_MODULE_4__.evaluate)(e,t,r===o);if(a.error)throw new Error(a.error);return a.result},i=function(e){if("object"!=typeof e||null===e||"undefined"==typeof Proxy)return e;for(var t=0,r=Object.entries(e);t<r.length;t++){var c=r[t],u=c[0],s=c[1];if("__target__"!==u&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(s)){var l=s;if(i(l),Object.prototype.hasOwnProperty.call(l,n)||Object.prototype.hasOwnProperty.call(l,o)){var p=l;e[u]=new Proxy(l,{get:function(e,t){if("__target__"===t)return e;if("hasOwnProperty"===t)return e[t];for(var r=0,i=[n,o];r<i.length;r++){var c=i[r];if(t===c&&"string"==typeof e[t])return _(a(e[t],c))}var u=_(e);if("toString"===t){var s=a(u);return s[t].bind(s)}if("string"!=typeof t){var l,p=a(u);return null!=(l=p[t])&&l.bind?p[t].bind(p):p[t]}for(var d=0,f=[n,o];d<f.length;d++){var m=f[d];if(Object.prototype.hasOwnProperty.call(e,m))return a(u,m)[t]}return u[t]},ownKeys:function(e){for(var t=0,r=[n,o];t<r.length;t++){var i=r[t];if(Object.prototype.hasOwnProperty.call(e,i))return Object.getOwnPropertyNames(_(a(e[i],i)))}return Object.getOwnPropertyNames(e)}}),e[u].__target__||(e[u].__target__=p)}}}return e},_=function(e){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e)){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isProxy)(e)){for(var t=0,r=[n,o];t<r.length;t++){var i=r[t];if(Object.prototype.hasOwnProperty.call(e,i))return e[i]}e=e.__target__}for(var c=0,u=Object.entries(e);c<u.length;c++){var s=u[c],l=s[0],p=s[1];if([n,o].includes(l))return"undefined"==typeof Proxy?_(a(p)):p;e[l]=_(p)}}return e};t.resolve=_;var c=function(e){if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e))for(var t=0,r=Object.entries(e);t<r.length;t++){var n=r[t],o=n[0],a=n[1];if("__target__"!==o&&null!==a&&["function","undefined"].includes(typeof a)){var i=a.__target__;void 0!==i&&(e[o]=i),c(a)}}return e};return Object.prototype.hasOwnProperty.call(e,n)?a(e[n]):Object.prototype.hasOwnProperty.call(e,o)?a(e[o],o):c(_(i(e)))},_removeKeysInEvaluation2=function(e,t){void 0===t&&(t=["__evaluate__","__execute__"]);for(var r=0,n=Object.entries(e);r<n.length;r++){var o=n[r],a=o[0],i=o[1];!t.includes(a)&&t.some((function(t){return Object.prototype.hasOwnProperty.call(e,t)}))?delete e[a]:(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(i)&&_removeKeysInEvaluation2(i,t)}return e},_extend2=function(e,t){for(var r=!1,n=arguments.length,o=new Array(n>2?n-2:0),a=2;a<n;a++)o[a-2]=arguments[a];var i,_=o;e===_constants__WEBPACK_IMPORTED_MODULE_1__.IGNORE_NULL_AND_UNDEFINED_SYMBOL||"boolean"==typeof e?(r=e,i=t):(i=e,(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(t)?_=[t].concat(_):void 0!==t&&(i=t));for(var c,u=function(e,t){return t===e?e:r&&t&&((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(t)||(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(t))?(n=(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(t)?e&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e)?e:new Map:e&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(e)?e:{},_extend2(r,n,t)):t;var n},s=_createForOfIteratorHelperLoose(_);!(c=s()).done;){var l=c.value,p=typeof i,d=typeof l;if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(i)&&(p+=" Map"),(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(l)&&(d+=" Map"),p===d&&i!==l)if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(i)&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(l))for(var f,m=_createForOfIteratorHelperLoose(l);!(f=m()).done;){var v=f.value,b=v[0],h=v[1];i.set(b,u(i.get(b),h))}else if(!(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(i)||Array.isArray(i)||"undefined"!=typeof Blob&&i instanceof Blob||!(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(l)||Array.isArray(l)||"undefined"!=typeof Blob&&l instanceof Blob)i=l;else for(var y=0,E=Object.entries(l);y<E.length;y++){var O=E[y],g=O[0],P=O[1];r===_constants__WEBPACK_IMPORTED_MODULE_1__.IGNORE_NULL_AND_UNDEFINED_SYMBOL&&[null,void 0].includes(P)||(i[g]=u(i[g],P))}else i=l}return i},_getProxyHandler=function(e,t){return void 0===t&&(t={}),t=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({delete:"[]",get:"[]",has:"[]",set:"[]"},t),{deleteProperty:function(r,n){return"[]"!==t.delete||"string"!=typeof n?e[t.delete](n):(delete e[n],!0)},get:function(r,n){return"[]"===t.get&&"string"==typeof n?e[n]:e[t.get](n)},has:function(r,n){return"[]"===t.has?n in e:e[t.has](n)},set:function(r,n,o){return"[]"!==t.set||"string"!=typeof n?e[t.set](n,o):(e[n]=o,!0)}}},_mask2=function(e,t){if(!0===(t=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({exclude:!1,include:!0},t)).exclude||Array.isArray(t.exclude)&&0===t.exclude.length||!1===t.include||"object"!=typeof e)return{};var r=Array.isArray(t.exclude)?t.exclude.reduce((function(e,t){var r;return _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,((r={})[t]=!0,r))}),{}):t.exclude,n=Array.isArray(t.include)?t.include.reduce((function(e,t){var r;return _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},e,((r={})[t]=!0,r))}),{}):t.include,o={};if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(n))for(var a=0,i=Object.entries(n);a<i.length;a++){var _=i[a],c=_[0],u=_[1];Object.prototype.hasOwnProperty.call(e,c)&&(!0===u?o[c]=e[c]:((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(u)||Array.isArray(u)&&u.length)&&"object"==typeof e[c]&&(o[c]=_mask2(e[c],{include:u})))}else o=e;if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(r)){for(var s=!1,l=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},o),p=0,d=Object.entries(r);p<d.length;p++){var f=d[p],m=f[0],v=f[1];if(Object.prototype.hasOwnProperty.call(l,m))if(!0===v)s=!0,delete l[m];else if(((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isPlainObject)(v)||Array.isArray(v)&&v.length)&&"object"==typeof l[m]){var b=l[m];l[m]=_mask2(l[m],{exclude:v}),l[m]!==b&&(s=!0)}}s&&(o=l)}return o},_modifyObject2=function(e,t,r,n,o,a,i,_,c){if(void 0===r&&(r="__remove__"),void 0===n&&(n="__prepend__"),void 0===o&&(o="__append__"),void 0===a&&(a="__"),void 0===i&&(i="__"),void 0===_&&(_=null),void 0===c&&(c=null),(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(t)&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var u,s=_createForOfIteratorHelperLoose(t);!(u=s()).done;){var l=u.value,p=l[0],d=l[1];e.has(p)&&_modifyObject2(e.get(p),d,r,n,o,a,i,t,p)}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(t)&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e))for(var f=0,m=Object.entries(t);f<m.length;f++){var v=m[f],b=v[0],h=v[1],y=NaN;if(Array.isArray(e)&&b.startsWith(a)&&b.endsWith(i)&&((y=parseInt(b.substring(a.length,b.length-i.length),10))<0||y>=e.length)&&(y=NaN),[r,n,o].includes(b)||!isNaN(y)){if(Array.isArray(e))if(b===r)for(var E,O=_createForOfIteratorHelperLoose([].concat(h));!(E=O()).done;){var g=E.value;"string"==typeof g&&g.startsWith(a)&&g.endsWith(i)?e.splice(parseInt(g.substring(a.length,g.length-i.length),10),1):e.includes(g)?e.splice(e.indexOf(g),1):"number"==typeof g&&g<e.length&&e.splice(g,1)}else b===o?e=e.concat(h):b===n?e=[].concat(h).concat(e):(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e[y])&&(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(h)?_extend2(!0,_modifyObject2(e[y],h,r,n,o,a,i),e[y],h):e[y]=h;else if(b===r)for(var P,x=_createForOfIteratorHelperLoose([].concat(h));!(P=x()).done;){var D=P.value;"string"==typeof D&&Object.prototype.hasOwnProperty.call(e,D)&&delete e[D]}delete t[b],_&&"string"==typeof c&&delete _[c]}else null!==e&&Object.prototype.hasOwnProperty.call(e,b)&&(e[b]=_modifyObject2(e[b],h,r,n,o,a,i,t,b))}return e},_removeKeyPrefixes2=function(e,t){void 0===t&&(t="#");var r=[].concat(t);if(Array.isArray(e))for(var n,o=0,a=_createForOfIteratorHelperLoose(e.slice());!(n=a()).done;){var i=n.value,_=!1;if("string"==typeof i){for(var c,u=_createForOfIteratorHelperLoose(r);!(c=u()).done;){var s=c.value;if(i.startsWith(s+":")){e.splice(o,1),_=!0;break}}if(_)continue}e[o]=_removeKeyPrefixes2(i,r),o+=1}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e))for(var l,p=_createForOfIteratorHelperLoose(new Set(e));!(l=p()).done;){var d=l.value,f=!1;if("string"==typeof d){for(var m,v=_createForOfIteratorHelperLoose(r);!(m=v()).done;){var b=m.value;if(d.startsWith(b+":")){e.delete(d),f=!0;break}}if(f)continue}_removeKeyPrefixes2(d,r)}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var h,y=_createForOfIteratorHelperLoose(new Map(e));!(h=y()).done;){var E=h.value,O=E[0],g=E[1],P=!1;if("string"==typeof O){for(var x,D=_createForOfIteratorHelperLoose(r);!(x=D()).done;){var M=x.value,A=(0,_string__WEBPACK_IMPORTED_MODULE_4__.escapeRegularExpressions)(M);if(new RegExp("^"+A+"[0-9]*$").test(O)){e.delete(O),P=!0;break}}if(P)continue}e.set(O,_removeKeyPrefixes2(g,r))}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e))for(var I=0,C=Object.entries(Object.assign({},e));I<C.length;I++){for(var w,T=C[I],L=T[0],S=T[1],R=!1,U=_createForOfIteratorHelperLoose(r);!(w=U()).done;){var k=w.value,j=(0,_string__WEBPACK_IMPORTED_MODULE_4__.escapeRegularExpressions)(k);if(new RegExp("^"+j+"[0-9]*$").test(L)){delete e[L],R=!0;break}}R||(e[L]=_removeKeyPrefixes2(S,r))}return e},_represent2=function(e,t,r,n,o,a){if(void 0===t&&(t=30),void 0===r&&(r=" "),void 0===n&&(n=""),void 0===o&&(o="__maximum_number_of_levels_reached__"),void 0===a&&(a=8),0===a)return String(o);if(null===e)return"null";if(void 0===e)return"undefined";if("string"==typeof e)return'"'+e.replace(/\n/g,"\n"+n)+'"';if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isNumeric)(e)||"boolean"==typeof e)return String(e);if(e instanceof Date)return e.toISOString();if(Array.isArray(e)){for(var i,_="[",c=!1,u=1,s=_createForOfIteratorHelperLoose(e);!(i=s()).done;){var l=i.value;if(u>t){_+="\n"+n+"...";break}c&&(_+=","),_+="\n"+n+r+_represent2(l,t,r,""+n+r,o,a-1),c=!0,u+=1}return c&&(_+="\n"+n),_+"]"}if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e)){for(var p,d="",f=!1,m=1,v=_createForOfIteratorHelperLoose(e);!(p=v()).done;){var b=p.value,h=b[0],y=b[1];if(m>t){d+=",\n"+n+"...";break}f&&(d+=",\n"+n+r),d+=_represent2(h,t,r,""+n+r,o,a-1)+" -> "+_represent2(y,t,r,""+n+r,o,a-1),f=!0,m+=1}return f||(d="EmptyMap"),d}if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e)){for(var E,O="{",g=!1,P=1,x=_createForOfIteratorHelperLoose(e);!(E=x()).done;){var D=E.value;if(P>t){O+=",\n"+n+"...";break}g&&(O+=","),O+="\n"+n+r+_represent2(D,t,r,""+n+r,o,a-1),g=!0,P+=1}return g?O+="\n"+n+"}":O="EmptySet",O}if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isFunction)(e))return"__function__";for(var M,A="{",I=!1,C=1,w=_createForOfIteratorHelperLoose(Object.getOwnPropertyNames(e).sort());!(M=w()).done;){var T=M.value;if(C>t){A+=",\n"+n+"...";break}I&&(A+=","),A+="\n"+n+r+T+": "+_represent2(e[T],t,r,""+n+r,o,a-1),I=!0,C+=1}return I&&(A+="\n"+n),A+"}"},_sort=function(e){var t=[];if(Array.isArray(e))for(var r=0;r<e.length;r++)t.push(r);else if("object"==typeof e)if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var n,o=_createForOfIteratorHelperLoose(e);!(n=o()).done;){var a=n.value;t.push(a[0])}else if(null!==e)for(var i=0,_=Object.keys(e);i<_.length;i++){var c=_[i];t.push(c)}return t.sort()},_unwrapProxy2=function(e,t){if(void 0===t&&(t=new Set),(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isObject)(e)){if(t.has(e))return e;try{(0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isFunction)(e.__revoke__)&&((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isProxy)(e)&&(e=e.__target__),e.__revoke__())}catch(t){return e}finally{t.add(e)}if(Array.isArray(e))for(var r,n=0,o=_createForOfIteratorHelperLoose(e);!(r=o()).done;){var a=r.value;e[n]=_unwrapProxy2(a,t),n+=1}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isMap)(e))for(var i,_=_createForOfIteratorHelperLoose(e);!(i=_()).done;){var c=i.value,u=c[0],s=c[1];e.set(u,_unwrapProxy2(s,t))}else if((0,_indicators__WEBPACK_IMPORTED_MODULE_2__.isSet)(e)){for(var l,p=[],d=_createForOfIteratorHelperLoose(e);!(l=d()).done;){var f=l.value;e.delete(f),p.push(_unwrapProxy2(f,t))}for(var m=0,v=p;m<v.length;m++){var b=v[m];e.add(b)}}else for(var h=0,y=Object.entries(e);h<y.length;h++){var E=y[h],O=E[0],g=E[1];e[O]=_unwrapProxy2(g,t)}}return e}},function(e,t,r){r.r(t),r.d(t,{isAnyMatching:function(){return u},isArrayLike:function(){return c},isFunction:function(){return m},isMap:function(){return d},isNumeric:function(){return i},isObject:function(){return s},isPlainObject:function(){return l},isProxy:function(){return f},isSet:function(){return p},isWindow:function(){return _}});var n=r(0),o=r(2);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var i=function(e){var t=(0,o.determineType)(e);return["number","string"].includes(t)&&!isNaN(e-parseFloat(e))},_=function(e){return![null,void 0].includes(e)&&"object"==typeof e&&e===(null==e?void 0:e.window)},c=function(e){var t;try{t=Boolean(e)&&e.length}catch(e){return!1}var r=(0,o.determineType)(e);if("function"===r||_(e))return!1;if("array"===r||0===t)return!0;if("number"==typeof t&&t>0)try{return e[t-1],!0}catch(e){}return!1},u=function(e,t){for(var r,n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(r=n()).done;){var o=r.value;if("string"==typeof o){if(o===e)return!0}else if(o.test(e))return!0}return!1},s=function(e){return null!==e&&"object"==typeof e},l=function(e){return s(e)&&n.PLAIN_OBJECT_PROTOTYPES.includes(Object.getPrototypeOf(e))},p=function(e){return"set"===(0,o.determineType)(e)},d=function(e){return"map"===(0,o.determineType)(e)},f=function(e){return Boolean(e.__target__)},m=function(e){return Boolean(e)&&["[object AsyncFunction]","[object Function]"].includes({}.toString.call(e))}},function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__4__},function(module,__nested_webpack_exports__,__nested_webpack_require_35314__){__nested_webpack_require_35314__.r(__nested_webpack_exports__),__nested_webpack_require_35314__.d(__nested_webpack_exports__,{clearRequireCache:function(){return _clearRequireCache},currentImport:function(){return _currentImport},currentRequire:function(){return _currentRequire},isolatedRequire:function(){return _isolatedRequire},optionalRequire:function(){return _optionalRequire}});var _currentRequire=eval("typeof require === 'undefined' ? null : require"),currentOptionalImport=null;try{currentOptionalImport=eval("typeof import === 'undefined' ? null : import")}catch(e){}var _currentImport=currentOptionalImport,_optionalRequire=function(e){try{return _currentRequire?_currentRequire(e):null}catch(e){return null}},_clearRequireCache=function(e){void 0===e&&(e=(null==_currentRequire?void 0:_currentRequire.cache)||__nested_webpack_require_35314__.c);for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var o=n[r],a=o[0],i=o[1];t[a]=i,delete e[a]}return t},restoreRequireCache=function(e,t){void 0===e&&(e=(null==_currentRequire?void 0:_currentRequire.cache)||__nested_webpack_require_35314__.c),_clearRequireCache();for(var r=0,n=Object.entries(t);r<n.length;r++){var o=n[r],a=o[0],i=o[1];e[a]=i}},_isolatedRequire=function(e,t){void 0===t&&(t=_currentRequire||__nested_webpack_require_35314__(6));var r=_clearRequireCache(t.cache);try{return t(e)}catch(e){throw e}finally{restoreRequireCache(t.cache,r)}}},function(e){function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=function(){return[]},t.resolve=t,t.id=6,e.exports=t},function(__unused_webpack_module,__nested_webpack_exports__,__nested_webpack_require_36873__){__nested_webpack_require_36873__.r(__nested_webpack_exports__),__nested_webpack_require_36873__.d(__nested_webpack_exports__,{ALLOWED_STARTING_VARIABLE_SYMBOLS:function(){return _ALLOWED_STARTING_VARIABLE_SYMBOLS},ALLOWED_VARIABLE_SYMBOLS:function(){return _ALLOWED_VARIABLE_SYMBOLS},FIX_ENCODING_ERROR_MAPPING:function(){return _FIX_ENCODING_ERROR_MAPPING},POLYFILL_TEMPLATES:function(){return _POLYFILL_TEMPLATES},addSeparatorToPath:function(){return _addSeparatorToPath},camelCaseToDelimited:function(){return _camelCaseToDelimited},capitalize:function(){return _capitalize},compile:function(){return _compile},compressStyleValue:function(){return _compressStyleValue},convertToValidVariableName:function(){return _convertToValidVariableName},decodeHTMLEntities:function(){return _decodeHTMLEntities},delimitedToCamelCase:function(){return _delimitedToCamelCase},encodeURIComponentExtended:function(){return _encodeURIComponentExtended},escapeRegularExpressions:function(){return _escapeRegularExpressions},evaluate:function(){return _evaluate2},findNormalizedMatchRange:function(){return _findNormalizedMatchRange},fixKnownEncodingErrors:function(){return _fixKnownEncodingErrors},format:function(){return _format},getDomainName:function(){return _getDomainName},getEditDistance:function(){return _getEditDistance},getPortNumber:function(){return _getPortNumber},getProtocolName:function(){return _getProtocolName},getURLParameter:function(){return _getURLParameter},hasPathPrefix:function(){return _hasPathPrefix},limit:function(){return _limit},lowerCase:function(){return _lowerCase},mark:function(){return _mark},maskForRegularExpression:function(){return _maskForRegularExpression},normalizeDomNodeSelector:function(){return _normalizeDomNodeSelector},normalizePhoneNumber:function(){return _normalizePhoneNumber},normalizeURL:function(){return _normalizeURL},normalizeZipCode:function(){return _normalizeZipCode},parseEncodedObject:function(){return _parseEncodedObject},representPhoneNumber:function(){return _representPhoneNumber},representURL:function(){return _representURL},serviceURLEquals:function(){return _serviceURLEquals},sliceAllExceptNumberAndLastSeparator:function(){return _sliceAllExceptNumberAndLastSeparator}});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__nested_webpack_require_36873__(4),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__nested_webpack_require_36873__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_1__=__nested_webpack_require_36873__(13),_babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_1___default=__nested_webpack_require_36873__.n(_babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_1__),_constants__WEBPACK_IMPORTED_MODULE_2__=__nested_webpack_require_36873__(0),_context__WEBPACK_IMPORTED_MODULE_3__=__nested_webpack_require_36873__(1),_filesystem__WEBPACK_IMPORTED_MODULE_5__=__nested_webpack_require_36873__(14),_object__WEBPACK_IMPORTED_MODULE_4__=__nested_webpack_require_36873__(2);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var _POLYFILL_TEMPLATES={value:!1},_ALLOWED_VARIABLE_SYMBOLS="0-9a-zA-Z_$",_ALLOWED_STARTING_VARIABLE_SYMBOLS="a-zA-Z_$",_FIX_ENCODING_ERROR_MAPPING=[["Ã\\x84","Ä"],["Ã\\x96","Ö"],["Ã\\x9c","Ü"],["ä","ä"],["ö","ö"],["ü","ü"],["\\x96","-"],["é","é"],["è","e"],["ô","o"],["à ","á"],["ø","ø"],["Ã\\x9f","ß"],["Ã","ß"]],_escapeRegularExpressions=function(e,t){if(void 0===t&&(t=[]),1===e.length&&!_constants__WEBPACK_IMPORTED_MODULE_2__.SPECIAL_REGEX_SEQUENCES.includes(e))return e;t.includes("\\")||e.replace(/\\/g,"\\\\");for(var r,n=_createForOfIteratorHelperLoose(_constants__WEBPACK_IMPORTED_MODULE_2__.SPECIAL_REGEX_SEQUENCES);!(r=n()).done;){var o=r.value;t.includes(o)||(e=e.replace(new RegExp("\\"+o,"g"),"\\"+o))}return e},_convertToValidVariableName=function(e){return["class","default"].includes(e)?"_"+e:e.replace(new RegExp("^[^"+_ALLOWED_STARTING_VARIABLE_SYMBOLS+"]+"),"").replace(new RegExp("[^"+_ALLOWED_VARIABLE_SYMBOLS+"]+([a-zA-Z])","g"),(function(e,t){return t.toUpperCase()}))},_encodeURIComponentExtended=function(e,t){return void 0===t&&(t=!1),encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,t?"%20":"+")},_addSeparatorToPath=function(e,t){return void 0===t&&(t="/"),(e=e.trim()).substring(e.length-1)!==t&&e.length?e+t:e},_hasPathPrefix=function(e,t,r){var n;return void 0===e&&(e="/admin"),void 0===t&&(t=(null==(n=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:n.pathname)||""),void 0===r&&(r="/"),"string"==typeof e&&(e.endsWith(r)||(e+=r),t===e.substring(0,e.length-r.length)||t.startsWith(e))},_getDomainName=function(e,t){var r,n;void 0===e&&(e=(null==(r=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:r.href)||""),void 0===t&&(t=(null==(n=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:n.hostname)||"");var o=/^([a-z]*:?\/\/)?([^/]+?)(?::[0-9]+)?(?:\/.*|$)/i.exec(e);return o&&o.length>2&&o[1]&&o[2]?o[2]:t},_getPortNumber=function(e,t){var r,n,o;void 0===e&&(e=(null==(n=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:n.href)||""),void 0===t&&(t=null!=(o=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)&&o.port?parseInt(_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.port):null);var a=/^(?:[a-z]*:?\/\/[^/]+?)?[^/]+?:([0-9]+)/i.exec(e);return a&&a.length>1?parseInt(a[1],10):null!==t?t:null!=(r=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)&&r.port&&parseInt(_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.port,10)?parseInt(_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.port,10):"https"===_getProtocolName(e)?443:80},_getProtocolName=function(e,t){var r,n;void 0===e&&(e=(null==(r=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:r.href)||""),void 0===t&&(t=(null==(n=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:n.protocol)&&_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.protocol.substring(0,_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.protocol.length-1)||"");var o=/^([a-z]+):\/\//i.exec(e);return o&&o.length>1&&o[1]?o[1]:t},_getURLParameter=function(e,t,r,n,o,a,i){var _,c,u;void 0===e&&(e=null),void 0===t&&(t=!1),void 0===r&&(r=null),void 0===n&&(n="$"),void 0===o&&(o="!"),void 0===a&&(a=null),void 0===i&&(i=null!==(c=null==(u=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:u.hash)&&void 0!==c?c:"");var s=null!==(_=i)&&void 0!==_?_:"#",l="";if(a)l=a;else if(o&&s.startsWith(o)){var p,d=s.indexOf("#");-1===d?(p=s.substring(o.length),s=""):(p=s.substring(o.length,d),s=s.substring(d));var f=p.indexOf("?");-1!==f&&(l=p.substring(f))}else _context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location&&(l=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location.search||"");var m=r||l,v="&"===m;if(v||"#"===m){var b="";try{b=decodeURIComponent(s)}catch(e){}var h=b.indexOf(n);-1===h?m="":(m=b.substring(h)).startsWith(n)&&(m=m.substring(n.length))}else m.startsWith("?")&&(m=m.substring(1));var y=m?m.split("&"):[];l=l.substring(1),v&&l&&(y=y.concat(l.split("&")));for(var E,O=[],g=_createForOfIteratorHelperLoose(y);!(E=g()).done;){var P=E.value,x=P.split("="),D=void 0;try{D=decodeURIComponent(x[0])}catch(e){D=""}try{P=decodeURIComponent(x[1])}catch(e){P=""}O.push(D),t?Object.prototype.hasOwnProperty.call(O,D)&&Array.isArray(O[D])?O[D].push(P):O[D]=[P]:O[D]=P}return e?Object.prototype.hasOwnProperty.call(O,e)?O[e]:null:O},_serviceURLEquals=function(e,t){var r;void 0===t&&(t=(null==(r=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.location)?void 0:r.href)||"");var n=_getDomainName(e,""),o=_getProtocolName(e,""),a=_getPortNumber(e);return!(""!==n&&n!==_getDomainName(t)||""!==o&&o!==_getProtocolName(t)||null!==a&&a!==_getPortNumber(t))},_normalizeURL=function(e){if("string"==typeof e){var t=e.replace(/^:?\/+/,"").replace(/\/+$/,"").trim();return t.startsWith("http")?t:"http://"+t}return""},_representURL=function(e){return"string"==typeof e?e.replace(/^(https?)?:?\/+/,"").replace(/\/+$/,"").trim():""},_camelCaseToDelimited=function(e,t,r){void 0===t&&(t="-"),void 0===r&&(r=null),r||(r=_constants__WEBPACK_IMPORTED_MODULE_2__.ABBREVIATIONS);var n=_maskForRegularExpression(t);if(r.length){for(var o,a="",i=_createForOfIteratorHelperLoose(r);!(o=i()).done;)a&&(a+="|"),a+=o.value.toUpperCase();e=e.replace(new RegExp("("+a+")("+a+")","g"),"$1"+t+"$2")}return(e=e.replace(new RegExp("([^"+n+"])([A-Z][a-z]+)","g"),"$1"+t+"$2")).replace(/([a-z0-9])([A-Z])/g,"$1"+t+"$2").toLowerCase()},_capitalize=function(e){return e.charAt(0).toUpperCase()+e.substring(1)},_compressStyleValue=function(e){return e.replace(/ *([:;]) */g,"$1").replace(/ +/g," ").replace(/^;+/,"").replace(/;+$/,"").trim()},_decodeHTMLEntities=function(e){if(_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.document){var t=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.document.createElement("textarea");return t.innerHTML=e,t.value}return null},_delimitedToCamelCase=function(e,t,r,n,o){void 0===t&&(t="-"),void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=!1);var a,i=_maskForRegularExpression(t);if(r||(r=_constants__WEBPACK_IMPORTED_MODULE_2__.ABBREVIATIONS),n)a=_constants__WEBPACK_IMPORTED_MODULE_2__.ABBREVIATIONS.join("|");else{a="";for(var _,c=_createForOfIteratorHelperLoose(r);!(_=c()).done;){var u=_.value;a&&(a+="|"),a+=_capitalize(u)+"|"+u}}var s=e.startsWith(t);return s&&(e=e.substring(t.length)),e=e.replace(new RegExp("("+i+")("+a+")("+i+"|$)","g"),(function(e,t,r,n){return t+r.toUpperCase()+n})),o&&(i="(?:"+i+")+"),e=e.replace(new RegExp(i+"([a-zA-Z0-9])","g"),(function(e,t){return t.toUpperCase()})),s&&(e=t+e),e},_compile=function(e,t,r,n,o){var a;void 0===t&&(t=[]),void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o={});for(var i,_,c=Object.keys(globalThis).concat("globalThis").filter((function(e){return new RegExp("^["+_ALLOWED_STARTING_VARIABLE_SYMBOLS+"]["+_ALLOWED_VARIABLE_SYMBOLS+"]*$").test(e)})),u={error:null,globalNames:c,globalNamesUndefinedList:c.map((function(){})),originalScopeNames:Array.isArray(t)?t:"string"==typeof t?[t]:Object.keys(t),scopeNameMapping:{},scopeNames:[],templateFunction:function(){}},s=_createForOfIteratorHelperLoose(u.originalScopeNames);!(i=s()).done;){var l=i.value,p=_convertToValidVariableName(l);u.scopeNameMapping[l]=p,u.scopeNames.push(p)}if(_POLYFILL_TEMPLATES.value)if(null!=(a=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.Babel)&&a.transform)e=_context__WEBPACK_IMPORTED_MODULE_3__.globalContext.Babel.transform("("+e+")",{plugins:["transform-template-literals"]}).code;else if(e.startsWith("`")&&e.endsWith("`")){var d="####",f="`"===(e=e.replace(/\\\$/g,d).replace(/^`\$\{([\s\S]+)}`$/,"String($1)").replace(/^`([^']+)`$/,"'$1'").replace(/^`([^"]+)`$/,'"$1"')).charAt(0)?"'":e.charAt(0);e=e.replace(/\$\{((([^{]*{[^}]*}[^}]*})|[^{}]+)+)}/g,f+"+($1)+"+f).replace(/^`([\s\S]+)`$/,f+"$1"+f).replace(/\n+/g,"").replace(new RegExp(d,"g"),"\\$")}try{_=_babel_runtime_helpers_construct__WEBPACK_IMPORTED_MODULE_1___default()(Function,(n?u.globalNames:[]).concat(u.scopeNames,[(r?"":"return ")+e]))}catch(t){u.error='Given expression "'+e+'" could not be compiled width given scope names "'+u.scopeNames.join('", "')+'": '+(0,_object__WEBPACK_IMPORTED_MODULE_4__.represent)(t)}if(_){var m=_.bind(o);u.templateFunction=n?function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return m.apply(void 0,u.globalNamesUndefinedList.concat(t))}:m}return u},_evaluate2=function(e,t,r,n,o){void 0===t&&(t={}),void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o={});var a=_compile(e,t,r,n,o),i=a.error,_=a.originalScopeNames,c=a.scopeNames,u=a.templateFunction,s={compileError:null,runtimeError:null,error:"Not yet evaluated.",result:void 0};if(i)return s.compileError=s.error=i,s;try{s={compileError:null,runtimeError:null,error:null,result:u.apply(void 0,_.map((function(e){return t[e]})))}}catch(i){s.error=s.runtimeError='Given expression "'+e+'" could not be evaluated with given scope names "'+c.join('", "')+'": '+(0,_object__WEBPACK_IMPORTED_MODULE_4__.represent)(i)}return s},_findNormalizedMatchRange=function(e,t,r,n){void 0===r&&(r=function(e){return String(e).toLowerCase()}),void 0===n&&(n=["<",">"]);var o=r(t),a=r(e),i="string"==typeof e?e:a;if(a&&o)for(var _=!1,c=0;c<i.length;c+=1)if(_)Array.isArray(n)&&i.charAt(c)===n[1]&&(_=!1);else if(Array.isArray(n)&&i.charAt(c)===n[0])_=!0;else if(r(i.substring(c)).startsWith(o)){if(1===o.length)return[c,c+1];for(var u=i.length;u>c;u-=1)if(!r(i.substring(c,u)).startsWith(o))return[c,u+1]}return null},_fixKnownEncodingErrors=function(e){for(var t=0,r=_FIX_ENCODING_ERROR_MAPPING;t<r.length;t++){var n=r[t],o=n[0],a=n[1];e=e.replace(new RegExp(o,"g"),a)}return e},_format=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];r.unshift(e);for(var o=0,a=0,i=r;a<i.length;a++){var _=i[a];e=e.replace(new RegExp("\\{"+String(o)+"\\}","gm"),String(_)),o+=1}return e},_getEditDistance=function(e,t){for(var r=Array(t.length+1).fill(null).map((function(){return Array(e.length+1).fill(null)})),n=0;n<=e.length;n++)r[0][n]=n;for(var o=0;o<=t.length;o++)r[o][0]=o;for(var a=1;a<=t.length;a++)for(var i=1;i<=e.length;i++){var _=e[i-1]===t[a-1]?0:1;r[a][i]=Math.min(r[a][i-1]+1,r[a-1][i]+1,r[a-1][i-1]+_)}return r[t.length][e.length]},_maskForRegularExpression=function(e){return e.replace(/([\\|.*$^+[\]()?\-{}])/g,"\\$1")},_lowerCase=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},_mark=function(e,t,r){if(void 0===r&&(r={}),"string"==typeof e&&null!=t&&t.length){var n=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({marker:'<span class="tools-mark">{1}</span>',normalizer:function(e){return String(e).toLowerCase()},skipTagDelimitedParts:["<",">"]},r);e=e.trim();for(var o,a=[],i=[].concat(t),_=0,c=_createForOfIteratorHelperLoose(i);!(o=c()).done;){var u=o.value;i[_]=n.normalizer(u).trim(),_+=1}for(var s=e,l=0,p=0;p<_context__WEBPACK_IMPORTED_MODULE_3__.MAXIMAL_NUMBER_OF_ITERATIONS.value;p++){for(var d,f=null,m=void 0,v=_createForOfIteratorHelperLoose(i);!(d=v()).done;){var b=d.value;(m=_findNormalizedMatchRange(s,b,n.normalizer,n.skipTagDelimitedParts))&&(!f||m[0]<f[0])&&(f=m)}if(!f){s.length&&a.push(s);break}f[0]>0&&a.push(e.substring(l,l+f[0])),a.push("string"==typeof n.marker?_format(n.marker,e.substring(l+f[0],l+f[1])):n.marker(e.substring(l+f[0],l+f[1]),a)),l+=f[1],s=e.substring(l)}return"string"==typeof n.marker?a.join(""):a}return e},_normalizePhoneNumber=function(e,t){if(void 0===t&&(t=!0),"string"==typeof e||"number"==typeof e){var r=String(e).trim();if(r=(r=r.replace(/^[^0-9]*\+/,"00")).replace(/([0-9].*?) *(,|o[rd]?)\.? ?-?[0-9]+$/,"$1"),t)return r.replace(/[^0-9]+/g,"");var n="(?:[ /\\-]+)";r=(r=r.replace(new RegExp("^(.+?)"+n+"?\\(0\\)"+n+"?(.+)$"),"$1-$2")).replace(new RegExp("^(.+?)"+n+"?\\((.+)\\)"+n+"?(.+)$"),"$1-$2-$3");var o=new RegExp("^(00[0-9]+)"+n+"([0-9]+)"+n+"(.+)$");if(o.test(r))r=r.replace(o,(function(e,t,r,n){return t+"-"+r+"-"+_sliceAllExceptNumberAndLastSeparator(n)}));else{var a=function(e,t,r){return t.replace(/ +/,"")+"-"+_sliceAllExceptNumberAndLastSeparator(r)};r=(o=/^([0-9 ]+)[/-](.+)$/).test(r)?r.replace(o,a):r.replace(new RegExp("^([0-9]+)"+n+"(.+)$"),a)}return r.replace(/[^0-9-]+/g,"").replace(/^-+$/,"")}return""},_normalizeZipCode=function(e){return"string"==typeof e||"number"==typeof e?String(e).trim().replace(/^([^0-9]*[a-zA-Z]-)?(.+)$/,(function(e,t,r){var n;return t&&(t=t.substring(t.length-2).charAt(0).toUpperCase()+"-"),(null!==(n=t)&&void 0!==n?n:"")+(null!=r?r:"").trim().replace(/[^0-9]+/g,"")})):""},_parseEncodedObject=function parseEncodedObject(serializedObject,scope,name){var _evaluate;if(void 0===scope&&(scope={}),void 0===name&&(name="scope"),!_filesystem__WEBPACK_IMPORTED_MODULE_5__.readFileSync)throw new Error("File system api could not be loaded.");serializedObject.endsWith(".json")&&(0,_filesystem__WEBPACK_IMPORTED_MODULE_5__.isFileSync)(serializedObject)&&(serializedObject=(0,_filesystem__WEBPACK_IMPORTED_MODULE_5__.readFileSync)(serializedObject,{encoding:_constants__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_ENCODING})),serializedObject=serializedObject.trim(),serializedObject.startsWith("{")||(serializedObject=eval("Buffer").from(serializedObject,"base64").toString(_constants__WEBPACK_IMPORTED_MODULE_2__.DEFAULT_ENCODING));var result=_evaluate2(serializedObject,(_evaluate={},_evaluate[name]=scope,_evaluate));return"object"==typeof result.result?result.result:null},_representPhoneNumber=function(e){if(["number","string"].includes((0,_object__WEBPACK_IMPORTED_MODULE_4__.determineType)(e))&&e){var t=String(e).replace(/^(00|\+)([0-9]+)-([0-9-]+)$/,"+$2 (0) $3");return(t=(t=t.replace(/^0([1-9][0-9-]+)$/,"+49 (0) $1")).replace(/^([^-]+)-([0-9-]+)$/,"$1 / $2")).replace(/^(.*?)([0-9]+)(-?[0-9]*)$/,(function(e,t,r,n){return t+(r.length%2==0?r.replace(/([0-9]{2})/g,"$1 "):r.replace(/^([0-9]{3})([0-9]+)$/,(function(e,t,r){return t+" "+r.replace(/([0-9]{2})/g,"$1 ").trim()}))+n).trim()})).trim()}return""},_sliceAllExceptNumberAndLastSeparator=function(e){var t=/^(.*[0-9].*)-([0-9]+)$/;return t.test(e)?e.replace(t,(function(e,t,r){return t.replace(/[^0-9]+/g,"")+"-"+r})):e.replace(/[^0-9]+/g,"")},_normalizeDomNodeSelector=function(e,t){void 0===t&&(t="");var r="";return t&&(r=t+" "),e.startsWith(r)||e.trim().startsWith("<")||(e=r+e),e.trim()},_limit=function(e,t){return void 0===t&&(t=100),e.length<=t?e:e.substring(0,t-3)+"..."}},function(e,t,r){r.r(t),r.d(t,{ceil:function(){return _},floor:function(){return c},getUTCTimestamp:function(){return o},isNotANumber:function(){return a},round:function(){return i}});var n=r(2),o=function(e,t){void 0===t&&(t=!1);var r=[null,void 0].includes(e)?new Date:new Date(e);return Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate(),r.getUTCHours(),r.getUTCMinutes(),r.getUTCSeconds(),r.getUTCMilliseconds())/(t?1:1e3)},a=function(e){return"number"===(0,n.determineType)(e)&&isNaN(e)},i=function(e,t){return void 0===t&&(t=0),Math.round(e*Math.pow(10,t))/Math.pow(10,t)},_=function(e,t){return void 0===t&&(t=0),Math.ceil(e*Math.pow(10,t))/Math.pow(10,t)},c=function(e,t){return void 0===t&&(t=0),Math.floor(e*Math.pow(10,t))/Math.pow(10,t)}},function(e,t,r){r.d(t,{Lock:function(){return _}});var n=r(11),o=r.n(n),a=r(12),i=r.n(a),_=function(){function e(e){void 0===e&&(e={}),this.locks=void 0,this.locks=e}var t=e.prototype;return t.acquire=function(e,t,r){var n=this;return void 0===r&&(r=!1),new Promise((function(o){var a=function(e){var a,i;t&&(i=t(e));var _=function(t){return r&&n.release(e),o(t),t};return null!=(a=i)&&a.then?i.then(_):(_(i),i)};Object.prototype.hasOwnProperty.call(n.locks,e)?n.locks[e].push(a):(n.locks[e]=[],a(e))}))},t.release=function(){var e=o()(i().mark((function e(t){var r;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Object.prototype.hasOwnProperty.call(this.locks,t)){e.next=3;break}if(void 0!==(r=this.locks[t].shift())){e.next=1;break}delete this.locks[t],e.next=3;break;case 1:return e.next=2,r(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),e}()},function(e,t,r){r.d(t,{Semaphore:function(){return n}});var n=function(){function e(e){void 0===e&&(e=2),this.queue=[],this.numberOfResources=void 0,this.numberOfFreeResources=void 0,this.numberOfResources=e,this.numberOfFreeResources=e}var t=e.prototype;return t.acquire=function(){var e=this;return new Promise((function(t){e.numberOfFreeResources<=0?e.queue.push(t):(e.numberOfFreeResources-=1,t(e.numberOfFreeResources))}))},t.release=function(){var e=this.queue.shift();void 0===e?this.numberOfFreeResources+=1:e(this.numberOfFreeResources)},e}()},function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__11__},function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__12__},function(e){e.exports=__WEBPACK_EXTERNAL_MODULE__13__},function(e,t,r){r.r(t),r.d(t,{copyDirectoryRecursive:function(){return $},copyDirectoryRecursiveSync:function(){return q},copyFile:function(){return z},copyFileSync:function(){return V},isDirectory:function(){return H},isDirectorySync:function(){return G},isFile:function(){return Y},isFileSync:function(){return X},mkdirSync:function(){return v},readFileSync:function(){return E},readdirSync:function(){return h},statSync:function(){return g},walkDirectoryRecursively:function(){return J},walkDirectoryRecursivelySync:function(){return Z},writeFileSync:function(){return x}});var n=r(4),o=r.n(n),a=r(11),i=r.n(a),_=r(12),c=r.n(_),u=r(0),s=r(1),l=r(5);function p(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return d(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?d(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var f=(0,l.optionalRequire)("fs")||{},m=f.mkdirSync,v=void 0===m?null:m,b=f.readdirSync,h=void 0===b?null:b,y=f.readFileSync,E=void 0===y?null:y,O=f.statSync,g=void 0===O?null:O,P=f.writeFileSync,x=void 0===P?null:P,D=(0,l.optionalRequire)("fs/promises")||{},M=D.mkdir,A=void 0===M?null:M,I=D.readdir,C=void 0===I?null:I,w=D.readFile,T=void 0===w?null:w,L=D.stat,S=void 0===L?null:L,R=D.writeFile,U=void 0===R?null:R,k=(0,l.optionalRequire)("path")||{},j=k.basename,B=void 0===j?null:j,N=k.join,K=void 0===N?null:N,W=k.resolve,F=void 0===W?null:W,$=function(){var e=i()(c().mark((function e(t,r,n,o,a){var i,_,l,d,f,m,v,b;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n=s.NOOP),void 0===o&&(o={encoding:null,flag:"r"}),void 0===a&&(a={encoding:u.DEFAULT_ENCODING,flag:"w",mode:438}),B&&K&&A&&F){e.next=1;break}throw new Error("Could not load filesystem functions.");case 1:return t=F(t),e.next=2,H(r);case 2:if(!e.sent){e.next=3;break}r=F(r,B(t));case 3:return e.prev=3,e.next=4,A(r);case 4:e.next=6;break;case 5:if(e.prev=5,"EEXIST"===(m=e.catch(3)).code){e.next=6;break}throw m;case 6:return v=p,e.next=7,J(t,n);case 7:i=v(e.sent);case 8:if((_=i()).done){e.next=15;break}if(d=_.value,f=K(r,d.path.substring(t.length)),null==(l=d.stats)||!l.isDirectory()){e.next=13;break}return e.prev=9,e.next=10,A(f);case 10:e.next=12;break;case 11:if(e.prev=11,"EEXIST"===(b=e.catch(9)).code){e.next=12;break}throw b;case 12:e.next=14;break;case 13:return e.next=14,z(d.path,f,o,a);case 14:e.next=8;break;case 15:return e.abrupt("return",r);case 16:case"end":return e.stop()}}),e,null,[[3,5],[9,11]])})));return function(t,r,n,o,a){return e.apply(this,arguments)}}(),q=function(e,t,r,n,o){if(void 0===r&&(r=s.NOOP),void 0===n&&(n={encoding:null,flag:"r"}),void 0===o&&(o={encoding:u.DEFAULT_ENCODING,flag:"w",mode:438}),!(B&&K&&v&&F))throw new Error("Could not load filesystem functions.");e=F(e),G(t)&&(t=F(t,B(e)));try{v(t)}catch(e){if("EEXIST"!==e.code)throw e}for(var a=0,i=Z(e,r);a<i.length;a++){var _,c=i[a],l=K(t,c.path.substring(e.length));if(null!=(_=c.stats)&&_.isDirectory())try{v(l)}catch(e){if("EEXIST"!==e.code)throw e}else V(c.path,l,n,o)}return t},z=function(){var e=i()(c().mark((function e(t,r,n,o){var a,i;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===n&&(n={encoding:null,flag:"r"}),void 0===o&&(o={encoding:u.DEFAULT_ENCODING,flag:"w",mode:438}),B&&T&&F&&U){e.next=1;break}throw new Error("Could not load filesystem functions.");case 1:return e.next=2,H(r);case 2:if(!e.sent){e.next=3;break}r=F(r,B(t));case 3:return a=U,i=r,e.next=4,T(t,n);case 4:return e.next=5,a(i,e.sent,o);case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e)})));return function(t,r,n,o){return e.apply(this,arguments)}}(),V=function(e,t,r,n){if(void 0===r&&(r={encoding:null,flag:"r"}),void 0===n&&(n={encoding:u.DEFAULT_ENCODING,flag:"w",mode:438}),!(B&&E&&F&&x))throw new Error("Could not load filesystem functions.");return G(t)&&(t=F(t,B(e))),x(t,E(e,r),n),t},H=function(){var e=i()(c().mark((function e(t){var r;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(S){e.next=1;break}throw new Error("Could not load filesystem functions.");case 1:return e.prev=1,e.next=2,S(t);case 2:return e.abrupt("return",e.sent.isDirectory());case 3:if(e.prev=3,r=e.catch(1),!Object.prototype.hasOwnProperty.call(r,"code")||!["ENOENT","ENOTDIR"].includes(r.code)){e.next=4;break}return e.abrupt("return",!1);case 4:throw r;case 5:case"end":return e.stop()}}),e,null,[[1,3]])})));return function(t){return e.apply(this,arguments)}}(),G=function(e){if(!g)throw new Error("Could not load filesystem functions.");try{return g(e).isDirectory()}catch(e){if(Object.prototype.hasOwnProperty.call(e,"code")&&["ENOENT","ENOTDIR"].includes(e.code))return!1;throw e}},Y=function(){var e=i()(c().mark((function e(t){var r;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(S){e.next=1;break}throw new Error("Could not load filesystem functions.");case 1:return e.prev=1,e.next=2,S(t);case 2:return e.abrupt("return",e.sent.isFile());case 3:if(e.prev=3,r=e.catch(1),!Object.prototype.hasOwnProperty.call(r,"code")||!["ENOENT","ENOTDIR"].includes(r.code)){e.next=4;break}return e.abrupt("return",!1);case 4:throw r;case 5:case"end":return e.stop()}}),e,null,[[1,3]])})));return function(t){return e.apply(this,arguments)}}(),X=function(e){if(!g)throw new Error("Could not load filesystem functions.");try{return g(e).isFile()}catch(e){if(Object.prototype.hasOwnProperty.call(e,"code")&&["ENOENT","ENOTDIR"].includes(e.code))return!1;throw e}},J=function(){var e=i()(c().mark((function e(t,r,n){var a,i,_,s,l,d,f,m,v,b,h,y,E,O,g;return c().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r=null),void 0===n&&(n=u.DEFAULT_ENCODING),C&&F&&S){e.next=1;break}throw new Error("Could not load filesystem functions.");case 1:return a=[],E=p,e.next=2,C(t,"string"==typeof n?{encoding:n,withFileTypes:!0}:o()({},n,{withFileTypes:!0}));case 2:i=E(e.sent);case 3:if((_=i()).done){e.next=9;break}return s=_.value,l=F(t,s.name),d={directoryPath:t,directoryEntry:s,error:null,name:s.name,path:l,stats:null},e.prev=4,e.next=5,S(l);case 5:d.stats=e.sent,e.next=7;break;case 6:e.prev=6,O=e.catch(4),d.error=O;case 7:a.push(d);case 8:e.next=3;break;case 9:r&&a.sort((function(e,t){var r,n,o;return null!=(r=e.stats)&&r.isDirectory()?null!=(o=t.stats)&&o.isDirectory()?0:-1:null!=(n=t.stats)&&n.isDirectory()?1:0})),f=[],m=0,v=a;case 10:if(!(m<v.length)){e.next=17;break}if(h=v[m],f.push(h),null!==(y=r?r(h):void 0)){e.next=11;break}return e.abrupt("continue",17);case 11:if("object"!=typeof y||!("then"in y)){e.next=13;break}return e.next=12,y;case 12:y=e.sent;case 13:if(null!==y){e.next=14;break}return e.abrupt("continue",17);case 14:if(!1===y||null==(b=h.stats)||!b.isDirectory()){e.next=16;break}return g=f,e.next=15,J(h.path,r,n);case 15:f=g.concat.call(g,e.sent);case 16:m++,e.next=10;break;case 17:return e.abrupt("return",f);case 18:case"end":return e.stop()}}),e,null,[[4,6]])})));return function(t,r,n){return e.apply(this,arguments)}}(),Z=function(e,t,r){if(void 0===t&&(t=s.NOOP),void 0===r&&(r=u.DEFAULT_ENCODING),!(h&&F&&g))throw new Error("Could not load filesystem functions.");for(var n,a=[],i=p(h(e,"string"==typeof r?{encoding:r,withFileTypes:!0}:o()({},r,{withFileTypes:!0})));!(n=i()).done;){var _=n.value,c=F(e,_.name),l={directoryPath:e,directoryEntry:_,error:null,name:_.name,path:c,stats:null};try{l.stats=g(c)}catch(e){l.error=e}a.push(l)}var d=[];if(t){a.sort((function(e,t){var r,n,o;return null!=(r=e.stats)&&r.isDirectory()?null!=(o=t.stats)&&o.isDirectory()?0:-1:null!=(n=t.stats)&&n.isDirectory()?1:0}));for(var f,m=p(a);!(f=m()).done;){var v,b=f.value;d.push(b);var y=t(b);if(null===y)break;!1!==y&&null!=(v=b.stats)&&v.isDirectory()&&(d=d.concat(Z(b.path,t,r)))}}return d}},function(e,t,r){r.r(t),r.d(t,{debounce:function(){return a},preventDefault:function(){return _},stopPropagation:function(){return c},timeout:function(){return i}});var n=r(1),o=r(3),a=function(e,t){void 0===t&&(t=600);for(var r=arguments.length,n=new Array(r>2?r-2:0),o=2;o<r;o++)n[o-2]=arguments[o];var a,_,c=new Promise((function(e){_=e}));return function(){for(var r,o=arguments.length,u=new Array(o),s=0;s<o;s++)u[s]=arguments[s];return u=u.concat(n),null==(r=a)||r.clear(),a=i((function(){_(e.apply(void 0,u)),c=new Promise((function(e){_=e}))}),t),c}},i=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var a,i,_=n.NOOP,c=0,u=!1,s=0,l=t;s<l.length;s++){var p=l[s];"number"!=typeof p||isNaN(p)?"boolean"==typeof p?u=p:(0,o.isFunction)(p)&&(_=p):c=p}var d=new Promise((function(e,t){a=t,i=e})),f=function(){var e;(e=_).call.apply(e,[d].concat(t)),i(!1)},m=2147483647;if(c<=m)d.timeoutID=setTimeout(f,c);else{var v=Math.floor(c/m),b=c%m,h=function(){v>0?(v-=1,d.timeoutID=setTimeout(h,m)):d.timeoutID=setTimeout(f,b)};h()}return d.clear=function(){Object.prototype.hasOwnProperty.call(d,"timeoutID")&&(clearTimeout(d.timeoutID),(u?a:i)(!0))},d},_=function(e){e.preventDefault()},c=function(e){e.stopPropagation()}},function(e,t,r){r.d(t,{isAndExpression:function(){return c},isArrayContainsExpression:function(){return b},isConcatExpression:function(){return s},isCondition:function(){return _},isIfExpression:function(){return f},isMappingExpression:function(){return l},isOperation:function(){return p},isOrExpression:function(){return u},isSelector:function(){return v},isSpecificExpression:function(){return i},isSwitchExpression:function(){return m},isUnaryOperation:function(){return d},isValue:function(){return h}});var n=r(3);function o(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var i=function(e,t,r){if(void 0===r&&(r=[]),!(0,n.isPlainObject)(e)||!Object.prototype.hasOwnProperty.call(e,t))return!1;for(var a,i=o(r);!(a=i()).done;){var _=a.value;if(!Object.prototype.hasOwnProperty.call(e,_))return!1}return!0},_=function(e){return i(e,"$comparator",["value1","value2"])},c=function(e){return i(e,"$and")},u=function(e){return i(e,"$or")},s=function(e){return i(e,"$concat")},l=function(e){return i(e,"$mapping",["data"])},p=function(e){return i(e,"$operator",["operand1","operand2"])},d=function(e){return i(e,"$operator",["operand"])},f=function(e){return i(e,"$if")},m=function(e){return i(e,"$switch")},v=function(e){return i(e,"$select")},b=function(e){return i(e,"$arrayContains")},h=function(e){return!(v(e)||_(e)||d(e)||p(e)||c(e)||u(e)||s(e)||l(e)||f(e)||m(e)||b(e))}},function(e,t,r){r.d(t,{CLI_COLOR:function(){return n}});var n={black:"",blink:"",blue:"",bold:"",cyan:"",darkGray:"",default:"",dim:"",green:"",invert:"",invisible:"",lightBlue:"",lightCyan:"",lightGray:"",lightGreen:"",lightMagenta:"",lightRed:"",lightYellow:"",magenta:"",nodim:"",noblink:"",nobold:"",noinvert:"",noinvisible:"",nounderline:"",red:"",underline:"",white:"",yellow:""}},function(e,t,r){r.r(t),r.d(t,{LEVELS:function(){return c},LEVELS_COLOR:function(){return u},Logger:function(){return s}});var n,o=r(17),a=r(1),i=r(3),_=r(2),c=["error","critical","warn","info","debug"],u=[o.CLI_COLOR.red,o.CLI_COLOR.magenta,o.CLI_COLOR.yellow,o.CLI_COLOR.green,o.CLI_COLOR.blue],s=function(){function e(t){void 0===t&&(t={}),this.level=e.defaultLevel,this.name=e.defaultName,this.configure(t),e.instances[this.name]=this}e.configureAllInstances=function(t){void 0===t&&(t={}),t.level&&(e.defaultLevel=t.level),t.name&&(e.defaultName=t.name);for(var r=0,n=Object.values(e.instances);r<n.length;r++)n[r].configure(t)};var t=e.prototype;return t.configure=function(t){var r=t.name,n=t.level;this.level=n||e.defaultLevel,this.name=r||e.defaultName},t.log=function(e,t,r,n){void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===n&&(n="info");var _=c.indexOf(this.level),s=c.indexOf(n);if(t||_>=s){for(var l,p=[],d=""+u[s]+n+o.CLI_COLOR.default+":"+this.name+":"+(new Date).toISOString()+":",f=arguments.length,m=new Array(f>4?f-4:0),v=4;v<f;v++)m[v-4]=arguments[v];if(r)p.push(e);else if("string"==typeof e)p.push.apply(p,[d,e].concat(m));else if((0,i.isNumeric)(e)||"boolean"==typeof e)p.push.apply(p,[d,e.toString()].concat(m));else{var b=d.substring(0,d.length-1),h=77+u[s].length+o.CLI_COLOR.default.length-b.length,y=Math.floor(h/2);this.log(","+"-".repeat(y)+b+"-".repeat(y)+"-".repeat(h%2)+",",t,!0,n),this.log(e,t,!0,n),this.log("'"+"-".repeat(77)+"'",t,!0,n)}if(p.length)if(a.globalContext.console&&n in a.globalContext.console&&a.globalContext.console[n]!==a.NOOP)(l=a.globalContext.console)[n].apply(l,p);else{var E;Object.prototype.hasOwnProperty.call(a.globalContext,"window")&&Object.prototype.hasOwnProperty.call(a.globalContext.window,"alert")&&(null==(E=a.globalContext.window)||E.alert(p.join(" ")))}}},t.info=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[e,!1,!1,"info"].concat(r))},t.debug=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[e,!1,!1,"debug"].concat(r))},t.error=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[e,!0,!1,"error"].concat(r))},t.critical=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[e,!0,!1,"warn"].concat(r))},t.warn=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.log.apply(this,[e,!1,!1,"warn"].concat(r))},e.show=function(t,r,n){void 0===r&&(r=3),void 0===n&&(n=0);var o="";if("object"===(0,_.determineType)(t)){for(var a=0,i=Object.entries(t);a<i.length;a++){var c=i[a],u=c[0],s=c[1];o+=u+": ",o+=n<=r?e.show(s,r,n+1):String(s),o+="\n"}return o.trim()}return(o=String(t).trim())+' (Type: "'+(0,_.determineType)(t)+'")'},e}();n=s,s.defaultLevel="warn",s.defaultName="app",s.selfClass=n,s.instances={},s.runtimeVersion=Math.random(),t.default=s},function(e,t,r){r.r(t),r.d(t,{aggregatePropertyIfEqual:function(){return c},deleteEmptyItems:function(){return u},extract:function(){return s},extractIfMatches:function(){return l},extractIfPropertyExists:function(){return p},extractIfPropertyMatches:function(){return d},intersect:function(){return f},makeArray:function(){return m},makeRange:function(){return v},merge:function(){return b},paginate:function(){return h},permute:function(){return y},permuteLength:function(){return E},removeArrayItem:function(){return g},sortTopological:function(){return P},sumUpProperty:function(){return O},unique:function(){return x}});var n=r(4),o=r.n(n),a=r(3);function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return _(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var c=function(e,t,r){void 0===r&&(r="");var n=r;if(Array.isArray(e)&&e.length&&Object.prototype.hasOwnProperty.call(e[0],t)){n=e[0][t];for(var o=0,a=m(e);o<a.length;o++)if(a[o][t]!==n)return r}return n},u=function(e,t){void 0===t&&(t=[]);for(var r=[],n=0,o=m(e);n<o.length;n++){for(var a=o[n],i=!0,_=0,c=Object.entries(a);_<c.length;_++){var u=c[_],s=u[0],l=u[1];if(!["",null,void 0].includes(l)&&(!t.length||m(t).includes(s))){i=!1;break}}i||r.push(a)}return r},s=function(e,t){for(var r=[],n=0,o=m(e);n<o.length;n++){for(var a=o[n],i={},_=0,c=m(t);_<c.length;_++){var u=c[_];Object.prototype.hasOwnProperty.call(a,u)&&(i[u]=a[u])}r.push(i)}return r},l=function(e,t){if(!t)return m(e);for(var r=[],n=0,o=m(e);n<o.length;n++){var a=o[n];("string"==typeof t?new RegExp(t):t).test(a)&&r.push(a)}return r},p=function(e,t){if(e&&t){for(var r=[],n=0,o=m(e);n<o.length;n++){for(var a=o[n],i=!1,_=0,c=Object.entries(a);_<c.length;_++){var u=c[_],s=u[0],l=u[1];if(s===t&&![null,void 0].includes(l)){i=!0;break}}i&&r.push(a)}return r}return e},d=function(e,t){if(e){for(var r=[],n=0,o=m(e);n<o.length;n++){var a=o[n],i=!0;for(var _ in t)if(!t[_]||!("string"==typeof t[_]?new RegExp(t[_]):t[_]).test(a[_])){i=!1;break}i&&r.push(a)}return r}return e},f=function(e,t,r,n){void 0===r&&(r=[]),void 0===n&&(n=!0);var o=[];t=m(t);for(var _=function(e,t,r,o,a,i){if(i?a&&(r=o):o=r,t[o]!==e[r]&&(n||![null,void 0].includes(t[o])||![null,void 0].includes(e[r])))return!1},c=0,u=m(e);c<u.length;c++){var s=u[c];if((0,a.isPlainObject)(s))for(var l=0,p=t;l<p.length;l++){var d=p[l],f=!0,v=void 0,b=Array.isArray(r);if((0,a.isPlainObject)(r)||b&&r.length?v=!0:(v=!1,r=s),Array.isArray(r))for(var h,y=0,E=i(r);!(h=E()).done;){if(!1===_(s,d,y,h.value,b,v)){f=!1;break}y+=1}else for(var O=0,g=Object.entries(r);O<g.length;O++){var P=g[O];if(!1===_(s,d,P[0],P[1],b,v)){f=!1;break}}if(f){o.push(s);break}}else t.includes(s)&&o.push(s)}return o},m=function(e){var t=[];return[null,void 0].includes(e)||((0,a.isArrayLike)(Object(e))?b(t,"string"==typeof e?[e]:e):t.push(e)),t},v=function(e,t,r){var n,o;if(void 0===t&&(t=1),void 0===r&&(r=!1),1===(e=[].concat(e)).length)n=0,o=parseInt(String(e[0]),10);else{if(2!==e.length)return e;n=parseInt(String(e[0]),10),o=parseInt(String(e[1]),10)}if(o<n)return[];for(var a=[n];n<=o-t;)n+=t,(!r||n<=o-t)&&a.push(n);return a},b=function(e,t){Array.isArray(t)||(t=Array.prototype.slice.call(t));for(var r,n=i(t);!(r=n()).done;){var o=r.value;e.push(o)}return e},h=function(e){void 0===e&&(e={});var t=e,r=t.boundaryCount,n=void 0===r?1:r,a=t.disabled,i=void 0!==a&&a,_=t.hideNextButton,c=void 0!==_&&_,u=t.hidePrevButton,s=void 0!==u&&u,l=t.page,p=void 0===l?1:l,d=t.pageSize,f=void 0===d?5:d,m=t.showFirstButton,b=void 0!==m&&m,h=t.showLastButton,y=void 0!==h&&h,E=t.siblingCount,O=void 0===E?4:E,g=t.total,P=void 0===g?100:g,x="number"!=typeof f||isNaN(f)?P:Math.ceil(P/f),D=v([1,Math.min(n,x)]),M=v([Math.max(x-n+1,n+1),x]),A=Math.max(Math.min(p-O,x-n-2*O-1),n+2),I=Math.min(Math.max(p+O,n+2*O+2),M.length>0?M[0]-2:x-1);return[].concat(b?["first"]:[],s?[]:["previous"],D,A>n+2?["start-ellipsis"]:n+1<x-n?[n+1]:[],v([A,I]),I<x-n-1?["end-ellipsis"]:x-n>n?[x-n]:[],M,c?[]:["next"],y?["last"]:[]).map((function(e){var t;return"number"==typeof e?{disabled:i,page:e,selected:e===p,type:"page"}:o()({disabled:i||-1===e.indexOf("ellipsis")&&("next"===e||"last"===e?p>=x:p<=1),selected:!1,type:e},e.endsWith("-ellipsis")?{}:{page:(null!==(t={first:1,last:x}[e])&&void 0!==t?t:"next"===e)?Math.min(p+1,x):Math.max(p-1,1)})}))},y=function(e){var t=[],r=function(e,n){if(void 0===n&&(n=[]),0===e.length)t.push(n);else for(var o=0;o<e.length;o++){var a=e.slice();r(a,n.concat(a.splice(o,1)))}};return r(e),t},E=function(e,t){void 0===t&&(t=1);var r=[];if(0===e.length)return r;for(var n=function(e,t,o){if(0!==e)for(var a=0;a<t.length;a++)n(e-1,t.slice(a+1),o.concat([t[a]]));else o.length>0&&(r[r.length]=o)},o=t;o<e.length;o++)n(o,e,[]);return r.push(e),r},O=function(e,t){var r=0;if(Array.isArray(e)&&e.length)for(var n,o=i(e);!(n=o()).done;){var a=n.value;Object.prototype.hasOwnProperty.call(a,t)&&(r+=parseFloat(a[t]||0))}return r},g=function(e,t,r){void 0===r&&(r=!1);var n=e.indexOf(t);if(-1===n){if(r)throw new Error("Given target doesn't exists in given list.")}else e.splice(n,1);return e},P=function(e){for(var t=[],r=0,n=Object.entries(e);r<n.length;r++){var o=n[r],a=o[0],_=o[1];if(e[a]=[].concat(_),_.length>0)for(var c,u=i(m(_));!(c=u()).done;){var s=c.value;t.push([a,s])}else t.push([a])}for(var l=[],p=0,d=t;p<d.length;p++)for(var f,v=i(d[p]);!(f=v()).done;){var b=f.value;l.includes(b)||l.push(b)}for(var h=[],y=function(e,r){if(0!==r.length&&r.includes(e))throw new Error('Cyclic dependency found. "'+e+'" is dependent of itself.\nDependency chain: "'+r.join('" -> "')+'" => "'+e+'".');var n=l.indexOf(e);if(-1!==n){var o;l[n]=null;for(var a=0,i=t;a<i.length;a++){var _=i[a];_[0]===e&&(o=o||r.concat([e]),y(_[1],o))}h.push(e)}},E=0;E<l.length;E++){var O=l[E];if(O){l[E]=null;for(var g,P=i(t);!(g=P()).done;){var x=g.value;x[0]===O&&y(x[1],[O])}h.push(O)}}return h},x=function(e){for(var t,r=[],n=i(m(e));!(t=n()).done;){var o=t.value;r.includes(o)||r.push(o)}return r}},function(e,t,r){r.r(t),r.d(t,{DATE_TIME_PATTERN_CACHE:function(){return l},dateTimeFormat:function(){return p},interpretDateTime:function(){return d},normalizeDateTime:function(){return f},sliceWeekday:function(){return m}});var n=r(13),o=r.n(n),a=r(4),i=r.n(a),_=r(0),c=r(7);function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var l=[],p=function(e,t,r,n){void 0===e&&(e="full"),void 0===t&&(t=new Date),void 0===r&&(r={}),void 0===n&&(n=_.LOCALES),"number"==typeof t&&(t*=1e3);var o=new Date(t);if(["full","long","medium","short"].includes(e))return new Intl.DateTimeFormat([].concat(n,"en-US"),i()({dateStyle:e,timeStyle:e},r)).format(o);for(var a,s={},l=u(["full","long","medium","short"]);!(a=l()).done;){var p=a.value;s[p+"Literals"]=[];var d=new Intl.DateTimeFormat([].concat(n,"en-US"),i()({dateStyle:p,timeStyle:p},r));s[p]=d.format(o);for(var f,m=u(d.formatToParts(o));!(f=m()).done;){var v=f.value;"literal"===v.type?s[p+"Literals"].push(v.value):s[""+p+(0,c.capitalize)(v.type)]=v.value}}var b=(0,c.evaluate)("`"+e+"`",s);if(b.error)throw new Error(b.error);return b.result.replace(/\s/g," ")},d=function(e,t){var r=Boolean(t),n="[0-2][0-9]:[0-6][0-9]",a="^[0-9]{4}-[01][0-9]-[0-3][0-9](?<time>(?:T"+n+"(?::[0-6][0-9](?:\\.[0-9]+)?)?(?<dateTimeTimezone>Z|(?:[+-]"+n+"))?)|(?<dateTimezone>Z|(?:[+-]"+n+")))?$",i=e.match(new RegExp(a,"i"));if(i){var _,s,p,f,v,b=new Date(e);return isNaN(b.getDate())?null:(null!==(_=null==(s=i.groups)?void 0:s.dateTimeTimezone)&&void 0!==_?_:null==(p=i.groups)?void 0:p.dateTimezone)?b:([null,void 0].includes(t)&&(r=!1),r?null!=(v=i.groups)&&v.time?new Date(b.getTime()-60*b.getTimezoneOffset()*1e3):b:null!=(f=i.groups)&&f.time?b:new Date(b.getTime()+60*b.getTimezoneOffset()*1e3))}if(e=e.replace(/^(-?)-*0*([1-9][0-9]*)$/,"$1$2"),String(parseInt(e))===e){[null,void 0].includes(t)&&(r=!0);var h=new Date(1e3*parseInt(e));return new Date(1e3*(parseInt(e)+(r?0:60*h.getTimezoneOffset())))}if(!l.length)for(var y,E="(?:0?[0-9])|(?:[1-5][0-9])|(?:60)",O="(?<second>"+E+")",g="(?<minute>"+E+")",P="(?<hour>(?:0?[0-9])|(?:1[0-9])|(?:2[0-4]))",x="(?<noonIndicator> *(?:(?:a\\.?m\\.?)|(?:p\\.?m\\.?)))?",D="(?<day>(?:0?[1-9])|(?:[1-2][0-9])|(?:3[01]))",M="(?<month>(?:0?[1-9])|(?:1[0-2]))",A="(?<year>(?:0?[1-9])|(?:[1-9][0-9]+))",I={},C=u(["t"," "]);!(y=C()).done;)for(var w,T=y.value,L=u([":","/","-"," "]);!(w=L()).done;)for(var S=w.value,R=0,U=[P+(S+"+")+g+x,P+(S+"+")+g+S+"+"+O+x,P+(S+"+")+g+S+"+"+O+S+"+(?<millisecond>(?:0{0,3}[0-9])|(?:0{0,2}[1-9]{2})|(?:0?[1-9]{3})|(?:1[1-9]{3}))"+x,P+x];R<U.length;R++)for(var k=U[R],j=0,B=[{delimiter:["/","-"," "],pattern:[M+"${delimiter}"+D+"${delimiter}"+A,M+"${delimiter}"+D+" +"+A,A+"${delimiter}"+M+"${delimiter}"+D,A+" +"+M+"${delimiter}"+D,M+"${delimiter}"+D+"${delimiter}"+A+T+"+"+k,M+"${delimiter}"+D+" +"+A+T+"+"+k,k+(T+"+")+M+"${delimiter}"+D+"${delimiter}"+A,k+(T+"+")+M+"${delimiter}"+D+" +"+A,A+"${delimiter}"+M+"${delimiter}"+D+T+"+"+k,A+" +"+M+"${delimiter}"+D+T+"+"+k,k+(T+"+")+A+"${delimiter}"+M+"${delimiter}"+D,k+(T+"+")+A+" +"+M+"${delimiter}"+D]},{delimiter:"\\.",pattern:[D+"${delimiter}"+M+"${delimiter}"+A,D+"${delimiter}"+M+" +"+A,A+"${delimiter}"+D+"${delimiter}"+M,A+" +"+D+"${delimiter}"+M,D+"${delimiter}"+M+"${delimiter}"+A+T+"+"+k,D+"${delimiter}"+M+" +"+A+T+"+"+k,k+(T+"+")+D+"${delimiter}"+M+"${delimiter}"+A,k+(T+"+")+D+"${delimiter}"+M+" +"+A,A+"${delimiter}"+D+"${delimiter}"+M+T+"+"+k,A+" +"+D+"${delimiter}"+M+T+"+"+k,k+(T+"+")+A+"${delimiter}"+D+"${delimiter}"+M,k+(T+"+")+A+" +"+D+"${delimiter}"+M]},{pattern:k}];j<B.length;j++)for(var N,K=B[j],W=u([].concat(Object.prototype.hasOwnProperty.call(K,"delimiter")?K.delimiter:"-"));!(N=W()).done;)for(var F,$=N.value,q=u([].concat(K.pattern));!(F=q()).done;){var z=F.value,V=(0,c.evaluate)("`^"+z+"$`",{delimiter:$+"+"}).result;V&&!Object.prototype.hasOwnProperty.call(I,V)&&(I[V]=!0,l.push(new RegExp(V)))}e=(e=e.toLowerCase()).replace(/([^0-9a-z])[^0-9a-z]+/g,"$1");for(var H=1,G=0,Y=[["jan","january?","janvier"],["feb","february?","février"],["m(?:a|ae|ä)r","m(?:a|ae|ä)r(?:ch|s|z)"],["ap[rv]","a[pv]ril"],["ma[iy]"],["ju[ein]","jui?n[ei]?"],["jul","jul[iy]","juillet"],["aug","august","août"],["sep","septemb(?:er|re)"],["o[ck]t","o[ck]tob(?:er|re)"],["nov","novemb(?:er|re)"],["de[cz]","d[eé][cz]emb(?:er|re)"]];G<Y.length;G++){for(var X,J=!1,Z=u(Y[G]);!(X=Z()).done;){var Q=X.value,ee=new RegExp("(^|[^a-z])"+Q+"([^a-z]|$)");if(ee.test(e)){e=e.replace(ee,"$1"+String(H)+"$2"),J=!0;break}}if(J)break;H+=1}e=m(e);var te=/(.+)\+(.+)$/,re=te.exec(e);re&&(e=e.replace(te,"$1"));for(var ne,oe=u(["","Uhr","o'clock"]);!(ne=oe()).done;){var ae=ne.value;e=e.replace(ae,"")}e=e.trim();for(var ie,_e=function(){var t=ue[ce],n=null;try{n=e.match(t)}catch(e){}if(n){var a,i=function(e,t){return void 0===t&&(t=0),n.groups&&e in n.groups?parseInt(n.groups[e],10):t},_=[i("year",1970),i("month",1)-1,i("day",1),i("hour"),i("minute"),i("second"),i("millisecond")];null!=(a=n.groups)&&a.noonIndicator&&"pm"===n.groups.noonIndicator.trim().replace(/\./g,"")&&_[3]<=12&&(_[3]+=12);var c=null;if(re){var u=d(re[2],!0);u&&(c=new Date(Date.UTC.apply(Date,_)-u.getTime()))}return c||(c=r?new Date(Date.UTC.apply(Date,_)):o()(Date,_)),isNaN(c.getDate())?{v:null}:{v:c}}},ce=0,ue=l;ce<ue.length;ce++)if(ie=_e())return ie.v;return null},f=function(e,t){void 0===e&&(e=null);var r=Boolean(t);if(null===e)return new Date;if("string"==typeof e){if(/^.*(?:(?:[0-9]{1,4}[^0-9]){2}|[0-9]{1,4}[^0-9.]).*$/.test(e))return d(e,r);var n=parseFloat(e);String(n)===e&&(e=n)}if("number"==typeof e){[null,void 0].includes(t)&&(r=!0);var o=new Date(1e3*e);return new Date(1e3*(e+(r?0:60*o.getTimezoneOffset())))}var a=new Date(e);return isNaN(a.getDate())?null:a},m=function(e){var t=/[a-z]{2}\.+ *([^ ].*)$/i;return t.exec(e)?e.replace(t,"$1"):e}},function(e,t,r){function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}r.r(t),r.d(t,{getParameterNames:function(){return a},identity:function(){return i},invertArrayFilter:function(){return _}});var a=function(e){var t=("string"==typeof e?e:e.toString()).replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,"");if(t.startsWith("class"))return a("function "+t.replace(/.*(constructor\([^)]+\))/m,"$1"));var r=/^function\s*[^(]*\(\s*([^)]*)\)/m.exec(t);null===r&&(r=/^[^(]*\(\s*([^)]*)\) *=>.*/m.exec(t)),null===r&&(r=/([^= ]+) *=>.*/m.exec(t));var o=[];if(r&&r.length>1&&r[1].trim().length){for(var i,_=n(r[1].split(","));!(i=_()).done;){var c=i.value;o.push(c.replace(/=.+$/g,"").trim())}return o}return o},i=function(e){return e},_=function(e){return function(t){if(Array.isArray(t)){for(var r=arguments.length,o=new Array(r>1?r-1:0),a=1;a<r;a++)o[a-1]=arguments[a];var i=e.apply(void 0,[t].concat(o)),_=[];if(i.length)for(var c,u=n(t);!(c=u()).done;){var s=c.value;i.includes(s)||_.push(s)}else _=t;return _}return t}}},function(e,t,r){r.d(t,{DEFAULT_OPTIONS:function(){return p},NO_ITEM_FOUND_SYMBOL:function(){return l},SELECTOR_KEY_NAMES:function(){return s},evaluateAnd:function(){return x},evaluateArrayContains:function(){return I},evaluateConcat:function(){return M},evaluateCondition:function(){return h},evaluateIf:function(){return g},evaluateMapping:function(){return A},evaluateOperation:function(){return E},evaluateOptionalThen:function(){return O},evaluateOr:function(){return D},evaluateSelector:function(){return b},evaluateSelectorUntilLastObject:function(){return v},evaluateSwitch:function(){return P},evaluateUnaryOperation:function(){return y},normalizeSelector:function(){return f},selectArrayItem:function(){return m}});var n=r(4),o=r.n(n),a=r(3),i=r(2),_=r(16);function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var s=new Set(["name"]),l=Symbol.for("EXPRESSION_EVALUATOR_NO_ITEM_FOUND"),p={skipMissingLevel:!1,contextReplacements:{},delimiter:"."},d=function(e){for(var t,r=[],n=c(e);!(t=n()).done;){var o=t.value,a=o.indexOf("[");a>0&&r.push(o.substring(0,a)),r.push(o.substring(a+1,o.length-1))}return r},f=function(e,t){void 0===t&&(t={});for(var r,n=o()({},p,{scope:{}},t),i=[],_=c([].concat(e));!(r=_()).done;){var u=r.value;if("string"==typeof u)for(var s,l=c(u.split(n.delimiter));!(s=l()).done;){var m=s.value;if(m)if((0,a.isFunction)(m))i.push(m);else{var v=m.indexOf("["),b=m;if(-1!==v&&(b=m.substring(v),m=m.substring(0,v)),Object.prototype.hasOwnProperty.call(n.contextReplacements,m)?i.push.apply(i,f(n.contextReplacements[m],n)):i.push(m),b!==m){var h=b.match(/[^[]*\[\d+]/g);i.push.apply(i,d(h))}}}else i.push(C(u,n.scope,n))}return i},m=function(e,t){for(var r,n=c(e);!(r=n()).done;)for(var o,a=r.value,i=c(s);!(o=i()).done;){var _=o.value;if(Object.prototype.hasOwnProperty.call(a,_)&&a[_]===t)return a}return l},v=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});for(var n,i=o()({},p,r),_=f(e,o()({},i,{scope:t})),u=t,s=0,d=c(_);!(n=d()).done;){var v=n.value,b=s===_.length-1;if((0,a.isObject)(u))if(Array.isArray(u)&&"string"==typeof v&&isNaN(parseInt(v))){var h=m(u,v);if(h!==l){if(b)return"number"==typeof v?[u,v]:[u,u.indexOf(h)];u=h}}else{if(b)return[u,v];if((0,a.isFunction)(v))u=v(u);else if(Object.prototype.hasOwnProperty.call(u,v))u=u[v];else if(!i.skipMissingLevel)return[u,v]}else{if(b)return[u,v];if(!i.skipMissingLevel)return[u,v]}s+=1}return[{},""]},b=function(e,t,r){void 0===t&&(t={}),void 0===r&&(r={});var n=v(e,t,r),o=n[0],i=n[1];return""===i?t:(0,a.isFunction)(i)?i(o):Object.prototype.hasOwnProperty.call(o,i)?o[i]:void 0},h=function(e,t,r){var n=C(e.value1,t,r),o=C(e.value2,t,r);switch(e.$comparator){case"==":return(0,i.equals)(n,o);case"!=":return!(0,i.equals)(n,o);case"<":return n<o;case"<=":return n<=o;case">":return n>o;case">=":return n>=o}},y=function(e,t,r){var n=C(e.operand,t,r);switch(e.$operator){case"!":return!n;case"!!":return Boolean(n)}},E=function(e,t,r){var n=C(e.operand1,t,r),o=C(e.operand2,t,r);switch(e.$operator){case"+":return n+o;case"-":return n-o;case"*":return n*o;case"**":return Math.pow(n,o);case"/":return n/o}},O=function(e,t,r){if(void 0!==e.then)return C(e.then,t,r)},g=function(e,t,r){return C(e.$if,t,r)?O(e,t,r):void 0===e.else?void 0:C(e.else,t)},P=function(e,t,r){for(var n,o=C(e.$switch,t),a=c(e.caseExpressions);!(n=a()).done;){var i=n.value;if(o===C(i.$case,t,r))return O(i,t,r)}if(void 0!==e.default)return C(e.default,t,r)},x=function(e,t,r){for(var n,o=c(e.$and);!(n=o()).done;)if(!C(n.value,t,r))return!1;return!0},D=function(e,t,r){for(var n,o=c(e.$or);!(n=o()).done;)if(C(n.value,t,r))return!0;return!1},M=function(e,t,r){for(var n,o=[],a=!1,i=c(e.$concat);!(n=i()).done;){var _=C(n.value,t,r);Array.isArray(_)&&(a=!0),o=o.concat(_)}return a?o:o.join("")},A=function(e,t,r){var n=C(e.data,t,r),a=[];if(Array.isArray(n))a=n;else for(var i=0,_=Object.entries(n);i<_.length;i++){var u=_[i],s=u[0],l=u[1];a.push(o()({},l,{$key:s}))}for(var p,d=[],f=c(a);!(p=f()).done;){for(var m=p.value,v={},b=0,h=Object.entries(e.$mapping);b<h.length;b++){var y=h[b],E=y[0],O=y[1];Object.prototype.hasOwnProperty.call(m,E)&&(v[O]=m[E])}d.push(v)}return d},I=function(e,t,r){var n=t;null!=e.$arrayContains.target&&(n=C(e.$arrayContains.target,t,r));var o=C(e.$arrayContains.value,t,r),i=C(e.$arrayContains.key,t,r);return!!Array.isArray(n)&&n.some((function(e){return"string"==typeof i&&(0,a.isPlainObject)(e)&&Object.prototype.hasOwnProperty.call(e,i)?e[i]===o:e===o}))};function C(e,t,r){return void 0===t&&(t={}),void 0===r&&(r={}),(0,_.isSelector)(e)?b(e.$select,t,r):(0,_.isCondition)(e)?h(e,t,r):(0,_.isUnaryOperation)(e)?y(e,t,r):(0,_.isOperation)(e)?E(e,t,r):(0,_.isOrExpression)(e)?D(e,t,r):(0,_.isAndExpression)(e)?x(e,t,r):(0,_.isConcatExpression)(e)?M(e,t,r):(0,_.isMappingExpression)(e)?A(e,t,r):(0,_.isIfExpression)(e)?g(e,t,r):(0,_.isSwitchExpression)(e)?P(e,t,r):(0,_.isArrayContainsExpression)(e)?I(e,t,r):e}t.default=C},function(e,t,r){function n(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return o(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}r.d(t,{viewArrayAsScope:function(){return a},viewObjectAsScope:function(){return i}});var a=function(e,t,r){return new Proxy(e,{ownKeys:function(e){return Reflect.ownKeys(e)},get:function(e,o){for(var a,_=n(e);!(a=_()).done;)for(var c,u=a.value,s=n(r);!(c=s()).done;)if(u[c.value]===o)return i(u,t,r)},set:function(e,t,o){for(var a,i=0,_=n(e);!(a=_()).done;){for(var c,u=a.value,s=n(r);!(c=s()).done;)if(u[c.value]===t)return e[i]=o,!0;i+=1}return!1}})},i=function(e,t,r){return void 0===t&&(t=["children"]),void 0===r&&(r=["name"]),new Proxy(e,{ownKeys:function(e){return Reflect.ownKeys(e)},get:function(e,n){var o=e[n];if(Object.prototype.hasOwnProperty.call(e,n))return t.includes(n)&&Array.isArray(o)?a(o,t,r):null!==o&&"object"==typeof o?i(o,t,r):o},set:function(e,t,r){return!(!Object.prototype.hasOwnProperty.call(e,t)||!Object.prototype.hasOwnProperty.call(e,t)||(e[t]=r,0))}})}},function(e,t,r){r.d(t,{DEFAULT_OPTIONS:function(){return n.DEFAULT_OPTIONS},NO_ITEM_FOUND_SYMBOL:function(){return n.NO_ITEM_FOUND_SYMBOL},SELECTOR_KEY_NAMES:function(){return n.SELECTOR_KEY_NAMES},evaluateAnd:function(){return n.evaluateAnd},evaluateArrayContains:function(){return n.evaluateArrayContains},evaluateConcat:function(){return n.evaluateConcat},evaluateCondition:function(){return n.evaluateCondition},evaluateExpression:function(){return i},evaluateIf:function(){return n.evaluateIf},evaluateMapping:function(){return n.evaluateMapping},evaluateOperation:function(){return n.evaluateOperation},evaluateOptionalThen:function(){return n.evaluateOptionalThen},evaluateOr:function(){return n.evaluateOr},evaluateSelector:function(){return n.evaluateSelector},evaluateSelectorUntilLastObject:function(){return n.evaluateSelectorUntilLastObject},evaluateSwitch:function(){return n.evaluateSwitch},evaluateUnaryOperation:function(){return n.evaluateUnaryOperation},isAndExpression:function(){return a.isAndExpression},isArrayContainsExpression:function(){return a.isArrayContainsExpression},isConcatExpression:function(){return a.isConcatExpression},isCondition:function(){return a.isCondition},isIfExpression:function(){return a.isIfExpression},isMappingExpression:function(){return a.isMappingExpression},isOperation:function(){return a.isOperation},isOrExpression:function(){return a.isOrExpression},isSelector:function(){return a.isSelector},isSpecificExpression:function(){return a.isSpecificExpression},isSwitchExpression:function(){return a.isSwitchExpression},isUnaryOperation:function(){return a.isUnaryOperation},isValue:function(){return a.isValue},normalizeSelector:function(){return n.normalizeSelector},selectArrayItem:function(){return n.selectArrayItem},viewArrayAsScope:function(){return o.viewArrayAsScope},viewObjectAsScope:function(){return o.viewObjectAsScope}});var n=r(22),o=r(23),a=r(16),i=n.default},function(e,t,r){r.d(t,{deleteCookie:function(){return _},getCookie:function(){return c},setCookie:function(){return u}});var n=r(4),o=r.n(n),a=r(1);function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var _=function(e){a.globalContext.document&&(a.globalContext.document.cookie=e+"=; Max-Age=-99999999;")},c=function(e){if(a.globalContext.document){for(var t,r=e+"=",n=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return i(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?i(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(decodeURIComponent(a.globalContext.document.cookie).split(";"));!(t=n()).done;){for(var o=t.value;o.startsWith(" ");)o=o.substring(1);if(o.startsWith(r))return o.substring(r.length,o.length)}return""}return null},u=function(e,t,r){if(void 0===r&&(r={}),a.globalContext.document){var n,i=o()({domain:"",httpOnly:!1,minimal:!1,numberOfDaysUntilExpiration:365,path:"/",sameSite:"Lax",secure:!0},r),_=new Date;return _.setTime(_.getTime()+24*i.numberOfDaysUntilExpiration*60*60*1e3),""===i.domain&&null!=(n=a.globalContext.location)&&n.hostname&&(i.domain=a.globalContext.location.hostname),a.globalContext.document.cookie=e+"="+t+(i.minimal?"":';Expires="'+_.toUTCString()+";Path="+i.path+";Domain="+i.domain+(i.sameSite?";SameSite="+i.sameSite:"")+(i.secure?";Secure":"")+(i.httpOnly?";HttpOnly":"")),!0}return!1}},function(e,t,r){r.d(t,{cacheImage:function(){return d},checkReachability:function(){return l},checkUnreachability:function(){return p}});var n=r(11),o=r.n(n),a=r(12),i=r.n(a),_=r(3),c=r(1),u=r(2),s=r(15),l=function(){var e=o()(i().mark((function e(t,r){var n,a,_,l,p,d,f,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),c.globalContext.fetch){e.next=1;break}throw new Error("Missing fetch implementation available.");case 1:if(a=null!==(n=r.abortController)&&void 0!==n?n:new AbortController,_=(0,u.extend)(!0,{expectedIntermediateStatusCodes:[],options:{signal:a.signal},pollIntervallInSeconds:.1,statusCodes:200,timeoutInSeconds:10,wait:!1},r),l=[].concat(_.statusCodes),p=[].concat(_.expectedIntermediateStatusCodes),d=function(e,t){return"status"in e&&t.includes(e.status)},f=function(e){if(!d(e,l))throw new Error("Given status code "+String(e.status)+" differs from "+l.join(", ")+".");return e},!_.wait){e.next=2;break}return e.abrupt("return",new Promise((function(e,r){var n=!1,u=(0,s.timeout)(1e3*_.timeoutInSeconds),l=function(e){return n||(v=(0,s.timeout)(1e3*_.pollIntervallInSeconds,m)).catch((function(){})),e},m=function(){var n=o()(i().mark((function n(){var o,a,s;return i().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.prev=0,n.next=1,c.globalContext.fetch(t,_.options);case 1:o=n.sent,n.next=3;break;case 2:return n.prev=2,a=n.catch(0),n.abrupt("return",l(a));case 3:n.prev=3,e(f(o)),u.clear(),n.next=6;break;case 4:if(n.prev=4,s=n.catch(3),!d(o,p)){n.next=5;break}return n.abrupt("return",l(s));case 5:r(s),u.clear();case 6:return n.abrupt("return",o);case 7:case"end":return n.stop()}}),n,null,[[0,2],[3,4]])})));return function(){return n.apply(this,arguments)}}(),v=(0,s.timeout)(m);u.then((function(){n=!0,v.clear(),r(new Error("Timeout of "+String(_.timeoutInSeconds)+" seconds reached.")),a.abort()}),(function(){}))})));case 2:return m=f,e.next=3,c.globalContext.fetch(t,_.options);case 3:return e.abrupt("return",m(e.sent));case 4:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),p=function(){var e=o()(i().mark((function e(t,r){var n,a,l,p,d,f,m;return i().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0===r&&(r={}),c.globalContext.fetch){e.next=1;break}throw new Error("Missing fetch implementation available.");case 1:if(a=null!==(n=r.abortController)&&void 0!==n?n:new AbortController,l=(0,u.extend)(!0,{options:{signal:a.signal},pollIntervallInSeconds:.1,statusCodes:[],timeoutInSeconds:10,wait:!1},r),p=function(e){var r=[].concat(l.statusCodes);if(r.length){if((0,_.isObject)(e)&&"status"in e&&r.includes(e.status))throw new Error('Given url "'+t+'" is reachable and responses with status code "'+String(e.status)+'".');return new Error('Given status code is not "'+r.join(", ")+'".')}return null},!l.wait){e.next=2;break}return e.abrupt("return",new Promise((function(e,r){var n=!1,_=function(){var r=o()(i().mark((function r(){var o,a,f;return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=1,c.globalContext.fetch(t,l.options);case 1:if(o=r.sent,!n){r.next=2;break}return r.abrupt("return",o);case 2:if(!(a=p(o))){r.next=3;break}return d.clear(),e(a),r.abrupt("return",a);case 3:(u=(0,s.timeout)(1e3*l.pollIntervallInSeconds,_)).catch((function(){})),r.next=5;break;case 4:return r.prev=4,f=r.catch(0),d.clear(),e(f),r.abrupt("return",f);case 5:return r.abrupt("return",null);case 6:case"end":return r.stop()}}),r,null,[[0,4]])})));return function(){return r.apply(this,arguments)}}(),u=(0,s.timeout)(_),d=(0,s.timeout)(1e3*l.timeoutInSeconds);d.then((function(){n=!0,u.clear(),r(new Error("Timeout of "+String(l.timeoutInSeconds)+" seconds reached.")),a.abort()}),(function(){}))})));case 2:return e.prev=2,f=p,e.next=3,c.globalContext.fetch(t,l.options);case 3:if(!(d=f(e.sent))){e.next=4;break}return e.abrupt("return",d);case 4:e.next=6;break;case 5:return e.prev=5,m=e.catch(2),e.abrupt("return",m);case 6:throw new Error('Given url "'+t+'" is reachable.');case 7:case"end":return e.stop()}}),e,null,[[2,5]])})));return function(t,r){return e.apply(this,arguments)}}(),d=function(e){return new Promise((function(t,r){var n=document.createElement("img");n.onload=function(){var e=n.complete;n.remove(),e?t():r(new Error("Image could not be loaded."))},n.src=e}))}},function(e,t,r){r.d(t,{createDomNodes:function(){return l},fade:function(){return p},fadeIn:function(){return d},fadeOut:function(){return f},getAll:function(){return m},getParents:function(){return v},getText:function(){return b},isEquivalent:function(){return h},isHidden:function(){return y},onDocumentReady:function(){return E},wrap:function(){return O}});var n=r(11),o=r.n(n),a=r(12),i=r.n(a),_=r(1),c=r(15);function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return s(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?s(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var l=function(e){var t=document.createElement("div");return t.innerHTML=e,1===t.childNodes.length?t.childNodes[0].cloneNode(!0):t},p=function(e,t,r){void 0===t&&(t=200),void 0===r&&(r=!0),r?(e.style.visibility="hidden",e.style.opacity="0",e.style.transition="visibility 0s "+String(t)+"ms, opacity "+String(t)+"ms linear"):(e.style.visibility="visible",e.style.opacity="1",e.style.transition="opacity "+String(t)+"ms linear");var n=_.NOOP,o=!1,a=new Promise((function(e){n=function(){o=!0,e()},(0,c.timeout)(t).then(n)}));return a.clear=function(){o||(e.style.transition="none",n())},a},d=function(e,t){return void 0===t&&(t=200),p(e,t,!1)},f=function(e,t){return void 0===t&&(t=200),p(e,t)},m=function(e){for(var t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ALL,null),n=r.currentNode;n;)t.push(n),n=r.nextNode();return t},v=function(e){for(var t=[];null!=(r=e)&&r.parentNode;){var r;t.unshift(e.parentNode),e=e.parentNode}return t},b=function(e,t){if(void 0===t&&(t=!1),e.nodeType===Node.TEXT_NODE){var r,n=null==(r=e.nodeValue)?void 0:r.trim();if(n)return[n]}for(var o,a=[],i=u(e.childNodes);!(o=i()).done;){var _=o.value;(t||_.nodeType===Node.TEXT_NODE)&&a.push.apply(a,b(_))}return a},h=function(e,t,r){if(void 0===r&&(r=!1),e===t)return!0;if(!e||!t)return!1;if(!_.globalContext.document)throw new Error("Missing document in global context.");for(var n=_.globalContext.document.createElement.bind(_.globalContext.document),o=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,a={first:e,second:t},i={first:n("dummy"),second:n("dummy")},c=0,u=Object.entries(a);c<u.length;c++){var s=u[c],p=s[0],d=s[1];if("string"==typeof d)if(r||d.startsWith("<")&&d.endsWith(">")&&d.length>=3||o.test(d))i[p]=l(d);else{var f=document.querySelector(d);if(!f)return!1;i[p]=f.cloneNode(!0)}else{if(!("cloneNode"in d))return!1;i[p]=d.cloneNode(!0)}}return i.first.normalize(),i.second.normalize(),i.first.isEqualNode(i.second)},y=function(e){var t;return!(null!=(t=_.globalContext.document)&&t.contains(e))||"none"===e.style.display||"INPUT"===e.nodeName&&"hidden"===e.getAttribute("type")||["contents","inline"].includes(e.style.display)&&(!("innerHTML"in e)||""===e.innerHTML.trim())||"0px"===e.style.height&&"0px"===e.style.width||Boolean(e.parentElement)&&y(e.parentElement)},E=function(e){return new Promise((function(t){o()(i().mark((function r(){return i().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(!["complete","interactive"].includes(document.readyState)){r.next=2;break}return r.next=1,(0,c.timeout)();case 1:t(),null==e||e(),r.next=3;break;case 2:document.addEventListener("DOMContentLoaded",(function(){t(),null==e||e()}));case 3:case"end":return r.stop()}}),r)})))()}))},O=function(e,t){var r=e.length?Array.from(e):[e],n=r[0];n.parentNode&&n.parentNode.insertBefore(t,n);for(var o,a=u(r);!(o=a()).done;){var i=o.value;t.appendChild(i)}}},function(e,t,r){r.d(t,{getProcessCloseHandler:function(){return o},handleChildProcess:function(){return a}});var n=r(1),o=function(e,t,r,o){void 0===r&&(r=null),void 0===o&&(o=n.NOOP);var a=!1;return function(n){if(a)a=!0;else{a=!0;for(var i=arguments.length,_=new Array(i>1?i-1:0),c=1;c<i;c++)_[c-1]=arguments[c];if("number"!=typeof n||0===n)o(),e({reason:r,parameters:_});else{var u=new Error("Task exited with error code "+String(n));u.returnCode=n,u.parameters=_,t(u)}}}},a=function(e){return e.stdout&&e.stdout.pipe(process.stdout),e.stderr&&e.stderr.pipe(process.stderr),e.on("close",(function(e){0!==e&&console.error("Task exited with error code "+String(e))})),e}},function(e,t,r){r.d(t,{UTILITY_SCOPE:function(){return m},UTILITY_SCOPE_NAMES:function(){return v},UTILITY_SCOPE_VALUES:function(){return b},determineUniqueScopeName:function(){return y},isolateScope:function(){return h}});var n=r(1),o=r(19),a=r(20),i=r(14),_=r(21),c=r(3),u=r(18),s=r(8),l=r(2),p=r(5),d=r(7),f=r(15),m={array:o,datetime:a,filesystem:i,functions:_,indicators:c,logger:u,number:s,object:l,require:p,string:d,utility:f},v=["array","datetime","filesystem","functions","indicators","logger","number","object","require","string","utility"],b=[o,a,i,_,c,u,s,l,p,d,f],h=function(e,t){for(var r in void 0===t&&(t=[]),e)t.includes(r.charAt(0))||["constructor","prototype","this"].includes(r)||Object.prototype.hasOwnProperty.call(e,r)||(e[r]=void 0);return e},y=function(e,t,r,o){if(void 0===e&&(e="callback"),void 0===t&&(t=""),void 0===r&&(r=n.globalContext),void 0===o&&(o=""),o.length&&!(o in r))return o;for(var a=e+t,i=0;i<n.MAXIMAL_NUMBER_OF_ITERATIONS.value&&(a=e+String(Math.round(Math.random()*Math.pow(10,10)))+t)in r;i++);return a}},,function(e,t,r){r.r(t),r.d(t,{ABBREVIATIONS:function(){return i.ABBREVIATIONS},ALLOWED_STARTING_VARIABLE_SYMBOLS:function(){return E.ALLOWED_STARTING_VARIABLE_SYMBOLS},ALLOWED_VARIABLE_SYMBOLS:function(){return E.ALLOWED_VARIABLE_SYMBOLS},ANIMATION_END_EVENT_NAMES:function(){return i.ANIMATION_END_EVENT_NAMES},CLASS_TO_TYPE_MAPPING:function(){return i.CLASS_TO_TYPE_MAPPING},CLI_COLOR:function(){return a.CLI_COLOR},CLOSE_EVENT_NAMES:function(){return i.CLOSE_EVENT_NAMES},CONSOLE_METHODS:function(){return i.CONSOLE_METHODS},DATE_TIME_PATTERN_CACHE:function(){return s.DATE_TIME_PATTERN_CACHE},DEFAULT_ENCODING:function(){return i.DEFAULT_ENCODING},DEFAULT_OPTIONS:function(){return l.DEFAULT_OPTIONS},FIX_ENCODING_ERROR_MAPPING:function(){return E.FIX_ENCODING_ERROR_MAPPING},IGNORE_NULL_AND_UNDEFINED_SYMBOL:function(){return i.IGNORE_NULL_AND_UNDEFINED_SYMBOL},KEYBOARD_CODES:function(){return i.KEYBOARD_CODES},KEY_CODES:function(){return i.KEY_CODES},LEVELS:function(){return O.LEVELS},LEVELS_COLOR:function(){return O.LEVELS_COLOR},LOCALES:function(){return i.LOCALES},Lock:function(){return i.Lock},Logger:function(){return O.Logger},MAXIMAL_NUMBER_OF_ITERATIONS:function(){return _.MAXIMAL_NUMBER_OF_ITERATIONS},NOOP:function(){return _.NOOP},NO_ITEM_FOUND_SYMBOL:function(){return l.NO_ITEM_FOUND_SYMBOL},PLAIN_OBJECT_PROTOTYPES:function(){return i.PLAIN_OBJECT_PROTOTYPES},POLYFILL_TEMPLATES:function(){return E.POLYFILL_TEMPLATES},SELECTOR_KEY_NAMES:function(){return l.SELECTOR_KEY_NAMES},SPECIAL_REGEX_SEQUENCES:function(){return i.SPECIAL_REGEX_SEQUENCES},Semaphore:function(){return i.Semaphore},TRANSITION_END_EVENT_NAMES:function(){return i.TRANSITION_END_EVENT_NAMES},UTILITY_SCOPE:function(){return y.UTILITY_SCOPE},UTILITY_SCOPE_NAMES:function(){return y.UTILITY_SCOPE_NAMES},UTILITY_SCOPE_VALUES:function(){return y.UTILITY_SCOPE_VALUES},VALUE_COPY_SYMBOL:function(){return i.VALUE_COPY_SYMBOL},addDynamicGetterAndSetter:function(){return v.addDynamicGetterAndSetter},addSeparatorToPath:function(){return E.addSeparatorToPath},aggregatePropertyIfEqual:function(){return n.aggregatePropertyIfEqual},cacheImage:function(){return u.cacheImage},camelCaseToDelimited:function(){return E.camelCaseToDelimited},capitalize:function(){return E.capitalize},ceil:function(){return m.ceil},checkReachability:function(){return u.checkReachability},checkUnreachability:function(){return u.checkUnreachability},clearRequireCache:function(){return h.clearRequireCache},compile:function(){return E.compile},compressStyleValue:function(){return E.compressStyleValue},convertCircularObjectToJSON:function(){return v.convertCircularObjectToJSON},convertMapToPlainObject:function(){return v.convertMapToPlainObject},convertPlainObjectToMap:function(){return v.convertPlainObjectToMap},convertSubstringInPlainObject:function(){return v.convertSubstringInPlainObject},convertToValidVariableName:function(){return E.convertToValidVariableName},copy:function(){return v.copy},copyDirectoryRecursive:function(){return p.copyDirectoryRecursive},copyDirectoryRecursiveSync:function(){return p.copyDirectoryRecursiveSync},copyFile:function(){return p.copyFile},copyFileSync:function(){return p.copyFileSync},createDomNodes:function(){return o.createDomNodes},currentImport:function(){return h.currentImport},currentRequire:function(){return h.currentRequire},dateTimeFormat:function(){return s.dateTimeFormat},debounce:function(){return g.debounce},decodeHTMLEntities:function(){return E.decodeHTMLEntities},deleteCookie:function(){return c.deleteCookie},deleteEmptyItems:function(){return n.deleteEmptyItems},delimitedToCamelCase:function(){return E.delimitedToCamelCase},determineGlobalContext:function(){return _.determineGlobalContext},determineType:function(){return v.determineType},determineUniqueScopeName:function(){return y.determineUniqueScopeName},encodeURIComponentExtended:function(){return E.encodeURIComponentExtended},equals:function(){return v.equals},escapeRegularExpressions:function(){return E.escapeRegularExpressions},evaluate:function(){return E.evaluate},evaluateAnd:function(){return l.evaluateAnd},evaluateArrayContains:function(){return l.evaluateArrayContains},evaluateConcat:function(){return l.evaluateConcat},evaluateCondition:function(){return l.evaluateCondition},evaluateDynamicData:function(){return v.evaluateDynamicData},evaluateExpression:function(){return l.evaluateExpression},evaluateIf:function(){return l.evaluateIf},evaluateMapping:function(){return l.evaluateMapping},evaluateOperation:function(){return l.evaluateOperation},evaluateOptionalThen:function(){return l.evaluateOptionalThen},evaluateOr:function(){return l.evaluateOr},evaluateSelector:function(){return l.evaluateSelector},evaluateSelectorUntilLastObject:function(){return l.evaluateSelectorUntilLastObject},evaluateSwitch:function(){return l.evaluateSwitch},evaluateUnaryOperation:function(){return l.evaluateUnaryOperation},extend:function(){return v.extend},extract:function(){return n.extract},extractIfMatches:function(){return n.extractIfMatches},extractIfPropertyExists:function(){return n.extractIfPropertyExists},extractIfPropertyMatches:function(){return n.extractIfPropertyMatches},fade:function(){return o.fade},fadeIn:function(){return o.fadeIn},fadeOut:function(){return o.fadeOut},findNormalizedMatchRange:function(){return E.findNormalizedMatchRange},fixKnownEncodingErrors:function(){return E.fixKnownEncodingErrors},floor:function(){return m.floor},format:function(){return E.format},getAll:function(){return o.getAll},getCookie:function(){return c.getCookie},getDomainName:function(){return E.getDomainName},getEditDistance:function(){return E.getEditDistance},getParameterNames:function(){return d.getParameterNames},getParents:function(){return o.getParents},getPortNumber:function(){return E.getPortNumber},getProcessCloseHandler:function(){return b.getProcessCloseHandler},getProtocolName:function(){return E.getProtocolName},getProxyHandler:function(){return v.getProxyHandler},getText:function(){return o.getText},getURLParameter:function(){return E.getURLParameter},getUTCTimestamp:function(){return m.getUTCTimestamp},globalContext:function(){return _.globalContext},handleChildProcess:function(){return b.handleChildProcess},hasPathPrefix:function(){return E.hasPathPrefix},identity:function(){return d.identity},interpretDateTime:function(){return s.interpretDateTime},intersect:function(){return n.intersect},invertArrayFilter:function(){return d.invertArrayFilter},isAndExpression:function(){return l.isAndExpression},isAnyMatching:function(){return f.isAnyMatching},isArrayContainsExpression:function(){return l.isArrayContainsExpression},isArrayLike:function(){return f.isArrayLike},isConcatExpression:function(){return l.isConcatExpression},isCondition:function(){return l.isCondition},isDirectory:function(){return p.isDirectory},isDirectorySync:function(){return p.isDirectorySync},isEquivalent:function(){return o.isEquivalent},isFile:function(){return p.isFile},isFileSync:function(){return p.isFileSync},isFunction:function(){return f.isFunction},isHidden:function(){return o.isHidden},isIfExpression:function(){return l.isIfExpression},isMap:function(){return f.isMap},isMappingExpression:function(){return l.isMappingExpression},isNotANumber:function(){return m.isNotANumber},isNumeric:function(){return f.isNumeric},isObject:function(){return f.isObject},isOperation:function(){return l.isOperation},isOrExpression:function(){return l.isOrExpression},isPlainObject:function(){return f.isPlainObject},isProxy:function(){return f.isProxy},isSelector:function(){return l.isSelector},isSet:function(){return f.isSet},isSpecificExpression:function(){return l.isSpecificExpression},isSwitchExpression:function(){return l.isSwitchExpression},isUnaryOperation:function(){return l.isUnaryOperation},isValue:function(){return l.isValue},isWindow:function(){return f.isWindow},isolateScope:function(){return y.isolateScope},isolatedRequire:function(){return h.isolatedRequire},limit:function(){return E.limit},lowerCase:function(){return E.lowerCase},makeArray:function(){return n.makeArray},makeRange:function(){return n.makeRange},mark:function(){return E.mark},mask:function(){return v.mask},maskForRegularExpression:function(){return E.maskForRegularExpression},merge:function(){return n.merge},mkdirSync:function(){return p.mkdirSync},mockConsole:function(){return _.mockConsole},modifyObject:function(){return v.modifyObject},normalizeDateTime:function(){return s.normalizeDateTime},normalizeDomNodeSelector:function(){return E.normalizeDomNodeSelector},normalizePhoneNumber:function(){return E.normalizePhoneNumber},normalizeSelector:function(){return l.normalizeSelector},normalizeURL:function(){return E.normalizeURL},normalizeZipCode:function(){return E.normalizeZipCode},onDocumentReady:function(){return o.onDocumentReady},optionalRequire:function(){return h.optionalRequire},paginate:function(){return n.paginate},parseEncodedObject:function(){return E.parseEncodedObject},permute:function(){return n.permute},permuteLength:function(){return n.permuteLength},preventDefault:function(){return g.preventDefault},readFileSync:function(){return p.readFileSync},readdirSync:function(){return p.readdirSync},removeArrayItem:function(){return n.removeArrayItem},removeKeyPrefixes:function(){return v.removeKeyPrefixes},removeKeysInEvaluation:function(){return v.removeKeysInEvaluation},represent:function(){return v.represent},representPhoneNumber:function(){return E.representPhoneNumber},representURL:function(){return E.representURL},round:function(){return m.round},selectArrayItem:function(){return l.selectArrayItem},serviceURLEquals:function(){return E.serviceURLEquals},setCookie:function(){return c.setCookie},setGlobalContext:function(){return _.setGlobalContext},sliceAllExceptNumberAndLastSeparator:function(){return E.sliceAllExceptNumberAndLastSeparator},sliceWeekday:function(){return s.sliceWeekday},sort:function(){return v.sort},sortTopological:function(){return n.sortTopological},statSync:function(){return p.statSync},stopPropagation:function(){return g.stopPropagation},sumUpProperty:function(){return n.sumUpProperty},timeout:function(){return g.timeout},unique:function(){return n.unique},unwrapProxy:function(){return v.unwrapProxy},viewArrayAsScope:function(){return l.viewArrayAsScope},viewObjectAsScope:function(){return l.viewObjectAsScope},walkDirectoryRecursively:function(){return p.walkDirectoryRecursively},walkDirectoryRecursivelySync:function(){return p.walkDirectoryRecursivelySync},wrap:function(){return o.wrap},writeFileSync:function(){return p.writeFileSync}});var n=r(19),o=r(27),a=r(17),i=r(0),_=r(1),c=r(25),u=r(26),s=r(20),l=r(24),p=r(14),d=r(21),f=r(3),m=r(8),v=r(2),b=r(28),h=r(5),y=r(29),E=r(7),O=r(18),g=r(15)}],__webpack_module_cache__={};function __nested_webpack_require_120035__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](r,r.exports,__nested_webpack_require_120035__),r.loaded=!0,r.exports}__nested_webpack_require_120035__.c=__webpack_module_cache__,__nested_webpack_require_120035__.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return __nested_webpack_require_120035__.d(t,{a:t}),t},__nested_webpack_require_120035__.d=function(e,t){for(var r in t)__nested_webpack_require_120035__.o(t,r)&&!__nested_webpack_require_120035__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__nested_webpack_require_120035__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__nested_webpack_require_120035__.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},__nested_webpack_require_120035__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__nested_webpack_require_120035__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __nested_webpack_exports__=__nested_webpack_require_120035__(31);return __nested_webpack_exports__}()},module.exports=r(__nested_webpack_require_3485__(6),__nested_webpack_require_3485__(11),__nested_webpack_require_3485__(17),__nested_webpack_require_3485__(15))},function(e){function t(){return e.exports=t=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},e.exports.__esModule=!0,e.exports.default=e.exports,t.apply(null,arguments)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(2),o=r(0),a=r(12),i=r(3),_=r(4),c=r(13),u=r(14);function s(){"use strict";var t=o(),r=t.m(s),l=(Object.getPrototypeOf?Object.getPrototypeOf(r):r.__proto__).constructor;function p(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===l||"GeneratorFunction"===(t.displayName||t.name))}var d={throw:1,return:2,break:3,continue:3};function f(e){var t,r;return function(n){t||(t={stop:function(){return r(n.a,2)},catch:function(){return n.v},abrupt:function(e,t){return r(n.a,d[e],t)},delegateYield:function(e,o,a){return t.resultName=o,r(n.d,u(e),a)},finish:function(e){return r(n.f,e)}},r=function(e,r,o){n.p=t.prev,n.n=t.next;try{return e(r,o)}finally{t.next=n.n}}),t.resultName&&(t[t.resultName]=n.v,t.resultName=void 0),t.sent=n.v,t.next=n.n;try{return e.call(this,t)}finally{n.p=t.prev,n.n=t.next}}}return(e.exports=s=function(){return{wrap:function(e,r,n,o){return t.w(f(e),r,n,o&&o.reverse())},isGeneratorFunction:p,mark:t.m,awrap:function(e,t){return new n(e,t)},AsyncIterator:_,async:function(e,t,r,n,o){return(p(t)?i:a)(f(e),t,r,n,o)},keys:c,values:u}},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=s,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(r){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(r){}return(e.exports=t=function(){return!!r},e.exports.__esModule=!0,e.exports.default=e.exports)()}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(r,n){return e.exports=t=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},e.exports.__esModule=!0,e.exports.default=e.exports,t(r,n)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e){function t(e,t,r,n,o,a,i){try{var _=e[a](i),c=_.value}catch(e){return void r(e)}_.done?t(c):Promise.resolve(c).then(n,o)}e.exports=function(e){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=e.apply(r,n);function _(e){t(i,o,a,_,c,"next",e)}function c(e){t(i,o,a,_,c,"throw",e)}_(void 0)}))}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(3);e.exports=function(e,t,r,o,a){var i=n(e,t,r,o,a);return i.next().then((function(e){return e.done?e.value:i.next()}))},e.exports.__esModule=!0,e.exports.default=e.exports},function(e){e.exports=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(8).default;e.exports=function(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(n(e)+" is not iterable")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){var n=r(9),o=r(10);e.exports=function(e,t,r){if(n())return Reflect.construct.apply(null,arguments);var a=[null];a.push.apply(a,t);var i=new(e.bind.apply(e,a));return r&&o(i,r.prototype),i},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,t,r){"use strict";r.r(t),r.d(t,{authorize:function(){return p},databaseHelper:function(){return f},default:function(){return m},log:function(){return l},validateDocumentUpdate:function(){return d}});var n=r(5),o=JSON.parse('{"fz":{"Z":{"ge":{"MZ":{"U":{"i0":{"additional":"_additional","role":"_roles","attachment":"_attachments","conflict":"_conflicts","constraint":{"execution":"_constraintExecutions","expression":"_constraintExpressions"},"create":{"execution":"_createExecution","expression":"_createExecution"},"deleted":"_deleted","deletedConflict":"_deleted_conflicts","designDocumentNamePrefix":"_design/","extend":"_extends","id":"_id","localSequence":"_local_seq","maximumAggregatedSize":"_maximumAggregatedSize","minimumAggregatedSize":"_minimumAggregatedSize","oldType":"_oldType","revision":"_rev","revisions":"_revisions","revisionsInformation":"_revs_info","updateStrategy":"_updateStrategy","ignoreIfNoOldDocument":"_ignoreIfNoOldDocument","type":"-type","update":{"execution":"_updateExecution","expression":"_updateExpression"}}}}}}}}');function a(e,t,r){if(_())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var o=new(e.bind.apply(e,n));return r&&i(o,r.prototype),o}function i(e,t){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},i(e,t)}function _(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_=function(){return!!e})()}function c(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return u(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function s(){return s=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},s.apply(null,arguments)}e=r.hmd(e);var l=new n.Logger({name:"web-node.couchdb.database"}),p=function(e,t,r,n,a,i,_,u,l,d,f){var m,v,b;void 0===t&&(t=null),void 0===r&&(r={}),void 0===n&&(n={admins:{names:[],roles:[]},members:{names:[],roles:[]}}),void 0===i&&(i=!1),void 0===_&&(_=o.fz.Z.ge.MZ.U.i0),void 0===u&&(u=[]),void 0===l&&(l=[]);var h,y,E=function(e,t,r){var n;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),s(((n={})[t]=e,n.error=t,n.message=e,n.name=t,n),r)};d?h=d:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?h=function(e){return JSON.stringify(e,null,4)}:E("Needed json serializer is not available."),f?y=f:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"parse")?y=function(e){return JSON.parse(e)}:E("Needed json parser is not available.");var O=function(e){return y(h(e))},g=_,P=g.id,x=g.type,D=g.attachment,M=g.designDocumentNamePrefix,A=g.deleted,I=null!==(m=e[x])&&void 0!==m?m:t&&t[x];if(!I)return!0;var C,w=i?"read":"write",T={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};Object.prototype.hasOwnProperty.call(e,P)&&e[P].startsWith(M)&&!T.read.includes("readonlymember")||T.read.push("readonlymember"),"name"in r||(r.name='"unknown"');var L=[],S="You are trying to "+w+' object of type "'+I+'".';if(null!=(v=r.roles)&&v.length){var R,U,k=O(T),j=r.roles,B=k[w];if(a&&I&&Object.prototype.hasOwnProperty.call(a,I)){var N=function(e){for(var t,r=c(["read","write"]);!(t=r()).done;){var n=t.value;e[n]=e[n].concat(T[n])}return e};if((k=N(O(a[I]))).attachments)for(var K=0,W=Object.values(k.attachments);K<W.length;K++)N(W[K]);for(var F=0,$=Object.values(k.properties);F<$.length;F++)N($[F]);B=k[w]}else l.length&&(B=l);for(var q=function(e,t){void 0===t&&(t={}),L=Object.prototype.hasOwnProperty.call(t,e)?t[e][w]:B;for(var r,n=c(j);!(r=n()).done;){var o=r.value;if(L.includes(o))return!0}return!1},z=e[A]?null!==(R=t)&&void 0!==R?R:{}:e,V=!0,H=0,G=Object.entries(z);H<G.length;H++){var Y=G[H],X=Y[0],J=Y[1],Z=u.concat(X);if(S="You are trying to "+w+' property "'+Z.join(".")+'" of object having type "'+I+'".',V=!1,X===D){V=!0;for(var Q=0,ee=Object.keys(J);Q<ee.length;Q++){var te=ee[Q],re=Z.concat(te);if(S="You are trying to "+w+' file on property "'+re.join(".")+'" of object having type "'+I+'".',!(V=q(te,k.attachments)))break}}else q(X,k.properties)&&(null!==J&&"object"==typeof J&&Object.prototype.hasOwnProperty.call(J,x)&&p(J,t&&t[X]||null,r,n,a,i,_,Z,Object.prototype.hasOwnProperty.call(k.properties,X)?k.properties[X][w]:B),V=!0);if(!V)break}if(V)return!0;C='Current user "'+(null!==(U=r.name)&&void 0!==U?U:"unknown")+'" owns the following roles: "'+r.roles.join('", "')+'"'}else C='Current user "'+(null!==(b=r.name)&&void 0!==b?b:"unknown")+"\" doesn't own any role";var ne=S+" Only users with a least one of these roles are allowed to perform requested "+w+' action: "'+[].concat(L).join('", "')+'". '+C+".";throw{unauthorized:ne,error:"unauthorized",message:ne,name:"unauthorized"}},d=function(e,t,r,o,i,_,u,p,d){void 0===_&&(_={}),void 0===u&&(u=!0),l.debug("Got new document",e,"to update",t);var f=function(e,t,r){var n;throw void 0===t&&(t="forbidden"),void 0===r&&(r={}),s(((n={})[t]=e,n.error=t,n.message=e,n.name=t,n),r)},m=new Date,v=Date.UTC(m.getUTCFullYear(),m.getUTCMonth(),m.getUTCDate(),m.getUTCHours(),m.getUTCMinutes(),m.getUTCSeconds(),m.getUTCMilliseconds())/1e3,b=!i.dateTimeFormat.startsWith("iso"),h=i.property.name.special,y=h.id,E=h.revision,O=h.type;t&&t[O]&&!e[O]&&(e[O]=t[O]);var g="",P="",x=function(){g=Object.prototype.hasOwnProperty.call(e,y)?e[y]:"",P=Object.prototype.hasOwnProperty.call(e,E)?e[E]:""};if(x(),Object.prototype.hasOwnProperty.call(o,i.property.name.validatedDocumentsCache)&&o[i.property.name.validatedDocumentsCache].has(g+"-"+P))return o[i.property.name.validatedDocumentsCache].delete(g+"-"+P),e;["0-latest","0-upsert"].includes(P)&&(t&&Object.prototype.hasOwnProperty.call(t,E)?P=e[E]=t[E]:"0-latest"===P?f("Revision: No old document available to update."):delete e[E]);var D,M,A={};if("migrate"===i.updateStrategy)for(var I=0,C=Object.entries(_);I<C.length;I++){var w=C[I],T=w[0],L=w[1];if(Object.prototype.hasOwnProperty.call(L,h.oldType)&&L[h.oldType])for(var S,R=c([].concat(L[h.oldType]));!(S=R()).done;){var U=S.value;A[U]=T}}p?D=p:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"stringify")?D=function(e){return JSON.stringify(e,null,4)}:f("Needed json serializer is not available."),d?M=d:"undefined"!=typeof JSON&&Object.prototype.hasOwnProperty.call(JSON,"parse")?M=function(e){return JSON.parse(e)}:f("Needed json parser is not available.");var k=[h.additional,h.role,h.constraint.execution,h.constraint.expression,h.create.execution,h.create.expression,h.extend,h.maximumAggregatedSize,h.minimumAggregatedSize,h.oldType,h.update.execution,h.update.expression,h.updateStrategy,h.ignoreIfNoOldDocument],j=function(e){return M(D(e))},B=j(e),N=function(e){return"string"==typeof e?e.trim():""},K=function(e,t,r){void 0===t&&(t=!1),void 0===r&&(r={});var n=s({},G,{code:""},r);n.scope=n;var o=N(e);if(o){var i=(t?"return ":"")+o;n.code=i;var _,c=Object.keys(n);try{_=a(Function,c.concat([i]))}catch(e){f(q(e),"compilation",{code:i,error:e,scope:n})}var u={code:i,result:void 0,scope:n};try{u.result=_.apply(void 0,c.map((function(e){return n[e]})))}catch(e){f(q(e),"runtime",{code:i,error:e,scope:n})}return u}return f("No expression to evaluate provided.","empty"),{code:n.code,result:void 0,scope:n}},W=function(e,t,r){if(r.fileName){if(r.fileName.value)return r.fileName.value===t;if(r.fileName.pattern)return[].concat(r.fileName.pattern).some((function(e){return new RegExp(e).test(t)}))}return e===t},F=function(t,r){if(r||(r=e[h.attachment]),t)for(var n=0,o=Object.keys(r);n<o.length;n++){var a=o[n];if(a.startsWith(t))return a}else{var i=Object.keys(r);if(i.length)return i[0]}return null},$=function(e){if(b)null!==e&&"number"!=typeof e&&(e=new Date(e),e=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds())/1e3);else if(null!==e){e=new Date("number"!=typeof e||isNaN(e)?e:1e3*e);try{e=e.toISOString()}catch(e){}}return e},q=function(e){return e instanceof Error?String(e):D(e)},z=function(t,r){return void 0===r&&(r=e),Object.prototype.hasOwnProperty.call(r,t)&&![null,void 0].includes(r[t])},V=function(e,t){void 0===t&&(t=null),Object.prototype.hasOwnProperty.call(e,O)||(t&&Object.prototype.hasOwnProperty.call(t,O)&&["fillUp","migrate"].includes(i.updateStrategy)?e[O]=t[O]:f('Type: You have to specify a model type via property "'+O+'".')),u&&!new RegExp(i.property.name.typePattern.public).test(e[O])&&f('TypeName: You have to specify a model type which matches "'+i.property.name.typePattern.public+'" as public type (given "'+e[O]+'").'),Object.prototype.hasOwnProperty.call(_,e[O])||(Object.prototype.hasOwnProperty.call(A,e[O])?e[O]=A[e[O]]:f('Model: Given model "'+e[O]+'" is not specified.'))},H=function(r,n,o,u,s,p,d){void 0===r&&(r=e),void 0===n&&(n=null),void 0===s&&(s=[]),void 0===p&&(p=i.updateStrategy),void 0===d&&(d=!1);var m=s.length?' in "'+s.join('" -> "')+'"':"",v=[];Object.prototype.hasOwnProperty.call(u,h.updateStrategy)&&(p=u[h.updateStrategy]),Object.prototype.hasOwnProperty.call(e,h.updateStrategy)&&(p=r[h.updateStrategy],delete r[h.updateStrategy]),Object.prototype.hasOwnProperty.call(e,h.ignoreIfNoOldDocument)&&(d=r[h.ignoreIfNoOldDocument],delete r[h.ignoreIfNoOldDocument]),d&&!t&&f("NoChange: No old data given to an update request. A deletion might happened before due to a race condition. Update will be ignored.");var g=void 0;Object.prototype.hasOwnProperty.call(u,h.additional)&&u[h.additional]&&(g=u[h.additional]);var P=function(e,t,i,_,l){void 0===l&&(l=["constraintExecution","constraintExpression"]);for(var v,b=i.updateStrategy||p,h=c(l);!(v=h()).done;){var y=v.value;if(Object.prototype.hasOwnProperty.call(i,y)){var E=void 0;try{E=K(i[y].evaluation,y.endsWith("Expression"),{checkPropertyContent:D,model:u,modelName:o,name:t,type:y,newDocument:r,newValue:e,oldDocument:n,oldValue:_,parentNames:s,pathDescription:m,propertyDefinition:i,updateStrategy:b,ignoreIfNoOldDocument:d})}catch(e){var O,g;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+y+'" has invalid code "'+e.code+'": "'+(null!==(O=e.message)&&void 0!==O?O:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+y+'" has throw an error with code "'+e.code+'": "'+(null!==(g=e.message)&&void 0!==g?g:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(E&&!E.result){var P,x=N(null==(P=i[y])?void 0:P.description);f(y.charAt(0).toUpperCase()+(y.substring(1)+": ")+(x?a(Function,Object.keys(E.scope).concat(["return "+x])).apply(void 0,Object.values(E.scope)):'Property "'+t+'" should satisfy constraint "'+E.code+'" (given "'+q(e)+'")'+m+"."))}}}},D=function(e,t,r,n){for(var o,a=r.updateStrategy||p,i=[],u=[].concat(r.type?r.type:[]),d=!1,v=!1,h=c(u);!(o=h()).done;){var E=o.value;if("string"==typeof E&&Object.prototype.hasOwnProperty.call(_,E)||"object"==typeof E){var O="string"==typeof E?E:"in-place";if("object"==typeof e&&Object.getPrototypeOf(e)===Object.prototype){var g=void 0;try{g=H(e,n,O,"string"==typeof E?_[E]:E,s.concat(t),a)}catch(r){var x,D=null!==(x=null==r?void 0:r.message)&&void 0!==x?x:"unknown";1===u.length?f('NestedType: Under key "'+t+'" isn\'t of type "'+O+'" (given "'+q(e)+'" of type '+typeof e+') Issue is "'+D+'"'+m+"."):l.debug('Tried to match "'+q(e)+'"','with type "'+O+'". Got error:','"'+D+'"')}if(g){if(g.changedPath.length&&(i=g.changedPath),e=g.newDocument,q(e)===q({}))return{newValue:void 0,changedPath:i};d=!0,v=!0;break}}else 1===u.length&&f('NestedType: Under key "'+t+'" isn\'t of type "'+O+'" (given "'+q(e)+'" of type '+typeof e+")"+m+".")}else if("DateTime"===E){var M=e;if(e=$(e),!(b&&("number"!=typeof e||isNaN(e))||!b&&"string"!=typeof e)){v=!0;break}1===u.length&&f('PropertyType: Property "'+t+'" isn\'t of (valid) type "DateTime" (given "'+q(M).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof M+'")'+m+".")}else if("string"==typeof E&&["boolean","integer","number","string"].includes(E)){if(!("number"==typeof e&&isNaN(e)||"integer"!==E&&typeof e!==E||"integer"===E&&parseInt(e,10)!==e)){v=!0;break}1===u.length&&f('PropertyType: Property "'+t+'" isn\'t of (valid) type "'+E+'" (given "'+q(e)+'" of type "'+typeof e+'")'+m+".")}else if("string"==typeof E&&E.startsWith("foreignKey:")){var A=_[E.substring(11)][y].type;if(A===typeof e){v=!0;break}1===u.length&&f('PropertyType: Foreign key property "'+t+'" isn\'t of type "'+A+'" (given "'+q(e)+'" of type "'+typeof e+'")'+m+".")}else{if("any"===E||q(e)===q(E)){v=!0;break}1===u.length&&f('PropertyType: Property "'+t+'" isn\'t value "'+String(E)+'" (given "'+q(e).replace(/^"/,"").replace(/"$/,"")+'" of type "'+typeof e+'")'+m+".")}}if(v||f('PropertyType: None of the specified types "'+u.map((function(e){return"string"==typeof e?e:"in-place"})).join('", "')+'" for property "'+t+'" matches value "'+q(e).replace(/^"/,"").replace(/"$/,"")+e+'" of type "'+typeof e+'"'+m+"."),"string"==typeof e&&("number"==typeof r.minimumLength&&e.length<r.minimumLength&&f('MinimalLength: Property "'+t+'" must have minimal length '+r.minimumLength+" (given "+e+" with length "+String(e.length)+")"+m+"."),"number"==typeof r.maximumLength&&e.length>r.maximumLength&&f('MaximalLength: Property "'+t+'" must have maximal length '+r.maximumLength+" (given "+e+" with length "+String(e.length)+")"+m+".")),"number"==typeof e&&("number"==typeof r.minimum&&e<r.minimum&&f('Minimum: Property "'+t+'" (type '+[].concat(r.type).join(" or ")+") must satisfy a minimum of "+r.minimum+" (given "+String(e)+" is too low)"+m+"."),"number"==typeof r.maximum&&e>r.maximum&&f('Maximum: Property "'+t+'" (type '+[].concat(r.type).join(" or ")+") must satisfy a maximum of "+r.maximum+" (given "+String(e)+" is too high)"+m+".")),r.selection){var I=Array.isArray(r.selection)?r.selection.map((function(e){return void 0===(null==e?void 0:e.value)?e:e.value})):Object.keys(r.selection);"DateTime"===r.type&&(I=I.map($)),I.includes(e)||f('Selection: Property "'+t+'" (type '+[].concat(r.type).join(" or ")+') should be one of "'+I.join('", "')+'". But is "'+e+'"'+m+".")}if(r.pattern){for(var C,w=[].concat(r.pattern),T=!1,L=c(w);!(C=L()).done;){var S=C.value;if(new RegExp(S).test(e)){T=!0;break}}T||f('PatternMatch: Property "'+t+'" should match regular expression pattern "'+w.join('", "')+'" (given "'+e+'")'+m+".")}if(r.invertedPattern)for(var R,U=c([].concat(r.invertedPattern));!(R=U()).done;){var k=R.value;new RegExp(k).test(e)&&f('InvertedPatternMatch: Property "'+t+'" should not match regular expression pattern '+String(k)+' (given "'+String(e)+'")'+m+".")}return P(e,t,r,n),d||r.preventVersionCreation&&"migrate"!==p||q(e)===q(n)||(i=s.concat(t,"value updated")),{newValue:e,changedPath:i}},M=function(e,t,r,n,o){var a=e.updateStrategy||p,_=t[n];if(!e.writable)if(r){if(Object.prototype.hasOwnProperty.call(r,n)&&q(_)===q(r[n]))return n!==y&&"incremental"===a&&delete t[n],!0;f("Readonly: Property "+String(n)+'" isnot writable (old document "'+q(r)+'")'+o+".")}else f('Readonly: Property "'+String(n)+'" is not writable'+o+".");if(!e.mutable&&r&&Object.prototype.hasOwnProperty.call(r,n)){if(q(_)===q(r[n]))return"incremental"!==a||i.property.name.reserved.concat(h.deleted,y,E).includes(String(n))||delete t[n],!0;"migrate"!==a&&f('Immutable: Property "'+String(n)+'" is not writable. Trying to update from "'+String(r[n])+'" to "'+String(_)+'" (old document "'+q(r)+'")'+o+".")}if(null===_){if(e.nullable)return"incremental"===a&&r&&void 0!==r[n]||delete t[n],r&&Object.prototype.hasOwnProperty.call(r,n)&&(v=s.concat(String(n),"delete property")),!0;f('NotNull: Property "'+String(n)+'" should not be "null"'+o+".")}return!1},A=function(e,t,r,n,a){var i=e.updateStrategy||p;if(!r||!(Object.prototype.hasOwnProperty.call(r,n)||Object.prototype.hasOwnProperty.call(t,n)||e.nullable||Object.prototype.hasOwnProperty.call(e,"default")))for(var _,l=c(["createExecution","createExpression"]);!(_=l()).done;){var v=_.value;if(Object.prototype.hasOwnProperty.call(e,v)){var b=void 0;try{b=K(e[v],v.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:D,model:u,modelName:o,name:String(n),type:v,newDocument:t,oldDocument:r,newValue:void 0,oldValue:void 0,parentNames:s,pathDescription:m,propertyDefinition:e,updateStrategy:i,ignoreIfNoOldDocument:d})}catch(e){var h,y;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+v+'" has invalid code "'+e.code+'" for property "'+String(n)+'": "'+(null!==(h=e.message)&&void 0!==h?h:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+v+'" has throw an error with code "'+e.code+'" for property "'+String(n)+'": "'+(null!==(y=e.message)&&void 0!==y?y:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}b&&![null,void 0].includes(b.result)&&(a?a[n]=b.result:t[n]=b.result)}}},I=function(e,t,r,n,a){var i=e.updateStrategy||p;if(!a){if(!e.runUpdateHookAlways&&!Object.prototype.hasOwnProperty.call(t,n))return;e.trim&&"string"==typeof t[n]&&(t[n]=t[n].trim()),e.emptyEqualsNull&&(""===t[n]||Array.isArray(t[n])&&0===t[n].length||null!==t[n]&&"object"==typeof t[n]&&0===Object.keys(t).length)&&(t[n]=null)}for(var _,l=c(["updateExecution","updateExpression"]);!(_=l()).done;){var v=_.value;if(Object.prototype.hasOwnProperty.call(e,v))try{var b=K(e[v],v.endsWith("Expression"),{attachmentsTarget:a,checkPropertyContent:D,model:u,modelName:o,name:String(n),type:v,newDocument:t,oldDocument:r,newValue:t[n],oldValue:r&&r[n],parentNames:s,pathDescription:m,propertyDefinition:e,updateStrategy:i,ignoreIfNoOldDocument:d});a?a[n]=b.result:void 0!==b.result&&(t[n]=b.result)}catch(e){var h,y;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+v+'" has invalid code "'+e.code+'" for property "'+String(n)+'": "'+(null!==(h=e.message)&&void 0!==h?h:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+v+'" has throw an error with code "'+e.code+'" for property "'+String(n)+'": "'+(null!==(y=e.message)&&void 0!==y?y:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}}},C=Object.keys(u).filter((function(e){return!k.includes(e)}));if("migrate"===p)for(var w,T=c(C);!(w=T()).done;){var L=w.value;if(u[L].oldName)for(var S,R=c([].concat(u[L].oldName));!(S=R()).done;){var U=S.value;Object.prototype.hasOwnProperty.call(r,U)&&(r[L]=r[U],delete r[U])}}if(!n)for(var j=0,B=[h.create.execution,h.create.expression];j<B.length;j++){var F=B[j];if(Object.prototype.hasOwnProperty.call(u,F)){var G=void 0;try{G=K(u[F],F.endsWith("Expression"),{checkPropertyContent:D,model:u,modelName:o,type:F,newDocument:r,oldDocument:n,parentNames:s,pathDescription:m,updateStrategy:p,ignoreIfNoOldDocument:d}).result}catch(e){var Y,X;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+F+'" has invalid code "'+e.code+'" for document "'+o+'": "'+(null!==(Y=e.message)&&void 0!==Y?Y:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+F+'" has throw an error with code "'+e.code+'" for document "'+o+'": "'+(null!==(X=e.message)&&void 0!==X?X:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[null,void 0].includes(G)||(r=G),0===s.length&&(V(r,n),o=r[O],x())}}for(var J=0,Z=[h.update.execution,h.update.expression];J<Z.length;J++){var Q=Z[J];if(Object.prototype.hasOwnProperty.call(u,Q)){var ee=void 0;try{ee=K(u[Q],Q.endsWith("Expression"),{checkPropertyContent:D,model:u,modelName:o,type:Q,newDocument:r,oldDocument:n,parentNames:s,pathDescription:m,updateStrategy:p,ignoreIfNoOldDocument:d}).result}catch(e){var te,re;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+Q+'" has invalid code "'+e.code+'" for document "'+o+'": "'+(null!==(te=e.message)&&void 0!==te?te:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+Q+'" has throw an error with code "'+e.code+'" for document "'+o+'": "'+(null!==(re=e.message)&&void 0!==re?re:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}[void 0,null].includes(ee)||(r=ee),0===s.length&&(V(r,n),o=r[O],x())}}for(var ne,oe=g?Object.keys(r).filter((function(e){return!C.includes(e)})):[],ae=c(C.concat(oe));!(ne=ae()).done;){var ie=ne.value;if(h.attachment===ie)for(var _e=function(){var e=ue[ce],t=e[0],o=e[1];r[h.attachment]||(r[h.attachment]={}),n&&!Object.prototype.hasOwnProperty.call(n,ie)&&(n[h.attachment]={});var a=r[h.attachment],i=Object.keys(a).filter((function(e){return null!==a[e].data&&W(t,e,o)})),_=[];if(n){var u=n[ie];_=Object.keys(u).filter((function(e){return!(Object.prototype.hasOwnProperty.call(a,e)&&Object.prototype.hasOwnProperty.call(a[e],"data")&&null===a[e].data)&&Boolean(u[e])&&(Object.prototype.hasOwnProperty.call(u[e],"data")&&null!==u[e].data||Object.prototype.hasOwnProperty.call(u[e],"stub")&&Boolean(u[e].digest))&&W(t,e,o)}))}var l=o;p=l.updateStrategy||p;for(var d,b=c(i);!(d=b()).done;){var y=d.value;A(l,r,n&&n[ie]?n[ie]:null,y,a)}for(var E,O=c(i);!(E=O()).done;){var g=E.value;I(l,r,n&&n[ie]?n[ie]:null,g,a)}if(void 0===l.default){if(l.nullable||i.length>0||_.length>0||f('AttachmentMissing: Missing attachment for type "'+t+'"'+m+"."),"fillUp"===p&&0===i.length&&_.length>0)for(var P,x=c(_);!(P=x()).done;){var D=P.value;null===a[D]?v=s.concat(ie,D,"file removed"):a[D]=n[ie][D]}}else if(0===i.length)if(0===_.length)for(var M in l.default)Object.prototype.hasOwnProperty.call(l.default,M)&&(a[M]=l.default[M],v=s.concat(ie,t,"add default file"));else if("fillUp"===p)for(var C,w=c(_);!(C=w()).done;){var T=C.value;a[T]=n[ie][T]}},ce=0,ue=Object.entries(u[h.attachment]);ce<ue.length;ce++)_e();else{var se=C.includes(ie)?u[ie]:g;p=se.updateStrategy||p,A(se,r,n,ie),I(se,r,n,ie),[null,void 0].includes(se.default)?(se.nullable||Object.prototype.hasOwnProperty.call(r,ie)&&void 0!==r[ie]||n&&Object.prototype.hasOwnProperty.call(n,ie)&&"replace"!==p||s.length>0&&ie===O||f('MissingProperty: Missing property "'+String(ie)+'"'+m+"."),Object.prototype.hasOwnProperty.call(r,ie)&&void 0!==r[ie]||!n||!Object.prototype.hasOwnProperty.call(n,ie)||("fillUp"===p?r[ie]=n[ie]:"replace"===p&&(v=s.concat(String(ie),"property removed")))):z(ie,r)||(n?null!==r[ie]&&"fillUp"===p?r[ie]=n[ie]:"migrate"===p&&(r[ie]=se.default,v=s.concat(String(ie),"migrate default value")):(r[ie]=se.default,v=v.concat(String(ie),"add default value")))}}if(n&&"incremental"===p)for(var le=0,pe=Object.entries(r);le<pe.length;le++){var de=pe[le],fe=de[0],me=de[1];!Object.prototype.hasOwnProperty.call(n,fe)||i.property.name.reserved.concat(y,E,h.conflict,h.deleted,h.deletedConflict,h.localSequence,h.revisions,h.revisionsInformation,O).includes(fe)||n[fe]!==me&&q(n[fe])!==q(me)||delete r[fe]}for(var ve=0,be=Object.entries(r);ve<be.length;ve++){var he=be[ve],ye=he[0],Ee=he[1];if(!i.property.name.reserved.concat(E,h.conflict,h.deleted,h.deletedConflict,h.localSequence,h.revisions,h.revisionsInformation,h.updateStrategy).includes(ye)){if(s.length>0&&ye===O){delete r[ye];continue}var Oe=void 0;if(Object.prototype.hasOwnProperty.call(u,ye))Oe=u[ye];else if(g)Oe=g;else{if("migrate"===p){delete r[ye],v=s.concat(String(ye),"migrate removed property");continue}f('Property: Given property "'+String(ye)+'" isn\'t specified in model "'+o+'"'+m+".")}if(!Oe)continue;if(h.attachment===ye){var ge=Ee;for(var Pe in ge)if(Object.prototype.hasOwnProperty.call(ge,Pe))for(var xe=0,De=Object.keys(u[ye]);xe<De.length;xe++){var Me=De[xe],Ae=u[h.attachment][Me];if(W(Me,Pe,Ae)){M(Ae,r,n,Pe,m);break}}continue}if(M(Oe,r,n,ye,m))continue;var Ie="string"==typeof Oe.type&&Oe.type.endsWith("[]")||Array.isArray(Oe.type)&&Oe.type.length&&Array.isArray(Oe.type[0]);if(Ie&&![null,void 0].includes(Ee)){var Ce=Ee;Array.isArray(Ce)?"number"==typeof Oe.minimumNumber&&Ce.length<Oe.minimumNumber?f('MinimumArrayLength: Property "'+String(ye)+'" (array of length '+String(Ce.length)+") doesn't fulfill minimum array length of "+Oe.minimumNumber+m+"."):"number"==typeof Oe.maximumNumber&&Oe.maximumNumber<Ce.length&&f('MaximumArrayLength: Property "'+String(ye)+'" (array of length '+String(Ce.length)+") doesn't fulfill maximum array length of "+Oe.maximumNumber+m+"."):f('PropertyType: Property "'+String(ye)+'" isn\'t of type "array -> '+Oe.type+'" (given"'+q(Ce)+'")'+m+"."),P(Ce,String(ye),Oe,n&&Object.prototype.hasOwnProperty.call(n,ye)&&n[ye]||void 0,["arrayConstraintExecution","arrayConstraintExpression"]);var we={};for(var Te in Oe)if(Object.prototype.hasOwnProperty.call(Oe,Te))if("type"===Te){var Le=Oe[Te];Array.isArray(Oe[Te])?we[Te]=Le[0]:we[Te]=[Le.substring(0,Le.length-2)]}else we[Te]=Oe[Te];for(var Se,Re=0,Ue=c(Ce.slice());!(Se=Ue()).done;){var ke=Se.value;Ce[Re]=D(ke,String(Re+1)+'. value in "'+String(ye)+'"',we,void 0).newValue,[null,void 0].includes(Ce[Re])&&Ce.splice(Re,1),Re+=1}Oe.preventVersionCreation&&"migrate"!==p||n&&Object.prototype.hasOwnProperty.call(n,ye)&&Array.isArray(n[ye])&&n[ye].length===Ce.length&&q(n[ye])===q(Ce)||(v=s.concat(String(ye),"array updated"))}else{var je=n&&Object.prototype.hasOwnProperty.call(n,ye)?n[ye]:void 0,Be=Ie?{newValue:null,changedPath:[]}:D(Ee,String(ye),Oe,je);r[ye]=Be.newValue,Be.changedPath.length&&(v=Be.changedPath),null===r[ye]&&(void 0===je?"fillUp"===p&&delete r[ye]:v=s.concat(String(ye),"property removed")),void 0===r[ye]&&delete r[ye]}}}for(var Ne=0,Ke=Object.keys(h.constraint);Ne<Ke.length;Ne++){var We=Ke[Ne],Fe=h.constraint[We];if(Object.prototype.hasOwnProperty.call(u,Fe))for(var $e,qe=u[Fe],ze=c([].concat(qe));!($e=ze()).done;){var Ve=$e.value,He=void 0;try{He=K(Ve.evaluation,Fe===h.constraint.expression,{checkPropertyContent:D,model:u,modelName:o,type:Fe,newDocument:r,oldDocument:n,parentNames:s,pathDescription:m,updateStrategy:p,ignoreIfNoOldDocument:d})}catch(e){var Ge,Ye;if(function(e){return Object.prototype.hasOwnProperty.call(e,"compilation")}(e)&&f('Compilation: Hook "'+Fe+'" has invalid code "'+e.code+'": "'+(null!==(Ge=e.message)&&void 0!==Ge?Ge:"unknown")+'"'+m+"."),function(e){return Object.prototype.hasOwnProperty.call(e,"runtime")}(e)&&f('Runtime: Hook "'+Fe+'" has thrown an error with code "'+e.code+'": "'+(null!==(Ye=e.message)&&void 0!==Ye?Ye:"unknown")+'"'+m+"."),!Object.prototype.hasOwnProperty.call(e,"empty"))throw e}if(He&&!He.result){var Xe=Fe.replace(/^[^a-zA-Z]+/,"");f(Xe.charAt(0).toUpperCase()+(Xe.substring(1)+": ")+(Ve.description?a(Function,Object.keys(He.scope).concat(["return "+Ve.description.trim()])).apply(void 0,Object.values(He.scope)):'Model "'+o+'" should satisfy constraint "'+He.code+'" (given "'+q(r)+'")'+m+"."))}}}if(Object.prototype.hasOwnProperty.call(r,h.attachment)){var Je,Ze,Qe=u[h.attachment],et=r[h.attachment];"object"==typeof et&&Object.getPrototypeOf(et)===Object.prototype||f("AttachmentType: given attachment has invalid type"+m+".");var tt=null;if(n&&Object.prototype.hasOwnProperty.call(n,h.attachment)&&null!==(tt=n[h.attachment])&&"object"==typeof tt)for(var rt=0,nt=Object.entries(tt);rt<nt.length;rt++){var ot=nt[rt],at=ot[0],it=ot[1];if(it&&Object.prototype.hasOwnProperty.call(et,at)){var _t=et[at];null===_t||null===_t.data||_t.content_type===it.content_type&&(_t.data===it.data||_t.digest===it.digest)?(null!==_t&&null!==_t.data||(v=s.concat(h.attachment,at,"attachment removed")),"incremental"===p&&delete et[at]):v=s.concat(h.attachment,at,"attachment updated")}else"fillUp"===p?et[at]=it:"replace"===p&&(v=s.concat(h.attachment,at,"attachment removed"))}for(var ct=0,ut=Object.entries(et);ct<ut.length;ct++){var st,lt=ut[ct],pt=lt[0],dt=lt[1];if(!dt)break;null===dt.data?delete et[pt]:tt&&Object.prototype.hasOwnProperty.call(tt,pt)&&dt.content_type===(null==(st=tt[pt])?void 0:st.content_type)&&(dt.data===tt[pt].data||dt.digest===tt[pt].digest)||(v=s.concat(h.attachment,pt,"attachment updated"))}0===Object.keys(et).length&&delete r[h.attachment];for(var ft={},mt=0,vt=Object.keys(Qe);mt<vt.length;mt++)ft[vt[mt]]=[];for(var bt=0,ht=Object.keys(et);bt<ht.length;bt++){for(var yt=ht[bt],Et=!1,Ot=0,gt=Object.entries(Qe);Ot<gt.length;Ot++){var Pt=gt[Ot],xt=Pt[0],Dt=Pt[1];if(W(xt,yt,Dt)){ft[xt].push(yt),Et=!0;break}}Et||f('AttachmentTypeMatch: None of the specified attachment types ("'+Object.keys(Qe).join('", "')+'") matches given one ("'+yt+'")'+m+".")}for(var Mt=0,At=0,It=Object.keys(ft);At<It.length;At++){var Ct=It[At],wt=Qe[Ct];if(Object.prototype.hasOwnProperty.call(ft,Ct)){var Tt=ft[Ct].length;"number"==typeof wt.maximumNumber&&Tt>wt.maximumNumber&&f("AttachmentMaximum: given number of attachments ("+String(Tt)+") doesn't satisfy specified maximum of "+String(wt.maximumNumber)+' from type "'+Ct+'"'+m+"."),(!wt.nullable||0!==Tt)&&"number"==typeof wt.minimumNumber&&Tt<wt.minimumNumber&&f("AttachmentMinimum: given number of attachments ("+String(Tt)+") doesn't satisfy specified minimum of "+String(wt.minimumNumber)+' from type "'+Ct+'"'+m+".");for(var Lt,St=0,Rt=c(ft[Ct]);!(Lt=Rt()).done;){var Ut,kt,jt,Bt=Lt.value;if(null!=(Ut=wt.fileName)&&Ut.pattern){for(var Nt,Kt=[].concat(wt.fileName.pattern),Wt=!1,Ft=c(Kt);!(Nt=Ft()).done;){var $t=Nt.value;if(new RegExp($t).test(Bt)){Wt=!0;break}}Wt||f('AttachmentName: given attachment name "'+Bt+'" doesn\'t satisfy one of specified regular expression patterns "'+Kt.join('", "')+'" from type "'+Ct+'"'+m+".")}if(null!=(kt=wt.fileName)&&kt.invertedPattern)for(var qt,zt=c([].concat(wt.fileName.invertedPattern));!(qt=zt()).done;){var Vt=qt.value;new RegExp(Vt).test(Bt)&&f('InvertedAttachmentName: given attachment name "'+Bt+'" does satisfy specified regular expression pattern "'+Vt.toString()+'" from type "'+Ct+'"'+m+".")}if(null!=(jt=et[Bt])&&jt.content_type){if(wt.contentTypePattern){for(var Ht,Gt=[].concat(wt.contentTypePattern),Yt=!1,Xt=c(Gt);!(Ht=Xt()).done;){var Jt=Ht.value;if(new RegExp(Jt).test(et[Bt].content_type)){Yt=!0;break}}Yt||f('AttachmentContentType: given attachment content type "'+et[Bt].content_type+'" doesn\'t satisfy specified regular expression pattern "'+Gt.join('", "')+'" from type "'+Ct+'"'+m+".")}var Zt=wt.invertedContentTypePattern;if(Zt)for(var Qt,er=c([].concat(Zt));!(Qt=er()).done;){var tr=Qt.value;new RegExp(tr).test(et[Bt].content_type)&&f('InvertedAttachmentContentType: given attachment content type "'+et[Bt].content_type+'" does satisfy specified regular expression pattern "'+tr.toString()+'" from type "'+Ct+'"'+m+".")}}var rr=0;et[Bt]&&"length"in et[Bt]?rr=et[Bt].length:et[Bt]&&"data"in et[Bt]&&(rr="undefined"!=typeof Buffer&&"byteLength"in Buffer?Buffer.byteLength(et[Bt].data,"base64"):et[Bt].data.length),"number"==typeof wt.minimumSize&&wt.minimumSize>rr?f("AttachmentMinimumSize: given attachment size "+String(rr)+" byte doesn't satisfy specified minimum of "+String(wt.minimumSize)+" byte"+m+"."):"number"==typeof wt.maximumSize&&wt.maximumSize<rr&&f("AttachmentMaximumSize: given attachment size "+String(rr)+" byte doesn't satisfy specified maximum of "+String(wt.maximumSize)+" byte"+m+"."),St+=rr}"number"==typeof wt.minimumAggregatedSize&&wt.minimumAggregatedSize>St?f('AttachmentAggregatedMinimumSize: given aggregated size of attachments from type "'+Ct+'" '+String(St)+" byte doesn't satisfy specified minimum of "+String(wt.minimumAggregatedSize)+" byte"+m+"."):"number"==typeof wt.maximumAggregatedSize&&wt.maximumAggregatedSize<St&&f('AttachmentAggregatedMaximumSize: given aggregated size of attachments from type "'+Ct+'" '+String(St)+" byte doesn't satisfy specified maximum of "+String(wt.maximumAggregatedSize)+" byte"+m+"."),Mt+=St}}(null!==(Je=u[h.minimumAggregatedSize])&&void 0!==Je?Je:0)>Mt?f("AggregatedMinimumSize: given aggregated size "+String(Mt)+" byte doesn't satisfy specified minimum of "+String(u[h.minimumAggregatedSize])+" byte"+m+"."):(null!==(Ze=u[h.maximumAggregatedSize])&&void 0!==Ze?Ze:1/0)<Mt&&f("AggregatedMaximumSize: given aggregated size "+String(Mt)+" byte doesn't satisfy specified maximum of "+String(u[h.maximumAggregatedSize])+" byte"+m+".")}if(n&&Object.prototype.hasOwnProperty.call(n,h.attachment)&&0===Object.keys(n[h.attachment]).length&&delete n[h.attachment],n){if(g&&"fillUp"===(g.updateStrategy||p))for(var nr=0,or=Object.keys(n);nr<or.length;nr++){var ar=or[nr];Object.prototype.hasOwnProperty.call(r,ar)||(r[ar]=n[ar])}if(0===v.length&&"migrate"===p)for(var ir=0,_r=Object.keys(n);ir<_r.length;ir++){var cr=_r[ir];Object.prototype.hasOwnProperty.call(r,cr)||(v=s.concat(cr,"migrate removed property"))}}return{changedPath:v,newDocument:r}},G={attachmentWithPrefixExists:function(t,r){if(void 0===r&&(r=e),Object.prototype.hasOwnProperty.call(r,h.attachment)){var n=r[h.attachment],o=F(t);if(o){var a=n[o];return Object.prototype.hasOwnProperty.call(a,"stub")&&a.stub||Object.prototype.hasOwnProperty.call(a,"data")&&![null,void 0].includes(a.data)}}return!1},checkDocument:H,deepCopy:j,getDateTime:function(e){return"number"==typeof e?new Date(1e3*e):new Date(e)},getEffectiveValue:function(e,r,n){return void 0===r&&(r=B),void 0===n&&(n=t),Object.prototype.hasOwnProperty.call(r,e)?r[e]:n&&Object.prototype.hasOwnProperty.call(n,e)?n[e]:null},getFileNameByPrefix:F,isDefinedPropertyValue:z,require:n.currentRequire,serialize:q,id:g,revision:P,idName:y,revisionName:E,specialNames:h,typeName:O,modelConfiguration:i,models:_,now:m,nowUTCTimestamp:v,securitySettings:o,userContext:r,originalNewDocument:B},Y=e[h.attachment];if(e[h.attachment])for(var X=0,J=Object.values(Y);X<J.length;X++){var Z=J[X];null!=Z&&Z.contentType&&(Z.content_type=Z.contentType,delete Z.contentType)}V(e,t);var Q=e[O],ee=_[Q],te=H(e,t,Q,ee);return(te.newDocument._deleted&&!t||!(te.newDocument._deleted&&te.newDocument._deleted!==(null==t?void 0:t._deleted)||te.changedPath.length))&&f("NoChange: No new data given. New document: "+q(e)+"; old document: "+q(t)+"."),Object.prototype.hasOwnProperty.call(o,i.property.name.validatedDocumentsCache)?o[i.property.name.validatedDocumentsCache].add(g+"-"+P):o[i.property.name.validatedDocumentsCache]=new Set([g+"-"+P]),l.debug('Document has changes in "'+te.changedPath.join(".")+'".'),l.debug("Determined new document:",te.newDocument),te.newDocument},f=e.exports,m=f},function(e,t,r){var n=r(7)();e.exports=n;try{regeneratorRuntime=n}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=n:Function("r","regeneratorRuntime = r")(n)}}],__webpack_module_cache__={};function __nested_webpack_require_173540__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e].call(r.exports,r,r.exports,__nested_webpack_require_173540__),r.loaded=!0,r.exports}__nested_webpack_require_173540__.d=function(e,t){for(var r in t)__nested_webpack_require_173540__.o(t,r)&&!__nested_webpack_require_173540__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__nested_webpack_require_173540__.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),__nested_webpack_require_173540__.hmd=function(e){return(e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:function(){throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e},__nested_webpack_require_173540__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__nested_webpack_require_173540__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},__nested_webpack_require_173540__.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e};var __nested_webpack_exports__=__nested_webpack_require_173540__(16);module.exports=__nested_webpack_exports__})()},(module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{database:()=>database,default:()=>__WEBPACK_DEFAULT_EXPORT__,loadService:()=>loadService,postLoadService:()=>postLoadService,preLoadService:()=>preLoadService,shouldExit:()=>shouldExit});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),clientnode__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_3__),fs__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(7),fs__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_4__),path__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(8),path__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_5__),pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(9),pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_6__),pouchdb_find__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(10),pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(pouchdb_find__WEBPACK_IMPORTED_MODULE_7__),pouchdb_node__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(11),pouchdb_node__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(pouchdb_node__WEBPACK_IMPORTED_MODULE_8__),pouchdb_validation__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(12),pouchdb_validation__WEBPACK_IMPORTED_MODULE_9___default=__webpack_require__.n(pouchdb_validation__WEBPACK_IMPORTED_MODULE_9__),_databaseHelper__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(5),_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_10__),_helper__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(0),_server__WEBPACK_IMPORTED_MODULE_12__=__webpack_require__(19);function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}module=__webpack_require__.hmd(module);var preLoadService=function(){var _ref2=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee(_ref){var configuration,services,couchdb,triedPaths,runnerFound,_iterator,_step,runner,inPlaceRunner,_iterator2,_step2,name,binaryRunner,_iterator3,_step3,directoryPath,_iterator4,_step4,_name,binaryFilePath,backendConnectorConfiguration,modelConfiguration,models,_t;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context){for(;;)switch(_context.prev=_context.next){case 0:if(configuration=_ref.configuration.couchdb,services=_ref.services,Object.prototype.hasOwnProperty.call(services,"couchdb")||(services.couchdb={}),couchdb=services.couchdb,Object.prototype.hasOwnProperty.call(couchdb,"server")){_context.next=19;break}couchdb.server={},triedPaths=[],runnerFound=!1,_iterator=_createForOfIteratorHelperLoose([].concat(configuration.runner.variants));case 1:if((_step=_iterator()).done){_context.next=18;break}if(runner=_step.value,!runner.packages){_context.next=9;break}inPlaceRunner=runner,runnerFound=!0,_iterator2=_createForOfIteratorHelperLoose(inPlaceRunner.packages);case 2:if((_step2=_iterator2()).done){_context.next=7;break}return name=_step2.value,_context.prev=3,_context.next=4,eval("import('"+name+"')");case 4:_context.next=6;break;case 5:return _context.prev=5,_t=_context.catch(3),runnerFound=!1,_context.abrupt("continue",7);case 6:_context.next=2;break;case 7:if(!runnerFound){_context.next=8;break}return couchdb.server.runner=inPlaceRunner,_context.abrupt("continue",18);case 8:return _context.abrupt("continue",17);case 9:binaryRunner=runner,_iterator3=_createForOfIteratorHelperLoose([].concat(binaryRunner.locations));case 10:if((_step3=_iterator3()).done){_context.next=16;break}directoryPath=_step3.value,_iterator4=_createForOfIteratorHelperLoose([].concat(binaryRunner.names));case 11:if((_step4=_iterator4()).done){_context.next=14;break}return _name=_step4.value,binaryFilePath=(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(directoryPath,_name),triedPaths.push(binaryFilePath),_context.next=12,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(binaryFilePath);case 12:if(!_context.sent){_context.next=13;break}return binaryRunner.binaryFilePath=binaryFilePath,couchdb.server.runner=binaryRunner,runnerFound=!0,_context.abrupt("continue",14);case 13:_context.next=11;break;case 14:if(!runnerFound){_context.next=15;break}return _context.abrupt("continue",16);case 15:_context.next=10;break;case 16:if(!runnerFound){_context.next=17;break}return _context.abrupt("continue",18);case 17:_context.next=1;break;case 18:runnerFound||_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("No couchdb runner found via files in one of the following",'locations: "'+triedPaths.join('", "')+'". Running pouchdb',"locally.");case 19:Object.prototype.hasOwnProperty.call(couchdb,"connector")||(backendConnectorConfiguration=couchdb.server.runner.configuration.values&&couchdb.server.runner.configuration.values["couchdb/database_dir"]?{prefix:(0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(String(couchdb.server.runner.configuration.values["couchdb/database_dir"]))+"/"}:couchdb.server.runner.configuration,couchdb.backendConnector=pouchdb_node__WEBPACK_IMPORTED_MODULE_8___default().plugin(pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_6___default()).plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_7___default()).plugin(pouchdb_validation__WEBPACK_IMPORTED_MODULE_9___default()).plugin((0,_helper__WEBPACK_IMPORTED_MODULE_11__.getPouchDBPlugin)(configuration)).defaults(backendConnectorConfiguration),couchdb.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_8___default().defaults((0,_helper__WEBPACK_IMPORTED_MODULE_11__.getConnectorOptions)(configuration.connector)),configuration.debug&&couchdb.connector.debug.enable("*")),modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.model),delete modelConfiguration.property.defaultDefinition,delete modelConfiguration.entities,models=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.applyModelsInheritance)(configuration.model),couchdb.validateDocument=function(e,t){var r,n=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(null!==(r=t.oldDocument)&&void 0!==r?r:e),o=Boolean(t.checkPublicModelType);(e=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(e))[configuration.model.property.name.special.updateStrategy]="migrate",t.type&&(e[modelConfiguration.property.name.special.type]=n[modelConfiguration.property.name.special.type]=t.type);try{return(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.validateDocumentUpdate)(e,n,{db:configuration.databaseName,name:configuration.admin.name,roles:["_admin"]},(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.security[configuration.databaseName]),modelConfiguration,models,o),!0}catch(e){return!(!Object.prototype.hasOwnProperty.call(e,"forbidden")||!e.forbidden.startsWith("NoChange:"))||e}};case 20:case"end":return _context.stop()}}),_callee,null,[[3,5]])})));return function(e){return _ref2.apply(this,arguments)}}(),loadService=function(){var _ref3=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee4(state){var configuration,services,specialNames,idName,revisionName,typeName,promise,couchdb,_determineForeignKeySelectors,_i4,_Object$entries4,_Object$entries4$_i,modelName,model,foreignKeySelectors,_data,urlPrefix,authorizationHeader,headers,createAdminUser,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,userDatabaseConnection,_iterator6,_step6,_step6$value,name,password,roles,_userDatabaseConnecti,runner,_iterator7,_step7,prefix,_i8,_Object$entries6,_Object$entries6$_i,subPath,value,fullPath,url,response,changeNeeded,_yield$globalContext$,givenAuthorizationHeaders,_authorizationHeader,securityConfigurations,_i9,_Object$entries7,_Object$entries7$_i,databaseName,securityObject,fullSecurityObject,_fullSecurityObject$a,_fullSecurityObject$a2,_fullSecurityObject$m,_fullSecurityObject$m2,_response,modelConfiguration,models,databaseHelperCode,_iterator8,_step8,_type,code,_i0,_Object$entries8,_Object$entries8$_i,_modelName2,_model,_i1,_Object$entries9,_Object$entries9$_i,_name2,specification,_iterator9,_step9,constraint,_iterator0,_step0,type,_constraint,migrators,_iterator1,_step1,file,extension,_name3,documents,_iterator10,_step10,document,_forbidden,_iterator11,_step11,retrievedDocument,_document,newDocument,_iterator12,_step12,_name4,_result,result,genericIndexes,_i10,_Object$entries0,_Object$entries0$_i,_modelName3,_model2,_iterator13,_step13,propertyName,_name5,found,_iterator14,_step14,index,_t4,_t5,_t6,_t7,_t8,_t9,_t0,_t1,_t10,_t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22,_t23;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:if(clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch){_context5.next=1;break}throw new Error("Missing fetch implementation.");case 1:for(configuration=state.configuration,services=state.services,specialNames=configuration.couchdb.model.property.name.special,idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type,promise=null,couchdb=services.couchdb,couchdb.reinitializeMaterializedViews=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(){var t,r,n,o,a,i,_,c,u,s,l,p,d,f;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=0,r=Object.entries(configuration.couchdb.materializedViews);case 1:if(!(t<r.length)){e.next=7;break}o=r[t],a=o[0],i=o[1],(n={})[specialNames.type]=a,n[specialNames.id]=a,_=n,c=0,u=Object.entries(i);case 2:if(!(c<u.length)){e.next=5;break}return s=u[c],l=s[0],p=s[1],e.next=3,couchdb.connection.find(p.query);case 3:d=e.sent,p.initialMapperExpression?(f=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.evaluate)(p.initialMapperExpression,{data:d.docs})).error?_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn('Could not execute initial expression "'+p.initialMapperExpression+'" for property "'+l+'" in view document','"'+a+'":',f.error):_[l]=f.result:_[l]=d.docs;case 4:c++,e.next=2;break;case 5:return _helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Initialize view "+a+":",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_)),e.next=6,couchdb.connection.put(_);case 6:t++,e.next=1;break;case 7:case"end":return e.stop()}}),e)}))),couchdb.foreignKeys={static:{},runtime:{}},_determineForeignKeySelectors=function(e,t){void 0===t&&(t=[]);for(var r=[],n=0,o=Object.entries(e);n<o.length;n++){var a=o[n],i=a[0],_=a[1];if("string"==typeof _.type){if(Object.prototype.hasOwnProperty.call(configuration.couchdb.model.entities,_.type))r=r.concat(_determineForeignKeySelectors(configuration.couchdb.model.entities[_.type],t.concat(i)));else if(_.type.startsWith("foreignKey:")){var c=_.type.substring(11);c.endsWith("[]")&&(c=c.substring(0,c.length-2)),r.push({targetModelName:c,propertySelector:t.concat(i)})}}else(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(_.type)&&(r=r.concat(_determineForeignKeySelectors(_.type,t.concat(i))))}return r},_i4=0,_Object$entries4=Object.entries(configuration.couchdb.model.entities);_i4<_Object$entries4.length;_i4++)_Object$entries4$_i=_Object$entries4[_i4],modelName=_Object$entries4$_i[0],model=_Object$entries4$_i[1],foreignKeySelectors=_determineForeignKeySelectors(model),foreignKeySelectors.length>0&&(couchdb.foreignKeys.static[modelName]=foreignKeySelectors);if(couchdb.removeDanglingForeignKeys=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(){var t,r,n,o,a,i,_,c,u,s,l,p,d,f,m,v,b,h,y,E,O,g,P,x;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:couchdb.foreignKeys.runtime={},t=function(e,t,r){Array.isArray(couchdb.foreignKeys.runtime[e])?couchdb.foreignKeys.runtime[e].push({propertySelector:t.split("."),id:r}):couchdb.foreignKeys.runtime[e]=[{propertySelector:t.split("."),id:r}]},r=0,n=Object.entries(couchdb.foreignKeys.static);case 1:if(!(r<n.length)){e.next=16;break}return a=n[r],i=a[0],_=a[1],c=_.map((function(e){return e.propertySelector.join(".")})),u={selector:{$and:[(o={},o[typeName]=i,o),{$or:c.map((function(e){var t;return(t={})[e]={$exists:!0},t}))}]},fields:[idName].concat(c)},s=0,e.next=2,couchdb.connection.find(u);case 2:l=e.sent.docs;case 3:if(!(s<l.length)){e.next=15;break}p=l[s],d=_createForOfIteratorHelperLoose(c);case 4:if((f=d()).done){e.next=14;break}if(v=f.value,b=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.evaluateSelectorUntilLastObject)(v,p),h=b[0],y=b[1],O=h[E=y]){e.next=5;break}return e.abrupt("continue",13);case 5:if(!Array.isArray(O)){e.next=9;break}g=_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(){var r,n;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=x[P],e.next=1,couchdb.connection.find({selector:(r={},r[idName]=n,r)});case 1:if(0!==e.sent.docs.length){e.next=3;break}return _helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Found dangling document reference","("+n+") in document",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(p)+" of type",'"'+i+'" in array of property','"'+v+'". Removing the reference.'),h[E]=O.filter((function(e){return e!==n})),e.next=2,couchdb.connection.put(p);case 2:e.next=4;break;case 3:t(n,v,p[idName]);case 4:case"end":return e.stop()}}),e)})),P=0,x=O;case 6:if(!(P<x.length)){e.next=8;break}return e.delegateYield(g(),"t0",7);case 7:P++,e.next=6;break;case 8:e.next=13;break;case 9:return e.next=10,couchdb.connection.find({selector:(m={},m[idName]=O,m)});case 10:if(0!==e.sent.docs.length){e.next=12;break}return _helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Found dangling document reference","("+O+") in document",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(p)+" of type",'"'+i+'" in property "'+v+'".',"Removing the reference."),h[E]=null,e.next=11,couchdb.connection.put(p);case 11:e.next=13;break;case 12:t(O,v,p[idName]);case 13:e.next=4;break;case 14:s++,e.next=3;break;case 15:r++,e.next=1;break;case 16:case"end":return e.stop()}}),e)}))),!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context5.next=3;break}return _context5.next=2,(0,_server__WEBPACK_IMPORTED_MODULE_12__.ni)(state,null==(_data=state.data)?void 0:_data.couchdbWebNodeExpressUtilities);case 2:couchdb.server.restart=_server__WEBPACK_IMPORTED_MODULE_12__.S8,couchdb.server.start=_server__WEBPACK_IMPORTED_MODULE_12__.ni,couchdb.server.stop=_server__WEBPACK_IMPORTED_MODULE_12__.ds,promise=new Promise((function(e,t){couchdb.server.resolve=e,couchdb.server.reject=t}));case 3:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context5.next=4;break}return _context5.abrupt("return",{couchdb:promise});case 4:if(urlPrefix=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.getEffectiveURL)(configuration.couchdb,!1),authorizationHeader={Authorization:"Basic "+Buffer.from(configuration.couchdb.admin.name+":"+configuration.couchdb.admin.password,"binary").toString("base64")},headers={Accept:"application/json","Content-Type":"application/json"},!configuration.couchdb.ensureAdminPresence){_context5.next=19;break}return createAdminUser=function(){if(_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("No admin user available. Automatically creating admin user",'"'+configuration.couchdb.admin.name+'".'),!clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch)throw new Error("Missing fetch implementation.");return clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+couchdb.server.runner.adminUserConfigurationPath+"/"+configuration.couchdb.admin.name,{body:'"'+configuration.couchdb.admin.password+'"',method:"PUT"})},unauthenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",(0,_helper__WEBPACK_IMPORTED_MODULE_11__.getConnectorOptions)(configuration.couchdb.connector)),_context5.prev=5,_context5.next=6,unauthenticatedUserDatabaseConnection.allDocs({limit:1});case 6:return _context5.next=7,createAdminUser();case 7:_context5.next=11;break;case 8:if(_context5.prev=8,_t4=_context5.catch(5),"unauthorized"===_t4.name){_context5.next=11;break}if("not_found"!==_t4.name){_context5.next=10;break}return _context5.next=9,createAdminUser();case 9:_context5.next=11;break;case 10:_helper__WEBPACK_IMPORTED_MODULE_11__.log.error("Can't check for admin user or create a new one:",'"'+configuration.couchdb.admin.name+'":',(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t4));case 11:return _context5.prev=11,_context5.next=12,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.waitWithTimeout)(unauthenticatedUserDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"unauthenticated user database client connection to close");case 12:return _context5.finish(11);case 13:return authenticatedUserDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},(0,_helper__WEBPACK_IMPORTED_MODULE_11__.getConnectorOptions)(configuration.couchdb.connector),{auth:{username:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}})),_context5.prev=14,_context5.next=15,authenticatedUserDatabaseConnection.allDocs({limit:1});case 15:_context5.next=17;break;case 16:_context5.prev=16,_t5=_context5.catch(14),_helper__WEBPACK_IMPORTED_MODULE_11__.log.error("Can't login as admin user",'"'+configuration.couchdb.admin.name+'":',(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t5));case 17:return _context5.prev=17,_context5.next=18,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.waitWithTimeout)(authenticatedUserDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"authenticated user database client connection to close");case 18:return _context5.finish(17);case 19:if(!configuration.couchdb.ensureUserPresence){_context5.next=32;break}userDatabaseConnection=new couchdb.connector(urlPrefix+"/_users",_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},(0,_helper__WEBPACK_IMPORTED_MODULE_11__.getConnectorOptions)(configuration.couchdb.connector),{auth:{username:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}})),_iterator6=_createForOfIteratorHelperLoose(configuration.couchdb.users);case 20:if((_step6=_iterator6()).done){_context5.next=32;break}return _step6$value=_step6.value,name=_step6$value.name,password=_step6$value.password,roles=_step6$value.roles,_context5.prev=21,_context5.next=22,userDatabaseConnection.get("org.couchdb.user:"+name);case 22:_context5.next=29;break;case 23:if(_context5.prev=23,_t6=_context5.catch(21),"not_found"!==_t6.name){_context5.next=28;break}return _helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Create missing database user "'+name+'".'),_context5.prev=24,_context5.next=25,userDatabaseConnection.put((_userDatabaseConnecti={},_userDatabaseConnecti[configuration.couchdb.model.property.name.special.id]="org.couchdb.user:"+name,_userDatabaseConnecti.name=name,_userDatabaseConnecti.password=password,_userDatabaseConnecti.roles=roles,_userDatabaseConnecti.type="user",_userDatabaseConnecti));case 25:_context5.next=27;break;case 26:throw _context5.prev=26,_t7=_context5.catch(24),new Error("Couldn't create missing user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t7),{cause:_t7});case 27:_context5.next=29;break;case 28:throw new Error("Couldn't check for presence of user \""+name+'": '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t6),{cause:_t6});case 29:return _context5.prev=29,_context5.next=30,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.waitWithTimeout)(userDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"user database client connection to close");case 30:return _context5.finish(29);case 31:_context5.next=20;break;case 32:if(!configuration.couchdb.model.updateConfiguration||Object.prototype.hasOwnProperty.call(couchdb.server.runner,"packages")){_context5.next=52;break}runner=couchdb.server.runner,_iterator7=_createForOfIteratorHelperLoose(runner.configuration.prefixes);case 33:if((_step7=_iterator7()).done){_context5.next=52;break}prefix=_step7.value,_i8=0,_Object$entries6=Object.entries(runner.configuration.values);case 34:if(!(_i8<_Object$entries6.length)){_context5.next=51;break}return _Object$entries6$_i=_Object$entries6[_i8],subPath=_Object$entries6$_i[0],value=_Object$entries6$_i[1],fullPath="/"+prefix+(prefix.trim()?"/":"")+subPath,url=""+urlPrefix+fullPath,response=void 0,_context5.prev=35,_context5.next=36,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{headers:authorizationHeader});case 36:response=_context5.sent,_context5.next=38;break;case 37:_context5.prev=37,_t8=_context5.catch(35),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn('Configuration "'+fullPath+'" (with desired value',"["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]) couldn't be determined:",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t8));case 38:if(!response){_context5.next=50;break}if(!response.ok){_context5.next=49;break}if(changeNeeded=!0,"function"!=typeof response.text){_context5.next=42;break}return _context5.prev=39,_t9=value,_context5.next=40,response["string"==typeof value?"text":"json"]();case 40:_t0=_context5.sent,changeNeeded=_t9===_t0,_context5.next=42;break;case 41:_context5.prev=41,_t1=_context5.catch(39),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Error checking current value of",'"'+fullPath+'" to be',"["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]:",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t1));case 42:if(!changeNeeded){_context5.next=47;break}return _context5.prev=43,_context5.next=44,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(url,{body:'"'+value+'"',headers:authorizationHeader,method:"PUT"});case 44:_context5.next=46;break;case 45:_context5.prev=45,_t10=_context5.catch(43),_helper__WEBPACK_IMPORTED_MODULE_11__.log.error('Configuration "'+fullPath+"\" couldn't be","applied to ["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]:",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t10));case 46:_context5.next=48;break;case 47:_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Configuration "'+fullPath+'" is already set',"to desired value ["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"].");case 48:_context5.next=50;break;case 49:_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Configuration "'+fullPath+'" does not exist',"(desired value ["+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(value)+"]). Response","code is "+String(response.status)+".");case 50:_i8++,_context5.next=34;break;case 51:_context5.next=33;break;case 52:return _context5.next=53,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.initializeConnection)(services,configuration);case 53:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context5.next=62;break}return _context5.next=54,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/_session",{body:JSON.stringify({name:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}),headers:_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},headers),method:"POST"});case 54:_yield$globalContext$=_context5.sent,givenAuthorizationHeaders=_yield$globalContext$.headers,_authorizationHeader={Cookie:givenAuthorizationHeaders.get("set-cookie")},securityConfigurations=configuration.couchdb.security,_i9=0,_Object$entries7=Object.entries(securityConfigurations);case 55:if(!(_i9<_Object$entries7.length)){_context5.next=62;break}if(_Object$entries7$_i=_Object$entries7[_i9],databaseName=_Object$entries7$_i[0],securityObject=_Object$entries7$_i[1],"_default"!==databaseName){_context5.next=56;break}return _context5.abrupt("continue",61);case 56:return fullSecurityObject=securityObject,"_users"!==databaseName&&(fullSecurityObject.admins||(fullSecurityObject.admins={names:[],roles:[]}),securityConfigurations._default.admins&&(securityConfigurations._default.admins.names&&(fullSecurityObject.admins.names=securityConfigurations._default.admins.names.concat(null!==(_fullSecurityObject$a=fullSecurityObject.admins.names)&&void 0!==_fullSecurityObject$a?_fullSecurityObject$a:[])),securityConfigurations._default.admins.roles&&(fullSecurityObject.admins.roles=securityConfigurations._default.admins.roles.concat(null!==(_fullSecurityObject$a2=fullSecurityObject.admins.roles)&&void 0!==_fullSecurityObject$a2?_fullSecurityObject$a2:[]))),fullSecurityObject.members||(fullSecurityObject.members={names:[],roles:[]}),securityConfigurations._default.members&&(securityConfigurations._default.members.names&&(fullSecurityObject.members.names=securityConfigurations._default.members.names.concat(null!==(_fullSecurityObject$m=fullSecurityObject.members.names)&&void 0!==_fullSecurityObject$m?_fullSecurityObject$m:[])),securityConfigurations._default.members.roles&&(fullSecurityObject.members.roles=securityConfigurations._default.members.roles.concat(null!==(_fullSecurityObject$m2=fullSecurityObject.members.roles)&&void 0!==_fullSecurityObject$m2?_fullSecurityObject$m2:[])))),_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Apply security settings for database "'+databaseName+'":',(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(fullSecurityObject)),_context5.prev=57,_context5.next=58,clientnode__WEBPACK_IMPORTED_MODULE_3__.globalContext.fetch(urlPrefix+"/"+databaseName+"/_security",{body:JSON.stringify(fullSecurityObject),headers:_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},headers,_authorizationHeader),method:"PUT"});case 58:if(_response=_context5.sent,_response.ok){_context5.next=59;break}throw new Error(_response.statusText);case 59:_context5.next=61;break;case 60:_context5.prev=60,_t11=_context5.catch(57),_helper__WEBPACK_IMPORTED_MODULE_11__.log.error('Security object for database "'+databaseName+"\" couldn't","be applied:",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t11));case 61:_i9++,_context5.next=55;break;case 62:if(modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(configuration.couchdb.model),delete modelConfiguration.property.defaultDefinition,delete modelConfiguration.entities,models=configuration.couchdb.model.entities,!configuration.couchdb.model.updateValidation){_context5.next=84;break}return _context5.next=63,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(eval("require.resolve('./databaseHelper')"),{encoding:configuration.core.encoding,flag:"r"});case 63:databaseHelperCode=_context5.sent,_iterator8=_createForOfIteratorHelperLoose([{description:"Authorization",methodName:"authorize",name:"authorization",serializedParameter:JSON.stringify((0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.couchdb.model))+", false, "+JSON.stringify(configuration.couchdb.model.property.name.special)},{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:JSON.stringify(modelConfiguration)+", "+JSON.stringify(models)}]);case 64:if((_step8=_iterator8()).done){_context5.next=69;break}_type=_step8.value,code="function(...parameters) {\n return require('helper')."+_type.methodName+"(...parameters.concat(["+_type.serializedParameter+"]))\n}",_context5.prev=65,new Function("return "+code),_context5.next=67;break;case 66:throw _context5.prev=66,_t12=_context5.catch(65),new Error("Generated "+_type.name+' code "'+code+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t12),{cause:_t12});case 67:return configuration.core.debug&&_helper__WEBPACK_IMPORTED_MODULE_11__.log.debug(_type.name+' code: \n\n"'+code+'" integrated.'),_context5.next=68,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.ensureValidationDocumentPresence)(couchdb.connection,_type.name,{helper:databaseHelperCode,validate_doc_update:code},_type.description,!0,idName,revisionName,specialNames.designDocumentNamePrefix);case 68:_context5.next=64;break;case 69:_i0=0,_Object$entries8=Object.entries(models);case 70:if(!(_i0<_Object$entries8.length)){_context5.next=84;break}_Object$entries8$_i=_Object$entries8[_i0],_modelName2=_Object$entries8$_i[0],_model=_Object$entries8$_i[1],_i1=0,_Object$entries9=Object.entries(_model);case 71:if(!(_i1<_Object$entries9.length)){_context5.next=83;break}if(_Object$entries9$_i=_Object$entries9[_i1],_name2=_Object$entries9$_i[0],specification=_Object$entries9$_i[1],![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name2)){_context5.next=77;break}_iterator9=_createForOfIteratorHelperLoose([].concat(specification));case 72:if((_step9=_iterator9()).done){_context5.next=76;break}if(constraint=_step9.value,!constraint.description){_context5.next=75;break}_context5.prev=73,new Function("return "+constraint.description),_context5.next=75;break;case 74:throw _context5.prev=74,_t13=_context5.catch(73),new Error('Specified constraint description "'+constraint.description+'" for model "'+_modelName2+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t13),{cause:_t13});case 75:_context5.next=72;break;case 76:_context5.next=82;break;case 77:_iterator0=_createForOfIteratorHelperLoose(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);case 78:if((_step0=_iterator0()).done){_context5.next=82;break}if(type=_step0.value,!(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isObject)(specification)){_context5.next=81;break}if(_constraint=specification[type],null==_constraint||!_constraint.description){_context5.next=81;break}_context5.prev=79,new Function(_constraint.description),_context5.next=81;break;case 80:throw _context5.prev=80,_t14=_context5.catch(79),new Error('Specified constraint description "'+_constraint.description+'" for model "'+_modelName2+'" in property "'+_name2+'" as "'+type+"\" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t14),{cause:_t14});case 81:_context5.next=78;break;case 82:_i1++,_context5.next=71;break;case 83:_i0++,_context5.next=70;break;case 84:if(!configuration.couchdb.model.autoMigrationPath){_context5.next=118;break}return migrators={},_context5.next=85,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isDirectory)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath));case 85:if(!_context5.sent){_context5.next=103;break}return _t15=_createForOfIteratorHelperLoose,_context5.next=86,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.walkDirectoryRecursively)((0,path__WEBPACK_IMPORTED_MODULE_5__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_3__.NOOP:function(e){return!["debug","deprecated"].includes(e.name)});case 86:_iterator1=_t15(_context5.sent);case 87:if((_step1=_iterator1()).done){_context5.next=103;break}if(file=_step1.value,extension=(0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name),_name3=(0,path__WEBPACK_IMPORTED_MODULE_5__.basename)(file.name,extension),".json"!==extension){_context5.next=99;break}return documents=void 0,_context5.prev=88,_t16=[],_t17=JSON,_context5.next=89,fs__WEBPACK_IMPORTED_MODULE_4__.promises.readFile(file.path,{encoding:configuration.core.encoding,flag:"r"});case 89:documents=_t16.concat.call(_t16,_t17.parse.call(_t17,_context5.sent)),_context5.next=91;break;case 90:throw _context5.prev=90,_t18=_context5.catch(88),new Error('Parsing document "'+file.path+'" to include by automigration of has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t18),{cause:_t18});case 91:1===documents.length&&(documents[0][idName]||(documents[0][idName]=_name3),documents[0][revisionName]||(documents[0][revisionName]="0-upsert")),_iterator10=_createForOfIteratorHelperLoose(documents);case 92:if((_step10=_iterator10()).done){_context5.next=98;break}return document=_step10.value,_context5.prev=93,_context5.next=94,couchdb.connection.put(document);case 94:_context5.next=96;break;case 95:throw _context5.prev=95,_t19=_context5.catch(93),null!=(_forbidden=_t19.forbidden)&&_forbidden.startsWith("NoChange:")&&_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Including document "'+document[idName]+'"',"of type",'"'+document[typeName]+"\" hasn't","changed existing document."),new Error('Migrating document "'+document[idName]+'" of type "'+document[typeName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t19),{cause:_t19});case 96:_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Including document "'+document[idName]+'" of','type "'+document[typeName]+'" was',"successful.");case 97:_context5.next=92;break;case 98:_context5.next=102;break;case 99:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context5.next=100;break}migrators[file.path]=eval("require('"+file.path+"')").default,_context5.next=102;break;case 100:if(![".mjs"].includes((0,path__WEBPACK_IMPORTED_MODULE_5__.extname)(file.name))){_context5.next=102;break}return _context5.next=101,eval("import('"+file.path+"')");case 101:migrators[file.path]=_context5.sent.default;case 102:_context5.next=87;break;case 103:return _t20=_createForOfIteratorHelperLoose,_context5.next=104,couchdb.connection.allDocs({include_docs:!0});case 104:_iterator11=_t20(_context5.sent.rows);case 105:if((_step11=_iterator11()).done){_context5.next=118;break}if(retrievedDocument=_step11.value,"string"==typeof retrievedDocument.id&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context5.next=117;break}_document=retrievedDocument.doc,newDocument=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.copy)(_document),newDocument[configuration.couchdb.model.property.name.special.updateStrategy]="migrate",_iterator12=_createForOfIteratorHelperLoose(Object.keys(migrators).sort());case 106:if((_step12=_iterator12()).done){_context5.next=111;break}_name4=_step12.value,_result=void 0,_context5.prev=107,_result=migrators[_name4](newDocument,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},clientnode__WEBPACK_IMPORTED_MODULE_3__.UTILITY_SCOPE,{configuration,databaseHelper:_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default(),idName,typeName,migrators,models,modelConfiguration,selfFilePath:_name4,services})),_context5.next=109;break;case 108:throw _context5.prev=108,_t21=_context5.catch(107),new Error('Running migrater "'+_name4+'" in document '+(0,_helper__WEBPACK_IMPORTED_MODULE_11__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+'" failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t21),{cause:_t21});case 109:_result&&(newDocument=_result,_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Running migrater "'+_name4+'" for document','"'+newDocument[idName]+'" (of type','"'+newDocument[typeName]+'") was successful.'));case 110:_context5.next=106;break;case 111:if(result=couchdb.validateDocument(newDocument,{checkPublicModelType:!0,oldDocument:_document}),!0===result){_context5.next=113;break}if(!Object.prototype.hasOwnProperty.call(result,"forbidden")){_context5.next=112;break}_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn('Document "'+(0,_helper__WEBPACK_IMPORTED_MODULE_11__.mayStripRepresentation)(_document,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+"\" doesn't satisfy its schema (and can not be","migrated automatically): "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(result)),_context5.next=113;break;case 112:throw result;case 113:return _context5.prev=113,_context5.next=114,couchdb.connection.put(newDocument);case 114:_context5.next=116;break;case 115:throw _context5.prev=115,_t22=_context5.catch(113),new Error('Replacing auto migrated document "'+newDocument[idName]+'" has failed: '+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t22),{cause:_t22});case 116:_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Auto migrating document "'+newDocument[idName]+'" was',"successful.");case 117:_context5.next=105;break;case 118:return _context5.next=119,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.removeDeprecatedIndexes)(couchdb.connection,models,configuration.couchdb.model);case 119:return _context5.next=120,couchdb.connection.getIndexes();case 120:if(genericIndexes=_context5.sent.indexes.filter((function(e){return e.name.endsWith("-GenericIndex")})),!configuration.couchdb.createGenericFlatIndex||!configuration.couchdb.model.autoMigrationPath&&0!==genericIndexes.length){_context5.next=129;break}_i10=0,_Object$entries0=Object.entries(models);case 121:if(!(_i10<_Object$entries0.length)){_context5.next=129;break}if(_Object$entries0$_i=_Object$entries0[_i10],_modelName3=_Object$entries0$_i[0],_model2=_Object$entries0$_i[1],!new RegExp(configuration.couchdb.model.property.name.typePattern.public).test(_modelName3)){_context5.next=128;break}return _context5.next=122,couchdb.connection.createIndex({index:{ddoc:_modelName3+"-GenericIndex",fields:[typeName],name:_modelName3+"-GenericIndex"}});case 122:_iterator13=_createForOfIteratorHelperLoose((0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineGenericIndexablePropertyNames)(configuration.couchdb.model,_model2));case 123:if((_step13=_iterator13()).done){_context5.next=128;break}propertyName=_step13.value,_name5=_modelName3+"-"+propertyName+"-GenericIndex",found=!1,_iterator14=_createForOfIteratorHelperLoose(genericIndexes);case 124:if((_step14=_iterator14()).done){_context5.next=126;break}if(index=_step14.value,index.name!==_name5){_context5.next=125;break}return found=!0,_context5.abrupt("continue",126);case 125:_context5.next=124;break;case 126:if(found){_context5.next=127;break}return _context5.next=127,couchdb.connection.createIndex({index:{ddoc:_name5,fields:[typeName,propertyName],name:_name5}});case 127:_context5.next=123;break;case 128:_i10++,_context5.next=121;break;case 129:return _context5.next=130,couchdb.reinitializeMaterializedViews();case 130:if(!(Object.keys(couchdb.foreignKeys.static).length>0)){_context5.next=131;break}return _context5.next=131,couchdb.removeDanglingForeignKeys();case 131:if(!configuration.couchdb.model.triggerInitialCompaction){_context5.next=135;break}return _context5.prev=132,_context5.next=133,couchdb.connection.compact();case 133:_context5.next=135;break;case 134:_context5.prev=134,_t23=_context5.catch(132),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Initial database compaction has failed: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(_t23));case 135:return _context5.abrupt("return",{couchdb:promise});case 136:case"end":return _context5.stop()}}),_callee4,null,[[5,8,11,13],[14,16,17,19],[21,23,29,31],[24,26],[35,37],[39,41],[43,45],[57,60],[65,66],[73,74],[79,80],[88,90],[93,95],[107,108],[113,115],[132,134]])})));return function(e){return _ref3.apply(this,arguments)}}(),postLoadService=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,a,i,_,c,u;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.configuration.couchdb,n=t.pluginAPI,o=t.services,a=o.couchdb,i=r.model.property.name.special,_=0,c=new clientnode__WEBPACK_IMPORTED_MODULE_3__.Semaphore(r.numberOfParallelChangesRunner),u=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(){var o,s,l,p,d,f,m,v,b,h,y,E,O,g,P,x,D,M,A,I;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a.changesStream&&a.changesStream.cancel(),p=r.changesStream,void 0!==a.lastChangesSequenceIdentifier&&(p.since=a.lastChangesSequenceIdentifier),_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Initialize changes stream since",'"'+String(p.since)+'".'),a.changesStream=a.connection.changes(p),Object.keys(r.materializedViews).length){for(d=r.updateMaterializedViewsChangesStream,void 0!==a.lastUpdateMaterializedViewsChangesSequenceIdentifier&&(d.since=a.lastUpdateMaterializedViewsChangesSequenceIdentifier),f={$and:[]},m=0,v=Object.entries(r.materializedViews);m<v.length;m++)for(h=v[m],y=h[0],E=h[1],O=[],f.$and.push(((b={})[i.id]={$ne:y},b),{$or:O}),g=0,P=Object.values(E);g<P.length;g++)x=P[g],O.push(x.query.selector);d.selector=f,_helper__WEBPACK_IMPORTED_MODULE_11__.log.info('Initialize changes stream for views since "'+String(d.since)+'".'),a.updateMaterializedViewsChangesStream=a.connection.changes(d)}return Object.keys(a.foreignKeys.static).length>0&&(D=r.updateForeignKeysChangesStream,void 0!==a.lastUpdateForeignKeysChangesSequenceIdentifier&&(D.since=a.lastUpdateForeignKeysChangesSequenceIdentifier),D.selector={$or:Object.keys(a.foreignKeys.static).map((function(e){var t;return(t={})[i.type]=e,t}))},_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Initialize changes stream to update foreign keys since",'"'+String(D.since)+'"','with selector "'+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(D.selector)+'".'),a.updateForeignKeysChangesStream=a.connection.changes(D),M=r.removeDanglingForeignKeysChangesStream,void 0!==a.lastRemoveDanglingForeignKeysChangesSequenceIdentifier&&(M.since=a.lastRemoveDanglingForeignKeysChangesSequenceIdentifier),M.selector={$or:Array.from(new Set(Object.values(a.foreignKeys.static).flatMap((function(e){return e.map((function(e){return e.targetModelName}))})))).map((function(e){var t;return(t={})[i.type]=e,t}))},_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Initialize changes stream to remove dangling foreign keys",'since "'+String(M.since)+'" with selector "'+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(M.selector)+'".'),a.removeDanglingForeignKeysChangesStream=a.connection.changes(M)),A=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(n){var o,i,c;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((_+=1)>r.changesStreamReinitializer.retries)){e.next=2;break}return _helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Observing changes feed throws an error for",String(_)+" times through:",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n)+" Restarting database server and","reinitialize changes stream..."),_=0,a.changesStream.cancel(),null==(o=a.removeDanglingForeignKeysChangesStream)||o.cancel(),null==(i=a.updateMaterializedViewsChangesStream)||i.cancel(),e.next=1,a.server.restart(t);case 1:e.next=3;break;case 2:return c=Math.min(Math.pow(r.changesStreamReinitializer.retryWaitingFactorInSeconds,_),r.changesStreamReinitializer.maximumRetryWaitingTimeInSeconds),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Observing changes feed throws an error for",String(_)+" of",String(r.changesStreamReinitializer.retries),"allowed times through: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(n),"Reinitializing changes stream in",String(c)+" seconds..."),e.next=3,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.timeout)(1e3*c);case 3:u();case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),a.changesStream.on("error",A),a.updateForeignKeysChangesStream&&a.updateForeignKeysChangesStream.on("error",A),a.removeDanglingForeignKeysChangesStream&&a.removeDanglingForeignKeysChangesStream.on("error",A),a.updateMaterializedViewsChangesStream&&a.updateMaterializedViewsChangesStream.on("error",A),e.next=1,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{data:{changesStream:a.changesStream,updateMaterializedViewsChangesStream:a.updateMaterializedViewsChangesStream},hook:"couchdbInitializeChangesStream"}));case 1:null==(o=a.updateForeignKeysChangesStream)||o.on("change",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,c,u,s,l,p,d,f,m,v,b,h,y,E,O,g;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(_=0,r=0,n=Object.entries(a.foreignKeys.runtime);r<n.length;r++)o=n[r],c=o[0],u=o[1],a.foreignKeys.runtime[c]=u.filter((function(e){return e.id!==t.id}));if(t.deleted){e.next=4;break}return e.next=1,a.connection.find({selector:(s={},s[i.id]=t.id,s),fields:[i.type]});case 1:if(0!==(l=e.sent.docs).length){e.next=2;break}_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn('Could not find document with id "'+t.id+'"',"remembered as foreign key source."),e.next=4;break;case 2:return d=l[0],f=a.foreignKeys.static[d[i.type]].map((function(e){return e.propertySelector})),e.next=3,a.connection.find({selector:(p={},p[i.id]=t.id,p),fields:f.map((function(e){return e.join(".")}))});case 3:if(0===(l=e.sent.docs).length)_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Could not find document with id",'"'+t.id+'" remembered as foreign',"key source.");else for(m=l[0],v=_createForOfIteratorHelperLoose(f);!(b=v()).done;)for(h=b.value,y=[].concat((0,clientnode__WEBPACK_IMPORTED_MODULE_3__.evaluateSelector)(h,m)),E=_createForOfIteratorHelperLoose(y);!(O=E()).done;)(g=O.value)&&(Object.prototype.hasOwnProperty.call(a.foreignKeys.runtime,g)||(a.foreignKeys.runtime[g]=[]),a.foreignKeys.runtime[g].push({propertySelector:h,id:t.id}));case 4:a.lastUpdateForeignKeysChangesSequenceIdentifier=t.seq;case 5:case"end":return e.stop()}}),e)})))),null==(s=a.removeDanglingForeignKeysChangesStream)||s.on("change",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o,c,u,s,l,p,d,f,m,v,b,h,y;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(_=0,!t.deleted||!Object.prototype.hasOwnProperty.call(a.foreignKeys.runtime,t.id)){e.next=9;break}r=_createForOfIteratorHelperLoose(a.foreignKeys.runtime[t.id]);case 1:if((n=r()).done){e.next=8;break}return c=n.value,u=c.propertySelector,s=c.id,l=u.join("."),e.next=2,a.connection.find({selector:(o={},o[i.id]=s,o),fields:[i.id,l]});case 2:if(0!==(p=e.sent.docs).length){e.next=3;break}return _helper__WEBPACK_IMPORTED_MODULE_11__.log.warn('Could not find document with id "'+s+'"',"remembered as foreign key source."),e.abrupt("continue",7);case 3:return d=p[0],f=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.evaluateSelectorUntilLastObject)(l,d),m=f[0],v=f[1],h=m[b=v],_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Found dangling document reference","("+t.id+") in document",(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.represent)(d)+" in property",'"'+l+'". Removing the reference.'),Array.isArray(h)?m[b]=h.filter((function(e){return e!==t.id})):m[b]=null,d[i.revision]="0-latest",e.prev=4,e.next=5,a.connection.put(d);case 5:e.next=7;break;case 6:e.prev=6,y=e.catch(4),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Could not remove dangling foreign key","relation:",y);case 7:e.next=1;break;case 8:delete a.foreignKeys.runtime[t.id];case 9:a.lastRemoveDanglingForeignKeysChangesSequenceIdentifier=t.seq;case 10:case"end":return e.stop()}}),e,null,[[4,6]])})))),I=new clientnode__WEBPACK_IMPORTED_MODULE_3__.Lock,null==(l=a.updateMaterializedViewsChangesStream)||l.on("change",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var n,o,c,u,s,l,p,d,f,m,v,b,h,y,E;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:_=0,n=0,o=Object.entries(r.materializedViews);case 1:if(!(n<o.length)){e.next=8;break}return u=o[n],s=u[0],l=u[1],(c={})[i.id]=s,p=c,e.prev=2,e.next=3,I.acquire(s);case 3:for(d=!1,f=0,m=Object.entries(l);f<m.length;f++)v=m[f],b=v[0],(h=v[1]).updateExpression&&((y=(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.evaluate)(h.updateExpression,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({deleted:!1},t,{document:t.doc}))).error?_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Could not execute update",'expression "'+h.updateExpression+'" for property "'+b+'" in view','document "'+s+'":',y.error):void 0!==y.result&&(d=!0,p[b]=y.result));if(!d){e.next=4;break}return e.next=4,a.connection.put(p);case 4:e.next=6;break;case 5:e.prev=5,E=e.catch(2),_helper__WEBPACK_IMPORTED_MODULE_11__.log.warn("Updating view failed:",E);case 6:return e.prev=6,I.release(s),e.finish(6);case 7:n++,e.next=1;break;case 8:a.lastUpdateMaterializedViewsChangesSequenceIdentifier=t.seq;case 9:case"end":return e.stop()}}),e,null,[[2,5,6,7]])})))),a.changesStream.on("change",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(r){var o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return _=0,e.next=1,c.acquire();case 1:return e.prev=1,e.next=2,n.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{data:r,hook:"couchdbChange"}));case 2:a.lastChangesSequenceIdentifier=r.seq,e.next=4;break;case 3:e.prev=3,o=e.catch(1),_helper__WEBPACK_IMPORTED_MODULE_11__.log.error("An error occurred during on change database hook:",o);case 4:return e.prev=4,c.release(),e.finish(4);case 5:case"end":return e.stop()}}),e,null,[[1,3,4,5]])})))),_helper__WEBPACK_IMPORTED_MODULE_11__.log.info("Changes stream initialized.");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),!r.attachAutoRestarter){e.next=1;break}return u(),e.next=1,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.timeout)();case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),shouldExit=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t){var r,n,o;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.configuration,n=t.services,e.next=1,(0,_server__WEBPACK_IMPORTED_MODULE_12__.ds)(n,r);case 1:return delete n.couchdb,o="log.txt",e.next=2,(0,clientnode__WEBPACK_IMPORTED_MODULE_3__.isFile)(o);case 2:if(!e.sent){e.next=3;break}return e.next=3,fs__WEBPACK_IMPORTED_MODULE_4__.promises.unlink(o);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),database=module.exports;const __WEBPACK_DEFAULT_EXPORT__=database},e=>{"use strict";e.exports=require("fs")},e=>{"use strict";e.exports=require("path")},e=>{"use strict";e.exports=require("pouchdb-adapter-memory")},e=>{"use strict";e.exports=require("pouchdb-find")},e=>{"use strict";e.exports=require("pouchdb-node")},e=>{"use strict";e.exports=require("pouchdb-validation")},e=>{"use strict";e.exports=require("child_process")},e=>{"use strict";e.exports=require("express-pouchdb/lib/utils")},e=>{"use strict";e.exports=require("mkdirp")},e=>{"use strict";e.exports=require("pouchdb-node/node_modules/node-fetch/lib/index.js")},,,(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{"use strict";__webpack_require__.d(__webpack_exports__,{S8:()=>restart,ds:()=>stop,ni:()=>start});var _babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__=__webpack_require__(1),_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default=__webpack_require__.n(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0__),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__=__webpack_require__(2),_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default=__webpack_require__.n(_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1__),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__=__webpack_require__(3),_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default=__webpack_require__.n(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2__),child_process__WEBPACK_IMPORTED_MODULE_3__=__webpack_require__(13),child_process__WEBPACK_IMPORTED_MODULE_3___default=__webpack_require__.n(child_process__WEBPACK_IMPORTED_MODULE_3__),clientnode__WEBPACK_IMPORTED_MODULE_4__=__webpack_require__(4),clientnode__WEBPACK_IMPORTED_MODULE_4___default=__webpack_require__.n(clientnode__WEBPACK_IMPORTED_MODULE_4__),express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__=__webpack_require__(14),express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5___default=__webpack_require__.n(express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__),mkdirp__WEBPACK_IMPORTED_MODULE_6__=__webpack_require__(15),mkdirp__WEBPACK_IMPORTED_MODULE_6___default=__webpack_require__.n(mkdirp__WEBPACK_IMPORTED_MODULE_6__),node_fetch__WEBPACK_IMPORTED_MODULE_7__=__webpack_require__(16),node_fetch__WEBPACK_IMPORTED_MODULE_7___default=__webpack_require__.n(node_fetch__WEBPACK_IMPORTED_MODULE_7__),fs__WEBPACK_IMPORTED_MODULE_8__=__webpack_require__(7),fs__WEBPACK_IMPORTED_MODULE_8___default=__webpack_require__.n(fs__WEBPACK_IMPORTED_MODULE_8__),path__WEBPACK_IMPORTED_MODULE_9__=__webpack_require__(8),path__WEBPACK_IMPORTED_MODULE_9___default=__webpack_require__.n(path__WEBPACK_IMPORTED_MODULE_9__),_databaseHelper__WEBPACK_IMPORTED_MODULE_10__=__webpack_require__(5),_databaseHelper__WEBPACK_IMPORTED_MODULE_10___default=__webpack_require__.n(_databaseHelper__WEBPACK_IMPORTED_MODULE_10__),_helper__WEBPACK_IMPORTED_MODULE_11__=__webpack_require__(0),_this=void 0;function _createForOfIteratorHelperLoose(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}clientnode__WEBPACK_IMPORTED_MODULE_4__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_7___default();var log=new clientnode__WEBPACK_IMPORTED_MODULE_4__.Logger({name:"web-node.couchdb.server"}),initializeExpress=function(){var _ref=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee5(name,state,connector,configuration,runnerConfiguration,pluginAPI,expressUtilities){var _ref3,specialNames,testConnector,isInMemory,_ref2,express,expressPouchDB,allDocs,changes,compact,revsDiff,security,viewCleanup,tempViews,find,views,ddocInfo,show,list,update,attachments,documents,validation,notFoundError,expressInstance,routesToPostpone,expressPouchDBInstance,authorizedChanges,_iterator3,_step3,_step3$value,_name,module,_iterator5,_step5,_step5$value,_name2,_module,_iterator6,_step6,_step6$value,_name3,_module2,_iterator7,_step7,_step7$value,_name4,_module3,_t9,_t0;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context5){for(;;)switch(_context5.prev=_context5.next){case 0:return log.info('Couchdb runner is in-place with: "'+name+'".'),specialNames=configuration.model.property.name.special,testConnector=new connector("",{skip_setup:!0}),isInMemory="memory"===testConnector.adapter,_context5.next=1,testConnector.close();case 1:if(null==expressUtilities){_context5.next=2;break}_t9=expressUtilities,_context5.next=4;break;case 2:return _t0=function(e){return e.default||e},_context5.next=3,eval("import('./loadExpress.js')");case 3:_t9=_t0(_context5.sent.default);case 4:for(_ref2=_t9,express=_ref2.express,expressPouchDB=_ref2.expressPouchDB,allDocs=_ref2.allDocs,changes=_ref2.changes,compact=_ref2.compact,revsDiff=_ref2.revsDiff,security=_ref2.security,viewCleanup=_ref2.viewCleanup,tempViews=_ref2.tempViews,find=_ref2.find,views=_ref2.views,ddocInfo=_ref2.ddocInfo,show=_ref2.show,list=_ref2.list,update=_ref2.update,attachments=_ref2.attachments,documents=_ref2.documents,validation=_ref2.validation,notFoundError=_ref2.notFoundError,expressInstance=express(),routesToPostpone=[[["routes/all-docs",allDocs],["routes/changes",changes],["routes/compact",compact],["routes/revs-diff",revsDiff],["routes/security",security],["routes/view-cleanup",viewCleanup],["routes/temp-views",tempViews]],[["routes/find",find],["routes/views",views],["routes/ddoc-info",ddocInfo],["routes/show",show],["routes/list",list],["routes/update",update]],[["routes/attachments",attachments]],[["routes/documents",documents],["validation",validation],["routes/404",notFoundError]]],expressPouchDBInstance=expressPouchDB(connector,_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},runnerConfiguration,{overrideMode:{exclude:(_ref3=[]).concat.apply(_ref3,routesToPostpone).map((function(e){return e[0]}))},inMemoryConfig:isInMemory})),expressPouchDBInstance.all("/:db/_all_docs",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.jsonParser,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r,n){var o,a,i,_,c,u,s,l,p;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t,(a=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},o.body,o.query)).include_docs){e.next=1;break}return n(),e.abrupt("return");case 1:return e.prev=1,e.next=2,o.db.allDocs(a);case 2:i=e.sent,_=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.model),c=_createForOfIteratorHelperLoose(i.rows);case 3:if((u=c()).done){e.next=7;break}s=u.value,e.prev=4,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.authorize)(s.doc,null,o.couchSession.userCtx,o.couchSecurityObj,_,!0,specialNames),e.next=6;break;case 5:return e.prev=5,l=e.catch(4),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,l,403),e.abrupt("return");case 6:e.next=3;break;case 7:(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendJSON)(r,200,i),e.next=9;break;case 8:e.prev=8,p=e.catch(1),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,p,400);case 9:case"end":return e.stop()}}),e,null,[[1,8],[4,5]])})))),authorizedChanges=function(e,t,r){var n=e,o=_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},n.body,n.query);if(Object.defineProperty(n,"query",{value:_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},n.query),writable:!0,configurable:!0,enumerable:!0}),o.include_docs){var a=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.model),i=function(e){return(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.authorize)(e,null,n.couchSession.userCtx,n.couchSecurityObj,a,!0,specialNames)},_=n.db.changes.bind(n.db);n.db.changes=function(){var e=_.apply(void 0,arguments);return e&&(e.on?e.on("change",(function(e){if(e.doc)try{i(e.doc)}catch(t){try{delete e.doc,e.error=t}catch(e){console.error(e)}}})):e.then&&e.then((function(e){for(var t,r=_createForOfIteratorHelperLoose(e.results);!(t=r()).done;){var n=t.value;if(n.doc)try{i(n.doc)}catch(e){try{delete n.doc,n.error=e}catch(e){log.error(e)}}}}))),e},r(),n.db.changes=_}else r()},expressPouchDBInstance.get("/:db/_changes",authorizedChanges),expressPouchDBInstance.post("/:db/_changes",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.jsonParser,authorizedChanges),_iterator3=_createForOfIteratorHelperLoose(routesToPostpone[0]);!(_step3=_iterator3()).done;)_step3$value=_step3.value,_name=_step3$value[0],module=_step3$value[1],module(expressPouchDBInstance);for(expressPouchDBInstance.post("/:db/_find",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.jsonParser,_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r){var n,o,a,i,_,c,u,s,l,p,d;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t,o=!1,Array.isArray(n.body.fields)&&!n.body.fields.includes(specialNames.type)&&(n.body.fields.push(specialNames.type),o=!0),e.prev=1,i={request:n,response:r},e.next=2,pluginAPI.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},state,{hook:"onPouchDBFind",data:i}));case 2:if(_=e.sent,null!=(a=_)&&a.docs){e.next=4;break}return e.next=3,n.db.find(n.body);case 3:_=e.sent;case 4:c=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.model),u=_createForOfIteratorHelperLoose(_.docs);case 5:if((s=u()).done){e.next=9;break}l=s.value,e.prev=6,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.authorize)(l,null,n.couchSession.userCtx,n.couchSecurityObj,c,!0,specialNames),o&&delete l[specialNames.type],e.next=8;break;case 7:return e.prev=7,p=e.catch(6),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,p,403),e.abrupt("return");case 8:e.next=5;break;case 9:(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendJSON)(r,200,_),e.next=11;break;case 10:e.prev=10,d=e.catch(1),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,d,400);case 11:case"end":return e.stop()}}),e,null,[[1,10],[6,7]])})))),_iterator5=_createForOfIteratorHelperLoose(routesToPostpone[1]);!(_step5=_iterator5()).done;)_step5$value=_step5.value,_name2=_step5$value[0],_module=_step5$value[1],_module(expressPouchDBInstance);for(expressPouchDBInstance.get("/:db/:id/:attachment(*)",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r,n){var o,a,i,_,c,u,s,l,p,d;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=t,e.prev=1,i=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.model),e.next=2,o.db.find({fields:[specialNames.type],selector:(a={},a[specialNames.id]=o.query.id,a)});case 2:_=e.sent,c=_.docs,u=c[0],e.prev=3,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.authorize)(((l={})[specialNames.type]=u[specialNames.type],l[specialNames.attachment]=((s={})[o.params.attachment]={},s),l),null,o.couchSession.userCtx,o.couchSecurityObj,i,!0,specialNames),e.next=5;break;case 4:return e.prev=4,p=e.catch(3),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,p,403),e.abrupt("return");case 5:e.next=7;break;case 6:return e.prev=6,d=e.catch(1),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,d,400),e.abrupt("return");case 7:n();case 8:case"end":return e.stop()}}),e,null,[[1,6],[3,4]])})))),_iterator6=_createForOfIteratorHelperLoose(routesToPostpone[2]);!(_step6=_iterator6()).done;)_step6$value=_step6.value,_name3=_step6$value[0],_module2=_step6$value[1],_module2(expressPouchDBInstance);for(expressPouchDBInstance.get("/:db/:id(*)",_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r){var n,o,a,i,_;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t,e.prev=1,o=(0,_helper__WEBPACK_IMPORTED_MODULE_11__.determineModelRolesMapping)(configuration.model),e.next=2,n.db.get(n.params.id,n.query);case 2:a=e.sent,e.prev=3,(0,_databaseHelper__WEBPACK_IMPORTED_MODULE_10__.authorize)(a,null,n.couchSession.userCtx,n.couchSecurityObj,o,!0,specialNames),e.next=5;break;case 4:return e.prev=4,i=e.catch(3),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,i,403),e.abrupt("return");case 5:(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendJSON)(r,200,a),e.next=7;break;case 6:e.prev=6,_=e.catch(1),(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_5__.sendError)(r,_,400);case 7:case"end":return e.stop()}}),e,null,[[1,6],[3,4]])})))),_iterator7=_createForOfIteratorHelperLoose(routesToPostpone[3]);!(_step7=_iterator7()).done;)_step7$value=_step7.value,_name4=_step7$value[0],_module3=_step7$value[1],_module3(expressPouchDBInstance);if(isInMemory){_context5.next=5;break}return(0,mkdirp__WEBPACK_IMPORTED_MODULE_6__.mkdirpSync)((0,path__WEBPACK_IMPORTED_MODULE_9__.resolve)(configuration.path)),_context5.next=5,(0,mkdirp__WEBPACK_IMPORTED_MODULE_6__.mkdirp)((0,path__WEBPACK_IMPORTED_MODULE_9__.resolve)(configuration.path));case 5:return _context5.next=6,pluginAPI.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},state,{hook:"initializeExpressPouchDB",data:{expressInstance,expressPouchDBInstance}}));case 6:return expressInstance.use("/",expressPouchDBInstance),_context5.abrupt("return",{expressInstance,expressPouchDBInstance});case 7:case"end":return _context5.stop()}}),_callee5)})));return function(e,t,r,n,o,a,i){return _ref.apply(this,arguments)}}(),start=function(){var _ref9=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function _callee6(state,expressUtilities){var configuration,pluginAPI,_state$services$couch,backendConnector,server,runnerConfiguration,runner,name,_yield$initializeExpr,expressInstance,expressPouchDBInstance,binaryRunner,_t1;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(_context6){for(;;)switch(_context6.prev=_context6.next){case 0:if(configuration=state.configuration,pluginAPI=state.pluginAPI,_state$services$couch=state.services.couchdb,backendConnector=_state$services$couch.backendConnector,server=_state$services$couch.server,runnerConfiguration=configuration.couchdb.runner,runner=server.runner,!runner.configurationFile){_context6.next=5;break}return _context6.prev=1,_context6.next=2,fs__WEBPACK_IMPORTED_MODULE_8__.promises.mkdir((0,path__WEBPACK_IMPORTED_MODULE_9__.dirname)(runner.configurationFile.path),{recursive:!0});case 2:_context6.next=4;break;case 3:if(_context6.prev=3,_t1=_context6.catch(1),"EEXIST"===_t1.code){_context6.next=4;break}throw _t1;case 4:return _context6.next=5,fs__WEBPACK_IMPORTED_MODULE_8__.promises.writeFile(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 5:if(name=[].concat(runner.names)[0],!runner.packages){_context6.next=9;break}if(server.expressInstance){_context6.next=7;break}return _context6.next=6,initializeExpress(name,state,backendConnector,configuration.couchdb,runner.configuration,pluginAPI,expressUtilities);case 6:_yield$initializeExpr=_context6.sent,expressInstance=_yield$initializeExpr.expressInstance,expressPouchDBInstance=_yield$initializeExpr.expressPouchDBInstance,server.expressInstance=expressInstance,server.expressPouchDBInstance=expressPouchDBInstance;case 7:return _context6.next=8,new Promise((function(e){var t,r,n;server.process=null==(t=server.expressInstance)?void 0:t.listen(configuration.couchdb.runner.port,e),null==(r=server.process)||r.on("close",(function(){server.resolve.call(_this)})),null==(n=server.process)||n.on("error",(function(e){server.reject.call(_this,e)}))}));case 8:_context6.next=10;break;case 9:log.info('Couchdb runner is: "'+name+'".'),binaryRunner=runner,server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_3__.spawn)("default"===runnerConfiguration.memoryInMegaByte?binaryRunner.binaryFilePath:runnerConfiguration.nodePath,("default"===runnerConfiguration.memoryInMegaByte?[]:["--max-old-space-size="+runnerConfiguration.memoryInMegaByte,binaryRunner.binaryFilePath]).concat(binaryRunner.arguments?binaryRunner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},eval("process").env,binaryRunner.environment):eval("process").env,shell:!0,stdio:"inherit"}),new Promise((function(e,t){for(var r,n=_createForOfIteratorHelperLoose(clientnode__WEBPACK_IMPORTED_MODULE_4__.CLOSE_EVENT_NAMES);!(r=n()).done;){var o,a=r.value;null==(o=server.process)||o.on(a,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.getProcessCloseHandler)(e,t,{process:server.process,reason:a}))}})).then((function(e){server.resolve.call(_this,e)}),(function(e){server.reject.call(_this,e)}));case 10:return _context6.next=11,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkReachability)((0,_helper__WEBPACK_IMPORTED_MODULE_11__.getEffectiveURL)(configuration.couchdb,!1,!1),{wait:!0});case 11:case"end":return _context6.stop()}}),_callee6,null,[[1,3]])})));return function(e,t){return _ref9.apply(this,arguments)}}(),restart=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r,n){var o,a,i,_,c,u,s;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r=!1),o=t.configuration,a=t.pluginAPI,i=t.services,_=i.couchdb.server,c=_.resolve,u=_.reject,s=new Promise((function(e,t){_.resolve=e,_.reject=t})),e.next=1,stop(i,o,r);case 1:return e.next=2,s;case 2:return _.resolve=c,_.reject=u,e.next=3,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.initializeConnection)(i,o,!1);case 3:return e.next=4,start(t,n);case 4:return e.next=5,a.callStack(_babel_runtime_helpers_extends__WEBPACK_IMPORTED_MODULE_0___default()({},t,{hook:"restartCouchdb"}));case 5:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),stop=function(){var e=_babel_runtime_helpers_asyncToGenerator__WEBPACK_IMPORTED_MODULE_1___default()(_babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().mark((function e(t,r,n){var o,a,i;return _babel_runtime_regenerator__WEBPACK_IMPORTED_MODULE_2___default().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=t.couchdb,a=r.couchdb,void 0===n&&(n=!1),!n){e.next=2;break}return e.next=1,o.connection.destroy();case 1:e.next=3;break;case 2:if(null==(i=o.connection.close())||!i.catch){e.next=3;break}return i.catch((function(e){log.error("Couchdb connection could not be gracefully closed:",e)})),e.next=3,(0,_helper__WEBPACK_IMPORTED_MODULE_11__.waitWithTimeout)(i,a.closeTimeoutInSeconds,"couchdb connection to close");case 3:return o.server.process&&(o.server.runner.packages?o.server.process.close():o.server.process.kill("SIGINT")),e.next=4,(0,clientnode__WEBPACK_IMPORTED_MODULE_4__.checkUnreachability)((0,_helper__WEBPACK_IMPORTED_MODULE_11__.getEffectiveURL)(a),{wait:!0});case 4:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}()}],__webpack_module_cache__={};function __webpack_require__(e){var t=__webpack_module_cache__[e];if(void 0!==t)return t.exports;var r=__webpack_module_cache__[e]={id:e,loaded:!1,exports:{}};return __webpack_modules__[e](r,r.exports,__webpack_require__),r.loaded=!0,r.exports}__webpack_require__.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return __webpack_require__.d(t,{a:t}),t},__webpack_require__.d=(e,t)=>{for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.hmd=e=>((e=Object.create(e)).children||(e.children=[]),Object.defineProperty(e,"exports",{enumerable:!0,set:()=>{throw new Error("ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: "+e.id)}}),e),__webpack_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),__webpack_require__.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var __webpack_exports__=__webpack_require__(6);module.exports=__webpack_exports__})();
1
+ if(typeof window==='undefined'||window===null)var window=(typeof globalThis==='undefined'||globalThis===null)?{}:globalThis;import { lastValueFrom as __WEBPACK_EXTERNAL_MODULE_rxjs_lastValueFrom__, map as __WEBPACK_EXTERNAL_MODULE_rxjs_map__, retry as __WEBPACK_EXTERNAL_MODULE_rxjs_retry__, timer as __WEBPACK_EXTERNAL_MODULE_rxjs_timer__ } from "rxjs";
2
+ import { fromFetch as __WEBPACK_EXTERNAL_MODULE_rxjs_fetch_acb1bba5_fromFetch__ } from "rxjs/fetch";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_child_process__ from "child_process";
4
+ import * as __WEBPACK_EXTERNAL_MODULE_clientnode__ from "clientnode";
5
+ import * as __WEBPACK_EXTERNAL_MODULE_express_pouchdb_lib_utils_d9028396__ from "express-pouchdb/lib/utils";
6
+ import * as __WEBPACK_EXTERNAL_MODULE_fs_promises_cc1b69f3__ from "fs/promises";
7
+ import * as __WEBPACK_EXTERNAL_MODULE_mkdirp__ from "mkdirp";
8
+ import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
9
+ import * as __WEBPACK_EXTERNAL_MODULE_pouchdb_adapter_memory_01c036b4__ from "pouchdb-adapter-memory";
10
+ import * as __WEBPACK_EXTERNAL_MODULE_pouchdb_find_9445dd40__ from "pouchdb-find";
11
+ import * as __WEBPACK_EXTERNAL_MODULE_pouchdb_node_83c7160d__ from "pouchdb-node";
12
+ import * as __WEBPACK_EXTERNAL_MODULE_pouchdb_node_node_modules_node_fetch_lib_index_js_c3ba0d2e__ from "pouchdb-node/node_modules/node-fetch/lib/index.js";
13
+ import * as __WEBPACK_EXTERNAL_MODULE_pouchdb_validation_de480713__ from "pouchdb-validation";
14
+ import * as __WEBPACK_EXTERNAL_MODULE_url__ from "url";
15
+ /******/ var __webpack_modules__ = ([
16
+ /* 0 */
17
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
18
+
19
+ const x = (y) => {
20
+ const x = {}; __webpack_require__.d(x, y); return x
21
+ }
22
+ const y = (x) => (() => (x))
23
+ module.exports = x({ ["CLOSE_EVENT_NAMES"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.CLOSE_EVENT_NAMES), ["Lock"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.Lock), ["Logger"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.Logger), ["NOOP"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.NOOP), ["Semaphore"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.Semaphore), ["UTILITY_SCOPE"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.UTILITY_SCOPE), ["checkReachability"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.checkReachability), ["checkUnreachability"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.checkUnreachability), ["copy"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.copy), ["evaluate"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.evaluate), ["evaluateSelector"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.evaluateSelector), ["evaluateSelectorUntilLastObject"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.evaluateSelectorUntilLastObject), ["extend"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.extend), ["format"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.format), ["getProcessCloseHandler"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.getProcessCloseHandler), ["globalContext"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.globalContext), ["isDirectory"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isDirectory), ["isFile"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isFile), ["isObject"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.isObject), ["represent"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.represent), ["timeout"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.timeout), ["walkDirectoryRecursively"]: () => (__WEBPACK_EXTERNAL_MODULE_clientnode__.walkDirectoryRecursively) });
24
+
25
+ /***/ }),
26
+ /* 1 */
27
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
28
+
29
+
30
+ // EXPORTS
31
+ __webpack_require__.d(__webpack_exports__, {
32
+ PA: () => (/* binding */ applyModelsInheritance),
33
+ A5: () => (/* binding */ determineGenericIndexablePropertyNames),
34
+ Ic: () => (/* binding */ determineModelRolesMapping),
35
+ EB: () => (/* binding */ ensureValidationDocumentPresence),
36
+ Yp: () => (/* binding */ getConnectorOptions),
37
+ Nk: () => (/* binding */ getEffectiveURL),
38
+ NN: () => (/* binding */ getPouchDBPlugin),
39
+ Tg: () => (/* binding */ initializeConnection),
40
+ Rm: () => (/* binding */ log),
41
+ Ro: () => (/* binding */ mayStripRepresentation),
42
+ Wo: () => (/* binding */ removeDeprecatedIndexes),
43
+ e$: () => (/* binding */ waitWithTimeout)
44
+ });
45
+
46
+ // UNUSED EXPORTS: TOGGLE_LATEST_REVISION_DETERMINING, applyDefaultPropertyConfigurations, applyModelInheritance, isPropertyDefinition, normalizeRoles
47
+
48
+ // EXTERNAL MODULE: external "clientnode"
49
+ var external_clientnode_ = __webpack_require__(0);
50
+ ;// external "rxjs"
51
+
52
+ ;// external "rxjs/fetch"
53
+
54
+ // EXTERNAL MODULE: ./package.json
55
+ var package_0 = __webpack_require__(5);
56
+ ;// ./helper.ts
57
+ // -*- coding: utf-8 -*-
58
+ /** @module helper *//* !
59
+ region header
60
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
61
+
62
+ License
63
+ -------
64
+
65
+ This library written by Torben Sickert stands under a creative commons
66
+ naming 3.0 unported license.
67
+ See https://creativecommons.org/licenses/by/3.0/deed.de
68
+ endregion
69
+ */// region imports
70
+ function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof Generator?n:Generator,u=Object.create(c.prototype);return _regeneratorDefine2(u,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],y=!1,G={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function d(t,r){return i=t,c=0,u=e,G.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!y&&f&&!o&&t<p.length;t++){var o,i=p[t],d=G.p,l=i[2];r>3?(o=l===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,G.v=n,G.n=i[1]):d<l&&(o=r<3||i[0]>n||n>l)&&(i[4]=r,i[5]=n,G.n=l,c=0))}if(o||r>1)return a;throw y=!0,n}return function(o,p,l){if(f>1)throw TypeError("Generator is already running");for(y&&1===p&&d(p,l),c=p,u=l;(t=c<2?e:u)||!y;){i||(c?c<3?(c>1&&(G.n=-1),d(c,u)):G.n=u:G.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(y=G.n<0)?u:r.call(n,G))!==a)break}catch(t){i=e,c=1,u=t}finally{f=1}}return{value:t,done:y}}}(r,o,i),!0),u}var a={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(_regeneratorDefine2(t={},n,function(){return this}),t),u=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(u),e}return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(u,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,o,"GeneratorFunction"),_regeneratorDefine2(u),_regeneratorDefine2(u,o,"Generator"),_regeneratorDefine2(u,n,function(){return this}),_regeneratorDefine2(u,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(e,r,n,t){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}_regeneratorDefine2=function _regeneratorDefine(e,r,n,t){function o(r,n){_regeneratorDefine2(e,r,function(e){return this._invoke(r,n,e)})}r?i?i(e,r,{value:n,enumerable:!t,configurable:!t,writable:!t}):e[r]=n:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(e,r,n,t)}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){return void e(n)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n)}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n)}_next(void 0)})}};// endregion
71
+ /*
72
+ Token to provide to "bulkDocs" method call to indicate id determination
73
+ skip or not (depends on "skipLatestRevisionDetermining" configuration).
74
+ */var TOGGLE_LATEST_REVISION_DETERMINING=Symbol("toggleLatestRevisionDetermining");var log=new external_clientnode_.Logger({name:"web-node.couchdb"});/**
75
+ * Determines plugin to hook into any write operations.
76
+ * @param configuration - This's plugin configuration object.
77
+ * @returns A pouchdb plugin in object style.
78
+ */var getPouchDBPlugin=function getPouchDBPlugin(configuration){var _configuration$model$=configuration.model.property.name.special,idName=_configuration$model$.id,revisionName=_configuration$model$.revision,attachmentsPropertyName=_configuration$model$.attachment,deletedName=_configuration$model$.deleted;return{installCouchDBWebNodePlugin:function installCouchDBWebNodePlugin(description){var _this=this;if(this.bulkDocs){var nativeBulkDocs=this.bulkDocs.bind(this);this.bulkDocs=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(firstParameter){var _len,parameters,_key,toggleLatestRevisionDetermining,skipLatestRevisionDetermining,data,chunkSize,results,_index,chunk,result,conflictingIndexes,conflicts,index,_iterator,_step,item,retriedResults,_iterator2,_step2,retriedResult,_args=arguments,_t,_t2,_t3;return _regenerator().w(function(_context){while(1)switch(_context.p=_context.n){case 0:log.debug("BulkDocs called from:",description);// Normalize parameter to an array of documents.
79
+ if((0,external_clientnode_.isObject)(firstParameter)&&Object.keys(firstParameter).length===1&&"docs"in firstParameter&&Array.isArray(firstParameter.docs))firstParameter=firstParameter.docs;for(_len=_args.length,parameters=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){parameters[_key-1]=_args[_key]}toggleLatestRevisionDetermining=parameters.length>0&&parameters[parameters.length-1]===TOGGLE_LATEST_REVISION_DETERMINING;skipLatestRevisionDetermining=toggleLatestRevisionDetermining?!configuration.skipLatestRevisionDetermining:configuration.skipLatestRevisionDetermining;if(toggleLatestRevisionDetermining)parameters.pop();data=!Array.isArray(firstParameter)&&(0,external_clientnode_.isObject)(firstParameter)&&idName in firstParameter?[firstParameter]:firstParameter;chunkSize=configuration.maximumNumberOfEntitiesInBulkOperation;results=[];_index=0;case 1:if(!(_index<data.length)){_context.n=4;break}chunk=data.slice(_index,_index+chunkSize);_context.n=2;return nativeBulkDocs.call.apply(nativeBulkDocs,[_this,chunk].concat(_toConsumableArray(parameters)));case 2:result=_context.v;results=results.concat(result);case 3:_index+=chunkSize;_context.n=1;break;case 4:conflictingIndexes=[];conflicts=[];index=0;_iterator=_createForOfIteratorHelper(results);_context.p=5;_iterator.s();case 6:if((_step=_iterator.n()).done){_context.n=13;break}item=_step.value;if(!(_typeof(data[index])==="object")){_context.n=11;break}if(!(revisionName in data[index]&&item.name==="conflict"&&["0-latest","0-upsert"].includes(data[index][revisionName]))){_context.n=7;break}conflicts.push(data[index]);conflictingIndexes.push(index);_context.n=11;break;case 7:if(!(idName in data[index]&&configuration.ignoreNoChangeError&&"name"in item&&item.name==="forbidden"&&"message"in item&&item.message.startsWith("NoChange:"))){_context.n=11;break}results[index]={id:data[index][idName],ok:true};if(skipLatestRevisionDetermining){_context.n=11;break}if(!(revisionName in data[index]&&!["0-latest","0-upsert"].includes(data[index][revisionName]))){_context.n=8;break}_t=data[index][revisionName];_context.n=10;break;case 8:_context.n=9;return _this.get(results[index].id);case 9:_t2=revisionName;_t=_context.v[_t2];case 10:results[index].rev=_t;case 11:index+=1;case 12:_context.n=6;break;case 13:_context.n=15;break;case 14:_context.p=14;_t3=_context.v;_iterator.e(_t3);case 15:_context.p=15;_iterator.f();return _context.f(15);case 16:if(!conflicts.length){_context.n=18;break}data=conflicts;if(toggleLatestRevisionDetermining)parameters.push(TOGGLE_LATEST_REVISION_DETERMINING);_context.n=17;return _this.bulkDocs.apply(_this,[data].concat(_toConsumableArray(parameters)));case 17:retriedResults=_context.v;_iterator2=_createForOfIteratorHelper(retriedResults);try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){retriedResult=_step2.value;results[conflictingIndexes.shift()]=retriedResult}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}case 18:return _context.a(2,results)}},_callee,null,[[5,14,15,16]])}))}this.post=this.put=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(document,options){var result;return _regenerator().w(function(_context2){while(1)switch(_context2.n){case 0:_context2.n=1;return _this.bulkDocs([document],options);case 1:result=_context2.v[0];if(!(result!==null&&result!==void 0&&result.name)){_context2.n=2;break}throw result;case 2:return _context2.a(2,result)}},_callee2)}));this.remove=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(id,revision){return _regenerator().w(function(_context3){while(1)switch(_context3.n){case 0:return _context3.a(2,_this.put(_defineProperty(_defineProperty(_defineProperty({},idName,id),revisionName,revision),deletedName,true)))}},_callee3)}));if(this.putAttachment)this.putAttachment=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(id,attachmentName,revisionOrAttachment,attachmentOrType,type){var _ref5,_type;var attachment,revision;return _regenerator().w(function(_context4){while(1)switch(_context4.n){case 0:if(typeof revisionOrAttachment==="string"){attachment=attachmentOrType;revision=revisionOrAttachment}else{attachment=revisionOrAttachment;revision="0-latest"}return _context4.a(2,_this.put(_defineProperty(_defineProperty(_defineProperty({},idName,id),revisionName,revision),attachmentsPropertyName,_defineProperty({},attachmentName,{/*
80
+ NOTE: We only need to set a content type to
81
+ avoid getting a warning.
82
+ */// eslint-disable-next-line camelcase
83
+ content_type:(_ref5=(_type=attachment.type)!==null&&_type!==void 0?_type:type)!==null&&_ref5!==void 0?_ref5:"application/octet-stream",data:attachment}))))}},_callee4)}));if(this.removeAttachment)this.removeAttachment=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(id,attachmentName,revision){return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:return _context5.a(2,_this.put(_defineProperty(_defineProperty(_defineProperty({},idName,id),revisionName,revision),attachmentsPropertyName,_defineProperty({},attachmentName,{/*
84
+ NOTE: We only need to set a content type to
85
+ avoid getting a warning.
86
+ */// eslint-disable-next-line camelcase
87
+ content_type:"application/octet-stream",data:null}))))}},_callee5)}))}}};// region utility functions
88
+ var removeDeprecatedIndexes=/*#__PURE__*/function(){var _removeDeprecatedIndexes=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(connection,models,modelConfiguration){var genericIndexes,_iterator3,_step3,index,exists,_i,_Object$entries,_Object$entries$_i,modelName,model,_i2,_determineGenericInde,name,_t4;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:_context6.n=1;return connection.getIndexes();case 1:genericIndexes=_context6.v.indexes.filter(function(index){return index.name.endsWith("-GenericIndex")});_iterator3=_createForOfIteratorHelper(genericIndexes);_context6.p=2;_iterator3.s();case 3:if((_step3=_iterator3.n()).done){_context6.n=8;break}index=_step3.value;exists=false;_i=0,_Object$entries=Object.entries(models);case 4:if(!(_i<_Object$entries.length)){_context6.n=6;break}_Object$entries$_i=_slicedToArray(_Object$entries[_i],2),modelName=_Object$entries$_i[0],model=_Object$entries$_i[1];if(!index.name.startsWith("".concat(modelName,"-"))){_context6.n=5;break}for(_i2=0,_determineGenericInde=determineGenericIndexablePropertyNames(modelConfiguration,model);_i2<_determineGenericInde.length;_i2++){name=_determineGenericInde[_i2];if(["".concat(modelName,"-").concat(name,"-GenericIndex"),"".concat(modelName,"-GenericIndex")].includes(index.name))exists=true}return _context6.a(3,6);case 5:_i++;_context6.n=4;break;case 6:if(exists){_context6.n=7;break}_context6.n=7;return connection.deleteIndex(index);case 7:_context6.n=3;break;case 8:_context6.n=10;break;case 9:_context6.p=9;_t4=_context6.v;_iterator3.e(_t4);case 10:_context6.p=10;_iterator3.f();return _context6.f(10);case 11:return _context6.a(2)}},_callee6,null,[[2,9,10,11]])}));function removeDeprecatedIndexes(_x12,_x13,_x14){return _removeDeprecatedIndexes.apply(this,arguments)}return removeDeprecatedIndexes}();/**
89
+ * Converts internal declarative database connector configuration object
90
+ * into a database compatible one.
91
+ * @param configuration - Connector configuration object.
92
+ * @param abortControllerStack - Stack to put abort signals to. They will be
93
+ * shifted and used for fetch calls.
94
+ * @returns Database compatible configuration object.
95
+ */var getConnectorOptions=function getConnectorOptions(configuration,abortControllerStack){/*
96
+ NOTE: We convert given fetch options into a fetch function wrapper
97
+ which is than accepted by pouchdb's api.
98
+ */var getOptions=function getOptions(options){var _abortControllerStack;if(options===void 0){options={}}options=(0,external_clientnode_.extend)(true,(0,external_clientnode_.copy)(configuration.fetch),options);if(Array.isArray(abortControllerStack)&&abortControllerStack.length>0)options.signal=(_abortControllerStack=abortControllerStack.pop())===null||_abortControllerStack===void 0?void 0:_abortControllerStack.controller.signal;return options};var KNOWN_ERRORS=new Map([[408,"Request Timeout"],[425,"Too Early"],[429,"Too Many Requests"],[502,"Bad Gateway"],[503,"Service Unavailable"],[504,"Gateway Timeout"]]);return _objectSpread(_objectSpread({},configuration),{},{fetch:function fetch(url,options){var _configuration$fetchI=configuration.fetchInterceptor,numberOfRetries=_configuration$fetchI.numberOfRetries,retryIntervalInSeconds=_configuration$fetchI.retryIntervalInSeconds,exponentialBackoff=_configuration$fetchI.exponentialBackoff,maximumRetryIntervallInSeconds=_configuration$fetchI.maximumRetryIntervallInSeconds;// Provides a retry mechanism with configurable delay mechanism.
99
+ var $result=__WEBPACK_EXTERNAL_MODULE_rxjs_fetch_acb1bba5_fromFetch__(url,getOptions(options)).pipe(__WEBPACK_EXTERNAL_MODULE_rxjs_map__(function(response){if(KNOWN_ERRORS.has(response.status))// eslint-disable-next-line no-throw-literal
100
+ throw response;return response}),__WEBPACK_EXTERNAL_MODULE_rxjs_retry__({count:numberOfRetries,delay:function delay(error,retryCount){// Client side error will just be forwarded
101
+ if(typeof error.status!=="number")throw error;var httpError=error;if(httpError.headers.has("retry-after")){var retryValue=httpError.headers.get("retry-after");if(typeof retryValue==="string"){var intervallInSeconds=parseInt(retryValue);if(String(intervallInSeconds)===retryValue){log.info("Retry in ".concat(retryValue," seconds"),"according to given retry value.");// We interpret value as seconds.
102
+ return __WEBPACK_EXTERNAL_MODULE_rxjs_timer__(intervallInSeconds*1000)}var futureRetryMoment=new Date(retryValue);if(!isNaN(futureRetryMoment.getTime())){var now=new Date;if(now<futureRetryMoment){if(maximumRetryIntervallInSeconds<(futureRetryMoment.getTime()-now.getTime())/1000){log.info("Retry at",futureRetryMoment.toUTCString(),"according to given retry","value.");return __WEBPACK_EXTERNAL_MODULE_rxjs_timer__(futureRetryMoment)}log.warn("The recommended retry attempt is",futureRetryMoment.toUTCString(),"further in the future than the","configured maximum wait time of",maximumRetryIntervallInSeconds,"seconds.")}else log.warn("Given retry time recommendation","from server is in the past and","has to be ignored therefore.")}}}var delayInSeconds=exponentialBackoff?Math.pow(2,retryCount-1)*retryIntervalInSeconds:retryIntervalInSeconds;return __WEBPACK_EXTERNAL_MODULE_rxjs_timer__(Math.min(delayInSeconds,maximumRetryIntervallInSeconds)*1000)}}));return __WEBPACK_EXTERNAL_MODULE_rxjs_lastValueFrom__($result)}})};/**
103
+ * Determines a representation for given plain object.
104
+ * @param object - Object to represent.
105
+ * @param maximumRepresentationTryLength - Maximum representation string to
106
+ * process.
107
+ * @param maximumRepresentationLength - Maximum length of returned
108
+ * representation.
109
+ * @returns Representation string.
110
+ */var mayStripRepresentation=function mayStripRepresentation(object,maximumRepresentationTryLength,maximumRepresentationLength){var representation=(0,external_clientnode_.represent)(object);if(representation.length<=maximumRepresentationTryLength){if(representation.length>maximumRepresentationLength)return representation.substring(0,maximumRepresentationLength-"...".length)+"..."}else return"DOCUMENT IS TOO BIG TO REPRESENT";return representation};/**
111
+ * Updates/creates a design document in database with a validation function
112
+ * set to given code.
113
+ * @param databaseConnection - Database connection to use for document
114
+ * updates.
115
+ * @param documentName - Design document name.
116
+ * @param documentData - Design document data.
117
+ * @param description - Used to produce semantic logging messages.
118
+ * @param doLogging - Enables logging.
119
+ * @param idName - Property name for ids.
120
+ * @param revisionName - Property name for revisions.
121
+ * @param designDocumentNamePrefix - Document name prefix indicating deign
122
+ * documents.
123
+ * @returns Promise which will be resolved after given document has updated
124
+ * successfully.
125
+ */var ensureValidationDocumentPresence=/*#__PURE__*/function(){var _ensureValidationDocumentPresence=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(databaseConnection,documentName,documentData,description,doLogging,idName,revisionName,designDocumentNamePrefix){var newDocument,oldDocument,_t5,_t6;return _regenerator().w(function(_context7){while(1)switch(_context7.p=_context7.n){case 0:if(doLogging===void 0){doLogging=true}if(idName===void 0){idName="_id"}if(revisionName===void 0){revisionName="_rev"}if(designDocumentNamePrefix===void 0){designDocumentNamePrefix="_design/"}newDocument=_objectSpread(_defineProperty(_defineProperty(_defineProperty({},idName,"".concat(designDocumentNamePrefix).concat(documentName)),"language","javascript"),"version",package_0/* version */.rE),documentData);_context7.p=1;_context7.n=2;return databaseConnection.get("".concat(designDocumentNamePrefix).concat(documentName));case 2:oldDocument=_context7.v;newDocument[revisionName]=oldDocument[revisionName];_context7.n=3;return databaseConnection.put(newDocument);case 3:if(doLogging)log.info("".concat(description," updated."));_context7.n=8;break;case 4:_context7.p=4;_t5=_context7.v;if(doLogging)if(_t5.error==="not_found"||_t5.name==="not_found"||_t5.message==="missing"||_t5.reason==="missing")log.info("".concat(description," not available. Create new one."));else log.info("".concat(description," couldn't be updated:"),"\"".concat((0,external_clientnode_.represent)(_t5),"\" create new one."));_context7.p=5;_context7.n=6;return databaseConnection.put(newDocument);case 6:if(doLogging)log.info("".concat(description," installed/updated."));_context7.n=8;break;case 7:_context7.p=7;_t6=_context7.v;throw new Error("".concat(description," couldn't be installed/updated: ")+"\"".concat((0,external_clientnode_.represent)(_t6),"\"."),{cause:_t6});case 8:return _context7.a(2)}},_callee7,null,[[5,7],[1,4]])}));function ensureValidationDocumentPresence(_x15,_x16,_x17,_x18,_x19,_x20,_x21,_x22){return _ensureValidationDocumentPresence.apply(this,arguments)}return ensureValidationDocumentPresence}();/**
126
+ * Initializes a database connection instance.
127
+ * @param services - An object with stored service instances.
128
+ * @param configuration - Mutable by plugins extended configuration object.
129
+ * @param checkForDatabaseReachability - Indicates whether to check for
130
+ * reachability of newly created database.
131
+ * @returns Given and extended object of services.
132
+ */var initializeConnection=/*#__PURE__*/function(){var _initializeConnection=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(services,configuration,checkForDatabaseReachability){var couchdb,config,url,_t7;return _regenerator().w(function(_context8){while(1)switch(_context8.p=_context8.n){case 0:if(checkForDatabaseReachability===void 0){checkForDatabaseReachability=true}couchdb=services.couchdb;config=configuration.couchdb;url=getEffectiveURL(config);/*
133
+ NOTE: We have to connect remotely for a memory based database to avoid
134
+ having multiple ones created per connector instance.
135
+ */if(services.couchdb.server.expressPouchDBInstance){// @ts-expect-error "pouchdb-validation" does not have a typings yet.
136
+ couchdb.connection=new couchdb.connector(config.databaseName,couchdb.server.runner.configuration);couchdb.connection.installValidationMethods()}else// @ts-expect-error "pouchdb-validation" does not have a typings yet.
137
+ couchdb.connection=new couchdb.connector(url,getConnectorOptions(config.connector));couchdb.connection.installCouchDBWebNodePlugin("backend");couchdb.connection.setMaxListeners(Infinity);// region ensure database presence
138
+ if(!checkForDatabaseReachability){_context8.n=4;break}_context8.p=1;_context8.n=2;return couchdb.connection.allDocs({limit:1});case 2:_context8.n=4;break;case 3:_context8.p=3;_t7=_context8.v;throw new Error("Database has not been installed yet: ".concat((0,external_clientnode_.represent)(_t7)),{cause:_t7});case 4:return _context8.a(2,services)}},_callee8,null,[[1,3]])}));function initializeConnection(_x23,_x24,_x25){return _initializeConnection.apply(this,arguments)}return initializeConnection}();/**
139
+ * Determines the effective database URL to connect to based on given
140
+ * configuration.
141
+ * @param configuration - Couchdb configuration object.
142
+ * @param withDatabase - Indicates whether the URL should contain the database
143
+ * name or not.
144
+ * @param withCredentials - Indicates whether the URL should contain the
145
+ * credentials or not.
146
+ * @returns The effective URL.
147
+ */var getEffectiveURL=function getEffectiveURL(configuration,withDatabase,withCredentials){if(withDatabase===void 0){withDatabase=true}if(withCredentials===void 0){withCredentials=false}var urlTemplate=/^https?:\/\//.test(configuration.url)?configuration.url:"http://{1}".concat(configuration.runner.host,":")+String(configuration.runner.port);return (0,external_clientnode_.format)(urlTemplate,withCredentials?"".concat(configuration.admin.name,":")+"".concat(configuration.admin.password,"@"):"")+(withDatabase?"/".concat(configuration.databaseName):"")};/**
148
+ * Waits for given promise to be resolved or given timeout has been exceeded.
149
+ * @param promise - Promise to wait for.
150
+ * @param timeoutInSeconds - Timeout in seconds.
151
+ * @param description - Used to produce semantic logging messages.
152
+ * @returns A promise which will be resolved after given promise is resolved or
153
+ * given timeout has been exceeded.
154
+ */var waitWithTimeout=function waitWithTimeout(promise,timeoutInSeconds,description){var timeoutExceeded=true;return Promise.race([promise.then(function(){timeoutExceeded=false}),(0,external_clientnode_.timeout)(timeoutInSeconds*1000).then(function(){if(timeoutExceeded)log.warn("Timeout of","".concat(String(timeoutInSeconds),"."),"seconds reached while waiting for ".concat(description,"."))})])};// endregion
155
+ // region model
156
+ /**
157
+ * Determines a mapping of all models to roles who are allowed to edit
158
+ * corresponding model instances.
159
+ * @param modelConfiguration - Model specification object.
160
+ * @returns The mapping object.
161
+ */var determineModelRolesMapping=function determineModelRolesMapping(modelConfiguration){var _modelConfiguration$p=modelConfiguration.property.name.special,rolePropertyName=_modelConfiguration$p.role,attachmentsPropertyName=_modelConfiguration$p.attachment;var modelRolesMapping={};var models=applyModelsInheritance(modelConfiguration);for(var _i3=0,_Object$entries2=Object.entries(models);_i3<_Object$entries2.length;_i3++){var _Object$entries2$_i=_slicedToArray(_Object$entries2[_i3],2),modelName=_Object$entries2$_i[0],model=_Object$entries2$_i[1];if(model[rolePropertyName]){modelRolesMapping[modelName]=_objectSpread({properties:{}},normalizeRoles(model[rolePropertyName]));for(var _i4=0,_Object$entries3=Object.entries(model);_i4<_Object$entries3.length;_i4++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i4],2),name=_Object$entries3$_i[0],property=_Object$entries3$_i[1];if((0,external_clientnode_.isObject)(property))if(name===attachmentsPropertyName){modelRolesMapping[modelName].attachments={};for(var _i5=0,_Object$entries4=Object.entries(property);_i5<_Object$entries4.length;_i5++){var _Object$entries4$_i=_slicedToArray(_Object$entries4[_i5],2),fileDescription=_Object$entries4$_i[0],fileDefinition=_Object$entries4$_i[1];if(fileDefinition.roles)modelRolesMapping[modelName].attachments[fileDescription]=normalizeRoles(fileDefinition.roles)}}else if(property.roles)modelRolesMapping[modelName].properties[name]=normalizeRoles(property.roles)}}}return modelRolesMapping};/**
162
+ * Determines whether given value of a model is a property specification.
163
+ * @param value - Value to analyze.
164
+ * @returns Boolean indicating the case.
165
+ */var isPropertyDefinition=function isPropertyDefinition(value){return (0,external_clientnode_.isObject)(value)};/**
166
+ * Determines all property names which are indexable in a generic manner.
167
+ * @param modelConfiguration - Model specification object.
168
+ * @param model - Model to determine property names from.
169
+ * @returns The mapping object.
170
+ */var determineGenericIndexablePropertyNames=function determineGenericIndexablePropertyNames(modelConfiguration,model){var specialNames=modelConfiguration.property.name.special;return Object.keys(model).filter(function(name){var specification=model[name];return isPropertyDefinition(specification)&&Object.prototype.hasOwnProperty.call(specification,"index")&&specification.index||isPropertyDefinition(specification)&&!(Object.prototype.hasOwnProperty.call(specification,"index")&&!specification.index||modelConfiguration.property.name.reserved.concat(specialNames.additional,specialNames.role,specialNames.attachment,specialNames.conflict,specialNames.constraint.execution,specialNames.constraint.expression,specialNames.deleted,specialNames.deletedConflict,specialNames.extend,specialNames.maximumAggregatedSize,specialNames.minimumAggregatedSize,specialNames.oldType,specialNames.id,specialNames.revision,specialNames.revisions,specialNames.revisionsInformation,specialNames.type,specialNames.updateStrategy).includes(name)||specification.type&&(typeof specification.type==="string"&&specification.type.endsWith("[]")||Array.isArray(specification.type)&&specification.type.length&&Array.isArray(specification.type[0])||Object.prototype.hasOwnProperty.call(modelConfiguration.entities,specification.type)))}).concat([specialNames.id,specialNames.revision]).sort()};/**
171
+ * Extend given model with all specified one.
172
+ * @param model - Model to extend.
173
+ * @param modelConfiguration - Model specification object.
174
+ * @param _name - Model name to extend. Only needed for debugging purposes.
175
+ * @returns Given model in extended version.
176
+ */var _applyModelInheritance=function applyModelInheritance(model,modelConfiguration,_name){if(_name===void 0){_name="in-place"}var models=modelConfiguration.entities;var extendPropertyName=modelConfiguration.property.name.special.extend;if(Object.prototype.hasOwnProperty.call(models,"_base"))if(Object.prototype.hasOwnProperty.call(model,extendPropertyName)&&model[extendPropertyName]&&![].concat(model[extendPropertyName]).includes("_base"))model[extendPropertyName]=["_base"].concat(model[extendPropertyName]);else model[extendPropertyName]="_base";if(Object.prototype.hasOwnProperty.call(model,extendPropertyName)){var originallyDeclaredExtensions=[].concat(model[extendPropertyName]);var _iterator4=_createForOfIteratorHelper(originallyDeclaredExtensions),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var modelNameToExtend=_step4.value;if(modelNameToExtend!=="_base")_applyModelInheritance(models[modelNameToExtend],modelConfiguration,modelNameToExtend);/*
177
+ NOTE: We need to merge into model to change the given object
178
+ in-place. Furthermore, we have to copy the initial model before
179
+ merging it finally to avoid having the inherited overwrites in
180
+ the final model object as well.
181
+ */(0,external_clientnode_.extend)(true,model,models[modelNameToExtend],(0,external_clientnode_.copy)(model));model[extendPropertyName]=originallyDeclaredExtensions}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}delete model[extendPropertyName]}applyDefaultPropertyConfigurations(model,modelConfiguration);return model};/**
182
+ * Apply default property definitions to given model.
183
+ * @param model - Model to extends its properties.
184
+ * @param modelConfiguration - Model configuration to take into account.
185
+ * @returns Extended model.
186
+ */var applyDefaultPropertyConfigurations=function applyDefaultPropertyConfigurations(model,modelConfiguration){var specialNames=modelConfiguration.property.name.special;for(var _i6=0,_Object$entries5=Object.entries(model);_i6<_Object$entries5.length;_i6++){var _Object$entries5$_i=_slicedToArray(_Object$entries5[_i6],2),name=_Object$entries5$_i[0],propertyDefinition=_Object$entries5$_i[1];if(name===specialNames.attachment){var fileDefinition=propertyDefinition;for(var _i7=0,_Object$entries6=Object.entries(fileDefinition);_i7<_Object$entries6.length;_i7++){var _Object$entries6$_i=_slicedToArray(_Object$entries6[_i7],2),type=_Object$entries6$_i[0],value=_Object$entries6$_i[1];fileDefinition[type]=(0,external_clientnode_.extend)(true,(0,external_clientnode_.copy)(modelConfiguration.property.defaultDefinition),value)}}else if(![specialNames.role,specialNames.constraint.execution,specialNames.constraint.expression,specialNames.extend,specialNames.maximumAggregatedSize,specialNames.minimumAggregatedSize,specialNames.oldType].includes(name)){var property=(0,external_clientnode_.extend)(true,(0,external_clientnode_.copy)(modelConfiguration.property.defaultDefinition),propertyDefinition);model[name]=property;var types=[].concat(property.type);var _iterator5=_createForOfIteratorHelper(types),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var _type2=_step5.value;if(!Array.isArray(_type2)&&_typeof(_type2)==="object")property.type=_applyModelInheritance(_type2,modelConfiguration)}}catch(err){_iterator5.e(err)}finally{_iterator5.f()}}}return model};/**
187
+ * Extend default specification with specific one.
188
+ * @param modelConfiguration - Model specification object.
189
+ * @returns Models with extended specific specifications.
190
+ */var applyModelsInheritance=function applyModelsInheritance(modelConfiguration){var models=modelConfiguration.entities;var typePattern=modelConfiguration.property.name.typePattern;for(var _i8=0,_Object$keys=Object.keys(models);_i8<_Object$keys.length;_i8++){var modelName=_Object$keys[_i8];if(!(new RegExp(typePattern.public).test(modelName)||new RegExp(typePattern.private).test(modelName)))throw new Error("Model names have to match "+"\"".concat(typePattern.public,"\" or \"").concat(typePattern.private,"\" for ")+"xprivate one (given name: \"".concat(modelName,"\")."));if(modelName!=="_base")_applyModelInheritance(models[modelName],modelConfiguration,modelName)}return models};/**
191
+ * Convert given roles to its normalized representation.
192
+ * @param roles - Unstructured role's description.
193
+ * @returns Normalized roles representation.
194
+ */var normalizeRoles=function normalizeRoles(roles){if(Array.isArray(roles))return{read:roles,write:roles};if(_typeof(roles)==="object"){var result={read:[],write:[]};for(var _i9=0,_Object$keys2=Object.keys(result);_i9<_Object$keys2.length;_i9++){var type=_Object$keys2[_i9];if(Object.prototype.hasOwnProperty.call(roles,type)){var operationRoles=roles[type];if(Array.isArray(operationRoles))result[type]=operationRoles;else if(typeof operationRoles==="string")result[type]=[operationRoles]}}return result}return{read:[roles],write:[roles]}};// endregion
195
+
196
+ /***/ }),
197
+ /* 2 */,
198
+ /* 3 */
199
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
200
+
201
+ const x = (y) => {
202
+ const x = {}; __webpack_require__.d(x, y); return x
203
+ }
204
+ const y = (x) => (() => (x))
205
+ module.exports = x({ ["mkdir"]: () => (__WEBPACK_EXTERNAL_MODULE_fs_promises_cc1b69f3__.mkdir), ["readFile"]: () => (__WEBPACK_EXTERNAL_MODULE_fs_promises_cc1b69f3__.readFile), ["unlink"]: () => (__WEBPACK_EXTERNAL_MODULE_fs_promises_cc1b69f3__.unlink), ["writeFile"]: () => (__WEBPACK_EXTERNAL_MODULE_fs_promises_cc1b69f3__.writeFile) });
206
+
207
+ /***/ }),
208
+ /* 4 */
209
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
210
+
211
+ const x = (y) => {
212
+ const x = {}; __webpack_require__.d(x, y); return x
213
+ }
214
+ const y = (x) => (() => (x))
215
+ module.exports = x({ ["basename"]: () => (__WEBPACK_EXTERNAL_MODULE_path__.basename), ["dirname"]: () => (__WEBPACK_EXTERNAL_MODULE_path__.dirname), ["extname"]: () => (__WEBPACK_EXTERNAL_MODULE_path__.extname), ["resolve"]: () => (__WEBPACK_EXTERNAL_MODULE_path__.resolve) });
216
+
217
+ /***/ }),
218
+ /* 5 */
219
+ /***/ ((module) => {
220
+
221
+ module.exports = /*#__PURE__*/JSON.parse('{"rE":"2.0.840","fz":{"Z":{"ge":{"MZ":{"U":{"i0":{"additional":"_additional","role":"_roles","attachment":"_attachments","conflict":"_conflicts","constraint":{"execution":"_constraintExecutions","expression":"_constraintExpressions"},"create":{"execution":"_createExecution","expression":"_createExecution"},"deleted":"_deleted","deletedConflict":"_deleted_conflicts","designDocumentNamePrefix":"_design/","extend":"_extends","id":"_id","localSequence":"_local_seq","maximumAggregatedSize":"_maximumAggregatedSize","minimumAggregatedSize":"_minimumAggregatedSize","oldType":"_oldType","revision":"_rev","revisions":"_revisions","revisionsInformation":"_revs_info","updateStrategy":"_updateStrategy","ignoreIfNoOldDocument":"_ignoreIfNoOldDocument","type":"-type","update":{"execution":"_updateExecution","expression":"_updateExpression"}}}}}}}}');
222
+
223
+ /***/ }),
224
+ /* 6 */
225
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
226
+
227
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
228
+ /* harmony export */ Gq: () => (/* binding */ _authorize),
229
+ /* harmony export */ Te: () => (/* binding */ validateDocumentUpdate)
230
+ /* harmony export */ });
231
+ /* unused harmony exports log, databaseHelper */
232
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
233
+ /* harmony import */ var _package_json__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5);
234
+ // -*- coding: utf-8 -*-
235
+ /** @module databaseHelper *//* !
236
+ region header
237
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
238
+
239
+ License
240
+ -------
241
+
242
+ This library written by Torben Sickert stands under a creative commons
243
+ naming 3.0 unported license.
244
+ See https://creativecommons.org/licenses/by/3.0/deed.de
245
+ endregion
246
+ */// region imports
247
+ function _toConsumableArray(r){return _arrayWithoutHoles(r)||_iterableToArray(r)||_unsupportedIterableToArray(r)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArray(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}function _arrayWithoutHoles(r){if(Array.isArray(r))return _arrayLikeToArray(r)}function _construct(t,e,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,e);var p=new(t.bind.apply(t,o));return r&&_setPrototypeOf(p,r.prototype),p}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!t})()}function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)};// endregion
248
+ /**
249
+ * WebNode plugin interface with all provided hooks.
250
+ */var log=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Logger({name:"web-node.couchdb.database"});/**
251
+ * Authorizes given document update against given mapping of allowed roles for
252
+ * writing into corresponding model instances.
253
+ * @param newDocument - Updated document.
254
+ * @param oldDocument - If an existing document should be updated its given
255
+ * here.
256
+ * @param userContext - Contains meta information about currently acting user.
257
+ * @param securitySettings - Database security settings.
258
+ * @param modelRolesMapping - Allowed roles for given models.
259
+ * @param read - Indicates whether a read or write of given document should be
260
+ * authorized or not.
261
+ * @param specialNames - Special names configuration.
262
+ * @param contextPath - Path of properties leading to current document.
263
+ * @param parentRoles - Roles of parent object when called recursively.
264
+ * @param toJSON - JSON stringifier.
265
+ * @param fromJSON - JSON parser.
266
+ * @returns Throws an exception if authorization is not accepted and "true"
267
+ * otherwise.
268
+ */var _authorize=function authorize(newDocument,oldDocument,userContext,securitySettings,modelRolesMapping,read,specialNames,contextPath,parentRoles,toJSON,fromJSON){var _ref,_userContext$roles,_userContext$name2;if(oldDocument===void 0){oldDocument=null}if(userContext===void 0){userContext={}}if(securitySettings===void 0){securitySettings={admins:{names:[],roles:[]},members:{names:[],roles:[]}}}if(read===void 0){read=false}if(specialNames===void 0){specialNames=_package_json__WEBPACK_IMPORTED_MODULE_1__/* .webNode.couchdb.model.property.name.special */ .fz.Z.ge.MZ.U.i0}if(contextPath===void 0){contextPath=[]}if(parentRoles===void 0){parentRoles=[]}// region ensure needed environment
269
+ var throwError=function throwError(message,type,additionalErrorData){if(type===void 0){type="forbidden"}if(additionalErrorData===void 0){additionalErrorData={}}/*
270
+ eslint-disable no-throw-literal,@typescript-eslint/only-throw-error
271
+ */throw _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},type,message),"error",type),"message",message),"name",type),additionalErrorData);/*
272
+ eslint-enable no-throw-literal,@typescript-eslint/only-throw-error
273
+ */};/// region json parser and serializer determination
274
+ var serializeData;if(toJSON)serializeData=toJSON;else if(typeof JSON!=="undefined"&&Object.prototype.hasOwnProperty.call(JSON,"stringify"))serializeData=function serializeData(object){return JSON.stringify(object,null,4)};else throwError("Needed json serializer is not available.");var parseJSON;if(fromJSON)parseJSON=fromJSON;else if(typeof JSON!=="undefined"&&Object.prototype.hasOwnProperty.call(JSON,"parse"))parseJSON=function parseJSON(object){return JSON.parse(object)};else throwError("Needed json parser is not available.");/// endregion
275
+ var deepCopy=function deepCopy(data){return parseJSON(serializeData(data))};var _specialNames=specialNames,idPropertyName=_specialNames.id,typePropertyName=_specialNames.type,attachmentsPropertyName=_specialNames.attachment,designDocumentNamePrefix=_specialNames.designDocumentNamePrefix,deletedPropertyName=_specialNames.deleted;var modelType=(_ref=newDocument[typePropertyName])!==null&&_ref!==void 0?_ref:oldDocument&&oldDocument[typePropertyName];// endregion
276
+ /*
277
+ NOTE: Special documents and change sequences are not checked further
278
+ since there is no specified model.
279
+ If no special document given but missing type property further
280
+ validation will complain.
281
+ */if(!modelType)return true;var operationType=read?"read":"write";var baseRoles={properties:{},read:["_admin","readonlyadmin"],write:["_admin"]};// A "readonlymember" is allowed to read all but design documents.
282
+ if(!(Object.prototype.hasOwnProperty.call(newDocument,idPropertyName)&&newDocument[idPropertyName].startsWith(designDocumentNamePrefix)&&!baseRoles.read.includes("readonlymember")))baseRoles.read.push("readonlymember");if(!("name"in userContext))userContext.name="\"unknown\"";var userRolesDescription;var relevantRoles=[];var relatedContextPathDescription="You are trying to ".concat(operationType," object of type \"").concat(modelType,"\".");if((_userContext$roles=userContext.roles)!==null&&_userContext$roles!==void 0&&_userContext$roles.length){var _userContext$name;var modelRoles=deepCopy(baseRoles);var userRoles=userContext.roles;// region determine model specific roles
283
+ var relevantModelRoles=modelRoles[operationType];if(modelRolesMapping&&modelType&&Object.prototype.hasOwnProperty.call(modelRolesMapping,modelType)){var extendWithBasicRoles=function extendWithBasicRoles(roles){var _iterator=_createForOfIteratorHelper(["read","write"]),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var operation=_step.value;roles[operation]=roles[operation].concat(baseRoles[operation])}}catch(err){_iterator.e(err)}finally{_iterator.f()}return roles};modelRoles=extendWithBasicRoles(deepCopy(modelRolesMapping[modelType]));if(modelRoles.attachments)for(var _i=0,_Object$values=Object.values(modelRoles.attachments);_i<_Object$values.length;_i++){var roles=_Object$values[_i];extendWithBasicRoles(roles)}for(var _i2=0,_Object$values2=Object.values(modelRoles.properties);_i2<_Object$values2.length;_i2++){var _roles=_Object$values2[_i2];extendWithBasicRoles(_roles)}relevantModelRoles=modelRoles[operationType]}else if(parentRoles.length)relevantModelRoles=parentRoles;// endregion
284
+ var checkProperty=function checkProperty(name,propertyRoles){if(propertyRoles===void 0){propertyRoles={}}relevantRoles=Object.prototype.hasOwnProperty.call(propertyRoles,name)?propertyRoles[name][operationType]:relevantModelRoles;var _iterator2=_createForOfIteratorHelper(userRoles),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var userRole=_step2.value;if(relevantRoles.includes(userRole))return true}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}return false};var documentToAnalyze=newDocument[deletedPropertyName]?oldDocument!==null&&oldDocument!==void 0?oldDocument:{}:newDocument;var authorized=true;for(var _i3=0,_Object$entries=Object.entries(documentToAnalyze);_i3<_Object$entries.length;_i3++){var _Object$entries$_i=_slicedToArray(_Object$entries[_i3],2),name=_Object$entries$_i[0],value=_Object$entries$_i[1];var localContextPath=contextPath.concat(name);relatedContextPathDescription="You are trying to ".concat(operationType," property ")+"\"".concat(localContextPath.join("."),"\" of object having type ")+"\"".concat(modelType,"\".");authorized=false;if(name===attachmentsPropertyName){authorized=true;for(var _i4=0,_Object$keys=Object.keys(value);_i4<_Object$keys.length;_i4++){var fileDescription=_Object$keys[_i4];var _contextPath=localContextPath.concat(fileDescription);relatedContextPathDescription="You are trying to ".concat(operationType," file on ")+"property \"".concat(_contextPath.join("."),"\" of object ")+"having type \"".concat(modelType,"\".");authorized=checkProperty(fileDescription,modelRoles.attachments);if(!authorized)break}}else if(checkProperty(name,modelRoles.properties)){if(value!==null&&_typeof(value)==="object"&&Object.prototype.hasOwnProperty.call(value,typePropertyName))_authorize(value,oldDocument&&oldDocument[name]||null,userContext,securitySettings,modelRolesMapping,read,specialNames,localContextPath,Object.prototype.hasOwnProperty.call(modelRoles.properties,name)?modelRoles.properties[name][operationType]:relevantModelRoles);authorized=true}if(!authorized)break}if(authorized)return true;userRolesDescription="Current user \"".concat((_userContext$name=userContext.name)!==null&&_userContext$name!==void 0?_userContext$name:"unknown","\" owns the ")+"following roles: \"".concat(userContext.roles.join("\", \""),"\"");//
285
+ }else userRolesDescription="Current user \"".concat((_userContext$name2=userContext.name)!==null&&_userContext$name2!==void 0?_userContext$name2:"unknown","\" doesn't own ")+"any role";var message=relatedContextPathDescription+" Only users with a least one of these roles are allowed to "+"perform requested ".concat(operationType," action: \"")+[].concat(relevantRoles).join("\", \"")+"\". ".concat(userRolesDescription,".");/* eslint-disable @typescript-eslint/only-throw-error,no-throw-literal */throw{unauthorized:message,error:"unauthorized",message:message,name:"unauthorized"};/* eslint-enable @typescript-eslint/only-throw-error,no-throw-literal */};/**
286
+ * Represents a design document validation function for given model
287
+ * specification.
288
+ * @param newDocument - Updated document.
289
+ * @param oldDocument - If an existing document should be updated its given
290
+ * here.
291
+ * @param userContext - Contains meta information about currently acting user.
292
+ * @param securitySettings - Database security settings.
293
+ * @param modelConfiguration - Model configuration object.
294
+ * @param models - Models specification object.
295
+ * @param checkPublicModelType - Indicates whether to public model types only.
296
+ * @param toJSON - JSON stringifier.
297
+ * @param fromJSON - JSON parser.
298
+ * @returns Modified given new document.
299
+ */var validateDocumentUpdate=function validateDocumentUpdate(newDocument,oldDocument,userContext,securitySettings,modelConfiguration,models,checkPublicModelType,toJSON,fromJSON){if(models===void 0){models={}}if(checkPublicModelType===void 0){checkPublicModelType=true}log.debug("Got new document",newDocument,"to update",oldDocument);// region ensure needed environment
300
+ var throwError=function throwError(message,type,additionalErrorData){if(type===void 0){type="forbidden"}if(additionalErrorData===void 0){additionalErrorData={}}/*
301
+ eslint-disable no-throw-literal,@typescript-eslint/only-throw-error
302
+ */throw _objectSpread(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},type,message),"error",type),"message",message),"name",type),additionalErrorData);/*
303
+ eslint-enable no-throw-literal,@typescript-eslint/only-throw-error
304
+ */};var now=new Date;var nowUTCTimestamp=Date.UTC(now.getUTCFullYear(),now.getUTCMonth(),now.getUTCDate(),now.getUTCHours(),now.getUTCMinutes(),now.getUTCSeconds(),now.getUTCMilliseconds())/1000;var saveDateTimeAsNumber=!modelConfiguration.dateTimeFormat.startsWith("iso");var specialNames=modelConfiguration.property.name.special;var idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type;if(oldDocument&&oldDocument[typeName]&&!newDocument[typeName])newDocument[typeName]=oldDocument[typeName];var id="";var revision="";var setDocumentEnvironment=function setDocumentEnvironment(){id=Object.prototype.hasOwnProperty.call(newDocument,idName)?newDocument[idName]:"";revision=Object.prototype.hasOwnProperty.call(newDocument,revisionName)?newDocument[revisionName]:""};setDocumentEnvironment();/*
305
+ NOTE: Needed to be able to validate user documents.
306
+
307
+ if (
308
+ newDocument.hasOwnProperty('type') &&
309
+ newDocument.type === 'user' &&
310
+ id.startsWith('org.couchdb.user:')
311
+ )
312
+ return newDocument
313
+ */if(Object.prototype.hasOwnProperty.call(securitySettings,modelConfiguration.property.name.validatedDocumentsCache)&&securitySettings[modelConfiguration.property.name.validatedDocumentsCache].has("".concat(id,"-").concat(revision))){securitySettings[modelConfiguration.property.name.validatedDocumentsCache].delete("".concat(id,"-").concat(revision));return newDocument}if(["0-latest","0-upsert"].includes(revision))if(oldDocument&&Object.prototype.hasOwnProperty.call(oldDocument,revisionName))revision=newDocument[revisionName]=oldDocument[revisionName];else if(revision==="0-latest")throwError("Revision: No old document available to update.");else delete newDocument[revisionName];/// region collect old model types to migrate.
314
+ var oldModelMapping={};if(modelConfiguration.updateStrategy==="migrate")for(var _i5=0,_Object$entries2=Object.entries(models);_i5<_Object$entries2.length;_i5++){var _Object$entries2$_i=_slicedToArray(_Object$entries2[_i5],2),name=_Object$entries2$_i[0],_model=_Object$entries2$_i[1];if(Object.prototype.hasOwnProperty.call(_model,specialNames.oldType)&&_model[specialNames.oldType]){var _iterator3=_createForOfIteratorHelper([].concat(_model[specialNames.oldType])),_step3;try{for(_iterator3.s();!(_step3=_iterator3.n()).done;){var oldName=_step3.value;oldModelMapping[oldName]=name}}catch(err){_iterator3.e(err)}finally{_iterator3.f()}}}/// endregion
315
+ /// region json parser and serializer determination
316
+ var serializeData;if(toJSON)serializeData=toJSON;else if(typeof JSON!=="undefined"&&Object.prototype.hasOwnProperty.call(JSON,"stringify"))serializeData=function serializeData(object){return JSON.stringify(object,null,4)};else throwError("Needed json serializer is not available.");var parseJSON;if(fromJSON)parseJSON=fromJSON;else if(typeof JSON!=="undefined"&&Object.prototype.hasOwnProperty.call(JSON,"parse"))parseJSON=function parseJSON(object){return JSON.parse(object)};else throwError("Needed json parser is not available.");/// endregion
317
+ // endregion
318
+ var specialPropertyNames=[specialNames.additional,specialNames.role,specialNames.constraint.execution,specialNames.constraint.expression,specialNames.create.execution,specialNames.create.expression,specialNames.extend,specialNames.maximumAggregatedSize,specialNames.minimumAggregatedSize,specialNames.oldType,specialNames.update.execution,specialNames.update.expression,specialNames.updateStrategy,specialNames.ignoreIfNoOldDocument];// region functions
319
+ /// region generic functions
320
+ var deepCopy=function deepCopy(data){return parseJSON(serializeData(data))};var originalNewDocument=deepCopy(newDocument);var determineTrimmedString=function determineTrimmedString(value){if(typeof value==="string")return value.trim();return""};var evaluate=function evaluate(givenExpression,isEvaluation,givenScope){if(isEvaluation===void 0){isEvaluation=false}if(givenScope===void 0){givenScope={}}var scope=_objectSpread(_objectSpread({},BASIC_SCOPE),{},{code:""},givenScope);scope.scope=scope;var expression=determineTrimmedString(givenExpression);if(expression){var code=(isEvaluation?"return ":"")+expression;// region determine scope
321
+ scope.code=code;var scopeNames=Object.keys(scope);// endregion
322
+ // region compile
323
+ var templateFunction;try{/* eslint-disable @typescript-eslint/no-implied-eval */templateFunction=_construct(Function,scopeNames.concat([code]));/* eslint-enable @typescript-eslint/no-implied-eval */}catch(error){throwError(serialize(error),"compilation",{code:code,error:error,scope:scope})}// endregion
324
+ // region run
325
+ var _result={code:code,result:undefined,scope:scope};try{// @ts-expect-error "templateFunction" can be not defined.
326
+ _result.result=templateFunction.apply(void 0,_toConsumableArray(scopeNames.map(function(name){return scope[name]})))}catch(error){throwError(serialize(error),"runtime",{code:code,error:error,scope:scope})}return _result;// endregion
327
+ }throwError("No expression to evaluate provided.","empty");return{code:scope.code,result:undefined,scope:scope}};var fileNameMatchesModelType=function fileNameMatchesModelType(typeName,fileName,fileType){if(fileType.fileName){if(fileType.fileName.value)return fileType.fileName.value===fileName;if(fileType.fileName.pattern)return[].concat(fileType.fileName.pattern).some(function(pattern){return new RegExp(pattern).test(fileName)})}return typeName===fileName};var getDateTime=function getDateTime(value){return typeof value==="number"?new Date(value*1000):new Date(value)};var getFileNameByPrefix=function getFileNameByPrefix(prefix,attachments){if(!attachments)attachments=newDocument[specialNames.attachment];if(prefix){for(var _i6=0,_Object$keys2=Object.keys(attachments);_i6<_Object$keys2.length;_i6++){var _name=_Object$keys2[_i6];if(_name.startsWith(prefix))return _name}}else{var keys=Object.keys(attachments);if(keys.length)return keys[0]}return null};var normalizeDateTime=function normalizeDateTime(value){if(saveDateTimeAsNumber){if(value!==null&&typeof value!=="number"){value=new Date(value);value=Date.UTC(value.getUTCFullYear(),value.getUTCMonth(),value.getUTCDate(),value.getUTCHours(),value.getUTCMinutes(),value.getUTCSeconds(),value.getUTCMilliseconds())/1000}}else if(value!==null){value=new Date(typeof value==="number"&&!isNaN(value)?value*1000:value);try{// Use ISO 8601 format to save date as string.
328
+ value=value.toISOString()}catch(_unused){// Ignore exception.
329
+ }}return value};var serialize=function serialize(value){return value instanceof Error?String(value):serializeData(value)};/// endregion
330
+ var isDefinedPropertyValue=function isDefinedPropertyValue(name,document){if(document===void 0){document=newDocument}return Object.prototype.hasOwnProperty.call(document,name)&&![null,undefined].includes(document[name])};var getEffectiveValue=function getEffectiveValue(name,localNewDocument,localOldDocument){if(localNewDocument===void 0){localNewDocument=originalNewDocument}if(localOldDocument===void 0){localOldDocument=oldDocument}return Object.prototype.hasOwnProperty.call(localNewDocument,name)?localNewDocument[name]:localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,name)?localOldDocument[name]:null};var attachmentWithPrefixExists=function attachmentWithPrefixExists(namePrefix,document){if(document===void 0){document=newDocument}if(Object.prototype.hasOwnProperty.call(document,specialNames.attachment)){var attachments=document[specialNames.attachment];var _name2=getFileNameByPrefix(namePrefix);if(_name2){var attachment=attachments[_name2];return Object.prototype.hasOwnProperty.call(attachment,"stub")&&attachment.stub||Object.prototype.hasOwnProperty.call(attachment,"data")&&![null,undefined].includes(attachment.data)}}return false};var checkModelType=function checkModelType(localNewDocument,localOldDocument){if(localOldDocument===void 0){localOldDocument=null}// region check for model type (optionally migrate them)
331
+ if(!Object.prototype.hasOwnProperty.call(localNewDocument,typeName))if(localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,typeName)&&["fillUp","migrate"].includes(modelConfiguration.updateStrategy))localNewDocument[typeName]=localOldDocument[typeName];else throwError("Type: You have to specify a model type via property "+"\"".concat(typeName,"\"."));if(checkPublicModelType&&!new RegExp(modelConfiguration.property.name.typePattern.public).test(localNewDocument[typeName]))throwError("TypeName: You have to specify a model type which "+"matches \""+modelConfiguration.property.name.typePattern.public+"\" as public type (given \""+"".concat(localNewDocument[typeName],"\")."));if(!Object.prototype.hasOwnProperty.call(models,localNewDocument[typeName]))if(Object.prototype.hasOwnProperty.call(oldModelMapping,localNewDocument[typeName]))localNewDocument[typeName]=oldModelMapping[localNewDocument[typeName]];else throwError("Model: Given model \""+"".concat(localNewDocument[typeName],"\" is not ")+"specified.");// endregion
332
+ };var _checkDocument=function checkDocument(localNewDocument,localOldDocument,modelName,model,parentNames,updateStrategy,ignoreIfNoOldDocument){if(localNewDocument===void 0){localNewDocument=newDocument}if(localOldDocument===void 0){localOldDocument=null}if(parentNames===void 0){parentNames=[]}if(updateStrategy===void 0){updateStrategy=modelConfiguration.updateStrategy}if(ignoreIfNoOldDocument===void 0){ignoreIfNoOldDocument=false}var pathDescription=parentNames.length?" in \"".concat(parentNames.join("\" -> \""),"\""):"";var changedPath=[];if(Object.prototype.hasOwnProperty.call(model,specialNames.updateStrategy))updateStrategy=model[specialNames.updateStrategy];if(Object.prototype.hasOwnProperty.call(newDocument,specialNames.updateStrategy)){updateStrategy=localNewDocument[specialNames.updateStrategy];delete localNewDocument[specialNames.updateStrategy]}if(Object.prototype.hasOwnProperty.call(newDocument,specialNames.ignoreIfNoOldDocument)){ignoreIfNoOldDocument=localNewDocument[specialNames.ignoreIfNoOldDocument];delete localNewDocument[specialNames.ignoreIfNoOldDocument]}if(ignoreIfNoOldDocument&&!oldDocument)throwError("NoChange: No old data given to an update request. "+"A deletion might happened before due to a race condition. "+"Update will be ignored.");var additionalPropertyDefinition=undefined;if(Object.prototype.hasOwnProperty.call(model,specialNames.additional)&&model[specialNames.additional])additionalPropertyDefinition=model[specialNames.additional];// region document specific functions
333
+ var checkPropertyConstraints=function checkPropertyConstraints(newValue,name,propertyDefinition,oldValue,types){if(types===void 0){types=["constraintExecution","constraintExpression"]}var localUpdateStrategy=propertyDefinition.updateStrategy||updateStrategy;var _iterator4=_createForOfIteratorHelper(types),_step4;try{for(_iterator4.s();!(_step4=_iterator4.n()).done;){var type=_step4.value;if(Object.prototype.hasOwnProperty.call(propertyDefinition,type)){var _result2=undefined;try{_result2=evaluate(// @ts-expect-error "prop...S..[type]" is optional.
334
+ propertyDefinition[type].evaluation,type.endsWith("Expression"),{checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,name:name,type:type,newDocument:localNewDocument,newValue:newValue,oldDocument:localOldDocument,oldValue:oldValue,parentNames:parentNames,pathDescription:pathDescription,propertyDefinition:propertyDefinition,updateStrategy:localUpdateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument})}catch(error){var _error$message,_error$message2;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(type,"\" has invalid")+" code \"".concat(error.code,"\": ")+"\"".concat((_error$message=error.message)!==null&&_error$message!==void 0?_error$message:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(type,"\" has throw an ")+"error with code \"".concat(error.code,"\": ")+"\"".concat((_error$message2=error.message)!==null&&_error$message2!==void 0?_error$message2:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}if(_result2&&!_result2.result){var _propertyDefinition$t;var description=determineTrimmedString((_propertyDefinition$t=propertyDefinition[type])===null||_propertyDefinition$t===void 0?void 0:_propertyDefinition$t.description);throwError(type.charAt(0).toUpperCase()+"".concat(type.substring(1),": ")+(description?/*
335
+ eslint-disable
336
+ @typescript-eslint/no-implied-eval,
337
+ @typescript-eslint/no-unsafe-call
338
+ */_construct(Function,_toConsumableArray(Object.keys(_result2.scope)).concat(["return ".concat(description)])).apply(void 0,_toConsumableArray(Object.values(_result2.scope))):"Property \"".concat(name,"\" should satisfy ")+"constraint \"".concat(_result2.code,"\" (given ")+"\"".concat(serialize(newValue),"\")").concat(pathDescription,".")/*
339
+ eslint-enable
340
+ @typescript-eslint/no-implied-eval,
341
+ @typescript-eslint/no-unsafe-call
342
+ */))}}}}catch(err){_iterator4.e(err)}finally{_iterator4.f()}};var checkPropertyContent=function checkPropertyContent(newValue,name,propertyDefinition,oldValue){var localUpdateStrategy=propertyDefinition.updateStrategy||updateStrategy;var changedPath=[];// region type
343
+ var types=[].concat(propertyDefinition.type?propertyDefinition.type:[]);var nestedObjectTypeMatched=false;var typeMatched=false;var _iterator5=_createForOfIteratorHelper(types),_step5;try{for(_iterator5.s();!(_step5=_iterator5.n()).done;){var type=_step5.value;if(typeof type==="string"&&Object.prototype.hasOwnProperty.call(models,type)||_typeof(type)==="object"){var _modelName=typeof type==="string"?type:"in-place";if(_typeof(newValue)==="object"&&Object.getPrototypeOf(newValue)===Object.prototype){var _result3=void 0;try{_result3=_checkDocument(newValue,oldValue,_modelName,typeof type==="string"?models[type]:type,parentNames.concat(name),localUpdateStrategy)}catch(error){var _message;var errorMessage=(_message=error===null||error===void 0?void 0:error.message)!==null&&_message!==void 0?_message:"unknown";if(types.length===1)throwError("NestedType: Under key \"".concat(name,"\" isn't ")+"of type \"".concat(_modelName,"\" (given ")+"\"".concat(serialize(newValue),"\" of type ")+"".concat(_typeof(newValue),") Issue is ")+"\"".concat(errorMessage,"\"").concat(pathDescription,"."));else log.debug("Tried to match \"".concat(serialize(newValue),"\""),"with type \"".concat(_modelName,"\". Got error:"),"\"".concat(errorMessage,"\""))}if(_result3){if(_result3.changedPath.length)changedPath=_result3.changedPath;newValue=_result3.newDocument;if(serialize(newValue)===serialize({}))return{newValue:undefined,changedPath:changedPath};nestedObjectTypeMatched=true;typeMatched=true;break}}else if(types.length===1)throwError("NestedType: Under key \"".concat(name,"\" isn't of type ")+"\"".concat(_modelName,"\" (given \"").concat(serialize(newValue),"\" ")+"of type ".concat(_typeof(newValue),")").concat(pathDescription,"."))}else if(type==="DateTime"){var initialNewValue=newValue;newValue=normalizeDateTime(newValue);if(saveDateTimeAsNumber&&(typeof newValue!=="number"||isNaN(newValue))||!saveDateTimeAsNumber&&typeof newValue!=="string"){if(types.length===1)throwError("PropertyType: Property \"".concat(name,"\" isn't of ")+"(valid) type \"DateTime\" (given \""+serialize(initialNewValue).replace(/^"/,"").replace(/"$/,"")+"\" of type \"".concat(_typeof(initialNewValue),"\")")+"".concat(pathDescription,"."))}else{typeMatched=true;break}}else if(typeof type==="string"&&["boolean","integer","number","string"].includes(type)){if(typeof newValue==="number"&&isNaN(newValue)||!(type==="integer"||_typeof(newValue)===type)||type==="integer"&&parseInt(newValue,10)!==newValue){if(types.length===1)throwError("PropertyType: Property \"".concat(name,"\" isn't of ")+"(valid) type \"".concat(type,"\" (given ")+"\"".concat(serialize(newValue),"\" of type ")+"\"".concat(_typeof(newValue),"\")").concat(pathDescription,"."))}else{typeMatched=true;break}}else if(typeof type==="string"&&type.startsWith("foreignKey:")){var foreignKeyType=models[type.substring("foreignKey:".length)][idName].type;if(foreignKeyType===_typeof(newValue)){typeMatched=true;break}else if(types.length===1)throwError("PropertyType: Foreign key property \"".concat(name,"\" ")+"isn't of type \"".concat(foreignKeyType,"\" (given ")+"\"".concat(serialize(newValue),"\" of type ")+"\"".concat(_typeof(newValue),"\")").concat(pathDescription,"."))}else if(type==="any"||serialize(newValue)===serialize(type)){typeMatched=true;break}else if(types.length===1)throwError("PropertyType: Property \"".concat(name,"\" isn't value ")+"\"".concat(String(type),"\" (given \"")+serialize(newValue).replace(/^"/,"").replace(/"$/,"")+"\" of type \"".concat(_typeof(newValue),"\")").concat(pathDescription,"."))}}catch(err){_iterator5.e(err)}finally{_iterator5.f()}if(!typeMatched)throwError("PropertyType: None of the specified types \""+types.map(function(type){return typeof type==="string"?type:"in-place"}).join("\", \"")+"\" for property \"".concat(name,"\" matches value \"")+serialize(newValue).replace(/^"/,"").replace(/"$/,"")+"".concat(newValue,"\" of type \"").concat(_typeof(newValue),"\"")+"".concat(pathDescription,"."));// endregion
344
+ // region range
345
+ if(typeof newValue==="string"){if(typeof propertyDefinition.minimumLength==="number"&&newValue.length<propertyDefinition.minimumLength)throwError("MinimalLength: Property \"".concat(name,"\" must have ")+"minimal length "+propertyDefinition.minimumLength+" (given ".concat(newValue," with length ")+"".concat(String(newValue.length),")")+"".concat(pathDescription,"."));if(typeof propertyDefinition.maximumLength==="number"&&newValue.length>propertyDefinition.maximumLength)throwError("MaximalLength: Property \"".concat(name,"\" must have ")+"maximal length "+propertyDefinition.maximumLength+" (given ".concat(newValue," with length ")+"".concat(String(newValue.length),")")+"".concat(pathDescription,"."))}if(typeof newValue==="number"){if(typeof propertyDefinition.minimum==="number"&&newValue<propertyDefinition.minimum)throwError("Minimum: Property \"".concat(name,"\" (type ")+[].concat(propertyDefinition.type).join(" or ")+") must satisfy a minimum of "+propertyDefinition.minimum+" (given ".concat(String(newValue)," is too low)")+"".concat(pathDescription,"."));if(typeof propertyDefinition.maximum==="number"&&newValue>propertyDefinition.maximum)throwError("Maximum: Property \"".concat(name,"\" (type ")+[].concat(propertyDefinition.type).join(" or ")+") must satisfy a maximum of "+propertyDefinition.maximum+" (given ".concat(String(newValue)," is too high)")+"".concat(pathDescription,"."))}// endregion
346
+ // region selection
347
+ if(propertyDefinition.selection){var selection=Array.isArray(propertyDefinition.selection)?propertyDefinition.selection.map(function(value){return(value===null||value===void 0?void 0:value.value)===undefined?value:value.value}):Object.keys(propertyDefinition.selection);if(propertyDefinition.type==="DateTime")selection=selection.map(normalizeDateTime);if(!selection.includes(newValue))throwError("Selection: Property \"".concat(name,"\" (type ")+[].concat(propertyDefinition.type).join(" or ")+") should be one of \"".concat(selection.join("\", \""),"\". ")+"But is \"".concat(newValue,"\"").concat(pathDescription,"."))}// endregion
348
+ // region pattern
349
+ if(propertyDefinition.pattern){var patterns=[].concat(propertyDefinition.pattern);var matched=false;var _iterator6=_createForOfIteratorHelper(patterns),_step6;try{for(_iterator6.s();!(_step6=_iterator6.n()).done;){var pattern=_step6.value;if(new RegExp(pattern).test(newValue)){matched=true;break}}}catch(err){_iterator6.e(err)}finally{_iterator6.f()}if(!matched)throwError("PatternMatch: Property \"".concat(name,"\" should ")+"match regular expression pattern "+"\"".concat(patterns.join("\", \""),"\" (given ")+"\"".concat(newValue,"\")").concat(pathDescription,"."))}if(propertyDefinition.invertedPattern){var _iterator7=_createForOfIteratorHelper([].concat(propertyDefinition.invertedPattern)),_step7;try{for(_iterator7.s();!(_step7=_iterator7.n()).done;){var _pattern=_step7.value;if(new RegExp(_pattern).test(newValue))throwError("InvertedPatternMatch: Property \"".concat(name,"\" ")+"should not match regular expression pattern "+"".concat(String(_pattern)," (given ")+"\"".concat(String(newValue),"\")").concat(pathDescription,"."))}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}}// endregion
350
+ checkPropertyConstraints(newValue,name,propertyDefinition,oldValue);if(// NOTE: Nested object should formulate its changed path than.
351
+ !nestedObjectTypeMatched&&(!propertyDefinition.preventVersionCreation||updateStrategy==="migrate")&&serialize(newValue)!==serialize(oldValue))changedPath=parentNames.concat(name,"value updated");return{newValue:newValue,changedPath:changedPath}};var checkPropertyWriteableMutableNullable=function checkPropertyWriteableMutableNullable(propertyDefinition,newDocument,oldDocument,name,pathDescription){var localUpdateStrategy=propertyDefinition.updateStrategy||updateStrategy;var value=newDocument[name];// region writable
352
+ if(!propertyDefinition.writable)if(oldDocument){if(Object.prototype.hasOwnProperty.call(oldDocument,name)&&serialize(value)===serialize(oldDocument[name])){if(name!==idName&&localUpdateStrategy==="incremental")delete newDocument[name];return true}else throwError("Readonly: Property ".concat(String(name),"\" is")+"not writable (old document "+"\"".concat(serialize(oldDocument),"\")").concat(pathDescription,"."));}else throwError("Readonly: Property \"".concat(String(name),"\" is not ")+"writable".concat(pathDescription,"."));// endregion
353
+ // region mutable
354
+ if(!propertyDefinition.mutable&&oldDocument&&Object.prototype.hasOwnProperty.call(oldDocument,name))if(serialize(value)===serialize(oldDocument[name])){if(localUpdateStrategy==="incremental"&&!modelConfiguration.property.name.reserved.concat(specialNames.deleted,idName,revisionName).includes(String(name)))delete newDocument[name];return true}else if(localUpdateStrategy!=="migrate")throwError("Immutable: Property \"".concat(String(name),"\" is not ")+"writable. Trying to update from "+"\"".concat(String(oldDocument[name]),"\" to ")+"\"".concat(String(value),"\" (old document ")+"\"".concat(serialize(oldDocument),"\")").concat(pathDescription,"."));// endregion
355
+ // region nullable
356
+ if(value===null)if(propertyDefinition.nullable){if(localUpdateStrategy!=="incremental"||!oldDocument||oldDocument[name]===undefined)delete newDocument[name];if(oldDocument&&Object.prototype.hasOwnProperty.call(oldDocument,name))changedPath=parentNames.concat(String(name),"delete property");return true}else throwError("NotNull: Property \"".concat(String(name),"\" should not be ")+"\"null\"".concat(pathDescription,"."));// endregion
357
+ return false};/// region create hook
358
+ var runCreatePropertyHook=function runCreatePropertyHook(propertyDefinition,newDocument,oldDocument,name,attachmentsTarget){var localUpdateStrategy=propertyDefinition.updateStrategy||updateStrategy;if(!oldDocument||!(Object.prototype.hasOwnProperty.call(oldDocument,name)||Object.prototype.hasOwnProperty.call(newDocument,name)||propertyDefinition.nullable||Object.prototype.hasOwnProperty.call(propertyDefinition,"default"))){var _iterator8=_createForOfIteratorHelper(["createExecution","createExpression"]),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var type=_step8.value;if(Object.prototype.hasOwnProperty.call(propertyDefinition,type)){var _result4=undefined;try{_result4=evaluate(propertyDefinition[type],type.endsWith("Expression"),{attachmentsTarget:attachmentsTarget,checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,name:String(name),type:type,newDocument:newDocument,oldDocument:oldDocument,newValue:undefined,oldValue:undefined,parentNames:parentNames,pathDescription:pathDescription,propertyDefinition:propertyDefinition,updateStrategy:localUpdateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument})}catch(error){var _error$message3,_error$message4;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(type,"\" has ")+"invalid code \"".concat(error.code,"\" for ")+"property \"".concat(String(name),"\": ")+"\"".concat((_error$message3=error.message)!==null&&_error$message3!==void 0?_error$message3:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(type,"\" has throw ")+"an error with code \"".concat(error.code,"\" for ")+"property \"".concat(String(name),"\": ")+"\"".concat((_error$message4=error.message)!==null&&_error$message4!==void 0?_error$message4:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}if(_result4&&![null,undefined].includes(_result4.result))if(attachmentsTarget)attachmentsTarget[name]=_result4.result;else newDocument[name]=_result4.result}}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}};/// endregion
359
+ /// region update hook
360
+ var runUpdatePropertyHook=function runUpdatePropertyHook(propertyDefinition,newDocument,oldDocument,name,attachmentsTarget){var localUpdateStrategy=propertyDefinition.updateStrategy||updateStrategy;if(!attachmentsTarget){if(!(propertyDefinition.runUpdateHookAlways||Object.prototype.hasOwnProperty.call(newDocument,name)))return;if(propertyDefinition.trim&&typeof newDocument[name]==="string")newDocument[name]=newDocument[name].trim();if(propertyDefinition.emptyEqualsNull&&(newDocument[name]===""||Array.isArray(newDocument[name])&&newDocument[name].length===0||newDocument[name]!==null&&_typeof(newDocument[name])==="object"&&Object.keys(newDocument).length===0))newDocument[name]=null}var _iterator9=_createForOfIteratorHelper(["updateExecution","updateExpression"]),_step9;try{for(_iterator9.s();!(_step9=_iterator9.n()).done;){var type=_step9.value;if(Object.prototype.hasOwnProperty.call(propertyDefinition,type))try{var _result5=evaluate(propertyDefinition[type],type.endsWith("Expression"),{attachmentsTarget:attachmentsTarget,checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,name:String(name),type:type,newDocument:newDocument,oldDocument:oldDocument,newValue:newDocument[name],oldValue:oldDocument&&oldDocument[name],parentNames:parentNames,pathDescription:pathDescription,propertyDefinition:propertyDefinition,updateStrategy:localUpdateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument});if(attachmentsTarget)attachmentsTarget[name]=_result5.result;else if(_result5.result!==undefined)newDocument[name]=_result5.result}catch(error){var _error$message5,_error$message6;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(type,"\" has invalid ")+"code \"".concat(error.code,"\" for property \"")+"".concat(String(name),"\": ")+"\"".concat((_error$message5=error.message)!==null&&_error$message5!==void 0?_error$message5:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(type,"\" has throw an error")+" with code \"".concat(error.code,"\" for property ")+"\"".concat(String(name),"\": ")+"\"".concat((_error$message6=error.message)!==null&&_error$message6!==void 0?_error$message6:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}}}catch(err){_iterator9.e(err)}finally{_iterator9.f()}};/// endregion
361
+ // endregion
362
+ var specifiedPropertyNames=Object.keys(model).filter(function(name){return!specialPropertyNames.includes(name)});// region migrate old model specific property names
363
+ if(updateStrategy==="migrate"){var _iterator0=_createForOfIteratorHelper(specifiedPropertyNames),_step0;try{for(_iterator0.s();!(_step0=_iterator0.n()).done;){var _name3=_step0.value;if(model[_name3].oldName){var _iterator1=_createForOfIteratorHelper([].concat(model[_name3].oldName)),_step1;try{for(_iterator1.s();!(_step1=_iterator1.n()).done;){var _oldName=_step1.value;if(Object.prototype.hasOwnProperty.call(localNewDocument,_oldName)){localNewDocument[_name3]=localNewDocument[_oldName];delete localNewDocument[_oldName]}}}catch(err){_iterator1.e(err)}finally{_iterator1.f()}}}}catch(err){_iterator0.e(err)}finally{_iterator0.f()}}// endregion
364
+ // region run create document hook
365
+ if(!localOldDocument)for(var _i7=0,_arr=[specialNames.create.execution,specialNames.create.expression];_i7<_arr.length;_i7++){var type=_arr[_i7];if(Object.prototype.hasOwnProperty.call(model,type)){var _result6=void 0;try{_result6=evaluate(model[type],type.endsWith("Expression"),{checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,type:type,newDocument:localNewDocument,oldDocument:localOldDocument,parentNames:parentNames,pathDescription:pathDescription,updateStrategy:updateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument}).result}catch(error){var _error$message7,_error$message8;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(type,"\" has invalid ")+"code \"".concat(error.code,"\" for document \"")+"".concat(modelName,"\": ")+"\"".concat((_error$message7=error.message)!==null&&_error$message7!==void 0?_error$message7:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(type,"\" has throw an error")+" with code \"".concat(error.code,"\" for ")+"document \"".concat(modelName,"\": ")+"\"".concat((_error$message8=error.message)!==null&&_error$message8!==void 0?_error$message8:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}if(![null,undefined].includes(_result6))// @ts-expect-error Typescript cannot determine.
366
+ localNewDocument=_result6;if(parentNames.length===0){checkModelType(localNewDocument,localOldDocument);modelName=localNewDocument[typeName];setDocumentEnvironment()}}}// endregion
367
+ // region run update document hook
368
+ for(var _i8=0,_arr2=[specialNames.update.execution,specialNames.update.expression];_i8<_arr2.length;_i8++){var _type=_arr2[_i8];if(Object.prototype.hasOwnProperty.call(model,_type)){var _result7=void 0;try{_result7=evaluate(model[_type],_type.endsWith("Expression"),{checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,type:_type,newDocument:localNewDocument,oldDocument:localOldDocument,parentNames:parentNames,pathDescription:pathDescription,updateStrategy:updateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument}).result}catch(error){var _error$message9,_error$message0;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(_type,"\" has invalid ")+"code \"".concat(error.code,"\" for document ")+"\"".concat(modelName,"\": ")+"\"".concat((_error$message9=error.message)!==null&&_error$message9!==void 0?_error$message9:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(_type,"\" has throw an error ")+"with code \"".concat(error.code,"\" for document ")+"\"".concat(modelName,"\": ")+"\"".concat((_error$message0=error.message)!==null&&_error$message0!==void 0?_error$message0:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}if(![undefined,null].includes(_result7))// @ts-expect-error Typescript cannot determine.
369
+ localNewDocument=_result7;if(parentNames.length===0){checkModelType(localNewDocument,localOldDocument);modelName=localNewDocument[typeName];setDocumentEnvironment()}}}// endregion
370
+ var additionalPropertyNames=additionalPropertyDefinition?Object.keys(localNewDocument).filter(function(name){return!specifiedPropertyNames.includes(name)}):[];var _iterator10=_createForOfIteratorHelper(specifiedPropertyNames.concat(additionalPropertyNames)),_step10;try{for(_iterator10.s();!(_step10=_iterator10.n()).done;)// region run hooks and check for presence of needed data
371
+ {var _name9=_step10.value;if(specialNames.attachment===_name9)// region attachment
372
+ {var _loop=function _loop(){var _Object$entries7$_i=_slicedToArray(_Object$entries7[_i19],2),type=_Object$entries7$_i[0],property=_Object$entries7$_i[1];if(!localNewDocument[specialNames.attachment])localNewDocument[specialNames.attachment]={};if(localOldDocument&&!Object.prototype.hasOwnProperty.call(localOldDocument,_name9))localOldDocument[specialNames.attachment]={};var newAttachments=localNewDocument[specialNames.attachment];var newFileNames=Object.keys(newAttachments).filter(function(fileName){return newAttachments[fileName].data!==null&&fileNameMatchesModelType(type,fileName,property)});var oldFileNames=[];if(localOldDocument){var _oldAttachments=localOldDocument[_name9];oldFileNames=Object.keys(_oldAttachments).filter(function(fileName){return!(Object.prototype.hasOwnProperty.call(newAttachments,fileName)&&Object.prototype.hasOwnProperty.call(newAttachments[fileName],"data")&&newAttachments[fileName].data===null)&&Boolean(_oldAttachments[fileName])&&(Object.prototype.hasOwnProperty.call(_oldAttachments[fileName],"data")&&_oldAttachments[fileName].data!==null||Object.prototype.hasOwnProperty.call(_oldAttachments[fileName],"stub")&&Boolean(_oldAttachments[fileName].digest))&&fileNameMatchesModelType(type,fileName,property)})}var propertyDefinition=property;updateStrategy=propertyDefinition.updateStrategy||updateStrategy;var _iterator18=_createForOfIteratorHelper(newFileNames),_step18;try{for(_iterator18.s();!(_step18=_iterator18.n()).done;){var _fileName7=_step18.value;runCreatePropertyHook(propertyDefinition,localNewDocument,localOldDocument&&localOldDocument[_name9]?localOldDocument[_name9]:null,_fileName7,newAttachments)}}catch(err){_iterator18.e(err)}finally{_iterator18.f()}var _iterator19=_createForOfIteratorHelper(newFileNames),_step19;try{for(_iterator19.s();!(_step19=_iterator19.n()).done;){var _fileName8=_step19.value;runUpdatePropertyHook(propertyDefinition,localNewDocument,localOldDocument&&localOldDocument[_name9]?localOldDocument[_name9]:null,_fileName8,newAttachments)}}catch(err){_iterator19.e(err)}finally{_iterator19.f()}if(typeof propertyDefinition.default==="undefined"){if(!(propertyDefinition.nullable||newFileNames.length>0||oldFileNames.length>0))throwError("AttachmentMissing: Missing attachment for "+"type \"".concat(type,"\"").concat(pathDescription,"."));if(updateStrategy==="fillUp"&&newFileNames.length===0&&oldFileNames.length>0){var _iterator20=_createForOfIteratorHelper(oldFileNames),_step20;try{for(_iterator20.s();!(_step20=_iterator20.n()).done;){var _fileName4=_step20.value;if(newAttachments[_fileName4]===null)changedPath=parentNames.concat(_name9,_fileName4,"file removed");else// @ts-expect-error Existing old file name
373
+ newAttachments[_fileName4]=localOldDocument[_name9][_fileName4]}}catch(err){_iterator20.e(err)}finally{_iterator20.f()}}}else if(newFileNames.length===0)if(oldFileNames.length===0){for(var _fileName5 in propertyDefinition.default)if(Object.prototype.hasOwnProperty.call(propertyDefinition.default,_fileName5)){newAttachments[_fileName5]=propertyDefinition.default[_fileName5];changedPath=parentNames.concat(_name9,type,"add default file")}}else if(updateStrategy==="fillUp"){var _iterator21=_createForOfIteratorHelper(oldFileNames),_step21;try{for(_iterator21.s();!(_step21=_iterator21.n()).done;)// @ts-expect-error Existing old file name
374
+ {var _fileName6=_step21.value;newAttachments[_fileName6]=localOldDocument[_name9][_fileName6]}}catch(err){_iterator21.e(err)}finally{_iterator21.f()}}};for(var _i19=0,_Object$entries7=Object.entries(model[specialNames.attachment]);_i19<_Object$entries7.length;_i19++){_loop()}}// endregion
375
+ else{var _propertyDefinition=specifiedPropertyNames.includes(_name9)?model[_name9]:additionalPropertyDefinition;updateStrategy=_propertyDefinition.updateStrategy||updateStrategy;runCreatePropertyHook(_propertyDefinition,localNewDocument,localOldDocument,_name9);runUpdatePropertyHook(_propertyDefinition,localNewDocument,localOldDocument,_name9);if([null,undefined].includes(_propertyDefinition.default)){if(!(_propertyDefinition.nullable||Object.prototype.hasOwnProperty.call(localNewDocument,_name9)&&localNewDocument[_name9]!==undefined||localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,_name9)&&updateStrategy!=="replace"||parentNames.length>0&&_name9===typeName))throwError("MissingProperty: Missing property "+"\"".concat(String(_name9),"\"").concat(pathDescription,"."));if((!Object.prototype.hasOwnProperty.call(localNewDocument,_name9)||localNewDocument[_name9]===undefined)&&localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,_name9))if(updateStrategy==="fillUp")localNewDocument[_name9]=localOldDocument[_name9];else if(updateStrategy==="replace")changedPath=parentNames.concat(String(_name9),"property removed")}else if(!isDefinedPropertyValue(_name9,localNewDocument))if(localOldDocument){if(localNewDocument[_name9]!==null&&updateStrategy==="fillUp")localNewDocument[_name9]=localOldDocument[_name9];else if(updateStrategy==="migrate"){localNewDocument[_name9]=_propertyDefinition.default;changedPath=parentNames.concat(String(_name9),"migrate default value")}}else{localNewDocument[_name9]=_propertyDefinition.default;changedPath=changedPath.concat(String(_name9),"add default value")}}}// endregion
376
+ // region check given data
377
+ /// region remove new data which already exists
378
+ }catch(err){_iterator10.e(err)}finally{_iterator10.f()}if(localOldDocument&&updateStrategy==="incremental")for(var _i9=0,_Object$entries3=Object.entries(localNewDocument);_i9<_Object$entries3.length;_i9++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i9],2),_name4=_Object$entries3$_i[0],value=_Object$entries3$_i[1];if(Object.prototype.hasOwnProperty.call(localOldDocument,_name4)&&!modelConfiguration.property.name.reserved.concat(idName,revisionName,specialNames.conflict,specialNames.deleted,specialNames.deletedConflict,specialNames.localSequence,specialNames.revisions,specialNames.revisionsInformation,typeName).includes(_name4)&&(localOldDocument[_name4]===value||serialize(localOldDocument[_name4])===serialize(value)))delete localNewDocument[_name4]}/// endregion
379
+ for(var _i0=0,_arr3=Object.entries(localNewDocument);_i0<_arr3.length;_i0++){var _arr3$_i=_slicedToArray(_arr3[_i0],2),_name5=_arr3$_i[0],newValue=_arr3$_i[1];if(!modelConfiguration.property.name.reserved.concat(revisionName,specialNames.conflict,specialNames.deleted,specialNames.deletedConflict,specialNames.localSequence,specialNames.revisions,specialNames.revisionsInformation,specialNames.updateStrategy).includes(_name5)){if(parentNames.length>0&&_name5===typeName){delete localNewDocument[_name5];continue}var propertyDefinition=void 0;if(Object.prototype.hasOwnProperty.call(model,_name5))propertyDefinition=model[_name5];else if(additionalPropertyDefinition)propertyDefinition=additionalPropertyDefinition;else if(updateStrategy==="migrate"){delete localNewDocument[_name5];changedPath=parentNames.concat(String(_name5),"migrate removed property");continue}else throwError("Property: Given property \"".concat(String(_name5),"\" isn't ")+"specified in model \"".concat(modelName,"\"").concat(pathDescription,"."));// NOTE: Only needed to avoid type check errors.
380
+ if(!propertyDefinition)continue;// region check writable/mutable/nullable
381
+ if(specialNames.attachment===_name5){var attachments=newValue;for(var fileName in attachments)if(Object.prototype.hasOwnProperty.call(attachments,fileName))for(var _i1=0,_Object$keys3=Object.keys(model[_name5]);_i1<_Object$keys3.length;_i1++){var _type2=_Object$keys3[_i1];var file=model[specialNames.attachment][_type2];if(fileNameMatchesModelType(_type2,fileName,file)){checkPropertyWriteableMutableNullable(file,localNewDocument,localOldDocument,fileName,pathDescription);break}}continue}else if(checkPropertyWriteableMutableNullable(propertyDefinition,localNewDocument,localOldDocument,_name5,pathDescription))continue;// endregion
382
+ var isArrayType=typeof propertyDefinition.type==="string"&&propertyDefinition.type.endsWith("[]")||Array.isArray(propertyDefinition.type)&&propertyDefinition.type.length&&Array.isArray(propertyDefinition.type[0]);if(isArrayType&&![null,undefined].includes(newValue)){var newProperty=newValue;// region check arrays
383
+ if(!Array.isArray(newProperty))throwError("PropertyType: Property \"".concat(String(_name5),"\" isn't ")+"of type \"array -> "+"".concat(propertyDefinition.type,"\" (given")+"\"".concat(serialize(newProperty),"\")").concat(pathDescription,"."));else if(typeof propertyDefinition.minimumNumber==="number"&&newProperty.length<propertyDefinition.minimumNumber)throwError("MinimumArrayLength: Property \"".concat(String(_name5),"\" ")+"(array of length ".concat(String(newProperty.length),")")+" doesn't fulfill minimum array length of "+propertyDefinition.minimumNumber+"".concat(pathDescription,"."));else if(typeof propertyDefinition.maximumNumber==="number"&&propertyDefinition.maximumNumber<newProperty.length)throwError("MaximumArrayLength: Property \"".concat(String(_name5),"\" ")+"(array of length ".concat(String(newProperty.length),")")+" doesn't fulfill maximum array length of "+propertyDefinition.maximumNumber+"".concat(pathDescription,"."));checkPropertyConstraints(newProperty,String(_name5),propertyDefinition,localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,_name5)&&localOldDocument[_name5]||undefined,["arrayConstraintExecution","arrayConstraintExpression"]);/// region check/migrate array content
384
+ var propertyDefinitionCopy={};for(var key in propertyDefinition)if(Object.prototype.hasOwnProperty.call(propertyDefinition,key))if(key==="type"){var _type3=propertyDefinition[key];if(Array.isArray(propertyDefinition[key]))propertyDefinitionCopy[key]=_type3[0];else propertyDefinitionCopy[key]=[_type3.substring(0,_type3.length-"[]".length)]}else propertyDefinitionCopy[key]=propertyDefinition[key];//// region check each array item
385
+ var index=0;var _iterator11=_createForOfIteratorHelper(newProperty.slice()),_step11;try{for(_iterator11.s();!(_step11=_iterator11.n()).done;){var _value=_step11.value;newProperty[index]=checkPropertyContent(_value,"".concat(String(index+1),". value in \"").concat(String(_name5),"\""),propertyDefinitionCopy,undefined).newValue;if([null,undefined].includes(newProperty[index]))newProperty.splice(index,1);index+=1}//// endregion
386
+ }catch(err){_iterator11.e(err)}finally{_iterator11.f()}if(!(propertyDefinition.preventVersionCreation&&updateStrategy!=="migrate"||localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,_name5)&&Array.isArray(localOldDocument[_name5])&&localOldDocument[_name5].length===newProperty.length&&serialize(localOldDocument[_name5])===serialize(newProperty)))changedPath=parentNames.concat(String(_name5),"array updated");/// endregion
387
+ // endregion
388
+ }else{var oldValue=localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,_name5)?localOldDocument[_name5]:undefined;var _result8=isArrayType?{newValue:null,changedPath:[]}:checkPropertyContent(newValue,String(_name5),propertyDefinition,oldValue);localNewDocument[_name5]=_result8.newValue;if(_result8.changedPath.length)changedPath=_result8.changedPath;// NOTE: Do not use "newValue" here anymore.
389
+ if(localNewDocument[_name5]===null)if(oldValue===undefined){if(updateStrategy==="fillUp")delete localNewDocument[_name5]}else changedPath=parentNames.concat(String(_name5),"property removed");if(localNewDocument[_name5]===undefined)delete localNewDocument[_name5]}}}/// region constraint
390
+ for(var _i10=0,_arr4=Object.keys(specialNames.constraint);_i10<_arr4.length;_i10++){var _type4=_arr4[_i10];var constraintName=specialNames.constraint[_type4];if(Object.prototype.hasOwnProperty.call(model,constraintName)){var constraints=model[constraintName];var _iterator12=_createForOfIteratorHelper([].concat(constraints)),_step12;try{for(_iterator12.s();!(_step12=_iterator12.n()).done;){var constraint=_step12.value;var _result9=undefined;try{_result9=evaluate(constraint.evaluation,constraintName===specialNames.constraint.expression,{checkPropertyContent:checkPropertyContent,model:model,modelName:modelName,type:constraintName,newDocument:localNewDocument,oldDocument:localOldDocument,parentNames:parentNames,pathDescription:pathDescription,updateStrategy:updateStrategy,ignoreIfNoOldDocument:ignoreIfNoOldDocument})}catch(error){var _error$message1,_error$message10;if(function(error){return Object.prototype.hasOwnProperty.call(error,"compilation")}(error))throwError("Compilation: Hook \"".concat(constraintName,"\" has ")+"invalid code \"".concat(error.code,"\": ")+"\"".concat((_error$message1=error.message)!==null&&_error$message1!==void 0?_error$message1:"unknown","\"")+"".concat(pathDescription,"."));if(function(error){return Object.prototype.hasOwnProperty.call(error,"runtime")}(error))throwError("Runtime: Hook \"".concat(constraintName,"\" ")+"has thrown an error with code "+"\"".concat(error.code,"\": ")+"\"".concat((_error$message10=error.message)!==null&&_error$message10!==void 0?_error$message10:"unknown","\"")+"".concat(pathDescription,"."));if(!Object.prototype.hasOwnProperty.call(error,"empty"))throw error}if(_result9&&!_result9.result){var errorName=constraintName.replace(/^[^a-zA-Z]+/,"");throwError(errorName.charAt(0).toUpperCase()+"".concat(errorName.substring(1),": ")+(constraint.description?/*
391
+ eslint-disable
392
+ @typescript-eslint/no-implied-eval,
393
+ @typescript-eslint/no-unsafe-call
394
+ */_construct(Function,_toConsumableArray(Object.keys(_result9.scope)).concat(["return "+constraint.description.trim()])).apply(void 0,_toConsumableArray(Object.values(_result9.scope))):"Model \"".concat(modelName,"\" should satisfy ")+"constraint \"".concat(_result9.code,"\" (given ")+"\"".concat(serialize(localNewDocument),"\")")+"".concat(pathDescription,".")/*
395
+ eslint-enable
396
+ @typescript-eslint/no-implied-eval,
397
+ @typescript-eslint/no-unsafe-call
398
+ */))}}}catch(err){_iterator12.e(err)}finally{_iterator12.f()}}}/// endregion
399
+ /// region attachment
400
+ if(Object.prototype.hasOwnProperty.call(localNewDocument,specialNames.attachment)){var _model$specialNames$m,_model$specialNames$m2;var attachmentModel=model[specialNames.attachment];var _newAttachments=localNewDocument[specialNames.attachment];if(_typeof(_newAttachments)!=="object"||Object.getPrototypeOf(_newAttachments)!==Object.prototype)throwError("AttachmentType: given attachment has invalid type"+"".concat(pathDescription,"."));// region migrate old attachments
401
+ var oldAttachments=null;if(localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,specialNames.attachment)){oldAttachments=localOldDocument[specialNames.attachment];if(oldAttachments!==null&&_typeof(oldAttachments)==="object")for(var _i11=0,_Object$entries4=Object.entries(oldAttachments);_i11<_Object$entries4.length;_i11++){var _Object$entries4$_i=_slicedToArray(_Object$entries4[_i11],2),_fileName=_Object$entries4$_i[0],oldAttachment=_Object$entries4$_i[1];if(oldAttachment&&Object.prototype.hasOwnProperty.call(_newAttachments,_fileName)){var newAttachment=_newAttachments[_fileName];if(newAttachment===null||newAttachment.data===null||newAttachment.content_type===oldAttachment.content_type&&(newAttachment.data===oldAttachment.data||newAttachment.digest===oldAttachment.digest)){if(newAttachment===null||newAttachment.data===null)changedPath=parentNames.concat(specialNames.attachment,_fileName,"attachment removed");if(updateStrategy==="incremental")delete _newAttachments[_fileName]}else changedPath=parentNames.concat(specialNames.attachment,_fileName,"attachment updated")}else if(updateStrategy==="fillUp")_newAttachments[_fileName]=oldAttachment;else if(updateStrategy==="replace")changedPath=parentNames.concat(specialNames.attachment,_fileName,"attachment removed")}}for(var _i12=0,_Object$entries5=Object.entries(_newAttachments);_i12<_Object$entries5.length;_i12++){var _oldAttachments$_file;var _Object$entries5$_i=_slicedToArray(_Object$entries5[_i12],2),_fileName2=_Object$entries5$_i[0],_newAttachment=_Object$entries5$_i[1];if(!_newAttachment)break;if(_newAttachment.data===null)delete _newAttachments[_fileName2];else if(!(oldAttachments&&Object.prototype.hasOwnProperty.call(oldAttachments,_fileName2)&&_newAttachment.content_type===((_oldAttachments$_file=oldAttachments[_fileName2])===null||_oldAttachments$_file===void 0?void 0:_oldAttachments$_file.content_type)&&(_newAttachment.data===oldAttachments[_fileName2].data||_newAttachment.digest===oldAttachments[_fileName2].digest)))changedPath=parentNames.concat(specialNames.attachment,_fileName2,"attachment updated")}// endregion
402
+ if(Object.keys(_newAttachments).length===0)delete localNewDocument[specialNames.attachment];var attachmentToTypeMapping={};for(var _i13=0,_Object$keys4=Object.keys(attachmentModel);_i13<_Object$keys4.length;_i13++){var _type5=_Object$keys4[_i13];attachmentToTypeMapping[_type5]=[]}for(var _i14=0,_Object$keys5=Object.keys(_newAttachments);_i14<_Object$keys5.length;_i14++){var _name6=_Object$keys5[_i14];var matched=false;for(var _i15=0,_Object$entries6=Object.entries(attachmentModel);_i15<_Object$entries6.length;_i15++){var _Object$entries6$_i=_slicedToArray(_Object$entries6[_i15],2),_type6=_Object$entries6$_i[0],specification=_Object$entries6$_i[1];if(fileNameMatchesModelType(_type6,_name6,specification)){attachmentToTypeMapping[_type6].push(_name6);matched=true;break}}if(!matched)throwError("AttachmentTypeMatch: None of the specified "+"attachment types (\""+Object.keys(attachmentModel).join("\", \"")+"\") matches given one (\"".concat(_name6,"\")").concat(pathDescription,"."))}var sumOfAggregatedSizes=0;for(var _i16=0,_Object$keys6=Object.keys(attachmentToTypeMapping);_i16<_Object$keys6.length;_i16++){var _type7=_Object$keys6[_i16];var _specification=attachmentModel[_type7];if(!Object.prototype.hasOwnProperty.call(attachmentToTypeMapping,_type7))continue;var numberOfAttachments=attachmentToTypeMapping[_type7].length;if(typeof _specification.maximumNumber==="number"&&numberOfAttachments>_specification.maximumNumber)throwError("AttachmentMaximum: given number of attachments "+"(".concat(String(numberOfAttachments),") doesn't satisfy ")+"specified maximum of "+"".concat(String(_specification.maximumNumber)," from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."));if(!(_specification.nullable&&numberOfAttachments===0)&&typeof _specification.minimumNumber==="number"&&numberOfAttachments<_specification.minimumNumber)throwError("AttachmentMinimum: given number of attachments "+"(".concat(String(numberOfAttachments),") doesn't satisfy ")+"specified minimum of "+"".concat(String(_specification.minimumNumber)," from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."));var aggregatedSize=0;var _iterator13=_createForOfIteratorHelper(attachmentToTypeMapping[_type7]),_step13;try{for(_iterator13.s();!(_step13=_iterator13.n()).done;){var _specification$fileNa,_specification$fileNa2,_newAttachments$_file;var _fileName3=_step13.value;if((_specification$fileNa=_specification.fileName)!==null&&_specification$fileNa!==void 0&&_specification$fileNa.pattern){var patterns=[].concat(_specification.fileName.pattern);var _matched=false;var _iterator14=_createForOfIteratorHelper(patterns),_step14;try{for(_iterator14.s();!(_step14=_iterator14.n()).done;){var pattern=_step14.value;if(new RegExp(pattern).test(_fileName3)){_matched=true;break}}}catch(err){_iterator14.e(err)}finally{_iterator14.f()}if(!_matched)throwError("AttachmentName: given attachment name "+"\"".concat(_fileName3,"\" doesn't satisfy one of ")+"specified regular expression patterns "+"\"".concat(patterns.join("\", \""),"\" from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."))}if((_specification$fileNa2=_specification.fileName)!==null&&_specification$fileNa2!==void 0&&_specification$fileNa2.invertedPattern){var _iterator15=_createForOfIteratorHelper([].concat(_specification.fileName.invertedPattern)),_step15;try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){var _pattern2=_step15.value;if(new RegExp(_pattern2).test(_fileName3))throwError("InvertedAttachmentName: given "+"attachment name \"".concat(_fileName3,"\" does ")+"satisfy specified regular "+"expression pattern \""+"".concat(_pattern2.toString(),"\" from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."))}}catch(err){_iterator15.e(err)}finally{_iterator15.f()}}if((_newAttachments$_file=_newAttachments[_fileName3])!==null&&_newAttachments$_file!==void 0&&_newAttachments$_file.content_type){if(_specification.contentTypePattern){var _patterns=[].concat(_specification.contentTypePattern);var _matched2=false;var _iterator16=_createForOfIteratorHelper(_patterns),_step16;try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){var _pattern3=_step16.value;if(new RegExp(_pattern3).test(_newAttachments[_fileName3].content_type)){_matched2=true;break}}}catch(err){_iterator16.e(err)}finally{_iterator16.f()}if(!_matched2)throwError("AttachmentContentType: given "+"attachment content type \""+_newAttachments[_fileName3].content_type+"\" doesn't satisfy specified regular"+" expression pattern "+"\"".concat(_patterns.join("\", \""),"\" from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."))}var invertedPatterns=_specification.invertedContentTypePattern;if(invertedPatterns){var _iterator17=_createForOfIteratorHelper([].concat(invertedPatterns)),_step17;try{for(_iterator17.s();!(_step17=_iterator17.n()).done;){var _pattern4=_step17.value;if(new RegExp(_pattern4).test(_newAttachments[_fileName3].content_type))throwError("InvertedAttachmentContentType: "+"given attachment content type \""+_newAttachments[_fileName3].content_type+"\" does satisfy specified regular "+"expression pattern "+"\"".concat(_pattern4.toString(),"\" from type ")+"\"".concat(_type7,"\"").concat(pathDescription,"."))}}catch(err){_iterator17.e(err)}finally{_iterator17.f()}}}var length=0;if(_newAttachments[_fileName3]&&"length"in _newAttachments[_fileName3])length=_newAttachments[_fileName3].length;else if(_newAttachments[_fileName3]&&"data"in _newAttachments[_fileName3])if(typeof Buffer!=="undefined"&&"byteLength"in Buffer)length=Buffer.byteLength(_newAttachments[_fileName3].data,"base64");else length=_newAttachments[_fileName3].data.length;if(typeof _specification.minimumSize==="number"&&_specification.minimumSize>length)throwError("AttachmentMinimumSize: given attachment "+"size ".concat(String(length)," byte doesn't satisfy ")+"specified minimum of "+"".concat(String(_specification.minimumSize)," byte")+"".concat(pathDescription,"."));else if(typeof _specification.maximumSize==="number"&&_specification.maximumSize<length)throwError("AttachmentMaximumSize: given attachment "+"size ".concat(String(length)," byte doesn't satisfy ")+"specified maximum of "+"".concat(String(_specification.maximumSize)," byte")+"".concat(pathDescription,"."));aggregatedSize+=length}}catch(err){_iterator13.e(err)}finally{_iterator13.f()}if(typeof _specification.minimumAggregatedSize==="number"&&_specification.minimumAggregatedSize>aggregatedSize)throwError("AttachmentAggregatedMinimumSize: given "+"aggregated size of attachments from type "+"\"".concat(_type7,"\" ").concat(String(aggregatedSize)," byte doesn't ")+"satisfy specified minimum of "+"".concat(String(_specification.minimumAggregatedSize)," byte")+"".concat(pathDescription,"."));else if(typeof _specification.maximumAggregatedSize==="number"&&_specification.maximumAggregatedSize<aggregatedSize)throwError("AttachmentAggregatedMaximumSize: given "+"aggregated size of attachments from type \"".concat(_type7,"\" ")+"".concat(String(aggregatedSize)," byte doesn't satisfy ")+"specified maximum of "+"".concat(String(_specification.maximumAggregatedSize)," byte")+"".concat(pathDescription,"."));sumOfAggregatedSizes+=aggregatedSize}if(((_model$specialNames$m=model[specialNames.minimumAggregatedSize])!==null&&_model$specialNames$m!==void 0?_model$specialNames$m:0)>sumOfAggregatedSizes)throwError("AggregatedMinimumSize: given aggregated size "+"".concat(String(sumOfAggregatedSizes)," byte doesn't satisfy ")+"specified minimum of "+"".concat(String(model[specialNames.minimumAggregatedSize])," ")+"byte".concat(pathDescription,"."));else if(((_model$specialNames$m2=model[specialNames.maximumAggregatedSize])!==null&&_model$specialNames$m2!==void 0?_model$specialNames$m2:Infinity)<sumOfAggregatedSizes)throwError("AggregatedMaximumSize: given aggregated size "+"".concat(String(sumOfAggregatedSizes)," byte doesn't satisfy ")+"specified maximum of "+"".concat(String(model[specialNames.maximumAggregatedSize])," ")+"byte".concat(pathDescription,"."))}/// endregion
403
+ // endregion
404
+ if(localOldDocument&&Object.prototype.hasOwnProperty.call(localOldDocument,specialNames.attachment)&&Object.keys(localOldDocument[specialNames.attachment]).length===0)delete localOldDocument[specialNames.attachment];if(localOldDocument){// region fill up old additional properties if desired
405
+ if(additionalPropertyDefinition&&(additionalPropertyDefinition.updateStrategy||updateStrategy)==="fillUp")for(var _i17=0,_Object$keys7=Object.keys(localOldDocument);_i17<_Object$keys7.length;_i17++){var _name7=_Object$keys7[_i17];if(!Object.prototype.hasOwnProperty.call(localNewDocument,_name7))localNewDocument[_name7]=localOldDocument[_name7]}// endregion
406
+ if(changedPath.length===0&&updateStrategy==="migrate")for(var _i18=0,_Object$keys8=Object.keys(localOldDocument);_i18<_Object$keys8.length;_i18++){var _name8=_Object$keys8[_i18];if(!Object.prototype.hasOwnProperty.call(localNewDocument,_name8))changedPath=parentNames.concat(_name8,"migrate removed property")}}return{changedPath:changedPath,newDocument:localNewDocument}};// endregion
407
+ var BASIC_SCOPE={attachmentWithPrefixExists:attachmentWithPrefixExists,checkDocument:_checkDocument,deepCopy:deepCopy,getDateTime:getDateTime,getEffectiveValue:getEffectiveValue,getFileNameByPrefix:getFileNameByPrefix,isDefinedPropertyValue:isDefinedPropertyValue,serialize:serialize,id:id,revision:revision,idName:idName,revisionName:revisionName,specialNames:specialNames,typeName:typeName,modelConfiguration:modelConfiguration,models:models,now:now,nowUTCTimestamp:nowUTCTimestamp,securitySettings:securitySettings,userContext:userContext,originalNewDocument:originalNewDocument};var newAttachments=newDocument[specialNames.attachment];// region migrate attachment content types
408
+ if(newDocument[specialNames.attachment])for(var _i20=0,_Object$values3=Object.values(newAttachments);_i20<_Object$values3.length;_i20++){var attachment=_Object$values3[_i20];if(attachment!==null&&attachment!==void 0&&attachment.contentType){// eslint-disable-next-line camelcase
409
+ attachment.content_type=attachment.contentType;delete attachment.contentType}}// endregion
410
+ checkModelType(newDocument,oldDocument);var modelName=newDocument[typeName];var model=models[modelName];var result=_checkDocument(newDocument,oldDocument,modelName,model);// region check if changes happened
411
+ if(result.newDocument._deleted&&!oldDocument||!(result.newDocument._deleted&&result.newDocument._deleted!==(oldDocument===null||oldDocument===void 0?void 0:oldDocument._deleted)||result.changedPath.length))throwError("NoChange: No new data given. New document: "+"".concat(serialize(newDocument),"; old document: ")+"".concat(serialize(oldDocument),"."));// endregion
412
+ // region add metadata to security object for further processing
413
+ if(Object.prototype.hasOwnProperty.call(securitySettings,modelConfiguration.property.name.validatedDocumentsCache))securitySettings[modelConfiguration.property.name.validatedDocumentsCache].add("".concat(id,"-").concat(revision));else securitySettings[modelConfiguration.property.name.validatedDocumentsCache]=new Set(["".concat(id,"-").concat(revision)]);// endregion
414
+ log.debug("Document has changes in \"".concat(result.changedPath.join("."),"\"."));log.debug("Determined new document:",result.newDocument);return result.newDocument};var databaseHelper={authorize:_authorize,validateDocumentUpdate:validateDocumentUpdate};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (databaseHelper);
415
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
416
+ /* harmony export */ "Ay", 0, /* export default binding */ __WEBPACK_DEFAULT_EXPORT__
417
+ /* harmony export */ ]);
418
+
419
+
420
+ /***/ }),
421
+ /* 7 */
422
+ /***/ ((module, __webpack_exports__, __webpack_require__) => {
423
+
424
+ var __webpack_import_meta__ = Object.assign(import.meta, {url: "file:///__w/couchdb-web-node-plugin/couchdb-web-node-plugin/index.ts", webpack: 5, main: __webpack_require__.c[__webpack_require__.s] === module, env: {"NODE_ENV":"production","MODE":"production","DEV":false,"PROD":true,"SSR":true,"BASE_URL":"/"}});
425
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
426
+ /* harmony export */ EK: () => (/* binding */ shouldExit),
427
+ /* harmony export */ OO: () => (/* binding */ database),
428
+ /* harmony export */ jv: () => (/* binding */ preLoadService),
429
+ /* harmony export */ oV: () => (/* binding */ loadService),
430
+ /* harmony export */ q5: () => (/* binding */ postLoadService)
431
+ /* harmony export */ });
432
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
433
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
434
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
435
+ /* harmony import */ var url__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8);
436
+ /* harmony import */ var pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9);
437
+ /* harmony import */ var pouchdb_find__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(10);
438
+ /* harmony import */ var pouchdb_node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(11);
439
+ /* harmony import */ var pouchdb_validation__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(12);
440
+ /* harmony import */ var _databaseHelper_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(6);
441
+ /* harmony import */ var _helper_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(1);
442
+ /* harmony import */ var _server_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(20);
443
+ // #!/usr/bin/env babel-node
444
+ // -*- coding: utf-8 -*-
445
+ /** @module couchdb-web-node-plugin *//* !
446
+ region header
447
+ [Project page](https://torben.website/couchdb-web-node-plugin)
448
+
449
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
450
+
451
+ License
452
+ -------
453
+
454
+ This library written by Torben Sickert stands under a creative commons
455
+ naming 3.0 unported license.
456
+ See https://creativecommons.org/licenses/by/3.0/deed.de
457
+ endregion
458
+ */// region imports
459
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _regeneratorValues(e){if(null!=e){var t=e["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],r=0;if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length))return{next:function next(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}}throw new TypeError(_typeof(e)+" is not iterable")}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof Generator?n:Generator,u=Object.create(c.prototype);return _regeneratorDefine2(u,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],y=!1,G={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function d(t,r){return i=t,c=0,u=e,G.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!y&&f&&!o&&t<p.length;t++){var o,i=p[t],d=G.p,l=i[2];r>3?(o=l===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,G.v=n,G.n=i[1]):d<l&&(o=r<3||i[0]>n||n>l)&&(i[4]=r,i[5]=n,G.n=l,c=0))}if(o||r>1)return a;throw y=!0,n}return function(o,p,l){if(f>1)throw TypeError("Generator is already running");for(y&&1===p&&d(p,l),c=p,u=l;(t=c<2?e:u)||!y;){i||(c?c<3?(c>1&&(G.n=-1),d(c,u)):G.n=u:G.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(y=G.n<0)?u:r.call(n,G))!==a)break}catch(t){i=e,c=1,u=t}finally{f=1}}return{value:t,done:y}}}(r,o,i),!0),u}var a={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(_regeneratorDefine2(t={},n,function(){return this}),t),u=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(u),e}return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(u,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,o,"GeneratorFunction"),_regeneratorDefine2(u),_regeneratorDefine2(u,o,"Generator"),_regeneratorDefine2(u,n,function(){return this}),_regeneratorDefine2(u,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(e,r,n,t){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}_regeneratorDefine2=function _regeneratorDefine(e,r,n,t){function o(r,n){_regeneratorDefine2(e,r,function(e){return this._invoke(r,n,e)})}r?i?i(e,r,{value:n,enumerable:!t,configurable:!t,writable:!t}):e[r]=n:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(e,r,n,t)}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){return void e(n)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n)}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n)}_next(void 0)})}};// endregion
460
+ /**
461
+ * Launches an application server und triggers all some pluginable hooks on
462
+ * an event.
463
+ *//**
464
+ * Appends an application server to the web node services.
465
+ * @param state - Application state.
466
+ * @param state.configuration - Applications configuration.
467
+ * @param state.configuration.couchdb - Plugins configuration.
468
+ * @param state.services - Applications services.
469
+ * @returns Promise resolving to nothing.
470
+ */var preLoadService=/*#__PURE__*/function(){var _preLoadService=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref){var configuration,services,couchdb,triedPaths,runnerFound,_iterator,_step,runner,inPlaceRunner,_iterator2,_step2,name,binaryRunner,_iterator3,_step3,directoryPath,_iterator4,_step4,_name,binaryFilePath,backendConnectorConfiguration,modelConfiguration,models,_t,_t2,_t3,_t4,_t5;return _regenerator().w(function(_context){while(1)switch(_context.p=_context.n){case 0:configuration=_ref.configuration.couchdb,services=_ref.services;if(!Object.prototype.hasOwnProperty.call(services,"couchdb"))services.couchdb={};couchdb=services.couchdb;if(Object.prototype.hasOwnProperty.call(couchdb,"server")){_context.n=35;break}couchdb.server={};// region search for an available database server variant
471
+ triedPaths=[];runnerFound=false;_iterator=_createForOfIteratorHelper([].concat(configuration.runner.variants));_context.p=1;_iterator.s();case 2:if((_step=_iterator.n()).done){_context.n=31;break}runner=_step.value;if(!runner.packages){_context.n=14;break}inPlaceRunner=runner;runnerFound=true;_iterator2=_createForOfIteratorHelper(inPlaceRunner.packages);_context.p=3;_iterator2.s();case 4:if((_step2=_iterator2.n()).done){_context.n=9;break}name=_step2.value;_context.p=5;_context.n=6;return eval("import('".concat(name,"')"));case 6:_context.n=8;break;case 7:_context.p=7;_t=_context.v;runnerFound=false;return _context.a(3,9);case 8:_context.n=4;break;case 9:_context.n=11;break;case 10:_context.p=10;_t2=_context.v;_iterator2.e(_t2);case 11:_context.p=11;_iterator2.f();return _context.f(11);case 12:if(!runnerFound){_context.n=13;break}couchdb.server.runner=inPlaceRunner;return _context.a(3,31);case 13:return _context.a(3,30);case 14:binaryRunner=runner;_iterator3=_createForOfIteratorHelper([].concat(binaryRunner.locations));_context.p=15;_iterator3.s();case 16:if((_step3=_iterator3.n()).done){_context.n=26;break}directoryPath=_step3.value;_iterator4=_createForOfIteratorHelper([].concat(binaryRunner.names));_context.p=17;_iterator4.s();case 18:if((_step4=_iterator4.n()).done){_context.n=21;break}_name=_step4.value;binaryFilePath=(0,path__WEBPACK_IMPORTED_MODULE_2__.resolve)(directoryPath,_name);triedPaths.push(binaryFilePath);_context.n=19;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFile)(binaryFilePath);case 19:if(!_context.v){_context.n=20;break}binaryRunner.binaryFilePath=binaryFilePath;couchdb.server.runner=binaryRunner;runnerFound=true;return _context.a(3,21);case 20:_context.n=18;break;case 21:_context.n=23;break;case 22:_context.p=22;_t3=_context.v;_iterator4.e(_t3);case 23:_context.p=23;_iterator4.f();return _context.f(23);case 24:if(!runnerFound){_context.n=25;break}return _context.a(3,26);case 25:_context.n=16;break;case 26:_context.n=28;break;case 27:_context.p=27;_t4=_context.v;_iterator3.e(_t4);case 28:_context.p=28;_iterator3.f();return _context.f(28);case 29:if(!runnerFound){_context.n=30;break}return _context.a(3,31);case 30:_context.n=2;break;case 31:_context.n=33;break;case 32:_context.p=32;_t5=_context.v;_iterator.e(_t5);case 33:_context.p=33;_iterator.f();return _context.f(33);case 34:if(!runnerFound)_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("No couchdb runner found via files in one of the following","locations: \"".concat(triedPaths.join("\", \""),"\". Running pouchdb"),"locally.");// endregion
472
+ case 35:if(!Object.prototype.hasOwnProperty.call(couchdb,"connector")){backendConnectorConfiguration=couchdb.server.runner.configuration.values&&couchdb.server.runner.configuration.values["couchdb/database_dir"]?/*
473
+ NOTE: If we have a database server running outside of this
474
+ process (called via a configured binary), we need to configure
475
+ the path prefix only. Further configuration will be made via
476
+ http requests.
477
+ */{prefix:(0,path__WEBPACK_IMPORTED_MODULE_2__.resolve)(String(/*
478
+ eslint-disable
479
+ @typescript-eslint/no-unnecessary-type-assertion
480
+ */couchdb.server.runner.configuration.values["couchdb/database_dir"]/*
481
+ eslint-enable
482
+ @typescript-eslint/no-unnecessary-type-assertion
483
+ */))+"/"}:couchdb.server.runner.configuration;couchdb.backendConnector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6__["default"].plugin(pouchdb_adapter_memory__WEBPACK_IMPORTED_MODULE_4__["default"]).plugin(pouchdb_find__WEBPACK_IMPORTED_MODULE_5__["default"]).plugin(pouchdb_validation__WEBPACK_IMPORTED_MODULE_7__["default"]).plugin((0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getPouchDBPlugin */ .NN)(configuration)).defaults(backendConnectorConfiguration);// Plugins are already applied via backend connector via prototype.
484
+ couchdb.connector=pouchdb_node__WEBPACK_IMPORTED_MODULE_6__["default"].defaults((0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getConnectorOptions */ .Yp)(configuration.connector));if(configuration.debug)couchdb.connector.debug.enable("*")}modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(configuration.model);delete modelConfiguration.property.defaultDefinition;delete modelConfiguration.entities;models=(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .applyModelsInheritance */ .PA)(configuration.model);// Export validate document function to be used by other plugins.
485
+ couchdb.validateDocument=function(document,options){var _options$oldDocument;var oldDocument=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)((_options$oldDocument=options.oldDocument)!==null&&_options$oldDocument!==void 0?_options$oldDocument:document);var checkPublicModelType=Boolean(options.checkPublicModelType);document=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(document);document[configuration.model.property.name.special.updateStrategy]="migrate";if(options.type)document[modelConfiguration.property.name.special.type]=oldDocument[modelConfiguration.property.name.special.type]=options.type;try{(0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_8__/* .validateDocumentUpdate */ .Te)(/*
486
+ NOTE: Removed property marked with "null" will be removed
487
+ so final removing would be skipped if we do not use a copy
488
+ here.
489
+ */document,/*
490
+ NOTE: During processing attachments sub object will be
491
+ manipulated so copying is needed to copy to avoid
492
+ unexpected behavior in this context.
493
+ */oldDocument,{db:configuration.databaseName,name:configuration.admin.name,roles:["_admin"]},// NOTE: We need a copy to ignore validated document caches.s
494
+ (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(configuration.security[configuration.databaseName]),modelConfiguration,models,checkPublicModelType);return true}catch(error){if(Object.prototype.hasOwnProperty.call(error,"forbidden")&&error.forbidden.startsWith("NoChange:"))return true;return error}};case 36:return _context.a(2)}},_callee,null,[[17,22,23,24],[15,27,28,29],[5,7],[3,10,11,12],[1,32,33,34]])}));function preLoadService(_x){return _preLoadService.apply(this,arguments)}return preLoadService}();/**
495
+ * Start database's child process and return a Promise which observes this
496
+ * service.
497
+ * @param state - Application state.
498
+ * @param state.configuration - Applications configuration.
499
+ * @param state.services - Applications services.
500
+ * @returns A mapping to promises which correspond to the plugin specific
501
+ * continues services.
502
+ */var loadService=/*#__PURE__*/function(){var _loadService=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(state){var configuration,services,specialNames,idName,revisionName,typeName,promise,couchdb,_determineForeignKeySelectors,_i4,_Object$entries4,_Object$entries4$_i,modelName,model,foreignKeySelectors,_data,urlPrefix,authorizationHeader,headers,createAdminUser,unauthenticatedUserDatabaseConnection,authenticatedUserDatabaseConnection,userDatabaseConnection,_iterator6,_step6,_step6$value,name,password,roles,runner,_iterator7,_step7,prefix,_i8,_Object$entries6,_Object$entries6$_i,subPath,_value,fullPath,url,response,changeNeeded,_yield$globalContext$,givenAuthorizationHeaders,_authorizationHeader,securityConfigurations,_i9,_Object$entries7,_Object$entries7$_i,databaseName,securityObject,fullSecurityObject,_fullSecurityObject$a,_fullSecurityObject$a2,_fullSecurityObject$m,_fullSecurityObject$m2,_response,modelConfiguration,models,databaseHelperModuleName,databaseHelperCode,_iterator8,_step8,_type,code,_i0,_Object$entries8,_Object$entries8$_i,_modelName2,_model,_i1,_Object$entries9,_Object$entries9$_i,_name2,specification,_iterator9,_step9,constraint,_iterator0,_step0,type,_constraint,migrators,_iterator1,_step1,file,extension,_name3,documents,_iterator10,_step10,_document,_forbidden,_iterator11,_step11,retrievedDocument,_document2,newDocument,_iterator12,_step12,_name4,_result,result,genericIndexes,_i10,_Object$entries0,_Object$entries0$_i,_modelName3,_model2,_iterator13,_step13,propertyName,_name5,found,_iterator14,_step14,index,_t9,_t0,_t1,_t10,_t11,_t12,_t13,_t14,_t15,_t16,_t17,_t18,_t19,_t20,_t21,_t22,_t23,_t24,_t25,_t26,_t27,_t28,_t29,_t30,_t31,_t32,_t33,_t34,_t35,_t36,_t37,_t38,_t39;return _regenerator().w(function(_context5){while(1)switch(_context5.p=_context5.n){case 0:if(clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch){_context5.n=1;break}throw new Error("Missing fetch implementation.");case 1:configuration=state.configuration,services=state.services;specialNames=configuration.couchdb.model.property.name.special;idName=specialNames.id,revisionName=specialNames.revision,typeName=specialNames.type;promise=null;couchdb=services.couchdb;// region add create/reinitialize materialized views functionality
503
+ couchdb.reinitializeMaterializedViews=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(){var _i,_Object$entries,_Object$entries$_i,id,viewConfiguration,viewDocument,_i2,_Object$entries2,_Object$entries2$_i,name,viewDataConfiguration,rawData,result;return _regenerator().w(function(_context2){while(1)switch(_context2.n){case 0:_i=0,_Object$entries=Object.entries(configuration.couchdb.materializedViews);case 1:if(!(_i<_Object$entries.length)){_context2.n=7;break}_Object$entries$_i=_slicedToArray(_Object$entries[_i],2),id=_Object$entries$_i[0],viewConfiguration=_Object$entries$_i[1];viewDocument=_defineProperty(_defineProperty({},specialNames.type,id),specialNames.id,id);_i2=0,_Object$entries2=Object.entries(viewConfiguration);case 2:if(!(_i2<_Object$entries2.length)){_context2.n=5;break}_Object$entries2$_i=_slicedToArray(_Object$entries2[_i2],2),name=_Object$entries2$_i[0],viewDataConfiguration=_Object$entries2$_i[1];_context2.n=3;return couchdb.connection.find(viewDataConfiguration.query);case 3:rawData=_context2.v;if(viewDataConfiguration.initialMapperExpression){result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(viewDataConfiguration.initialMapperExpression,{data:rawData.docs});if(result.error)_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not execute initial expression \""+viewDataConfiguration.initialMapperExpression+"\" for property \"".concat(name,"\" in view document"),"\"".concat(id,"\":"),result.error);else viewDocument[name]=result.result}else viewDocument[name]=rawData.docs;case 4:_i2++;_context2.n=2;break;case 5:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Initialize view ".concat(id,":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(viewDocument));_context2.n=6;return couchdb.connection.put(viewDocument);case 6:_i++;_context2.n=1;break;case 7:return _context2.a(2)}},_callee2)}));// endregion
504
+ // region add remove dangling foreign keys functionality
505
+ couchdb.foreignKeys={static:{},runtime:{}};_determineForeignKeySelectors=function determineForeignKeySelectors(model,path){if(path===void 0){path=[]}var result=[];for(var _i3=0,_Object$entries3=Object.entries(model);_i3<_Object$entries3.length;_i3++){var _Object$entries3$_i=_slicedToArray(_Object$entries3[_i3],2),name=_Object$entries3$_i[0],property=_Object$entries3$_i[1];if(typeof property.type==="string"){if(Object.prototype.hasOwnProperty.call(configuration.couchdb.model.entities,property.type))result=result.concat(_determineForeignKeySelectors(configuration.couchdb.model.entities[property.type],path.concat(name)));else if(property.type.startsWith("foreignKey:")){var foreignModelName=property.type.substring("foreignKey:".length);if(foreignModelName.endsWith("[]"))foreignModelName=foreignModelName.substring(0,foreignModelName.length-2);result.push({targetModelName:foreignModelName,propertySelector:path.concat(name)})}}else if((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(property.type))result=result.concat(_determineForeignKeySelectors(property.type,path.concat(name)))}return result};for(_i4=0,_Object$entries4=Object.entries(configuration.couchdb.model.entities);_i4<_Object$entries4.length;_i4++){_Object$entries4$_i=_slicedToArray(_Object$entries4[_i4],2),modelName=_Object$entries4$_i[0],model=_Object$entries4$_i[1];foreignKeySelectors=_determineForeignKeySelectors(model);if(foreignKeySelectors.length>0)couchdb.foreignKeys.static[modelName]=foreignKeySelectors}couchdb.removeDanglingForeignKeys=/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(){var addReference,_i5,_Object$entries5,_Object$entries5$_i,_modelName,staticForeignKeys,selectors,query,_i6,_arr,document,_iterator5,_step5,selector,_evaluateSelectorUnti,_evaluateSelectorUnti2,object,lastKey,key,value,_loop,_i7,_arr2,_t7,_t8;return _regenerator().w(function(_context4){while(1)switch(_context4.p=_context4.n){case 0:couchdb.foreignKeys.runtime={};addReference=function addReference(id,selector,targetID){if(Array.isArray(couchdb.foreignKeys.runtime[id]))couchdb.foreignKeys.runtime[id].push({propertySelector:selector.split("."),id:targetID});else couchdb.foreignKeys.runtime[id]=[{propertySelector:selector.split("."),id:targetID}]};_i5=0,_Object$entries5=Object.entries(couchdb.foreignKeys.static);case 1:if(!(_i5<_Object$entries5.length)){_context4.n=20;break}_Object$entries5$_i=_slicedToArray(_Object$entries5[_i5],2),_modelName=_Object$entries5$_i[0],staticForeignKeys=_Object$entries5$_i[1];selectors=staticForeignKeys.map(function(_ref4){var propertySelector=_ref4.propertySelector;return propertySelector.join(".")});query={selector:{$and:[_defineProperty({},typeName,_modelName),{$or:selectors.map(function(selector){return _defineProperty({},selector,{$exists:true})})}]},fields:[idName].concat(selectors)};_i6=0;_context4.n=2;return couchdb.connection.find(query);case 2:_arr=_context4.v.docs;case 3:if(!(_i6<_arr.length)){_context4.n=19;break}document=_arr[_i6];_iterator5=_createForOfIteratorHelper(selectors);_context4.p=4;_iterator5.s();case 5:if((_step5=_iterator5.n()).done){_context4.n=15;break}selector=_step5.value;_evaluateSelectorUnti=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluateSelectorUntilLastObject)(selector,document),_evaluateSelectorUnti2=_slicedToArray(_evaluateSelectorUnti,2),object=_evaluateSelectorUnti2[0],lastKey=_evaluateSelectorUnti2[1];key=lastKey;value=object[key];if(value){_context4.n=6;break}return _context4.a(3,14);case 6:if(!Array.isArray(value)){_context4.n=10;break}_loop=/*#__PURE__*/_regenerator().m(function _loop(){var id,_t6;return _regenerator().w(function(_context3){while(1)switch(_context3.n){case 0:id=_arr2[_i7];_context3.n=1;return couchdb.connection.find({selector:_defineProperty({},idName,id)});case 1:_t6=_context3.v.docs.length;if(!(_t6===0)){_context3.n=3;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Found dangling document reference","(".concat(id,") in document"),"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(document)," of type"),"\"".concat(_modelName,"\" in array of property"),"\"".concat(selector,"\". Removing the reference."));object[key]=value.filter(function(givenID){return givenID!==id});_context3.n=2;return couchdb.connection.put(document);case 2:_context3.n=4;break;case 3:addReference(id,selector,document[idName]);case 4:return _context3.a(2)}},_loop)});_i7=0,_arr2=value;case 7:if(!(_i7<_arr2.length)){_context4.n=9;break}return _context4.d(_regeneratorValues(_loop()),8);case 8:_i7++;_context4.n=7;break;case 9:_context4.n=14;break;case 10:_context4.n=11;return couchdb.connection.find({selector:_defineProperty({},idName,value)});case 11:_t7=_context4.v.docs.length;if(!(_t7===0)){_context4.n=13;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Found dangling document reference","(".concat(value,") in document"),"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(document)," of type"),"\"".concat(_modelName,"\" in property \"").concat(selector,"\"."),"Removing the reference.");object[key]=null;_context4.n=12;return couchdb.connection.put(document);case 12:_context4.n=14;break;case 13:addReference(value,selector,document[idName]);case 14:_context4.n=5;break;case 15:_context4.n=17;break;case 16:_context4.p=16;_t8=_context4.v;_iterator5.e(_t8);case 17:_context4.p=17;_iterator5.f();return _context4.f(17);case 18:_i6++;_context4.n=3;break;case 19:_i5++;_context4.n=1;break;case 20:return _context4.a(2)}},_callee3,null,[[4,16,17,18]])}));// endregion
506
+ if(!Object.prototype.hasOwnProperty.call(couchdb.server,"runner")){_context5.n=3;break}_context5.n=2;return (0,_server_js__WEBPACK_IMPORTED_MODULE_10__/* .start */ .ni)(state,(_data=state.data)===null||_data===void 0?void 0:_data.couchdbWebNodeExpressUtilities);case 2:couchdb.server.restart=_server_js__WEBPACK_IMPORTED_MODULE_10__/* .restart */ .S8;couchdb.server.start=_server_js__WEBPACK_IMPORTED_MODULE_10__/* .start */ .ni;couchdb.server.stop=_server_js__WEBPACK_IMPORTED_MODULE_10__/* .stop */ .ds;promise=new Promise(function(resolve,reject){// NOTE: These callbacks can be reassigned during server restart.
507
+ couchdb.server.resolve=resolve;couchdb.server.reject=reject});case 3:if(!Object.prototype.hasOwnProperty.call(couchdb,"connection")){_context5.n=4;break}return _context5.a(2,{couchdb:promise});case 4:urlPrefix=(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getEffectiveURL */ .Nk)(configuration.couchdb,false);authorizationHeader={Authorization:"Basic "+Buffer.from("".concat(configuration.couchdb.admin.name,":")+configuration.couchdb.admin.password,"binary").toString("base64")};headers={Accept:"application/json","Content-Type":"application/json"};// region ensure presence of global admin user
508
+ if(!configuration.couchdb.ensureAdminPresence){_context5.n=19;break}createAdminUser=function createAdminUser(){_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("No admin user available. Automatically creating admin user","\"".concat(configuration.couchdb.admin.name,"\"."));if(!clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch)throw new Error("Missing fetch implementation.");return clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch("".concat(urlPrefix,"/")+"".concat(couchdb.server.runner.adminUserConfigurationPath,"/")+configuration.couchdb.admin.name,{body:"\"".concat(configuration.couchdb.admin.password,"\""),method:"PUT"})};unauthenticatedUserDatabaseConnection=new couchdb.connector("".concat(urlPrefix,"/_users"),(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getConnectorOptions */ .Yp)(configuration.couchdb.connector));_context5.p=5;_context5.n=6;return unauthenticatedUserDatabaseConnection.allDocs({limit:1});case 6:_context5.n=7;return createAdminUser();case 7:_context5.n=11;break;case 8:_context5.p=8;_t9=_context5.v;if(!(_t9.name!=="unauthorized")){_context5.n=11;break}if(!(_t9.name==="not_found")){_context5.n=10;break}_context5.n=9;return createAdminUser();case 9:_context5.n=11;break;case 10:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.error("Can't check for admin user or create a new one:","\"".concat(configuration.couchdb.admin.name,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t9));case 11:_context5.p=11;_context5.n=12;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .waitWithTimeout */ .e$)(unauthenticatedUserDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"unauthenticated user database client connection to close");case 12:return _context5.f(11);case 13:// NOTE: Check if newly created admin user is able to log in.
509
+ authenticatedUserDatabaseConnection=new couchdb.connector("".concat(urlPrefix,"/_users"),_objectSpread(_objectSpread({},(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getConnectorOptions */ .Yp)(configuration.couchdb.connector)),{},{auth:{username:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}}));_context5.p=14;_context5.n=15;return authenticatedUserDatabaseConnection.allDocs({limit:1});case 15:_context5.n=17;break;case 16:_context5.p=16;_t0=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.error("Can't login as admin user","\"".concat(configuration.couchdb.admin.name,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t0));case 17:_context5.p=17;_context5.n=18;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .waitWithTimeout */ .e$)(authenticatedUserDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"authenticated user database client connection to close");case 18:return _context5.f(17);case 19:if(!configuration.couchdb.ensureUserPresence){_context5.n=36;break}userDatabaseConnection=new couchdb.connector("".concat(urlPrefix,"/_users"),_objectSpread(_objectSpread({},(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .getConnectorOptions */ .Yp)(configuration.couchdb.connector)),{},{auth:{username:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}}));_iterator6=_createForOfIteratorHelper(configuration.couchdb.users);_context5.p=20;_iterator6.s();case 21:if((_step6=_iterator6.n()).done){_context5.n=33;break}_step6$value=_step6.value,name=_step6$value.name,password=_step6$value.password,roles=_step6$value.roles;_context5.p=22;_context5.n=23;return userDatabaseConnection.get("org.couchdb.user:".concat(name));case 23:_context5.n=30;break;case 24:_context5.p=24;_t1=_context5.v;if(!(_t1.name==="not_found")){_context5.n=29;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Create missing database user \"".concat(name,"\"."));_context5.p=25;_context5.n=26;return userDatabaseConnection.put(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({},configuration.couchdb.model.property.name.special.id,"org.couchdb.user:".concat(name)),"name",name),"password",password),"roles",roles),"type","user"));case 26:_context5.n=28;break;case 27:_context5.p=27;_t10=_context5.v;throw new Error("Couldn't create missing user \"".concat(name,"\": ")+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t10),{cause:_t10});case 28:_context5.n=30;break;case 29:throw new Error("Couldn't check for presence of user \"".concat(name,"\": ")+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t1),{cause:_t1});case 30:_context5.p=30;_context5.n=31;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .waitWithTimeout */ .e$)(userDatabaseConnection.close(),configuration.couchdb.closeTimeoutInSeconds,"user database client connection to close");case 31:return _context5.f(30);case 32:_context5.n=21;break;case 33:_context5.n=35;break;case 34:_context5.p=34;_t11=_context5.v;_iterator6.e(_t11);case 35:_context5.p=35;_iterator6.f();return _context5.f(35);case 36:if(!(configuration.couchdb.model.updateConfiguration&&!Object.prototype.hasOwnProperty.call(couchdb.server.runner,"packages"))){_context5.n=60;break}runner=couchdb.server.runner;_iterator7=_createForOfIteratorHelper(runner.configuration.prefixes);_context5.p=37;_iterator7.s();case 38:if((_step7=_iterator7.n()).done){_context5.n=57;break}prefix=_step7.value;_i8=0,_Object$entries6=Object.entries(runner.configuration.values);case 39:if(!(_i8<_Object$entries6.length)){_context5.n=56;break}_Object$entries6$_i=_slicedToArray(_Object$entries6[_i8],2),subPath=_Object$entries6$_i[0],_value=_Object$entries6$_i[1];fullPath="/".concat(prefix).concat(prefix.trim()?"/":"").concat(subPath);url="".concat(urlPrefix).concat(fullPath);response=void 0;_context5.p=40;_context5.n=41;return clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch(url,{headers:authorizationHeader});case 41:response=_context5.v;_context5.n=43;break;case 42:_context5.p=42;_t12=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Configuration \"".concat(fullPath,"\" (with desired value"),"[".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_value),"]) couldn't be determined:"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t12));case 43:if(!response){_context5.n=55;break}if(!response.ok){_context5.n=54;break}changeNeeded=true;if(!(typeof response.text==="function")){_context5.n=47;break}_context5.p=44;_t13=_value;_context5.n=45;return response[typeof _value==="string"?"text":"json"]();case 45:_t14=_context5.v;changeNeeded=_t13===_t14;_context5.n=47;break;case 46:_context5.p=46;_t15=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Error checking current value of","\"".concat(fullPath,"\" to be"),"[".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_value),"]:"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t15));case 47:if(!changeNeeded){_context5.n=52;break}_context5.p=48;_context5.n=49;return clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch(url,{body:"\"".concat(_value,"\""),headers:authorizationHeader,method:"PUT"});case 49:_context5.n=51;break;case 50:_context5.p=50;_t16=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.error("Configuration \"".concat(fullPath,"\" couldn't be"),"applied to [".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_value),"]:"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t16));case 51:_context5.n=53;break;case 52:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Configuration \"".concat(fullPath,"\" is already set"),"to desired value [".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_value),"]."));case 53:_context5.n=55;break;case 54:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Configuration \"".concat(fullPath,"\" does not exist"),"(desired value [".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_value),"]). Response"),"code is ".concat(String(response.status),"."));case 55:_i8++;_context5.n=39;break;case 56:_context5.n=38;break;case 57:_context5.n=59;break;case 58:_context5.p=58;_t17=_context5.v;_iterator7.e(_t17);case 59:_context5.p=59;_iterator7.f();return _context5.f(59);case 60:_context5.n=61;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .initializeConnection */ .Tg)(services,configuration);case 61:if(!configuration.couchdb.ensureSecuritySettingsPresence){_context5.n=70;break}_context5.n=62;return clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch("".concat(urlPrefix,"/_session"),{body:JSON.stringify({name:configuration.couchdb.admin.name,password:configuration.couchdb.admin.password}),headers:_objectSpread({},headers),method:"POST"});case 62:_yield$globalContext$=_context5.v;givenAuthorizationHeaders=_yield$globalContext$.headers;_authorizationHeader={Cookie:givenAuthorizationHeaders.get("set-cookie")};securityConfigurations=configuration.couchdb.security;_i9=0,_Object$entries7=Object.entries(securityConfigurations);case 63:if(!(_i9<_Object$entries7.length)){_context5.n=70;break}_Object$entries7$_i=_slicedToArray(_Object$entries7[_i9],2),databaseName=_Object$entries7$_i[0],securityObject=_Object$entries7$_i[1];if(!(databaseName==="_default")){_context5.n=64;break}return _context5.a(3,69);case 64:fullSecurityObject=securityObject;if(databaseName!=="_users"){if(!fullSecurityObject.admins)fullSecurityObject.admins={names:[],roles:[]};if(securityConfigurations._default.admins){if(securityConfigurations._default.admins.names)fullSecurityObject.admins.names=securityConfigurations._default.admins.names.concat((_fullSecurityObject$a=fullSecurityObject.admins.names)!==null&&_fullSecurityObject$a!==void 0?_fullSecurityObject$a:[]);if(securityConfigurations._default.admins.roles)fullSecurityObject.admins.roles=securityConfigurations._default.admins.roles.concat((_fullSecurityObject$a2=fullSecurityObject.admins.roles)!==null&&_fullSecurityObject$a2!==void 0?_fullSecurityObject$a2:[])}if(!fullSecurityObject.members)fullSecurityObject.members={names:[],roles:[]};if(securityConfigurations._default.members){if(securityConfigurations._default.members.names)fullSecurityObject.members.names=securityConfigurations._default.members.names.concat((_fullSecurityObject$m=fullSecurityObject.members.names)!==null&&_fullSecurityObject$m!==void 0?_fullSecurityObject$m:[]);if(securityConfigurations._default.members.roles)fullSecurityObject.members.roles=securityConfigurations._default.members.roles.concat((_fullSecurityObject$m2=fullSecurityObject.members.roles)!==null&&_fullSecurityObject$m2!==void 0?_fullSecurityObject$m2:[])}}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Apply security settings for database \"".concat(databaseName,"\":"),(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(fullSecurityObject));_context5.p=65;_context5.n=66;return clientnode__WEBPACK_IMPORTED_MODULE_0__.globalContext.fetch("".concat(urlPrefix,"/").concat(databaseName,"/_security"),{body:JSON.stringify(fullSecurityObject),headers:_objectSpread(_objectSpread({},headers),_authorizationHeader),method:"PUT"});case 66:_response=_context5.v;if(_response.ok){_context5.n=67;break}throw new Error(_response.statusText);case 67:_context5.n=69;break;case 68:_context5.p=68;_t18=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.error("Security object for database \"".concat(databaseName,"\" couldn't"),"be applied:",(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t18));case 69:_i9++;_context5.n=63;break;case 70:// endregion
510
+ modelConfiguration=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(configuration.couchdb.model);delete modelConfiguration.property.defaultDefinition;delete modelConfiguration.entities;models=configuration.couchdb.model.entities;if(!configuration.couchdb.model.updateValidation){_context5.n=104;break}/*
511
+ NOTE: We import pre-transpiled JavaScript code here. The module
512
+ specifier is kept in a variable so the bundler does not statically
513
+ resolve and emit the referenced source file (which would overwrite
514
+ our own source file since build output and sources share the same
515
+ directory). Resolution is therefore deferred to runtime.
516
+ */databaseHelperModuleName="./databaseHelper.cjs";_context5.n=71;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile)((0,url__WEBPACK_IMPORTED_MODULE_3__.fileURLToPath)(__webpack_import_meta__.resolve(databaseHelperModuleName)),{encoding:configuration.core.encoding,flag:"r"});case 71:databaseHelperCode=_context5.v;// region generate/update authentication/validation code
517
+ _iterator8=_createForOfIteratorHelper([{description:"Authorization",methodName:"authorize",name:"authorization",serializedParameter:JSON.stringify((0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .determineModelRolesMapping */ .Ic)(configuration.couchdb.model))+", false, "+JSON.stringify(configuration.couchdb.model.property.name.special)},{description:"Model specification",methodName:"validateDocumentUpdate",name:"validation",serializedParameter:"".concat(JSON.stringify(modelConfiguration),", ")+JSON.stringify(models)}]);_context5.p=72;_iterator8.s();case 73:if((_step8=_iterator8.n()).done){_context5.n=78;break}_type=_step8.value;/*
518
+ NOTE: This code should be widely supported since no transpiler
519
+ can interact here easily.
520
+ NOTE: The "require" function is provided by the couchdb
521
+ environment and not a node commonjs module loading method.
522
+ */code="function(...parameters) {\n"+" return require('helper').".concat(_type.methodName)+"(...parameters.concat([".concat(_type.serializedParameter,"]")+"))\n"+"}";_context5.p=74;/* eslint-disable @typescript-eslint/no-implied-eval */new Function("return ".concat(code));/* eslint-enable @typescript-eslint/no-implied-eval */_context5.n=76;break;case 75:_context5.p=75;_t19=_context5.v;throw new Error("Generated ".concat(_type.name," code \"").concat(code,"\" doesn't compile:")+" ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t19)),{cause:_t19});case 76:if(configuration.core.debug)_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.debug("".concat(_type.name," code: \n\n\"").concat(code,"\" integrated."));_context5.n=77;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .ensureValidationDocumentPresence */ .EB)(couchdb.connection,_type.name,{helper:databaseHelperCode,// eslint-disable-next-line camelcase
523
+ validate_doc_update:code},_type.description,true,idName,revisionName,specialNames.designDocumentNamePrefix);case 77:_context5.n=73;break;case 78:_context5.n=80;break;case 79:_context5.p=79;_t20=_context5.v;_iterator8.e(_t20);case 80:_context5.p=80;_iterator8.f();return _context5.f(80);case 81:_i0=0,_Object$entries8=Object.entries(models);case 82:if(!(_i0<_Object$entries8.length)){_context5.n=104;break}_Object$entries8$_i=_slicedToArray(_Object$entries8[_i0],2),_modelName2=_Object$entries8$_i[0],_model=_Object$entries8$_i[1];_i1=0,_Object$entries9=Object.entries(_model);case 83:if(!(_i1<_Object$entries9.length)){_context5.n=103;break}_Object$entries9$_i=_slicedToArray(_Object$entries9[_i1],2),_name2=_Object$entries9$_i[0],specification=_Object$entries9$_i[1];if(![specialNames.constraint.execution,specialNames.constraint.expression].includes(_name2)){_context5.n=93;break}_iterator9=_createForOfIteratorHelper([].concat(specification));_context5.p=84;_iterator9.s();case 85:if((_step9=_iterator9.n()).done){_context5.n=89;break}constraint=_step9.value;if(!constraint.description){_context5.n=88;break}_context5.p=86;new Function("return ".concat(constraint.description));_context5.n=88;break;case 87:_context5.p=87;_t21=_context5.v;throw new Error("Specified constraint description \""+"".concat(constraint.description,"\" for model ")+"\"".concat(_modelName2,"\" doesn't compile: ")+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t21),{cause:_t21});case 88:_context5.n=85;break;case 89:_context5.n=91;break;case 90:_context5.p=90;_t22=_context5.v;_iterator9.e(_t22);case 91:_context5.p=91;_iterator9.f();return _context5.f(91);case 92:_context5.n=102;break;case 93:_iterator0=_createForOfIteratorHelper(["conflictingConstraintExpression","conflictingConstraintExecution","constraintExpression","constraintExecution"]);_context5.p=94;_iterator0.s();case 95:if((_step0=_iterator0.n()).done){_context5.n=99;break}type=_step0.value;if(!(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isObject)(specification)){_context5.n=98;break}_constraint=specification[type];/*
524
+ eslint-disable
525
+ @typescript-eslint/no-implied-eval
526
+ */if(!(_constraint!==null&&_constraint!==void 0&&_constraint.description)){_context5.n=98;break}_context5.p=96;new Function(_constraint.description);_context5.n=98;break;case 97:_context5.p=97;_t23=_context5.v;throw new Error("Specified constraint "+"description \""+_constraint.description+"\" for model \"".concat(_modelName2,"\" in ")+"property \"".concat(_name2,"\" as \"").concat(type,"\"")+" doesn't compile: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t23),{cause:_t23});case 98:_context5.n=95;break;case 99:_context5.n=101;break;case 100:_context5.p=100;_t24=_context5.v;_iterator0.e(_t24);case 101:_context5.p=101;_iterator0.f();return _context5.f(101);case 102:_i1++;_context5.n=83;break;case 103:_i0++;_context5.n=82;break;case 104:if(!configuration.couchdb.model.autoMigrationPath){_context5.n=153;break}migrators={};_context5.n=105;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isDirectory)((0,path__WEBPACK_IMPORTED_MODULE_2__.resolve)(configuration.couchdb.model.autoMigrationPath));case 105:if(!_context5.v){_context5.n=130;break}_t25=_createForOfIteratorHelper;_context5.n=106;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.walkDirectoryRecursively)((0,path__WEBPACK_IMPORTED_MODULE_2__.resolve)(configuration.couchdb.model.autoMigrationPath),configuration.couchdb.debug?clientnode__WEBPACK_IMPORTED_MODULE_0__.NOOP:function(file){return!["debug","deprecated"].includes(file.name)});case 106:_iterator1=_t25(_context5.v);_context5.p=107;_iterator1.s();case 108:if((_step1=_iterator1.n()).done){_context5.n=127;break}file=_step1.value;extension=(0,path__WEBPACK_IMPORTED_MODULE_2__.extname)(file.name);_name3=(0,path__WEBPACK_IMPORTED_MODULE_2__.basename)(file.name,extension);if(!(extension===".json")){_context5.n=124;break}documents=void 0;_context5.p=109;_t26=[];_t27=JSON;_context5.n=110;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_1__.readFile)(file.path,{encoding:configuration.core.encoding,flag:"r"});case 110:documents=_t26.concat.call(_t26,_t27.parse.call(_t27,_context5.v));_context5.n=112;break;case 111:_context5.p=111;_t28=_context5.v;throw new Error("Parsing document \"".concat(file.path,"\" to include ")+"by automigration of has failed: "+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t28),{cause:_t28});case 112:if(documents.length===1){if(!documents[0][idName])documents[0][idName]=_name3;if(!documents[0][revisionName])documents[0][revisionName]="0-upsert"}_iterator10=_createForOfIteratorHelper(documents);_context5.p=113;_iterator10.s();case 114:if((_step10=_iterator10.n()).done){_context5.n=120;break}_document=_step10.value;_context5.p=115;_context5.n=116;return couchdb.connection.put(_document);case 116:_context5.n=118;break;case 117:_context5.p=117;_t29=_context5.v;if((_forbidden=_t29.forbidden)!==null&&_forbidden!==void 0&&_forbidden.startsWith("NoChange:"))_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Including document \"".concat(_document[idName],"\""),"of type","\"".concat(_document[typeName],"\" hasn't"),"changed existing document.");throw new Error("Migrating document "+"\"".concat(_document[idName],"\" of type ")+"\"".concat(_document[typeName],"\" has ")+"failed: ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t29)),{cause:_t29});case 118:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Including document \"".concat(_document[idName],"\" of"),"type \"".concat(_document[typeName],"\" was"),"successful.");case 119:_context5.n=114;break;case 120:_context5.n=122;break;case 121:_context5.p=121;_t30=_context5.v;_iterator10.e(_t30);case 122:_context5.p=122;_iterator10.f();return _context5.f(122);case 123:_context5.n=126;break;case 124:if(![".js"].includes((0,path__WEBPACK_IMPORTED_MODULE_2__.extname)(file.name))){_context5.n=126;break}_context5.n=125;return __webpack_require__(13)(file.path);case 125:migrators[file.path]=_context5.v.default;case 126:_context5.n=108;break;case 127:_context5.n=129;break;case 128:_context5.p=128;_t31=_context5.v;_iterator1.e(_t31);case 129:_context5.p=129;_iterator1.f();return _context5.f(129);case 130:_t32=_createForOfIteratorHelper;_context5.n=131;return couchdb.connection.allDocs({// eslint-disable-next-line camelcase
527
+ include_docs:true});case 131:_iterator11=_t32(_context5.v.rows);_context5.p=132;_iterator11.s();case 133:if((_step11=_iterator11.n()).done){_context5.n=150;break}retrievedDocument=_step11.value;if(typeof retrievedDocument.id==="string"&&retrievedDocument.id.startsWith(configuration.couchdb.model.property.name.special.designDocumentNamePrefix)){_context5.n=149;break}_document2=retrievedDocument.doc;newDocument=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.copy)(_document2);newDocument[configuration.couchdb.model.property.name.special.updateStrategy]="migrate";_iterator12=_createForOfIteratorHelper(Object.keys(migrators).sort());_context5.p=134;_iterator12.s();case 135:if((_step12=_iterator12.n()).done){_context5.n=140;break}_name4=_step12.value;_result=void 0;_context5.p=136;_result=migrators[_name4](newDocument,_objectSpread(_objectSpread({},clientnode__WEBPACK_IMPORTED_MODULE_0__.UTILITY_SCOPE),{},{configuration:configuration,databaseHelper:_databaseHelper_js__WEBPACK_IMPORTED_MODULE_8__/* ["default"] */ .Ay,idName:idName,typeName:typeName,migrators:migrators,models:models,modelConfiguration:modelConfiguration,selfFilePath:_name4,services:services}));_context5.n=138;break;case 137:_context5.p=137;_t33=_context5.v;throw new Error("Running migrater \"".concat(_name4,"\" in document ")+(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .mayStripRepresentation */ .Ro)(_document2,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+"\" failed: ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t33)),{cause:_t33});case 138:if(_result){newDocument=_result;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Running migrater \"".concat(_name4,"\" for document"),"\"".concat(newDocument[idName],"\" (of type"),"\"".concat(newDocument[typeName],"\") was successful."))}case 139:_context5.n=135;break;case 140:_context5.n=142;break;case 141:_context5.p=141;_t34=_context5.v;_iterator12.e(_t34);case 142:_context5.p=142;_iterator12.f();return _context5.f(142);case 143:/*
528
+ Auto migration can:
529
+
530
+ - Remove not specified old properties.
531
+ - Add properties whose are missing and a default value is
532
+ specified.
533
+ - Trim existing strings if newly specified.
534
+ - Remove property values if there values equals to an empty
535
+ instance and the "emptyEqualsNull" property is set.
536
+ - Migrate types if old type "_oldType" is mentioned and
537
+ given data matches newly specified schema (you can also
538
+ provide a list of old types).
539
+ - Renames property names if "oldName" is provided in
540
+ property specification (you can also provide a list of
541
+ old names).
542
+ */result=couchdb.validateDocument(newDocument,{checkPublicModelType:true,oldDocument:_document2});if(!(result!==true)){_context5.n=145;break}if(!Object.prototype.hasOwnProperty.call(result,"forbidden")){_context5.n=144;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Document \""+(0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .mayStripRepresentation */ .Ro)(_document2,configuration.couchdb.maximumRepresentationTryLength,configuration.couchdb.maximumRepresentationLength)+"\" doesn't satisfy its schema (and can not be","migrated automatically): ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(result)));_context5.n=145;break;case 144:throw result;case 145:_context5.p=145;_context5.n=146;return couchdb.connection.put(newDocument);case 146:_context5.n=148;break;case 147:_context5.p=147;_t35=_context5.v;throw new Error("Replacing auto migrated document "+"\"".concat(newDocument[idName],"\" has failed: ")+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t35),{cause:_t35});case 148:_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Auto migrating document \"".concat(newDocument[idName],"\" was"),"successful.");case 149:_context5.n=133;break;case 150:_context5.n=152;break;case 151:_context5.p=151;_t36=_context5.v;_iterator11.e(_t36);case 152:_context5.p=152;_iterator11.f();return _context5.f(152);case 153:_context5.n=154;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .removeDeprecatedIndexes */ .Wo)(couchdb.connection,models,configuration.couchdb.model);case 154:_context5.n=155;return couchdb.connection.getIndexes();case 155:genericIndexes=_context5.v.indexes.filter(function(index){return index.name.endsWith("-GenericIndex")});if(!(configuration.couchdb.createGenericFlatIndex&&(configuration.couchdb.model.autoMigrationPath||genericIndexes.length===0))){_context5.n=172;break}_i10=0,_Object$entries0=Object.entries(models);case 156:if(!(_i10<_Object$entries0.length)){_context5.n=172;break}_Object$entries0$_i=_slicedToArray(_Object$entries0[_i10],2),_modelName3=_Object$entries0$_i[0],_model2=_Object$entries0$_i[1];if(!new RegExp(configuration.couchdb.model.property.name.typePattern.public).test(_modelName3)){_context5.n=171;break}_context5.n=157;return couchdb.connection.createIndex({index:{ddoc:"".concat(_modelName3,"-GenericIndex"),fields:[typeName],name:"".concat(_modelName3,"-GenericIndex")}});case 157:_iterator13=_createForOfIteratorHelper((0,_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .determineGenericIndexablePropertyNames */ .A5)(configuration.couchdb.model,_model2));_context5.p=158;_iterator13.s();case 159:if((_step13=_iterator13.n()).done){_context5.n=168;break}propertyName=_step13.value;_name5="".concat(_modelName3,"-").concat(propertyName,"-GenericIndex");found=false;_iterator14=_createForOfIteratorHelper(genericIndexes);_context5.p=160;_iterator14.s();case 161:if((_step14=_iterator14.n()).done){_context5.n=163;break}index=_step14.value;if(!(index.name===_name5)){_context5.n=162;break}found=true;return _context5.a(3,163);case 162:_context5.n=161;break;case 163:_context5.n=165;break;case 164:_context5.p=164;_t37=_context5.v;_iterator14.e(_t37);case 165:_context5.p=165;_iterator14.f();return _context5.f(165);case 166:if(found){_context5.n=167;break}_context5.n=167;return couchdb.connection.createIndex({index:{ddoc:_name5,fields:[typeName,propertyName],name:_name5}});case 167:_context5.n=159;break;case 168:_context5.n=170;break;case 169:_context5.p=169;_t38=_context5.v;_iterator13.e(_t38);case 170:_context5.p=170;_iterator13.f();return _context5.f(170);case 171:_i10++;_context5.n=156;break;case 172:_context5.n=173;return couchdb.reinitializeMaterializedViews();case 173:if(!(Object.keys(couchdb.foreignKeys.static).length>0)){_context5.n=174;break}_context5.n=174;return couchdb.removeDanglingForeignKeys();case 174:if(!configuration.couchdb.model.triggerInitialCompaction){_context5.n=178;break}_context5.p=175;_context5.n=176;return couchdb.connection.compact();case 176:_context5.n=178;break;case 177:_context5.p=177;_t39=_context5.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Initial database compaction has failed: ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_t39)));case 178:return _context5.a(2,{couchdb:promise})}},_callee4,null,[[175,177],[160,164,165,166],[158,169,170,171],[145,147],[136,137],[134,141,142,143],[132,151,152,153],[115,117],[113,121,122,123],[109,111],[107,128,129,130],[96,97],[94,100,101,102],[86,87],[84,90,91,92],[74,75],[72,79,80,81],[65,68],[48,50],[44,46],[40,42],[37,58,59,60],[25,27],[22,24,30,32],[20,34,35,36],[14,16,17,19],[5,8,11,13]])}));function loadService(_x2){return _loadService.apply(this,arguments)}return loadService}();/**
543
+ * Add database event listener to auto restart database server on unexpected
544
+ * server issues.
545
+ * @param state - Application state.
546
+ * @returns Promise resolving to nothing.
547
+ */var postLoadService=/*#__PURE__*/function(){var _postLoadService=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(state){var configuration,pluginAPI,services,couchdb,specialNames,numberOfErrorsThrough,changesRunnerSemaphore,_initialize;return _regenerator().w(function(_context10){while(1)switch(_context10.n){case 0:configuration=state.configuration.couchdb,pluginAPI=state.pluginAPI,services=state.services;couchdb=services.couchdb;specialNames=configuration.model.property.name.special;// region register database changes stream
548
+ /*
549
+ Maximum time one request could take + number of retries plus there
550
+ waiting times.
551
+ */numberOfErrorsThrough=0;/*
552
+ NOTE: Use this code to test changes stream reinitialization and
553
+ database server restarts. Play with length of interval to trigger error
554
+ events.
555
+ *//*
556
+ setInterval(
557
+ () => {
558
+ couchdb.changesStream.emit('error', {test: 2})
559
+ },
560
+ 6 * 1000
561
+ )
562
+ */changesRunnerSemaphore=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Semaphore(configuration.numberOfParallelChangesRunner);_initialize=/*#__PURE__*/function(){var _initialize2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(){var _couchdb$updateForeig,_couchdb$removeDangli2,_couchdb$updateMateri2;var changesConfiguration,updateMaterializedViewsChangesConfiguration,updateMaterializedViewsChangesConfigurationSelector,_i11,_Object$entries1,_Object$entries1$_i,id,viewConfiguration,orOperands,_i12,_Object$values,viewDataConfiguration,updateForeignKeysChangesConfiguration,removeDanglingForeignKeysChangesConfiguration,changesErrorHandler,updateMaterializedViewsLock;return _regenerator().w(function(_context1){while(1)switch(_context1.n){case 0:// region generic changes stream
563
+ if(couchdb.changesStream)couchdb.changesStream.cancel();changesConfiguration=configuration.changesStream;if(couchdb.lastChangesSequenceIdentifier!==undefined)changesConfiguration.since=couchdb.lastChangesSequenceIdentifier;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Initialize changes stream since","\"".concat(String(changesConfiguration.since),"\"."));couchdb.changesStream=couchdb.connection.changes(changesConfiguration);// endregion
564
+ // region materialized views changes stream
565
+ if(Object.keys(configuration.materializedViews).length){updateMaterializedViewsChangesConfiguration=configuration.updateMaterializedViewsChangesStream;if(couchdb.lastUpdateMaterializedViewsChangesSequenceIdentifier!==undefined)updateMaterializedViewsChangesConfiguration.since=couchdb.lastUpdateMaterializedViewsChangesSequenceIdentifier;updateMaterializedViewsChangesConfigurationSelector={$and:[]};for(_i11=0,_Object$entries1=Object.entries(configuration.materializedViews);_i11<_Object$entries1.length;_i11++){_Object$entries1$_i=_slicedToArray(_Object$entries1[_i11],2),id=_Object$entries1$_i[0],viewConfiguration=_Object$entries1$_i[1];orOperands=[];updateMaterializedViewsChangesConfigurationSelector.$and.push(_defineProperty({},specialNames.id,{$ne:id}),{$or:orOperands});for(_i12=0,_Object$values=Object.values(viewConfiguration);_i12<_Object$values.length;_i12++){viewDataConfiguration=_Object$values[_i12];orOperands.push(viewDataConfiguration.query.selector)}}updateMaterializedViewsChangesConfiguration.selector=updateMaterializedViewsChangesConfigurationSelector;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Initialize changes stream for views since \""+String(updateMaterializedViewsChangesConfiguration.since)+"\".");couchdb.updateMaterializedViewsChangesStream=couchdb.connection.changes(updateMaterializedViewsChangesConfiguration)}// endregion
566
+ // region foreign key changes stream
567
+ if(Object.keys(couchdb.foreignKeys.static).length>0){updateForeignKeysChangesConfiguration=configuration.updateForeignKeysChangesStream;if(couchdb.lastUpdateForeignKeysChangesSequenceIdentifier!==undefined)updateForeignKeysChangesConfiguration.since=couchdb.lastUpdateForeignKeysChangesSequenceIdentifier;updateForeignKeysChangesConfiguration.selector={$or:Object.keys(couchdb.foreignKeys.static).map(function(name){return _defineProperty({},specialNames.type,name)})};_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Initialize changes stream to update foreign keys since","\"".concat(String(updateForeignKeysChangesConfiguration.since),"\""),"with selector \""+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(updateForeignKeysChangesConfiguration.selector)+"\".");couchdb.updateForeignKeysChangesStream=couchdb.connection.changes(updateForeignKeysChangesConfiguration);removeDanglingForeignKeysChangesConfiguration=configuration.removeDanglingForeignKeysChangesStream;if(couchdb.lastRemoveDanglingForeignKeysChangesSequenceIdentifier!==undefined)removeDanglingForeignKeysChangesConfiguration.since=couchdb.lastRemoveDanglingForeignKeysChangesSequenceIdentifier;removeDanglingForeignKeysChangesConfiguration.selector={$or:Array.from(new Set(Object.values(couchdb.foreignKeys.static).flatMap(function(staticForeignKeys){return staticForeignKeys.map(function(_ref8){var targetModelName=_ref8.targetModelName;return targetModelName})}))).map(function(targetModelName){return _defineProperty({},specialNames.type,targetModelName)})};_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Initialize changes stream to remove dangling foreign keys","since \""+String(removeDanglingForeignKeysChangesConfiguration.since)+"\" with selector \""+(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(removeDanglingForeignKeysChangesConfiguration.selector)+"\".");couchdb.removeDanglingForeignKeysChangesStream=couchdb.connection.changes(removeDanglingForeignKeysChangesConfiguration)}// endregion
568
+ changesErrorHandler=/*#__PURE__*/function(){var _changesErrorHandler=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(error){var _couchdb$removeDangli,_couchdb$updateMateri,waitingTimeInSeconds;return _regenerator().w(function(_context6){while(1)switch(_context6.n){case 0:numberOfErrorsThrough+=1;if(!(numberOfErrorsThrough>configuration.changesStreamReinitializer.retries)){_context6.n=2;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Observing changes feed throws an error for","".concat(String(numberOfErrorsThrough)," times through:"),"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)," Restarting database server and"),"reinitialize changes stream...");numberOfErrorsThrough=0;couchdb.changesStream.cancel();(_couchdb$removeDangli=couchdb.removeDanglingForeignKeysChangesStream)===null||_couchdb$removeDangli===void 0||_couchdb$removeDangli.cancel();(_couchdb$updateMateri=couchdb.updateMaterializedViewsChangesStream)===null||_couchdb$updateMateri===void 0||_couchdb$updateMateri.cancel();_context6.n=1;return couchdb.server.restart(state);case 1:_context6.n=3;break;case 2:waitingTimeInSeconds=Math.min(Math.pow(configuration.changesStreamReinitializer.retryWaitingFactorInSeconds,numberOfErrorsThrough),configuration.changesStreamReinitializer.maximumRetryWaitingTimeInSeconds);_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Observing changes feed throws an error for","".concat(String(numberOfErrorsThrough)," of"),String(configuration.changesStreamReinitializer.retries),"allowed times through: ".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(error)),"Reinitializing changes stream in","".concat(String(waitingTimeInSeconds)," seconds..."));_context6.n=3;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)(1000*waitingTimeInSeconds);case 3:void _initialize();case 4:return _context6.a(2)}},_callee5)}));function changesErrorHandler(_x4){return _changesErrorHandler.apply(this,arguments)}return changesErrorHandler}();void couchdb.changesStream.on("error",changesErrorHandler);if(couchdb.updateForeignKeysChangesStream)void couchdb.updateForeignKeysChangesStream.on("error",changesErrorHandler);if(couchdb.removeDanglingForeignKeysChangesStream)void couchdb.removeDanglingForeignKeysChangesStream.on("error",changesErrorHandler);if(couchdb.updateMaterializedViewsChangesStream)void couchdb.updateMaterializedViewsChangesStream.on("error",changesErrorHandler);_context1.n=1;return pluginAPI.callStack(_objectSpread(_objectSpread({},state),{},{data:{changesStream:couchdb.changesStream,updateMaterializedViewsChangesStream:couchdb.updateMaterializedViewsChangesStream},hook:"couchdbInitializeChangesStream"}));case 1:void((_couchdb$updateForeig=couchdb.updateForeignKeysChangesStream)===null||_couchdb$updateForeig===void 0?void 0:_couchdb$updateForeig.on("change",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(change){var _i13,_Object$entries10,_Object$entries10$_i,documentID,runtimeForeignKeys,documents,_document3,selectors,_document4,_iterator15,_step15,_selector5,documentIDs,_iterator16,_step16,_documentID;return _regenerator().w(function(_context7){while(1)switch(_context7.n){case 0:numberOfErrorsThrough=0;/*
569
+ We clear all references to this document since we build
570
+ them up again afterward.
571
+ */for(_i13=0,_Object$entries10=Object.entries(couchdb.foreignKeys.runtime);_i13<_Object$entries10.length;_i13++){_Object$entries10$_i=_slicedToArray(_Object$entries10[_i13],2),documentID=_Object$entries10$_i[0],runtimeForeignKeys=_Object$entries10$_i[1];couchdb.foreignKeys.runtime[documentID]=runtimeForeignKeys.filter(function(_ref1){var id=_ref1.id;return id!==change.id})}if(change.deleted){_context7.n=4;break}_context7.n=1;return couchdb.connection.find({selector:_defineProperty({},specialNames.id,change.id),fields:[specialNames.type]});case 1:documents=_context7.v.docs;if(!(documents.length===0)){_context7.n=2;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not find document with id \"".concat(change.id,"\""),"remembered as foreign key source.");_context7.n=4;break;case 2:_document3=documents[0];selectors=couchdb.foreignKeys.static[_document3[specialNames.type]].map(function(_ref10){var propertySelector=_ref10.propertySelector;return propertySelector});_context7.n=3;return couchdb.connection.find({selector:_defineProperty({},specialNames.id,change.id),fields:selectors.map(function(selector){return selector.join(".")})});case 3:documents=_context7.v.docs;if(documents.length===0)_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not find document with id","\"".concat(change.id,"\" remembered as foreign"),"key source.");else{_document4=documents[0];_iterator15=_createForOfIteratorHelper(selectors);try{for(_iterator15.s();!(_step15=_iterator15.n()).done;){_selector5=_step15.value;documentIDs=[].concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluateSelector)(_selector5,_document4));_iterator16=_createForOfIteratorHelper(documentIDs);try{for(_iterator16.s();!(_step16=_iterator16.n()).done;){_documentID=_step16.value;if(_documentID){if(!Object.prototype.hasOwnProperty.call(couchdb.foreignKeys.runtime,_documentID))couchdb.foreignKeys.runtime[_documentID]=[];couchdb.foreignKeys.runtime[_documentID].push({propertySelector:_selector5,id:change.id})}}}catch(err){_iterator16.e(err)}finally{_iterator16.f()}}}catch(err){_iterator15.e(err)}finally{_iterator15.f()}}case 4:couchdb.lastUpdateForeignKeysChangesSequenceIdentifier=change.seq;case 5:return _context7.a(2)}},_callee6)}))));void((_couchdb$removeDangli2=couchdb.removeDanglingForeignKeysChangesStream)===null||_couchdb$removeDangli2===void 0?void 0:_couchdb$removeDangli2.on("change",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(change){var _iterator17,_step17,_step17$value,propertySelector,_id,_selector6,documents,_document5,_evaluateSelectorUnti3,_evaluateSelectorUnti4,_object,lastKey,_key,_value2,_t40,_t41;return _regenerator().w(function(_context8){while(1)switch(_context8.p=_context8.n){case 0:numberOfErrorsThrough=0;if(!(change.deleted&&Object.prototype.hasOwnProperty.call(couchdb.foreignKeys.runtime,change.id))){_context8.n=13;break}_iterator17=_createForOfIteratorHelper(couchdb.foreignKeys.runtime[change.id]);_context8.p=1;_iterator17.s();case 2:if((_step17=_iterator17.n()).done){_context8.n=9;break}_step17$value=_step17.value,propertySelector=_step17$value.propertySelector,_id=_step17$value.id;_selector6=propertySelector.join(".");_context8.n=3;return couchdb.connection.find({selector:_defineProperty({},specialNames.id,_id),fields:[specialNames.id,_selector6]});case 3:documents=_context8.v.docs;if(!(documents.length===0)){_context8.n=4;break}_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not find document with id \"".concat(_id,"\""),"remembered as foreign key source.");return _context8.a(3,8);case 4:_document5=documents[0];_evaluateSelectorUnti3=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluateSelectorUntilLastObject)(_selector6,_document5),_evaluateSelectorUnti4=_slicedToArray(_evaluateSelectorUnti3,2),_object=_evaluateSelectorUnti4[0],lastKey=_evaluateSelectorUnti4[1];_key=lastKey;_value2=_object[_key];_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Found dangling document reference","(".concat(change.id,") in document"),"".concat((0,clientnode__WEBPACK_IMPORTED_MODULE_0__.represent)(_document5)," in property"),"\"".concat(_selector6,"\". Removing the reference."));if(Array.isArray(_value2))_object[_key]=_value2.filter(function(id){return id!==change.id});else _object[_key]=null;_document5[specialNames.revision]="0-latest";_context8.p=5;_context8.n=6;return couchdb.connection.put(_document5);case 6:_context8.n=8;break;case 7:_context8.p=7;_t40=_context8.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not remove dangling foreign key","relation:",_t40);case 8:_context8.n=2;break;case 9:_context8.n=11;break;case 10:_context8.p=10;_t41=_context8.v;_iterator17.e(_t41);case 11:_context8.p=11;_iterator17.f();return _context8.f(11);case 12:delete couchdb.foreignKeys.runtime[change.id];case 13:couchdb.lastRemoveDanglingForeignKeysChangesSequenceIdentifier=change.seq;case 14:return _context8.a(2)}},_callee7,null,[[5,7],[1,10,11,12]])}))));updateMaterializedViewsLock=new clientnode__WEBPACK_IMPORTED_MODULE_0__.Lock;void((_couchdb$updateMateri2=couchdb.updateMaterializedViewsChangesStream)===null||_couchdb$updateMateri2===void 0?void 0:_couchdb$updateMateri2.on("change",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(change){var _i14,_Object$entries11,_Object$entries11$_i,_id2,_viewConfiguration,viewDocument,hasChanges,_i15,_Object$entries12,_Object$entries12$_i,name,_viewDataConfiguration,result,_t42;return _regenerator().w(function(_context9){while(1)switch(_context9.p=_context9.n){case 0:numberOfErrorsThrough=0;_i14=0,_Object$entries11=Object.entries(configuration.materializedViews);case 1:if(!(_i14<_Object$entries11.length)){_context9.n=8;break}_Object$entries11$_i=_slicedToArray(_Object$entries11[_i14],2),_id2=_Object$entries11$_i[0],_viewConfiguration=_Object$entries11$_i[1];viewDocument=_defineProperty({},specialNames.id,_id2);_context9.p=2;_context9.n=3;return updateMaterializedViewsLock.acquire(_id2);case 3:hasChanges=false;for(_i15=0,_Object$entries12=Object.entries(_viewConfiguration);_i15<_Object$entries12.length;_i15++){_Object$entries12$_i=_slicedToArray(_Object$entries12[_i15],2),name=_Object$entries12$_i[0],_viewDataConfiguration=_Object$entries12$_i[1];if(_viewDataConfiguration.updateExpression){result=(0,clientnode__WEBPACK_IMPORTED_MODULE_0__.evaluate)(_viewDataConfiguration.updateExpression,_objectSpread(_objectSpread({deleted:false},change),{},{document:change.doc}));if(result.error)_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Could not execute update","expression \""+_viewDataConfiguration.updateExpression+"\" for property \"".concat(name,"\" in view"),"document \"".concat(_id2,"\":"),result.error);else if(result.result!==undefined){hasChanges=true;viewDocument[name]=result.result}}}if(!hasChanges){_context9.n=4;break}_context9.n=4;return couchdb.connection.put(viewDocument);case 4:_context9.n=6;break;case 5:_context9.p=5;_t42=_context9.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.warn("Updating view failed:",_t42);case 6:_context9.p=6;void updateMaterializedViewsLock.release(_id2);return _context9.f(6);case 7:_i14++;_context9.n=1;break;case 8:couchdb.lastUpdateMaterializedViewsChangesSequenceIdentifier=change.seq;case 9:return _context9.a(2)}},_callee8,null,[[2,5,6,7]])}))));void couchdb.changesStream.on("change",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(change){var _t43;return _regenerator().w(function(_context0){while(1)switch(_context0.p=_context0.n){case 0:numberOfErrorsThrough=0;_context0.n=1;return changesRunnerSemaphore.acquire();case 1:_context0.p=1;_context0.n=2;return pluginAPI.callStack(_objectSpread(_objectSpread({},state),{},{data:change,hook:"couchdbChange"}));case 2:couchdb.lastChangesSequenceIdentifier=change.seq;_context0.n=4;break;case 3:_context0.p=3;_t43=_context0.v;_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.error("An error occurred during on change database hook:",_t43);case 4:_context0.p=4;changesRunnerSemaphore.release();return _context0.f(4);case 5:return _context0.a(2)}},_callee9,null,[[1,3,4,5]])})));_helper_js__WEBPACK_IMPORTED_MODULE_9__/* .log */ .Rm.info("Changes stream initialized.");case 2:return _context1.a(2)}},_callee0)}));function initialize(){return _initialize2.apply(this,arguments)}return initialize}();if(!configuration.attachAutoRestarter){_context10.n=1;break}void _initialize();// Make sure that all listener have been assigned.
572
+ _context10.n=1;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.timeout)();case 1:return _context10.a(2)}},_callee1)}));function postLoadService(_x3){return _postLoadService.apply(this,arguments)}return postLoadService}();/**
573
+ * Triggered when application will be closed soon.
574
+ * @param state - Application state.
575
+ * @param state.configuration - Applications configuration.
576
+ * @param state.services - Applications services.
577
+ * @returns Promise resolving to nothing.
578
+ */var shouldExit=/*#__PURE__*/function(){var _shouldExit=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(_ref14){var configuration,services,logFilePath;return _regenerator().w(function(_context11){while(1)switch(_context11.n){case 0:configuration=_ref14.configuration,services=_ref14.services;_context11.n=1;return (0,_server_js__WEBPACK_IMPORTED_MODULE_10__/* .stop */ .ds)(services,configuration);case 1:delete services.couchdb;logFilePath="log.txt";_context11.n=2;return (0,clientnode__WEBPACK_IMPORTED_MODULE_0__.isFile)(logFilePath);case 2:if(!_context11.v){_context11.n=3;break}_context11.n=3;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_1__.unlink)(logFilePath);case 3:return _context11.a(2)}},_callee10)}));function shouldExit(_x9){return _shouldExit.apply(this,arguments)}return shouldExit}();var database={preLoadService:preLoadService,loadService:loadService,postLoadService:postLoadService,shouldExit:shouldExit};/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (database);
579
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, [
580
+ /* harmony export */ "Ay", 0, /* export default binding */ __WEBPACK_DEFAULT_EXPORT__
581
+ /* harmony export */ ]);
582
+
583
+
584
+ /***/ }),
585
+ /* 8 */
586
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
587
+
588
+ const x = (y) => {
589
+ const x = {}; __webpack_require__.d(x, y); return x
590
+ }
591
+ const y = (x) => (() => (x))
592
+ module.exports = x({ ["fileURLToPath"]: () => (__WEBPACK_EXTERNAL_MODULE_url__.fileURLToPath) });
593
+
594
+ /***/ }),
595
+ /* 9 */
596
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
597
+
598
+ const x = (y) => {
599
+ const x = {}; __webpack_require__.d(x, y); return x
600
+ }
601
+ const y = (x) => (() => (x))
602
+ module.exports = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_pouchdb_adapter_memory_01c036b4__["default"]) });
603
+
604
+ /***/ }),
605
+ /* 10 */
606
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
607
+
608
+ const x = (y) => {
609
+ const x = {}; __webpack_require__.d(x, y); return x
610
+ }
611
+ const y = (x) => (() => (x))
612
+ module.exports = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_pouchdb_find_9445dd40__["default"]) });
613
+
614
+ /***/ }),
615
+ /* 11 */
616
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
617
+
618
+ const x = (y) => {
619
+ const x = {}; __webpack_require__.d(x, y); return x
620
+ }
621
+ const y = (x) => (() => (x))
622
+ module.exports = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_pouchdb_node_83c7160d__["default"]) });
623
+
624
+ /***/ }),
625
+ /* 12 */
626
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
627
+
628
+ const x = (y) => {
629
+ const x = {}; __webpack_require__.d(x, y); return x
630
+ }
631
+ const y = (x) => (() => (x))
632
+ module.exports = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_pouchdb_validation_de480713__["default"]) });
633
+
634
+ /***/ }),
635
+ /* 13 */
636
+ /***/ ((module) => {
637
+
638
+ function webpackEmptyAsyncContext(req) {
639
+ // Here Promise.resolve().then() is used instead of new Promise() to prevent
640
+ // uncaught exception popping up in devtools
641
+ return Promise.resolve().then(() => {
642
+ const e = new Error("Cannot find module '" + req + "'");
643
+ e.code = 'MODULE_NOT_FOUND';
644
+ throw e;
645
+ });
646
+ }
647
+ webpackEmptyAsyncContext.keys = () => ([]);
648
+ webpackEmptyAsyncContext.resolve = webpackEmptyAsyncContext;
649
+ webpackEmptyAsyncContext.id = 13;
650
+ module.exports = webpackEmptyAsyncContext;
651
+
652
+ /***/ }),
653
+ /* 14 */
654
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
655
+
656
+ const x = (y) => {
657
+ const x = {}; __webpack_require__.d(x, y); return x
658
+ }
659
+ const y = (x) => (() => (x))
660
+ module.exports = x({ ["spawn"]: () => (__WEBPACK_EXTERNAL_MODULE_child_process__.spawn) });
661
+
662
+ /***/ }),
663
+ /* 15 */
664
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
665
+
666
+ const x = (y) => {
667
+ const x = {}; __webpack_require__.d(x, y); return x
668
+ }
669
+ const y = (x) => (() => (x))
670
+ module.exports = x({ ["jsonParser"]: () => (__WEBPACK_EXTERNAL_MODULE_express_pouchdb_lib_utils_d9028396__.jsonParser), ["sendError"]: () => (__WEBPACK_EXTERNAL_MODULE_express_pouchdb_lib_utils_d9028396__.sendError), ["sendJSON"]: () => (__WEBPACK_EXTERNAL_MODULE_express_pouchdb_lib_utils_d9028396__.sendJSON) });
671
+
672
+ /***/ }),
673
+ /* 16 */
674
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
675
+
676
+ const x = (y) => {
677
+ const x = {}; __webpack_require__.d(x, y); return x
678
+ }
679
+ const y = (x) => (() => (x))
680
+ module.exports = x({ ["mkdirp"]: () => (__WEBPACK_EXTERNAL_MODULE_mkdirp__.mkdirp), ["mkdirpSync"]: () => (__WEBPACK_EXTERNAL_MODULE_mkdirp__.mkdirpSync) });
681
+
682
+ /***/ }),
683
+ /* 17 */
684
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
685
+
686
+ const x = (y) => {
687
+ const x = {}; __webpack_require__.d(x, y); return x
688
+ }
689
+ const y = (x) => (() => (x))
690
+ module.exports = x({ ["default"]: () => (__WEBPACK_EXTERNAL_MODULE_pouchdb_node_node_modules_node_fetch_lib_index_js_c3ba0d2e__["default"]) });
691
+
692
+ /***/ }),
693
+ /* 18 */,
694
+ /* 19 */,
695
+ /* 20 */
696
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
697
+
698
+ /* harmony export */ __webpack_require__.d(__webpack_exports__, {
699
+ /* harmony export */ S8: () => (/* binding */ restart),
700
+ /* harmony export */ ds: () => (/* binding */ stop),
701
+ /* harmony export */ ni: () => (/* binding */ start)
702
+ /* harmony export */ });
703
+ /* unused harmony exports log, initializeExpress */
704
+ /* harmony import */ var child_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(14);
705
+ /* harmony import */ var clientnode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(0);
706
+ /* harmony import */ var express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(15);
707
+ /* harmony import */ var mkdirp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(16);
708
+ /* harmony import */ var node_fetch__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(17);
709
+ /* harmony import */ var fs_promises__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3);
710
+ /* harmony import */ var path__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4);
711
+ /* harmony import */ var _databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(6);
712
+ /* harmony import */ var _helper_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(1);
713
+ // -*- coding: utf-8 -*-
714
+ /** @module helper *//* !
715
+ region header
716
+ Copyright Torben Sickert (info["~at~"]torben.website) 16.12.2012
717
+
718
+ License
719
+ -------
720
+
721
+ This library written by Torben Sickert stands under a creative commons
722
+ naming 3.0 unported license.
723
+ See https://creativecommons.org/licenses/by/3.0/deed.de
724
+ endregion
725
+ */// region imports
726
+ function _typeof(o){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol&&o!==Symbol.prototype?"symbol":typeof o},_typeof(o)}var _this=undefined;function _regenerator(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof Generator?n:Generator,u=Object.create(c.prototype);return _regeneratorDefine2(u,"_invoke",function(r,n,o){var i,c,u,f=0,p=o||[],y=!1,G={p:0,n:0,v:e,a:d,f:d.bind(e,4),d:function d(t,r){return i=t,c=0,u=e,G.n=r,a}};function d(r,n){for(c=r,u=n,t=0;!y&&f&&!o&&t<p.length;t++){var o,i=p[t],d=G.p,l=i[2];r>3?(o=l===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,G.v=n,G.n=i[1]):d<l&&(o=r<3||i[0]>n||n>l)&&(i[4]=r,i[5]=n,G.n=l,c=0))}if(o||r>1)return a;throw y=!0,n}return function(o,p,l){if(f>1)throw TypeError("Generator is already running");for(y&&1===p&&d(p,l),c=p,u=l;(t=c<2?e:u)||!y;){i||(c?c<3?(c>1&&(G.n=-1),d(c,u)):G.n=u:G.v=u);try{if(f=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(y=G.n<0)?u:r.call(n,G))!==a)break}catch(t){i=e,c=1,u=t}finally{f=1}}return{value:t,done:y}}}(r,o,i),!0),u}var a={};function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}t=Object.getPrototypeOf;var c=[][n]?t(t([][n]())):(_regeneratorDefine2(t={},n,function(){return this}),t),u=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(c);function f(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,GeneratorFunctionPrototype):(e.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(e,o,"GeneratorFunction")),e.prototype=Object.create(u),e}return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(u,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,o,"GeneratorFunction"),_regeneratorDefine2(u),_regeneratorDefine2(u,o,"Generator"),_regeneratorDefine2(u,n,function(){return this}),_regeneratorDefine2(u,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(e,r,n,t){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}_regeneratorDefine2=function _regeneratorDefine(e,r,n,t){function o(r,n){_regeneratorDefine2(e,r,function(e){return this._invoke(r,n,e)})}r?i?i(e,r,{value:n,enumerable:!t,configurable:!t,writable:!t}):e[r]=n:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(e,r,n,t)}function _createForOfIteratorHelper(r,e){var t="undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=_unsupportedIterableToArray(r))||e&&r&&"number"==typeof r.length){t&&(r=t);var _n=0,F=function F(){};return{s:F,n:function n(){return _n>=r.length?{done:!0}:{done:!1,value:r[_n++]}},e:function e(r){throw r},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,u=!1;return{s:function s(){t=t.call(r)},n:function n(){var r=t.next();return a=r.done,r},e:function e(r){u=!0,o=r},f:function f(){try{a||null==t.return||t.return()}finally{if(u)throw o}}}}function _slicedToArray(r,e){return _arrayWithHoles(r)||_iterableToArrayLimit(r,e)||_unsupportedIterableToArray(r,e)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(r,a){if(r){if("string"==typeof r)return _arrayLikeToArray(r,a);var t={}.toString.call(r).slice(8,-1);return"Object"===t&&r.constructor&&(t=r.constructor.name),"Map"===t||"Set"===t?Array.from(r):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?_arrayLikeToArray(r,a):void 0}}function _arrayLikeToArray(r,a){(null==a||a>r.length)&&(a=r.length);for(var e=0,n=Array(a);e<a;e++)n[e]=r[e];return n}function _iterableToArrayLimit(r,l){var t=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null!=t){var e,n,i,u,a=[],f=!0,o=!1;try{if(i=(t=t.call(r)).next,0===l){if(Object(t)!==t)return;f=!1}else for(;!(f=(e=i.call(t)).done)&&(a.push(e.value),a.length!==l);f=!0);}catch(r){o=!0,n=r}finally{try{if(!f&&null!=t.return&&(u=t.return(),Object(u)!==u))return}finally{if(o)throw n}}return a}}function _arrayWithHoles(r){if(Array.isArray(r))return r}function ownKeys(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);r&&(o=o.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),t.push.apply(t,o)}return t}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(t),!0).forEach(function(r){_defineProperty(e,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):ownKeys(Object(t)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))})}return e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _toPropertyKey(t){var i=_toPrimitive(t,"string");return"symbol"==_typeof(i)?i:i+""}function _toPrimitive(t,r){if("object"!=_typeof(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r||"default");if("object"!=_typeof(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}function asyncGeneratorStep(n,t,e,r,o,a,c){try{var i=n[a](c),u=i.value}catch(n){return void e(n)}i.done?t(u):Promise.resolve(u).then(r,o)}function _asyncToGenerator(n){return function(){var t=this,e=arguments;return new Promise(function(r,o){var a=n.apply(t,e);function _next(n){asyncGeneratorStep(a,r,o,_next,_throw,"next",n)}function _throw(n){asyncGeneratorStep(a,r,o,_next,_throw,"throw",n)}_next(void 0)})}};// endregion
727
+ clientnode__WEBPACK_IMPORTED_MODULE_1__.globalContext.fetch=node_fetch__WEBPACK_IMPORTED_MODULE_4__["default"];var log=new clientnode__WEBPACK_IMPORTED_MODULE_1__.Logger({name:"web-node.couchdb.server"});// region functions
728
+ /**
729
+ * Initializes an express instance connected with pouchdb.
730
+ * @param name - Instance name.
731
+ * @param state - Application state.
732
+ * @param connector - Database connector instance.
733
+ * @param configuration - Couchdb configuration object.
734
+ * @param runnerConfiguration - Couchdb runner configuration object.
735
+ * @param pluginAPI - Plugin API to call plugin hooks.
736
+ * @param expressUtilities - Optional express related utilities.
737
+ * @returns A promise resolving to the wrapping express instance and pouchdb's
738
+ * express instance.
739
+ */var initializeExpress=/*#__PURE__*/function(){var _initializeExpress=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(name,state,connector,configuration,runnerConfiguration,pluginAPI,expressUtilities){var _ref2;var specialNames,testConnector,isInMemory,_ref,express,expressPouchDB,allDocs,changes,compact,revsDiff,security,viewCleanup,tempViews,find,views,ddocInfo,show,list,update,attachments,documents,validation,notFoundError,expressInstance,routesToPostpone,expressPouchDBInstance,authorizedChanges,_iterator3,_step3,_step3$value,_name,module,_iterator5,_step5,_step5$value,_name2,_module,_iterator6,_step6,_step6$value,_name3,_module2,_iterator7,_step7,_step7$value,_name4,_module3,_t1,_t10;return _regenerator().w(function(_context5){while(1)switch(_context5.n){case 0:log.info("Couchdb runner is in-place with: \"".concat(name,"\"."));specialNames=configuration.model.property.name.special;// eslint-disable-next-line camelcase
740
+ testConnector=new connector("",{skip_setup:true});isInMemory=testConnector.adapter==="memory";_context5.n=1;return testConnector.close();case 1:if(!(expressUtilities!==null&&expressUtilities!==void 0)){_context5.n=2;break}_t1=expressUtilities;_context5.n=4;break;case 2:_t10=function _t10(module){return module.default||module};_context5.n=3;return eval("import('./loadExpress.js')");case 3:_t1=_t10(_context5.v.default);case 4:_ref=_t1;express=_ref.express;expressPouchDB=_ref.expressPouchDB;allDocs=_ref.allDocs;changes=_ref.changes;compact=_ref.compact;revsDiff=_ref.revsDiff;security=_ref.security;viewCleanup=_ref.viewCleanup;tempViews=_ref.tempViews;find=_ref.find;views=_ref.views;ddocInfo=_ref.ddocInfo;show=_ref.show;list=_ref.list;update=_ref.update;attachments=_ref.attachments;documents=_ref.documents;validation=_ref.validation;notFoundError=_ref.notFoundError;expressInstance=express();/*
741
+ These routes take many remaining paths (fallback). We will add
742
+ these manually after custom routes have been added.
743
+ *//*
744
+ We have to overwrite to apply read right authorization on
745
+ property level:
746
+
747
+ 'routes/all-docs',
748
+ 'routes/changes',
749
+ 'routes/find',
750
+ 'routes/attachments',
751
+ 'routes/documents',
752
+ */routesToPostpone=[[["routes/all-docs",allDocs],["routes/changes",changes],["routes/compact",compact],["routes/revs-diff",revsDiff],["routes/security",security],["routes/view-cleanup",viewCleanup],["routes/temp-views",tempViews]],[["routes/find",find],["routes/views",views],["routes/ddoc-info",ddocInfo],["routes/show",show],["routes/list",list],["routes/update",update]],[["routes/attachments",attachments]],[["routes/documents",documents],["validation",validation],["routes/404",notFoundError]]];expressPouchDBInstance=// eslint-disable-next-line @typescript-eslint/no-unsafe-call
753
+ expressPouchDB(connector,_objectSpread(_objectSpread({},runnerConfiguration),{},{overrideMode:{exclude:(_ref2=[]).concat.apply(_ref2,routesToPostpone).map(function(_ref3){var _ref4=_slicedToArray(_ref3,1),name=_ref4[0];return name})},inMemoryConfig:isInMemory}));// routes/all-docs
754
+ expressPouchDBInstance.all("/:db/_all_docs",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.jsonParser,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(givenRequest,response,next){var request,options,result,modelRolesMapping,_iterator,_step,row,_t,_t2,_t3;return _regenerator().w(function(_context){while(1)switch(_context.p=_context.n){case 0:request=givenRequest;options=_objectSpread(_objectSpread({},request.body),request.query);if(options.include_docs){_context.n=1;break}next();return _context.a(2);case 1:_context.p=1;_context.n=2;return request.db.allDocs(options);case 2:result=_context.v;// authorize documents
755
+ modelRolesMapping=(0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .determineModelRolesMapping */ .Ic)(configuration.model);_iterator=_createForOfIteratorHelper(result.rows);_context.p=3;_iterator.s();case 4:if((_step=_iterator.n()).done){_context.n=8;break}row=_step.value;_context.p=5;(0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__/* .authorize */ .Gq)(row.doc,null,request.couchSession.userCtx,request.couchSecurityObj,modelRolesMapping,true,specialNames);_context.n=7;break;case 6:_context.p=6;_t=_context.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t,403);return _context.a(2);case 7:_context.n=4;break;case 8:_context.n=10;break;case 9:_context.p=9;_t2=_context.v;_iterator.e(_t2);case 10:_context.p=10;_iterator.f();return _context.f(10);case 11:// endregion
756
+ (0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendJSON)(response,200,result);_context.n=13;break;case 12:_context.p=12;_t3=_context.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t3,400);case 13:return _context.a(2)}},_callee,null,[[5,6],[3,9,10,11],[1,12]])})));// routes/changes
757
+ authorizedChanges=function authorizedChanges(givenRequest,_response,next){var request=givenRequest;var options=_objectSpread(_objectSpread({},request.body),request.query);/*
758
+ NOTE: Needed workaround to allow changes implementation to set query
759
+ params on its own.
760
+ */Object.defineProperty(request,"query",{value:_objectSpread({},request.query),writable:true,configurable:true,enumerable:true});if(!options.include_docs){next();return}var modelRolesMapping=(0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .determineModelRolesMapping */ .Ic)(configuration.model);var authorizeChange=function authorizeChange(document){return (0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__/* .authorize */ .Gq)(document,null,request.couchSession.userCtx,request.couchSecurityObj,modelRolesMapping,true,specialNames)};var nativeChanges=request.db.changes.bind(request.db);request.db.changes=function(){var result=nativeChanges.apply(void 0,arguments);if(result)if(result.on)result.on("change",function(change){if(change.doc)try{authorizeChange(change.doc)}catch(error){try{delete change.doc;change.error=error}catch(error){console.error(error)}}});else if(result.then)void result.then(function(results){var _iterator2=_createForOfIteratorHelper(results.results),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var change=_step2.value;if(change.doc)try{authorizeChange(change.doc)}catch(error){try{delete change.doc;change.error=error}catch(error){log.error(error)}}}}catch(err){_iterator2.e(err)}finally{_iterator2.f()}});return result};next();request.db.changes=nativeChanges};expressPouchDBInstance.get("/:db/_changes",authorizedChanges);expressPouchDBInstance.post("/:db/_changes",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.jsonParser,authorizedChanges);_iterator3=_createForOfIteratorHelper(routesToPostpone[0]);try{for(_iterator3.s();!(_step3=_iterator3.n()).done;)// eslint-disable-next-line @typescript-eslint/no-unsafe-call
761
+ {_step3$value=_slicedToArray(_step3.value,2),_name=_step3$value[0],module=_step3$value[1];module(expressPouchDBInstance)}// routes/find
762
+ }catch(err){_iterator3.e(err)}finally{_iterator3.f()}expressPouchDBInstance.post("/:db/_find",express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.jsonParser,/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(givenRequest,response){var request,addedType,_result,hookData,result,modelRolesMapping,_iterator4,_step4,document,_t4,_t5,_t6;return _regenerator().w(function(_context2){while(1)switch(_context2.p=_context2.n){case 0:request=givenRequest;/*
763
+ NOTE: We always have to determine type to be able to evaluate
764
+ type based authorization rules.
765
+ */addedType=false;if(Array.isArray(request.body.fields)&&!request.body.fields.includes(specialNames.type)){request.body.fields.push(specialNames.type);addedType=true}_context2.p=1;hookData={request:request,response:response};_context2.n=2;return pluginAPI.callStack(_objectSpread(_objectSpread({},state),{},{hook:"onPouchDBFind",data:hookData}));case 2:result=_context2.v;if((_result=result)!==null&&_result!==void 0&&_result.docs){_context2.n=4;break}_context2.n=3;return request.db.find(request.body);case 3:result=_context2.v;case 4:// authorize documents
766
+ modelRolesMapping=(0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .determineModelRolesMapping */ .Ic)(configuration.model);_iterator4=_createForOfIteratorHelper(result.docs);_context2.p=5;_iterator4.s();case 6:if((_step4=_iterator4.n()).done){_context2.n=10;break}document=_step4.value;_context2.p=7;(0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__/* .authorize */ .Gq)(document,null,request.couchSession.userCtx,request.couchSecurityObj,modelRolesMapping,true,specialNames);if(addedType)delete document[specialNames.type];_context2.n=9;break;case 8:_context2.p=8;_t4=_context2.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t4,403);return _context2.a(2);case 9:_context2.n=6;break;case 10:_context2.n=12;break;case 11:_context2.p=11;_t5=_context2.v;_iterator4.e(_t5);case 12:_context2.p=12;_iterator4.f();return _context2.f(12);case 13:// endregion
767
+ (0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendJSON)(response,200,result);_context2.n=15;break;case 14:_context2.p=14;_t6=_context2.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t6,400);case 15:return _context2.a(2)}},_callee2,null,[[7,8],[5,11,12,13],[1,14]])})));_iterator5=_createForOfIteratorHelper(routesToPostpone[1]);try{for(_iterator5.s();!(_step5=_iterator5.n()).done;)// eslint-disable-next-line @typescript-eslint/no-unsafe-call
768
+ {_step5$value=_slicedToArray(_step5.value,2),_name2=_step5$value[0],_module=_step5$value[1];_module(expressPouchDBInstance)}// routes/attachments
769
+ }catch(err){_iterator5.e(err)}finally{_iterator5.f()}expressPouchDBInstance.get("/:db/:id/:attachment(*)",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(givenRequest,response,next){var request,modelRolesMapping,_yield$request$db$fin,_yield$request$db$fin2,document,_t7,_t8;return _regenerator().w(function(_context3){while(1)switch(_context3.p=_context3.n){case 0:request=givenRequest;_context3.p=1;modelRolesMapping=(0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .determineModelRolesMapping */ .Ic)(configuration.model);_context3.n=2;return request.db.find({fields:[specialNames.type],selector:_defineProperty({},specialNames.id,request.query.id)});case 2:_yield$request$db$fin=_context3.v;_yield$request$db$fin2=_slicedToArray(_yield$request$db$fin.docs,1);document=_yield$request$db$fin2[0];_context3.p=3;(0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__/* .authorize */ .Gq)(_defineProperty(_defineProperty({},specialNames.type,document[specialNames.type]),specialNames.attachment,_defineProperty({},request.params.attachment,{})),null,request.couchSession.userCtx,request.couchSecurityObj,modelRolesMapping,true,specialNames);_context3.n=5;break;case 4:_context3.p=4;_t7=_context3.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t7,403);return _context3.a(2);case 5:_context3.n=7;break;case 6:_context3.p=6;_t8=_context3.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t8,400);return _context3.a(2);case 7:next();case 8:return _context3.a(2)}},_callee3,null,[[3,4],[1,6]])})));// We already cover put and delete attachment via "bulkDocs" operation.
770
+ _iterator6=_createForOfIteratorHelper(routesToPostpone[2]);try{for(_iterator6.s();!(_step6=_iterator6.n()).done;)// eslint-disable-next-line @typescript-eslint/no-unsafe-call
771
+ {_step6$value=_slicedToArray(_step6.value,2),_name3=_step6$value[0],_module2=_step6$value[1];_module2(expressPouchDBInstance)}// routes/documents
772
+ }catch(err){_iterator6.e(err)}finally{_iterator6.f()}expressPouchDBInstance.get("/:db/:id(*)",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(givenRequest,response){var request,modelRolesMapping,document,_t9,_t0;return _regenerator().w(function(_context4){while(1)switch(_context4.p=_context4.n){case 0:request=givenRequest;_context4.p=1;modelRolesMapping=(0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .determineModelRolesMapping */ .Ic)(configuration.model);_context4.n=2;return request.db.get(request.params.id,request.query);case 2:document=_context4.v;_context4.p=3;(0,_databaseHelper_js__WEBPACK_IMPORTED_MODULE_7__/* .authorize */ .Gq)(document,null,request.couchSession.userCtx,request.couchSecurityObj,modelRolesMapping,true,specialNames);_context4.n=5;break;case 4:_context4.p=4;_t9=_context4.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t9,403);return _context4.a(2);case 5:(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendJSON)(response,200,document);_context4.n=7;break;case 6:_context4.p=6;_t0=_context4.v;(0,express_pouchdb_lib_utils__WEBPACK_IMPORTED_MODULE_2__.sendError)(response,_t0,400);case 7:return _context4.a(2)}},_callee4,null,[[3,4],[1,6]])})));// We already cover delete and copy via "get" and "bulkDocs" operation.
773
+ _iterator7=_createForOfIteratorHelper(routesToPostpone[3]);try{for(_iterator7.s();!(_step7=_iterator7.n()).done;)// eslint-disable-next-line @typescript-eslint/no-unsafe-call
774
+ {_step7$value=_slicedToArray(_step7.value,2),_name4=_step7$value[0],_module3=_step7$value[1];_module3(expressPouchDBInstance)}}catch(err){_iterator7.e(err)}finally{_iterator7.f()}if(isInMemory){_context5.n=5;break}/*
775
+ NOTE: Currently needed to use synchronized folder creation to avoid
776
+ having the folder not yet persisted in following execution when
777
+ working on not mounted locations. Seems to be an issue within a
778
+ container environment.
779
+ */;(0,mkdirp__WEBPACK_IMPORTED_MODULE_3__.mkdirpSync)((0,path__WEBPACK_IMPORTED_MODULE_6__.resolve)(configuration.path));_context5.n=5;return (0,mkdirp__WEBPACK_IMPORTED_MODULE_3__.mkdirp)((0,path__WEBPACK_IMPORTED_MODULE_6__.resolve)(configuration.path));case 5:_context5.n=6;return pluginAPI.callStack(_objectSpread(_objectSpread({},state),{},{hook:"initializeExpressPouchDB",data:{expressInstance:expressInstance,expressPouchDBInstance:expressPouchDBInstance}}));case 6:expressInstance.use("/",expressPouchDBInstance);return _context5.a(2,{expressInstance:expressInstance,expressPouchDBInstance:expressPouchDBInstance})}},_callee5)}));function initializeExpress(_x,_x2,_x3,_x4,_x5,_x6,_x7){return _initializeExpress.apply(this,arguments)}return initializeExpress}();/**
780
+ * Starts server process.
781
+ * @param state - Application state.
782
+ * @param expressUtilities - Optional express related utilities.
783
+ * @returns A promise representing the server process wrapped in a promise
784
+ * which resolves after server is reachable.
785
+ */var start=/*#__PURE__*/function(){var _start=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(state,expressUtilities){var configuration,pluginAPI,_state$services$couch,backendConnector,server,runnerConfiguration,runner,name,_yield$initializeExpr,expressInstance,expressPouchDBInstance,binaryRunner,_t11;return _regenerator().w(function(_context6){while(1)switch(_context6.p=_context6.n){case 0:configuration=state.configuration,pluginAPI=state.pluginAPI,_state$services$couch=state.services.couchdb,backendConnector=_state$services$couch.backendConnector,server=_state$services$couch.server;runnerConfiguration=configuration.couchdb.runner;runner=server.runner;// region create configuration file if needed
786
+ if(!runner.configurationFile){_context6.n=5;break}_context6.p=1;_context6.n=2;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_5__.mkdir)((0,path__WEBPACK_IMPORTED_MODULE_6__.dirname)(runner.configurationFile.path),{recursive:true});case 2:_context6.n=4;break;case 3:_context6.p=3;_t11=_context6.v;if(!(_t11.code!=="EEXIST")){_context6.n=4;break}throw _t11;case 4:_context6.n=5;return (0,fs_promises__WEBPACK_IMPORTED_MODULE_5__.writeFile)(runner.configurationFile.path,runner.configurationFile.content,{encoding:configuration.core.encoding});case 5:// endregion
787
+ name=[].concat(runner.names)[0];if(!runner.packages){_context6.n=9;break}if(server.expressInstance){_context6.n=7;break}_context6.n=6;return initializeExpress(name,state,backendConnector,configuration.couchdb,runner.configuration,pluginAPI,expressUtilities);case 6:_yield$initializeExpr=_context6.v;expressInstance=_yield$initializeExpr.expressInstance;expressPouchDBInstance=_yield$initializeExpr.expressPouchDBInstance;server.expressInstance=expressInstance;server.expressPouchDBInstance=expressPouchDBInstance;case 7:_context6.n=8;return new Promise(function(resolve){var _server$expressInstan,_server$process,_server$process2;server.process=(_server$expressInstan=server.expressInstance)===null||_server$expressInstan===void 0?void 0:_server$expressInstan.listen(configuration.couchdb.runner.port,resolve);(_server$process=server.process)===null||_server$process===void 0||_server$process.on("close",function(){server.resolve.call(_this)});(_server$process2=server.process)===null||_server$process2===void 0||_server$process2.on("error",function(error){server.reject.call(_this,error)})});case 8:_context6.n=10;break;case 9:log.info("Couchdb runner is: \"".concat(name,"\"."));binaryRunner=runner;server.process=(0,child_process__WEBPACK_IMPORTED_MODULE_0__.spawn)(runnerConfiguration.memoryInMegaByte==="default"?binaryRunner.binaryFilePath:runnerConfiguration.nodePath,(runnerConfiguration.memoryInMegaByte==="default"?[]:["--max-old-space-size="+runnerConfiguration.memoryInMegaByte,binaryRunner.binaryFilePath]).concat(binaryRunner.arguments?binaryRunner.arguments:[]),{cwd:eval("process").cwd(),env:Object.prototype.hasOwnProperty.call(runner,"environment")?_objectSpread(_objectSpread({},eval("process").env),binaryRunner.environment):eval("process").env,shell:true,stdio:"inherit"})// Forward process events to service promise.
788
+ ;new Promise(function(resolve,reject){var _iterator8=_createForOfIteratorHelper(clientnode__WEBPACK_IMPORTED_MODULE_1__.CLOSE_EVENT_NAMES),_step8;try{for(_iterator8.s();!(_step8=_iterator8.n()).done;){var _server$process3;var closeEventName=_step8.value;(_server$process3=server.process)===null||_server$process3===void 0||_server$process3.on(closeEventName,(0,clientnode__WEBPACK_IMPORTED_MODULE_1__.getProcessCloseHandler)(resolve,reject,{process:server.process,reason:closeEventName}))}}catch(err){_iterator8.e(err)}finally{_iterator8.f()}}).then(/*
789
+ NOTE: Please be aware of newly set server instances when
790
+ resolving happens here.
791
+ */function(value){server.resolve.call(_this,value)},function(reason){server.reject.call(_this,reason)});case 10:_context6.n=11;return (0,clientnode__WEBPACK_IMPORTED_MODULE_1__.checkReachability)((0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .getEffectiveURL */ .Nk)(configuration.couchdb,false,false),{wait:true});case 11:return _context6.a(2)}},_callee6,null,[[1,3]])}));function start(_x16,_x17){return _start.apply(this,arguments)}return start}();/**
792
+ * Stops open database connection if exists, stops server process, restarts
793
+ * server process and re-initializes server connection.
794
+ * @param state - Application state.
795
+ * @param destroy - Defined whether the database should be destroyed or just
796
+ * closed.
797
+ * @param expressUtilities - Optional express related utilities.
798
+ * @returns Given object of services wrapped in a promise resolving after
799
+ * finish.
800
+ */var restart=/*#__PURE__*/function(){var _restart=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(state,destroy,expressUtilities){var configuration,pluginAPI,services,server,resolveServerProcessBackup,rejectServerProcessBackup,temporaryServerPromise;return _regenerator().w(function(_context7){while(1)switch(_context7.n){case 0:if(destroy===void 0){destroy=false}configuration=state.configuration,pluginAPI=state.pluginAPI,services=state.services;server=services.couchdb.server;resolveServerProcessBackup=server.resolve;rejectServerProcessBackup=server.reject;// Avoid to notify web node about server process stop.
801
+ temporaryServerPromise=new Promise(function(resolve,reject){server.resolve=resolve;server.reject=reject});_context7.n=1;return stop(services,configuration,destroy);case 1:_context7.n=2;return temporaryServerPromise;case 2:// Reattach server process to web nodes process pool.
802
+ server.resolve=resolveServerProcessBackup;server.reject=rejectServerProcessBackup;_context7.n=3;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .initializeConnection */ .Tg)(services,configuration,false);case 3:_context7.n=4;return start(state,expressUtilities);case 4:_context7.n=5;return pluginAPI.callStack(_objectSpread(_objectSpread({},state),{},{hook:"restartCouchdb"}));case 5:return _context7.a(2)}},_callee7)}));function restart(_x18,_x19,_x20){return _restart.apply(this,arguments)}return restart}();/**
803
+ * Stops open database connection if exists and stops server process.
804
+ * @param services - An object with stored service instances.
805
+ * @param services.couchdb - Couchdb service instance.
806
+ * @param configuration - Mutable by plugins extended configuration object.
807
+ * @param configuration.couchdb - Mutable by plugins extended configuration
808
+ * object.
809
+ * @param destroy - Defined whether the database should be destroyed or just
810
+ * closed.
811
+ * @returns Given object of services wrapped in a promise resolving after
812
+ * finish.
813
+ */var stop=/*#__PURE__*/function(){var _stop=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(_ref9,_ref0,destroy){var couchdb,configuration,promise;return _regenerator().w(function(_context8){while(1)switch(_context8.n){case 0:couchdb=_ref9.couchdb;configuration=_ref0.couchdb;if(destroy===void 0){destroy=false}if(!destroy){_context8.n=2;break}_context8.n=1;return couchdb.connection.destroy();case 1:_context8.n=3;break;case 2:promise=couchdb.connection.close();if(!(promise!==null&&promise!==void 0&&promise.catch)){_context8.n=3;break}/*
814
+ NOTE: Waiting for close promise to resolved often takes endless
815
+ time.
816
+ */promise.catch(function(error){log.error("Couchdb connection could not be gracefully closed:",error)});_context8.n=3;return (0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .waitWithTimeout */ .e$)(promise,configuration.closeTimeoutInSeconds,"couchdb connection to close");case 3:if(couchdb.server.process)if(couchdb.server.runner.packages)couchdb.server.process.close();else couchdb.server.process.kill("SIGINT");_context8.n=4;return (0,clientnode__WEBPACK_IMPORTED_MODULE_1__.checkUnreachability)((0,_helper_js__WEBPACK_IMPORTED_MODULE_8__/* .getEffectiveURL */ .Nk)(configuration),{wait:true});case 4:return _context8.a(2)}},_callee8)}));function stop(_x21,_x22,_x23){return _stop.apply(this,arguments)}return stop}();
817
+
818
+ /***/ })
819
+ /******/ ]);
820
+ /************************************************************************/
821
+ /******/ // The module cache
822
+ /******/ const __webpack_module_cache__ = {};
823
+ /******/
824
+ /******/ // The require function
825
+ /******/ function __webpack_require__(moduleId) {
826
+ /******/ // Check if module is in cache
827
+ /******/ const cachedModule = __webpack_module_cache__[moduleId];
828
+ /******/ if (cachedModule !== undefined) {
829
+ /******/ return cachedModule.exports;
830
+ /******/ }
831
+ /******/ // Create a new module (and put it into the cache)
832
+ /******/ const module = __webpack_module_cache__[moduleId] = {
833
+ /******/ // no module.id needed
834
+ /******/ // no module.loaded needed
835
+ /******/ exports: {}
836
+ /******/ };
837
+ /******/
838
+ /******/ // Execute the module function
839
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
840
+ /******/
841
+ /******/ // Return the exports of the module
842
+ /******/ return module.exports;
843
+ /******/ }
844
+ /******/
845
+ /******/ // expose the module cache
846
+ /******/ __webpack_require__.c = __webpack_module_cache__;
847
+ /******/
848
+ /************************************************************************/
849
+ /******/ /* webpack/runtime/define property getters */
850
+ /******/ (() => {
851
+ /******/ // define getter/value functions for harmony exports
852
+ /******/ __webpack_require__.d = (exports, definition) => {
853
+ /******/ if(Array.isArray(definition)) {
854
+ /******/ var i = 0;
855
+ /******/ while(i < definition.length) {
856
+ /******/ var key = definition[i++];
857
+ /******/ var binding = definition[i++];
858
+ /******/ if(!__webpack_require__.o(exports, key)) {
859
+ /******/ if(binding === 0) {
860
+ /******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
861
+ /******/ } else {
862
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
863
+ /******/ }
864
+ /******/ } else if(binding === 0) { i++; }
865
+ /******/ }
866
+ /******/ } else {
867
+ /******/ for(var key in definition) {
868
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
869
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
870
+ /******/ }
871
+ /******/ }
872
+ /******/ }
873
+ /******/ };
874
+ /******/ })();
875
+ /******/
876
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
877
+ /******/ (() => {
878
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
879
+ /******/ })();
880
+ /******/
881
+ /************************************************************************/
882
+ /******/
883
+ /******/ // module cache are used so entry inlining is disabled
884
+ /******/ // startup
885
+ /******/ // Load entry module and return exports
886
+ /******/ let __webpack_exports__ = __webpack_require__(__webpack_require__.s = 7);
887
+ /******/ const __webpack_exports__database = __webpack_exports__.OO;
888
+ /******/ const __webpack_exports__default = __webpack_exports__.Ay;
889
+ /******/ const __webpack_exports__loadService = __webpack_exports__.oV;
890
+ /******/ const __webpack_exports__postLoadService = __webpack_exports__.q5;
891
+ /******/ const __webpack_exports__preLoadService = __webpack_exports__.jv;
892
+ /******/ const __webpack_exports__shouldExit = __webpack_exports__.EK;
893
+ /******/ export { __webpack_exports__database as database, __webpack_exports__default as default, __webpack_exports__loadService as loadService, __webpack_exports__postLoadService as postLoadService, __webpack_exports__preLoadService as preLoadService, __webpack_exports__shouldExit as shouldExit };
894
+ /******/