@nmshd/consumption 2.0.0-alpha.1 → 2.0.0-alpha.4
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/dist/buildInformation.js +4 -4
- package/dist/consumption/ConsumptionBaseController.d.ts +2 -3
- package/dist/consumption/ConsumptionBaseController.js +3 -23
- package/dist/consumption/ConsumptionBaseController.js.map +1 -1
- package/dist/consumption/ConsumptionController.d.ts +5 -2
- package/dist/consumption/ConsumptionController.js +2 -2
- package/dist/consumption/ConsumptionController.js.map +1 -1
- package/dist/modules/attributes/local/ConsumptionAttribute.d.ts +1 -1
- package/dist/modules/attributes/local/ConsumptionAttribute.js +5 -6
- package/dist/modules/attributes/local/ConsumptionAttribute.js.map +1 -1
- package/dist/modules/drafts/DraftsController.d.ts +2 -2
- package/dist/modules/drafts/DraftsController.js +2 -2
- package/dist/modules/drafts/DraftsController.js.map +1 -1
- package/dist/modules/drafts/local/Draft.d.ts +4 -4
- package/dist/modules/drafts/local/Draft.js +5 -6
- package/dist/modules/drafts/local/Draft.js.map +1 -1
- package/dist/modules/index.d.ts +2 -2
- package/dist/modules/index.js +1 -2
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/relationships/RelationshipInfoController.js +1 -1
- package/dist/modules/relationships/RelationshipInfoController.js.map +1 -1
- package/dist/modules/relationships/RelationshipInfoUtil.js +6 -6
- package/dist/modules/relationships/RelationshipInfoUtil.js.map +1 -1
- package/dist/modules/relationships/local/RelationshipAttribute.d.ts +4 -4
- package/dist/modules/relationships/local/RelationshipAttribute.js +4 -5
- package/dist/modules/relationships/local/RelationshipAttribute.js.map +1 -1
- package/dist/modules/relationships/local/RelationshipInfo.d.ts +1 -1
- package/dist/modules/relationships/local/RelationshipInfo.js +4 -4
- package/dist/modules/relationships/local/RelationshipInfo.js.map +1 -1
- package/dist/modules/relationships/local/RelationshipTheme.d.ts +4 -4
- package/dist/modules/relationships/local/RelationshipTheme.js +4 -5
- package/dist/modules/relationships/local/RelationshipTheme.js.map +1 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.d.ts +2 -2
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js.map +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.d.ts +5 -6
- package/dist/modules/requests/incoming/IncomingRequestsController.js +43 -46
- package/dist/modules/requests/incoming/IncomingRequestsController.js.map +1 -1
- package/dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js +4 -5
- package/dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js +3 -3
- package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/AcceptRequestItemParameters.d.ts +3 -6
- package/dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js +0 -19
- package/dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.d.ts +3 -8
- package/dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js +0 -26
- package/dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/DecideRequestItemParameters.d.ts +3 -5
- package/dist/modules/requests/incoming/decide/DecideRequestItemParameters.js +0 -5
- package/dist/modules/requests/incoming/decide/DecideRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/DecideRequestParameters.d.ts +5 -11
- package/dist/modules/requests/incoming/decide/DecideRequestParameters.js +0 -27
- package/dist/modules/requests/incoming/decide/DecideRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/InternalDecideRequestParameters.d.ts +19 -0
- package/dist/modules/requests/incoming/decide/InternalDecideRequestParameters.js +44 -0
- package/dist/modules/requests/incoming/decide/InternalDecideRequestParameters.js.map +1 -0
- package/dist/modules/requests/incoming/decide/RejectRequestItemParameters.d.ts +3 -8
- package/dist/modules/requests/incoming/decide/RejectRequestItemParameters.js +0 -32
- package/dist/modules/requests/incoming/decide/RejectRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/incoming/decide/RequestItemDecision.d.ts +4 -0
- package/dist/modules/requests/incoming/decide/RequestItemDecision.js +9 -0
- package/dist/modules/requests/incoming/decide/RequestItemDecision.js.map +1 -0
- package/dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js +4 -5
- package/dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js +3 -3
- package/dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js.map +1 -1
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.d.ts +5 -5
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js +4 -4
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/IRequestItemProcessor.d.ts +5 -5
- package/dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.d.ts +6 -3
- package/dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js +4 -1
- package/dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js.map +1 -1
- package/dist/modules/requests/local/ConsumptionRequest.d.ts +5 -5
- package/dist/modules/requests/local/ConsumptionRequest.js +7 -8
- package/dist/modules/requests/local/ConsumptionRequest.js.map +1 -1
- package/dist/modules/requests/local/ConsumptionRequestStatusLogEntry.js +3 -4
- package/dist/modules/requests/local/ConsumptionRequestStatusLogEntry.js.map +1 -1
- package/dist/modules/requests/local/ConsumptionResponse.d.ts +7 -7
- package/dist/modules/requests/local/ConsumptionResponse.js +8 -9
- package/dist/modules/requests/local/ConsumptionResponse.js.map +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js +9 -9
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
- package/dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js +4 -5
- package/dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.d.ts +4 -4
- package/dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js +4 -5
- package/dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js +4 -5
- package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.d.ts +4 -4
- package/dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js +4 -5
- package/dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js.map +1 -1
- package/dist/modules/settings/SettingsController.js +2 -2
- package/dist/modules/settings/SettingsController.js.map +1 -1
- package/dist/modules/settings/local/CreateSettingParameter.d.ts +2 -2
- package/dist/modules/settings/local/Setting.d.ts +4 -4
- package/dist/modules/settings/local/Setting.js +5 -6
- package/dist/modules/settings/local/Setting.js.map +1 -1
- package/dist/modules/sharedItems/SharedItemsController.js +1 -1
- package/dist/modules/sharedItems/SharedItemsController.js.map +1 -1
- package/dist/modules/sharedItems/local/SharedItem.d.ts +1 -1
- package/dist/modules/sharedItems/local/SharedItem.js +4 -5
- package/dist/modules/sharedItems/local/SharedItem.js.map +1 -1
- package/dist/modules/signatures/Signature.d.ts +5 -5
- package/dist/modules/signatures/Signature.js +9 -8
- package/dist/modules/signatures/Signature.js.map +1 -1
- package/dist/modules/signatures/SignatureContent.d.ts +0 -1
- package/dist/modules/signatures/SignatureContent.js +3 -7
- package/dist/modules/signatures/SignatureContent.js.map +1 -1
- package/lib-web/nmshd.consumption.js +226 -365
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +9 -9
- package/dist/modules/requests/incoming/decide/AcceptRequestParameters.d.ts +0 -6
- package/dist/modules/requests/incoming/decide/AcceptRequestParameters.js +0 -22
- package/dist/modules/requests/incoming/decide/AcceptRequestParameters.js.map +0 -1
- package/dist/modules/requests/incoming/decide/RejectRequestParameters.d.ts +0 -6
- package/dist/modules/requests/incoming/decide/RejectRequestParameters.js +0 -22
- package/dist/modules/requests/incoming/decide/RejectRequestParameters.js.map +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see nmshd.consumption.min.js.LICENSE.txt */
|
|
2
|
-
var NMSHDConsumption;(()=>{var e={2500:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildInformation=void 0;const n=r(194),i=r(5030),o=r(2890),s=r(9663);t.buildInformation={version:"2.0.0-alpha.1",build:"19",date:"2022-04-22T11:52:27+00:00",commit:"012b8a9a2b885dd7d176deb14a13034e1202c045",dependencies:{},libraries:{transport:s.buildInformation,crypto:o.buildInformation,serval:n.buildInformation,content:i.buildInformation}}},5136:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionBaseController=void 0;const n=r(194),i=r(9663);t.ConsumptionBaseController=class ConsumptionBaseController{constructor(e,t){this._parent=t,this._log=i.TransportLoggerFactory.getLogger(e)}get log(){return this._log}get parent(){return this._parent}init(){return Promise.resolve(this)}async parseObject(e,t){return await n.SerializableAsync.fromT(e,t)}async parseArray(e,t,r){const n=[];for(let o=0,s=e.length;o<s;o++)if(r){const s=e[o];if(!s[r]){const e=i.TransportErrors.controller.contentPropertyUndefined(r);throw this._log.error(e),e}n.push(this.parseObject(s[r],t))}else n.push(this.parseObject(e[o],t));return await Promise.all(n)}}},9793:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionController=void 0;const n=r(9662),i=r(5664);t.ConsumptionController=class ConsumptionController{constructor(e,t){this.transport=e,this.accountController=t}get attributes(){return this._attributes}get drafts(){return this._drafts}get outgoingRequests(){return this._outgoingRequests}get incomingRequests(){return this._incomingRequests}get settings(){return this._settings}get sharedItems(){return this._sharedItems}get relationshipInfo(){return this._relationshipInfo}async init(){this._attributes=await new n.ConsumptionAttributesController(this).init(),this._drafts=await new n.DraftsController(this).init();const e=new n.RequestItemProcessorRegistry;return this._outgoingRequests=await new n.OutgoingRequestsController(this,e).init(),this._incomingRequests=await new i.IncomingRequestsController(this,e).init(),this._settings=await new n.SettingsController(this).init(),this._sharedItems=await new n.SharedItemsController(this).init(),this._relationshipInfo=await new n.RelationshipInfoController(this).init(),this}}},2047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionControllerName=void 0,function(e){e.ConsumptionAttributesController="ConsumptionAttributesController",e.DraftsController="DraftsController",e.RelationshipInfoController="RelationshipInfoController",e.SingleRelationshipController="SingleRelationshipController",e.OnboardingFlowController="OnboardingFlowController",e.OffboardingFlowController="OffboardingFlowController",e.RequestsController="Requestsontroller",e.SettingsController="SettingsController",e.SharedItemsController="SharedItemsController"}(t.ConsumptionControllerName||(t.ConsumptionControllerName={}))},3926:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionErrors=void 0;const n=r(9663);class ConsumptionErrors{}t.ConsumptionErrors=ConsumptionErrors,ConsumptionErrors.attributes=new class Attributes{attributeExists(e){return new n.CoreError("error.consumption.attributes.attributeExists",`Attribute with name ${e} already exists. Please use succeed instead.`)}},ConsumptionErrors.requests=new class Requests{requestsExists(e){return new n.CoreError("error.consumption.requests.requestExists",`Request with id ${e} already exists and can't be created.`)}},ConsumptionErrors.relationshipInfo=new class RelationshipInfo{relationshipInfoExists(e){return new n.CoreError("error.consumption.relationshipInfos.relationshipInfoExists",`RelationshipInfo for Relationship ${e} already exists.`)}},ConsumptionErrors.onboarding=new class Onboarding{attributeNotSet(e){return new n.CoreError("error.consumption.onboarding.attributeNotSet",`No attribute with name ${e} set but was required to be shared.`)}wrongTemplate(){return new n.CoreError("error.consumption.onboarding.wrongTemplate","The given template is in the wrong format.")}}},6265:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionIds=void 0;const n=r(9663);class ConsumptionIds{}t.ConsumptionIds=ConsumptionIds,ConsumptionIds.attribute=new n.CoreIdHelper("CNSATT"),ConsumptionIds.draft=new n.CoreIdHelper("CNSDRF"),ConsumptionIds.relationshipInfo=new n.CoreIdHelper("CNSRIN"),ConsumptionIds.sharedItem=new n.CoreIdHelper("CNSSIT"),ConsumptionIds.response=new n.CoreIdHelper("CNSRES"),ConsumptionIds.request=new n.CoreIdHelper("CNSREQ"),ConsumptionIds.setting=new n.CoreIdHelper("CNSSET")},7997:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(5136),t),i(r(2047),t),i(r(3926),t),i(r(6265),t)},5590:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(2500),t),i(r(9793),t),i(r(6265),t),i(r(9662),t)},8896:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttributesController=void 0;const n=r(9663),i=r(4714),o=r(7997),s=r(5192);class ConsumptionAttributesController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.ConsumptionAttributesController,e)}async init(){return await super.init(),this.attributes=await this.parent.accountController.getSynchronizedCollection("Attributes"),this}checkValid(e){const t=n.CoreDate.utc();return!e.content.validFrom&&!e.content.validTo||(!(!e.content.validFrom||e.content.validTo||!e.content.validFrom.isSameOrBefore(t))||(!(e.content.validFrom||!e.content.validTo||!e.content.validTo.isAfter(t))||!!(e.content.validFrom&&e.content.validTo&&e.content.validFrom.isSameOrBefore(t)&&e.content.validTo.isAfter(t))))}findCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt)));let r;for(const e of t)this.checkValid(e)&&(r=e);return r}filterCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt))),r=[];for(const e of t)this.checkValid(e)&&r.push(e);return r}async getAttribute(e){const t=await this.attributes.find({[(0,i.nameof)((e=>e.id))]:e.toString()}),r=await this.parseArray(t,s.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeByName(e){const t=await this.attributes.find({[`${(0,i.nameof)((e=>e.content))}.${(0,i.nameof)((e=>e.name))}`]:e}),r=await this.parseArray(t,s.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeHistoryByName(e){const t=await this.attributes.find({[`${(0,i.nameof)((e=>e.content))}.${(0,i.nameof)((e=>e.name))}`]:e});return(await this.parseArray(t,s.ConsumptionAttribute)).sort(((e,t)=>e.createdAt.compare(t.createdAt)))}async getAttributes(e){const t=await this.attributes.find(e);return await this.parseArray(t,s.ConsumptionAttribute)}async getValidAttributes(e){const t=await this.attributes.find(e),r=await this.parseArray(t,s.ConsumptionAttribute);return this.filterCurrent(r)}async getAttributesByName(e){return(await this.getValidAttributes(e)).reduce(((e,t)=>(e[t.content.name]=t,e)),{})}async createAttribute(e){if(await this.getAttributeByName(e.content.name))throw o.ConsumptionErrors.attributes.attributeExists(e.content.name);return await this.attributes.create(e),e}async succeedAttribute(e,t){const r=await this.getAttributeByName(e.content.name);return r&&!t&&(t=n.CoreDate.utc()),r&&(e.content.validFrom=t,r.content.validTo=t,await this.updateAttribute(r)),await this.attributes.create(e),e}async updateAttribute(e){const t=await this.attributes.findOne({[(0,i.nameof)((e=>e.id))]:e.id.toString()});if(!t)throw n.TransportErrors.general.recordNotFound(s.ConsumptionAttribute,e.id.toString());return await this.attributes.update(t,e),e}async deleteAttribute(e){await this.attributes.delete(e)}}t.ConsumptionAttributesController=ConsumptionAttributesController},5192:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttribute=void 0;const s=r(194),a=r(5030),c=r(9663),u=r(4714),l=r(7997);let p=n=class ConsumptionAttribute extends c.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,u.nameof)((e=>e.createdAt))],this.userdataProperties=[(0,u.nameof)((e=>e.content))],this.metadataProperties=[(0,u.nameof)((e=>e.metadata)),(0,u.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,n)}static async fromAttribute(e){return await this.from({content:a.Attribute.from(e),id:await l.ConsumptionIds.attribute.generate(),createdAt:c.CoreDate.utc()})}};i([(0,s.validate)(),(0,s.serialize)({type:a.Attribute}),o("design:type",a.Attribute)],p.prototype,"content",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",c.CoreDate)],p.prototype,"createdAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)({any:!0}),o("design:type",Object)],p.prototype,"metadata",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",c.CoreDate)],p.prototype,"metadataModifiedAt",void 0),p=n=i([(0,s.type)("ConsumptionAttribute")],p),t.ConsumptionAttribute=p},1574:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DraftsController=void 0;const n=r(9663),i=r(7997),o=r(8535);class DraftsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.DraftsController,e)}async init(){return await super.init(),this.drafts=await this.parent.accountController.getSynchronizedCollection("Drafts"),this}async getDraft(e){const t=await this.drafts.read(e.toString());return t?await o.Draft.from(t):void 0}async getDrafts(e){const t=await this.drafts.find(e);return await this.parseArray(t,o.Draft)}async createDraft(e,t=""){const r=await o.Draft.from({id:await i.ConsumptionIds.draft.generate(),content:e,createdAt:new n.CoreDate,lastModifiedAt:new n.CoreDate,type:t});return await this.drafts.create(r),r}async updateDraft(e){const t=await this.drafts.read(e.id.toString());if(!t)throw new Error("Draft Not Found");await this.drafts.update(t,e)}async deleteDraft(e){await this.drafts.delete(e)}}t.DraftsController=DraftsController},8535:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Draft=void 0;const s=r(194),a=r(9663),c=r(4714);let u=n=class Draft extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.type)),(0,c.nameof)((e=>e.createdAt)),(0,c.nameof)((e=>e.lastModifiedAt))],this.userdataProperties=[(0,c.nameof)((e=>e.content))],this.metadataProperties=[(0,c.nameof)((e=>e.metadata)),(0,c.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.from(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],u.prototype,"type",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"createdAt",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"lastModifiedAt",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",s.SerializableAsync)],u.prototype,"content",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)({any:!0}),o("design:type",Object)],u.prototype,"metadata",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"metadataModifiedAt",void 0),u=n=i([(0,s.type)("Draft")],u),t.Draft=u},9662:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(8896),t),i(r(5192),t),i(r(1574),t),i(r(8535),t),i(r(7880),t),i(r(1447),t),i(r(4155),t),i(r(6058),t),i(r(8576),t),i(r(6520),t),i(r(9379),t),i(r(2639),t),i(r(1687),t),i(r(6592),t),i(r(7323),t),i(r(5829),t),i(r(9779),t),i(r(7066),t),i(r(5664),t),i(r(3665),t),i(r(569),t),i(r(7994),t),i(r(9469),t),i(r(9116),t),i(r(6137),t),i(r(5809),t),i(r(9472),t),i(r(2662),t),i(r(3592),t),i(r(4981),t),i(r(1557),t),i(r(5180),t),i(r(325),t),i(r(2660),t),i(r(8672),t),i(r(4943),t),i(r(8826),t),i(r(4245),t),i(r(7750),t)},6058:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoController=void 0;const n=r(7997),i=r(1447),o=r(3657);class RelationshipInfoController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.RelationshipInfoController,e)}async init(){return await super.init(),this.relationshipInfo=await this.parent.accountController.getSynchronizedCollection("RelationshipInfo"),this}async getRelationshipInfo(e){const t=await this.relationshipInfo.read(e.toString());return t?await i.RelationshipInfo.from(t):void 0}async getRelationshipInfoByRelationship(e){return await new o.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(e)}async getRelationshipInfos(e){const t=await this.relationshipInfo.find(e);return await this.parseArray(t,i.RelationshipInfo)}async createRelationshipInfo(e){if(await this.relationshipInfo.exists({relationshipId:e.relationshipId}))throw n.ConsumptionErrors.relationshipInfo.relationshipInfoExists(e.relationshipId.toString());return await this.relationshipInfo.create(e),e}async updateRelationshipInfo(e){const t=await this.relationshipInfo.read(e.id.toString());if(!t)throw new Error("RelationshipInfo Not Found");await this.relationshipInfo.update(t,e)}async deleteRelationshipInfo(e){await this.relationshipInfo.delete(e)}}t.RelationshipInfoController=RelationshipInfoController},3657:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoUtil=void 0;const n=r(194),i=r(5030),o=r(9663),s=r(7997),a=r(4943),c=r(7880),u=r(1447);class RelationshipInfoUtil{constructor(e){this.parent=e,this._log=o.TransportLoggerFactory.getLogger(RelationshipInfoUtil)}get log(){return this._log}async createInitialRelationshipInfo(e){const t=await this.parent.accountController.relationships.getRelationship(e);if(!t)throw o.TransportErrors.general.recordNotFound(o.Relationship,e.toString()).logWith(this._log);return await this.parseTemplateBody(t),await this.parseCreationRequest(t),await this.createRelationshipInfo(t)}getTitle(e,t){let r=e.peer.address.toString().substring(3,9);const n=t.get("Thing.name")?.content.value,i=t.get("Person.givenName")?.content.value,o=t.get("Person.familyName")?.content.value,s=t.get("Person.gender")?.content.value,a=t.get("Organization.name")?.content.value,c=t.get("Organization.legalname")?.content.value;return n?r=n:i&&o?r=`${i} ${o}`:i?r=i:o&&s?r=`i18n://salutation.gender.${s} ${o}`:a?r=a:c&&(r=c),r}async createRelationshipInfo(e){const t=e.peer.address.address.substring(3,9),r=await u.RelationshipInfo.from({attributes:[],id:await s.ConsumptionIds.relationshipInfo.generate(),isPinned:!1,relationshipId:e.id,title:t}),n=await this.parent.sharedItems.getSharedItems({sharedBy:e.peer.address.toString()}),o=[],a=new Map;for(const e of n)if(e.content instanceof i.Attribute){const t=await c.RelationshipAttribute.from({name:e.content.name,sharedItem:e.id,content:e.content});o.push(t),a.set(t.name,t)}r.attributes=o;const l=this.getTitle(e,a);return r.title=l,r}async parseTemplateBody(e){const t=e.cache.template;if(!t.cache)throw o.TransportErrors.general.cacheEmpty(o.RelationshipTemplate,t.id.toString()).logWith(this._log);const r=t.cache.content,c=this.parent.accountController.identity.isMe(t.cache.createdBy),u=t.cache.createdAt,l=c?this.parent.accountController.identity.address:e.peer.address,p=c?e.peer.address:this.parent.accountController.identity.address,f=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),d=[];if(r instanceof i.RelationshipTemplateBody){const e=r.sharedAttributes;e&&f.length!==e.length&&e.forEach((e=>{f.find((function(t){return t.content.name===e.name}))||d.push(e)}))}else{let e=r;(r instanceof n.JSONWrapper||r instanceof n.JSONWrapperAsync)&&(e=e.value),e?.attributes&&Array.isArray(e.attributes)&&f.length!==e.attributes.length&&e.attributes.forEach((e=>{f.find((function(t){return t.content.name===e.name}))||d.push(i.Attribute.from({name:e.name,value:e.value}))}))}for(const e of d){const r=await a.SharedItem.from({id:await s.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:u,sharedBy:l,sharedWith:p,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}async parseCreationRequest(e){const t=e.cache.creationChange,r=t.request,o=r.content,c=this.parent.accountController.identity.isMe(r.createdBy),u=r.createdAt,l=c?this.parent.accountController.identity.address:e.peer.address,p=c?e.peer.address:this.parent.accountController.identity.address,f=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),d=[];if(o instanceof i.RelationshipCreationChangeRequestBody){const e=o.sharedAttributes;e&&e.length>0&&f.length!==e.length&&e.forEach((e=>{f.find((function(t){return t.content.name===e.name}))||d.push(e)}))}else{let e=o;if((o instanceof n.JSONWrapper||o instanceof n.JSONWrapperAsync)&&(e=e.value),e?.attributes){const t=Object.keys(e.attributes);f.length!==t.length&&t.forEach((t=>{const r=e.attributes[t];f.find((function(e){return e.content.name===r.name}))||d.push(i.Attribute.from({name:r.name,value:r.value}))}))}}for(const e of d){const r=await a.SharedItem.from({id:await s.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:u,sharedBy:l,sharedWith:p,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}}t.RelationshipInfoUtil=RelationshipInfoUtil},7880:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipAttribute=void 0;const s=r(194),a=r(5030),c=r(9663);let u=n=class RelationshipAttribute extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],u.prototype,"name",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.Attribute)],u.prototype,"content",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",c.CoreId)],u.prototype,"sharedItem",void 0),u=n=i([(0,s.type)("RelationshipAttribute")],u),t.RelationshipAttribute=u},1447:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfo=void 0;const s=r(194),a=r(9663),c=r(4714),u=r(7997),l=r(7880),p=r(4155);let f=n=class RelationshipInfo extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.relationshipId)),(0,c.nameof)((e=>e.title)),(0,c.nameof)((e=>e.description)),(0,c.nameof)((e=>e.theme))],this.userdataProperties=[(0,c.nameof)((e=>e.isPinned)),(0,c.nameof)((e=>e.userTitle)),(0,c.nameof)((e=>e.userDescription))]}static async fromRelationship(e){return void 0===e.metadata?await n.from({id:await u.ConsumptionIds.relationshipInfo.generate(),relationshipId:e.id,attributes:[],isPinned:!1,title:e.peer.address.address.substring(3,9)}):await n.from(e.metadata)}static async from(e){return await super.fromT(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreId)],f.prototype,"relationshipId",void 0),i([(0,s.validate)(),(0,s.serialize)({type:l.RelationshipAttribute}),o("design:type",Array)],f.prototype,"attributes",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",Boolean)],f.prototype,"isPinned",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],f.prototype,"userTitle",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],f.prototype,"title",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],f.prototype,"userDescription",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],f.prototype,"description",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",p.RelationshipTheme)],f.prototype,"theme",void 0),f=n=i([(0,s.type)("RelationshipInfo")],f),t.RelationshipInfo=f},4155:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipTheme=void 0;const s=r(194);let a=n=class RelationshipTheme extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],a.prototype,"image",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],a.prototype,"imageBar",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],a.prototype,"backgroundColor",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],a.prototype,"foregroundColor",void 0),a=n=i([(0,s.type)("RelationshipTheme")],a),t.RelationshipTheme=a},7066:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DecideRequestParametersValidator=void 0;const n=r(5172);t.DecideRequestParametersValidator=class DecideRequestParametersValidator{validate(e,t){return e.items.length!==t.content.items.length?n.Result.fail(new n.ApplicationError("invalidNumberOfItems","Number of items in Request and Response do not match")):n.Result.ok(void 0)}}},5664:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IncomingRequestsController=void 0;const n=r(5030),i=r(9663),o=r(7997),s=r(9116),a=r(6137),c=r(5809),u=r(2662),l=r(8576),p=r(6520),f=r(9379),d=r(2639),h=r(1687),m=r(6592),y=r(5829),v=r(9779),g=r(7066),b=r(3665),w=r(569);class IncomingRequestsController extends o.ConsumptionBaseController{constructor(e,t){super(o.ConsumptionControllerName.RequestsController,e),this.processorRegistry=t,this.decideRequestParamsValidator=new g.DecideRequestParametersValidator}async init(){return await super.init(),this.consumptionRequests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async received(e){const t=await b.ReceivedIncomingRequestParameters.from(e),r=this.extractInfoFromSource(t.requestSourceObject),n=await a.ConsumptionRequest.from({id:t.receivedRequest.id??await i.CoreId.generate(),createdAt:i.CoreDate.utc(),status:c.ConsumptionRequestStatus.Open,content:t.receivedRequest,isOwn:!1,peer:r.peer,source:r.source,statusLog:[]});return await this.consumptionRequests.create(n),n}extractInfoFromSource(e){return e instanceof i.Message?this.extractInfoFromMessage(e):this.extractInfoFromRelationshipTemplate(e)}extractInfoFromMessage(e){if(e.isOwn)throw new Error("Cannot create incoming Request from own Message");return{peer:e.cache.createdBy,source:{reference:e.id,type:"Message"}}}extractInfoFromRelationshipTemplate(e){if(e.isOwn)throw new Error("Cannot create incoming Request from own Relationship Template");return{peer:e.cache.createdBy,source:{reference:e.id,type:"RelationshipTemplate"}}}async checkPrerequisites(e){const t=await l.CheckPrerequisitesOfIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);this.assertRequestStatus(r,c.ConsumptionRequestStatus.Open);for(const e of r.content.items)if(e instanceof n.RequestItem){const t=this.processorRegistry.getProcessorForItem(e);if(!await t.checkPrerequisitesOfIncomingRequestItem(e))return r}else for(const t of e.items){const e=this.processorRegistry.getProcessorForItem(t);if(!await e.checkPrerequisitesOfIncomingRequestItem(t))return r}return r.changeStatus(c.ConsumptionRequestStatus.DecisionRequired),await this.update(r),r}async requireManualDecision(e){const t=await w.RequireManualDecisionOfIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);return this.assertRequestStatus(r,c.ConsumptionRequestStatus.DecisionRequired),r.changeStatus(c.ConsumptionRequestStatus.ManualDecisionRequired),await this.update(r),r}async canAccept(e){const t=await d.AcceptRequestParameters.from(e);return await this.canDecide(t,"Accept")}async canReject(e){const t=await v.RejectRequestParameters.from(e);return await this.canDecide(t,"Reject")}async canDecide(e,t){const r=await this.getOrThrow(e.requestId);this.assertRequestStatus(r,c.ConsumptionRequestStatus.DecisionRequired,c.ConsumptionRequestStatus.ManualDecisionRequired);const n=await this.canDecideItems(e.items,r.content.items,t);return s.ValidationResult.fromItems(n)}async canDecideGroup(e,t,r){const n=await this.canDecideItems(e.items,t.items,r);return s.ValidationResult.fromItems(n)}async canDecideItems(e,t,r){const i=[];for(let o=0;o<e.length;o++){const s=e[o],a=t[o];if(a instanceof n.RequestItemGroup){const e=await this.canDecideGroup(s,a,r);i.push(e)}else{const e=await this.canDecideItem(s,a,r);i.push(e)}}return i}canDecideItem(e,t,r){return this.processorRegistry.getProcessorForItem(t)[`can${r}`](t,e)}async accept(e){if(!(await this.canAccept(e)).isSuccess())throw new Error("Cannot accept the Request with the given parameters. Call 'canAccept' to get more information.");return await this.decide(await d.AcceptRequestParameters.from(e))}async reject(e){if(!(await this.canReject(e)).isSuccess())throw new Error("Cannot reject the Request with the given parameters. Call 'canReject' to get more information.");return await this.decide(await v.RejectRequestParameters.from(e))}async decide(e){const t=await this.getOrThrow(e.requestId);this.assertRequestStatus(t,c.ConsumptionRequestStatus.DecisionRequired,c.ConsumptionRequestStatus.ManualDecisionRequired);const r=this.decideRequestParamsValidator.validate(e,t);if(!r.isSuccess)throw new Error(r.error.message);const n=await this.createConsumptionResponse(e,t);return t.response=n,t.changeStatus(c.ConsumptionRequestStatus.Decided),await this.update(t),t}async createConsumptionResponse(e,t){const r=t.content.items,o=await this.decideItems(e.items,r),s=await n.Response.from({result:e instanceof d.AcceptRequestParameters?n.ResponseResult.Accepted:n.ResponseResult.Rejected,requestId:t.id,items:o});return await u.ConsumptionResponse.from({content:s,createdAt:i.CoreDate.utc()})}async decideGroup(e,t){const r=await this.decideItems(e.items,t.items);return await n.ResponseItemGroup.from({items:r,metadata:t.responseMetadata})}async decideItems(e,t){const r=[];for(let n=0;n<e.length;n++){const i=e[n];i instanceof m.DecideRequestItemParameters?r.push(await this.decideItem(i,t[n])):i instanceof h.DecideRequestItemGroupParameters&&r.push(await this.decideGroup(i,t[n]))}return r}async decideItem(e,t){const r=this.processorRegistry.getProcessorForItem(t);try{if(e instanceof f.AcceptRequestItemParameters)return await r.accept(t,e);if(e instanceof y.RejectRequestItemParameters)return await r.reject(t,e)}catch(e){let r="";throw e instanceof Error&&(r=` Details: ${e.message}`),new Error(`An error occurred while processing a '${t.constructor.name}'. You should contact the developer of this RequestItem.${r}}`)}throw new Error("Unknown params type")}async complete(e){const t=await p.CompleteIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);if(r.isOwn)throw new Error("Cannot decide own Request");let n;if(this.assertRequestStatus(r,c.ConsumptionRequestStatus.Decided),t.responseSourceObject instanceof i.Message)n="Message";else{if(!(t.responseSourceObject instanceof i.RelationshipChange))throw new Error("Unknown response source");n="RelationshipChange"}return r.response.source=await u.ConsumptionResponseSource.from({type:n,reference:t.responseSourceObject.id}),r.changeStatus(c.ConsumptionRequestStatus.Completed),await this.update(r),r}async get(e){const t=await this.consumptionRequests.findOne({id:e.toString(),isOwn:!1});return t?await a.ConsumptionRequest.from(t):void 0}async getOrThrow(e){const t=await this.get(e);if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.toString());return t}async update(e){const t=await this.consumptionRequests.findOne({id:e.id.toString(),isOwn:!1});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.id.toString());await this.consumptionRequests.update(t,e)}assertRequestStatus(e,...t){if(!t.includes(e.status))throw new Error(`Consumption Request has to be in status '${t.join("/")}'.`)}}t.IncomingRequestsController=IncomingRequestsController},8576:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CheckPrerequisitesOfIncomingRequestParameters=void 0;const s=r(194),a=r(9663);let c=n=class CheckPrerequisitesOfIncomingRequestParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.CoreId)],c.prototype,"requestId",void 0),c=n=i([(0,s.type)("CheckPrerequisitesOfIncomingRequestParameters")],c),t.CheckPrerequisitesOfIncomingRequestParameters=c},6520:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CompleteIncomingRequestParameters=void 0;const o=r(194),s=r(9663);class CompleteIncomingRequestParameters extends o.SerializableAsync{static async from(e){return await super.fromT(e,CompleteIncomingRequestParameters)}}n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],CompleteIncomingRequestParameters.prototype,"requestId",void 0),n([(0,o.serialize)({unionTypes:[s.Message,s.RelationshipChange]}),(0,o.validate)(),i("design:type",Object)],CompleteIncomingRequestParameters.prototype,"responseSourceObject",void 0),t.CompleteIncomingRequestParameters=CompleteIncomingRequestParameters},9379:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(t,"__esModule",{value:!0}),t.AcceptRequestItemParameters=void 0;const o=r(194),s=r(6592);let a=n=class AcceptRequestItemParameters extends s.DecideRequestItemParameters{static async from(e){return await super.fromT(e,n)}};a=n=i([(0,o.type)("AcceptRequestItemParameters")],a),t.AcceptRequestItemParameters=a},2639:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(t,"__esModule",{value:!0}),t.AcceptRequestParameters=void 0;const o=r(194),s=r(7323);let a=n=class AcceptRequestParameters extends s.DecideRequestParameters{static async from(e){return await super.fromT(e,n)}};a=n=i([(0,o.type)("AcceptRequestParameters")],a),t.AcceptRequestParameters=a},1687:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.DecideRequestItemGroupParameters=void 0;const s=r(194);let a=n=class DecideRequestItemGroupParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",Array)],a.prototype,"items",void 0),a=n=i([(0,s.type)("DecideRequestItemGroupParameters")],a),t.DecideRequestItemGroupParameters=a},6592:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DecideRequestItemParameters=void 0;const n=r(194);class DecideRequestItemParameters extends n.SerializableAsync{}t.DecideRequestItemParameters=DecideRequestItemParameters},7323:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.DecideRequestParameters=void 0;const o=r(194),s=r(9663);class DecideRequestParameters extends o.SerializableAsync{}n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],DecideRequestParameters.prototype,"requestId",void 0),n([(0,o.serialize)(),(0,o.validate)({customValidator:e=>0===e.length?"may not be empty":void 0}),i("design:type",Array)],DecideRequestParameters.prototype,"items",void 0),t.DecideRequestParameters=DecideRequestParameters},5829:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RejectRequestItemParameters=void 0;const s=r(194),a=r(6592);let c=n=class RejectRequestItemParameters extends a.DecideRequestItemParameters{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)({nullable:!0}),o("design:type",String)],c.prototype,"code",void 0),i([(0,s.serialize)(),(0,s.validate)({nullable:!0}),o("design:type",String)],c.prototype,"message",void 0),c=n=i([(0,s.type)("RejectRequestItemParameters")],c),t.RejectRequestItemParameters=c},9779:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s};Object.defineProperty(t,"__esModule",{value:!0}),t.RejectRequestParameters=void 0;const o=r(194),s=r(7323);let a=n=class RejectRequestParameters extends s.DecideRequestParameters{static async from(e){return await super.fromT(e,n)}};a=n=i([(0,o.type)("RejectRequestParameters")],a),t.RejectRequestParameters=a},3665:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ReceivedIncomingRequestParameters=void 0;const s=r(194),a=r(5030),c=r(9663);let u=n=class ReceivedIncomingRequestParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.Request)],u.prototype,"receivedRequest",void 0),i([(0,s.serialize)({unionTypes:[c.Message,c.RelationshipTemplate]}),(0,s.validate)(),o("design:type",Object)],u.prototype,"requestSourceObject",void 0),u=n=i([(0,s.type)("ReceivedIncomingRequestParameters")],u),t.ReceivedIncomingRequestParameters=u},569:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequireManualDecisionOfIncomingRequestParameters=void 0;const o=r(194),s=r(9663);class RequireManualDecisionOfIncomingRequestParameters extends o.SerializableAsync{static async from(e){return await super.fromT(e,RequireManualDecisionOfIncomingRequestParameters)}}n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],RequireManualDecisionOfIncomingRequestParameters.prototype,"requestId",void 0),t.RequireManualDecisionOfIncomingRequestParameters=RequireManualDecisionOfIncomingRequestParameters},7994:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GenericRequestItemProcessor=void 0;const n=r(5030),i=r(9116);t.GenericRequestItemProcessor=class GenericRequestItemProcessor{checkPrerequisitesOfIncomingRequestItem(e){return!0}canAccept(e,t){return i.ValidationResult.success()}canReject(e,t){return i.ValidationResult.success()}async accept(e,t){return await n.AcceptResponseItem.from({result:n.ResponseItemResult.Accepted,metadata:e.responseMetadata})}async reject(e,t){return await n.RejectResponseItem.from({result:n.ResponseItemResult.Rejected,metadata:e.responseMetadata})}canApplyIncomingResponseItem(e,t){return i.ValidationResult.success()}canCreateOutgoingRequestItem(e){return i.ValidationResult.success()}applyIncomingResponseItem(e,t){}}},9469:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestItemProcessorRegistry=void 0;t.RequestItemProcessorRegistry=class RequestItemProcessorRegistry{constructor(){this.registry={}}registerProcessor(e,t){if(this.registry.hasOwnProperty(t.name))throw new Error(`There is already a processor registered for '${t.name}''. Use 'replaceProcessorForType' if you want to replace it.`);this.registry[t.name]=e}replaceProcessor(e,t){this.registry[t.name]=e}getProcessorForItem(e){const t=this.registry[e.constructor.name];if(!t)throw new Error(`There was no processor registered for '${e.constructor.name}'.`);return new t}}},9116:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorValidationResult=t.SuccessfulValidatonResult=t.ValidationResult=void 0;class ValidationResult{constructor(e){this.items=e}isSuccess(){return this instanceof SuccessfulValidatonResult}isError(){return this instanceof ErrorValidationResult}static success(e=[]){return new SuccessfulValidatonResult(e)}static error(e,t,r=[]){return new ErrorValidationResult(e,t,r)}static fromItems(e){return e.some((e=>e.isError()))?ValidationResult.error("inheritedFromItem","Some child items have errors.",e):ValidationResult.success(e)}}t.ValidationResult=ValidationResult;class SuccessfulValidatonResult extends ValidationResult{constructor(e){super(e)}}t.SuccessfulValidatonResult=SuccessfulValidatonResult;class ErrorValidationResult extends ValidationResult{constructor(e,t,r){super(r),this.code=e,this.message=t}}t.ErrorValidationResult=ErrorValidationResult},6137:function(e,t,r){"use strict";var n,i,o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequest=t.ConsumptionRequestSource=void 0;const a=r(194),c=r(5030),u=r(9663),l=r(5809),p=r(9472),f=r(2662);let d=n=class ConsumptionRequestSource extends u.CoreSerializableAsync{static from(e){return super.fromT(e,n)}};o([(0,a.serialize)(),(0,a.validate)(),s("design:type",String)],d.prototype,"type",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",u.CoreId)],d.prototype,"reference",void 0),d=n=o([(0,a.type)("ConsumptionRequestSource")],d),t.ConsumptionRequestSource=d;let h=i=class ConsumptionRequest extends u.CoreSynchronizable{changeStatus(e){const t=p.ConsumptionRequestStatusLogEntry.from({createdAt:u.CoreDate.utc(),oldStatus:this.status,newStatus:e});this.statusLog.push(t),this.status=e}sent(e){if(this.status!==l.ConsumptionRequestStatus.Draft)throw new Error("Consumption Request has to be in status 'Draft'.");this.source=e,this.changeStatus(l.ConsumptionRequestStatus.Open)}static async from(e){return await super.fromT(e,i)}};o([(0,a.serialize)(),(0,a.validate)(),s("design:type",Boolean)],h.prototype,"isOwn",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",u.CoreAddress)],h.prototype,"peer",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",u.CoreDate)],h.prototype,"createdAt",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",c.Request)],h.prototype,"content",void 0),o([(0,a.serialize)(),(0,a.validate)({nullable:!0}),s("design:type",d)],h.prototype,"source",void 0),o([(0,a.serialize)(),(0,a.validate)({nullable:!0}),s("design:type",f.ConsumptionResponse)],h.prototype,"response",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",String)],h.prototype,"status",void 0),o([(0,a.serialize)({type:p.ConsumptionRequestStatusLogEntry}),(0,a.validate)(),s("design:type",Array)],h.prototype,"statusLog",void 0),h=i=o([(0,a.type)("ConsumptionRequest")],h),t.ConsumptionRequest=h},5809:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequestStatus=void 0,function(e){e.Draft="Draft",e.Open="Open",e.DecisionRequired="DecisionRequired",e.ManualDecisionRequired="ManualDecisionRequired",e.Decided="Decided",e.Completed="Completed"}(t.ConsumptionRequestStatus||(t.ConsumptionRequestStatus={}))},9472:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequestStatusLogEntry=void 0;const s=r(194),a=r(9663);r(5809);let c=n=class ConsumptionRequestStatusLogEntry extends a.CoreSerializable{static from(e){return super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.CoreDate)],c.prototype,"createdAt",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",String)],c.prototype,"oldStatus",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",String)],c.prototype,"newStatus",void 0),i([(0,s.serialize)(),(0,s.validate)({nullable:!0}),o("design:type",Object)],c.prototype,"data",void 0),i([(0,s.serialize)(),(0,s.validate)({nullable:!0}),o("design:type",String)],c.prototype,"code",void 0),c=n=i([(0,s.type)("ConsumptionRequestStatusLogEntry")],c),t.ConsumptionRequestStatusLogEntry=c},2662:function(e,t,r){"use strict";var n,i,o=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},s=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionResponse=t.ConsumptionResponseSource=void 0;const a=r(194),c=r(5030),u=r(9663);let l=n=class ConsumptionResponseSource extends u.CoreSerializableAsync{static async from(e){return await super.fromT(e,n)}};o([(0,a.serialize)(),(0,a.validate)(),s("design:type",String)],l.prototype,"type",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",u.CoreId)],l.prototype,"reference",void 0),l=n=o([(0,a.type)("ConsumptionResponseSource")],l),t.ConsumptionResponseSource=l;let p=i=class ConsumptionResponse extends u.CoreSerializableAsync{static async from(e){return await super.fromT(e,i)}};o([(0,a.serialize)(),(0,a.validate)(),s("design:type",u.CoreDate)],p.prototype,"createdAt",void 0),o([(0,a.serialize)(),(0,a.validate)(),s("design:type",c.Response)],p.prototype,"content",void 0),o([(0,a.serialize)(),(0,a.validate)({nullable:!0}),s("design:type",l)],p.prototype,"source",void 0),p=i=o([(0,a.type)("ConsumptionResponse")],p),t.ConsumptionResponse=p},5180:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OutgoingRequestsController=void 0;const n=r(5030),i=r(9663),o=r(7997),s=r(9116),a=r(6137),c=r(5809),u=r(2662),l=r(3592),p=r(4981),f=r(1557),d=r(325);class OutgoingRequestsController extends o.ConsumptionBaseController{constructor(e,t){super(o.ConsumptionControllerName.RequestsController,e),this.processorRegistry=t}async init(){return await super.init(),this.consumptionRequests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async canCreate(e){const t=await f.CreateOutgoingRequestParameters.from(e),r=await this.canCreateItems(t.content.items);return s.ValidationResult.fromItems(r)}async canCreateItems(e){const t=[];for(const r of e)if(r instanceof n.RequestItem){const e=await this.canCreateItem(r);t.push(e)}else{const e=await this.canCreateItemGroup(r);t.push(e)}return t}async canCreateItem(e){const t=this.processorRegistry.getProcessorForItem(e);return await t.canCreateOutgoingRequestItem(e)}async canCreateItemGroup(e){const t=[];for(const r of e.items){const e=await this.canCreateItem(r);t.push(e)}return s.ValidationResult.fromItems(t)}async create(e){const t=await f.CreateOutgoingRequestParameters.from(e),r=await o.ConsumptionIds.request.generate();t.content.id=r;return await this._create(r,t.content,t.peer)}async _create(e,t,r){const n=await this.canCreate({content:t,peer:r});if(n.isError())throw new Error(n.message);const o=await a.ConsumptionRequest.from({id:e,content:t,createdAt:i.CoreDate.utc(),isOwn:!0,peer:r,status:c.ConsumptionRequestStatus.Draft,statusLog:[]});return await this.consumptionRequests.create(o),o}async createFromRelationshipCreationChange(e){const t=await p.CreateOutgoingRequestFromRelationshipCreationChangeParameters.from(e),r=t.creationChange.request.createdBy,n=t.creationChange.request.content.requestId;await this._create(n,t.template.cache.content,r),await this._sent(n,t.template);return await this._complete(n,t.creationChange,t.creationChange.request.content)}async sent(e){const t=await d.SentOutgoingRequestParameters.from(e);return await this._sent(t.requestId,t.requestSourceObject)}async _sent(e,t){const r=await this.getOrThrow(e);return this.assertRequestStatus(r,c.ConsumptionRequestStatus.Draft),r.changeStatus(c.ConsumptionRequestStatus.Open),r.source=await a.ConsumptionRequestSource.from({reference:t.id,type:this.getSourceType(t)}),await this.update(r),r}getSourceType(e){if(e instanceof i.Message){if(!e.isOwn)throw new Error("Cannot create outgoing Request from a peer Message");return"Message"}if(e instanceof i.RelationshipTemplate){if(!e.isOwn)throw new Error("Cannot create outgoing Request from a peer Relationship Template");return"RelationshipTemplate"}throw new Error("The given sourceObject is not of a valid type. Valid types are 'Message' and 'RelationshipTemplate'.")}async complete(e){const t=await l.CompleteOugoingRequestParameters.from(e);return await this._complete(t.requestId,t.responseSourceObject,t.receivedResponse)}async _complete(e,t,r){const n=await this.getOrThrow(e);this.assertRequestStatus(n,c.ConsumptionRequestStatus.Open);const o=await this.canComplete(n,r);if(o.isError())throw new Error(o.message);let s;if(await this.applyItems(n.content.items,r.items),t instanceof i.Message)s="Message";else{if(!(t instanceof i.RelationshipChange))throw new Error("Invalid responseSourceObject");s="RelationshipChange"}const a=await u.ConsumptionResponse.from({content:r,createdAt:i.CoreDate.utc(),source:{reference:t.id,type:s}});return n.response=a,n.changeStatus(c.ConsumptionRequestStatus.Completed),await this.update(n),n}async canComplete(e,t){for(let r=0;r<t.items.length;r++){const i=e.content.items[r];if(i instanceof n.RequestItem){const e=t.items[r],n=this.processorRegistry.getProcessorForItem(i),o=await n.canApplyIncomingResponseItem(e,i);if(o.isError())return o}else if(i instanceof n.RequestItemGroup){const e=t.items[r];for(let t=0;t<i.items.length;t++){const r=i.items[t],n=e.items[t],o=this.processorRegistry.getProcessorForItem(r),s=await o.canApplyIncomingResponseItem(n,r);if(s.isError())return s}}}return s.ValidationResult.success()}async applyItems(e,t){for(let r=0;r<t.length;r++){const i=e[r];if(i instanceof n.RequestItem){const e=t[r];await this.applyItem(i,e)}else{const e=t[r];await this.applyItems(i.items,e.items)}}}async applyItem(e,t){const r=this.processorRegistry.getProcessorForItem(e);await r.applyIncomingResponseItem(t,e)}async get(e){const t=await this.consumptionRequests.findOne({id:e.toString(),isOwn:!0});return t?await a.ConsumptionRequest.from(t):void 0}async getOrThrow(e){const t=await this.get(e);if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.toString());return t}async update(e){const t=await this.consumptionRequests.findOne({id:e.id.toString(),isOwn:!0});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.id.toString());await this.consumptionRequests.update(t,e)}assertRequestStatus(e,...t){if(!t.includes(e.status))throw new Error(`Consumption Request has to be in status '${t.join("/")}'.`)}}t.OutgoingRequestsController=OutgoingRequestsController},3592:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CompleteOugoingRequestParameters=void 0;const s=r(194),a=r(5030),c=r(9663);let u=n=class CompleteOugoingRequestParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",c.CoreId)],u.prototype,"requestId",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",c.Message)],u.prototype,"responseSourceObject",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.Response)],u.prototype,"receivedResponse",void 0),u=n=i([(0,s.type)("CompleteOugoingRequestParameters")],u),t.CompleteOugoingRequestParameters=u},4981:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateOutgoingRequestFromRelationshipCreationChangeParameters=void 0;const s=r(194),a=r(9663);let c=n=class CreateOutgoingRequestFromRelationshipCreationChangeParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.RelationshipTemplate)],c.prototype,"template",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.RelationshipChange)],c.prototype,"creationChange",void 0),c=n=i([(0,s.type)("CreateOutgoingRequestFromRelationshipCreationChangeParameters")],c),t.CreateOutgoingRequestFromRelationshipCreationChangeParameters=c},1557:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateOutgoingRequestParameters=void 0;const s=r(194),a=r(5030),c=r(9663);let u=n=class CreateOutgoingRequestParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.Request)],u.prototype,"content",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",c.CoreAddress)],u.prototype,"peer",void 0),u=n=i([(0,s.type)("CreateOutgoingRequestParameters")],u),t.CreateOutgoingRequestParameters=u},325:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SentOutgoingRequestParameters=void 0;const s=r(194),a=r(9663);let c=n=class SentOutgoingRequestParameters extends s.SerializableAsync{static async from(e){return await super.fromT(e,n)}};i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.CoreId)],c.prototype,"requestId",void 0),i([(0,s.serialize)(),(0,s.validate)(),o("design:type",a.Message)],c.prototype,"requestSourceObject",void 0),c=n=i([(0,s.type)("SentOutgoingRequestParameters")],c),t.SentOutgoingRequestParameters=c},8672:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsController=void 0;const n=r(9663),i=r(7997),o=r(2660);class SettingsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.SettingsController,e)}async init(){return await super.init(),this.settings=await this.parent.accountController.getSynchronizedCollection("Settings"),this}async getSetting(e){const t=await this.settings.read(e.toString());return t?await o.Setting.from(t):void 0}async getSettings(e){const t=await this.settings.find(e);return await this.parseArray(t,o.Setting)}async createSetting(e){const t=await o.Setting.from({id:await i.ConsumptionIds.setting.generate(),createdAt:n.CoreDate.utc(),key:e.key,scope:e.scope??o.SettingScope.Identity,value:e.value,reference:e.reference,succeedsAt:e.succeedsAt,succeedsItem:e.succeedsItem});return await this.settings.create(t),t}async updateSetting(e){const t=await this.settings.read(e.id.toString());if(!t)throw n.TransportErrors.general.recordNotFound(o.Setting,e.id.toString()).logWith(this._log);await this.settings.update(t,e)}async deleteSetting(e){await this.settings.delete(e)}}t.SettingsController=SettingsController},2660:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.SettingScope=void 0;const s=r(194),a=r(9663),c=r(4714);!function(e){e.Identity="Identity",e.Device="Device",e.Relationship="Relationship"}(t.SettingScope||(t.SettingScope={}));let u=n=class Setting extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.key)),(0,c.nameof)((e=>e.scope)),(0,c.nameof)((e=>e.reference)),(0,c.nameof)((e=>e.createdAt)),(0,c.nameof)((e=>e.deletedAt)),(0,c.nameof)((e=>e.succeedsItem)),(0,c.nameof)((e=>e.succeedsAt))],this.userdataProperties=[(0,c.nameof)((e=>e.value))],this.metadataProperties=[(0,c.nameof)((e=>e.metadata)),(0,c.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],u.prototype,"key",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],u.prototype,"scope",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreId)],u.prototype,"reference",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",s.SerializableAsync)],u.prototype,"value",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"createdAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"deletedAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreId)],u.prototype,"succeedsItem",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"succeedsAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)({any:!0}),o("design:type",Object)],u.prototype,"metadata",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"metadataModifiedAt",void 0),u=n=i([(0,s.type)("Setting")],u),t.Setting=u},8826:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItemsController=void 0;const n=r(9663),i=r(7997),o=r(4943);class SharedItemsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.SharedItemsController,e)}async init(){return await super.init(),this.sharedItems=await this.parent.accountController.getSynchronizedCollection("SharedItems"),this}async getSharedItem(e){const t=await this.sharedItems.read(e.toString());return t?await o.SharedItem.from(t):void 0}async getSharedItems(e){const t=await this.sharedItems.find(e);return await this.parseArray(t,o.SharedItem)}async createSharedItem(e){return await this.sharedItems.create(e),e}async updateSharedItem(e){const t=await this.sharedItems.read(e.id.toString());if(!t)throw n.TransportErrors.general.recordNotFound(o.SharedItem,e.id.toString());return await this.sharedItems.update(t,e)}async deleteSharedItem(e){await this.sharedItems.delete(e)}}t.SharedItemsController=SharedItemsController},4943:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItem=void 0;const s=r(194),a=r(9663),c=r(4714);let u=n=class SharedItem extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.tags)),(0,c.nameof)((e=>e.sharedBy)),(0,c.nameof)((e=>e.sharedWith)),(0,c.nameof)((e=>e.sharedAt)),(0,c.nameof)((e=>e.reference)),(0,c.nameof)((e=>e.content)),(0,c.nameof)((e=>e.succeedsItem)),(0,c.nameof)((e=>e.succeedsAt)),(0,c.nameof)((e=>e.expiresAt))],this.metadataProperties=[(0,c.nameof)((e=>e.metadata)),(0,c.nameof)((e=>e.metadataModifiedAt))]}static async from(e){return await super.fromT(e,n)}};i([(0,s.validate)({nullable:!0}),(0,s.serialize)({type:String}),o("design:type",Array)],u.prototype,"tags",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreAddress)],u.prototype,"sharedBy",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreAddress)],u.prototype,"sharedWith",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"sharedAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreId)],u.prototype,"reference",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",s.Serializable)],u.prototype,"content",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreId)],u.prototype,"succeedsItem",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"succeedsAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"expiresAt",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)({any:!0}),o("design:type",Object)],u.prototype,"metadata",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",a.CoreDate)],u.prototype,"metadataModifiedAt",void 0),u=n=i([(0,s.type)("SharedItem")],u),t.SharedItem=u},4245:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Signature=void 0;const s=r(194),a=r(2890),c=r(9663),u=r(7750);let l=n=class Signature extends c.CoreSerializableAsync{static async from(e){const t=await a.CryptoSignature.fromBase64(e.signature);return await super.fromT({content:e.content,signature:t},n)}static async deserialize(e){return await super.deserializeT(e,n)}async verify(e,t){if((await a.CryptoHash.hash(a.CoreBuffer.fromUtf8(e),this.content.hashAlgorithm)).toBase64()!==this.content.hash.hash)return!1;const r=this.content.serialize();return await c.CoreCrypto.verify(a.CoreBuffer.fromUtf8(r),this.signature,t)}toJSON(){return{content:this.content.toJSON(),signature:this.signature.toBase64()}}serialize(){return JSON.stringify(this.toJSON())}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",u.SignatureContent)],l.prototype,"content",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CryptoSignature)],l.prototype,"signature",void 0),l=n=i([(0,s.type)("Signature")],l),t.Signature=l},7750:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SignatureContent=void 0;const s=r(194),a=r(9663);let c=n=class SignatureContent extends a.CoreSerializable{static from(e){return super.from(e,n)}static deserialize(e){return super.deserializeT(e,n)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",Number)],c.prototype,"version",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",Number)],c.prototype,"signatureAlgorithm",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",Number)],c.prototype,"hashAlgorithm",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreDate)],c.prototype,"signedAt",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreAddress)],c.prototype,"signer",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreId)],c.prototype,"keyId",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreHash)],c.prototype,"hash",void 0),c=n=i([(0,s.type)("SignatureContent")],c),t.SignatureContent=c},1174:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},9159:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEventNamespaceFromObject=t.EventBus=void 0;t.EventBus=class EventBus{},t.getEventNamespaceFromObject=function getEventNamespaceFromObject(e){return e.namespace}},5970:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionTargetInfo=void 0;class SubscriptionTargetInfo{namespace;constructor(e){this.namespace=e}static from(e){return e instanceof Function?new ConstructorSubscriptionTargetInfo(e):new NamespaceSubscriptionTargetInfo(e)}}t.SubscriptionTargetInfo=SubscriptionTargetInfo;class ConstructorSubscriptionTargetInfo extends SubscriptionTargetInfo{constructorFunction;constructor(e){super(function getEventNamespaceFromClass(e){return e.namespace}(e)),this.constructorFunction=e}isCompatibleWith(e){return e instanceof this.constructorFunction}}class NamespaceSubscriptionTargetInfo extends SubscriptionTargetInfo{constructor(e){super(e)}isCompatibleWith(e){return!0}}},9729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter2EventBus=void 0;const n=r(6387);r(8660);const i=r(9159),o=r(5970);t.EventEmitter2EventBus=class EventEmitter2EventBus{emitter;wrappers=new Map;nextId=0;constructor(){this.emitter=new n.EventEmitter2({wildcard:!0,maxListeners:50,verboseMemoryLeak:!0})}subscribe(e,t){return this.registerHandler(e,t)}subscribeOnce(e,t){return this.registerHandler(e,t,!0)}unsubscribe(e,t){return this.unregisterHandler(e,t)}registerHandler(e,t,r=!1){const n=o.SubscriptionTargetInfo.from(e),i=this.nextId++,handlerWrapper=o=>{n.isCompatibleWith(o)&&(t(o),r&&this.unsubscribe(e,i))};return this.wrappers.set(i,handlerWrapper),this.emitter.on(n.namespace,handlerWrapper),i}unregisterHandler(e,t){const r=o.SubscriptionTargetInfo.from(e),n=this.wrappers.get(t);return!!n&&(this.emitter.off(r.namespace,n),this.wrappers.delete(t),!0)}publish(e){const t=(0,i.getEventNamespaceFromObject)(e);if(!t)throw Error("The event needs a namespace. Use the EventNamespace-decorator in order to define a namespace for a event.");this.emitter.emit(t,e)}}},9256:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(9159),t),i(r(9729),t)},5917:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataEvent=void 0;const n=r(8267);class DataEvent extends n.Event{data;constructor(e,t){super(e),this.data=t}}t.DataEvent=DataEvent},8267:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;t.Event=class Event{namespace;constructor(e){this.namespace=e}}},2636:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(5917),t),i(r(8267),t)},5172:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(9256),t),i(r(2636),t),i(r(9855),t),i(r(1809),t),i(r(4569),t),i(r(1174),t),i(r(7226),t),i(r(7374),t)},9855:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.log=void 0,t.log=function log(e,t,r){const n=r.value;return r.value=function(...e){const r=e.map((e=>JSON.stringify(e))).join();try{const i=n.apply(this,e),o=JSON.stringify(i);return console.log(`Call: ${t}(${r}) => ${o}`),i}catch(e){throw console.log(e),e}},r}},1809:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.measureExcecutionTime=void 0,t.measureExcecutionTime=function measureExcecutionTime(e,t,r){const n=r.value;return r.value=async function(...e){const t=Date.now(),r=await n.apply(this,e),i=Date.now();return console.info(`Execution time: ${i-t}ms`),r},r}},4569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomString=void 0,t.randomString=function randomString(e,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){let r="";const n=t.length;for(let i=0;i<e;i++)r+=t.charAt(Math.floor(Math.random()*n));return r}},7807:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApplicationError=void 0;class ApplicationError extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}equals(e){return this.code===e.code}}t.ApplicationError=ApplicationError},9278:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Result=void 0;class Result{_isSuccess;_error;_value;constructor(e,t,r){if(e&&r)throw new Error("InvalidOperation: A result cannot be successful and contain an error");if(!e&&!r)throw new Error("InvalidOperation: A failing result needs to contain an error");if(void 0!==t&&!e)throw new Error("InvalidOperation: A value is only useful in case of a success.");this._value=t,this._isSuccess=e,this._error=r}get isSuccess(){return this._isSuccess}get isError(){return!this._isSuccess}get error(){return this._error}get value(){if(!this.isSuccess)throw new Error("Can't get the value of an error result. Use 'error' instead.");return this._value}static ok(e){return new Result(!0,e)}static fail(e){return new Result(!1,void 0,e)}}t.Result=Result},7226:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7807),t),i(r(9278),t)},7374:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0,t.sleep=function sleep(e){return new Promise((t=>{setTimeout(t,e)}))}},6387:(e,t,r)=>{var n;!function(i){var o=Object.hasOwnProperty,s=Array.isArray?Array.isArray:function _isArray(e){return"[object Array]"===Object.prototype.toString.call(e)},a="object"==typeof process&&"function"==typeof process.nextTick,c="function"==typeof Symbol,u="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,p=c?u&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function init(){this._events={},this._conf&&configure.call(this,this._conf)}function configure(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==i&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function logPossibleMemoryLeak(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var toArray=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function toObject(e,t){for(var r={},n=e.length,o=t?value.length:0,s=0;s<n;s++)r[e[s]]=s<o?t[s]:i;return r}function TargetObserver(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function resolveOptions(e,t,r,n){var s=Object.assign({},t);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var a,c,u,l=Object.keys(e),p=l.length;function reject(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var f=0;f<p;f++){if(a=l[f],!n&&!o.call(t,a))throw Error('Unknown "'+a+'" option');(c=e[a])!==i&&(u=r[a],s[a]=u?u(c,reject):c)}return s}function constructorReducer(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function makeTypeReducer(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var o=typeof e;if(o===n||o===i)return e;r(t)}:function(n,i){for(var o=typeof n,s=r;s-- >0;)if(o===e[s])return n;i(t)}}Object.assign(TargetObserver.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,s=this._listeners,handler=function(){var n=toArray.apply(null,arguments),s={data:n,name:t,original:e};if(r){var a=r.call(i,s);!1!==a&&o.emit.apply(o,[s.name].concat(n))}else o.emit.apply(o,[t].concat(n))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===s[e]&&(s[e]=handler,n._on.call(i,e,handler))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&s[e]&&(s[e]=null,n._off.call(i,e,handler))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=handler,n._on.call(i,e,handler))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,s=this._emitter,a=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function clearRefs(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=findTargetIndex.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;a.call(c,e,t),delete o[e],--this._listenersCount||clearRefs()}else{for(n=(r=p(o)).length;n-- >0;)e=r[n],a.call(c,e,o[e]);this._listeners={},this._listenersCount=0,clearRefs()}}});var f=makeTypeReducer(["function"]),d=makeTypeReducer(["object","function"]);function makeCancelablePromise(e,t,r){var n,i,o,s=0,a=new e((function(c,u,l){function cleanup(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=resolveOptions(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof l;var _resolve=function(e){cleanup(),c(e)},_reject=function(e){cleanup(),u(e)};n?t(_resolve,_reject,l):(i=[function(e){_reject(e||Error("canceled"))}],t(_resolve,_reject,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),r.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),u(e)}),r.timeout))}));return n||(a.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),a}function findTargetIndex(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function searchListenerTree(e,t,r,n,i){if(!r)return null;if(0===n){var o=typeof t;if("string"===o){var s,a,c=0,u=0,l=this.delimiter,f=l.length;if(-1!==(a=t.indexOf(l))){s=new Array(5);do{s[c++]=t.slice(u,a),u=a+f}while(-1!==(a=t.indexOf(l,u)));s[c++]=t.slice(u),t=s,i=c}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var d,h,m,y,v,g,b,w=null,R=t[n],_=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),w=[r]):(e&&e.push.apply(e,r._listeners),w=[r]));else{if("*"===R){for(a=(g=p(r)).length;a-- >0;)"_listeners"!==(d=g[a])&&(b=searchListenerTree(e,t,r[d],n+1,i))&&(w?w.push.apply(w,b):w=b);return w}if("**"===R){for((v=n+1===i||n+2===i&&"*"===_)&&r._listeners&&(w=searchListenerTree(e,t,r,i,i)),a=(g=p(r)).length;a-- >0;)"_listeners"!==(d=g[a])&&("*"===d||"**"===d?(r[d]._listeners&&!v&&(b=searchListenerTree(e,t,r[d],i,i))&&(w?w.push.apply(w,b):w=b),b=searchListenerTree(e,t,r[d],n,i)):b=searchListenerTree(e,t,r[d],d===_?n+2:n,i),b&&(w?w.push.apply(w,b):w=b));return w}r[R]&&(w=searchListenerTree(e,t,r[R],n+1,i))}if((h=r["*"])&&searchListenerTree(e,t,h,n+1,i),m=r["**"])if(n<i)for(m._listeners&&searchListenerTree(e,t,m,i,i),a=(g=p(m)).length;a-- >0;)"_listeners"!==(d=g[a])&&(d===_?searchListenerTree(e,t,m[d],n+2,i):d===R?searchListenerTree(e,t,m[d],n+1,i):((y={})[d]=m[d],searchListenerTree(e,t,{"**":y},n+1,i)));else m._listeners?searchListenerTree(e,t,m,i,i):m["*"]&&m["*"]._listeners&&searchListenerTree(e,t,m["*"],i,i);return w}function growListenerTree(e,t,r){var n,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(n=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,n),s=n+c}while(-1!==(n=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var u,l=this.listenerTree;for(n=0;n<o;n++)if(l=l[u=i[n]]||(l[u]={}),n===o-1)return l._listeners?("function"==typeof l._listeners&&(l._listeners=[l._listeners]),r?l._listeners.unshift(t):l._listeners.push(t),!l._listeners.warned&&this._maxListeners>0&&l._listeners.length>this._maxListeners&&(l._listeners.warned=!0,logPossibleMemoryLeak.call(this,l._listeners.length,u))):l._listeners=t,!0;return!0}function collectTreeEvents(e,t,r,n){for(var i,o,s,a,c=p(e),u=c.length,l=e._listeners;u-- >0;)i=e[o=c[u]],s="_listeners"===o?r:r?r.concat(o):[o],a=n||"symbol"==typeof o,l&&t.push(a?s:s.join(this.delimiter)),"object"==typeof i&&collectTreeEvents.call(this,i,t,s,a);return t}function recursivelyGarbageCollect(e){for(var t,r,n,i=p(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||recursivelyGarbageCollect(t)||delete e[r]);return n}function Listener(e,t,r){this.emitter=e,this.event=t,this.listener=r}function setupListener(e,t,r){if(!0===r)o=!0;else if(!1===r)n=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var n=r.async,o=r.promisify,s=r.nextTick,c=r.objectify}if(n||s||o){var u=t,p=t._origin||t;if(s&&!a)throw Error("process.nextTick is not supported");o===i&&(o="AsyncFunction"===t.constructor.name),t=function(){var e=arguments,t=this,r=this.event;return o?s?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=r,u.apply(t,e)})):(s?process.nextTick:l)((function(){t.event=r,u.apply(t,e)}))},t._async=!0,t._origin=p}return[t,c?new Listener(this,e,t):this]}function EventEmitter(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,configure.call(this,e)}Listener.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},EventEmitter.EventEmitter2=EventEmitter,EventEmitter.prototype.listenTo=function(e,t,r){if("object"!=typeof e)throw TypeError("target musts be an object");var n=this;function listen(t){if("object"!=typeof t)throw TypeError("events must be an object");var i,o=r.reducers,s=findTargetIndex.call(n,e);i=-1===s?new TargetObserver(n,e,r):n._observers[s];for(var a,c=p(t),u=c.length,l="function"==typeof o,f=0;f<u;f++)a=c[f],i.subscribe(a,t[a]||a,l?o:o&&o[a])}return r=resolveOptions(r,{on:i,off:i,reducers:i},{on:f,off:f,reducers:d}),s(t)?listen(toObject(t)):listen("string"==typeof t?toObject(t.split(/\s+/)):t),this},EventEmitter.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),o=!0);return o},EventEmitter.prototype.delimiter=".",EventEmitter.prototype.setMaxListeners=function(e){e!==i&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},EventEmitter.prototype.getMaxListeners=function(){return this._maxListeners},EventEmitter.prototype.event="",EventEmitter.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},EventEmitter.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},EventEmitter.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},EventEmitter.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},EventEmitter.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},EventEmitter.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function listener(){return 0==--t&&o.off(e,listener),r.apply(this,arguments)}return listener._origin=r,this._on(e,listener,n,i)},EventEmitter.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||init.call(this);var e,t,r,n,i,o,s=arguments[0],a=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return!1;if(a&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(r=s.length,c)for(n=0;n<r;n++)if("symbol"==typeof s[n]){o=!0;break}o||(s=s.join(this.delimiter))}var u,l=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,l){case 1:u[n].call(this,s);break;case 2:u[n].call(this,s,arguments[1]);break;case 3:u[n].call(this,s,arguments[1],arguments[2]);break;default:u[n].apply(this,arguments)}if(a)u=[],searchListenerTree.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[s])){switch(this.event=s,l){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(l-1),i=1;i<l;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(l>3)for(t=new Array(l-1),i=1;i<l;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,l){case 1:u[n].call(this);break;case 2:u[n].call(this,arguments[1]);break;case 3:u[n].call(this,arguments[1],arguments[2]);break;default:u[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===s)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},EventEmitter.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||init.call(this);var e,t,r,n,i,o,s=arguments[0],a=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(a&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(n=s.length,c)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,l=[],p=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,p){case 1:l.push(this._all[i].call(this,s));break;case 2:l.push(this._all[i].call(this,s,arguments[1]));break;case 3:l.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:l.push(this._all[i].apply(this,arguments))}if(a?(u=[],searchListenerTree.call(this,u,e,this.listenerTree,0)):u=this._events[s],"function"==typeof u)switch(this.event=s,p){case 1:l.push(u.call(this));break;case 2:l.push(u.call(this,arguments[1]));break;case 3:l.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(p-1),o=1;o<p;o++)r[o-1]=arguments[o];l.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),p>3)for(r=new Array(p-1),o=1;o<p;o++)r[o-1]=arguments[o];for(i=0,n=u.length;i<n;i++)switch(this.event=s,p){case 1:l.push(u[i].call(this));break;case 2:l.push(u[i].call(this,arguments[1]));break;case 3:l.push(u[i].call(this,arguments[1],arguments[2]));break;default:l.push(u[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===s)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(l)},EventEmitter.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},EventEmitter.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},EventEmitter.prototype.onAny=function(e){return this._onAny(e,!1)},EventEmitter.prototype.prependAny=function(e){return this._onAny(e,!0)},EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},EventEmitter.prototype._on=function(e,t,r,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||init.call(this);var o,s=this;return n!==i&&(t=(o=setupListener.call(this,e,t,n))[0],s=o[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?(growListenerTree.call(this,e,t,r),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,logPossibleMemoryLeak.call(this,this._events[e].length,e))):this._events[e]=t,s)},EventEmitter.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,n=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=searchListenerTree.call(this,null,i,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],n.push({_listeners:r})}for(var o=0;o<n.length;o++){var a=n[o];if(r=a._listeners,s(r)){for(var c=-1,u=0,l=r.length;u<l;u++)if(r[u]===t||r[u].listener&&r[u].listener===t||r[u]._origin&&r[u]._origin===t){c=u;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&recursivelyGarbageCollect(this.listenerTree),this},EventEmitter.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},EventEmitter.prototype.removeListener=EventEmitter.prototype.off,EventEmitter.prototype.removeAllListeners=function(e){if(e===i)return!this._events||init.call(this),this;if(this.wildcard){var t,r=searchListenerTree.call(this,null,e,this.listenerTree,0);if(!r)return this;for(t=0;t<r.length;t++)r[t]._listeners=null;this.listenerTree&&recursivelyGarbageCollect(this.listenerTree)}else this._events&&(this._events[e]=null);return this},EventEmitter.prototype.listeners=function(e){var t,r,n,o,s,a=this._events;if(e===i){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(o=(t=p(a)).length,n=[];o-- >0;)"function"==typeof(r=a[t[o]])?n.push(r):n.push.apply(n,r);return n}if(this.wildcard){if(!(s=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return searchListenerTree.call(this,c,u,s,0),c}return a&&(r=a[e])?"function"==typeof r?[r]:r:[]},EventEmitter.prototype.eventNames=function(e){var t=this._events;return this.wildcard?collectTreeEvents.call(this,this.listenerTree,[],null,e):t?p(t):[]},EventEmitter.prototype.listenerCount=function(e){return this.listeners(e).length},EventEmitter.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return searchListenerTree.call(this,t,r,this.listenerTree,0),t.length>0}var n=this._events,o=this._all;return!!(o&&o.length||n&&(e===i?p(n).length:n[e]))},EventEmitter.prototype.listenersAny=function(){return this._all?this._all:[]},EventEmitter.prototype.waitFor=function(e,t){var r=this,n=typeof t;return"number"===n?t={timeout:t}:"function"===n&&(t={filter:t}),makeCancelablePromise((t=resolveOptions(t,{timeout:0,filter:i,handleError:!1,Promise,overload:!1},{filter:f,Promise:constructorReducer})).Promise,(function(n,i,o){function listener(){var o=t.filter;if(!o||o.apply(r,arguments))if(r.off(e,listener),t.handleError){var s=arguments[0];s?i(s):n(toArray.apply(null,arguments).slice(1))}else n(toArray.apply(null,arguments))}o((function(){r.off(e,listener)})),r._on(e,listener,!1)}),{timeout:t.timeout,overload:t.overload})};var h=EventEmitter.prototype;Object.defineProperties(EventEmitter,{defaultMaxListeners:{get:function(){return h._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");h._maxListeners=e},enumerable:!0},once:{value:function once(e,t,r){return makeCancelablePromise((r=resolveOptions(r,{Promise,timeout:0,overload:!1},{Promise:constructorReducer})).Promise,(function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(toArray.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,eventListener=function(){s&&e.removeListener("error",s),r(toArray.apply(null,arguments))};"error"!==t&&(s=function(r){e.removeListener(t,eventListener),n(r)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,eventListener)})),e.once(t,eventListener)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(h,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),(n=function(){return EventEmitter}.call(t,r,t,e))===i||(e.exports=n)}()},8660:()=>{var e;!function(e){!function(t){var r="object"==typeof global?global:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),n=makeExporter(e);function makeExporter(e,t){return function(r,n){"function"!=typeof e[r]&&Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0===r.Reflect?r.Reflect=e:n=makeExporter(r.Reflect,n),function(e){var t=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,n=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",i=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,s={__proto__:[]}instanceof Array,a=!o&&!s,c={create:o?function(){return MakeDictionary(Object.create(null))}:s?function(){return MakeDictionary({__proto__:null})}:function(){return MakeDictionary({})},has:a?function(e,r){return t.call(e,r)}:function(e,t){return t in e},get:a?function(e,r){return t.call(e,r)?e[r]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="object"==typeof process&&process.env&&"true"===process.env.REFLECT_METADATA_USE_MAP_POLYFILL,p=l||"function"!=typeof Map||"function"!=typeof Map.prototype.entries?CreateMapPolyfill():Map,f=l||"function"!=typeof Set||"function"!=typeof Set.prototype.entries?CreateSetPolyfill():Set,d=new(l||"function"!=typeof WeakMap?CreateWeakMapPolyfill():WeakMap);function decorate(e,t,r,n){if(IsUndefined(r)){if(!IsArray(e))throw new TypeError;if(!IsConstructor(t))throw new TypeError;return DecorateConstructor(e,t)}if(!IsArray(e))throw new TypeError;if(!IsObject(t))throw new TypeError;if(!IsObject(n)&&!IsUndefined(n)&&!IsNull(n))throw new TypeError;return IsNull(n)&&(n=void 0),DecorateProperty(e,t,r=ToPropertyKey(r),n)}function metadata(e,t){function decorator(r,n){if(!IsObject(r))throw new TypeError;if(!IsUndefined(n)&&!IsPropertyKey(n))throw new TypeError;OrdinaryDefineOwnMetadata(e,t,r,n)}return decorator}function defineMetadata(e,t,r,n){if(!IsObject(r))throw new TypeError;return IsUndefined(n)||(n=ToPropertyKey(n)),OrdinaryDefineOwnMetadata(e,t,r,n)}function hasMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryHasMetadata(e,t,r)}function hasOwnMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryHasOwnMetadata(e,t,r)}function getMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryGetMetadata(e,t,r)}function getOwnMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryGetOwnMetadata(e,t,r)}function getMetadataKeys(e,t){if(!IsObject(e))throw new TypeError;return IsUndefined(t)||(t=ToPropertyKey(t)),OrdinaryMetadataKeys(e,t)}function getOwnMetadataKeys(e,t){if(!IsObject(e))throw new TypeError;return IsUndefined(t)||(t=ToPropertyKey(t)),OrdinaryOwnMetadataKeys(e,t)}function deleteMetadata(e,t,r){if(!IsObject(t))throw new TypeError;IsUndefined(r)||(r=ToPropertyKey(r));var n=GetOrCreateMetadataMap(t,r,!1);if(IsUndefined(n))return!1;if(!n.delete(e))return!1;if(n.size>0)return!0;var i=d.get(t);return i.delete(r),i.size>0||d.delete(t),!0}function DecorateConstructor(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!IsUndefined(n)&&!IsNull(n)){if(!IsConstructor(n))throw new TypeError;t=n}}return t}function DecorateProperty(e,t,r,n){for(var i=e.length-1;i>=0;--i){var o=(0,e[i])(t,r,n);if(!IsUndefined(o)&&!IsNull(o)){if(!IsObject(o))throw new TypeError;n=o}}return n}function GetOrCreateMetadataMap(e,t,r){var n=d.get(e);if(IsUndefined(n)){if(!r)return;n=new p,d.set(e,n)}var i=n.get(t);if(IsUndefined(i)){if(!r)return;i=new p,n.set(t,i)}return i}function OrdinaryHasMetadata(e,t,r){if(OrdinaryHasOwnMetadata(e,t,r))return!0;var n=OrdinaryGetPrototypeOf(t);return!IsNull(n)&&OrdinaryHasMetadata(e,n,r)}function OrdinaryHasOwnMetadata(e,t,r){var n=GetOrCreateMetadataMap(t,r,!1);return!IsUndefined(n)&&ToBoolean(n.has(e))}function OrdinaryGetMetadata(e,t,r){if(OrdinaryHasOwnMetadata(e,t,r))return OrdinaryGetOwnMetadata(e,t,r);var n=OrdinaryGetPrototypeOf(t);return IsNull(n)?void 0:OrdinaryGetMetadata(e,n,r)}function OrdinaryGetOwnMetadata(e,t,r){var n=GetOrCreateMetadataMap(t,r,!1);if(!IsUndefined(n))return n.get(e)}function OrdinaryDefineOwnMetadata(e,t,r,n){GetOrCreateMetadataMap(r,n,!0).set(e,t)}function OrdinaryMetadataKeys(e,t){var r=OrdinaryOwnMetadataKeys(e,t),n=OrdinaryGetPrototypeOf(e);if(null===n)return r;var i=OrdinaryMetadataKeys(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new f,s=[],a=0,c=r;a<c.length;a++){var u=c[a];o.has(u)||(o.add(u),s.push(u))}for(var l=0,p=i;l<p.length;l++){u=p[l];o.has(u)||(o.add(u),s.push(u))}return s}function OrdinaryOwnMetadataKeys(e,t){var r=[],n=GetOrCreateMetadataMap(e,t,!1);if(IsUndefined(n))return r;for(var i=GetIterator(n.keys()),o=0;;){var s=IteratorStep(i);if(!s)return r.length=o,r;var a=IteratorValue(s);try{r[o]=a}catch(e){try{IteratorClose(i)}finally{throw e}}o++}}function Type(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function IsUndefined(e){return void 0===e}function IsNull(e){return null===e}function IsSymbol(e){return"symbol"==typeof e}function IsObject(e){return"object"==typeof e?null!==e:"function"==typeof e}function ToPrimitive(e,t){switch(Type(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",i=GetMethod(e,n);if(void 0!==i){var o=i.call(e,r);if(IsObject(o))throw new TypeError;return o}return OrdinaryToPrimitive(e,"default"===r?"number":r)}function OrdinaryToPrimitive(e,t){if("string"===t){var r=e.toString;if(IsCallable(r))if(!IsObject(i=r.call(e)))return i;if(IsCallable(n=e.valueOf))if(!IsObject(i=n.call(e)))return i}else{var n;if(IsCallable(n=e.valueOf))if(!IsObject(i=n.call(e)))return i;var i,o=e.toString;if(IsCallable(o))if(!IsObject(i=o.call(e)))return i}throw new TypeError}function ToBoolean(e){return!!e}function ToString(e){return""+e}function ToPropertyKey(e){var t=ToPrimitive(e,3);return IsSymbol(t)?t:ToString(t)}function IsArray(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function IsCallable(e){return"function"==typeof e}function IsConstructor(e){return"function"==typeof e}function IsPropertyKey(e){switch(Type(e)){case 3:case 4:return!0;default:return!1}}function GetMethod(e,t){var r=e[t];if(null!=r){if(!IsCallable(r))throw new TypeError;return r}}function GetIterator(e){var t=GetMethod(e,i);if(!IsCallable(t))throw new TypeError;var r=t.call(e);if(!IsObject(r))throw new TypeError;return r}function IteratorValue(e){return e.value}function IteratorStep(e){var t=e.next();return!t.done&&t}function IteratorClose(e){var t=e.return;t&&t.call(e)}function OrdinaryGetPrototypeOf(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function CreateMapPolyfill(){var e={},t=[],r=function(){function MapIterator(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return MapIterator.prototype["@@iterator"]=function(){return this},MapIterator.prototype[i]=function(){return this},MapIterator.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},MapIterator.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},MapIterator.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},MapIterator}();return function(){function Map(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(Map.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Map.prototype.has=function(e){return this._find(e,!1)>=0},Map.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},Map.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},Map.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,t===this._cacheKey&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},Map.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},Map.prototype.keys=function(){return new r(this._keys,this._values,getKey)},Map.prototype.values=function(){return new r(this._keys,this._values,getValue)},Map.prototype.entries=function(){return new r(this._keys,this._values,getEntry)},Map.prototype["@@iterator"]=function(){return this.entries()},Map.prototype[i]=function(){return this.entries()},Map.prototype._find=function(e,t){return this._cacheKey!==e&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=e)),this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},Map}();function getKey(e,t){return e}function getValue(e,t){return t}function getEntry(e,t){return[e,t]}}function CreateSetPolyfill(){return function(){function Set(){this._map=new p}return Object.defineProperty(Set.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),Set.prototype.has=function(e){return this._map.has(e)},Set.prototype.add=function(e){return this._map.set(e,e),this},Set.prototype.delete=function(e){return this._map.delete(e)},Set.prototype.clear=function(){this._map.clear()},Set.prototype.keys=function(){return this._map.keys()},Set.prototype.values=function(){return this._map.values()},Set.prototype.entries=function(){return this._map.entries()},Set.prototype["@@iterator"]=function(){return this.keys()},Set.prototype[i]=function(){return this.keys()},Set}()}function CreateWeakMapPolyfill(){var e=16,r=c.create(),n=CreateUniqueKey();return function(){function WeakMap(){this._key=CreateUniqueKey()}return WeakMap.prototype.has=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t&&c.has(t,this._key)},WeakMap.prototype.get=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t?c.get(t,this._key):void 0},WeakMap.prototype.set=function(e,t){return GetOrCreateWeakMapTable(e,!0)[this._key]=t,this},WeakMap.prototype.delete=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t&&delete t[this._key]},WeakMap.prototype.clear=function(){this._key=CreateUniqueKey()},WeakMap}();function CreateUniqueKey(){var e;do{e="@@WeakMap@@"+CreateUUID()}while(c.has(r,e));return r[e]=!0,e}function GetOrCreateWeakMapTable(e,r){if(!t.call(e,n)){if(!r)return;Object.defineProperty(e,n,{value:c.create()})}return e[n]}function FillRandomBytes(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function GenRandomBytes(e){return"function"==typeof Uint8Array?"undefined"!=typeof crypto?crypto.getRandomValues(new Uint8Array(e)):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(new Uint8Array(e)):FillRandomBytes(new Uint8Array(e),e):FillRandomBytes(new Array(e),e)}function CreateUUID(){var t=GenRandomBytes(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function MakeDictionary(e){return e.__=void 0,delete e.__,e}e("decorate",decorate),e("metadata",metadata),e("defineMetadata",defineMetadata),e("hasMetadata",hasMetadata),e("hasOwnMetadata",hasOwnMetadata),e("getMetadata",getMetadata),e("getOwnMetadata",getOwnMetadata),e("getMetadataKeys",getMetadataKeys),e("getOwnMetadataKeys",getOwnMetadataKeys),e("deleteMetadata",deleteMetadata)}(n)}()}(e||(e={}))},4714:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0;var n=r(6898);Object.defineProperty(t,"nameof",{enumerable:!0,get:function(){return n.nameof}})},6898:(e,t)=>{"use strict";function cleanseAssertionOperators(e){return e.replace(/[?!]/g,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0,t.nameof=function nameof(e,t){var r=e.toString();if(r.startsWith("class ")&&!r.startsWith("class =>"))return cleanseAssertionOperators(r.substring("class ".length,r.indexOf(" {")));if(r.includes("=>"))return cleanseAssertionOperators(r.substring(r.indexOf(".")+1));var n=r.match(/function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);if(n)return t&&t.lastProp?n[3]:n[1];if(r.startsWith("function "))return cleanseAssertionOperators(r.substring("function ".length,r.indexOf("(")));throw new Error("ts-simple-nameof: Invalid function.")}},5030:e=>{"use strict";e.exports=NMSHDContent},2890:e=>{"use strict";e.exports=NMSHDCrypto},9663:e=>{"use strict";e.exports=NMSHDTransport},194:e=>{"use strict";e.exports=TSServal}},t={};var r=function __webpack_require__(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,__webpack_require__),i.exports}(5590);NMSHDConsumption=r})();
|
|
2
|
+
var NMSHDConsumption;(()=>{var e={2500:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.buildInformation=void 0;const n=r(194),i=r(5030),o=r(2890),s=r(9663);t.buildInformation={version:"2.0.0-alpha.4",build:"22",date:"2022-04-28T10:14:47+00:00",commit:"f393644bb4ed077b45543c3a281c5c53052704f2",dependencies:{},libraries:{transport:s.buildInformation,crypto:o.buildInformation,serval:n.buildInformation,content:i.buildInformation}}},5136:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionBaseController=void 0;const n=r(9663);t.ConsumptionBaseController=class ConsumptionBaseController{constructor(e,t){this._parent=t,this._log=n.TransportLoggerFactory.getLogger(e)}get log(){return this._log}get parent(){return this._parent}init(){return Promise.resolve(this)}async parseArray(e,t){const r=e.map((e=>t.from(e)));return await Promise.all(r)}}},9793:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionController=void 0;const n=r(9662),i=r(5664);t.ConsumptionController=class ConsumptionController{constructor(e,t){this.transport=e,this.accountController=t}get attributes(){return this._attributes}get drafts(){return this._drafts}get outgoingRequests(){return this._outgoingRequests}get incomingRequests(){return this._incomingRequests}get settings(){return this._settings}get sharedItems(){return this._sharedItems}get relationshipInfo(){return this._relationshipInfo}async init(e=[]){this._attributes=await new n.ConsumptionAttributesController(this).init(),this._drafts=await new n.DraftsController(this).init();const t=new n.RequestItemProcessorRegistry(e);return this._outgoingRequests=await new n.OutgoingRequestsController(this,t).init(),this._incomingRequests=await new i.IncomingRequestsController(this,t).init(),this._settings=await new n.SettingsController(this).init(),this._sharedItems=await new n.SharedItemsController(this).init(),this._relationshipInfo=await new n.RelationshipInfoController(this).init(),this}}},2047:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionControllerName=void 0,function(e){e.ConsumptionAttributesController="ConsumptionAttributesController",e.DraftsController="DraftsController",e.RelationshipInfoController="RelationshipInfoController",e.SingleRelationshipController="SingleRelationshipController",e.OnboardingFlowController="OnboardingFlowController",e.OffboardingFlowController="OffboardingFlowController",e.RequestsController="Requestsontroller",e.SettingsController="SettingsController",e.SharedItemsController="SharedItemsController"}(t.ConsumptionControllerName||(t.ConsumptionControllerName={}))},3926:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionErrors=void 0;const n=r(9663);class ConsumptionErrors{}t.ConsumptionErrors=ConsumptionErrors,ConsumptionErrors.attributes=new class Attributes{attributeExists(e){return new n.CoreError("error.consumption.attributes.attributeExists",`Attribute with name ${e} already exists. Please use succeed instead.`)}},ConsumptionErrors.requests=new class Requests{requestsExists(e){return new n.CoreError("error.consumption.requests.requestExists",`Request with id ${e} already exists and can't be created.`)}},ConsumptionErrors.relationshipInfo=new class RelationshipInfo{relationshipInfoExists(e){return new n.CoreError("error.consumption.relationshipInfos.relationshipInfoExists",`RelationshipInfo for Relationship ${e} already exists.`)}},ConsumptionErrors.onboarding=new class Onboarding{attributeNotSet(e){return new n.CoreError("error.consumption.onboarding.attributeNotSet",`No attribute with name ${e} set but was required to be shared.`)}wrongTemplate(){return new n.CoreError("error.consumption.onboarding.wrongTemplate","The given template is in the wrong format.")}}},6265:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionIds=void 0;const n=r(9663);class ConsumptionIds{}t.ConsumptionIds=ConsumptionIds,ConsumptionIds.attribute=new n.CoreIdHelper("CNSATT"),ConsumptionIds.draft=new n.CoreIdHelper("CNSDRF"),ConsumptionIds.relationshipInfo=new n.CoreIdHelper("CNSRIN"),ConsumptionIds.sharedItem=new n.CoreIdHelper("CNSSIT"),ConsumptionIds.response=new n.CoreIdHelper("CNSRES"),ConsumptionIds.request=new n.CoreIdHelper("CNSREQ"),ConsumptionIds.setting=new n.CoreIdHelper("CNSSET")},7997:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(5136),t),i(r(2047),t),i(r(3926),t),i(r(6265),t)},5590:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(2500),t),i(r(9793),t),i(r(6265),t),i(r(9662),t)},8896:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttributesController=void 0;const n=r(9663),i=r(4714),o=r(7997),s=r(5192);class ConsumptionAttributesController extends o.ConsumptionBaseController{constructor(e){super(o.ConsumptionControllerName.ConsumptionAttributesController,e)}async init(){return await super.init(),this.attributes=await this.parent.accountController.getSynchronizedCollection("Attributes"),this}checkValid(e){const t=n.CoreDate.utc();return!e.content.validFrom&&!e.content.validTo||(!(!e.content.validFrom||e.content.validTo||!e.content.validFrom.isSameOrBefore(t))||(!(e.content.validFrom||!e.content.validTo||!e.content.validTo.isAfter(t))||!!(e.content.validFrom&&e.content.validTo&&e.content.validFrom.isSameOrBefore(t)&&e.content.validTo.isAfter(t))))}findCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt)));let r;for(const e of t)this.checkValid(e)&&(r=e);return r}filterCurrent(e){const t=e.sort(((e,t)=>e.createdAt.compare(t.createdAt))),r=[];for(const e of t)this.checkValid(e)&&r.push(e);return r}async getAttribute(e){const t=await this.attributes.find({[(0,i.nameof)((e=>e.id))]:e.toString()}),r=await this.parseArray(t,s.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeByName(e){const t=await this.attributes.find({[`${(0,i.nameof)((e=>e.content))}.${(0,i.nameof)((e=>e.name))}`]:e}),r=await this.parseArray(t,s.ConsumptionAttribute);return this.findCurrent(r)}async getAttributeHistoryByName(e){const t=await this.attributes.find({[`${(0,i.nameof)((e=>e.content))}.${(0,i.nameof)((e=>e.name))}`]:e});return(await this.parseArray(t,s.ConsumptionAttribute)).sort(((e,t)=>e.createdAt.compare(t.createdAt)))}async getAttributes(e){const t=await this.attributes.find(e);return await this.parseArray(t,s.ConsumptionAttribute)}async getValidAttributes(e){const t=await this.attributes.find(e),r=await this.parseArray(t,s.ConsumptionAttribute);return this.filterCurrent(r)}async getAttributesByName(e){return(await this.getValidAttributes(e)).reduce(((e,t)=>(e[t.content.name]=t,e)),{})}async createAttribute(e){if(await this.getAttributeByName(e.content.name))throw o.ConsumptionErrors.attributes.attributeExists(e.content.name);return await this.attributes.create(e),e}async succeedAttribute(e,t){const r=await this.getAttributeByName(e.content.name);return r&&!t&&(t=n.CoreDate.utc()),r&&(e.content.validFrom=t,r.content.validTo=t,await this.updateAttribute(r)),await this.attributes.create(e),e}async updateAttribute(e){const t=await this.attributes.findOne({[(0,i.nameof)((e=>e.id))]:e.id.toString()});if(!t)throw n.TransportErrors.general.recordNotFound(s.ConsumptionAttribute,e.id.toString());return await this.attributes.update(t,e),e}async deleteAttribute(e){await this.attributes.delete(e)}}t.ConsumptionAttributesController=ConsumptionAttributesController},5192:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionAttribute=void 0;const o=r(194),s=r(5030),a=r(9663),c=r(4714),u=r(7997);let l=class ConsumptionAttribute extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.createdAt))],this.userdataProperties=[(0,c.nameof)((e=>e.content))],this.metadataProperties=[(0,c.nameof)((e=>e.metadata)),(0,c.nameof)((e=>e.metadataModifiedAt))]}static from(e){return this.fromAny(e)}static async fromAttribute(e){return this.from({content:s.Attribute.from(e),id:await u.ConsumptionIds.attribute.generate(),createdAt:a.CoreDate.utc()})}};n([(0,o.validate)(),(0,o.serialize)({type:s.Attribute}),i("design:type",s.Attribute)],l.prototype,"content",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",a.CoreDate)],l.prototype,"createdAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)({any:!0}),i("design:type",Object)],l.prototype,"metadata",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",a.CoreDate)],l.prototype,"metadataModifiedAt",void 0),l=n([(0,o.type)("ConsumptionAttribute")],l),t.ConsumptionAttribute=l},1574:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DraftsController=void 0;const n=r(9663),i=r(7997),o=r(8535);class DraftsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.DraftsController,e)}async init(){return await super.init(),this.drafts=await this.parent.accountController.getSynchronizedCollection("Drafts"),this}async getDraft(e){const t=await this.drafts.read(e.toString());return t?o.Draft.from(t):void 0}async getDrafts(e){const t=await this.drafts.find(e);return await this.parseArray(t,o.Draft)}async createDraft(e,t=""){const r=o.Draft.from({id:await i.ConsumptionIds.draft.generate(),content:e,createdAt:new n.CoreDate,lastModifiedAt:new n.CoreDate,type:t});return await this.drafts.create(r),r}async updateDraft(e){const t=await this.drafts.read(e.id.toString());if(!t)throw new Error("Draft Not Found");await this.drafts.update(t,e)}async deleteDraft(e){await this.drafts.delete(e)}}t.DraftsController=DraftsController},8535:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Draft=void 0;const o=r(194),s=r(9663),a=r(4714);let c=class Draft extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,a.nameof)((e=>e.type)),(0,a.nameof)((e=>e.createdAt)),(0,a.nameof)((e=>e.lastModifiedAt))],this.userdataProperties=[(0,a.nameof)((e=>e.content))],this.metadataProperties=[(0,a.nameof)((e=>e.metadata)),(0,a.nameof)((e=>e.metadataModifiedAt))]}static from(e){return this.fromAny(e)}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],c.prototype,"type",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"createdAt",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"lastModifiedAt",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",o.Serializable)],c.prototype,"content",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)({any:!0}),i("design:type",Object)],c.prototype,"metadata",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"metadataModifiedAt",void 0),c=n([(0,o.type)("Draft")],c),t.Draft=c},9662:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(8896),t),i(r(5192),t),i(r(1574),t),i(r(8535),t),i(r(7880),t),i(r(1447),t),i(r(4155),t),i(r(6058),t),i(r(8576),t),i(r(6520),t),i(r(9379),t),i(r(1687),t),i(r(6592),t),i(r(7323),t),i(r(5829),t),i(r(1749),t),i(r(7066),t),i(r(5664),t),i(r(3665),t),i(r(569),t),i(r(7994),t),i(r(9469),t),i(r(9116),t),i(r(6137),t),i(r(5809),t),i(r(9472),t),i(r(2662),t),i(r(3592),t),i(r(4981),t),i(r(1557),t),i(r(5180),t),i(r(325),t),i(r(2660),t),i(r(8672),t),i(r(4943),t),i(r(8826),t),i(r(4245),t),i(r(7750),t)},6058:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoController=void 0;const n=r(7997),i=r(1447),o=r(3657);class RelationshipInfoController extends n.ConsumptionBaseController{constructor(e){super(n.ConsumptionControllerName.RelationshipInfoController,e)}async init(){return await super.init(),this.relationshipInfo=await this.parent.accountController.getSynchronizedCollection("RelationshipInfo"),this}async getRelationshipInfo(e){const t=await this.relationshipInfo.read(e.toString());return t?i.RelationshipInfo.from(t):void 0}async getRelationshipInfoByRelationship(e){return await new o.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(e)}async getRelationshipInfos(e){const t=await this.relationshipInfo.find(e);return await this.parseArray(t,i.RelationshipInfo)}async createRelationshipInfo(e){if(await this.relationshipInfo.exists({relationshipId:e.relationshipId}))throw n.ConsumptionErrors.relationshipInfo.relationshipInfoExists(e.relationshipId.toString());return await this.relationshipInfo.create(e),e}async updateRelationshipInfo(e){const t=await this.relationshipInfo.read(e.id.toString());if(!t)throw new Error("RelationshipInfo Not Found");await this.relationshipInfo.update(t,e)}async deleteRelationshipInfo(e){await this.relationshipInfo.delete(e)}}t.RelationshipInfoController=RelationshipInfoController},3657:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfoUtil=void 0;const n=r(194),i=r(5030),o=r(9663),s=r(7997),a=r(4943),c=r(7880),u=r(1447);class RelationshipInfoUtil{constructor(e){this.parent=e,this._log=o.TransportLoggerFactory.getLogger(RelationshipInfoUtil)}get log(){return this._log}async createInitialRelationshipInfo(e){const t=await this.parent.accountController.relationships.getRelationship(e);if(!t)throw o.TransportErrors.general.recordNotFound(o.Relationship,e.toString()).logWith(this._log);return await this.parseTemplateBody(t),await this.parseCreationRequest(t),await this.createRelationshipInfo(t)}getTitle(e,t){let r=e.peer.address.toString().substring(3,9);const n=t.get("Thing.name")?.content.value,i=t.get("Person.givenName")?.content.value,o=t.get("Person.familyName")?.content.value,s=t.get("Person.gender")?.content.value,a=t.get("Organization.name")?.content.value,c=t.get("Organization.legalname")?.content.value;return n?r=n:i&&o?r=`${i} ${o}`:i?r=i:o&&s?r=`i18n://salutation.gender.${s} ${o}`:a?r=a:c&&(r=c),r}async createRelationshipInfo(e){const t=e.peer.address.address.substring(3,9),r=u.RelationshipInfo.from({attributes:[],id:await s.ConsumptionIds.relationshipInfo.generate(),isPinned:!1,relationshipId:e.id,title:t}),n=await this.parent.sharedItems.getSharedItems({sharedBy:e.peer.address.toString()}),o=[],a=new Map;for(const e of n)if(e.content instanceof i.Attribute){const t=c.RelationshipAttribute.from({name:e.content.name,sharedItem:e.id,content:e.content});o.push(t),a.set(t.name,t)}r.attributes=o;const l=this.getTitle(e,a);return r.title=l,r}async parseTemplateBody(e){const t=e.cache.template;if(!t.cache)throw o.TransportErrors.general.cacheEmpty(o.RelationshipTemplate,t.id.toString()).logWith(this._log);const r=t.cache.content,c=this.parent.accountController.identity.isMe(t.cache.createdBy),u=t.cache.createdAt,l=c?this.parent.accountController.identity.address:e.peer.address,p=c?e.peer.address:this.parent.accountController.identity.address,d=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),f=[];if(r instanceof i.RelationshipTemplateBody){const e=r.sharedAttributes;e&&d.length!==e.length&&e.forEach((e=>{d.find((function(t){return t.content.name===e.name}))||f.push(e)}))}else{let e=r;r instanceof n.JSONWrapper&&(e=e.value),e?.attributes&&Array.isArray(e.attributes)&&d.length!==e.attributes.length&&e.attributes.forEach((e=>{d.find((function(t){return t.content.name===e.name}))||f.push(i.Attribute.from({name:e.name,value:e.value}))}))}for(const e of f){const r=a.SharedItem.from({id:await s.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:u,sharedBy:l,sharedWith:p,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}async parseCreationRequest(e){const t=e.cache.creationChange,r=t.request,o=r.content,c=this.parent.accountController.identity.isMe(r.createdBy),u=r.createdAt,l=c?this.parent.accountController.identity.address:e.peer.address,p=c?e.peer.address:this.parent.accountController.identity.address,d=await this.parent.sharedItems.getSharedItems({reference:t.id.toString()}),f=[];if(o instanceof i.RelationshipCreationChangeRequestBody){const e=o.sharedAttributes;e&&e.length>0&&d.length!==e.length&&e.forEach((e=>{d.find((function(t){return t.content.name===e.name}))||f.push(e)}))}else{let e=o;if(o instanceof n.JSONWrapper&&(e=e.value),e?.attributes){const t=Object.keys(e.attributes);d.length!==t.length&&t.forEach((t=>{const r=e.attributes[t];d.find((function(e){return e.content.name===r.name}))||f.push(i.Attribute.from({name:r.name,value:r.value}))}))}}for(const e of f){const r=a.SharedItem.from({id:await s.ConsumptionIds.sharedItem.generate(),content:e,sharedAt:u,sharedBy:l,sharedWith:p,reference:t.id,expiresAt:e.validTo});await this.parent.sharedItems.createSharedItem(r)}}}t.RelationshipInfoUtil=RelationshipInfoUtil},7880:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipAttribute=void 0;const o=r(194),s=r(5030),a=r(9663);let c=class RelationshipAttribute extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],c.prototype,"name",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.Attribute)],c.prototype,"content",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",a.CoreId)],c.prototype,"sharedItem",void 0),c=n([(0,o.type)("RelationshipAttribute")],c),t.RelationshipAttribute=c},1447:function(e,t,r){"use strict";var n,i=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},o=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipInfo=void 0;const s=r(194),a=r(9663),c=r(4714),u=r(7997),l=r(7880),p=r(4155);let d=n=class RelationshipInfo extends a.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,c.nameof)((e=>e.relationshipId)),(0,c.nameof)((e=>e.title)),(0,c.nameof)((e=>e.description)),(0,c.nameof)((e=>e.theme))],this.userdataProperties=[(0,c.nameof)((e=>e.isPinned)),(0,c.nameof)((e=>e.userTitle)),(0,c.nameof)((e=>e.userDescription))]}static async fromRelationship(e){return void 0===e.metadata?n.from({id:await u.ConsumptionIds.relationshipInfo.generate(),relationshipId:e.id,attributes:[],isPinned:!1,title:e.peer.address.address.substring(3,9)}):n.from(e.metadata)}static from(e){return this.fromAny(e)}};i([(0,s.validate)(),(0,s.serialize)(),o("design:type",a.CoreId)],d.prototype,"relationshipId",void 0),i([(0,s.validate)(),(0,s.serialize)({type:l.RelationshipAttribute}),o("design:type",Array)],d.prototype,"attributes",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",Boolean)],d.prototype,"isPinned",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],d.prototype,"userTitle",void 0),i([(0,s.validate)(),(0,s.serialize)(),o("design:type",String)],d.prototype,"title",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],d.prototype,"userDescription",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",String)],d.prototype,"description",void 0),i([(0,s.validate)({nullable:!0}),(0,s.serialize)(),o("design:type",p.RelationshipTheme)],d.prototype,"theme",void 0),d=n=i([(0,s.type)("RelationshipInfo")],d),t.RelationshipInfo=d},4155:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RelationshipTheme=void 0;const o=r(194);let s=class RelationshipTheme extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],s.prototype,"image",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],s.prototype,"imageBar",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],s.prototype,"backgroundColor",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],s.prototype,"foregroundColor",void 0),s=n([(0,o.type)("RelationshipTheme")],s),t.RelationshipTheme=s},7066:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DecideRequestParametersValidator=void 0;const n=r(5172);t.DecideRequestParametersValidator=class DecideRequestParametersValidator{validate(e,t){return e.items.length!==t.content.items.length?n.Result.fail(new n.ApplicationError("invalidNumberOfItems","Number of items in Request and Response do not match")):n.Result.ok(void 0)}}},5664:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IncomingRequestsController=void 0;const n=r(5030),i=r(9663),o=r(7997),s=r(9116),a=r(6137),c=r(5809),u=r(2662),l=r(8576),p=r(6520),d=r(2908),f=r(1749),h=r(7066),y=r(3665),m=r(569);class IncomingRequestsController extends o.ConsumptionBaseController{constructor(e,t){super(o.ConsumptionControllerName.RequestsController,e),this.processorRegistry=t,this.decideRequestParamsValidator=new h.DecideRequestParametersValidator}async init(){return await super.init(),this.consumptionRequests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async received(e){const t=y.ReceivedIncomingRequestParameters.from(e),r=this.extractInfoFromSource(t.requestSourceObject),n=a.ConsumptionRequest.from({id:t.receivedRequest.id??await i.CoreId.generate(),createdAt:i.CoreDate.utc(),status:c.ConsumptionRequestStatus.Open,content:t.receivedRequest,isOwn:!1,peer:r.peer,source:r.source,statusLog:[]});return await this.consumptionRequests.create(n),n}extractInfoFromSource(e){return e instanceof i.Message?this.extractInfoFromMessage(e):this.extractInfoFromRelationshipTemplate(e)}extractInfoFromMessage(e){if(e.isOwn)throw new Error("Cannot create incoming Request from own Message");return{peer:e.cache.createdBy,source:{reference:e.id,type:"Message"}}}extractInfoFromRelationshipTemplate(e){if(e.isOwn)throw new Error("Cannot create incoming Request from own Relationship Template");return{peer:e.cache.createdBy,source:{reference:e.id,type:"RelationshipTemplate"}}}async checkPrerequisites(e){const t=l.CheckPrerequisitesOfIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);this.assertRequestStatus(r,c.ConsumptionRequestStatus.Open);for(const e of r.content.items)if(e instanceof n.RequestItem){const t=this.processorRegistry.getProcessorForItem(e);if(!await t.checkPrerequisitesOfIncomingRequestItem(e))return r}else for(const t of e.items){const e=this.processorRegistry.getProcessorForItem(t);if(!await e.checkPrerequisitesOfIncomingRequestItem(t))return r}return r.changeStatus(c.ConsumptionRequestStatus.DecisionRequired),await this.update(r),r}async requireManualDecision(e){const t=m.RequireManualDecisionOfIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);return this.assertRequestStatus(r,c.ConsumptionRequestStatus.DecisionRequired),r.changeStatus(c.ConsumptionRequestStatus.ManualDecisionRequired),await this.update(r),r}async canAccept(e){return await this.canDecide({...e,decision:d.RequestDecision.Accept})}async canReject(e){return await this.canDecide({...e,decision:d.RequestDecision.Reject})}async canDecide(e){d.InternalDecideRequestParameters.from(e);const t=await this.getOrThrow(e.requestId),r=this.decideRequestParamsValidator.validate(e,t);if(!r.isSuccess)throw new Error(r.error.message);this.assertRequestStatus(t,c.ConsumptionRequestStatus.DecisionRequired,c.ConsumptionRequestStatus.ManualDecisionRequired);const n=await this.canDecideItems(e.items,t.content.items);return s.ValidationResult.fromItems(n)}async canDecideGroup(e,t){const r=await this.canDecideItems(e.items,t.items);return s.ValidationResult.fromItems(r)}async canDecideItems(e,t){const r=[];for(let i=0;i<e.length;i++){const o=e[i],s=t[i];if(s instanceof n.RequestItemGroup){const e=await this.canDecideGroup(o,s);r.push(e)}else{const e=await this.canDecideItem(o,s);r.push(e)}}return r}async canDecideItem(e,t){const r=this.processorRegistry.getProcessorForItem(t);return e.decision===f.RequestItemDecision.Accept?await r.canAccept(t,e):await r.canReject(t,e)}async accept(e){if(!(await this.canAccept(e)).isSuccess())throw new Error("Cannot accept the Request with the given parameters. Call 'canAccept' to get more information.");return await this.decide({...e,decision:d.RequestDecision.Accept})}async reject(e){if(!(await this.canReject(e)).isSuccess())throw new Error("Cannot reject the Request with the given parameters. Call 'canReject' to get more information.");return await this.decide({...e,decision:d.RequestDecision.Reject})}async decide(e){const t=await this.getOrThrow(e.requestId);this.assertRequestStatus(t,c.ConsumptionRequestStatus.DecisionRequired,c.ConsumptionRequestStatus.ManualDecisionRequired);const r=await this.createConsumptionResponse(e,t);return t.response=r,t.changeStatus(c.ConsumptionRequestStatus.Decided),await this.update(t),t}async createConsumptionResponse(e,t){const r=t.content.items,o=await this.decideItems(e.items,r),s=n.Response.from({result:e.decision===d.RequestDecision.Accept?n.ResponseResult.Accepted:n.ResponseResult.Rejected,requestId:t.id,items:o});return u.ConsumptionResponse.from({content:s,createdAt:i.CoreDate.utc()})}async decideGroup(e,t){const r=await this.decideItems(e.items,t.items);return n.ResponseItemGroup.from({items:r,metadata:t.responseMetadata})}async decideItems(e,t){const r=[];for(let i=0;i<e.length;i++){const o=e[i],s=t[i];s instanceof n.RequestItemGroup?r.push(await this.decideGroup(o,s)):r.push(await this.decideItem(o,t[i]))}return r}async decideItem(e,t){const r=this.processorRegistry.getProcessorForItem(t);try{return e.decision===f.RequestItemDecision.Accept?await r.accept(t,e):await r.reject(t,e)}catch(e){let r="";throw e instanceof Error&&(r=` Details: ${e.message}`),new Error(`An error occurred while processing a '${t.constructor.name}'. You should contact the developer of this RequestItem.${r}}`)}}async complete(e){const t=p.CompleteIncomingRequestParameters.from(e),r=await this.getOrThrow(t.requestId);if(r.isOwn)throw new Error("Cannot decide own Request");let n;if(this.assertRequestStatus(r,c.ConsumptionRequestStatus.Decided),t.responseSourceObject instanceof i.Message)n="Message";else{if(!(t.responseSourceObject instanceof i.RelationshipChange))throw new Error("Unknown response source");n="RelationshipChange"}return r.response.source=u.ConsumptionResponseSource.from({type:n,reference:t.responseSourceObject.id}),r.changeStatus(c.ConsumptionRequestStatus.Completed),await this.update(r),r}async get(e){const t=await this.consumptionRequests.findOne({id:e.toString(),isOwn:!1});return t?a.ConsumptionRequest.from(t):void 0}async getOrThrow(e){const t=await this.get(i.CoreId.from(e));if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.toString());return t}async update(e){const t=await this.consumptionRequests.findOne({id:e.id.toString(),isOwn:!1});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.id.toString());await this.consumptionRequests.update(t,e)}assertRequestStatus(e,...t){if(!t.includes(e.status))throw new Error(`Consumption Request has to be in status '${t.join("/")}'.`)}}t.IncomingRequestsController=IncomingRequestsController},8576:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CheckPrerequisitesOfIncomingRequestParameters=void 0;const o=r(194),s=r(9663);let a=class CheckPrerequisitesOfIncomingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],a.prototype,"requestId",void 0),a=n([(0,o.type)("CheckPrerequisitesOfIncomingRequestParameters")],a),t.CheckPrerequisitesOfIncomingRequestParameters=a},6520:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CompleteIncomingRequestParameters=void 0;const o=r(194),s=r(9663);class CompleteIncomingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}}n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],CompleteIncomingRequestParameters.prototype,"requestId",void 0),n([(0,o.serialize)({unionTypes:[s.Message,s.RelationshipChange]}),(0,o.validate)(),i("design:type",Object)],CompleteIncomingRequestParameters.prototype,"responseSourceObject",void 0),t.CompleteIncomingRequestParameters=CompleteIncomingRequestParameters},9379:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1687:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},6592:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},7323:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},2908:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequestDecision=t.InternalDecideRequestParameters=void 0;const o=r(194),s=r(9663);let a=class InternalDecideRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],a.prototype,"requestId",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",Array)],a.prototype,"items",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],a.prototype,"decision",void 0),a=n([(0,o.type)("InternalDecideRequestParameters")],a),t.InternalDecideRequestParameters=a,function(e){e.Accept="Accept",e.Reject="Reject"}(t.RequestDecision||(t.RequestDecision={}))},5829:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},1749:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestItemDecision=void 0,function(e){e.Accept="Accept",e.Reject="Reject"}(t.RequestItemDecision||(t.RequestItemDecision={}))},3665:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ReceivedIncomingRequestParameters=void 0;const o=r(194),s=r(5030),a=r(9663);let c=class ReceivedIncomingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Request)],c.prototype,"receivedRequest",void 0),n([(0,o.serialize)({unionTypes:[a.Message,a.RelationshipTemplate]}),(0,o.validate)(),i("design:type",Object)],c.prototype,"requestSourceObject",void 0),c=n([(0,o.type)("ReceivedIncomingRequestParameters")],c),t.ReceivedIncomingRequestParameters=c},569:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.RequireManualDecisionOfIncomingRequestParameters=void 0;const o=r(194),s=r(9663);class RequireManualDecisionOfIncomingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}}n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],RequireManualDecisionOfIncomingRequestParameters.prototype,"requestId",void 0),t.RequireManualDecisionOfIncomingRequestParameters=RequireManualDecisionOfIncomingRequestParameters},7994:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.GenericRequestItemProcessor=void 0;const n=r(5030),i=r(9116);t.GenericRequestItemProcessor=class GenericRequestItemProcessor{checkPrerequisitesOfIncomingRequestItem(e){return!0}canAccept(e,t){return i.ValidationResult.success()}canReject(e,t){return i.ValidationResult.success()}accept(e,t){return n.AcceptResponseItem.from({result:n.ResponseItemResult.Accepted,metadata:e.responseMetadata})}reject(e,t){return n.RejectResponseItem.from({result:n.ResponseItemResult.Rejected,metadata:e.responseMetadata})}canApplyIncomingResponseItem(e,t){return i.ValidationResult.success()}canCreateOutgoingRequestItem(e){return i.ValidationResult.success()}applyIncomingResponseItem(e,t){}}},9469:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RequestItemProcessorRegistry=void 0;t.RequestItemProcessorRegistry=class RequestItemProcessorRegistry{constructor(e=[]){this.registry={};for(const{itemConstructor:t,processorConstructor:r}of e)this.registerProcessor(r,t)}registerProcessor(e,t){if(this.registry.hasOwnProperty(t.name))throw new Error(`There is already a processor registered for '${t.name}''. Use 'replaceProcessorForType' if you want to replace it.`);this.registry[t.name]=e}replaceProcessor(e,t){this.registry[t.name]=e}getProcessorForItem(e){const t=this.registry[e.constructor.name];if(!t)throw new Error(`There was no processor registered for '${e.constructor.name}'.`);return new t}}},9116:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorValidationResult=t.SuccessfulValidatonResult=t.ValidationResult=void 0;class ValidationResult{constructor(e){this.items=e}isSuccess(){return this instanceof SuccessfulValidatonResult}isError(){return this instanceof ErrorValidationResult}static success(e=[]){return new SuccessfulValidatonResult(e)}static error(e,t,r=[]){return new ErrorValidationResult(e,t,r)}static fromItems(e){return e.some((e=>e.isError()))?ValidationResult.error("inheritedFromItem","Some child items have errors.",e):ValidationResult.success(e)}}t.ValidationResult=ValidationResult;class SuccessfulValidatonResult extends ValidationResult{constructor(e){super(e)}}t.SuccessfulValidatonResult=SuccessfulValidatonResult;class ErrorValidationResult extends ValidationResult{constructor(e,t,r){super(r),this.code=e,this.message=t}}t.ErrorValidationResult=ErrorValidationResult},6137:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequest=t.ConsumptionRequestSource=void 0;const o=r(194),s=r(5030),a=r(9663),c=r(5809),u=r(9472),l=r(2662);let p=class ConsumptionRequestSource extends a.CoreSerializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],p.prototype,"type",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreId)],p.prototype,"reference",void 0),p=n([(0,o.type)("ConsumptionRequestSource")],p),t.ConsumptionRequestSource=p;let d=class ConsumptionRequest extends a.CoreSynchronizable{changeStatus(e){const t=u.ConsumptionRequestStatusLogEntry.from({createdAt:a.CoreDate.utc(),oldStatus:this.status,newStatus:e});this.statusLog.push(t),this.status=e}sent(e){if(this.status!==c.ConsumptionRequestStatus.Draft)throw new Error("Consumption Request has to be in status 'Draft'.");this.source=e,this.changeStatus(c.ConsumptionRequestStatus.Open)}static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",Boolean)],d.prototype,"isOwn",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreAddress)],d.prototype,"peer",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreDate)],d.prototype,"createdAt",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Request)],d.prototype,"content",void 0),n([(0,o.serialize)(),(0,o.validate)({nullable:!0}),i("design:type",p)],d.prototype,"source",void 0),n([(0,o.serialize)(),(0,o.validate)({nullable:!0}),i("design:type",l.ConsumptionResponse)],d.prototype,"response",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],d.prototype,"status",void 0),n([(0,o.serialize)({type:u.ConsumptionRequestStatusLogEntry}),(0,o.validate)(),i("design:type",Array)],d.prototype,"statusLog",void 0),d=n([(0,o.type)("ConsumptionRequest")],d),t.ConsumptionRequest=d},5809:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequestStatus=void 0,function(e){e.Draft="Draft",e.Open="Open",e.DecisionRequired="DecisionRequired",e.ManualDecisionRequired="ManualDecisionRequired",e.Decided="Decided",e.Completed="Completed"}(t.ConsumptionRequestStatus||(t.ConsumptionRequestStatus={}))},9472:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionRequestStatusLogEntry=void 0;const o=r(194),s=r(9663);r(5809);let a=class ConsumptionRequestStatusLogEntry extends s.CoreSerializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreDate)],a.prototype,"createdAt",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],a.prototype,"oldStatus",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],a.prototype,"newStatus",void 0),n([(0,o.serialize)(),(0,o.validate)({nullable:!0}),i("design:type",Object)],a.prototype,"data",void 0),n([(0,o.serialize)(),(0,o.validate)({nullable:!0}),i("design:type",String)],a.prototype,"code",void 0),a=n([(0,o.type)("ConsumptionRequestStatusLogEntry")],a),t.ConsumptionRequestStatusLogEntry=a},2662:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.ConsumptionResponse=t.ConsumptionResponseSource=void 0;const o=r(194),s=r(5030),a=r(9663);let c=class ConsumptionResponseSource extends a.CoreSerializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",String)],c.prototype,"type",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreId)],c.prototype,"reference",void 0),c=n([(0,o.type)("ConsumptionResponseSource")],c),t.ConsumptionResponseSource=c;let u=class ConsumptionResponse extends a.CoreSerializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreDate)],u.prototype,"createdAt",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Response)],u.prototype,"content",void 0),n([(0,o.serialize)(),(0,o.validate)({nullable:!0}),i("design:type",c)],u.prototype,"source",void 0),u=n([(0,o.type)("ConsumptionResponse")],u),t.ConsumptionResponse=u},5180:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.OutgoingRequestsController=void 0;const n=r(5030),i=r(9663),o=r(7997),s=r(9116),a=r(6137),c=r(5809),u=r(2662),l=r(3592),p=r(4981),d=r(1557),f=r(325);class OutgoingRequestsController extends o.ConsumptionBaseController{constructor(e,t){super(o.ConsumptionControllerName.RequestsController,e),this.processorRegistry=t}async init(){return await super.init(),this.consumptionRequests=await this.parent.accountController.getSynchronizedCollection("Requests"),this}async canCreate(e){const t=d.CreateOutgoingRequestParameters.from(e),r=await this.canCreateItems(t.content.items);return s.ValidationResult.fromItems(r)}async canCreateItems(e){const t=[];for(const r of e)if(r instanceof n.RequestItem){const e=await this.canCreateItem(r);t.push(e)}else{const e=await this.canCreateItemGroup(r);t.push(e)}return t}async canCreateItem(e){const t=this.processorRegistry.getProcessorForItem(e);return await t.canCreateOutgoingRequestItem(e)}async canCreateItemGroup(e){const t=[];for(const r of e.items){const e=await this.canCreateItem(r);t.push(e)}return s.ValidationResult.fromItems(t)}async create(e){const t=d.CreateOutgoingRequestParameters.from(e),r=await o.ConsumptionIds.request.generate();t.content.id=r;return await this._create(r,t.content,t.peer)}async _create(e,t,r){const n=await this.canCreate({content:t,peer:r});if(n.isError())throw new Error(n.message);const o=a.ConsumptionRequest.from({id:e,content:t,createdAt:i.CoreDate.utc(),isOwn:!0,peer:r,status:c.ConsumptionRequestStatus.Draft,statusLog:[]});return await this.consumptionRequests.create(o),o}async createFromRelationshipCreationChange(e){const t=p.CreateOutgoingRequestFromRelationshipCreationChangeParameters.from(e),r=t.creationChange.request.createdBy,n=t.creationChange.request.content.requestId;await this._create(n,t.template.cache.content,r),await this._sent(n,t.template);return await this._complete(n,t.creationChange,t.creationChange.request.content)}async sent(e){const t=f.SentOutgoingRequestParameters.from(e);return await this._sent(t.requestId,t.requestSourceObject)}async _sent(e,t){const r=await this.getOrThrow(e);return this.assertRequestStatus(r,c.ConsumptionRequestStatus.Draft),r.changeStatus(c.ConsumptionRequestStatus.Open),r.source=a.ConsumptionRequestSource.from({reference:t.id,type:this.getSourceType(t)}),await this.update(r),r}getSourceType(e){if(e instanceof i.Message){if(!e.isOwn)throw new Error("Cannot create outgoing Request from a peer Message");return"Message"}if(e instanceof i.RelationshipTemplate){if(!e.isOwn)throw new Error("Cannot create outgoing Request from a peer Relationship Template");return"RelationshipTemplate"}throw new Error("The given sourceObject is not of a valid type. Valid types are 'Message' and 'RelationshipTemplate'.")}async complete(e){const t=l.CompleteOugoingRequestParameters.from(e);return await this._complete(t.requestId,t.responseSourceObject,t.receivedResponse)}async _complete(e,t,r){const n=await this.getOrThrow(e);this.assertRequestStatus(n,c.ConsumptionRequestStatus.Open);const o=await this.canComplete(n,r);if(o.isError())throw new Error(o.message);let s;if(await this.applyItems(n.content.items,r.items),t instanceof i.Message)s="Message";else{if(!(t instanceof i.RelationshipChange))throw new Error("Invalid responseSourceObject");s="RelationshipChange"}const a=u.ConsumptionResponse.from({content:r,createdAt:i.CoreDate.utc(),source:{reference:t.id,type:s}});return n.response=a,n.changeStatus(c.ConsumptionRequestStatus.Completed),await this.update(n),n}async canComplete(e,t){for(let r=0;r<t.items.length;r++){const i=e.content.items[r];if(i instanceof n.RequestItem){const e=t.items[r],n=this.processorRegistry.getProcessorForItem(i),o=await n.canApplyIncomingResponseItem(e,i);if(o.isError())return o}else if(i instanceof n.RequestItemGroup){const e=t.items[r];for(let t=0;t<i.items.length;t++){const r=i.items[t],n=e.items[t],o=this.processorRegistry.getProcessorForItem(r),s=await o.canApplyIncomingResponseItem(n,r);if(s.isError())return s}}}return s.ValidationResult.success()}async applyItems(e,t){for(let r=0;r<t.length;r++){const i=e[r];if(i instanceof n.RequestItem){const e=t[r];await this.applyItem(i,e)}else{const e=t[r];await this.applyItems(i.items,e.items)}}}async applyItem(e,t){const r=this.processorRegistry.getProcessorForItem(e);await r.applyIncomingResponseItem(t,e)}async get(e){const t=await this.consumptionRequests.findOne({id:e.toString(),isOwn:!0});return t?a.ConsumptionRequest.from(t):void 0}async getOrThrow(e){const t=await this.get(e);if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.toString());return t}async update(e){const t=await this.consumptionRequests.findOne({id:e.id.toString(),isOwn:!0});if(!t)throw i.TransportErrors.general.recordNotFound(a.ConsumptionRequest,e.id.toString());await this.consumptionRequests.update(t,e)}assertRequestStatus(e,...t){if(!t.includes(e.status))throw new Error(`Consumption Request has to be in status '${t.join("/")}'.`)}}t.OutgoingRequestsController=OutgoingRequestsController},3592:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CompleteOugoingRequestParameters=void 0;const o=r(194),s=r(5030),a=r(9663);let c=class CompleteOugoingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreId)],c.prototype,"requestId",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.Message)],c.prototype,"responseSourceObject",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Response)],c.prototype,"receivedResponse",void 0),c=n([(0,o.type)("CompleteOugoingRequestParameters")],c),t.CompleteOugoingRequestParameters=c},4981:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateOutgoingRequestFromRelationshipCreationChangeParameters=void 0;const o=r(194),s=r(9663);let a=class CreateOutgoingRequestFromRelationshipCreationChangeParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.RelationshipTemplate)],a.prototype,"template",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.RelationshipChange)],a.prototype,"creationChange",void 0),a=n([(0,o.type)("CreateOutgoingRequestFromRelationshipCreationChangeParameters")],a),t.CreateOutgoingRequestFromRelationshipCreationChangeParameters=a},1557:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.CreateOutgoingRequestParameters=void 0;const o=r(194),s=r(5030),a=r(9663);let c=class CreateOutgoingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Request)],c.prototype,"content",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",a.CoreAddress)],c.prototype,"peer",void 0),c=n([(0,o.type)("CreateOutgoingRequestParameters")],c),t.CreateOutgoingRequestParameters=c},325:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SentOutgoingRequestParameters=void 0;const o=r(194),s=r(9663);let a=class SentOutgoingRequestParameters extends o.Serializable{static from(e){return this.fromAny(e)}};n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.CoreId)],a.prototype,"requestId",void 0),n([(0,o.serialize)(),(0,o.validate)(),i("design:type",s.Message)],a.prototype,"requestSourceObject",void 0),a=n([(0,o.type)("SentOutgoingRequestParameters")],a),t.SentOutgoingRequestParameters=a},8672:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SettingsController=void 0;const n=r(9663),i=r(7997),o=r(2660);class SettingsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.SettingsController,e)}async init(){return await super.init(),this.settings=await this.parent.accountController.getSynchronizedCollection("Settings"),this}async getSetting(e){const t=await this.settings.read(e.toString());return t?o.Setting.from(t):void 0}async getSettings(e){const t=await this.settings.find(e);return await this.parseArray(t,o.Setting)}async createSetting(e){const t=o.Setting.from({id:await i.ConsumptionIds.setting.generate(),createdAt:n.CoreDate.utc(),key:e.key,scope:e.scope??o.SettingScope.Identity,value:e.value,reference:e.reference,succeedsAt:e.succeedsAt,succeedsItem:e.succeedsItem});return await this.settings.create(t),t}async updateSetting(e){const t=await this.settings.read(e.id.toString());if(!t)throw n.TransportErrors.general.recordNotFound(o.Setting,e.id.toString()).logWith(this._log);await this.settings.update(t,e)}async deleteSetting(e){await this.settings.delete(e)}}t.SettingsController=SettingsController},2660:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Setting=t.SettingScope=void 0;const o=r(194),s=r(9663),a=r(4714);!function(e){e.Identity="Identity",e.Device="Device",e.Relationship="Relationship"}(t.SettingScope||(t.SettingScope={}));let c=class Setting extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,a.nameof)((e=>e.key)),(0,a.nameof)((e=>e.scope)),(0,a.nameof)((e=>e.reference)),(0,a.nameof)((e=>e.createdAt)),(0,a.nameof)((e=>e.deletedAt)),(0,a.nameof)((e=>e.succeedsItem)),(0,a.nameof)((e=>e.succeedsAt))],this.userdataProperties=[(0,a.nameof)((e=>e.value))],this.metadataProperties=[(0,a.nameof)((e=>e.metadata)),(0,a.nameof)((e=>e.metadataModifiedAt))]}static from(e){return this.fromAny(e)}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],c.prototype,"key",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",String)],c.prototype,"scope",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreId)],c.prototype,"reference",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",o.Serializable)],c.prototype,"value",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"createdAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"deletedAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreId)],c.prototype,"succeedsItem",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"succeedsAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)({any:!0}),i("design:type",Object)],c.prototype,"metadata",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"metadataModifiedAt",void 0),c=n([(0,o.type)("Setting")],c),t.Setting=c},8826:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItemsController=void 0;const n=r(9663),i=r(7997),o=r(4943);class SharedItemsController extends i.ConsumptionBaseController{constructor(e){super(i.ConsumptionControllerName.SharedItemsController,e)}async init(){return await super.init(),this.sharedItems=await this.parent.accountController.getSynchronizedCollection("SharedItems"),this}async getSharedItem(e){const t=await this.sharedItems.read(e.toString());return t?o.SharedItem.from(t):void 0}async getSharedItems(e){const t=await this.sharedItems.find(e);return await this.parseArray(t,o.SharedItem)}async createSharedItem(e){return await this.sharedItems.create(e),e}async updateSharedItem(e){const t=await this.sharedItems.read(e.id.toString());if(!t)throw n.TransportErrors.general.recordNotFound(o.SharedItem,e.id.toString());return await this.sharedItems.update(t,e)}async deleteSharedItem(e){await this.sharedItems.delete(e)}}t.SharedItemsController=SharedItemsController},4943:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SharedItem=void 0;const o=r(194),s=r(9663),a=r(4714);let c=class SharedItem extends s.CoreSynchronizable{constructor(){super(...arguments),this.technicalProperties=["@type","@context",(0,a.nameof)((e=>e.tags)),(0,a.nameof)((e=>e.sharedBy)),(0,a.nameof)((e=>e.sharedWith)),(0,a.nameof)((e=>e.sharedAt)),(0,a.nameof)((e=>e.reference)),(0,a.nameof)((e=>e.content)),(0,a.nameof)((e=>e.succeedsItem)),(0,a.nameof)((e=>e.succeedsAt)),(0,a.nameof)((e=>e.expiresAt))],this.metadataProperties=[(0,a.nameof)((e=>e.metadata)),(0,a.nameof)((e=>e.metadataModifiedAt))]}static from(e){return this.fromAny(e)}};n([(0,o.validate)({nullable:!0}),(0,o.serialize)({type:String}),i("design:type",Array)],c.prototype,"tags",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreAddress)],c.prototype,"sharedBy",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreAddress)],c.prototype,"sharedWith",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"sharedAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreId)],c.prototype,"reference",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",o.Serializable)],c.prototype,"content",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreId)],c.prototype,"succeedsItem",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"succeedsAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"expiresAt",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)({any:!0}),i("design:type",Object)],c.prototype,"metadata",void 0),n([(0,o.validate)({nullable:!0}),(0,o.serialize)(),i("design:type",s.CoreDate)],c.prototype,"metadataModifiedAt",void 0),c=n([(0,o.type)("SharedItem")],c),t.SharedItem=c},4245:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.Signature=void 0;const o=r(194),s=r(2890),a=r(9663),c=r(7750);let u=class Signature extends a.CoreSerializable{static preFrom(e){return e.signature instanceof s.CryptoSignature&&(e.signature=s.CryptoSignature.fromBase64(e.signature)),e}static from(e){return this.fromAny(e)}async verify(e,t){if((await s.CryptoHash.hash(s.CoreBuffer.fromUtf8(e),this.content.hashAlgorithm)).toBase64()!==this.content.hash.hash)return!1;const r=this.content.serialize();return await a.CoreCrypto.verify(s.CoreBuffer.fromUtf8(r),this.signature,t)}toJSON(){return{content:this.content.toJSON(),signature:this.signature.toBase64()}}serialize(){return JSON.stringify(this.toJSON())}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",c.SignatureContent)],u.prototype,"content",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CryptoSignature)],u.prototype,"signature",void 0),u=n([(0,o.type)("Signature")],u),t.Signature=u},7750:function(e,t,r){"use strict";var n=this&&this.__decorate||function(e,t,r,n){var i,o=arguments.length,s=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(o<3?i(s):o>3?i(t,r,s):i(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},i=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};Object.defineProperty(t,"__esModule",{value:!0}),t.SignatureContent=void 0;const o=r(194),s=r(9663);let a=class SignatureContent extends s.CoreSerializable{static from(e){return this.fromAny(e)}};n([(0,o.validate)(),(0,o.serialize)(),i("design:type",Number)],a.prototype,"version",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",Number)],a.prototype,"signatureAlgorithm",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",Number)],a.prototype,"hashAlgorithm",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreDate)],a.prototype,"signedAt",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreAddress)],a.prototype,"signer",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreId)],a.prototype,"keyId",void 0),n([(0,o.validate)(),(0,o.serialize)(),i("design:type",s.CoreHash)],a.prototype,"hash",void 0),a=n([(0,o.type)("SignatureContent")],a),t.SignatureContent=a},1174:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0})},9159:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getEventNamespaceFromObject=t.EventBus=void 0;t.EventBus=class EventBus{},t.getEventNamespaceFromObject=function getEventNamespaceFromObject(e){return e.namespace}},5970:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SubscriptionTargetInfo=void 0;class SubscriptionTargetInfo{namespace;constructor(e){this.namespace=e}static from(e){return e instanceof Function?new ConstructorSubscriptionTargetInfo(e):new NamespaceSubscriptionTargetInfo(e)}}t.SubscriptionTargetInfo=SubscriptionTargetInfo;class ConstructorSubscriptionTargetInfo extends SubscriptionTargetInfo{constructorFunction;constructor(e){super(function getEventNamespaceFromClass(e){return e.namespace}(e)),this.constructorFunction=e}isCompatibleWith(e){return e instanceof this.constructorFunction}}class NamespaceSubscriptionTargetInfo extends SubscriptionTargetInfo{constructor(e){super(e)}isCompatibleWith(e){return!0}}},9729:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.EventEmitter2EventBus=void 0;const n=r(6387);r(8660);const i=r(9159),o=r(5970);t.EventEmitter2EventBus=class EventEmitter2EventBus{emitter;wrappers=new Map;nextId=0;constructor(){this.emitter=new n.EventEmitter2({wildcard:!0,maxListeners:50,verboseMemoryLeak:!0})}subscribe(e,t){return this.registerHandler(e,t)}subscribeOnce(e,t){return this.registerHandler(e,t,!0)}unsubscribe(e,t){return this.unregisterHandler(e,t)}registerHandler(e,t,r=!1){const n=o.SubscriptionTargetInfo.from(e),i=this.nextId++,handlerWrapper=o=>{n.isCompatibleWith(o)&&(t(o),r&&this.unsubscribe(e,i))};return this.wrappers.set(i,handlerWrapper),this.emitter.on(n.namespace,handlerWrapper),i}unregisterHandler(e,t){const r=o.SubscriptionTargetInfo.from(e),n=this.wrappers.get(t);return!!n&&(this.emitter.off(r.namespace,n),this.wrappers.delete(t),!0)}publish(e){const t=(0,i.getEventNamespaceFromObject)(e);if(!t)throw Error("The event needs a namespace. Use the EventNamespace-decorator in order to define a namespace for a event.");this.emitter.emit(t,e)}}},9256:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(9159),t),i(r(9729),t)},5917:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.DataEvent=void 0;const n=r(8267);class DataEvent extends n.Event{data;constructor(e,t){super(e),this.data=t}}t.DataEvent=DataEvent},8267:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Event=void 0;t.Event=class Event{namespace;constructor(e){this.namespace=e}}},2636:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(5917),t),i(r(8267),t)},5172:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(9256),t),i(r(2636),t),i(r(9855),t),i(r(1809),t),i(r(4569),t),i(r(1174),t),i(r(7226),t),i(r(7374),t)},9855:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.log=void 0,t.log=function log(e,t,r){const n=r.value;return r.value=function(...e){const r=e.map((e=>JSON.stringify(e))).join();try{const i=n.apply(this,e),o=JSON.stringify(i);return console.log(`Call: ${t}(${r}) => ${o}`),i}catch(e){throw console.log(e),e}},r}},1809:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.measureExcecutionTime=void 0,t.measureExcecutionTime=function measureExcecutionTime(e,t,r){const n=r.value;return r.value=async function(...e){const t=Date.now(),r=await n.apply(this,e),i=Date.now();return console.info(`Execution time: ${i-t}ms`),r},r}},4569:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.randomString=void 0,t.randomString=function randomString(e,t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"){let r="";const n=t.length;for(let i=0;i<e;i++)r+=t.charAt(Math.floor(Math.random()*n));return r}},7807:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ApplicationError=void 0;class ApplicationError extends Error{code;data;constructor(e,t,r){super(t),this.code=e,this.data=r}equals(e){return this.code===e.code}}t.ApplicationError=ApplicationError},9278:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Result=void 0;class Result{_isSuccess;_error;_value;constructor(e,t,r){if(e&&r)throw new Error("InvalidOperation: A result cannot be successful and contain an error");if(!e&&!r)throw new Error("InvalidOperation: A failing result needs to contain an error");if(void 0!==t&&!e)throw new Error("InvalidOperation: A value is only useful in case of a success.");this._value=t,this._isSuccess=e,this._error=r}get isSuccess(){return this._isSuccess}get isError(){return!this._isSuccess}get error(){return this._error}get value(){if(!this.isSuccess)throw new Error("Can't get the value of an error result. Use 'error' instead.");return this._value}static ok(e){return new Result(!0,e)}static fail(e){return new Result(!1,void 0,e)}}t.Result=Result},7226:function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||n(t,e,r)};Object.defineProperty(t,"__esModule",{value:!0}),i(r(7807),t),i(r(9278),t)},7374:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.sleep=void 0,t.sleep=function sleep(e){return new Promise((t=>{setTimeout(t,e)}))}},6387:(e,t,r)=>{var n;!function(i){var o=Object.hasOwnProperty,s=Array.isArray?Array.isArray:function _isArray(e){return"[object Array]"===Object.prototype.toString.call(e)},a="object"==typeof process&&"function"==typeof process.nextTick,c="function"==typeof Symbol,u="object"==typeof Reflect,l="function"==typeof setImmediate?setImmediate:setTimeout,p=c?u&&"function"==typeof Reflect.ownKeys?Reflect.ownKeys:function(e){var t=Object.getOwnPropertyNames(e);return t.push.apply(t,Object.getOwnPropertySymbols(e)),t}:Object.keys;function init(){this._events={},this._conf&&configure.call(this,this._conf)}function configure(e){e&&(this._conf=e,e.delimiter&&(this.delimiter=e.delimiter),e.maxListeners!==i&&(this._maxListeners=e.maxListeners),e.wildcard&&(this.wildcard=e.wildcard),e.newListener&&(this._newListener=e.newListener),e.removeListener&&(this._removeListener=e.removeListener),e.verboseMemoryLeak&&(this.verboseMemoryLeak=e.verboseMemoryLeak),e.ignoreErrors&&(this.ignoreErrors=e.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function logPossibleMemoryLeak(e,t){var r="(node) warning: possible EventEmitter memory leak detected. "+e+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(r+=" Event name: "+t+"."),"undefined"!=typeof process&&process.emitWarning){var n=new Error(r);n.name="MaxListenersExceededWarning",n.emitter=this,n.count=e,process.emitWarning(n)}else console.error(r),console.trace&&console.trace()}var toArray=function(e,t,r){var n=arguments.length;switch(n){case 0:return[];case 1:return[e];case 2:return[e,t];case 3:return[e,t,r];default:for(var i=new Array(n);n--;)i[n]=arguments[n];return i}};function toObject(e,t){for(var r={},n=e.length,o=t?value.length:0,s=0;s<n;s++)r[e[s]]=s<o?t[s]:i;return r}function TargetObserver(e,t,r){var n,i;if(this._emitter=e,this._target=t,this._listeners={},this._listenersCount=0,(r.on||r.off)&&(n=r.on,i=r.off),t.addEventListener?(n=t.addEventListener,i=t.removeEventListener):t.addListener?(n=t.addListener,i=t.removeListener):t.on&&(n=t.on,i=t.off),!n&&!i)throw Error("target does not implement any known event API");if("function"!=typeof n)throw TypeError("on method must be a function");if("function"!=typeof i)throw TypeError("off method must be a function");this._on=n,this._off=i;var o=e._observers;o?o.push(this):e._observers=[this]}function resolveOptions(e,t,r,n){var s=Object.assign({},t);if(!e)return s;if("object"!=typeof e)throw TypeError("options must be an object");var a,c,u,l=Object.keys(e),p=l.length;function reject(e){throw Error('Invalid "'+a+'" option value'+(e?". Reason: "+e:""))}for(var d=0;d<p;d++){if(a=l[d],!n&&!o.call(t,a))throw Error('Unknown "'+a+'" option');(c=e[a])!==i&&(u=r[a],s[a]=u?u(c,reject):c)}return s}function constructorReducer(e,t){return"function"==typeof e&&e.hasOwnProperty("prototype")||t("value must be a constructor"),e}function makeTypeReducer(e){var t="value must be type of "+e.join("|"),r=e.length,n=e[0],i=e[1];return 1===r?function(e,r){if(typeof e===n)return e;r(t)}:2===r?function(e,r){var o=typeof e;if(o===n||o===i)return e;r(t)}:function(n,i){for(var o=typeof n,s=r;s-- >0;)if(o===e[s])return n;i(t)}}Object.assign(TargetObserver.prototype,{subscribe:function(e,t,r){var n=this,i=this._target,o=this._emitter,s=this._listeners,handler=function(){var n=toArray.apply(null,arguments),s={data:n,name:t,original:e};if(r){var a=r.call(i,s);!1!==a&&o.emit.apply(o,[s.name].concat(n))}else o.emit.apply(o,[t].concat(n))};if(s[e])throw Error("Event '"+e+"' is already listening");this._listenersCount++,o._newListener&&o._removeListener&&!n._onNewListener?(this._onNewListener=function(r){r===t&&null===s[e]&&(s[e]=handler,n._on.call(i,e,handler))},o.on("newListener",this._onNewListener),this._onRemoveListener=function(r){r===t&&!o.hasListeners(r)&&s[e]&&(s[e]=null,n._off.call(i,e,handler))},s[e]=null,o.on("removeListener",this._onRemoveListener)):(s[e]=handler,n._on.call(i,e,handler))},unsubscribe:function(e){var t,r,n,i=this,o=this._listeners,s=this._emitter,a=this._off,c=this._target;if(e&&"string"!=typeof e)throw TypeError("event must be a string");function clearRefs(){i._onNewListener&&(s.off("newListener",i._onNewListener),s.off("removeListener",i._onRemoveListener),i._onNewListener=null,i._onRemoveListener=null);var e=findTargetIndex.call(s,i);s._observers.splice(e,1)}if(e){if(!(t=o[e]))return;a.call(c,e,t),delete o[e],--this._listenersCount||clearRefs()}else{for(n=(r=p(o)).length;n-- >0;)e=r[n],a.call(c,e,o[e]);this._listeners={},this._listenersCount=0,clearRefs()}}});var d=makeTypeReducer(["function"]),f=makeTypeReducer(["object","function"]);function makeCancelablePromise(e,t,r){var n,i,o,s=0,a=new e((function(c,u,l){function cleanup(){i&&(i=null),s&&(clearTimeout(s),s=0)}r=resolveOptions(r,{timeout:0,overload:!1},{timeout:function(e,t){return("number"!=typeof(e*=1)||e<0||!Number.isFinite(e))&&t("timeout must be a positive number"),e}}),n=!r.overload&&"function"==typeof e.prototype.cancel&&"function"==typeof l;var _resolve=function(e){cleanup(),c(e)},_reject=function(e){cleanup(),u(e)};n?t(_resolve,_reject,l):(i=[function(e){_reject(e||Error("canceled"))}],t(_resolve,_reject,(function(e){if(o)throw Error("Unable to subscribe on cancel event asynchronously");if("function"!=typeof e)throw TypeError("onCancel callback must be a function");i.push(e)})),o=!0),r.timeout>0&&(s=setTimeout((function(){var e=Error("timeout");e.code="ETIMEDOUT",s=0,a.cancel(e),u(e)}),r.timeout))}));return n||(a.cancel=function(e){if(i){for(var t=i.length,r=1;r<t;r++)i[r](e);i[0](e),i=null}}),a}function findTargetIndex(e){var t=this._observers;if(!t)return-1;for(var r=t.length,n=0;n<r;n++)if(t[n]._target===e)return n;return-1}function searchListenerTree(e,t,r,n,i){if(!r)return null;if(0===n){var o=typeof t;if("string"===o){var s,a,c=0,u=0,l=this.delimiter,d=l.length;if(-1!==(a=t.indexOf(l))){s=new Array(5);do{s[c++]=t.slice(u,a),u=a+d}while(-1!==(a=t.indexOf(l,u)));s[c++]=t.slice(u),t=s,i=c}else t=[t],i=1}else"object"===o?i=t.length:(t=[t],i=1)}var f,h,y,m,v,g,b,_=null,R=t[n],w=t[n+1];if(n===i)r._listeners&&("function"==typeof r._listeners?(e&&e.push(r._listeners),_=[r]):(e&&e.push.apply(e,r._listeners),_=[r]));else{if("*"===R){for(a=(g=p(r)).length;a-- >0;)"_listeners"!==(f=g[a])&&(b=searchListenerTree(e,t,r[f],n+1,i))&&(_?_.push.apply(_,b):_=b);return _}if("**"===R){for((v=n+1===i||n+2===i&&"*"===w)&&r._listeners&&(_=searchListenerTree(e,t,r,i,i)),a=(g=p(r)).length;a-- >0;)"_listeners"!==(f=g[a])&&("*"===f||"**"===f?(r[f]._listeners&&!v&&(b=searchListenerTree(e,t,r[f],i,i))&&(_?_.push.apply(_,b):_=b),b=searchListenerTree(e,t,r[f],n,i)):b=searchListenerTree(e,t,r[f],f===w?n+2:n,i),b&&(_?_.push.apply(_,b):_=b));return _}r[R]&&(_=searchListenerTree(e,t,r[R],n+1,i))}if((h=r["*"])&&searchListenerTree(e,t,h,n+1,i),y=r["**"])if(n<i)for(y._listeners&&searchListenerTree(e,t,y,i,i),a=(g=p(y)).length;a-- >0;)"_listeners"!==(f=g[a])&&(f===w?searchListenerTree(e,t,y[f],n+2,i):f===R?searchListenerTree(e,t,y[f],n+1,i):((m={})[f]=y[f],searchListenerTree(e,t,{"**":m},n+1,i)));else y._listeners?searchListenerTree(e,t,y,i,i):y["*"]&&y["*"]._listeners&&searchListenerTree(e,t,y["*"],i,i);return _}function growListenerTree(e,t,r){var n,i,o=0,s=0,a=this.delimiter,c=a.length;if("string"==typeof e)if(-1!==(n=e.indexOf(a))){i=new Array(5);do{i[o++]=e.slice(s,n),s=n+c}while(-1!==(n=e.indexOf(a,s)));i[o++]=e.slice(s)}else i=[e],o=1;else i=e,o=e.length;if(o>1)for(n=0;n+1<o;n++)if("**"===i[n]&&"**"===i[n+1])return;var u,l=this.listenerTree;for(n=0;n<o;n++)if(l=l[u=i[n]]||(l[u]={}),n===o-1)return l._listeners?("function"==typeof l._listeners&&(l._listeners=[l._listeners]),r?l._listeners.unshift(t):l._listeners.push(t),!l._listeners.warned&&this._maxListeners>0&&l._listeners.length>this._maxListeners&&(l._listeners.warned=!0,logPossibleMemoryLeak.call(this,l._listeners.length,u))):l._listeners=t,!0;return!0}function collectTreeEvents(e,t,r,n){for(var i,o,s,a,c=p(e),u=c.length,l=e._listeners;u-- >0;)i=e[o=c[u]],s="_listeners"===o?r:r?r.concat(o):[o],a=n||"symbol"==typeof o,l&&t.push(a?s:s.join(this.delimiter)),"object"==typeof i&&collectTreeEvents.call(this,i,t,s,a);return t}function recursivelyGarbageCollect(e){for(var t,r,n,i=p(e),o=i.length;o-- >0;)(t=e[r=i[o]])&&(n=!0,"_listeners"===r||recursivelyGarbageCollect(t)||delete e[r]);return n}function Listener(e,t,r){this.emitter=e,this.event=t,this.listener=r}function setupListener(e,t,r){if(!0===r)o=!0;else if(!1===r)n=!0;else{if(!r||"object"!=typeof r)throw TypeError("options should be an object or true");var n=r.async,o=r.promisify,s=r.nextTick,c=r.objectify}if(n||s||o){var u=t,p=t._origin||t;if(s&&!a)throw Error("process.nextTick is not supported");o===i&&(o="AsyncFunction"===t.constructor.name),t=function(){var e=arguments,t=this,r=this.event;return o?s?Promise.resolve():new Promise((function(e){l(e)})).then((function(){return t.event=r,u.apply(t,e)})):(s?process.nextTick:l)((function(){t.event=r,u.apply(t,e)}))},t._async=!0,t._origin=p}return[t,c?new Listener(this,e,t):this]}function EventEmitter(e){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,configure.call(this,e)}Listener.prototype.off=function(){return this.emitter.off(this.event,this.listener),this},EventEmitter.EventEmitter2=EventEmitter,EventEmitter.prototype.listenTo=function(e,t,r){if("object"!=typeof e)throw TypeError("target musts be an object");var n=this;function listen(t){if("object"!=typeof t)throw TypeError("events must be an object");var i,o=r.reducers,s=findTargetIndex.call(n,e);i=-1===s?new TargetObserver(n,e,r):n._observers[s];for(var a,c=p(t),u=c.length,l="function"==typeof o,d=0;d<u;d++)a=c[d],i.subscribe(a,t[a]||a,l?o:o&&o[a])}return r=resolveOptions(r,{on:i,off:i,reducers:i},{on:d,off:d,reducers:f}),s(t)?listen(toObject(t)):listen("string"==typeof t?toObject(t.split(/\s+/)):t),this},EventEmitter.prototype.stopListeningTo=function(e,t){var r=this._observers;if(!r)return!1;var n,i=r.length,o=!1;if(e&&"object"!=typeof e)throw TypeError("target should be an object");for(;i-- >0;)n=r[i],e&&n._target!==e||(n.unsubscribe(t),o=!0);return o},EventEmitter.prototype.delimiter=".",EventEmitter.prototype.setMaxListeners=function(e){e!==i&&(this._maxListeners=e,this._conf||(this._conf={}),this._conf.maxListeners=e)},EventEmitter.prototype.getMaxListeners=function(){return this._maxListeners},EventEmitter.prototype.event="",EventEmitter.prototype.once=function(e,t,r){return this._once(e,t,!1,r)},EventEmitter.prototype.prependOnceListener=function(e,t,r){return this._once(e,t,!0,r)},EventEmitter.prototype._once=function(e,t,r,n){return this._many(e,1,t,r,n)},EventEmitter.prototype.many=function(e,t,r,n){return this._many(e,t,r,!1,n)},EventEmitter.prototype.prependMany=function(e,t,r,n){return this._many(e,t,r,!0,n)},EventEmitter.prototype._many=function(e,t,r,n,i){var o=this;if("function"!=typeof r)throw new Error("many only accepts instances of Function");function listener(){return 0==--t&&o.off(e,listener),r.apply(this,arguments)}return listener._origin=r,this._on(e,listener,n,i)},EventEmitter.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||init.call(this);var e,t,r,n,i,o,s=arguments[0],a=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return!1;if(a&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(r=s.length,c)for(n=0;n<r;n++)if("symbol"==typeof s[n]){o=!0;break}o||(s=s.join(this.delimiter))}var u,l=arguments.length;if(this._all&&this._all.length)for(n=0,r=(u=this._all.slice()).length;n<r;n++)switch(this.event=s,l){case 1:u[n].call(this,s);break;case 2:u[n].call(this,s,arguments[1]);break;case 3:u[n].call(this,s,arguments[1],arguments[2]);break;default:u[n].apply(this,arguments)}if(a)u=[],searchListenerTree.call(this,u,e,this.listenerTree,0,r);else{if("function"==typeof(u=this._events[s])){switch(this.event=s,l){case 1:u.call(this);break;case 2:u.call(this,arguments[1]);break;case 3:u.call(this,arguments[1],arguments[2]);break;default:for(t=new Array(l-1),i=1;i<l;i++)t[i-1]=arguments[i];u.apply(this,t)}return!0}u&&(u=u.slice())}if(u&&u.length){if(l>3)for(t=new Array(l-1),i=1;i<l;i++)t[i-1]=arguments[i];for(n=0,r=u.length;n<r;n++)switch(this.event=s,l){case 1:u[n].call(this);break;case 2:u[n].call(this,arguments[1]);break;case 3:u[n].call(this,arguments[1],arguments[2]);break;default:u[n].apply(this,t)}return!0}if(!this.ignoreErrors&&!this._all&&"error"===s)throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},EventEmitter.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||init.call(this);var e,t,r,n,i,o,s=arguments[0],a=this.wildcard;if("newListener"===s&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(a&&(e=s,"newListener"!==s&&"removeListener"!==s&&"object"==typeof s)){if(n=s.length,c)for(i=0;i<n;i++)if("symbol"==typeof s[i]){t=!0;break}t||(s=s.join(this.delimiter))}var u,l=[],p=arguments.length;if(this._all)for(i=0,n=this._all.length;i<n;i++)switch(this.event=s,p){case 1:l.push(this._all[i].call(this,s));break;case 2:l.push(this._all[i].call(this,s,arguments[1]));break;case 3:l.push(this._all[i].call(this,s,arguments[1],arguments[2]));break;default:l.push(this._all[i].apply(this,arguments))}if(a?(u=[],searchListenerTree.call(this,u,e,this.listenerTree,0)):u=this._events[s],"function"==typeof u)switch(this.event=s,p){case 1:l.push(u.call(this));break;case 2:l.push(u.call(this,arguments[1]));break;case 3:l.push(u.call(this,arguments[1],arguments[2]));break;default:for(r=new Array(p-1),o=1;o<p;o++)r[o-1]=arguments[o];l.push(u.apply(this,r))}else if(u&&u.length){if(u=u.slice(),p>3)for(r=new Array(p-1),o=1;o<p;o++)r[o-1]=arguments[o];for(i=0,n=u.length;i<n;i++)switch(this.event=s,p){case 1:l.push(u[i].call(this));break;case 2:l.push(u[i].call(this,arguments[1]));break;case 3:l.push(u[i].call(this,arguments[1],arguments[2]));break;default:l.push(u[i].apply(this,r))}}else if(!this.ignoreErrors&&!this._all&&"error"===s)return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(l)},EventEmitter.prototype.on=function(e,t,r){return this._on(e,t,!1,r)},EventEmitter.prototype.prependListener=function(e,t,r){return this._on(e,t,!0,r)},EventEmitter.prototype.onAny=function(e){return this._onAny(e,!1)},EventEmitter.prototype.prependAny=function(e){return this._onAny(e,!0)},EventEmitter.prototype.addListener=EventEmitter.prototype.on,EventEmitter.prototype._onAny=function(e,t){if("function"!=typeof e)throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),t?this._all.unshift(e):this._all.push(e),this},EventEmitter.prototype._on=function(e,t,r,n){if("function"==typeof e)return this._onAny(e,t),this;if("function"!=typeof t)throw new Error("on only accepts instances of Function");this._events||init.call(this);var o,s=this;return n!==i&&(t=(o=setupListener.call(this,e,t,n))[0],s=o[1]),this._newListener&&this.emit("newListener",e,t),this.wildcard?(growListenerTree.call(this,e,t,r),s):(this._events[e]?("function"==typeof this._events[e]&&(this._events[e]=[this._events[e]]),r?this._events[e].unshift(t):this._events[e].push(t),!this._events[e].warned&&this._maxListeners>0&&this._events[e].length>this._maxListeners&&(this._events[e].warned=!0,logPossibleMemoryLeak.call(this,this._events[e].length,e))):this._events[e]=t,s)},EventEmitter.prototype.off=function(e,t){if("function"!=typeof t)throw new Error("removeListener only takes instances of Function");var r,n=[];if(this.wildcard){var i="string"==typeof e?e.split(this.delimiter):e.slice();if(!(n=searchListenerTree.call(this,null,i,this.listenerTree,0)))return this}else{if(!this._events[e])return this;r=this._events[e],n.push({_listeners:r})}for(var o=0;o<n.length;o++){var a=n[o];if(r=a._listeners,s(r)){for(var c=-1,u=0,l=r.length;u<l;u++)if(r[u]===t||r[u].listener&&r[u].listener===t||r[u]._origin&&r[u]._origin===t){c=u;break}if(c<0)continue;return this.wildcard?a._listeners.splice(c,1):this._events[e].splice(c,1),0===r.length&&(this.wildcard?delete a._listeners:delete this._events[e]),this._removeListener&&this.emit("removeListener",e,t),this}(r===t||r.listener&&r.listener===t||r._origin&&r._origin===t)&&(this.wildcard?delete a._listeners:delete this._events[e],this._removeListener&&this.emit("removeListener",e,t))}return this.listenerTree&&recursivelyGarbageCollect(this.listenerTree),this},EventEmitter.prototype.offAny=function(e){var t,r=0,n=0;if(e&&this._all&&this._all.length>0){for(r=0,n=(t=this._all).length;r<n;r++)if(e===t[r])return t.splice(r,1),this._removeListener&&this.emit("removeListenerAny",e),this}else{if(t=this._all,this._removeListener)for(r=0,n=t.length;r<n;r++)this.emit("removeListenerAny",t[r]);this._all=[]}return this},EventEmitter.prototype.removeListener=EventEmitter.prototype.off,EventEmitter.prototype.removeAllListeners=function(e){if(e===i)return!this._events||init.call(this),this;if(this.wildcard){var t,r=searchListenerTree.call(this,null,e,this.listenerTree,0);if(!r)return this;for(t=0;t<r.length;t++)r[t]._listeners=null;this.listenerTree&&recursivelyGarbageCollect(this.listenerTree)}else this._events&&(this._events[e]=null);return this},EventEmitter.prototype.listeners=function(e){var t,r,n,o,s,a=this._events;if(e===i){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!a)return[];for(o=(t=p(a)).length,n=[];o-- >0;)"function"==typeof(r=a[t[o]])?n.push(r):n.push.apply(n,r);return n}if(this.wildcard){if(!(s=this.listenerTree))return[];var c=[],u="string"==typeof e?e.split(this.delimiter):e.slice();return searchListenerTree.call(this,c,u,s,0),c}return a&&(r=a[e])?"function"==typeof r?[r]:r:[]},EventEmitter.prototype.eventNames=function(e){var t=this._events;return this.wildcard?collectTreeEvents.call(this,this.listenerTree,[],null,e):t?p(t):[]},EventEmitter.prototype.listenerCount=function(e){return this.listeners(e).length},EventEmitter.prototype.hasListeners=function(e){if(this.wildcard){var t=[],r="string"==typeof e?e.split(this.delimiter):e.slice();return searchListenerTree.call(this,t,r,this.listenerTree,0),t.length>0}var n=this._events,o=this._all;return!!(o&&o.length||n&&(e===i?p(n).length:n[e]))},EventEmitter.prototype.listenersAny=function(){return this._all?this._all:[]},EventEmitter.prototype.waitFor=function(e,t){var r=this,n=typeof t;return"number"===n?t={timeout:t}:"function"===n&&(t={filter:t}),makeCancelablePromise((t=resolveOptions(t,{timeout:0,filter:i,handleError:!1,Promise,overload:!1},{filter:d,Promise:constructorReducer})).Promise,(function(n,i,o){function listener(){var o=t.filter;if(!o||o.apply(r,arguments))if(r.off(e,listener),t.handleError){var s=arguments[0];s?i(s):n(toArray.apply(null,arguments).slice(1))}else n(toArray.apply(null,arguments))}o((function(){r.off(e,listener)})),r._on(e,listener,!1)}),{timeout:t.timeout,overload:t.overload})};var h=EventEmitter.prototype;Object.defineProperties(EventEmitter,{defaultMaxListeners:{get:function(){return h._maxListeners},set:function(e){if("number"!=typeof e||e<0||Number.isNaN(e))throw TypeError("n must be a non-negative number");h._maxListeners=e},enumerable:!0},once:{value:function once(e,t,r){return makeCancelablePromise((r=resolveOptions(r,{Promise,timeout:0,overload:!1},{Promise:constructorReducer})).Promise,(function(r,n,i){var o;if("function"==typeof e.addEventListener)return o=function(){r(toArray.apply(null,arguments))},i((function(){e.removeEventListener(t,o)})),void e.addEventListener(t,o,{once:!0});var s,eventListener=function(){s&&e.removeListener("error",s),r(toArray.apply(null,arguments))};"error"!==t&&(s=function(r){e.removeListener(t,eventListener),n(r)},e.once("error",s)),i((function(){s&&e.removeListener("error",s),e.removeListener(t,eventListener)})),e.once(t,eventListener)}),{timeout:r.timeout,overload:r.overload})},writable:!0,configurable:!0}}),Object.defineProperties(h,{_maxListeners:{value:10,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),(n=function(){return EventEmitter}.call(t,r,t,e))===i||(e.exports=n)}()},8660:()=>{var e;!function(e){!function(t){var r="object"==typeof global?global:"object"==typeof self?self:"object"==typeof this?this:Function("return this;")(),n=makeExporter(e);function makeExporter(e,t){return function(r,n){"function"!=typeof e[r]&&Object.defineProperty(e,r,{configurable:!0,writable:!0,value:n}),t&&t(r,n)}}void 0===r.Reflect?r.Reflect=e:n=makeExporter(r.Reflect,n),function(e){var t=Object.prototype.hasOwnProperty,r="function"==typeof Symbol,n=r&&void 0!==Symbol.toPrimitive?Symbol.toPrimitive:"@@toPrimitive",i=r&&void 0!==Symbol.iterator?Symbol.iterator:"@@iterator",o="function"==typeof Object.create,s={__proto__:[]}instanceof Array,a=!o&&!s,c={create:o?function(){return MakeDictionary(Object.create(null))}:s?function(){return MakeDictionary({__proto__:null})}:function(){return MakeDictionary({})},has:a?function(e,r){return t.call(e,r)}:function(e,t){return t in e},get:a?function(e,r){return t.call(e,r)?e[r]:void 0}:function(e,t){return e[t]}},u=Object.getPrototypeOf(Function),l="object"==typeof process&&process.env&&"true"===process.env.REFLECT_METADATA_USE_MAP_POLYFILL,p=l||"function"!=typeof Map||"function"!=typeof Map.prototype.entries?CreateMapPolyfill():Map,d=l||"function"!=typeof Set||"function"!=typeof Set.prototype.entries?CreateSetPolyfill():Set,f=new(l||"function"!=typeof WeakMap?CreateWeakMapPolyfill():WeakMap);function decorate(e,t,r,n){if(IsUndefined(r)){if(!IsArray(e))throw new TypeError;if(!IsConstructor(t))throw new TypeError;return DecorateConstructor(e,t)}if(!IsArray(e))throw new TypeError;if(!IsObject(t))throw new TypeError;if(!IsObject(n)&&!IsUndefined(n)&&!IsNull(n))throw new TypeError;return IsNull(n)&&(n=void 0),DecorateProperty(e,t,r=ToPropertyKey(r),n)}function metadata(e,t){function decorator(r,n){if(!IsObject(r))throw new TypeError;if(!IsUndefined(n)&&!IsPropertyKey(n))throw new TypeError;OrdinaryDefineOwnMetadata(e,t,r,n)}return decorator}function defineMetadata(e,t,r,n){if(!IsObject(r))throw new TypeError;return IsUndefined(n)||(n=ToPropertyKey(n)),OrdinaryDefineOwnMetadata(e,t,r,n)}function hasMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryHasMetadata(e,t,r)}function hasOwnMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryHasOwnMetadata(e,t,r)}function getMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryGetMetadata(e,t,r)}function getOwnMetadata(e,t,r){if(!IsObject(t))throw new TypeError;return IsUndefined(r)||(r=ToPropertyKey(r)),OrdinaryGetOwnMetadata(e,t,r)}function getMetadataKeys(e,t){if(!IsObject(e))throw new TypeError;return IsUndefined(t)||(t=ToPropertyKey(t)),OrdinaryMetadataKeys(e,t)}function getOwnMetadataKeys(e,t){if(!IsObject(e))throw new TypeError;return IsUndefined(t)||(t=ToPropertyKey(t)),OrdinaryOwnMetadataKeys(e,t)}function deleteMetadata(e,t,r){if(!IsObject(t))throw new TypeError;IsUndefined(r)||(r=ToPropertyKey(r));var n=GetOrCreateMetadataMap(t,r,!1);if(IsUndefined(n))return!1;if(!n.delete(e))return!1;if(n.size>0)return!0;var i=f.get(t);return i.delete(r),i.size>0||f.delete(t),!0}function DecorateConstructor(e,t){for(var r=e.length-1;r>=0;--r){var n=(0,e[r])(t);if(!IsUndefined(n)&&!IsNull(n)){if(!IsConstructor(n))throw new TypeError;t=n}}return t}function DecorateProperty(e,t,r,n){for(var i=e.length-1;i>=0;--i){var o=(0,e[i])(t,r,n);if(!IsUndefined(o)&&!IsNull(o)){if(!IsObject(o))throw new TypeError;n=o}}return n}function GetOrCreateMetadataMap(e,t,r){var n=f.get(e);if(IsUndefined(n)){if(!r)return;n=new p,f.set(e,n)}var i=n.get(t);if(IsUndefined(i)){if(!r)return;i=new p,n.set(t,i)}return i}function OrdinaryHasMetadata(e,t,r){if(OrdinaryHasOwnMetadata(e,t,r))return!0;var n=OrdinaryGetPrototypeOf(t);return!IsNull(n)&&OrdinaryHasMetadata(e,n,r)}function OrdinaryHasOwnMetadata(e,t,r){var n=GetOrCreateMetadataMap(t,r,!1);return!IsUndefined(n)&&ToBoolean(n.has(e))}function OrdinaryGetMetadata(e,t,r){if(OrdinaryHasOwnMetadata(e,t,r))return OrdinaryGetOwnMetadata(e,t,r);var n=OrdinaryGetPrototypeOf(t);return IsNull(n)?void 0:OrdinaryGetMetadata(e,n,r)}function OrdinaryGetOwnMetadata(e,t,r){var n=GetOrCreateMetadataMap(t,r,!1);if(!IsUndefined(n))return n.get(e)}function OrdinaryDefineOwnMetadata(e,t,r,n){GetOrCreateMetadataMap(r,n,!0).set(e,t)}function OrdinaryMetadataKeys(e,t){var r=OrdinaryOwnMetadataKeys(e,t),n=OrdinaryGetPrototypeOf(e);if(null===n)return r;var i=OrdinaryMetadataKeys(n,t);if(i.length<=0)return r;if(r.length<=0)return i;for(var o=new d,s=[],a=0,c=r;a<c.length;a++){var u=c[a];o.has(u)||(o.add(u),s.push(u))}for(var l=0,p=i;l<p.length;l++){u=p[l];o.has(u)||(o.add(u),s.push(u))}return s}function OrdinaryOwnMetadataKeys(e,t){var r=[],n=GetOrCreateMetadataMap(e,t,!1);if(IsUndefined(n))return r;for(var i=GetIterator(n.keys()),o=0;;){var s=IteratorStep(i);if(!s)return r.length=o,r;var a=IteratorValue(s);try{r[o]=a}catch(e){try{IteratorClose(i)}finally{throw e}}o++}}function Type(e){if(null===e)return 1;switch(typeof e){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return null===e?1:6;default:return 6}}function IsUndefined(e){return void 0===e}function IsNull(e){return null===e}function IsSymbol(e){return"symbol"==typeof e}function IsObject(e){return"object"==typeof e?null!==e:"function"==typeof e}function ToPrimitive(e,t){switch(Type(e)){case 0:case 1:case 2:case 3:case 4:case 5:return e}var r=3===t?"string":5===t?"number":"default",i=GetMethod(e,n);if(void 0!==i){var o=i.call(e,r);if(IsObject(o))throw new TypeError;return o}return OrdinaryToPrimitive(e,"default"===r?"number":r)}function OrdinaryToPrimitive(e,t){if("string"===t){var r=e.toString;if(IsCallable(r))if(!IsObject(i=r.call(e)))return i;if(IsCallable(n=e.valueOf))if(!IsObject(i=n.call(e)))return i}else{var n;if(IsCallable(n=e.valueOf))if(!IsObject(i=n.call(e)))return i;var i,o=e.toString;if(IsCallable(o))if(!IsObject(i=o.call(e)))return i}throw new TypeError}function ToBoolean(e){return!!e}function ToString(e){return""+e}function ToPropertyKey(e){var t=ToPrimitive(e,3);return IsSymbol(t)?t:ToString(t)}function IsArray(e){return Array.isArray?Array.isArray(e):e instanceof Object?e instanceof Array:"[object Array]"===Object.prototype.toString.call(e)}function IsCallable(e){return"function"==typeof e}function IsConstructor(e){return"function"==typeof e}function IsPropertyKey(e){switch(Type(e)){case 3:case 4:return!0;default:return!1}}function GetMethod(e,t){var r=e[t];if(null!=r){if(!IsCallable(r))throw new TypeError;return r}}function GetIterator(e){var t=GetMethod(e,i);if(!IsCallable(t))throw new TypeError;var r=t.call(e);if(!IsObject(r))throw new TypeError;return r}function IteratorValue(e){return e.value}function IteratorStep(e){var t=e.next();return!t.done&&t}function IteratorClose(e){var t=e.return;t&&t.call(e)}function OrdinaryGetPrototypeOf(e){var t=Object.getPrototypeOf(e);if("function"!=typeof e||e===u)return t;if(t!==u)return t;var r=e.prototype,n=r&&Object.getPrototypeOf(r);if(null==n||n===Object.prototype)return t;var i=n.constructor;return"function"!=typeof i||i===e?t:i}function CreateMapPolyfill(){var e={},t=[],r=function(){function MapIterator(e,t,r){this._index=0,this._keys=e,this._values=t,this._selector=r}return MapIterator.prototype["@@iterator"]=function(){return this},MapIterator.prototype[i]=function(){return this},MapIterator.prototype.next=function(){var e=this._index;if(e>=0&&e<this._keys.length){var r=this._selector(this._keys[e],this._values[e]);return e+1>=this._keys.length?(this._index=-1,this._keys=t,this._values=t):this._index++,{value:r,done:!1}}return{value:void 0,done:!0}},MapIterator.prototype.throw=function(e){throw this._index>=0&&(this._index=-1,this._keys=t,this._values=t),e},MapIterator.prototype.return=function(e){return this._index>=0&&(this._index=-1,this._keys=t,this._values=t),{value:e,done:!0}},MapIterator}();return function(){function Map(){this._keys=[],this._values=[],this._cacheKey=e,this._cacheIndex=-2}return Object.defineProperty(Map.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),Map.prototype.has=function(e){return this._find(e,!1)>=0},Map.prototype.get=function(e){var t=this._find(e,!1);return t>=0?this._values[t]:void 0},Map.prototype.set=function(e,t){var r=this._find(e,!0);return this._values[r]=t,this},Map.prototype.delete=function(t){var r=this._find(t,!1);if(r>=0){for(var n=this._keys.length,i=r+1;i<n;i++)this._keys[i-1]=this._keys[i],this._values[i-1]=this._values[i];return this._keys.length--,this._values.length--,t===this._cacheKey&&(this._cacheKey=e,this._cacheIndex=-2),!0}return!1},Map.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=e,this._cacheIndex=-2},Map.prototype.keys=function(){return new r(this._keys,this._values,getKey)},Map.prototype.values=function(){return new r(this._keys,this._values,getValue)},Map.prototype.entries=function(){return new r(this._keys,this._values,getEntry)},Map.prototype["@@iterator"]=function(){return this.entries()},Map.prototype[i]=function(){return this.entries()},Map.prototype._find=function(e,t){return this._cacheKey!==e&&(this._cacheIndex=this._keys.indexOf(this._cacheKey=e)),this._cacheIndex<0&&t&&(this._cacheIndex=this._keys.length,this._keys.push(e),this._values.push(void 0)),this._cacheIndex},Map}();function getKey(e,t){return e}function getValue(e,t){return t}function getEntry(e,t){return[e,t]}}function CreateSetPolyfill(){return function(){function Set(){this._map=new p}return Object.defineProperty(Set.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),Set.prototype.has=function(e){return this._map.has(e)},Set.prototype.add=function(e){return this._map.set(e,e),this},Set.prototype.delete=function(e){return this._map.delete(e)},Set.prototype.clear=function(){this._map.clear()},Set.prototype.keys=function(){return this._map.keys()},Set.prototype.values=function(){return this._map.values()},Set.prototype.entries=function(){return this._map.entries()},Set.prototype["@@iterator"]=function(){return this.keys()},Set.prototype[i]=function(){return this.keys()},Set}()}function CreateWeakMapPolyfill(){var e=16,r=c.create(),n=CreateUniqueKey();return function(){function WeakMap(){this._key=CreateUniqueKey()}return WeakMap.prototype.has=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t&&c.has(t,this._key)},WeakMap.prototype.get=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t?c.get(t,this._key):void 0},WeakMap.prototype.set=function(e,t){return GetOrCreateWeakMapTable(e,!0)[this._key]=t,this},WeakMap.prototype.delete=function(e){var t=GetOrCreateWeakMapTable(e,!1);return void 0!==t&&delete t[this._key]},WeakMap.prototype.clear=function(){this._key=CreateUniqueKey()},WeakMap}();function CreateUniqueKey(){var e;do{e="@@WeakMap@@"+CreateUUID()}while(c.has(r,e));return r[e]=!0,e}function GetOrCreateWeakMapTable(e,r){if(!t.call(e,n)){if(!r)return;Object.defineProperty(e,n,{value:c.create()})}return e[n]}function FillRandomBytes(e,t){for(var r=0;r<t;++r)e[r]=255*Math.random()|0;return e}function GenRandomBytes(e){return"function"==typeof Uint8Array?"undefined"!=typeof crypto?crypto.getRandomValues(new Uint8Array(e)):"undefined"!=typeof msCrypto?msCrypto.getRandomValues(new Uint8Array(e)):FillRandomBytes(new Uint8Array(e),e):FillRandomBytes(new Array(e),e)}function CreateUUID(){var t=GenRandomBytes(e);t[6]=79&t[6]|64,t[8]=191&t[8]|128;for(var r="",n=0;n<e;++n){var i=t[n];4!==n&&6!==n&&8!==n||(r+="-"),i<16&&(r+="0"),r+=i.toString(16).toLowerCase()}return r}}function MakeDictionary(e){return e.__=void 0,delete e.__,e}e("decorate",decorate),e("metadata",metadata),e("defineMetadata",defineMetadata),e("hasMetadata",hasMetadata),e("hasOwnMetadata",hasOwnMetadata),e("getMetadata",getMetadata),e("getOwnMetadata",getOwnMetadata),e("getMetadataKeys",getMetadataKeys),e("getOwnMetadataKeys",getOwnMetadataKeys),e("deleteMetadata",deleteMetadata)}(n)}()}(e||(e={}))},4714:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0;var n=r(6898);Object.defineProperty(t,"nameof",{enumerable:!0,get:function(){return n.nameof}})},6898:(e,t)=>{"use strict";function cleanseAssertionOperators(e){return e.replace(/[?!]/g,"")}Object.defineProperty(t,"__esModule",{value:!0}),t.nameof=void 0,t.nameof=function nameof(e,t){var r=e.toString();if(r.startsWith("class ")&&!r.startsWith("class =>"))return cleanseAssertionOperators(r.substring("class ".length,r.indexOf(" {")));if(r.includes("=>"))return cleanseAssertionOperators(r.substring(r.indexOf(".")+1));var n=r.match(/function\s*\(\w+\)\s*\{[\r\n\s]*return\s+\w+\.((\w+\.)*(\w+))/i);if(n)return t&&t.lastProp?n[3]:n[1];if(r.startsWith("function "))return cleanseAssertionOperators(r.substring("function ".length,r.indexOf("(")));throw new Error("ts-simple-nameof: Invalid function.")}},5030:e=>{"use strict";e.exports=NMSHDContent},2890:e=>{"use strict";e.exports=NMSHDCrypto},9663:e=>{"use strict";e.exports=NMSHDTransport},194:e=>{"use strict";e.exports=TSServal}},t={};var r=function __webpack_require__(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,__webpack_require__),i.exports}(5590);NMSHDConsumption=r})();
|
|
3
3
|
//# sourceMappingURL=nmshd.consumption.min.js.map
|