(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-55611646"],{"427f":function(e,t,a){"use strict";a.d(t,"a",(function(){return l}));a("99af"),a("7db0"),a("d3b7");var n=a("5530"),r=(a("96cf"),a("1da1")),u=a("a34a"),c=a.n(u),i=a("ff07"),o=a("4ad0"),s=a("bc5a");function l(){var e=function(e){var t=e.fileIds;return i["a"].FileProvider.find({fileIds:t})},t=function(e){var t=e.data;return i["a"].FileProvider.update({data:t})},a=function(e){var t=e.fileId;return i["a"].FileProvider.delete({data:t})},u=function(e,t){return i["a"].FileProvider.getUploadUrl({fileIds:[{subjectId:e,type:t}]})},l=function(e){var t=e.type,a=e.file,i=e.subjectId,l=void 0===i?"1":i,d=e.onUploadProgressCB;return new Promise(function(){var e=Object(r["a"])(c.a.mark((function e(i,f){var p;return c.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,u(l,t);case 2:p=e.sent,o["a"].addToQueue([Object(n["a"])(Object(n["a"])({file:a,fileType:Object(s["a"])(a),urlPart:p[0].fileUpload.urlPart,id:"".concat(p[0].fileId.subjectId,"_").concat(p[0].fileUpload.uuid),onSuccess:function(){var e=Object(r["a"])(c.a.mark((function e(){return c.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:i(p[0]);case 1:case"end":return e.stop()}}),e)})));function t(){return e.apply(this,arguments)}return t}()},d?{onUploadProgress:d}:{}),{},{onError:function(e){Object(o["b"])(),f(e)}})]);case 4:case"end":return e.stop()}}),e)})));return function(t,a){return e.apply(this,arguments)}}())},d=function(){var e=Object(r["a"])(c.a.mark((function e(a){var r,u,i,o,s;return c.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return r=a.fileId,u=a.file,i=a.onUploadProgressCB,e.next=3,l(Object(n["a"])(Object(n["a"])({},r),{},{onUploadProgressCB:i,file:u}));case 3:return o=e.sent,s={fileId:Object(n["a"])(Object(n["a"])({},o.fileId),{},{fileNumber:r.fileNumber}),uuid:o.fileUpload.uuid},e.next=7,t({data:s});case 7:return e.abrupt("return",e.sent);case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();return{findFiles:e,updateFile:t,deleteFile:a,uploadFilesToS3:l,uploadThenUpdate:d}}},"4a2f":function(e,t,a){},ccda:function(e,t,a){"use strict";a.d(t,"a",(function(){return W}));var n=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("div",[e._t("default",null,{sending:e.sending,sendMessage:e.onSendMessage,priceAmount:e.hasAttachments?e.priceMediaAmount:e.priceAmount,priceAmountText:e.priceAmountText,attachedFiles:e.attachedFiles,removeAttachment:e.removeAttachment,uploadingAttachment:e.uploadingAttachment,addExistingAttachment:e.addAttachmentFromVault,uploadAttachment:e.uploadAttachment}),a("portal",{attrs:{to:"modal"}},[a("vault-modal",{attrs:{show:e.showVault,maxFiles:e.maxFiles},on:{addAttachment:e.addAttachment,addAttachmentFromVault:e.addAttachmentFromVault,close:function(t){e.showVault=!1}}}),a("paid-action-confirm",{attrs:{"allow-do-not-show-again":e.allowDoNotShowAgain,price:e.priceAmount,value:e.showPaymentConfirm,"price-changed-text":e.$t("Message price changed")},on:{input:e.onPaymentConfirm},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.price;return[e._v(" "+e._s(e.$t("Send message for {0}",[a]))+" ")]}}])}),a("paid-action-confirm",{attrs:{"allow-do-not-show-again":e.allowDoNotShowAgain,price:e.priceMediaAmount,value:e.showPaymentMediaConfirm,"price-changed-text":e.$t("Message price changed")},on:{input:e.onPaymentConfirm},scopedSlots:e._u([{key:"default",fn:function(t){var a=t.price;return[e._v(" "+e._s(e.$t("Send message for {0}",[a]))+" ")]}}])}),a("paid-action-error",{attrs:{value:e.paymentError},on:{input:e.closeError}})],1)],2)},r=[],u=(a("99af"),a("a623"),a("4de4"),a("7db0"),a("c740"),a("4160"),a("a630"),a("d81d"),a("45fc"),a("a434"),a("d3b7"),a("3ca3"),a("2ca0"),a("159b"),a("ddb0"),a("2b3d"),a("5530")),c=a("3835"),i=a("b85c"),o=(a("96cf"),a("1da1")),s=a("a34a"),l=a.n(s),d=a("2b0e"),f=a("a6f4"),p=a("e3ec"),v=a("2007"),m=a("9b43"),h=a("a32c"),b=a("bc5a"),j=a("26b5"),g=a("ff07"),O=a("6624"),w=a("85b1"),A=a("4afc"),x=a("427f"),P=a("d70b"),y=a("a5de"),I=a("526c"),F=a("6073"),k=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("base-confirm",{staticClass:"vault-modal",attrs:{"class-wrapper":"vault-modal__wrapper",value:e.show,title:e.$t("Add attachment")},on:{input:function(t){return e.$emit("close")}}},[a("vault-controller",{attrs:{maxFiles:e.maxFiles,multiple:e.maxFiles>1},on:{addAttachment:e.addAttachment,addAttachmentFromVault:e.addAttachmentFromVault}})],1)},M=[],S=(a("a9e3"),a("64ae")),C=a("5608"),E=a("1d17"),_=Object(f["c"])({name:"VaultModal",components:{BaseConfirm:C["a"],VaultController:E["a"]},props:{show:{type:Boolean},maxFiles:{type:Number,default:Number.POSITIVE_INFINITY}},setup:function(e,t){var a=t.emit,n=function(e){a("addAttachment",e),a("close")},r=function(e){var t=e.map((function(e){return{src:Object(S["d"])(e,e.urlPart),uid:e.uuid,type:e.metadata.contentType,publicAccess:!1}}));a("addAttachmentFromVault",t),a("close")};return{addAttachment:n,addAttachmentFromVault:r}}}),U=_,V=(a("d3cd"),a("2877")),T=Object(V["a"])(U,k,M,!1,null,null,null),N=T.exports,B="0",$="preview_",R=function(){var e=Object(f["o"])(!1),t=Object(f["o"])(!0),a=Object(f["o"])([]),n=Object(x["a"])(),r=n.uploadFilesToS3,s=Object(A["a"])(),p=s.authUser,v=function(e,a){return{type:Object(b["a"])(e),src:URL.createObjectURL(e),uid:a,publicAccess:!t.value}},m=Object(f["a"])((function(){var e;return(null===(e=p.value)||void 0===e?void 0:e.role)===P["a"].userRegistrationRole})),h=Object(f["a"])((function(){return m.value?y["e"]:y["d"]})),j=Object(f["a"])((function(){return m.value?0:y["c"]})),g=Object(f["a"])((function(){return a.value.filter((function(e){return!e.publicAccess}))})),O=Object(f["a"])((function(){return a.value.filter((function(e){return e.publicAccess}))})),w=Object(f["a"])((function(){return t.value?g.value.length>=h.value:t.value?void 0:O.value.length>=j.value})),I=function(){var n=Object(o["a"])(l.a.mark((function n(o){var s,p,m,h,b,j,g,O,A,x,P,y,I;return l.a.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(0!==o.length){n.next=2;break}return n.abrupt("return");case 2:n.prev=2,s=Array.from(o),e.value=!0,p=Math.round(999999*Math.random())+1,m=Object(i["a"])(s.entries()),n.prev=7,m.s();case 9:if((h=m.n()).done){n.next=19;break}if(b=Object(c["a"])(h.value,2),j=b[0],g=b[1],!w.value){n.next=14;break}return s.splice(j),n.abrupt("break",19);case 14:O="".concat($).concat(p,"_").concat(j),A=Object(u["a"])(Object(u["a"])({},v(g,O)),{},{uploadProgress:0}),t.value?a.value.push(A):a.value.unshift(A);case 17:n.next=9;break;case 19:n.next=24;break;case 21:n.prev=21,n.t0=n["catch"](7),m.e(n.t0);case 24:return n.prev=24,m.f(),n.finish(24);case 27:x=Object(i["a"])(s.entries()),n.prev=28,y=l.a.mark((function e(){var t,n,i,o,s;return l.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return t=Object(c["a"])(P.value,2),n=t[0],i=t[1],o="".concat($).concat(p,"_").concat(n),e.next=4,r({type:"message_attachment",file:i,onUploadProgressCB:function(e){var t=a.value.findIndex((function(e){return e.uid===o}));-1!==t&&d["default"].set(a.value[t],"uploadProgress",Math.floor(e.loaded/e.total*100))}});case 4:s=e.sent,a.value=a.value.map((function(e){return e.uid===o?Object(u["a"])(Object(u["a"])({},e),{},{uid:s.fileUpload.uuid,uploadProgress:100}):e}));case 6:case"end":return e.stop()}}),e)})),x.s();case 31:if((P=x.n()).done){n.next=35;break}return n.delegateYield(y(),"t1",33);case 33:n.next=31;break;case 35:n.next=40;break;case 37:n.prev=37,n.t2=n["catch"](28),x.e(n.t2);case 40:return n.prev=40,x.f(),n.finish(40);case 43:if(n.prev=43,I=a.value.every((function(e){return!("uploadProgress"in e)||100===e.uploadProgress})),!I){n.next=49;break}return n.next=48,Object(f["g"])();case 48:e.value=!1;case 49:return n.finish(43);case 50:case"end":return n.stop()}}),n,null,[[2,,43,50],[7,21,24,27],[28,37,40,43]])})));return function(e){return n.apply(this,arguments)}}(),F=function(e){return a.value.some((function(t){return t.uid===e.uid}))},k=function(){var e=Object(o["a"])(l.a.mark((function e(n){return l.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:n.forEach((function(e){w.value||F(e)||(t.value?a.value.push(e):(e.publicAccess=!t.value,a.value.unshift(e)))}));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),M=function(){a.value=[]},S=function(t){e.value||(t?(a.value=a.value.filter((function(e){return e.uid!==t.uid})),0===g.value.length&&O.value.length>0&&M()):M())},C=Object(f["a"])((function(){return m.value?y["e"]:y["d"]})),E=Object(f["a"])((function(){return t.value?C.value-g.value.length:y["c"]-O.value.length}));return{uploading:e,attachedFiles:a,hasAttachments:Object(f["a"])((function(){return a.value.length>0})),addAttachment:I,addAttachmentFromVault:k,remove:S,isPrivate:t,maxFiles:E}},D=function(e){var t=Object(f["o"])([]),a=Object(O["a"])(),n=a.findAll,r=function(){var e=Object(o["a"])(l.a.mark((function e(){return l.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,n([p["PaymentPackageEnum"].PER_SENT_MESSAGE]);case 2:t.value=e.sent;case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),u=Object(f["o"])(),c=function(){var e=Object(o["a"])(l.a.mark((function e(t){var a;return l.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return e.next=2,g["a"].MessagePricesProvider.find({userIds:[t]});case 2:a=e.sent,u.value=a.find((function(e){return e.userId===t}));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i=Object(f["a"])((function(){var e,a;return null!==(e=null===(a=t.value.find((function(e){var t;return e.id===(null===(t=u.value)||void 0===t?void 0:t.perSentPriceId)})))||void 0===a?void 0:a.amount)&&void 0!==e?e:0})),s=Object(f["a"])((function(){var e,a;return null!==(e=null===(a=t.value.find((function(e){var t;return e.id===(null===(t=u.value)||void 0===t?void 0:t.perSentWithAttachmentPriceId)})))||void 0===a?void 0:a.amount)&&void 0!==e?e:0})),d=Object(f["o"])(!1),v=Object(f["o"])(!1),h=function(){var e=Object(o["a"])(l.a.mark((function e(t,a){return l.a.wrap((function(e){while(1)switch(e.prev=e.next){case 0:return d.value=!0,g["a"].PayPerMessageProvider.setReceiveErrors(!1),e.prev=2,e.next=5,g["a"].PayPerMessageProvider.payPerMessage({recipientId:t,attachment:a});case 5:return e.abrupt("return",e.sent);case 8:if(e.prev=8,e.t0=e["catch"](2),!e.t0.some((function(e){var t;return"{com.scrile.money.validation.SpendingBalanceValidator.message}"===(null===e||void 0===e?void 0:null===(t=e.details)||void 0===t?void 0:t.messageTemplate)}))){e.next=13;break}return v.value=!0,e.abrupt("return",null);case 13:throw e.t0;case 14:return e.prev=14,d.value=!1,e.finish(14);case 17:case"end":return e.stop()}}),e,null,[[2,8,14,17]])})));return function(t,a){return e.apply(this,arguments)}}(),b=function(){v.value=!1},w=Object(A["a"])(),x=w.authUser,y=w.authorities,I=Object(f["a"])((function(){return Object(m["checkAuthorities"])(y.value,["sendFreeMessageToPaidThreads"])}));Object(f["j"])((function(){e&&P["a"].featurePaidSentMessage&&x.value&&!I.value&&(c(e),r())}));var F=Object(j["a"])(),k=Object(f["o"])(!1),M=Object(f["o"])(!1),S=function(e){k.value=!1,M.value=!1,F.resolve(e);var t=Object(j["a"])();F.promise=t.promise,F.resolve=t.resolve},C=function(t,a){return P["a"].featurePaidSentMessage&&!I.value&&e?function(){var n=Object(o["a"])(l.a.mark((function n(r){var u;return l.a.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(e){n.next=2;break}throw new Error("UserId required");case 2:return n.prev=2,d.value=!0,n.next=6,c(e);case 6:if(!(i.value>0||a&&s.value>0)){n.next=17;break}return a&&s.value>i.value?M.value=!0:k.value=!0,n.next=10,F.promise;case 10:if(n.sent){n.next=12;break}return n.abrupt("return");case 12:return n.next=14,h(e,a);case 14:if(u=n.sent,u){n.next=17;break}return n.abrupt("return");case 17:return n.next=19,t(r);case 19:return n.abrupt("return",n.sent);case 20:return n.prev=20,d.value=!1,k.value=!1,M.value=!1,n.finish(20);case 25:case"end":return n.stop()}}),n,null,[[2,,20,25]])})));return function(e){return n.apply(this,arguments)}}():t};return{createSendPaidMessage:C,priceAmount:i,priceMediaAmount:s,processingPayment:d,showPaymentConfirm:k,showPaymentMediaConfirm:M,onPaymentConfirm:S,error:v,closeError:b}},q=Object(f["c"])({name:"SendMessageController",components:{PaidActionConfirm:I["a"],PaidActionError:F["a"],VaultModal:N},props:{threadIds:{type:Array},recipientIds:{type:Array},contentFeed:{type:Object},allowDoNotShowAgain:{type:Boolean,default:!1}},setup:function(e,t){var a,n=t.emit,r=R(),c=r.addAttachment,i=r.addAttachmentFromVault,s=r.attachedFiles,d=r.uploading,p=r.remove,m=r.isPrivate,b=r.hasAttachments,j=r.maxFiles;Object(f["j"])((function(){if((!e.threadIds||0===e.threadIds.length)&&(!e.recipientIds||0===e.recipientIds.length))throw new Error("threadId of recipientIds are required")})),Object(f["s"])(s,(function(e){e.some((function(e){return e.uid.startsWith($)}))||n("attachedFilesUpdate",e)}));var O=Object(f["o"])(!1),A=Object(f["o"])(!1),x=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];m.value=e,A.value=!0},P=function(e){return""!==e||s.value.length>0},y=function(){var t=Object(o["a"])(l.a.mark((function t(a){var r,c,i;return l.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,O.value=!0,c=Object(u["a"])(Object(u["a"])({},e.threadIds&&(null===(r=e.threadIds)||void 0===r?void 0:r.length)>0?{threadIds:e.threadIds}:{recipientIds:e.recipientIds}),{},{text:a,files:s.value.map((function(e){return{uuid:e.uid,publicAccess:e.publicAccess}})),pricePackageId:B},e.contentFeed?{linkSubject:{subjectId:e.contentFeed.id,subjectType:"content_set"}}:{}),n("startedSending"),t.next=6,g["a"].MessagesProvider.sendExtendedMessages({data:c});case 6:return i=t.sent,(null===i||void 0===i?void 0:i.length)>0&&(n("addMessage",i[0]),p()),t.abrupt("return",i);case 9:return t.prev=9,n("stoppedSending"),O.value=!1,t.finish(9);case 13:case"end":return t.stop()}}),t,null,[[0,,9,13]])})));return function(e){return t.apply(this,arguments)}}(),I=D(1===(null===(a=e.recipientIds)||void 0===a?void 0:a.length)?e.recipientIds[0]:void 0),F=I.priceAmount,k=I.priceMediaAmount,M=I.error,S=I.closeError,C=I.processingPayment,E=I.createSendPaidMessage,_=I.onPaymentConfirm,U=I.showPaymentConfirm,V=I.showPaymentMediaConfirm,T=Object(w["a"])(function(){var t=Object(o["a"])(l.a.mark((function t(a,n){var r,u,c,i;return l.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(!d.value){t.next=2;break}return t.abrupt("return");case 2:if(c=0===(null===(r=e.threadIds)||void 0===r?void 0:r.length)&&1===(null===(u=e.recipientIds)||void 0===u?void 0:u.length)?y:E(y,b.value),P(a)){t.next=5;break}return t.abrupt("return",[]);case 5:return t.next=7,c(a);case 7:return i=t.sent,i&&i.length>0&&n(),t.abrupt("return",i||[]);case 10:case"end":return t.stop()}}),t)})));return function(e,a){return t.apply(this,arguments)}}()),N=Object(f["a"])((function(){var e=Object(v["formatMoney"])(b.value?k.value:F.value,{currencyCode:Object(h["d"])()});return"".concat(e.symbol).concat(e.wholePart).concat(e.separator).concat(e.fractionalPart)}));return{onSendMessage:T,sending:Object(f["a"])((function(){return O.value||C.value})),priceAmount:F,priceAmountText:N,priceMediaAmount:k,attachedFiles:s,hasAttachments:b,addAttachment:c,addAttachmentFromVault:i,removeAttachment:p,uploadingAttachment:d,onPaymentConfirm:_,showPaymentConfirm:U,showPaymentMediaConfirm:V,paymentError:M,closeError:S,uploadAttachment:x,isPrivate:m,maxFiles:j,showVault:A}}}),J=q,L=Object(V["a"])(J,n,r,!1,null,null,null),W=L.exports},d3cd:function(e,t,a){"use strict";a("4a2f")}}]);