getModalFocusableData = (modalId) => {
    const { _state, _dom } = globalObj;

    /**
     * Saves all focusable elements inside modal, into the array
     * @param {HTMLElement} modal
     * @param {Element[]} array
     */
    const saveAllFocusableElements = (modal, array) => {
        const focusableElements = getFocusableElements(modal);

        /**
         * Save first and last elements (trap focus inside modal)
         */
        array[0] = focusableElements[0];
        array[1] = focusableElements[focusableElements.length - 1];
    };

    if (modalId === 1 && _state._consentModalExists)
        saveAllFocusableElements(_dom._cm, _state._cmFocusableElements);

    if (modalId === 2 && _state._preferencesModalExists)
        saveAllFocusableElements(_dom._pm, _state._pmFocusableElements);
}
Save reference to first and last focusable elements inside each modal
to prevent losing focus while navigating with TAB
@param {1 | 2} [modalId]