1"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[13670,42247],{59(e,t,i){i.d(t,{A:()=>s});class s{static debounce(e,t){let i,s=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return function(){for(var r=arguments.length,n=Array(r),o=0;o<r;o++)n[o]=arguments[o];s&&!i&&setTimeout(e.bind(e,...n),0),clearTimeout(i),i=setTimeout(e.bind(e,...n),t)}}}},68(e,t,i){i.d(t,{A:()=>s});class s{constructor(){this._request=null,this._errorHandlingInternal=!1}get(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",s=this._createPreparedRequest("GET",e,i);return this._sendRequest(s,null,t)}post(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let r=this._createPreparedRequest("POST",e,s);return this._sendRequest(r,t,i)}delete(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let r=this._createPreparedRequest("DELETE",e,s);return this._sendRequest(r,t,i)}patch(e,t,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"application/json";s=this._getContentType(t,s);let r=this._createPreparedRequest("PATCH",e,s);return this._sendRequest(r,t,i)}abort(){if(this._request)return this._request.abort()}setErrorHandlingInternal(e){this._errorHandlingInternal=e}_registerOnLoaded(e,t){t&&(!0===this._errorHandlingInternal?(e.addEventListener("load",()=>{t(e.responseText,e)}),e.addEventListener("abort",()=>{console.warn(`the request to ${e.responseURL} was aborted`)}),e.addEventListener("error",()=>{console.warn(`the request to ${e.responseURL} failed with status ${e.status}`)}),e.addEventListener("timeout",()=>{console.warn(`the request to ${e.responseURL} timed out`)})):e.addEventListener("loadend",()=>{t(e.responseText,e)}))}_sendRequest(e,t,i){return this._registerOnLoaded(e,i),e.send(t),e}_getContentType(e,t){return e instanceof FormData&&(t=!1),t}_createPreparedRequest(e,t,i){return this._request=new XMLHttpRequest,this._request.open(e,t),this._request.setRequestHeader("X-Requested-With","XMLHttpRequest"),i&&this._request.setRequestHeader("Content-type",i),this._request}}},156(e){var t=function(e){var t;return!!e&&"object"==typeof e&&"[object RegExp]"!==(t=Object.prototype.toString.call(e))&&"[object Date]"!==t&&e.$$typeof!==i},i="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function s(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a(Array.isArray(e)?[]:{},e,t):e}function r(e,t,i){return e.concat(t).map(function(e){return s(e,i)})}function n(e){return Object.keys(e).concat(Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[])}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,i,l){(l=l||{}).arrayMerge=l.arrayMerge||r,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=s;var d,h,u=Array.isArray(i);return u!==Array.isArray(e)?s(i,l):u?l.arrayMerge(e,i,l):(h={},(d=l).isMergeableObject(e)&&n(e).forEach(function(t){h[t]=s(e[t],d)}),n(i).forEach(function(t){(!o(e,t)||Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))&&(o(e,t)&&d.isMergeableObject(i[t])?h[t]=(function(e,t){if(!t.customMerge)return a;var i=t.customMerge(e);return"function"==typeof i?i:a})(t,d)(e[t],i[t],d):h[t]=s(i[t],d))}),h)}a.all=function(e,t){if(!Array.isArray(e))throw Error("first argument should be an array");return e.reduce(function(e,i){return a(e,i,t)},{})},e.exports=a},247(e,t,i){i.r(t),i.d(t,{default:()=>d});var s=i(670),r=i(68),n=i(156),o=i.n(n),a=i(795),l=i(724);class d extends s.default{static #e=this.options=o()(s.default.options,{invisibleCheckBoxSelector:".invisible.form-check-input",inputNameSelector:"#b2b-create-form-ou-name-input",multipleTagSelector:".multiple-tag",defaultShippingAddressSelector:"#ouShippingAddess",defaultBillingAddressSelector:"#ouBillingAddess",shippingAddressSelector:".js-ou-shipping-address",billingAddressSelector:".js-ou-billing-address",checkboxAddressSelector:".js-ou-checkbox",paymentMethodSelector:".js-ou-payment-method",shippingMethodSelector:".js-ou-shipping-method",employeeSelector:".js-ou-employee-selection",afterSubmitPath:"/"});init(){super.init(),document.$emitter.subscribe("OrganizationUnitFormValidation/resetChosenEmployees",this._resetChosenEmployees.bind(this)),document.$emitter.subscribe("OrganizationUnit/cancelModal",this._handleModalCancel.bind(this)),this._client=new r.A,this.el.addEventListener("submit",this._onCustomFormSubmit.bind(this))}_resetChosenEmployees(){this.options.chosenEmployeeIds=null,this._onCustomFormSubmit(new Event("submit"))}_afterSubmit(e){l.A.remove(this.el),window.location.href=this.options.afterSubmitPath}_employeeConfirmationHandler(){let e=!0,t=a.A.querySelector(document,this.options.ouConfirmModalSelector,!1);return this.options.chosenEmployeeIds&&(e=this._chosenEmployeesHandler()),!e&&!!t&&(new bootstrap.Modal(t).show(),!0)}_organizationSaveHandler(){return!!this.el.checkValidity()&&(()=>{let e=this.el.getAttribute("action"),t=this.el.getAttribute("method"),i=this._getRequestData();l.A.create(this.el),this._client[t](e,JSON.stringify(i),e=>{let t=JSON.parse(e).id;this._afterSubmit(t)})})}_onCustomFormSubmit(e){e.preventDefault();let t=this._organizationSaveHandler();!t||this._employeeConfirmationHandler()||(this._multipleCheckboxesHandler(),t?.())}_handleModalCancel(){PageLoadingIndicatorUtil.remove();let e=this.el.querySelector('button[type="submit"]');e&&(e.disabled=!1),this.el.reset()}_getRequestData(){let e={name:"",employeeIds:[],shippingAddressIds:[],billingAddressIds:[],paymentMethodIds:[],shippingMethodIds:[],defaultShippingAddressId:"",defaultBillingAddressId:""},t=this.el.querySelector(this.options.inputNameSelector)?.value,i=this.el.querySelector(this.options.employeeSelector),s=i?.querySelectorAll(this.options.multipleTagSelector),r=this.el.querySelectorAll(`${this.options.shippingAddressSelector} ${this.options.checkboxAddressSelector}:checked`),n=this.el.querySelectorAll(`${this.options.billingAddressSelector} ${this.options.checkboxAddressSelector}:checked`),o=this.el.querySelectorAll(`${this.options.paymentMethodSelector} ${this.options.checkboxAddressSelector}:checked`),a=this.el.querySelectorAll(`${this.options.shippingMethodSelector} ${this.options.checkboxAddressSelector}:checked`),l=this.el.querySelector(this.options.defaultShippingAddressSelector),d=this.el.querySelector(this.options.defaultBillingAddressSelector);return e.name=t||"",s?.forEach(t=>{t.dataset.tagId&&e.employeeIds.push(t.dataset.tagId)}),r.forEach(t=>{e.shippingAddressIds.push({id:t.dataset.id,customerAddressId:t.dataset.customerAddressId})}
1),n.forEach(t=>{e.billingAddressIds.push({id:t.dataset.id,customerAddressId:t.dataset.customerAddressId})}),o.forEach(t=>{e.paymentMethodIds.push(t.value)}),a.forEach(t=>{e.shippingMethodIds.push(t.value)}),e.defaultShippingAddressId=l?.dataset.addressId||"",e.defaultBillingAddressId=d?.dataset.addressId||"",e}_chosenEmployeesHandler(){let e=a.A.querySelectorAll(this.el,this.options.multipleTagSelector,!1),t=[];return e.forEach(e=>{let i=e.dataset.tagId;i&&t.push(i)}),this.options.chosenEmployeeIds.every(e=>t.includes(e))}}},670(e,t,i){i.r(t),i.d(t,{default:()=>l});var s=i(737),r=i(59),n=i(683);class o extends n.A{constructor(e,t="before"){super(e,t),this._isValidElement()||console.warn(`[ButtonLoadingIndicatorUtil] Parent element is not of type <button> or <a>. Given element: ${this.parent}`)}create(){if(!this._isValidElement()){console.warn(`[ButtonLoadingIndicatorUtil] Unable to create loading indicator. Parent element is not of type <button> or <a>. Given element: ${this.parent}`);return}if("inner"===this.position){let e=this.parent.getBoundingClientRect().width;this.parent.style.width=`${e}px`}super.create(),this.parent.classList.add(`is-loading-indicator-${this.position}`),this._isButtonElement()?this.parent.disabled=!0:this._isAnchorElement()&&this.parent.classList.add("disabled")}remove(){if(!this.exists()){console.warn(`[ButtonLoadingIndicatorUtil] Unable to remove loading indicator. No indicator present on given element: ${this.parent}`);return}"inner"===this.position&&(this.parent.style.width="auto"),super.remove(),this.parent.classList.remove(`is-loading-indicator-${this.position}`),this._isButtonElement()?this.parent.disabled=!1:this._isAnchorElement()&&this.parent.classList.remove("disabled")}_isValidElement(){return this._isButtonElement()||this._isAnchorElement()}_isButtonElement(){return this.parent?.tagName.toLowerCase()==="button"}_isAnchorElement(){return this.parent?.tagName.toLowerCase()==="a"}}class a extends s.A{static #e=this.options={validation:!0,validateOnSubmit:!0,focusInvalidField:!0,debounceTime:"200",formFieldSelector:"input, textarea, select",loadingIndicator:!0,loadingIndicatorPosition:"inner"};init(){if(!1===this._isFormElement(this.el)){console.error("[FormHandler]: Element is not of type <form>",this.el);return}this.form=this.el,this.submitButtons=this._getSubmitButtons(),this.submittButtonLoaders=[],!0===this.options.validation&&this._initFormValidation(),this._initFormEvents()}set formFields(e){this._formFields=e}get formFields(){return this.options.formFieldSelector?this.form.querySelectorAll(this.options.formFieldSelector):[...this.form.elements]}_initFormEvents(){this.form.addEventListener("submit",this._onFormSubmit.bind(this)),this.form.addEventListener("removeLoader",this.removeLoadingIndicator.bind(this))}_initFormValidation(){window.formValidation.setNoValidate(this.form),this.form.checkValidity=this._checkValidity.bind(this),this._initFieldValidationEvents()}_initFieldValidationEvents(){this.formFields.forEach(e=>{this._initFieldValidation(e)})}_initFieldValidation(e){let t=e.tagName.toLowerCase();e.addEventListener("select"===t?"change":"input",r.A.debounce(window.formValidation.validateField.bind(window.formValidation,e),this.options.debounceTime))}_onFormSubmit(e){if(this.$emitter.publish("beforeSubmit"),!0===this.options.validateOnSubmit){let t=window.formValidation.validateForm(this.form,this.formFields);if(t.length>0){e.preventDefault(),this.$emitter.publish("validationFailed",{invalidFields:t}),!0===this.options.focusInvalidField&&(t[0].scrollIntoView({behavior:"smooth",block:"center"}),t[0].focus());return}}this.$emitter.publish("validSubmit"),!0===this.options.loadingIndicator&&this.addLoadingIndicator()}addLoadingIndicator(){this.submitButtons.forEach(e=>{let t=new o(e,this.options.loadingIndicatorPosition);this.submittButtonLoaders.push(t),t.create()})}removeLoadingIndicator(){this.submittButtonLoaders.forEach(e=>{e.remove()})}_checkValidity(){return 0===window.formValidation.validateForm(this.form,this.formFields).length}_getSubmitButtons(){let e=Array.from(this.form.querySelectorAll("button[type=submit]")),t=this.form.id;if(t){let i=Array.from(document.querySelectorAll(`button[type=submit][form="${t}"]`));e.push(...i)}return e}_isFormElement(e){return"form"===e.tagName.toLowerCase()}}class l extends a{_onFormSubmit(e){super._onFormSubmit(e),this._multipleCheckboxesHandler()}_multipleCheckboxesHandler(){this.el.querySelectorAll(".invisible.form-check-input:not(:checked)").forEach(e
1=>{e.checked=!1,e.dispatchEvent(new Event("input"))})}}},683(e,t,i){i.d(t,{A:()=>n});let s="loader",r={BEFORE:"before",INNER:"inner"};class n{constructor(e,t=r.BEFORE){this.parent=e instanceof Element?e:document.body.querySelector(e),this.position=t}create(){if(!this.exists()){if(this.position===r.INNER){this._previousHTML=this.parent.innerHTML,this.parent.innerHTML=n.getTemplate();return}this.parent.insertAdjacentHTML(this._getPosition(),n.getTemplate())}}remove(){if(this.position===r.INNER){this.parent.innerHTML=this._previousHTML;return}this.parent.querySelectorAll(`.${s}`).forEach(e=>e.remove())}exists(){return this.parent.querySelectorAll(`.${s}`).length>0}_getPosition(){return this.position===r.BEFORE?"afterbegin":"beforeend"}static getTemplate(){return`<div class="${s}" role="status"> 2 <span class="visually-hidden">Loading...</span> 3 </div>`}static SELECTOR_CLASS(){return s}}},707(e,t,i){i.d(t,{A:()=>s});class s{static ucFirst(e){return e.charAt(0).toUpperCase()+e.slice(1)}static lcFirst(e){return e.charAt(0).toLowerCase()+e.slice(1)}static toDashCase(e){return e.replace(/([A-Z])/g,"-$1").replace(/^-/,"").toLowerCase()}static toLowerCamelCase(e,t){let i=s.toUpperCamelCase(e,t);return s.lcFirst(i)}static toUpperCamelCase(e,t){return t?e.split(t).map(e=>s.ucFirst(e.toLowerCase())).join(""):s.ucFirst(e.toLowerCase())}static parsePrimitive(e){try{return/^\d+(.|,)\d+$/.test(e)&&(e=e.replace(",",".")),JSON.parse(e)}catch(t){return e.toString()}}}},724(e,t,i){i.d(t,{A:()=>n});var s=i(683);let r="element-loader-backdrop";class n extends s.A{static create(e){e.classList.add("has-element-loader"),n.exists(e)||(n.appendLoader(e),setTimeout(()=>{let t=e.querySelector(`.${r}`);t&&t.classList.add("element-loader-backdrop-open")},1))}static remove(e){e.classList.remove("has-element-loader");let t=e.querySelector(`.${r}`);t&&t.remove()}static exists(e){return e.querySelectorAll(`.${r}`).length>0}static getTemplate(){return` 4 <div class="${r}"> 5 <div class="loader" role="status"> 6 <span class="visually-hidden">Loading...</span> 7 </div> 8 </div> 9 `}static appendLoader(e){e.insertAdjacentHTML("beforeend",n.getTemplate())}}},737(e,t,i){i.d(t,{A:()=>a});var s=i(156),r=i.n(s),n=i(707);class o{constructor(e=document){this._el=e,e.$emitter=this,this._listeners=[]}publish(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]&&arguments[2],s=new CustomEvent(e,{detail:t,cancelable:i});return this.el.dispatchEvent(s),s}subscribe(e,t){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=this,r=e.split("."),n=i.scope?t.bind(i.scope):t;if(i.once&&!0===i.once){let t=n;n=function(i){s.unsubscribe(e),t(i)}}return this.el.addEventListener(r[0],n),this.listeners.push({splitEventName:r,opts:i,cb:n}),!0}unsubscribe(e){let t=e.split(".");return this.listeners=this.listeners.reduce((e,i)=>([...i.splitEventName].sort().toString()===t.sort().toString()?this.el.removeEventListener(i.splitEventName[0],i.cb):e.push(i),e),[]),!0}reset(){return this.listeners.forEach(e=>{this.el.removeEventListener(e.splitEventName[0],e.cb)}),this.listeners=[],!0}get el(){return this._el}set el(e){this._el=e}get listeners(){return this._listeners}set listeners(e){this._listeners=e}}class a{constructor(e,t={},i=!1){if(!(e instanceof Node)){console.warn(`There is no valid element given while trying to create a plugin instance for "${i}".`);return}this.el=e,this.$emitter=new o(this.el),this._pluginName=this._getPluginName(i),this.options=this._mergeOptions(t),this._initialized=!1,this._registerInstance(),this._init()}init(){console.warn(`The "init" method for the plugin "${this._pluginName}" is not defined. The plugin will not be initialized.`)}update(){}_init(){this._initialized||(this.init(),this._initialized=!0)}_update(){this._initialized&&this.update()}_mergeOptions(e){let t=[this.constructor.options,this.options,e];return t.push(this._getConfigFromDataAttribute()),t.push(this._getOptionsFromDataAttribute()),r().all(t.filter(e=>e instanceof Object&&!(e instanceof Array)).map(e=>e||{}))}_getConfigFromDataAttribute(){let e={};if("function"!=typeof this.el.getAttribute)return e;let t=n.A.toDashCase(this._pluginName),i=this.el.getAttribute(`data-${t}-config`);return i?window.PluginConfigManager.get(this._pluginName,i):e}_getOptionsFromDataAttribute(){let e={};if("function"!=typeof this.el.getAttribute)return e;let t=n.A.toDashCase(this._pluginName),i=this.el.getAttribute(`data-${t}-options`);if(i)try{return JSON.parse(i)}catch(e){console.error(`The data attribute "data-${t}-options" could not be parsed to json: ${e.message}`)}return e}_registerInstance(){window.PluginManager.getPluginInstancesFromElement(this.el).set(this._pluginName,this),window.PluginManager.getPlugin(this._pluginName,!1).get("instances").push(this)}_getPluginName(e){return e||(e=this.constructor.name),e}}},795(e,t,i){i.d(t,{A:()=>r});var s=i(707);class r{static isNode(e){return"object"==typeof e&&null!==e&&(e===document||e===window||e instanceof Node)}static hasAttribute(e,t){if(!r.isNode(e))throw Error("The element must be a valid HTML Node!");return"function"==typeof e.hasAttribute&&e.hasAttribute(t)}static getAttribute(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!1===r.hasAttribute(e,t))throw Error(`The required property "${t}" does not exist!`);
9if("function"!=typeof e.getAttribute){if(i)throw Error("This node doesn't support the getAttribute function!");return}return e.getAttribute(t)}static getDataAttribute(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2],n=t.replace(/^data(|-)/,""),o=s.A.toLowerCamelCase(n,"-");if(!r.isNode(e)){if(i)throw Error("The passed node is not a valid HTML Node!");return}if(void 0===e.dataset){if(i)throw Error("This node doesn't support the dataset attribute!");return}let a=e.dataset[o];if(void 0===a){if(i)throw Error(`The required data attribute "${t}" does not exist on ${e}!`);return a}return s.A.parsePrimitive(a)}static querySelector(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let s=e.querySelector(t)||!1;if(i&&!1===s)throw Error(`The required element "${t}" does not exist in parent node!`);return s}static querySelectorAll(e,t){let i=!(arguments.length>2)||void 0===arguments[2]||arguments[2];if(i&&!r.isNode(e))throw Error("The parent node is not a valid HTML Node!");let s=e.querySelectorAll(t);if(0===s.length&&(s=!1),i&&!1===s)throw Error(`At least one item of "${t}" must exist in parent node!`);return s}static getFocusableElements(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body,t=` 10 input:not([tabindex^="-"]):not([disabled]):not([type="hidden"]), 11 select:not([tabindex^="-"]):not([disabled]), 12 textarea:not([tabindex^="-"]):not([disabled]), 13 button:not([tabindex^="-"]):not([disabled]), 14 a[href]:not([tabindex^="-"]):not([disabled]), 15 [tabindex]:not([tabindex^="-"]):not([disabled]) 16 `;return e.querySelectorAll(t)}static getFirstFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document.body;return this.getFocusableElements(e)[0]}static getLastFocusableElement(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:document,t=this.getFocusableElements(e);return t[t.length-1]}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.