'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const balFileUpload_type = require('./bal-file-upload.type-616d69d9.js');
const date = require('./date-575d2aa5.js');
const balClose_i18n = require('./bal-close.i18n-56dddd35.js');
const balDatepicker_i18n = require('./bal-datepicker.i18n-8c3dd510.js');
const balTimeInput_i18n = require('./bal-time-input.i18n-b2bb9182.js');
const balInputStepper_i18n = require('./bal-input-stepper.i18n-dbcd32ab.js');
const balLabel_i18n = require('./bal-label.i18n-a25878af.js');
const initialize = require('./initialize-4f14a981.js');
const balStep_util = require('./bal-step.util-8d81c054.js');
const balTab_util = require('./bal-tab.util-2c3af4d0.js');
const helpers = require('./helpers-46584747.js');
const form = require('./form-2279fb2f.js');
const scroll = require('./scroll-96adb682.js');
const browser = require('./browser-9ac97263.js');
const device = require('./device-13af13af.js');
const overlays = require('./overlays-cc6ecb89.js');
const breakpoints_subject = require('./breakpoints.subject-05580367.js');
const config_utils = require('./config.utils-aef60f18.js');
const config_default = require('./config.default-ab53c2d9.js');
const listener = require('./listener-154f256a.js');
const swipe_subject = require('./swipe.subject-7c290368.js');
require('./_commonjsHelpers-bcc1208a.js');
require('./index.esm-e1cd7aff.js');
require('./index-e6a233be.js');
require('./index-7446596e.js');
require('./icons.constant-f1294def.js');
require('./tokens.esm-6aa178aa.js');
require('./log-71656e64.js');

const i18nBalFieldLabel = {
    de: {
        optional: ' (optional)',
    },
    en: {
        optional: ' (optional)',
    },
    fr: {
        optional: ' (optionnel)',
    },
    it: {
        optional: ' (opzionale)',
    },
    nl: {
        optional: ' (optioneel)',
    },
    es: {
        optional: ' (opcional)',
    },
    pl: {
        optional: ' (opcjonalnie)',
    },
    pt: {
        optional: ' (opcional)',
    },
    sv: {
        optional: ' (frivillig)',
    },
    fi: {
        optional: ' (valinnainen)',
    },
};

const newBalCheckboxOption = (option) => {
    return Object.assign(Object.assign({ interface: 'checkbox', labelHidden: false, flat: false, disabled: false, readonly: false, required: false, hidden: false, invalid: false, checked: false }, option), { label: '', html: option.label });
};

const newBalRadioOption = (option) => {
    return Object.assign(Object.assign({ interface: 'radio', labelHidden: false, flat: false, disabled: false, readonly: false, required: false, hidden: false, invisible: false, invalid: false }, option), { label: '', html: option.label });
};

const newBalOptionValue = (value, label, disabled = false, data) => {
    return {
        value,
        label,
        disabled,
        data,
    };
};
const newBalSingleOptionValue = (valueAndLabel, disabled = false, data) => {
    return newBalOptionValue(valueAndLabel, valueAndLabel, disabled, data);
};

class BalOrientationSubject extends listener.Subject {
    constructor() {
        super(observer => observer.orientationListener(this.state));
        this.listener = new breakpoints_subject.BalWindowResizeListener();
        this.state = device.balDevice.orientation.toObject();
        this.listener.connect();
        this.listener.add(() => {
            const newState = device.balDevice.orientation.toObject();
            if (!this.isEqual(newState)) {
                this.state = newState;
                this.notify(undefined);
            }
        });
    }
    attach(observer) {
        super.attach(observer);
        observer.orientationListener(this.state);
    }
    isEqual(newState) {
        return newState.landscape === this.state.landscape && newState.portrait === this.state.portrait;
    }
}
const balOrientationSubject = new BalOrientationSubject();

class BalModalController {
    constructor() {
        this.tag = 'bal-modal';
    }
    create(options) {
        if (typeof customElements !== 'undefined' && browser.balBrowser.hasDocument) {
            return customElements.whenDefined(this.tag).then(() => {
                const element = document.createElement(this.tag);
                Object.assign(element, options);
                helpers.getAppRoot(document).appendChild(element);
                return new Promise(resolve => helpers.componentOnReady(element, resolve));
            });
        }
        return Promise.resolve();
    }
    async dismissAll(data, role) {
        if (browser.balBrowser.hasDocument) {
            const overlays$1 = overlays.getOverlays(document, this.tag);
            await Promise.all(overlays$1.map(o => o.dismiss(data, role)));
        }
    }
    dismiss(data, role, id) {
        if (browser.balBrowser.hasDocument) {
            const overlay = overlays.getOverlay(document, this.tag, id);
            if (!overlay) {
                return Promise.reject('overlay does not exist');
            }
            return overlay.dismiss(data, role);
        }
        return Promise.resolve(false);
    }
    async getTop() {
        if (browser.balBrowser.hasDocument) {
            return overlays.getOverlay(document, this.tag);
        }
        return;
    }
}
const balModalController = new BalModalController();

