import {
  FormlyBootstrapModule,
  FormlyConfigModule,
  FormlyModule
} from "./chunk-NFRJCL7R.js";
import "./chunk-62OL73TD.js";
import "./chunk-IGGXREIH.js";
import {
  MenuMapService
} from "./chunk-3FLJCSSF.js";
import {
  ToastrService
} from "./chunk-2YLAF7RI.js";
import {
  CommonSharedModule,
  DynamicFontSizeDirective,
  NgOptionComponent,
  NgSelectComponent,
  NgSelectModule
} from "./chunk-7NQGM4EA.js";
import {
  DefaultValueAccessor,
  FormArrayName,
  FormBuilder,
  FormControlName,
  FormGroupDirective,
  FormGroupName,
  FormsModule,
  NgControlStatus,
  NgControlStatusGroup,
  NgSelectOption,
  ReactiveFormsModule,
  RequiredValidator,
  SelectControlValueAccessor,
  TranslatePipe,
  TranslateService,
  Validators,
  ɵNgNoValidate,
  ɵNgSelectMultipleOption
} from "./chunk-NLYGDKUR.js";
import "./chunk-ZEL7H2AL.js";
import {
  GridApiService,
  LocalStorageService,
  Router
} from "./chunk-P7K2QEDI.js";
import {
  CommonModule,
  Location,
  NgIf,
  ɵsetClassDebugInfo,
  ɵɵStandaloneFeature,
  ɵɵadvance,
  ɵɵconditional,
  ɵɵdefineComponent,
  ɵɵdirectiveInject,
  ɵɵelement,
  ɵɵelementEnd,
  ɵɵelementStart,
  ɵɵgetCurrentView,
  ɵɵlistener,
  ɵɵnextContext,
  ɵɵpipe,
  ɵɵpipeBind1,
  ɵɵproperty,
  ɵɵrepeater,
  ɵɵrepeaterCreate,
  ɵɵrepeaterTrackByIdentity,
  ɵɵresetView,
  ɵɵrestoreView,
  ɵɵtemplate,
  ɵɵtext,
  ɵɵtextInterpolate,
  ɵɵtextInterpolate1
} from "./chunk-GKZIWABI.js";
import {
  __async
} from "./chunk-CVWHNZRK.js";

