import{a as ee}from"./chunk-6OP6ITFS.js";import{p as $}from"./chunk-SPUEGBWO.js";import{j as Q,k as V}from"./chunk-3JLWQSYQ.js";import{G as X,ab as Y,vb as Z}from"./chunk-ROXKKVPK.js";import{A as s,Fa as h,Ga as w,Ha as I,Hc as H,Ic as L,Ja as b,Jc as j,Ka as y,Kb as B,La as T,Ma as _,Nb as k,Pc as q,Qb as N,Rc as z,S as n,Sb as R,Ta as d,Ua as c,X as C,Xc as G,ad as J,bc as E,bd as K,cc as A,da as S,ea as v,fb as P,fc as x,ic as F,ja as m,ka as o,kc as D,la as r,lc as O,ma as g,oc as W,ta as u,xb as U}from"./chunk-ZVAMPSQU.js";import{j as f}from"./chunk-FB5LSH2R.js";function te(l,a){l&1&&(o(0,"ion-item")(1,"ion-label")(2,"p"),h(3),d(4,"translate"),r()()()),l&2&&(n(3),w(c(4,1,"pages.newMessageModal.input.target")))}var Ce=(()=>{let a=class a{constructor(){this.navCtrl=s(R),this.translate=s(J),this.modalCtrl=s(j),this.toastCtrl=s(q),this.serverActionsService=s($),this.utilService=s(V),this.message="",Z({closeOutline:X,sendOutline:Y}),setTimeout(()=>{this.initialRecipientId&&this.setSelectedUser(this.initialRecipientId)})}setSelectedUser(i){return f(this,null,function*(){let t=yield this.serverActionsService.users.getUserProfilesById({ids:[i]}),e=t==null?void 0:t.at(0);e&&(this.recipientInfo=e)})}onSelectedUserChange(i){this.recipientId=i?i.id:null}send(){return f(this,null,function*(){if(!this.recipientId)return;let i=yield this.translate.get("pages.newMessageModal.defaultMessage").toPromise();this.message=this.message||i,(yield this.serverActionsService.messages.createMessage({to:this.recipientId,body:this.message}))&&(this.modalCtrl.dismiss(),this.navCtrl.navigateForward(Q.MessageThreadPage.getPath(this.recipientId)))})}cancel(){this.modalCtrl.dismiss()}};a.\u0275fac=function(t){return new(t||a)},a.\u0275cmp=C({type:a,selectors:[["page-new-message-modal"]],inputs:{initialRecipientId:"initialRecipientId"},decls:23,vars:18,consts:[["slot","end"],[3,"click"],["name","close-outline","slot","icon-only"],[1,"ion-padding"],[3,"selectedUserChange","selectedUser"],["labelPlacement","stacked",3,"ngModelChange","ngModel","label","placeholder"],["expand","block",3,"click","disabled"],["name","send-outline","slot","start"]],template:function(t,e){t&1&&(o(0,"ion-header")(1,"ion-toolbar")(2,"ion-title"),h(3),d(4,"translate"),r(),o(5,"ion-buttons",0)(6,"ion-button",1),u("click",function(){return e.cancel()}),g(7,"ion-icon",2),r()()()(),o(8,"ion-content",3)(9,"select-user",4),u("selectedUserChange",function(p){return e.onSelectedUserChange(p)}),r(),S(10,te,5,3,"ion-item"),g(11,"br")(12,"br"),o(13,"ion-item")(14,"ion-textarea",5),d(15,"translate"),d(16,"translate"),T("ngModelChange",function(p){return y(e.message,p)||(e.message=p),p}),r()()(),o(17,"ion-footer",3)(18,"ion-button",6),u("click",function(){return e.send()}),g(19,"ion-icon",7),o(20,"ion-label"),h(21),d(22,"translate"),r()()()),t&2&&(n(3),I(" ",c(4,10,"pages.newMessageModal.title")," "),n(6),m("selectedUser",e.recipientInfo),n(),v(e.recipientId?-1:10),n(4),m("label",_(c(15,12,"pages.newMessageModal.compose")))("placeholder",_(c(16,14,"pages.newMessageModal.input.messagePlaceholder"))),b("ngModel",e.message),n(4),m("disabled",!e.recipientId),n(3),I(" ",c(22,16,"pages.newMessageModal.send")," "))},dependencies:[P,N,B,k,U,ee,D,L,H,A,E,z,x,O,W,G,F,K],encapsulation:2});let l=a;return l})();export{Ce as a};
