var EC,__extends=this&&this.__extends||(()=>{var e=function(t,n){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){t.__proto__=n}:function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}))(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}})();(t=>{var n,o,r;function e(t,n,o,e){o=r.call(this,o)||this;return o.serviceSelectorControllerName=e,o.controllerName=t,o.actionName=n,o.form=o.component.find("form"),o}n=t.ServiceSelector||(t.ServiceSelector={}),o=n.SsfContractManagement||(n.SsfContractManagement={}),__extends(e,r=n.BaseComponent),e.prototype.initialize=function(){this.bindEvents(),this.initializeValidation()},e.prototype.initializeValidation=function(){this.form.ssfvalidator({showValidationMessages:!0}),this.form.ssfvalidator("addRule","required-contracts-if-needed",$.proxy(this.isValidContractSelection,this),"[data-selector='required-contracts-message']")},e.prototype.startAddingContractsOption=function(){return this.component.find('[data-selector="start-adding-contracts"]')},e.prototype.bindEvents=function(){var n=this;this.startAddingContractsOption().on("click",function(){n.showContractManagement()}),this.component.find('[data-selector="dont-add-contracts"]').on("click",function(){n.hideContractManagement()}),this.component.find("[data-selector='add-new-contract-button']").on("click",function(){return n.openContractDetailsModal()}),this.component.find('[data-selector="continue-button"]').on("click",function(t){return n.submitContractSelection(t)})},e.prototype.submitContractSelection=function(t){this.form.ssfvalidator("validate")||t.preventDefault()},e.prototype.isValidContractSelection=function(){return!this.startAddingContractsOption().is(":checked")||0<this.component.find('[name="selectedContracts"]').filter(function(t,n){return $(n).is(":checked")}).length},e.prototype.showContractManagement=function(){this.yourContractsComponent().show()},e.prototype.yourContractsComponent=function(){return this.component.find('[data-selector="your-contracts"]')},e.prototype.hideContractManagement=function(){this.yourContractsComponent().hide(),$.publish(t.ServiceSelector.Commands.clearContractSelection,this.component[0])},e.prototype.openContractDetailsModal=function(){n.Ajax.sendDataToActionAndUpdate(this.controllerName,this.actionName,null,{serviceSelectorControllerName:this.serviceSelectorControllerName},null,{onSuccess:function(){return n.SppHelper.openModal("#contract-details-popup")}})},o.ContractOverview=e})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var n=function(t,e){return(n=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}))(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}})();(t=>{var e,n;function o(t,e,o){t=n.call(this,t)||this;return t.form=t.component.find("[data-selector='contract-details-form']"),t.controllerName=e,t.serviceSelectorControllerName=o,t.deleteButton=t.component.find("[data-selector='delete-contract-button']"),t.deleteConfirmationBox=t.component.find("[data-selector='delete-confirmation-box']"),t}t=(e=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(e.SsfContractManagement={}),__extends(o,n=e.BaseContractComponent),o.prototype.initialize=function(t){this.bindEvents(),t&&this.deleteButton.show(),this.setupDataScopeTracker(this)},o.prototype.bindEvents=function(){var t=this;this.component.find("[data-selector='save-contract-button']").on("click",function(){return t.saveContract()}),this.component.find("[data-selector='delete-contract-button']").on("click",function(){return t.showDeleteConfirmation()}),this.component.find("[data-selector='delete-contract-cancel-button']").on("click",function(){return t.cancelDelete()}),this.component.find("[data-selector='delete-contract-confirmation-button']").on("click",function(){return t.deleteContract()})},o.prototype.showDeleteConfirmation=function(){this.deleteButton.hide(),this.deleteConfirmationBox.show()},o.prototype.cancelDelete=function(){this.deleteButton.show(),this.deleteConfirmationBox.hide()},o.prototype.saveContract=function(){this.form.ssfvalidator("validate")?this.submit():e.Debug.logToConsole("KO!")},o.prototype.submit=function(){var t=this;e.Ajax.getDataFromAction(this.controllerName,"SaveContract",this.form.find(":input").serialize(),{},null,{useWaitPanel:!0,onSuccess:function(){return t.onSuccessfullySavedContract()},onValidationFailed:function(){return alert("Contract details were invalidated by the backend!")}})},o.prototype.onSuccessfullySavedContract=function(){this.trackChange(!1),this.close(),this.refreshContractsList()},o.prototype.close=function(){this.component.find("[data-selector='close-popup']").click()},o.prototype.deleteContract=function(){var t=this;e.Ajax.sendDataToActionAndUpdate(this.controllerName,"DeleteContract",null,{contractId:this.findContractId()},null,{onSuccess:function(){t.refreshContractsList(),t.close()}})},o.prototype.findContractId=function(){return this.component.find("[data-selector='temporaryId']").val()},o.prototype.refreshContractsList=function(){e.Ajax.sendDataToActionAndUpdate(this.controllerName,"Contracts",null,{divToUpdate:"contracts-list",serviceSelectorController:this.serviceSelectorControllerName},null,null)},t.ContractDetailsModal=o})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var o=function(t,e){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}})();(t=>{var e,n;function o(t,e){t=n.call(this,t)||this;return t.form=t.component.find("[data-selector='contract-details-form']"),t.controllerName=e,t.deleteButton=t.component.find("[data-selector='delete-contract-button']"),t.deleteConfirmationBox=t.component.find("[data-selector='delete-confirmation-box']"),t}t=(e=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(e.SsfContractManagement={}),__extends(o,n=e.BaseContractComponent),o.prototype.initialize=function(t){this.bindEvents(),t&&this.deleteButton.show(),this.setupDataScopeTracker(this)},o.prototype.bindEvents=function(){var t=this;this.component.find("[data-selector='save-contract-button']").on("click",function(){return t.saveContract()}),this.component.find("[data-selector='delete-contract-button']").on("click",function(){return t.showDeleteConfirmation()}),this.component.find("[data-selector='delete-contract-cancel-button']").on("click",function(){return t.cancelDelete()}),this.component.find("[data-selector='delete-contract-confirmation-button']").on("click",function(){return t.deleteContract()})},o.prototype.showDeleteConfirmation=function(){this.deleteButton.hide(),this.deleteConfirmationBox.show()},o.prototype.cancelDelete=function(){this.deleteButton.show(),this.deleteConfirmationBox.hide()},o.prototype.saveContract=function(){this.form.ssfvalidator("validate")?this.submit():e.Debug.logToConsole("KO!")},o.prototype.submit=function(){var t=this;e.Ajax.getDataFromAction(this.controllerName,"SaveContract",this.form.find(":input").serialize(),{},null,{useWaitPanel:!0,onSuccess:function(){t.trackChange(!1),t.onContractChanged()},onValidationFailed:function(){return alert("Contract details were invalidated by the backend!")}})},o.prototype.refreshParent=function(){var t=this.component.parents("[data-service-selector-controller]").data("serviceSelectorController");e.Ajax.sendDataToActionAndUpdate(t,"LoadSummaryModal","",{},null,{})},o.prototype.onContractChanged=function(){$.publish(e.Events.contractInformationChanged)},o.prototype.deleteContract=function(){var t=this;e.Ajax.sendDataToActionAndUpdate(this.controllerName,"DeleteContract",null,{contractId:this.findContractId()},null,{onSuccess:function(){t.onContractChanged()}})},o.prototype.findContractId=function(){return this.component.find("[data-selector='temporaryId']").val()},t.EditContract=o})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var o=function(t,n){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])}))(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function e(){this.constructor=t}o(t,n),t.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}})();(t=>{var a,e;function n(t,n){t=e.call(this,t)||this;return t.form=t.component.find("[data-selector='contract-details-form']"),t.controllerName=n,t}t=(a=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(a.SsfContractManagement={}),__extends(n,e=a.BaseContractComponent),n.prototype.initialize=function(t){this.bindEvents(),this.setupDataScopeTracker(this)},n.prototype.bindEvents=function(){var t=this;this.component.find("[data-selector='save-contract-button']").on("click",function(){return t.addContract()}),this.component.find("[data-selector='cancel-contract-button']").on("click",function(){return t.onCancelContract()}),this.subscribeToEvents()},n.prototype.subscribeToEvents=function(){var t=this;$.unsubscribe(a.Events.contractInformationChanged),$.subscribe(a.Events.contractInformationChanged,function(){return t.onContractInformationChanged()})},n.prototype.addContract=function(){this.form.ssfvalidator("validate")?this.submit():a.Debug.logToConsole("KO!")},n.prototype.submit=function(){var t=this;a.Ajax.getDataFromAction(this.controllerName,"SaveContract",this.form.find(":input").serialize(),{},null,{useWaitPanel:!0,onSuccess:function(){return t.onContractInformationChanged()},onValidationFailed:function(){return alert("Contract details were invalidated by the backend!")}})},n.prototype.onContractInformationChanged=function(){var t=this,n=(this.trackChange(!1),this.findContractHtmlElementsThatCanBeAddedToProfile().filter(":checked").map(function(t,n){return $(n).data("value")}).toArray()),e=this.findContractHtmlElementsThatCanBeAddedToProfile().map(function(t,n){return $(n).data("value")}).toArray(),o=this.component.parents("[data-service-selector-controller-name]").data("serviceSelectorControllerName"),r=$("[data-selector='related-contracts']").attr("id");a.Ajax.sendDataToActionAndUpdate(o,"RefreshContractsOfProfile","",{divToUpdate:r},null,{onSuccess:function(){return t.selectContractsIncludingNewlyCreated(e,n)}})},n.prototype.onCancelContract=function(){var t=this.component.parents("[data-selector='summary-add-profile-box']");a.Ajax.sendDataToActionAndUpdate(this.controllerName,"ResetAddContractToProfile","",{divToUpdate:this.component.parents("[data-selector='add-contract-to-profile-box']")[0].id},null,{onSuccess:function(){return t.slideToggle()}})},n.prototype.findContractHtmlElementsThatCanBeAddedToProfile=function(){return $('[data-selector="unselected-related-contract-id"]')},n.prototype.selectContractsIncludingNewlyCreated=function(e,o){var r=this,t=this.findContractHtmlElementsThatCanBeAddedToProfile(),n=t.filter(function(t,n){return!r.isAnElementOf(e,n)}),a=t.filter(function(t,n){return r.isAnElementOf(o,n)}).add(n);a.each(function(t,n){return r.select(n)}),t.filter(function(t,n){return-1===a.index(n)}).each(function(t,n){return r.unselect(n)})},n.prototype.isAnElementOf=function(t,n){n=$(n).data("value");return-1!==t.indexOf(n)},n.prototype.select=function(t){t=$(t);t.val("true"),t.prop("checked",!0)},n.prototype.unselect=function(t){t=$(t);t.val("false"),t.prop("checked",!1)},t.AddContractToProfile=n})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var r=function(t,e){return(r=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}))(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function i(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}})();(t=>{var r,n;function e(t,e,i){void 0===i&&(i=!1);t=n.call(this,t)||this;return t.form=t.component.find("[data-selector='contract-details-form']"),t.controllerName=e,t.tariffSelection=t.component.find("[data-selector='select-tariff']"),t.isSelfManagementContext=i,t}t=(r=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(r.SsfContractManagement={}),__extends(e,n=r.BaseComponent),e.prototype.initialize=function(t){this.initializeEuroConsumersDropdowns(),this.initializeValidation(),this.bindEvents(),this.setupDataScopeTracker(this)},e.prototype.initializeEuroConsumersDropdowns=function(){this.form.find(".form__field--select").data("uniformed")&&$.uniform.restore(this.form.find(".form__field--select")),this.form.find(".form__field--select").uniform(r.Constants.jqueryUniformDefaultOptions)},e.prototype.initializeValidation=function(){this.form.ssfvalidator({showValidationMessages:!0,showSummary:!1,summarySelector:"[data-selector=validation-summary]"})},e.prototype.bindEvents=function(){var e=this;this.component.find(this.findProvider()).on("change",function(t){return e.reloadTariffs($(t.target).val())}),this.component.find(this.findSingleServices()).on("change",function(){e.clearTariffs(),e.reloadTariffs(e.findProvider().val())})},e.prototype.reloadTariffs=function(t){var e;t?(e=this.findSingleServices().filter(":checked").map(function(t,e){return $(e).val()}).toArray(),this.loadTariffs(t,e)):this.clearTariffs()},e.prototype.clearTariffs=function(){this.tariffSelection.children().not("[data-placeholder]").remove(),this.tariffSelection.attr("selectedIndex",0),this.tariffSelection.trigger("change")},e.prototype.loadTariffs=function(t,e){var i=this;r.Ajax.getDataFromAction(this.controllerName,"Tariffs",null,{providerId:t,selectedServiceIds:e,isSelfManagementContext:this.isSelfManagementContext},null,{onSuccess:function(t){return i.renderTariffs(t)}})},e.prototype.renderTariffs=function(t){var e=this;this.clearTariffs(),t.forEach(function(t){return e.addTariff(t)}),this.tariffSelection.find("[data-placeholder-other]").insertAfter(this.tariffSelection.find("option:last"))},e.prototype.addTariff=function(t){this.tariffSelection.append($("<option/>").attr("value",t.Id).text(t.Name))},e.prototype.findProvider=function(){return $('[data-selector="select-provider"]')},e.prototype.findSingleServices=function(){return $('[data-selector="single-service"]')},t.ContractDetails=e})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var o=function(t,e){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}})();(e=>{var n,t,o,r;function c(t){var e=o.call(this,t)||this,t=n.InitHelpers.readInitData(t);return e.serviceSelectorControllerName=t.controllerName,e.initialize(),e}n=e.ServiceSelector||(e.ServiceSelector={}),t=n.SsfContractManagement||(n.SsfContractManagement={}),__extends(c,o=n.BaseComponentNew),c.prototype.initialize=function(){this.bindEditContractEvents(),this.subscribeToEvents(),this.component.find("a.asr__contract__choice").on("click",function(t){t.preventDefault(),$(this).toggleClass("asr__contract__choice--checked"),$(this).children().first().prop("checked",!$(this).children().first().prop("checked"))})},c.prototype.subscribeToEvents=function(){var t=this;$.subscribe(e.ServiceSelector.Commands.clearContractSelection,function(){t.unselectAllContracts()})},c.prototype.unselectAllContracts=function(){this.component.find("a.asr__contract__choice").each(function(t,e){$(e).removeClass("asr__contract__choice--checked"),$(e).children().prop("checked",!1)})},c.prototype.bindEditContractEvents=function(){var e=this;this.component.find('[data-selector="edit-contract"]').on("click",function(t){t.preventDefault();t=$(t.currentTarget).data("contract-id").toString();e.openContractDetailsModal(t)}),this.component.find('[data-selector="add-new-contract-button-list"]').on("click",function(t){t.preventDefault(),e.openContractDetailsModal()})},c.prototype.openContractDetailsModal=function(t){n.Ajax.sendDataToActionAndUpdate("ContractDetails","Details",null,{contractId:t,serviceSelectorControllerName:this.serviceSelectorControllerName},null,{onSuccess:function(){return n.SppHelper.openModal("#contract-details-popup")}})},r=c,t.ContractsList=r,n.InitHelpers.initializeControlsByFactoryMethod("ContractsList",function(t){return new r(t)}),$(document).ajaxComplete(function(){return n.InitHelpers.initializeControlsByFactoryMethod("ContractsList",function(t){return new r(t)})})})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var e=function(t,n){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,n){t.__proto__=n}:function(t,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}))(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function o(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}})();(t=>{var o,n;function e(t){return n.call(this,t)||this}t=(o=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(o.SsfContractManagement={}),__extends(e,n=o.BaseComponent),e.prototype.initialize=function(){this.bindEvents()},e.prototype.bindEvents=function(){var o=this;this.component.find("[data-selector='add-new-contract-button']").on("click",function(t){t.preventDefault();var n=$(t.target).data("servicedomainId"),t=$(t.target).data("servicescopeId");o.openAddContractModal(n,t)}),this.component.find("[data-selector='edit-contract-button']").on("click",function(t){t.preventDefault();t=$(t.target).data("contractId");o.openEditContractModal(t)})},e.prototype.openAddContractModal=function(t,n){o.Ajax.sendDataToActionAndUpdate("MyContractDetails","Details",null,{serviceDomainId:t,serviceScopeId:n},null,{onSuccess:function(){return o.SppHelper.openModal("#contract-details-popup")}})},e.prototype.openEditContractModal=function(t){o.Ajax.sendDataToActionAndUpdate("MyContractDetails","Details",null,{contractId:t},null,{onSuccess:function(){return o.SppHelper.openModal("#contract-details-popup")}})},t.MyContractsList=e})(EC=EC||{});;
var EC,__extends=this&&this.__extends||(()=>{var o=function(t,e){return(o=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}})();(t=>{var n,o;function e(t,e){t=o.call(this,t)||this;return t.form=t.component.find("[data-selector='contract-details-form']"),t.controllerName=e,t.deleteButton=t.component.find("[data-selector='delete-contract-button']"),t.deleteConfirmationBox=t.component.find("[data-selector='delete-confirmation-box']"),t}t=(n=t.ServiceSelector||(t.ServiceSelector={})).SsfContractManagement||(n.SsfContractManagement={}),__extends(e,o=n.BaseContractComponent),e.prototype.initialize=function(t){this.bindEvents(),t&&this.deleteButton.show(),this.setupDataScopeTracker(this)},e.prototype.bindEvents=function(){var t=this;this.component.find("[data-selector='save-contract-button']").on("click",function(){return t.saveContract()}),this.component.find("[data-selector='delete-contract-button']").on("click",function(){return t.showDeleteConfirmation()}),this.component.find("[data-selector='delete-contract-cancel-button']").on("click",function(){return t.cancelDelete()}),this.component.find("[data-selector='delete-contract-confirmation-button']").on("click",function(){return t.deleteContract()})},e.prototype.showDeleteConfirmation=function(){this.deleteButton.hide(),this.deleteConfirmationBox.show()},e.prototype.cancelDelete=function(){this.deleteButton.show(),this.deleteConfirmationBox.hide()},e.prototype.saveContract=function(){this.form.ssfvalidator("validate")?this.submit():n.Debug.logToConsole("KO!")},e.prototype.submit=function(){var t=this;n.Ajax.getDataFromAction(this.controllerName,"SaveContract",this.form.find(":input").serialize(),{},null,{useWaitPanel:!0,onSuccess:function(){return t.onSuccessfullySavedContract()},onValidationFailed:function(){return alert("Contract details were invalidated by the backend!")}})},e.prototype.onSuccessfullySavedContract=function(){this.trackChange(!1),this.close(),this.refreshCurrentContractsTab()},e.prototype.close=function(){this.component.find("[data-selector='close-popup']").click()},e.prototype.deleteContract=function(){var t=this;n.Ajax.sendDataToActionAndUpdate(this.controllerName,"DeleteContract",null,{contractId:this.findContractId()},null,{onSuccess:function(){t.refreshCurrentContractsTab(),t.close()}})},e.prototype.findContractId=function(){return this.component.find("[data-selector='contractId']").val()},e.prototype.refreshCurrentContractsTab=function(){var t=this.component.parents().find('[data-selector="my-contracts-list"]')[0].id,e=this.component.parents().find("#filter-by").val();this.component.closest("body").hasClass("context-mycontracts")&&n.Ajax.sendDataToActionAndUpdate("SSFMyContractOverviewV2","MyContractsList",null,{divToUpdate:t,activeTab:!0,serviceDomainId:e},null,null)},t.MyContractDetailsModal=e})(EC=EC||{});;