// src/app/@lcp-framework/pages/email-template-assignment/email-template-assignment.component.ts
function EmailTemplateAssignmentComponent_For_25_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const process_r1 = ctx.$implicit;
    \u0275\u0275property("value", process_r1.id);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(process_r1.name);
  }
}
function EmailTemplateAssignmentComponent_For_30_For_10_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const template_r3 = ctx.$implicit;
    \u0275\u0275property("value", template_r3.value);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(template_r3.label);
  }
}
function EmailTemplateAssignmentComponent_For_30_div_11_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "email_template_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_div_25_For_8_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const tag_r7 = ctx.$implicit;
    \u0275\u0275property("value", tag_r7.id);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(tag_r7.name);
  }
}
function EmailTemplateAssignmentComponent_For_30_div_25_div_9_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "email_tag_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_div_25_div_10_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 34);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_12_0;
    const assignment_r4 = \u0275\u0275nextContext(2).$implicit;
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1("sends to : ", (tmp_12_0 = assignment_r4.get("email_tag_mail")) == null ? null : tmp_12_0.value, "");
  }
}
function EmailTemplateAssignmentComponent_For_30_div_25_Template(rf, ctx) {
  if (rf & 1) {
    const _r6 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(6, "select", 32);
    \u0275\u0275listener("change", function EmailTemplateAssignmentComponent_For_30_div_25_Template_select_change_6_listener() {
      let tmp_12_0;
      \u0275\u0275restoreView(_r6);
      const assignment_r4 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.getTemplateAssignmentTags((tmp_12_0 = assignment_r4.get("email_to")) == null ? null : tmp_12_0.value, assignment_r4));
    });
    \u0275\u0275repeaterCreate(7, EmailTemplateAssignmentComponent_For_30_div_25_For_8_Template, 2, 2, "option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275template(9, EmailTemplateAssignmentComponent_For_30_div_25_div_9_Template, 3, 3, "div", 20)(10, EmailTemplateAssignmentComponent_For_30_div_25_div_10_Template, 2, 1, "div", 33);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_13_0;
    let tmp_14_0;
    const assignment_r4 = \u0275\u0275nextContext().$implicit;
    const ctx_r4 = \u0275\u0275nextContext();
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 3, "email_tag"), " ");
    \u0275\u0275advance(5);
    \u0275\u0275repeater(ctx_r4.recipientTags);
    \u0275\u0275advance(2);
    \u0275\u0275property("ngIf", ((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.invalid) && (((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.touched) || ((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.dirty)));
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", (tmp_14_0 = assignment_r4.get("email_tag_mail")) == null ? null : tmp_14_0.value);
  }
}
function EmailTemplateAssignmentComponent_For_30_div_26_For_8_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "ng-option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const user_r9 = ctx.$implicit;
    \u0275\u0275property("value", user_r9.value);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(user_r9.label);
  }
}
function EmailTemplateAssignmentComponent_For_30_div_26_div_9_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "user_email_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_div_26_Template(rf, ctx) {
  if (rf & 1) {
    const _r8 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(6, "ng-select", 35);
    \u0275\u0275listener("search", function EmailTemplateAssignmentComponent_For_30_div_26_Template_ng_select_search_6_listener($event) {
      \u0275\u0275restoreView(_r8);
      const assignment_r4 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.getUsers(assignment_r4, $event.term || ""));
    })("clear", function EmailTemplateAssignmentComponent_For_30_div_26_Template_ng_select_clear_6_listener() {
      \u0275\u0275restoreView(_r8);
      const assignment_r4 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.getUsers(assignment_r4, ""));
    });
    \u0275\u0275repeaterCreate(7, EmailTemplateAssignmentComponent_For_30_div_26_For_8_Template, 2, 2, "ng-option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275template(9, EmailTemplateAssignmentComponent_For_30_div_26_div_9_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_14_0;
    let tmp_15_0;
    const assignment_r4 = \u0275\u0275nextContext().$implicit;
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 4, "user_email"), " ");
    \u0275\u0275advance(4);
    \u0275\u0275property("clearable", true)("searchable", true);
    \u0275\u0275advance();
    \u0275\u0275repeater((tmp_14_0 = assignment_r4.get("user_list")) == null ? null : tmp_14_0.value);
    \u0275\u0275advance(2);
    \u0275\u0275property("ngIf", ((tmp_15_0 = assignment_r4.get("email_to")) == null ? null : tmp_15_0.invalid) && (((tmp_15_0 = assignment_r4.get("email_to")) == null ? null : tmp_15_0.touched) || ((tmp_15_0 = assignment_r4.get("email_to")) == null ? null : tmp_15_0.dirty)));
  }
}
function EmailTemplateAssignmentComponent_For_30_div_27_div_9_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "email_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_div_27_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275element(6, "input", 36);
    \u0275\u0275elementStart(7, "div", 34);
    \u0275\u0275text(8);
    \u0275\u0275elementEnd();
    \u0275\u0275template(9, EmailTemplateAssignmentComponent_For_30_div_27_div_9_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_13_0;
    const assignment_r4 = \u0275\u0275nextContext().$implicit;
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 3, "email"), " ");
    \u0275\u0275advance(6);
    \u0275\u0275textInterpolate1("Note : Can add multiple emails as comma seperated values eg: ", "example1@gmail.com, example2@gmail.com", "");
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.invalid) && (((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.touched) || ((tmp_13_0 = assignment_r4.get("email_to")) == null ? null : tmp_13_0.dirty)));
  }
}
function EmailTemplateAssignmentComponent_For_30_Conditional_28_Template(rf, ctx) {
  if (rf & 1) {
    const _r10 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "i", 37);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_For_30_Conditional_28_Template_i_click_0_listener() {
      \u0275\u0275restoreView(_r10);
      const i_r11 = \u0275\u0275nextContext().$index;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.removeEmailTemplateAssignment(i_r11));
    });
    \u0275\u0275elementEnd();
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_12_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "send_type_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_26_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "recipient_type_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_27_For_8_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const tag_r15 = ctx.$implicit;
    \u0275\u0275property("value", tag_r15.id);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(tag_r15.name);
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_27_div_9_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "email_tag_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_27_div_10_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 34);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_22_0;
    const ccBcc_r13 = \u0275\u0275nextContext(2).$implicit;
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1("sends to : ", (tmp_22_0 = ccBcc_r13.get("email_tag_mail")) == null ? null : tmp_22_0.value, "");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_27_Template(rf, ctx) {
  if (rf & 1) {
    const _r14 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(6, "select", 32);
    \u0275\u0275listener("change", function EmailTemplateAssignmentComponent_For_30_For_32_div_27_Template_select_change_6_listener() {
      let tmp_22_0;
      \u0275\u0275restoreView(_r14);
      const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext(2);
      return \u0275\u0275resetView(ctx_r4.getTemplateAssignmentTags((tmp_22_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_22_0.value, ccBcc_r13));
    });
    \u0275\u0275repeaterCreate(7, EmailTemplateAssignmentComponent_For_30_For_32_div_27_For_8_Template, 2, 2, "option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275template(9, EmailTemplateAssignmentComponent_For_30_For_32_div_27_div_9_Template, 3, 3, "div", 20)(10, EmailTemplateAssignmentComponent_For_30_For_32_div_27_div_10_Template, 2, 1, "div", 33);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_23_0;
    let tmp_24_0;
    const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
    const ctx_r4 = \u0275\u0275nextContext(2);
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 3, "email_tag"), " ");
    \u0275\u0275advance(5);
    \u0275\u0275repeater(ctx_r4.recipientTags);
    \u0275\u0275advance(2);
    \u0275\u0275property("ngIf", ((tmp_23_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_23_0.invalid) && (((tmp_23_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_23_0.touched) || ((tmp_23_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_23_0.dirty)));
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", (tmp_24_0 = ccBcc_r13.get("email_tag_mail")) == null ? null : tmp_24_0.value);
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_28_For_8_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "ng-option", 14);
    \u0275\u0275text(1);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    const user_r17 = ctx.$implicit;
    \u0275\u0275property("value", user_r17.value);
    \u0275\u0275advance();
    \u0275\u0275textInterpolate(user_r17.label);
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_28_div_9_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "user_email_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_28_Template(rf, ctx) {
  if (rf & 1) {
    const _r16 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(6, "ng-select", 35);
    \u0275\u0275listener("search", function EmailTemplateAssignmentComponent_For_30_For_32_div_28_Template_ng_select_search_6_listener($event) {
      \u0275\u0275restoreView(_r16);
      const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext(2);
      return \u0275\u0275resetView(ctx_r4.getUsers(ccBcc_r13, $event.term || ""));
    })("clear", function EmailTemplateAssignmentComponent_For_30_For_32_div_28_Template_ng_select_clear_6_listener() {
      \u0275\u0275restoreView(_r16);
      const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
      const ctx_r4 = \u0275\u0275nextContext(2);
      return \u0275\u0275resetView(ctx_r4.getUsers(ccBcc_r13, ""));
    });
    \u0275\u0275repeaterCreate(7, EmailTemplateAssignmentComponent_For_30_For_32_div_28_For_8_Template, 2, 2, "ng-option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275template(9, EmailTemplateAssignmentComponent_For_30_For_32_div_28_div_9_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    let tmp_24_0;
    let tmp_25_0;
    const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 4, "user_email"), " ");
    \u0275\u0275advance(4);
    \u0275\u0275property("clearable", true)("searchable", true);
    \u0275\u0275advance();
    \u0275\u0275repeater((tmp_24_0 = ccBcc_r13.get("user_list")) == null ? null : tmp_24_0.value);
    \u0275\u0275advance(2);
    \u0275\u0275property("ngIf", ((tmp_25_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_25_0.invalid) && (((tmp_25_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_25_0.touched) || ((tmp_25_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_25_0.dirty)));
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_29_div_7_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 31);
    \u0275\u0275text(1);
    \u0275\u0275pipe(2, "translate");
    \u0275\u0275elementEnd();
  }
  if (rf & 2) {
    \u0275\u0275advance();
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(2, 1, "email_is_required"), " ");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_div_29_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 9)(1, "label");
    \u0275\u0275text(2);
    \u0275\u0275pipe(3, "translate");
    \u0275\u0275elementStart(4, "span", 11);
    \u0275\u0275text(5, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275element(6, "input", 36);
    \u0275\u0275template(7, EmailTemplateAssignmentComponent_For_30_For_32_div_29_div_7_Template, 3, 3, "div", 20);
    \u0275\u0275elementStart(8, "div", 34);
    \u0275\u0275text(9);
    \u0275\u0275elementEnd()();
  }
  if (rf & 2) {
    let tmp_22_0;
    const ccBcc_r13 = \u0275\u0275nextContext().$implicit;
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(3, 3, "email"), " ");
    \u0275\u0275advance(5);
    \u0275\u0275property("ngIf", ((tmp_22_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_22_0.invalid) && (((tmp_22_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_22_0.touched) || ((tmp_22_0 = ccBcc_r13.get("email_to")) == null ? null : tmp_22_0.dirty)));
    \u0275\u0275advance(2);
    \u0275\u0275textInterpolate1("Note : Can add multiple emails as comma seperated values eg: ", "example1@gmail.com, example2@gmail.com", "");
  }
}
function EmailTemplateAssignmentComponent_For_30_For_32_Template(rf, ctx) {
  if (rf & 1) {
    const _r12 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 29)(1, "div", 9)(2, "label");
    \u0275\u0275text(3);
    \u0275\u0275pipe(4, "translate");
    \u0275\u0275elementStart(5, "span", 11);
    \u0275\u0275text(6, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(7, "select", 38)(8, "option", 39);
    \u0275\u0275text(9, "CC");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(10, "option", 40);
    \u0275\u0275text(11, "BCC");
    \u0275\u0275elementEnd()();
    \u0275\u0275template(12, EmailTemplateAssignmentComponent_For_30_For_32_div_12_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(13, "div", 9)(14, "label");
    \u0275\u0275text(15);
    \u0275\u0275pipe(16, "translate");
    \u0275\u0275elementStart(17, "span", 11);
    \u0275\u0275text(18, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(19, "select", 21);
    \u0275\u0275listener("change", function EmailTemplateAssignmentComponent_For_30_For_32_Template_select_change_19_listener() {
      const ccBcc_r13 = \u0275\u0275restoreView(_r12).$implicit;
      const ctx_r4 = \u0275\u0275nextContext(2);
      return \u0275\u0275resetView(ctx_r4.clearUserTagValues(ccBcc_r13));
    });
    \u0275\u0275elementStart(20, "option", 22);
    \u0275\u0275text(21, "Tag");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(22, "option", 23);
    \u0275\u0275text(23, "User");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(24, "option", 24);
    \u0275\u0275text(25, "Custom Mail");
    \u0275\u0275elementEnd()();
    \u0275\u0275template(26, EmailTemplateAssignmentComponent_For_30_For_32_div_26_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
    \u0275\u0275template(27, EmailTemplateAssignmentComponent_For_30_For_32_div_27_Template, 11, 5, "div", 25)(28, EmailTemplateAssignmentComponent_For_30_For_32_div_28_Template, 10, 6, "div", 25)(29, EmailTemplateAssignmentComponent_For_30_For_32_div_29_Template, 10, 5, "div", 25);
    \u0275\u0275elementStart(30, "i", 41);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_For_30_For_32_Template_i_click_30_listener() {
      const j_r18 = \u0275\u0275restoreView(_r12).$index;
      const i_r11 = \u0275\u0275nextContext().$index;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.removeCcBccGroup(i_r11, j_r18));
    });
    \u0275\u0275elementEnd()();
  }
  if (rf & 2) {
    let tmp_22_0;
    let tmp_24_0;
    let tmp_25_0;
    let tmp_26_0;
    let tmp_27_0;
    const ccBcc_r13 = ctx.$implicit;
    const j_r18 = ctx.$index;
    \u0275\u0275property("formGroupName", j_r18);
    \u0275\u0275advance(3);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(4, 8, "send_type"), " ");
    \u0275\u0275advance(9);
    \u0275\u0275property("ngIf", ((tmp_22_0 = ccBcc_r13.get("send_type")) == null ? null : tmp_22_0.invalid) && (((tmp_22_0 = ccBcc_r13.get("send_type")) == null ? null : tmp_22_0.touched) || ((tmp_22_0 = ccBcc_r13.get("send_type")) == null ? null : tmp_22_0.dirty)));
    \u0275\u0275advance(3);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(16, 10, "recipient_type"), " ");
    \u0275\u0275advance(11);
    \u0275\u0275property("ngIf", ((tmp_24_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_24_0.invalid) && (((tmp_24_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_24_0.touched) || ((tmp_24_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_24_0.dirty)));
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_25_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_25_0.value) === "tag");
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_26_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_26_0.value) === "user_id");
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_27_0 = ccBcc_r13.get("recipient_type")) == null ? null : tmp_27_0.value) === "custom");
  }
}
function EmailTemplateAssignmentComponent_For_30_Template(rf, ctx) {
  if (rf & 1) {
    const _r2 = \u0275\u0275getCurrentView();
    \u0275\u0275elementStart(0, "div", 17)(1, "div", 18)(2, "div", 9)(3, "label");
    \u0275\u0275text(4);
    \u0275\u0275pipe(5, "translate");
    \u0275\u0275elementStart(6, "span", 11);
    \u0275\u0275text(7, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(8, "select", 19);
    \u0275\u0275repeaterCreate(9, EmailTemplateAssignmentComponent_For_30_For_10_Template, 2, 2, "option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275template(11, EmailTemplateAssignmentComponent_For_30_div_11_Template, 3, 3, "div", 20);
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(12, "div", 9)(13, "label");
    \u0275\u0275text(14);
    \u0275\u0275pipe(15, "translate");
    \u0275\u0275elementStart(16, "span", 11);
    \u0275\u0275text(17, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(18, "select", 21);
    \u0275\u0275listener("change", function EmailTemplateAssignmentComponent_For_30_Template_select_change_18_listener() {
      const assignment_r4 = \u0275\u0275restoreView(_r2).$implicit;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.clearUserTagValues(assignment_r4));
    });
    \u0275\u0275elementStart(19, "option", 22);
    \u0275\u0275text(20, "Tag");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(21, "option", 23);
    \u0275\u0275text(22, "User");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(23, "option", 24);
    \u0275\u0275text(24, "Custom Mail");
    \u0275\u0275elementEnd()()();
    \u0275\u0275template(25, EmailTemplateAssignmentComponent_For_30_div_25_Template, 11, 5, "div", 25)(26, EmailTemplateAssignmentComponent_For_30_div_26_Template, 10, 6, "div", 25)(27, EmailTemplateAssignmentComponent_For_30_div_27_Template, 10, 5, "div", 25)(28, EmailTemplateAssignmentComponent_For_30_Conditional_28_Template, 1, 0, "i", 26);
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(29, "div", 27)(30, "div", 28);
    \u0275\u0275repeaterCreate(31, EmailTemplateAssignmentComponent_For_30_For_32_Template, 31, 12, "div", 29, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(33, "button", 30);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_For_30_Template_button_click_33_listener() {
      const i_r11 = \u0275\u0275restoreView(_r2).$index;
      const ctx_r4 = \u0275\u0275nextContext();
      return \u0275\u0275resetView(ctx_r4.addCcBccGroup(i_r11));
    });
    \u0275\u0275text(34);
    \u0275\u0275pipe(35, "translate");
    \u0275\u0275elementEnd()()();
  }
  if (rf & 2) {
    let tmp_13_0;
    let tmp_15_0;
    let tmp_16_0;
    let tmp_17_0;
    const assignment_r4 = ctx.$implicit;
    const i_r11 = ctx.$index;
    const ctx_r4 = \u0275\u0275nextContext();
    \u0275\u0275property("formGroupName", i_r11);
    \u0275\u0275advance(4);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(5, 9, "email_template"), " ");
    \u0275\u0275advance(5);
    \u0275\u0275repeater(ctx_r4.templateList);
    \u0275\u0275advance(2);
    \u0275\u0275property("ngIf", ((tmp_13_0 = assignment_r4.get("template_id")) == null ? null : tmp_13_0.invalid) && (((tmp_13_0 = assignment_r4.get("template_id")) == null ? null : tmp_13_0.touched) || ((tmp_13_0 = assignment_r4.get("template_id")) == null ? null : tmp_13_0.dirty)));
    \u0275\u0275advance(3);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(15, 11, "recipient_type"), " ");
    \u0275\u0275advance(11);
    \u0275\u0275property("ngIf", ((tmp_15_0 = assignment_r4.get("recipient_type")) == null ? null : tmp_15_0.value) === "tag");
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_16_0 = assignment_r4.get("recipient_type")) == null ? null : tmp_16_0.value) === "user_id");
    \u0275\u0275advance();
    \u0275\u0275property("ngIf", ((tmp_17_0 = assignment_r4.get("recipient_type")) == null ? null : tmp_17_0.value) === "custom");
    \u0275\u0275advance();
    \u0275\u0275conditional(28, i_r11 > 0 ? 28 : -1);
    \u0275\u0275advance(3);
    \u0275\u0275repeater(ctx_r4.getCcBccControls(i_r11));
    \u0275\u0275advance(3);
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(35, 13, "add_cc_bcc"), " ");
  }
}
var _EmailTemplateAssignmentComponent = class _EmailTemplateAssignmentComponent {
  constructor(fb, translate, location, router, commonService, gridApiService, toastr, localStorageService) {
    this.fb = fb;
    this.translate = translate;
    this.location = location;
    this.router = router;
    this.commonService = commonService;
    this.gridApiService = gridApiService;
    this.toastr = toastr;
    this.localStorageService = localStorageService;
    this.emailTemplateProcessDetail = [];
    this.loading = false;
    this.recipientTags = [];
    this.templateList = [];
    this.userId = 0;
    this.options = [];
    this.form = this.fb.group({
      email_template_process: this.fb.group({
        email_template_process_id: [null, Validators.required]
      }),
      email_template_assignments: this.fb.array([])
    });
    const currentRoute = this.router.routerState.snapshot.url;
    this.emailTempAssignmentId = String(currentRoute.split("/")[currentRoute.split("/").length - 1]);
  }
  ngOnInit() {
    return __async(this, null, function* () {
      yield this.getEmailTemplateTag();
      yield this.getEmailTemplates();
      yield this.getEmailTemplateProcess();
      yield this.getTemplateAssignment();
      this.userId = this.localStorageService.getData("user_data") && JSON.parse(this.localStorageService.getData("user_data")).main.id;
    });
  }
  getEmailTemplateTag() {
    return __async(this, null, function* () {
      const payload = {
        company_id: 1,
        search_all: [
          {
            value: "3",
            operator: "!=",
            column_name: "email_template_recipient_tags.status_id"
          }
        ],
        limit_range: 1e3,
        print_query: true,
        start_index: 0,
        primary_table: "email_template_recipient_tags",
        select_columns: [["email_template_recipient_tags.id"], ["email_template_recipient_tags.slug"], ["email_template_recipient_tags.name"]]
      };
      this.commonService.getCommonList(payload).subscribe({
        next: (response) => {
          if (response.code === 200 && response.status) {
            this.loading = false;
            if (response.data.records) {
              response.data.records.forEach((each) => {
                this.recipientTags.push({
                  id: each.id,
                  name: each.name
                });
              });
            }
          }
        }
      });
    });
  }
  getEmailTemplates() {
    return __async(this, null, function* () {
      const payload = {
        includes: [
          {
            join_type: "INNER",
            table_name: "email_template_process",
            join_condition: "email_template_process.id = email_templates.email_template_process_id"
          }
        ],
        company_id: 1,
        search_all: [
          {
            value: "1",
            operator: "=",
            column_name: "email_templates.status_id"
          },
          {
            value: this.emailTempAssignmentId,
            operator: "=",
            column_name: "email_template_process.uuid"
          }
        ],
        limit_range: 1e3,
        print_query: false,
        start_index: 0,
        sort_columns: [["email_templates.name", "asc"]],
        primary_table: "email_templates",
        select_columns: [
          ["email_templates.id", "value"],
          ["email_templates.name", "label"]
        ]
      };
      this.commonService.getCommonList(payload).subscribe({
        next: (response) => {
          if (response.code === 200 && response.status) {
            if (response.data.records.length) {
              for (let each of response.data.records) {
                this.templateList.push({ label: each.label, value: each.value });
              }
            }
          }
        }
      });
    });
  }
  getEmailTemplateProcess() {
    return __async(this, null, function* () {
      const payload = {
        company_id: 1,
        search_all: [
          {
            value: "3",
            operator: "!=",
            column_name: "email_template_process.status_id"
          },
          {
            value: this.emailTempAssignmentId,
            operator: "=",
            column_name: "email_template_process.uuid"
          }
        ],
        limit_range: 1,
        print_query: true,
        start_index: 0,
        primary_table: "email_template_process",
        select_columns: [["email_template_process.id"], ["email_template_process.slug"]]
      };
      this.commonService.getCommonList(payload).subscribe({
        next: (response) => {
          if (response.code === 200 && response.status) {
            if (response.data.records.length) {
              this.emailTemplateProcessDetail.push({
                id: response.data.records[0].id,
                name: response.data.records[0].slug
              });
              this.form.controls["email_template_process"].setValue({ email_template_process_id: response.data.records[0].id });
            }
          }
        }
      });
    });
  }
  getTemplateAssignment() {
    return __async(this, null, function* () {
      const payload = {
        company_id: 1,
        includes: [
          {
            join_type: "INNER",
            table_name: "email_template_assignments",
            join_condition: "email_template_process.id = email_template_assignments.email_template_process_id"
          }
        ],
        search_all: [
          {
            value: this.emailTempAssignmentId,
            operator: "=",
            column_name: "email_template_process.uuid"
          },
          {
            value: "3",
            operator: "!=",
            column_name: "email_template_process.status_id"
          }
        ],
        limit_range: 1e3,
        print_query: true,
        start_index: 0,
        primary_table: "email_template_process",
        select_columns: [
          ["email_template_process.id"],
          ["email_template_process.slug"],
          ["email_template_assignments.id", "eta_id"],
          ["email_template_assignments.template_id"],
          ["email_template_assignments.recipient_type"],
          ["email_template_assignments.email_to"]
        ]
      };
      this.loading = true;
      this.commonService.getCommonList(payload).subscribe({
        next: (response) => {
          if (response.code === 200 && response.status) {
            this.loading = false;
            if (response.data.records) {
              if (response.data.records.length) {
                const lineItemsArray = this.form.get("email_template_assignments");
                let temp_assgn_ids = [];
                for (let each of response.data.records) {
                  lineItemsArray.push(this.fb.group({
                    id: each.eta_id,
                    recipient_type: [each.recipient_type, Validators.required],
                    email_to: [each.email_to, Validators.required],
                    template_id: [each.template_id, Validators.required],
                    email_template_assignment_id: [each.eta_id, Validators.required],
                    cc_bcc: this.fb.array([]),
                    email_tag_mail: [null],
                    user_list: [null]
                  }));
                  if (each.recipient_type === "tag") {
                    this.getTemplateAssignmentTags(each.email_to, lineItemsArray.controls[lineItemsArray.length - 1]);
                  }
                  if (each.recipient_type === "user_id") {
                    this.getUsers(lineItemsArray.controls[lineItemsArray.length - 1], "");
                  }
                  temp_assgn_ids.push(each.eta_id);
                }
                this.getCcBccAssignments(temp_assgn_ids);
              } else {
                this.addEmailTemplateAssignment();
              }
            } else {
              const key = "failed_to_fetch_the_entity_details";
              const errorMessage = this.translate.instant(key);
              this.toastr.error(errorMessage, "Error");
            }
          } else {
            this.loading = false;
          }
        },
        error: (error) => {
          this.loading = false;
          console.error("Error fetching URL details:", error);
        }
      });
    });
  }
  getCcBccAssignments(assignmentIds) {
    return __async(this, null, function* () {
      let payload = {
        company_id: 1,
        includes: [
          {
            join_type: "INNER",
            table_name: "email_template_cc_bcc",
            join_condition: "email_template_assignments.id = email_template_cc_bcc.email_template_assignment_id"
          }
        ],
        search_any: [],
        limit_range: 1e3,
        print_query: true,
        start_index: 0,
        primary_table: "email_template_assignments",
        select_columns: [
          ["email_template_assignments.id", "eta_id"],
          ["email_template_cc_bcc.recipient_type"],
          ["email_template_cc_bcc.email_to"],
          ["email_template_cc_bcc.send_type"]
        ]
      };
      for (let each of assignmentIds) {
        payload.search_any.push({
          value: each,
          operator: "=",
          column_name: "email_template_cc_bcc.email_template_assignment_id"
        });
      }
      this.loading = true;
      this.commonService.getCommonList(payload).subscribe({
        next: (response) => {
          if (response.code === 200 && response.status) {
            this.loading = false;
            if (response.data.records) {
              const lineItemsArray = this.form.get("email_template_assignments");
              lineItemsArray.controls.forEach((eachTemp) => {
                for (let ccBcc of response.data.records) {
                  if (ccBcc.eta_id === eachTemp.controls["email_template_assignment_id"].value) {
                    const lineItemsArray2 = eachTemp.get("cc_bcc");
                    lineItemsArray2.push(this.fb.group({
                      eta_id: eachTemp.controls["email_template_assignment_id"].value,
                      send_type: [ccBcc.send_type, Validators.required],
                      recipient_type: [ccBcc.recipient_type, Validators.required],
                      email_to: [ccBcc.email_to, Validators.required],
                      email_tag_mail: [null],
                      user_list: [null]
                    }));
                    if (ccBcc.recipient_type === "tag") {
                      this.getTemplateAssignmentTags(ccBcc.email_to, lineItemsArray2.controls[lineItemsArray2.length - 1]);
                    }
                    if (ccBcc.recipient_type === "user_id") {
                      this.getUsers(lineItemsArray2.controls[lineItemsArray2.length - 1], "");
                    }
                  }
                }
              });
            }
          }
        }
      });
    });
  }
  get emailTemplateAssignments() {
    const emailRecpArray = this.form.get("email_template_assignments");
    return emailRecpArray?.controls?.length ? emailRecpArray.controls : [];
  }
  getTemplateAssignmentList() {
    const lineItemsArray = this.form.get("email_template_assignments");
    return lineItemsArray?.controls?.length ? lineItemsArray.controls : [];
  }
  addEmailTemplateAssignment() {
    const lineItemsArray = this.form.get("email_template_assignments");
    lineItemsArray.push(this.fb.group({
      id: [0],
      recipient_type: ["tag", Validators.required],
      email_to: [null, Validators.required],
      template_id: [null, Validators.required],
      email_template_assignment_id: [0],
      cc_bcc: this.fb.array([]),
      email_tag_mail: [null],
      user_list: [null]
    }));
  }
  removeEmailTemplateAssignment(index) {
    const lineItemsArray = this.form.get("email_template_assignments");
    lineItemsArray.removeAt(index);
  }
  getCcBccControls(i) {
    const lineItemsArray = this.form.get("email_template_assignments." + i + ".cc_bcc");
    return lineItemsArray?.controls?.length ? lineItemsArray.controls : [];
  }
  addCcBccGroup(i) {
    const lineItemsArray = this.form.get("email_template_assignments." + i + ".cc_bcc");
    lineItemsArray.push(this.fb.group({
      eta_id: 0,
      send_type: ["cc", Validators.required],
      recipient_type: ["tag", Validators.required],
      email_to: ["", Validators.required],
      email_tag_mail: [null],
      user_list: [null]
    }));
  }
  removeCcBccGroup(i, j) {
    const lineItemsArray = this.form.get("email_template_assignments." + i + ".cc_bcc");
    lineItemsArray.removeAt(j);
  }
  clearUserTagValues(formGroup) {
    formGroup.controls["email_to"].reset();
    formGroup.controls["email_tag_mail"].reset();
    if (formGroup.controls["recipient_type"].value === "user_id") {
      this.getUsers(formGroup, "");
    }
  }
  getTemplateAssignmentTags(tagId, formGroup) {
    let payload = {
      company_id: 1,
      search_all: [
        {
          value: "3",
          operator: "!=",
          column_name: "email_template_recipient_tags.status_id"
        },
        {
          value: tagId,
          operator: "=",
          column_name: "email_template_recipient_tags.id"
        }
      ],
      search_any: [],
      limit_range: 1e3,
      print_query: true,
      start_index: 0,
      primary_table: "email_template_recipient_tags",
      select_columns: [["email_template_recipient_tags.id"], ["email_template_recipient_tags.slug"], ["email_template_recipient_tags.query_information"]]
    };
    this.commonService.getCommonList(payload).subscribe({
      next: (response) => {
        if (response.code === 200 && response.status) {
          if (response.data.records.length) {
            const query_information_string = response.data.records[0].query_information;
            const query_information = JSON.parse(query_information_string);
            if (query_information.search_all.length) {
              query_information.search_all.forEach((each) => {
                if (each.value === "@process.user_id") {
                  each.value = this.userId;
                }
              });
            }
            this.commonService.getCommonList(query_information).subscribe({
              next: (response2) => {
                if (response2.data.records) {
                  let emailName = "";
                  if (response2.data.records.length) {
                    for (let each of response2.data.records) {
                      emailName = emailName ? emailName + ", " + each.email : each.email;
                      formGroup.get("email_tag_mail")?.setValue(emailName);
                    }
                  } else {
                    formGroup.get("email_tag_mail")?.setValue("No email id is present");
                  }
                }
              }
            });
          }
        }
      }
    });
  }
  getUsers(formGroup, uname) {
    let payload = {
      company_id: 1,
      search_all: [
        {
          value: "1",
          operator: "=",
          column_name: "status_id"
        }
      ],
      limit_range: 25,
      print_query: false,
      start_index: 0,
      sort_columns: [["email", "asc"]],
      primary_table: "users",
      select_columns: [
        ["email", "value"],
        ["email", "label"]
      ]
    };
    if (uname) {
      payload.search_all.push({
        value: "%" + uname + "%",
        operator: "ILIKE",
        column_name: "email"
      });
    }
    this.commonService.getCommonList(payload).subscribe({
      next: (response) => {
        if (response.code === 200 && response.status) {
          if (response.data.records.length) {
            formGroup.get("user_list")?.setValue(response.data.records);
          }
        }
      }
    });
  }
  submit() {
    this.form.markAllAsTouched();
    if (this.form.valid) {
      let no_of_tables = 2;
      let no_of_child_tables = 2;
      const payload = {
        data: {},
        table: ["email_template_process", "email_template_assignments"],
        action: ["select", "hard_delete"],
        columns: {
          table1: ["id"]
        },
        conditions: {
          table1: [
            {
              id: this.emailTemplateProcessDetail[0].id
            }
          ],
          table2: [
            {
              email_template_process_id: "@table1.id"
            }
          ]
        },
        table_mapping: ["table1", "table2"]
      };
      const lineItemsArray = this.form.get("email_template_assignments");
      for (let templates of lineItemsArray.controls) {
        no_of_tables++;
        payload.data["table" + no_of_tables] = [
          {
            email_to: templates.controls["email_to"].value,
            created_at: true,
            created_by: true,
            template_id: templates.controls["template_id"].value,
            recipient_type: templates.controls["recipient_type"].value,
            email_template_process_id: "@table1.id"
          }
        ];
        payload.action.push("insert");
        payload.table_mapping.push("table" + no_of_tables);
        payload.table.push("email_template_assignments");
        let ccBccLineItems = templates.controls["cc_bcc"];
        let parent_table = no_of_tables;
        for (let ccBccTemplates of ccBccLineItems.controls) {
          no_of_child_tables = no_of_tables + 1;
          payload.data["table" + no_of_child_tables] = [
            {
              email_to: ccBccTemplates.controls["email_to"].value,
              created_at: true,
              created_by: true,
              recipient_type: ccBccTemplates.controls["recipient_type"].value,
              send_type: ccBccTemplates.controls["send_type"].value,
              email_template_assignment_id: "@table" + parent_table + ".id"
            }
          ];
          payload.action.push("insert");
          payload.table_mapping.push("table" + no_of_child_tables);
          payload.table.push("email_template_cc_bcc");
          no_of_tables = no_of_child_tables;
        }
      }
      this.gridApiService.executeRecords(payload).subscribe({
        next: (response) => {
          this.loading = false;
          if (response.code === 200 && response.status) {
            this.toastr.success("Record updated successfully", "Success");
          }
        }
      });
    } else {
      this.toastr.error("Enter all required fields", "Error");
    }
  }
};
_EmailTemplateAssignmentComponent.\u0275fac = function EmailTemplateAssignmentComponent_Factory(t) {
  return new (t || _EmailTemplateAssignmentComponent)(\u0275\u0275directiveInject(FormBuilder), \u0275\u0275directiveInject(TranslateService), \u0275\u0275directiveInject(Location), \u0275\u0275directiveInject(Router), \u0275\u0275directiveInject(MenuMapService), \u0275\u0275directiveInject(GridApiService), \u0275\u0275directiveInject(ToastrService), \u0275\u0275directiveInject(LocalStorageService));
};
_EmailTemplateAssignmentComponent.\u0275cmp = /* @__PURE__ */ \u0275\u0275defineComponent({ type: _EmailTemplateAssignmentComponent, selectors: [["app-email-template-assignment"]], standalone: true, features: [\u0275\u0275StandaloneFeature], decls: 31, vars: 10, consts: [[1, "panel"], [1, "mb-5", "flex", "flex-col", "items-start", "justify-between", "gap-3", "lg:flex-row", "lg:items-center"], [1, "text-lg", "font-semibold", "dark:text-white-light"], [1, "align-center", "flex", "gap-3"], ["appDynamicFontSize", "body", "type", "button", 1, "btn", "btn-danger", "mr-5", "ltr:rounded-r", "rtl:rounded-l", 3, "click"], ["type", "submit", 1, "btn", "btn-outline-secondary", "ng-tns-c3247919129-2", "text-xs", "ltr:rounded-r", "rtl:rounded-l", 3, "click"], [3, "formGroup"], ["formGroupName", "email_template_process", 1, "mb-5", "flex", "flex-col", "items-start", "justify-between", "gap-3", "lg:flex-row", "lg:items-center"], [1, "min-w-200-p"], [1, "form-group"], ["for", "email_template_process_id"], [1, "text-danger"], ["formControlName", "email_template_process_id", "required", "", 1, "form-select", "w-full", "py-1", "text-xs", "text-gray-700", "placeholder:text-white-dark", "dark:bg-gray-800", "dark:text-white-dark"], ["value", ""], [3, "value"], ["type", "button", 1, "hover:bg-primary-dark", "dark:bg-primary-dark", "dark:focus:ring-primary-dark", "flex", "w-40", "flex-row", "items-center", "justify-center", "gap-8", "rounded-md", "bg-primary", "px-6", "py-2", "text-white", "shadow-sm", "focus:outline-none", "focus:ring-2", "focus:ring-primary", "focus:ring-offset-2", "dark:text-white", 3, "click"], ["formArrayName", "email_template_assignments"], [1, "my-4", 3, "formGroupName"], [1, "grid", "grid-cols-4", "gap-3"], ["formControlName", "template_id", "required", "", 1, "form-select", "w-full", "py-1", "text-xs", "text-gray-700", "placeholder:text-white-dark", "dark:bg-gray-800", "dark:text-white-dark"], ["class", "invalid-feedback mt-1 text-danger", 4, "ngIf"], ["formControlName", "recipient_type", "required", "", 1, "form-select", "w-full", "py-1", "text-xs", "text-gray-700", "placeholder:text-white-dark", "dark:bg-gray-800", "dark:text-white-dark", 3, "change"], ["value", "tag"], ["value", "user_id"], ["value", "custom"], ["class", "form-group", 4, "ngIf"], [1, "fa-solid", "fa-xmark", "color-red", "mt-5", "cursor-pointer", "text-xl"], [1, "mt-5", "rounded", "border", "p-3"], ["formArrayName", "cc_bcc", 1, "grid", "grid-cols-1"], [1, "mt-4", "grid", "grid-cols-4", "gap-3", 3, "formGroupName"], ["type", "button", 1, "hover:bg-primary-dark", "dark:bg-primary-dark", "dark:focus:ring-primary-dark", "mt-5", "flex", "flex-row", "items-center", "justify-center", "gap-8", "rounded-md", "bg-primary", "px-6", "py-2", "text-white", "shadow-sm", "focus:outline-none", "focus:ring-2", "focus:ring-primary", "focus:ring-offset-2", "dark:text-white", 3, "click"], [1, "invalid-feedback", "mt-1", "text-danger"], ["formControlName", "email_to", "required", "", 1, "form-select", "w-full", "py-1", "text-xs", "text-gray-700", "placeholder:text-white-dark", "dark:bg-gray-800", "dark:text-white-dark", 3, "change"], ["class", "mt-5", 4, "ngIf"], [1, "mt-5"], ["bindLabel", "label", "bindValue", "value", "formControlName", "email_to", "placeholder", "Select User", 1, "custom-multiselect", "et-ng-select", 3, "search", "clear", "clearable", "searchable"], ["type", "email", "formControlName", "email_to", "placeholder", "Enter email address", "required", "", 1, "form-control", "form-input", "w-full", "py-1", "text-xs", "text-gray-600", "placeholder:text-white-dark"], [1, "fa-solid", "fa-xmark", "color-red", "mt-5", "cursor-pointer", "text-xl", 3, "click"], ["formControlName", "send_type", "required", "", 1, "form-select", "w-full", "py-1", "text-xs", "text-gray-700", "placeholder:text-white-dark", "dark:bg-gray-800", "dark:text-white-dark"], ["value", "cc"], ["value", "bcc"], [1, "fa-solid", "fa-xmark", "mt-5", "text-xl", 3, "click"]], template: function EmailTemplateAssignmentComponent_Template(rf, ctx) {
  if (rf & 1) {
    \u0275\u0275elementStart(0, "div", 0)(1, "div", 1)(2, "h5", 2);
    \u0275\u0275text(3);
    \u0275\u0275pipe(4, "translate");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(5, "div", 3)(6, "button", 4);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_Template_button_click_6_listener() {
      return ctx.location.back();
    });
    \u0275\u0275text(7);
    \u0275\u0275pipe(8, "translate");
    \u0275\u0275elementEnd();
    \u0275\u0275elementStart(9, "button", 5);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_Template_button_click_9_listener() {
      return ctx.submit();
    });
    \u0275\u0275text(10, "Submit");
    \u0275\u0275elementEnd()()();
    \u0275\u0275elementStart(11, "div")(12, "form", 6)(13, "div", 7)(14, "div", 8)(15, "div", 9)(16, "label", 10);
    \u0275\u0275text(17);
    \u0275\u0275pipe(18, "translate");
    \u0275\u0275elementStart(19, "span", 11);
    \u0275\u0275text(20, "*");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(21, "select", 12)(22, "option", 13);
    \u0275\u0275text(23, "Please select");
    \u0275\u0275elementEnd();
    \u0275\u0275repeaterCreate(24, EmailTemplateAssignmentComponent_For_25_Template, 2, 2, "option", 14, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd()()();
    \u0275\u0275elementStart(26, "button", 15);
    \u0275\u0275listener("click", function EmailTemplateAssignmentComponent_Template_button_click_26_listener() {
      return ctx.addEmailTemplateAssignment();
    });
    \u0275\u0275text(27, " Add ");
    \u0275\u0275elementEnd()();
    \u0275\u0275elementStart(28, "div", 16);
    \u0275\u0275repeaterCreate(29, EmailTemplateAssignmentComponent_For_30_Template, 36, 15, "div", 17, \u0275\u0275repeaterTrackByIdentity);
    \u0275\u0275elementEnd()()()();
  }
  if (rf & 2) {
    \u0275\u0275advance(3);
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(4, 4, "email_template_assignment_form"), " ");
    \u0275\u0275advance(4);
    \u0275\u0275textInterpolate1(" ", \u0275\u0275pipeBind1(8, 6, "back"), " ");
    \u0275\u0275advance(5);
    \u0275\u0275property("formGroup", ctx.form);
    \u0275\u0275advance(5);
    \u0275\u0275textInterpolate1("", \u0275\u0275pipeBind1(18, 8, "email_template_process"), " ");
    \u0275\u0275advance(7);
    \u0275\u0275repeater(ctx.emailTemplateProcessDetail);
    \u0275\u0275advance(5);
    \u0275\u0275repeater(ctx.getTemplateAssignmentList());
  }
}, dependencies: [FormlyModule, CommonSharedModule, NgIf, \u0275NgNoValidate, NgSelectOption, \u0275NgSelectMultipleOption, DefaultValueAccessor, SelectControlValueAccessor, NgControlStatus, NgControlStatusGroup, RequiredValidator, NgSelectComponent, NgOptionComponent, DynamicFontSizeDirective, TranslatePipe, FormlyBootstrapModule, ReactiveFormsModule, FormGroupDirective, FormControlName, FormGroupName, FormArrayName, FormlyConfigModule, FormsModule, CommonModule, NgSelectModule], styles: ["\n\n.grid[_ngcontent-%COMP%] {\n  display: grid;\n  gap: 1rem;\n}\n.grid-cols-1[_ngcontent-%COMP%] {\n  grid-template-columns: 1fr;\n}\n.md\\:grid-cols-2[_ngcontent-%COMP%] {\n  grid-template-columns: repeat(2, 1fr);\n}\n.email-template-assignments[_ngcontent-%COMP%] {\n  display: grid;\n  grid-template-columns: 2fr 1fr;\n  gap: 1rem;\n  align-items: start;\n}\n.email-template-main[_ngcontent-%COMP%] {\n  display: flex;\n  flex-wrap: wrap;\n  gap: 1rem;\n  align-items: center;\n}\n.email-template-group[_ngcontent-%COMP%] {\n  flex: 1;\n}\n.email-template-cc-bcc[_ngcontent-%COMP%] {\n  display: flex;\n  flex-direction: column;\n  gap: 0.5rem;\n}\n.min-w-200-p[_ngcontent-%COMP%] {\n  min-width: 200px;\n}\n/*# sourceMappingURL=email-template-assignment.component.css.map */"] });
var EmailTemplateAssignmentComponent = _EmailTemplateAssignmentComponent;
(() => {
  (typeof ngDevMode === "undefined" || ngDevMode) && \u0275setClassDebugInfo(EmailTemplateAssignmentComponent, { className: "EmailTemplateAssignmentComponent", filePath: "src\\app\\@lcp-framework\\pages\\email-template-assignment\\email-template-assignment.component.ts", lineNumber: 24 });
})();
export {
  EmailTemplateAssignmentComponent
};
//# sourceMappingURL=chunk-4LVH2ORC.js.map
