'use strict';

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

function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }

var React = require('react');
var React__default = _interopDefault(React);

/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0

THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.

See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */

var extendStatics = function(d, b) {
    extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return extendStatics(d, b);
};

function __extends(d, b) {
    extendStatics(d, b);
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}

function createCommonjsModule(fn, module) {
	return module = { exports: {} }, fn(module, module.exports), module.exports;
}

var classnames = createCommonjsModule(function (module) {
/*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/
/* global define */

(function () {

	var hasOwn = {}.hasOwnProperty;

	function classNames () {
		var classes = [];

		for (var i = 0; i < arguments.length; i++) {
			var arg = arguments[i];
			if (!arg) continue;

			var argType = typeof arg;

			if (argType === 'string' || argType === 'number') {
				classes.push(arg);
			} else if (Array.isArray(arg) && arg.length) {
				var inner = classNames.apply(null, arg);
				if (inner) {
					classes.push(inner);
				}
			} else if (argType === 'object') {
				for (var key in arg) {
					if (hasOwn.call(arg, key) && arg[key]) {
						classes.push(key);
					}
				}
			}
		}

		return classes.join(' ');
	}

	if ( module.exports) {
		classNames.default = classNames;
		module.exports = classNames;
	} else {
		window.classNames = classNames;
	}
}());
});