const hasTouchSupport = () => device.balDevice.hasTouchScreen;
const isBrowser = (browser$1) => {
    if (browser$1 === 'Safari') {
        return browser.balBrowser.isSafari;
    }
    return false;
};
const getPlatforms = (_win) => breakpoints_subject.balBreakpoints.detect();
const isPlatform = (winOrPlatform, platform) => {
    if (typeof winOrPlatform === 'string') {
        platform = winOrPlatform;
    }
    if (platform) {
        return breakpoints_subject.balBreakpoints.detect().includes(platform);
    }
    return false;
};
const NewBalOptionValue = newBalOptionValue;
const NewBalSingleOptionValue = newBalSingleOptionValue;

Object.defineProperty(exports, 'FileUploadRejectionReason', {
    enumerable: true,
    get: function () {
        return balFileUpload_type.FileUploadRejectionReason;
    }
});
exports.BalDate = date.BalDate;
exports.i18nBalDate = date.i18nBalDate;
exports.i18nBalClose = balClose_i18n.i18nBalClose;
exports.i18nBalDatepicker = balDatepicker_i18n.i18nBalDatepicker;
exports.i18nBalTimeInput = balTimeInput_i18n.i18nBalTimeInput;
exports.i18nBalInputStepper = balInputStepper_i18n.i18nBalInputStepper;
exports.i18nBalLabel = balLabel_i18n.i18nBalLabel;
exports.BalSnackbarController = initialize.BalSnackbarController;
exports.BalToastController = initialize.BalToastController;
exports.balSnackbarController = initialize.balSnackbarController;
exports.balToastController = initialize.balToastController;
exports.initialize = initialize.initializeBaloiseDesignSystem;
exports.initializeBaloiseDesignSystem = initialize.initializeBaloiseDesignSystem;
exports.setupConfig = initialize.setupConfig;
exports.newBalStepOption = balStep_util.newBalStepOption;
exports.newBalTabOption = balTab_util.newBalTabOption;
exports.componentOnReady = helpers.componentOnReady;
exports.deepReady = helpers.deepReady;
exports.getAppRoot = helpers.getAppRoot;
exports.isDescendant = helpers.isDescendant;
exports.shallowReady = helpers.shallowReady;
exports.wait = helpers.wait;
exports.waitAfterFramePaint = helpers.waitAfterFramePaint;
exports.waitAfterIdleCallback = helpers.waitAfterIdleCallback;
exports.waitForComponent = helpers.waitForComponent;
exports.waitForDesignSystem = helpers.waitForDesignSystem;
exports.scrollToFirstInvalidField = form.scrollToFirstInvalidField;
exports.BalScrollHandler = scroll.BalScrollHandler;
exports.balBrowser = browser.balBrowser;
exports.BalDevice = device.BalDevice;
exports.balDevice = device.balDevice;
exports.BalBreakpointSubject = breakpoints_subject.BalBreakpointSubject;
exports.BalBreakpointsUtil = breakpoints_subject.BalBreakpointsUtil;
exports.balBreakpointSubject = breakpoints_subject.balBreakpointSubject;
exports.balBreakpoints = breakpoints_subject.balBreakpoints;
exports.attachToConfig = config_utils.attachToConfig;
exports.detachFromConfig = config_utils.detachFromConfig;
exports.onBalConfigChange = config_utils.onBalConfigChange;
exports.updateBalAllowedLanguages = config_utils.updateBalAllowedLanguages;
exports.updateBalAnimated = config_utils.updateBalAnimated;
exports.updateBalIcons = config_utils.updateBalIcons;
exports.updateBalLanguage = config_utils.updateBalLanguage;
exports.updateBalRegion = config_utils.updateBalRegion;
exports.useBalConfig = config_utils.useBalConfig;
exports.defaultConfig = config_default.defaultConfig;
exports.BalSwipeSubject = swipe_subject.BalSwipeSubject;
exports.BalModalController = BalModalController;
exports.BalOrientationSubject = BalOrientationSubject;
exports.NewBalOptionValue = NewBalOptionValue;
exports.NewBalSingleOptionValue = NewBalSingleOptionValue;
exports.balModalController = balModalController;
exports.balOrientationSubject = balOrientationSubject;
exports.getPlatforms = getPlatforms;
exports.hasTouchSupport = hasTouchSupport;
exports.i18nBalFieldLabel = i18nBalFieldLabel;
exports.isBrowser = isBrowser;
exports.isPlatform = isPlatform;
exports.newBalCheckboxOption = newBalCheckboxOption;
exports.newBalOptionValue = newBalOptionValue;
exports.newBalRadioOption = newBalRadioOption;
exports.newBalSingleOptionValue = newBalSingleOptionValue;
