"use strict";(globalThis.webpackChunkPlesk=globalThis.webpackChunkPlesk||[]).push([["app/change-customers-owner"],{3055:(e,t,s)=>{s.r(t),s.d(t,{default:()=>d});var i=s(90);class n extends i.ConfirmationPopupManager.PopupForm{_initConfiguration(e){super._initConfiguration({locale:i.Locale.getSection("admin.components.confirmations.change-customer-owner"),...e})}_onSuccessPreparePopup(e){if(this._clearMessages(),this._owners=$H(),this._response=e,"success"===this._response.status){document.getElementById(this._formBoxAreaId).innerHTML=`

${this.lmsg("ownerHint")}

${this.getOwnerSelectorHtml()}`,document.getElementById("owners").addEventListener("change",this.onOwnerChange.bind(this)),document.getElementById(this._formListAreaId).innerHTML=`
`;let e=!1;$H(this._response.customers).each(({value:t})=>{0!==t.subscriptions.length&&(e=!0),this.addCustomer(t)}),e||(document.getElementById(this._formDescriptionId).innerHTML="")}else this._addErrorMessage(this._response.message)}getOwnerSelectorHtml(){let e='",e}onOwnerChange(){$H(this._response.customers).each(({value:e})=>{0!==e.subscriptions.length&&$H(e.subscriptions).each(({value:e})=>{document.getElementById(`plans-box-${e.id}`).innerHTML=this.getPlanSelectorHtml(e),document.getElementById(`ipV4-box-${e.id}`).innerHTML=this.getIpAddressSelectorHtml(e,"ipV4"),document.getElementById(`ipV6-box-${e.id}`).innerHTML=this.getIpAddressSelectorHtml(e,"ipV6")})})}addCustomer(e){if(0===e.subscriptions.length){this._itemClass="odd"===this._itemClass?"even":"odd";const t=`${(0,i.escapeHtml)(e.name)}    `;(0,i.render)(document.getElementById(this._formListItemsAreaId),t)}else{let t=e.name;$H(e.subscriptions).each(({value:e})=>{this.addSubscription(e,t),t=" "})}}addSubscription(e,t){this._itemClass="odd"===this._itemClass?"even":"odd";const s=`${(0,i.escapeHtml)(t)}${(0,i.escapeHtml)(e.name)}${this.getPlanSelectorHtml(e)}${this.getIpAddressSelectorHtml(e,"ipV4")}${this.getIpAddressSelectorHtml(e,"ipV6")}`;(0,i.render)(document.getElementById(this._formListItemsAreaId),s)}getPlanSelectorHtml({id:e}){const t=this.getSelectedOwner();if(0===t.plans.length)return"";let s=`",s}getIpAddressSelectorHtml(e,t){const s=this.getSelectedOwner();if(void 0===s[t])return"";const{id:i}=e;let n=`",e[t].isDedicated&&(n+=`
${this.lmsg("ipAddressHint")}
`),n}getSelectedOwner(){return this._owners.get(document.getElementById("owners").value)}_isValid(){return this._valid=!0,this.getSelectedOwner().id?($H(this._response.customers).each(({value:e})=>{0!==e.subscriptions.length&&$H(e.subscriptions).each(({value:e})=>{if(this._valid){const{id:t}=e,s=document.getElementById(`ipV4-${t}`)?document.getElementById(`ipV4-${t}`).value:0,i=document.getElementById(`ipV6-${t}`)?document.getElementById(`ipV6-${t}`).value:0;s||i||(this._addErrorMessage(this.lmsg("ipAddressNotSelected")),this._valid=!1)}})}),this._valid):(this._addErrorMessage(this.lmsg("ownerNotSelected")),!1)}_getAdditionalParams(e){return e.set("owner-id",document.getElementById("owners").value),document.querySelectorAll(".plans").forEach(({id:t,value:s})=>{e.set(`plans[${t.replace("plans-","")}]`,s)}),document.querySelectorAll(".ipV4").forEach(({id:t,value:s})=>{e.set(`ipV4[${t.replace("ipV4-","")}]`,s)}),document.querySelectorAll(".ipV6").forEach(({id:t,value:s})=>{e.set(`ipV6[${t.replace("ipV6-","")}]`,s)}),e}}const d=n}}]); //# sourceMappingURL=change-customers-owner.js.map?a9da2bfdfc76e9f67f68