setLayout = (modal, allowedLayoutsObj, userGuiOptions, modalClassPrefix, defaultLayoutName, modalClassName) => {
    /**
     * Reset modal classes to default
     */
    modal.className = modalClassName;

    const layout = userGuiOptions && userGuiOptions.layout;
    const position = userGuiOptions && userGuiOptions.position;
    const flipButtons = userGuiOptions && userGuiOptions.flipButtons;
    const equalWeightButtons = !userGuiOptions || userGuiOptions.equalWeightButtons !== false;

    const layoutSplit = layout && layout.split(' ') || [];

    const layoutName = layoutSplit[0];
    const layoutVariant = layoutSplit[1];

    const currentLayoutName = layoutName in allowedLayoutsObj
        ? layoutName
        : defaultLayoutName;

    const currentLayout = allowedLayoutsObj[currentLayoutName];
    const currentLayoutVariant = elContains(currentLayout._variants, layoutVariant) && layoutVariant;

    const positionSplit = position && position.split(' ') || [];
    const positionV = positionSplit[0];

    const positionH = modalClassPrefix === CLASS_CONSTANTS._pmPrefix
        ? positionSplit[0]
        : positionSplit[1];

    const currentPositionV = elContains(currentLayout._alignV, positionV)
        ? positionV
        : currentLayout._defaultAlignV;

    const currentPositionH = elContains(currentLayout._alignH, positionH)
        ? positionH
        : currentLayout._defaultAlignH;

    const addModalClass = className => {
        className && addClass(modal, modalClassPrefix + className);
    };

    addModalClass(currentLayoutName);
    addModalClass(currentLayoutVariant);
    addModalClass(currentPositionV);
    addModalClass(currentPositionH);
    flipButtons && addModalClass('flip');

    const secondaryBtnClass = 'btn--secondary';
    const btnClassPrefix = modalClassName + '__';
    const btnClass = btnClassPrefix + secondaryBtnClass;

    /**
     * Add classes to buttons
     */
    if (modalClassName === 'cm') {
        const {_cmAcceptNecessaryBtn, _cmCloseIconBtn} = globalObj._dom;

        if (_cmAcceptNecessaryBtn) {
            equalWeightButtons
                ? removeClass(_cmAcceptNecessaryBtn, btnClass)
                : addClass(_cmAcceptNecessaryBtn, btnClass);
        }

        if (_cmCloseIconBtn) {
            equalWeightButtons
                ? removeClass(_cmCloseIconBtn, btnClass)
                : addClass(_cmCloseIconBtn, btnClass);
        }
    } else {
        const { _pmAcceptNecessaryBtn } =  globalObj._dom;

        if (_pmAcceptNecessaryBtn) {
            equalWeightButtons
                ? removeClass(_pmAcceptNecessaryBtn, btnClass)
                : addClass(_pmAcceptNecessaryBtn, btnClass);
        }
    }
}
Helper function to set the proper layout classes
@param {HTMLElement} modal
@param {Layouts} allowedLayoutsObj
@param {import("../core/global").GuiModalOption} userGuiOptions
@param {'cm--' | 'pm--'} modalClassPrefix
@param {string} defaultLayoutName
@param {'cm' | 'pm'} modalClassName