var __awaiter=this&&this.__awaiter||function(n,t,i,r){function u(n){return n instanceof i?n:new i(function(t){t(n)})}return new(i||(i=Promise))(function(i,f){function o(n){try{e(r.next(n))}catch(t){f(t)}}function s(n){try{e(r["throw"](n))}catch(t){f(t)}}function e(n){n.done?i(n.value):u(n.value).then(o,s)}e((r=r.apply(n,t||[])).next())})},Unibase;(function(n){let t;(function(t){let i;(function(i){let r;(function(r){class u extends t.Core.BaseComponent{constructor(){super(...arguments);this.RowIndex=0;this.RuleProviderId=0;this.AutomationMode=0;this.RuleInstance=n.Platform.Automation.Components.Rule.Instance()}jsFiles(){return["platform/automation/managers/rulemanager.js","platform/automation/enums/automationmode.js","platform/automation/components/conditions.js","platform/automation/components/contactselection.js","platform/automation/requests/ruleaction.js","platform/automation/requests/rulecondition.js","platform/forms/components/formviewer/formviewer.js","libs/parsley/parsley.min.js","libs/querybuilder/query-builder.min.js","libs/querybuilder/query-builder.standalone.min.js","libs/querybuilder/query-builder.standalone.js","libs/querybuilder/sql-parser.min.js","libs/notificationbuilder/notificationbuilder.js","platform/apps/managers/stagemanager.js","platform/automation/components/rulebuilder/rulebuilder.rule.js","platform/automation/components/rulebuilder/notificationgroup.js","platform/automation/managers/notificationgroupmanager.js"]}cssFiles(){return[]}html(){return`
Create Notification
Advanced Options
Condition Details
Stage Event
Send To Details
`}load(i,r){return __awaiter(this,void 0,void 0,function*(){var f=this,o,s;n.Platform.Automation.Components.SendNotification.Instance().ActionId=f.ActionId;n.Platform.Automation.Components.SendNotification.Instance().RuleActionData=f.RuleActionData;n.Platform.Automation.Components.SendNotification.Instance().RowIndex=f.RowIndex;n.Platform.Automation.Components.SendNotification.Instance().AutomationMode=f.AutomationMode;n.Platform.Automation.Components.SendNotification.Instance().RuleProviderId=f.RuleProviderId;n.Platform.Automation.Components.SendNotification.Instance().ParentActionId=f.ParentActionId;n.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode=f.IsAutomationMode;yield n.Platform.Automation.Components.NotificationGroup.Instance().LoadNotificationGroups();f.AutomationMode==n.Platform.Automation.Enums.AutomationMode.AdvancedMode&&eval('bizgaze_automation_flow_main.getcontainerid("'+r+'")');f.ParentActionId!=0&&(yield n.Platform.Automation.Components.ContactSelection.Instance().getResultActions(f.ParentActionId),yield n.Platform.Automation.Components.SendNotification.Instance().GetRuleActionInfo(Number(f.ParentActionId)),$("#ddl_NotificationGrp").prop("disabled",!0),$("#creategrp_btn").addClass("d-none"));o=t.Helpers.FileCacheHelper.Instance();yield o.loadJsFileAsync("platform/automation/components/contactselection.js",function(){jQuery(".ContactSelection").html(n.Platform.Automation.Components.ContactSelection.Instance().init(f.RuleProviderId));f.RuleActionData.length!=0&&n.Platform.Automation.Components.SendNotification.Instance().LoadNotificationData(f.RuleActionData)});yield o.loadJsFileAsync("platform/automation/components/externalrecipients.js",function(){jQuery(".ExternalRecipients").html(n.Platform.Automation.Components.ExternalRecipients.Instance().init(f.RuleProviderId));n.Platform.Automation.Components.ExternalRecipients.Instance().load(f.RuleProviderId)});s=_appsettings.server_url()+"/apis/v4/unibase/platform/apps/installedappautocomplete";AutoCompleteHelper.getHelper().Create("#ddl_createinstalledid","#hf_Autocomplete_InstalledApp",s,function(n){var t=n});$("#creategrp_btn").click(function(){n.Platform.Automation.Components.NotificationGroup.Instance().init(0,null,!0)});$("#btnCloseNotification").click(function(){$("#"+r).modal("hide");$("#"+r).remove();n.Platform.Automation.Components.SendNotification.Instance().AutomationMode==n.Platform.Automation.Enums.AutomationMode.NormalMode?n.Platform.Automation.Components.SendNotification.Instance().AutomationMode&&n.Platform.Automation.Components.SendNotification.Instance().IsAutomationMode&&n.Platform.Automation.Components.Rule.Instance().ChangeAction(f.RowIndex,i):eval("bizgaze_automation_flow_main.getpopupclosed()");n.Platform.Automation.Components.Conditions.conditionArray=[]});$(".isparent").change(function(){$(".isparent").is(":checked")?$(".Parentcolumns_info").removeClass("d-none"):$(".Parentcolumns_info").addClass("d-none")});f.RuleInstance.IsStageChangeEvent()?($("#SelectstagesDiv").removeClass("d-none"),yield n.Platform.Automation.Components.SendNotification.Instance().LoadAppStages()):$("#SelectstagesDiv").addClass("d-none");$("#btnSaveNotification").click(function(){let t=n.Platform.Forms.Components.FormViewer.Instance().requiredFieldValidation("frmUnibase_SendNotification");if(t==!1)return MessageHelper.Instance().showError("Mandatory fields are missing","Validate_NotificationAction"),!1;n.Platform.Automation.Components.SendNotification.Instance().SaveNotificationAction(i,r)});$("#ddl_SubjectTokens").change(function(){var n=$("#txtNotifications_MessageSubject").val().toString(),t="{{"+$("#ddl_SubjectTokens option:selected").text()+"}}",i=n.slice(0,u.Instance().tokenposition),r=n.slice(u.Instance().tokenposition,n.length);$("#txtNotifications_MessageSubject").val(i+t+r);$("#ddl_SubjectTokens").val(0)});$("#ddl_BodyTokens").change(function(){var n=$("#txtNotifications_MessageBody").val().toString(),t="{{"+$("#ddl_BodyTokens option:selected").text()+"}}",i=n.slice(0,u.Instance().tokenposition),r=n.slice(u.Instance().tokenposition,n.length);$("#txtNotifications_MessageBody").val(i+t+r);$("#ddl_BodyTokens").val(0)});$("#txtNotifications_MessageBody").focusout(function(n){u.Instance().tokenposition=n.target.selectionStart});$("#txtNotifications_MessageSubject").focusout(function(n){u.Instance().tokenposition=n.target.selectionStart});$("#ddl_NotificationType").val($("#hf_NotificationType").val());let e=f.RuleProviderId;e!=0&&(n.Platform.Automation.Components.SendNotification.Instance().LoadMsgSubjectTokens(e),n.Platform.Automation.Components.SendNotification.Instance().LoadMsgBodyTokens(e),yield n.Platform.Automation.Components.SendNotification.Instance().LoadParentTokens(e),n.Platform.Automation.Components.SendNotification.Instance().LoadRefColumns(e),n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(e,null));i!=""&&n.Platform.Automation.Components.SendNotification.Instance().EditNotificationAction(i,r);$("#ddl_createinstalledid").change(function(){$("#ddl_Form").html("");var t=Number($("#ddl_createinstalledid option:selected").val());t!=0&&n.Platform.Automation.Managers.RuleManager.Instance().getCreateFormsByInstalledAppId(t).then(function(n){if(n.result!=null){var t="";for(let i=0;i"+n.result[i].FormName+"<\/option>";$("#ddl_Form").append(t)}})});$("#ddl_NotificationType").change(function(){$("#ddl_NotificationType").val()=="6"?$("#createform_row").removeClass("hidden"):$("#createform_row").addClass("hidden")})})}ToggleNotificationConditions(){$("#ActionConditionsDiv").toggleClass("hidden");$(".conditionicon").hasClass("fa-angle-down")?($(".conditionicon").removeClass("fa-angle-down").addClass("fa-angle-up"),n.Platform.Automation.Components.ContactSelection.Instance().loadQueryBuilder(n.Platform.Automation.Components.SendNotification.Instance().RuleProviderId,null)):$(".conditionicon").removeClass("fa-angle-up").addClass("fa-angle-down")}ToggleExternalRecipients(){$("#ExternalRecipientsDiv").toggle(function(){$("#btn_ExternalRecipients").addClass("hidden");$("#ExternalRecipientsDiv").removeClass("hidden")})}LoadAppStages(){return __awaiter(this,void 0,void 0,function*(){var t="",i='