import{a as ee}from"./chunk-N7BQCFVD.js";import{a as $}from"./chunk-MRIU7QTQ.js";import{e as J,k as K,p as Z}from"./chunk-SPUEGBWO.js";import{j as G}from"./chunk-3JLWQSYQ.js";import{G as Q,Xa as X,ta as V,vb as Y}from"./chunk-ROXKKVPK.js";import{A as u,Fa as m,Ga as _,Ha as C,Hc as z,Ic as H,Ja as v,Jc as U,Ka as S,Kb as k,La as w,Ma as T,Nb as E,Qb as N,Rc as j,S as i,Sb as B,Ta as r,Ua as s,X as I,bc as x,bd as q,cc as A,da as P,ea as b,fb as O,fc as D,ic as F,ja as f,ka as n,kc as R,la as o,lc as L,ma as c,oc as W,ta as M,xb as y}from"./chunk-ZVAMPSQU.js";import{j as h}from"./chunk-FB5LSH2R.js";function te(l,a){l&1&&(n(0,"ion-label"),m(1),r(2,"translate"),o()),l&2&&(i(),C(" ",s(2,1,"pages.newMealPlanModal.createAndShare")," "))}function ie(l,a){l&1&&(n(0,"ion-label"),m(1),r(2,"translate"),o()),l&2&&(i(),C(" ",s(2,1,"pages.newMealPlanModal.create")," "))}var Ie=(()=>{let a=class a{constructor(){this.navCtrl=u(B),this.modalCtrl=u(U),this.loadingService=u(J),this.serverActionsService=u(Z),this.mealPlanTitle="",this.saving=!1,this.customMealOptions=null,this.selectedCollaboratorIds=[],Y({closeOutline:Q,listOutline:V,reorderThreeOutline:X})}openCustomMealOptions(){return h(this,null,function*(){let d=yield this.modalCtrl.create({component:ee,componentProps:{customMealOptions:this.customMealOptions||void 0}});yield d.present();let{data:e}=yield d.onDidDismiss();(e==null?void 0:e.customMealOptions)!==void 0&&(this.customMealOptions=e.customMealOptions||null)})}save(){return h(this,null,function*(){if(this.saving)return;this.saving=!0;let d=this.loadingService.start(),e=yield this.serverActionsService.mealPlans.createMealPlan({title:this.mealPlanTitle,collaboratorUserIds:this.selectedCollaboratorIds,customMealOptions:this.customMealOptions});d.dismiss(),this.saving=!1,e&&(this.modalCtrl.dismiss({success:!0,id:e.id}),this.navCtrl.navigateForward(G.MealPlanPage.getPath(e.id)))})}cancel(){this.modalCtrl.dismiss({success:!1})}};a.\u0275fac=function(e){return new(e||a)},a.\u0275cmp=I({type:a,selectors:[["page-new-meal-plan-modal"]],decls:27,vars:18,consts:[["slot","end"],[3,"click"],["name","close-outline","slot","icon-only"],[1,"ion-padding"],["type","text","autocapitalize","on","autocorrect","on",3,"ngModelChange","label","ngModel"],["button","","detail","","lines","none",3,"click"],["name","reorder-three-outline","slot","start"],[3,"selectedCollaboratorIdsChanged","selectedCollaboratorIds"],["expand","block",3,"click","disabled"],["name","list-outline","slot","start"]],template:function(e,t){e&1&&(n(0,"ion-header")(1,"ion-toolbar")(2,"ion-title"),m(3),r(4,"translate"),o(),n(5,"ion-buttons",0)(6,"ion-button",1),M("click",function(){return t.cancel()}),c(7,"ion-icon",2),o()()()(),n(8,"ion-content",3)(9,"h6"),m(10),r(11,"translate"),o(),n(12,"text-input",4),r(13,"translate"),w("ngModelChange",function(p){return S(t.mealPlanTitle,p)||(t.mealPlanTitle=p),p}),o(),c(14,"br"),n(15,"ion-item",5),M("click",function(){return t.openCustomMealOptions()}),c(16,"ion-icon",6),n(17,"ion-label"),m(18),r(19,"translate"),o()(),c(20,"br"),n(21,"select-collaborators",7),M("selectedCollaboratorIdsChanged",function(p){return t.selectedCollaboratorIds=p}),o()(),n(22,"ion-footer",3)(23,"ion-button",8),M("click",function(){return t.save()}),c(24,"ion-icon",9),P(25,te,3,3,"ion-label"),P(26,ie,3,3,"ion-label"),o()()),e&2&&(i(3),C(" ",s(4,10,"pages.newMealPlanModal.title")," "),i(7),_(s(11,12,"pages.updateMealPlanModal.detailsTitle")),i(2),f("label",T(s(13,14,"pages.newMealPlanModal.input.title"))),v("ngModel",t.mealPlanTitle),i(6),_(s(19,16,"pages.updateMealPlanModal.customizeMealOptions")),i(3),f("selectedCollaboratorIds",t.selectedCollaboratorIds),i(2),f("disabled",!t.mealPlanTitle),i(2),b(t.selectedCollaboratorIds.length>0?25:-1),i(),b(t.selectedCollaboratorIds.length===0?26:-1))},dependencies:[O,N,k,E,y,$,K,R,H,z,A,x,j,D,L,W,F,q],encapsulation:2});let l=a;return l})();export{Ie as a};