var Button = /** @class */ (function (_super) {
    __extends(Button, _super);
    function Button() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(Button.prototype, "labelRender", {
        get: function () {
            if (!this.props.label)
                return null;
            return (React__default.createElement("span", { className: "c-button__text" }, this.props.label));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Button.prototype, "renderIcon", {
        get: function () {
            if (!this.props.icon)
                return null;
            var className = classnames(this.props.icon, {
                'c-button__icon-left': this.props.iconPos !== 'right',
                'c-button__icon-right': this.props.iconPos === 'right'
            });
            return (React__default.createElement("span", { className: className }));
        },
        enumerable: true,
        configurable: true
    });
    Button.prototype.render = function () {
        var _a;
        var classes = classnames("c-button", (_a = {},
            _a["c-button--" + this.props.color] = !!this.props.color,
            _a["c-button--raised"] = this.props.raised,
            _a["c-button--rounded"] = this.props.rounded,
            _a["c-button--icon-only"] = !this.props.label && this.props.icon,
            _a["c-button--text-only"] = this.props.label && !this.props.icon,
            _a));
        return (React__default.createElement("button", { className: classes, style: this.props.style },
            this.props.iconPos == "left" && this.renderIcon,
            this.labelRender,
            this.props.iconPos == "right" && this.renderIcon));
    };
    Button.defaultProps = {
        iconPos: "left"
    };
    return Button;
}(React.Component));

var Card = /** @class */ (function (_super) {
    __extends(Card, _super);
    function Card() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Object.defineProperty(Card.prototype, "renderHeader", {
        get: function () {
            return React__default.createElement("div", { className: "c-card__header" }, this.props.header);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Card.prototype, "renderBody", {
        get: function () {
            var title, subTitle, footer, children;
            if (this.props.title) {
                title = React__default.createElement("div", { className: "c-card__title" }, this.props.title);
            }
            if (this.props.subTitle) {
                subTitle = React__default.createElement("div", { className: "c-card__subtitle" }, this.props.subTitle);
            }
            if (this.props.footer) {
                footer = React__default.createElement("div", { className: "c-card__footer" },
                    " ",
                    this.props.footer);
            }
            if (this.props.children) {
                children = React__default.createElement("div", { className: classnames("c-card__content", this.props.classNameContent) },
                    " ",
                    this.props.children,
                    " ");
            }
            return (React__default.createElement("div", { className: classnames("c-card__body", this.props.classNameBody, { "c-card__body--no-padding": this.props.bodyNoPadding }) },
                title,
                subTitle,
                children,
                footer));
        },
        enumerable: true,
        configurable: true
    });
    Card.prototype.render = function () {
        var header, body;
        var className = classnames('c-card', this.props.className, {
            "c-card--fluid": this.props.fluid,
        });
        if (this.props.header) {
            header = this.renderHeader;
        }
        body = this.renderBody;
        return (React__default.createElement("div", { className: className, style: this.props.style },
            header,
            body));
    };
    return Card;
}(React.PureComponent));

var RibbonBox = /** @class */ (function (_super) {
    __extends(RibbonBox, _super);
    function RibbonBox(props) {
        return _super.call(this, props) || this;
    }
    RibbonBox.prototype.render = function () {
        return (React.createElement("div", { className: "c-ribbon-box" }, this.props.label));
    };
    return RibbonBox;
}(React.PureComponent));

var Ribbon = /** @class */ (function (_super) {
    __extends(Ribbon, _super);
    function Ribbon(props) {
        return _super.call(this, props) || this;
    }
    Object.defineProperty(Ribbon.prototype, "content", {
        get: function () {
            return (React.createElement("a", null,
                React.createElement("i", { className: this.props.icon }),
                React.createElement("span", null, this.props.title)));
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(Ribbon.prototype, "child", {
        get: function () {
            return (React.createElement(React.Fragment, null,
                this.props.number && React.createElement(RibbonBox, { label: this.props.number }),
                this.content));
        },
        enumerable: true,
        configurable: true
    });
    Ribbon.prototype.render = function () {
        var card = (React.createElement(Card, { fluid: this.props.fluid, style: this.props.style, bodyNoPadding: true, classNameContent: "c-ribbon" }, this.child));
        if (this.props.noCard) {
            return (React.createElement("div", { className: "c-ribbon" }, this.child));
        }
        return card;
    };
    return Ribbon;
}(React.PureComponent));

var ContentSection = /** @class */ (function (_super) {
    __extends(ContentSection, _super);
    function ContentSection(props) {
        return _super.call(this, props) || this;
    }
    ContentSection.prototype.render = function () {
        return (React.createElement("div", { style: this.props.style, className: classnames("c-content-section", this.props.className) }, this.props.children));
    };
    return ContentSection;
}(React.PureComponent));

var FeatureIntro = /** @class */ (function (_super) {
    __extends(FeatureIntro, _super);
    function FeatureIntro(props) {
        return _super.call(this, props) || this;
    }
    FeatureIntro.prototype.render = function () {
        return (React.createElement("div", { style: this.props.style, className: classnames("c-feature-intro", this.props.className) },
            React.createElement("h1", null, this.props.title),
            React.createElement("p", null, this.props.subTitle)));
    };
    return FeatureIntro;
}(React.PureComponent));

var CalcUtils = /** @class */ (function () {
    function CalcUtils() {
    }
    CalcUtils.sum = function (a, b) {
        return a + b;
    };
    CalcUtils.rest = function (a, b) {
        return a - b;
    };
    CalcUtils.mult = function (a, b) {
        return a * b;
    };
    CalcUtils.div = function (a, b) {
        return a / b;
    };
    return CalcUtils;
}());

var ObjectUtils = /** @class */ (function () {
    function ObjectUtils() {
    }
    return ObjectUtils;
}());

var DomHandlerUtils = /** @class */ (function () {
    function DomHandlerUtils() {
    }
    DomHandlerUtils.innerWidth = function (el) {
        if (el) {
            var width = el.offsetWidth;
            var style = getComputedStyle(el);
            width += parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
            return width;
        }
        return 0;
    };
    DomHandlerUtils.width = function (el) {
        if (el) {
            var width = el.offsetWidth;
            var style = getComputedStyle(el);
            width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight);
            return width;
        }
        return 0;
    };
    DomHandlerUtils.getWindowScrollTop = function () {
        var doc = document.documentElement;
        return (window.pageYOffset || doc.scrollTop) - (doc.clientTop || 0);
    };
    DomHandlerUtils.getWindowScrollLeft = function () {
        var doc = document.documentElement;
        return (window.pageXOffset || doc.scrollLeft) - (doc.clientLeft || 0);
    };
    DomHandlerUtils.getOuterWidth = function (el, margin) {
        if (el) {
            var width = el.offsetWidth;
            if (margin) {
                var style = getComputedStyle(el);
                width += parseFloat(style.marginLeft) + parseFloat(style.marginRight);
            }
            return width;
        }
        return 0;
    };
    DomHandlerUtils.getOuterHeight = function (el, margin) {
        if (el) {
            var height = el.offsetHeight;
            if (margin) {
                var style = getComputedStyle(el);
                height += parseFloat(style.marginTop) + parseFloat(style.marginBottom);
            }
            return height;
        }
        return 0;
    };
    DomHandlerUtils.getClientHeight = function (el, margin) {
        if (el) {
            var height = el.clientHeight;
            if (margin) {
                var style = getComputedStyle(el);
                height += parseFloat(style.marginTop) + parseFloat(style.marginBottom);
            }
            return height;
        }
        return 0;
    };
    DomHandlerUtils.getViewport = function () {
        var win = window, d = document, e = d.documentElement, g = d.getElementsByTagName('body')[0], w = win.innerWidth || e.clientWidth || g.clientWidth, h = win.innerHeight || e.clientHeight || g.clientHeight;
        return { width: w, height: h };
    };
    DomHandlerUtils.getOffset = function (el) {
        if (el) {
            var rect = el.getBoundingClientRect();
            return {
                top: rect.top + document.body.scrollTop,
                left: rect.left + document.body.scrollLeft
            };
        }
        return {
            top: 'auto',
            left: 'auto'
        };
    };
    DomHandlerUtils.generateZIndex = function () {
        this.zindex = this.zindex || 999;
        return ++this.zindex;
    };
    DomHandlerUtils.getCurrentZIndex = function () {
        return this.zindex;
    };
    DomHandlerUtils.index = function (element) {
        if (element) {
            var children = element.parentNode.childNodes;
            var num = 0;
            for (var i = 0; i < children.length; i++) {
                if (children[i] === element)
                    return num;
                if (children[i].nodeType === 1)
                    num++;
            }
        }
        return -1;
    };
    DomHandlerUtils.addMultipleClasses = function (element, className) {
        if (element) {
            if (element.classList) {
                var styles = className.split(' ');
                for (var i = 0; i < styles.length; i++) {
                    element.classList.add(styles[i]);
                }
            }
            else {
                var styles = className.split(' ');
                for (var i = 0; i < styles.length; i++) {
                    element.className += ' ' + styles[i];
                }
            }
        }
    };
    DomHandlerUtils.addClass = function (element, className) {
        if (element) {
            if (element.classList)
                element.classList.add(className);
            else
                element.className += ' ' + className;
        }
    };
    DomHandlerUtils.removeClass = function (element, className) {
        if (element) {
            if (element.classList)
                element.classList.remove(className);
            else
                element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
        }
    };
    DomHandlerUtils.hasClass = function (element, className) {
        if (element) {
            if (element.classList)
                return element.classList.contains(className);
            else
                return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
        }
    };
    DomHandlerUtils.find = function (element, selector) {
        return element ? Array.from(element.querySelectorAll(selector)) : [];
    };
    DomHandlerUtils.findSingle = function (element, selector) {
        if (element) {
            return element.querySelector(selector);
        }
        return null;
    };
    DomHandlerUtils.getHeight = function (el) {
        if (el) {
            var height = el.offsetHeight;
            var style = getComputedStyle(el);
            height -= parseFloat(style.paddingTop) + parseFloat(style.paddingBottom) + parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
            return height;
        }
        return 0;
    };
    DomHandlerUtils.getWidth = function (el) {
        if (el) {
            var width = el.offsetWidth;
            var style = getComputedStyle(el);
            width -= parseFloat(style.paddingLeft) + parseFloat(style.paddingRight) + parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth);
            return width;
        }
        return 0;
    };
    DomHandlerUtils.absolutePosition = function (element, target) {
        if (element) {
            var elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
            var elementOuterHeight = elementDimensions.height;
            var elementOuterWidth = elementDimensions.width;
            var targetOuterHeight = target.offsetHeight;
            var targetOuterWidth = target.offsetWidth;
            var targetOffset = target.getBoundingClientRect();
            var windowScrollTop = this.getWindowScrollTop();
            var windowScrollLeft = this.getWindowScrollLeft();
            var viewport = this.getViewport();
            var top_1, left = void 0;
            if (targetOffset.top + targetOuterHeight + elementOuterHeight > viewport.height) {
                top_1 = targetOffset.top + windowScrollTop - elementOuterHeight;
                if (top_1 < 0) {
                    top_1 = windowScrollTop;
                }
            }
            else {
                top_1 = targetOuterHeight + targetOffset.top + windowScrollTop;
            }
            if (targetOffset.left + targetOuterWidth + elementOuterWidth > viewport.width)
                left = Math.max(0, targetOffset.left + windowScrollLeft + targetOuterWidth - elementOuterWidth);
            else
                left = targetOffset.left + windowScrollLeft;
            element.style.top = top_1 + 'px';
            element.style.left = left + 'px';
        }
    };
    DomHandlerUtils.relativePosition = function (element, target) {
        if (element) {
            var elementDimensions = element.offsetParent ? { width: element.offsetWidth, height: element.offsetHeight } : this.getHiddenElementDimensions(element);
            var targetHeight = target.offsetHeight;
            var targetOffset = target.getBoundingClientRect();
            var viewport = this.getViewport();
            var top_2, left = void 0;
            if ((targetOffset.top + targetHeight + elementDimensions.height) > viewport.height) {
                // @ts-ignore
                top_2 = -1 * (elementDimensions.height);
                if (targetOffset.top + top_2 < 0) {
                    top_2 = -1 * targetOffset.top;
                }
            }
            else {
                top_2 = targetHeight;
            }
            // @ts-ignore
            if (elementDimensions.width > viewport.width) {
                // element wider then viewport and cannot fit on screen (align at left side of viewport)
                left = targetOffset.left * -1;
            }
            else {
                // @ts-ignore
                if ((targetOffset.left + elementDimensions.width) > viewport.width) {
                    // element wider then viewport but can be fit on screen (align at right side of viewport)
                    // @ts-ignore
                    left = (targetOffset.left + elementDimensions.width - viewport.width) * -1;
                }
                else {
                    // element fits on screen (align with target)
                    left = 0;
                }
            }
            element.style.top = top_2 + 'px';
            element.style.left = left + 'px';
        }
    };
    DomHandlerUtils.getHiddenElementOuterHeight = function (element) {
        if (element) {
            element.style.visibility = 'hidden';
            element.style.display = 'block';
            var elementHeight = element.offsetHeight;
            element.style.display = 'none';
            element.style.visibility = 'visible';
            return elementHeight;
        }
        return 0;
    };
    DomHandlerUtils.getHiddenElementOuterWidth = function (element) {
        if (element) {
            element.style.visibility = 'hidden';
            element.style.display = 'block';
            var elementWidth = element.offsetWidth;
            element.style.display = 'none';
            element.style.visibility = 'visible';
            return elementWidth;
        }
        return 0;
    };
    DomHandlerUtils.getHiddenElementDimensions = function (element) {
        var dimensions = {};
        if (element) {
            element.style.visibility = 'hidden';
            element.style.display = 'block';
            dimensions.width = element.offsetWidth;
            dimensions.height = element.offsetHeight;
            element.style.display = 'none';
            element.style.visibility = 'visible';
        }
        return dimensions;
    };
    DomHandlerUtils.fadeIn = function (element, duration) {
        if (element) {
            element.style.opacity = 0;
            var last_1 = +new Date();
            var opacity_1 = 0;
            var tick_1 = function () {
                opacity_1 = +element.style.opacity + (new Date().getTime() - last_1) / duration;
                element.style.opacity = opacity_1;
                last_1 = +new Date();
                if (+opacity_1 < 1) {
                    (window.requestAnimationFrame && requestAnimationFrame(tick_1)) || setTimeout(tick_1, 16);
                }
            };
            tick_1();
        }
    };
    DomHandlerUtils.fadeOut = function (element, ms) {
        if (element) {
            var opacity_2 = 1, interval = 50, duration = ms, gap_1 = interval / duration;
            var fading_1 = setInterval(function () {
                opacity_2 -= gap_1;
                if (opacity_2 <= 0) {
                    opacity_2 = 0;
                    clearInterval(fading_1);
                }
                element.style.opacity = opacity_2;
            }, interval);
        }
    };
    DomHandlerUtils.getUserAgent = function () {
        return navigator.userAgent;
    };
    DomHandlerUtils.isIOS = function () {
        return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window['MSStream'];
    };
    DomHandlerUtils.isAndroid = function () {
        return /(android)/i.test(navigator.userAgent);
    };
    DomHandlerUtils.appendChild = function (element, target) {
        if (this.isElement(target))
            target.appendChild(element);
        else if (target.el && target.el.nativeElement)
            target.el.nativeElement.appendChild(element);
        else
            throw new Error('Cannot append ' + target + ' to ' + element);
    };
    DomHandlerUtils.scrollInView = function (container, item) {
        var borderTopValue = getComputedStyle(container).getPropertyValue('borderTopWidth');
        var borderTop = borderTopValue ? parseFloat(borderTopValue) : 0;
        var paddingTopValue = getComputedStyle(container).getPropertyValue('paddingTop');
        var paddingTop = paddingTopValue ? parseFloat(paddingTopValue) : 0;
        var containerRect = container.getBoundingClientRect();
        var itemRect = item.getBoundingClientRect();
        var offset = (itemRect.top + document.body.scrollTop) - (containerRect.top + document.body.scrollTop) - borderTop - paddingTop;
        var scroll = container.scrollTop;
        var elementHeight = container.clientHeight;
        var itemHeight = this.getOuterHeight(item);
        if (offset < 0) {
            container.scrollTop = scroll + offset;
        }
        else if ((offset + itemHeight) > elementHeight) {
            container.scrollTop = scroll + offset - elementHeight + itemHeight;
        }
    };
    DomHandlerUtils.clearSelection = function () {
        if (window.getSelection) {
            // @ts-ignore
            if (window.getSelection().empty) {
                // @ts-ignore
                window.getSelection().empty();
                // @ts-ignore
            }
            else if (window.getSelection().removeAllRanges && window.getSelection().rangeCount > 0 && window.getSelection().getRangeAt(0).getClientRects().length > 0) {
                // @ts-ignore
                window.getSelection().removeAllRanges();
            }
        }
        else if (document['selection'] && document['selection'].empty) {
            try {
                document['selection'].empty();
            }
            catch (error) {
                //ignore IE bug
            }
        }
    };
    DomHandlerUtils.calculateScrollbarWidth = function (el) {
        if (el) {
            var style = getComputedStyle(el);
            return (el.offsetWidth - el.clientWidth - parseFloat(style.borderLeftWidth) - parseFloat(style.borderRightWidth));
        }
        else {
            if (this.calculatedScrollbarWidth != null)
                return this.calculatedScrollbarWidth;
            var scrollDiv = document.createElement("div");
            scrollDiv.className = "p-scrollbar-measure";
            document.body.appendChild(scrollDiv);
            var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
            document.body.removeChild(scrollDiv);
            this.calculatedScrollbarWidth = scrollbarWidth;
            return scrollbarWidth;
        }
    };
    DomHandlerUtils.getBrowser = function () {
        if (!this.browser) {
            var matched = this.resolveUserAgent();
            this.browser = {};
            if (matched.browser) {
                this.browser[matched.browser] = true;
                this.browser['version'] = matched.version;
            }
            if (this.browser['chrome']) {
                this.browser['webkit'] = true;
            }
            else if (this.browser['webkit']) {
                this.browser['safari'] = true;
            }
        }
        return this.browser;
    };
    DomHandlerUtils.resolveUserAgent = function () {
        var ua = navigator.userAgent.toLowerCase();
        var match = /(chrome)[ ]([\w.]+)/.exec(ua) ||
            /(webkit)[ ]([\w.]+)/.exec(ua) ||
            /(opera)(?:.*version|)[ ]([\w.]+)/.exec(ua) ||
            /(msie) ([\w.]+)/.exec(ua) ||
            (ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua)) ||
            [];
        return {
            browser: match[1] || "",
            version: match[2] || "0"
        };
    };
    DomHandlerUtils.isVisible = function (element) {
        return element && element.offsetParent != null;
    };
    DomHandlerUtils.isElement = function (_) {
        return false;
    };
    return DomHandlerUtils;
}());

exports.Button = Button;
exports.CalcUtils = CalcUtils;
exports.Card = Card;
exports.ContentSection = ContentSection;
exports.DomHandlerUtils = DomHandlerUtils;
exports.FeatureIntro = FeatureIntro;
exports.ObjectUtils = ObjectUtils;
exports.Ribbon = Ribbon;
exports.RibbonBox = RibbonBox;
//# sourceMappingURL=index.js.map
